diff --git a/Code/FLCC/TempleGateAllSwitches.cs b/Code/FLCC/TempleGateAllSwitches.cs index 9157913..ec62eba 100644 --- a/Code/FLCC/TempleGateAllSwitches.cs +++ b/Code/FLCC/TempleGateAllSwitches.cs @@ -1,60 +1,49 @@ using Celeste; using Celeste.Mod.Entities; -using MonoMod.Utils; using Microsoft.Xna.Framework; using Monocle; -namespace vitmod -{ +namespace vitmod { [Tracked()] [CustomEntity("vitellary/templegateall")] - public class TempleGateAllSwitches : TempleGate - { - public TempleGateAllSwitches(EntityData data, Vector2 offset) : base(data.Position + offset, 48, Types.NearestSwitch, data.Attr("sprite", "default"), data.Level.Name) - { + public class TempleGateAllSwitches : TempleGate { + public TempleGateAllSwitches(EntityData data, Vector2 offset) : base(data.Position + offset, 48, Types.NearestSwitch, data.Attr("sprite", "default"), data.Level.Name) { ClaimedByASwitch = true; } - public static void Load() - { - On.Celeste.DashSwitch.OnDashed += DashSwitch_OnDashed; + public static void Load() { + On.Celeste.DashSwitch.Awake += DashSwitch_Awake; } - public static void Unload() - { - On.Celeste.DashSwitch.OnDashed -= DashSwitch_OnDashed; + public static void Unload() { + On.Celeste.DashSwitch.Awake -= DashSwitch_Awake; } - private static DashCollisionResults DashSwitch_OnDashed(On.Celeste.DashSwitch.orig_OnDashed orig, DashSwitch self, Player player, Vector2 direction) - { - DashCollisionResults result = orig(self, player, direction); - bool finalswitch = true; - if (self.pressed) - { - foreach (Solid solid in self.SceneAs().Tracker.GetEntities()) - { - if (solid is DashSwitch dashSwitch) - { - if (!dashSwitch.pressed) - { - finalswitch = false; - break; + private static void DashSwitch_Awake(On.Celeste.DashSwitch.orig_Awake orig, DashSwitch self, Scene scene) { + orig(self, scene); + DashCollision orig_OnDashCollide = self.OnDashCollide; + self.OnDashCollide = (Player player, Vector2 direction) => { + DashCollisionResults result = orig_OnDashCollide(player, direction); + bool finalswitch = true; + if (self.pressed) { + foreach (Solid solid in self.SceneAs().Tracker.GetEntities()) { + if (solid is DashSwitch dashSwitch) { + if (!dashSwitch.pressed) { + finalswitch = false; + break; + } } } + } else { + finalswitch = false; } - } - else - { - finalswitch = false; - } - if (finalswitch) - { - foreach (TempleGateAllSwitches gate in self.SceneAs().Tracker.GetEntities()) - { - gate.Open(); + if (finalswitch) { + foreach (TempleGateAllSwitches gate in self.SceneAs().Tracker.GetEntities()) { + gate.Open(); + } } - } - return result; + return result; + }; } } }