Skip to content

Commit

Permalink
fix: EmoteMod wheel is shown when tas press the second jump
Browse files Browse the repository at this point in the history
  • Loading branch information
DemoJameson committed Sep 24, 2023
1 parent 6ca3350 commit e3c2aff
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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;
}
}

0 comments on commit e3c2aff

Please sign in to comment.