Skip to content

Commit fc9dbe3

Browse files
committed
Use SIDs instead of IDs when looking up flag touch switches
Backport of maddie480/MaddieHelpingHand@e186934 and maddie480/MaddieHelpingHand@aa440b1
1 parent 36ef348 commit fc9dbe3

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Entities/FlagTouchSwitch.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ private void turnOn() {
207207
level.Session.SetFlag(flag + "_switch" + id, true);
208208
}
209209

210-
if ((SpringCollab2020MapDataProcessor.FlagTouchSwitches.Count <= level.Session.Area.ID
211-
|| SpringCollab2020MapDataProcessor.FlagTouchSwitches[level.Session.Area.ID][(int) level.Session.Area.Mode][flag]
212-
.All(touchSwitchID => touchSwitchID.Level == level.Session.Level || level.Session.GetFlag(flag + "_switch" + touchSwitchID.ID)))
210+
if (SpringCollab2020MapDataProcessor.FlagTouchSwitches[level.Session.Area.SID][(int) level.Session.Area.Mode][flag]
211+
.All(touchSwitchID => touchSwitchID.Level == level.Session.Level || level.Session.GetFlag(flag + "_switch" + touchSwitchID.ID))
213212
&& allTouchSwitchesInRoom.All(touchSwitch => touchSwitch.activated)) {
214213

215214
// all switches in the room are enabled, and all session flags for switches outside the room are enabled.

SpringCollab2020MapDataProcessor.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
namespace Celeste.Mod.SpringCollab2020 {
55
class SpringCollab2020MapDataProcessor : EverestMapDataProcessor {
66

7-
// the structure here is: FlagTouchSwitches[AreaID][ModeID][flagName] = list of entity ids for flag touch switches in this group on this map.
8-
public static List<List<Dictionary<string, List<EntityID>>>> FlagTouchSwitches = new List<List<Dictionary<string, List<EntityID>>>>();
7+
// the structure here is: FlagTouchSwitches[AreaSID][ModeID][flagName] = list of entity ids for flag touch switches in this group on this map.
8+
public static Dictionary<string, List<Dictionary<string, List<EntityID>>>> FlagTouchSwitches = new Dictionary<string, List<Dictionary<string, List<EntityID>>>>();
99
private string levelName;
1010

1111
// we want to match multi-room strawberry seeds with the strawberry that has the same name.
@@ -23,11 +23,10 @@ class SpringCollab2020MapDataProcessor : EverestMapDataProcessor {
2323
levelName = levelName.Substring(4);
2424
}
2525
}
26-
},
27-
{
26+
}, {
2827
"entity:SpringCollab2020/FlagTouchSwitch", flagTouchSwitch => {
2928
string flag = flagTouchSwitch.Attr("flag");
30-
Dictionary<string, List<EntityID>> allTouchSwitchesInMap = FlagTouchSwitches[AreaKey.ID][(int) AreaKey.Mode];
29+
Dictionary<string, List<EntityID>> allTouchSwitchesInMap = FlagTouchSwitches[AreaKey.SID][(int) AreaKey.Mode];
3130

3231
// if no dictionary entry exists for this flag, create one. otherwise, get it.
3332
List<EntityID> entityIDs;
@@ -71,17 +70,17 @@ class SpringCollab2020MapDataProcessor : EverestMapDataProcessor {
7170
}
7271

7372
public override void Reset() {
74-
while (FlagTouchSwitches.Count <= AreaKey.ID) {
75-
// fill out the empty space before the current map with empty dictionaries.
76-
FlagTouchSwitches.Add(new List<Dictionary<string, List<EntityID>>>());
73+
if (!FlagTouchSwitches.ContainsKey(AreaKey.SID)) {
74+
// create an entry for the current map SID.
75+
FlagTouchSwitches[AreaKey.SID] = new List<Dictionary<string, List<EntityID>>>();
7776
}
78-
while (FlagTouchSwitches[AreaKey.ID].Count <= (int) AreaKey.Mode) {
77+
while (FlagTouchSwitches[AreaKey.SID].Count <= (int) AreaKey.Mode) {
7978
// fill out the empty space before the current map MODE with empty dictionaries.
80-
FlagTouchSwitches[AreaKey.ID].Add(new Dictionary<string, List<EntityID>>());
79+
FlagTouchSwitches[AreaKey.SID].Add(new Dictionary<string, List<EntityID>>());
8180
}
8281

8382
// reset the dictionary for the current map and mode.
84-
FlagTouchSwitches[AreaKey.ID][(int) AreaKey.Mode] = new Dictionary<string, List<EntityID>>();
83+
FlagTouchSwitches[AreaKey.SID][(int) AreaKey.Mode] = new Dictionary<string, List<EntityID>>();
8584
}
8685

8786
public override void End() {

0 commit comments

Comments
 (0)