Skip to content

Commit

Permalink
feat: first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Jul 14, 2022
1 parent b5928a5 commit bfe27c3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion DoubleJumpFix/DoubleJumpFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

using Modding;

using Mono.Cecil.Cil;

using MonoMod.Cil;

namespace DoubleJumpFix;

public sealed class DoubleJumpFix : Mod {
Expand All @@ -10,6 +14,16 @@ public override string GetVersion() => typeof(DoubleJumpFix)
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;

public override void Initialize() {
public override void Initialize() =>
IL.HeroController.JumpReleased += Fix;

private static void Fix(ILContext il) {
ILLabel label = new ILCursor(il).GotoNext(MoveType.After, i => i.MatchBlt(out _)).MarkLabel();
_ = new ILCursor(il)
.GotoNext(MoveType.After, i => i.MatchBleUn(out _))
.Emit(OpCodes.Ldarg_0)
.Emit(OpCodes.Ldfld, ReflectionHelper.GetFieldInfo(typeof(HeroController), nameof(HeroController.cState)))
.Emit(OpCodes.Ldfld, ReflectionHelper.GetFieldInfo(typeof(HeroControllerStates), nameof(HeroControllerStates.doubleJumping)))
.Emit(OpCodes.Brtrue_S, label);
}
}

0 comments on commit bfe27c3

Please sign in to comment.