From fc9dbe3ab632f8f46cb82c3960ff4a5911b4a055 Mon Sep 17 00:00:00 2001 From: Maddie <52103563+maddie480@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:16:33 +0200 Subject: [PATCH] Use SIDs instead of IDs when looking up flag touch switches Backport of https://github.com/maddie480/MaddieHelpingHand/commit/e1869342e5c3a1e43ee8c0633c7efc40de875f73 and https://github.com/maddie480/MaddieHelpingHand/commit/aa440b1a549c2ed87dcb6da9a864a46109bbe386 --- Entities/FlagTouchSwitch.cs | 5 ++--- SpringCollab2020MapDataProcessor.cs | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Entities/FlagTouchSwitch.cs b/Entities/FlagTouchSwitch.cs index 226c2b3..213ee4c 100644 --- a/Entities/FlagTouchSwitch.cs +++ b/Entities/FlagTouchSwitch.cs @@ -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. diff --git a/SpringCollab2020MapDataProcessor.cs b/SpringCollab2020MapDataProcessor.cs index 0919e3e..f7e6c12 100644 --- a/SpringCollab2020MapDataProcessor.cs +++ b/SpringCollab2020MapDataProcessor.cs @@ -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>>> FlagTouchSwitches = new List>>>(); + // 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>>> FlagTouchSwitches = new Dictionary>>>(); private string levelName; // we want to match multi-room strawberry seeds with the strawberry that has the same name. @@ -23,11 +23,10 @@ class SpringCollab2020MapDataProcessor : EverestMapDataProcessor { levelName = levelName.Substring(4); } } - }, - { + }, { "entity:SpringCollab2020/FlagTouchSwitch", flagTouchSwitch => { string flag = flagTouchSwitch.Attr("flag"); - Dictionary> allTouchSwitchesInMap = FlagTouchSwitches[AreaKey.ID][(int) AreaKey.Mode]; + Dictionary> allTouchSwitchesInMap = FlagTouchSwitches[AreaKey.SID][(int) AreaKey.Mode]; // if no dictionary entry exists for this flag, create one. otherwise, get it. List entityIDs; @@ -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>>()); + if (!FlagTouchSwitches.ContainsKey(AreaKey.SID)) { + // create an entry for the current map SID. + FlagTouchSwitches[AreaKey.SID] = new List>>(); } - 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>()); + FlagTouchSwitches[AreaKey.SID].Add(new Dictionary>()); } // reset the dictionary for the current map and mode. - FlagTouchSwitches[AreaKey.ID][(int) AreaKey.Mode] = new Dictionary>(); + FlagTouchSwitches[AreaKey.SID][(int) AreaKey.Mode] = new Dictionary>(); } public override void End() {