From f269c85485507c9a0266e4e98c4a36e22c9ce3e0 Mon Sep 17 00:00:00 2001 From: Tyran Date: Sun, 9 Jun 2024 14:32:39 -0500 Subject: [PATCH] fix stopwatch hitbox bug --- .../EverestInterop/Hitboxes/HitboxOptimized.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CelesteTAS-EverestInterop/Source/EverestInterop/Hitboxes/HitboxOptimized.cs b/CelesteTAS-EverestInterop/Source/EverestInterop/Hitboxes/HitboxOptimized.cs index 64b3a751..a83247c9 100644 --- a/CelesteTAS-EverestInterop/Source/EverestInterop/Hitboxes/HitboxOptimized.cs +++ b/CelesteTAS-EverestInterop/Source/EverestInterop/Hitboxes/HitboxOptimized.cs @@ -34,6 +34,18 @@ private static void Initialize() { }); } + //remove overdraw issue with show hitboxes that occurs when using Stopwatch from Spirialis Helper. + //Adds a branch instruction at the beginning of the function that checks whether or not hitboxes are enabled, then returns immediately if they are. + if (ModUtils.GetType("SpirialisHelper", "Celeste.Mod.Spirialis.TimeController")?.GetMethodInfo("DrawTimestopEntities") is { } spirialisDrawMethodInfo) { + spirialisDrawMethodInfo.IlHook((cursor, context) => { + if (cursor.TryGotoNext(MoveType.After, ins => ins.MatchCall("SceneAs"), ins => ins.MatchStloc(0))) { + Instruction cursorNext = cursor.Next; + cursor.EmitDelegate>(IsShowHitboxes); + cursor.Emit(OpCodes.Brfalse, cursorNext).Emit(OpCodes.Ret); + } + }); + } + typeof(Puffer).GetMethodInfo("Explode").HookBefore(self => pufferPushRadius.Add(new Circle(40f, self.X, self.Y))); typeof(Puffer).GetMethod("Render").IlHook((cursor, context) => { if (cursor.TryGotoNext(i => i.MatchLdloc(out _), i => i.MatchLdcI4(28))) {