@@ -68,19 +68,20 @@ public static void activateHooks() {
6868 // block "climb hopping" on top of sideways jumpthrus, because this just looks weird.
6969 On . Celeste . Player . ClimbHopBlockedCheck += onPlayerClimbHopBlockedCheck ;
7070
71- using ( new DetourContext ( ) ) {
72- // mod collide checks to include sideways jumpthrus, so that the player behaves with them like with walls.
73- IL . Celeste . Player . WallJumpCheck += modCollideChecks ; // allow player to walljump off them
74- IL . Celeste . Player . ClimbCheck += modCollideChecks ; // allow player to climb on them
75- IL . Celeste . Player . ClimbBegin += modCollideChecks ; // if not applied, the player will clip through jumpthrus if trying to climb on them
76- IL . Celeste . Player . ClimbUpdate += modCollideChecks ; // when climbing, jumpthrus are handled like walls
77- IL . Celeste . Player . SlipCheck += modCollideChecks ; // make climbing on jumpthrus not slippery
78- IL . Celeste . Player . NormalUpdate += modCollideChecks ; // get the wall slide effect
79- IL . Celeste . Player . OnCollideH += modCollideChecks ; // handle dashes against jumpthrus properly, without "shifting" down
80-
81- // have the push animation when Madeline runs against a jumpthru for example
82- hookOnUpdateSprite = new ILHook ( typeof ( Player ) . GetMethod ( updateSpriteMethodToPatch , BindingFlags . NonPublic | BindingFlags . Instance ) , modCollideChecks ) ;
83- }
71+ // mod collide checks to include sideways jumpthrus, so that the player behaves with them like with walls.
72+ IL . Celeste . Player . WallJumpCheck += modCollideChecks ; // allow player to walljump off them
73+ IL . Celeste . Player . ClimbCheck += modCollideChecks ; // allow player to climb on them
74+ IL . Celeste . Player . ClimbBegin += modCollideChecks ; // if not applied, the player will clip through jumpthrus if trying to climb on them
75+ IL . Celeste . Player . ClimbUpdate += modCollideChecks ; // when climbing, jumpthrus are handled like walls
76+ IL . Celeste . Player . SlipCheck += modCollideChecks ; // make climbing on jumpthrus not slippery
77+ IL . Celeste . Player . NormalUpdate += modCollideChecks ; // get the wall slide effect
78+ IL . Celeste . Player . OnCollideH += modCollideChecks ; // handle dashes against jumpthrus properly, without "shifting" down
79+
80+ // don't make Madeline duck when dashing against a sideways jumpthru
81+ On . Celeste . Player . DuckFreeAt += preventDuckWhenDashingAgainstJumpthru ;
82+
83+ // have the push animation when Madeline runs against a jumpthru for example
84+ hookOnUpdateSprite = new ILHook ( typeof ( Player ) . GetMethod ( updateSpriteMethodToPatch , BindingFlags . NonPublic | BindingFlags . Instance ) , modCollideChecks ) ;
8485
8586 // one extra hook that kills the player momentum when hitting a jumpthru so that they don't get "stuck" on them.
8687 On . Celeste . Player . NormalUpdate += onPlayerNormalUpdate ;
@@ -107,15 +108,15 @@ public static void deactivateHooks() {
107108 IL . Celeste . Player . OnCollideH -= modCollideChecks ;
108109 hookOnUpdateSprite ? . Dispose ( ) ;
109110
111+ On . Celeste . Player . DuckFreeAt -= preventDuckWhenDashingAgainstJumpthru ;
112+
110113 On . Celeste . Player . NormalUpdate -= onPlayerNormalUpdate ;
111114 }
112115
113116 private static void addSidewaysJumpthrusInHorizontalMoveMethods ( ILContext il ) {
114117 ILCursor cursor = new ILCursor ( il ) ;
115118
116- if ( cursor . TryGotoNext ( MoveType . After , instr => instr . MatchCall < Entity > ( "CollideFirst" ) )
117- && cursor . TryGotoNext ( instr => instr . OpCode == OpCodes . Brfalse_S || instr . OpCode == OpCodes . Brtrue_S ) ) {
118-
119+ if ( cursor . TryGotoNext ( MoveType . After , instr => instr . MatchCall < Entity > ( "CollideFirst" ) ) ) {
119120 Logger . Log ( "SpringCollab2020/SidewaysJumpThru" , $ "Injecting sideways jumpthru check at { cursor . Index } in IL for { il . Method . Name } ") ;
120121 cursor . Emit ( OpCodes . Ldarg_0 ) ;
121122 cursor . Emit ( OpCodes . Ldarg_1 ) ;
@@ -205,6 +206,10 @@ private static void modCollideChecks(ILContext il) {
205206 }
206207 }
207208
209+ private static bool preventDuckWhenDashingAgainstJumpthru ( On . Celeste . Player . orig_DuckFreeAt orig , Player self , Vector2 at ) {
210+ return orig ( self , at ) && ! entityCollideCheckWithSidewaysJumpthrus ( self , at , false , false ) ;
211+ }
212+
208213 private static void callOrigMethodKeepingEverythingOnStack ( ILCursor cursor , VariableDefinition checkAtPositionStore , bool isSceneCollideCheck ) {
209214 // store the position in the local variable
210215 cursor . Emit ( OpCodes . Stloc , checkAtPositionStore ) ;
0 commit comments