@@ -68,19 +68,20 @@ public static void activateHooks() {
68
68
// block "climb hopping" on top of sideways jumpthrus, because this just looks weird.
69
69
On . Celeste . Player . ClimbHopBlockedCheck += onPlayerClimbHopBlockedCheck ;
70
70
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 ) ;
84
85
85
86
// one extra hook that kills the player momentum when hitting a jumpthru so that they don't get "stuck" on them.
86
87
On . Celeste . Player . NormalUpdate += onPlayerNormalUpdate ;
@@ -107,15 +108,15 @@ public static void deactivateHooks() {
107
108
IL . Celeste . Player . OnCollideH -= modCollideChecks ;
108
109
hookOnUpdateSprite ? . Dispose ( ) ;
109
110
111
+ On . Celeste . Player . DuckFreeAt -= preventDuckWhenDashingAgainstJumpthru ;
112
+
110
113
On . Celeste . Player . NormalUpdate -= onPlayerNormalUpdate ;
111
114
}
112
115
113
116
private static void addSidewaysJumpthrusInHorizontalMoveMethods ( ILContext il ) {
114
117
ILCursor cursor = new ILCursor ( il ) ;
115
118
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" ) ) ) {
119
120
Logger . Log ( "SpringCollab2020/SidewaysJumpThru" , $ "Injecting sideways jumpthru check at { cursor . Index } in IL for { il . Method . Name } ") ;
120
121
cursor . Emit ( OpCodes . Ldarg_0 ) ;
121
122
cursor . Emit ( OpCodes . Ldarg_1 ) ;
@@ -205,6 +206,10 @@ private static void modCollideChecks(ILContext il) {
205
206
}
206
207
}
207
208
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
+
208
213
private static void callOrigMethodKeepingEverythingOnStack ( ILCursor cursor , VariableDefinition checkAtPositionStore , bool isSceneCollideCheck ) {
209
214
// store the position in the local variable
210
215
cursor . Emit ( OpCodes . Stloc , checkAtPositionStore ) ;
0 commit comments