Skip to content

Commit fae096a

Browse files
committed
Make Mini Heart Doors stay open for the duration of the session (when not used with unlock cutscene triggers)
... which makes them more consistent with vanilla heart doors, and with how they behaved before 1.3.7 came out. Those can now be used as vanilla heart door replacement if someone needs them to be approachable from the right, or resizable vertically.
1 parent 972923f commit fae096a

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

DOCUMENTATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ The cutscene will trigger as soon as the player enters it if the conditions are
171171

172172
If you have multiple heart doors in your lobby, and don't want them to open all at the same time (for example because they are referring to different level sets), give your doors different _IDs_ (with the "Door Id" field). You should then use the same ID in the unlock cutscene trigger lo link the door to its trigger.
173173

174+
**Tip:** If you use these doors without an unlock cutscene trigger, they behave like vanilla mini heart doors, but approachable from both sides, with resizable height, and all using their own flags (so opening one won't open all heart gates with the same amount of hearts). You shouldn't use a mix of vanilla heart doors and mini heart doors in the same map though.
175+
174176
### Rainbow Berries
175177

176178
This is a special berry that will appear as a hologram until the player got all silver berries in the level set they're associated to. **Only silver berries count**, golden berries are excluded from this counter.

Entities/MiniHeartDoor.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ private static void modDoorRoutine(ILContext il) {
109109
return orig;
110110
});
111111
}
112+
113+
// add a patch at the place where the vanilla opened_heartgem_door_[heartcount] gets set.
114+
if (refToThis != null && cursor.TryGotoNext(MoveType.After, instr => instr.MatchLdstr("opened_heartgem_door_"))) {
115+
Logger.Log("CollabUtils2/MiniHeartDoor", $"Making mini heart door save its session flag at {cursor.Index} in IL for HeartGemDoor.Routine");
116+
117+
cursor.Emit(OpCodes.Ldarg_0);
118+
cursor.Emit(OpCodes.Ldfld, refToThis);
119+
cursor.EmitDelegate<Action<HeartGemDoor>>(self => {
120+
if (self is MiniHeartDoor door) {
121+
// mini heart doors use their own flags, that allow better differenciation between themselves by using entity ID.
122+
(door.Scene as Level).Session.SetFlag("opened_mini_heart_door_" + door.entityID, true);
123+
}
124+
});
125+
}
112126
}
113127

114128
private static void modDoorColor(ILContext il) {
@@ -134,12 +148,13 @@ private static void modDoorColor(ILContext il) {
134148

135149
private float height;
136150

151+
private EntityID entityID;
137152
public string DoorID;
138153
public string GetDoorSaveDataID(Scene scene) {
139154
return (scene as Level).Session.Area.GetSID() + (string.IsNullOrEmpty(DoorID) ? "" : ":" + DoorID);
140155
}
141156

142-
public MiniHeartDoor(EntityData data, Vector2 offset) : base(data, offset) {
157+
public MiniHeartDoor(EntityData data, Vector2 offset, EntityID entityID) : base(data, offset) {
143158
height = data.Height;
144159
levelSet = data.Attr("levelSet");
145160

@@ -148,12 +163,14 @@ public MiniHeartDoor(EntityData data, Vector2 offset) : base(data, offset) {
148163
color = colors[color];
149164
}
150165

166+
this.entityID = entityID;
151167
DoorID = data.Attr("doorID");
152168
}
153169

154170
public override void Added(Scene scene) {
155-
// if the gate was already opened on that save, open the door right away by setting the flag.
156-
(scene as Level).Session.SetFlag("opened_heartgem_door_" + Requires, CollabModule.Instance.SaveData.OpenedMiniHeartDoors.Contains(GetDoorSaveDataID(scene)));
171+
// if the gate was already opened on that save or in that session, open the door right away by setting the flag.
172+
(scene as Level).Session.SetFlag("opened_heartgem_door_" + Requires,
173+
(scene as Level).Session.GetFlag("opened_mini_heart_door_" + entityID) || CollabModule.Instance.SaveData.OpenedMiniHeartDoors.Contains(GetDoorSaveDataID(scene)));
157174

158175
base.Added(scene);
159176

everest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Name: CollabUtils2
2-
Version: 1.3.7
2+
Version: 1.3.8
33
DLL: bin/Debug/net452/CollabUtils2.dll
44
Dependencies:
55
- Name: Everest

0 commit comments

Comments
 (0)