From e3c2affe97301dcb89855333a04dcf418c483519 Mon Sep 17 00:00:00 2001 From: DemoJameson Date: Sun, 24 Sep 2023 14:43:57 +0800 Subject: [PATCH] fix: EmoteMod wheel is shown when tas press the second jump --- .../Source/EverestInterop/DesyncFixer.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs b/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs index 1a295d7d..84216646 100644 --- a/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs +++ b/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs @@ -51,6 +51,11 @@ private static void Initialize() { if (ModUtils.GetType("StrawberryJam2021", "Celeste.Mod.StrawberryJam2021.Entities.CustomAscendManager") is { } ascendManagerType) { ascendManagerType.GetMethodInfo("Routine")?.GetStateMachineTarget().IlHook(MakeRngConsistent); } + + // https://discord.com/channels/403698615446536203/519281383164739594/1154486504475869236 + if (ModUtils.GetType("EmoteMod", "Celeste.Mod.EmoteMod.EmoteWheelModule") is { } emoteModuleType) { + emoteModuleType.GetMethodInfo("Player_Update")?.IlHook(PreventEmoteMod); + } } [Load] @@ -193,4 +198,26 @@ private static void IgnoreSetOccluderCrash(On.Celeste.LightingRenderer.orig_SetO } } } + + private static void PreventEmoteMod(ILCursor ilCursor, ILContext ilContext) { + if (ilCursor.TryGotoNext( + ins => ins.OpCode == OpCodes.Call, + ins => ins.OpCode == OpCodes.Callvirt && ins.Operand.ToString().Contains("::get_EmoteWheelBinding()"), + ins => ins.OpCode == OpCodes.Callvirt, + ins => ins.OpCode == OpCodes.Callvirt && ins.Operand.ToString().Contains("::get_Count()") + )) { + object getSettings = ilCursor.Next.Operand; + object getEmoteWheelBindingSettings = ilCursor.Next.Next.Operand; + ilCursor.Index += 4; + ilCursor + .Emit(OpCodes.Call, getSettings) + .Emit(OpCodes.Callvirt, getEmoteWheelBindingSettings) + .EmitDelegate(IsEmoteWheelBindingPressed); + } + + } + + private static int IsEmoteWheelBindingPressed(int count, ButtonBinding binding) { + return binding.Pressed ? count : 0; + } } \ No newline at end of file