Skip to content

Commit

Permalink
Use SIDs instead of IDs when looking up flag touch switches
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Sep 4, 2024
1 parent 36ef348 commit fc9dbe3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Entities/FlagTouchSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ private void turnOn() {
level.Session.SetFlag(flag + "_switch" + id, true);
}

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

// all switches in the room are enabled, and all session flags for switches outside the room are enabled.
Expand Down
21 changes: 10 additions & 11 deletions SpringCollab2020MapDataProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace Celeste.Mod.SpringCollab2020 {
class SpringCollab2020MapDataProcessor : EverestMapDataProcessor {

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

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

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

public override void Reset() {
while (FlagTouchSwitches.Count <= AreaKey.ID) {
// fill out the empty space before the current map with empty dictionaries.
FlagTouchSwitches.Add(new List<Dictionary<string, List<EntityID>>>());
if (!FlagTouchSwitches.ContainsKey(AreaKey.SID)) {
// create an entry for the current map SID.
FlagTouchSwitches[AreaKey.SID] = new List<Dictionary<string, List<EntityID>>>();
}
while (FlagTouchSwitches[AreaKey.ID].Count <= (int) AreaKey.Mode) {
while (FlagTouchSwitches[AreaKey.SID].Count <= (int) AreaKey.Mode) {
// fill out the empty space before the current map MODE with empty dictionaries.
FlagTouchSwitches[AreaKey.ID].Add(new Dictionary<string, List<EntityID>>());
FlagTouchSwitches[AreaKey.SID].Add(new Dictionary<string, List<EntityID>>());
}

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

public override void End() {
Expand Down

0 comments on commit fc9dbe3

Please sign in to comment.