@@ -21,6 +21,8 @@ class UpsideDownJumpThru : JumpThru {
21
21
22
22
private static ILHook playerOrigUpdateHook ;
23
23
24
+ private static readonly Hitbox normalHitbox = new Hitbox ( 8f , 11f , - 4f , - 11f ) ;
25
+
24
26
public static void Load ( ) {
25
27
using ( new DetourContext { Before = { "*" } } ) { // these don't always call the orig methods, better apply them first.
26
28
// fix general actor/platform behavior to make them comply with jumpthrus.
@@ -42,6 +44,9 @@ public static void Load() {
42
44
playerOrigUpdateHook = new ILHook ( typeof ( Player ) . GetMethod ( "orig_Update" ) , filterOutJumpThrusFromCollideChecks ) ;
43
45
IL . Celeste . Player . DashUpdate += filterOutJumpThrusFromCollideChecks ;
44
46
IL . Celeste . Player . RedDashUpdate += filterOutJumpThrusFromCollideChecks ;
47
+
48
+ // listen for the player unducking, to knock the player down before they would go through upside down jumpthrus.
49
+ On . Celeste . Player . Update += onPlayerUpdate ;
45
50
}
46
51
}
47
52
@@ -55,6 +60,8 @@ public static void Unload() {
55
60
playerOrigUpdateHook ? . Dispose ( ) ;
56
61
IL . Celeste . Player . DashUpdate -= filterOutJumpThrusFromCollideChecks ;
57
62
IL . Celeste . Player . RedDashUpdate -= filterOutJumpThrusFromCollideChecks ;
63
+
64
+ On . Celeste . Player . Update -= onPlayerUpdate ;
58
65
}
59
66
60
67
private static bool onActorMoveVExact ( On . Celeste . Actor . orig_MoveVExact orig , Actor self , int moveV , Collision onCollide , Solid pusher ) {
@@ -289,6 +296,25 @@ private static void patchPlayerClimbUpdate(ILContext il) {
289
296
}
290
297
}
291
298
299
+ private static void onPlayerUpdate ( On . Celeste . Player . orig_Update orig , Player self ) {
300
+ bool unduckWouldGoThroughPlatform = self . Ducking && ! self . CollideCheck < UpsideDownJumpThru > ( ) ;
301
+ if ( unduckWouldGoThroughPlatform ) {
302
+ Collider bak = self . Collider ;
303
+ self . Collider = normalHitbox ;
304
+ unduckWouldGoThroughPlatform = self . CollideCheck < UpsideDownJumpThru > ( ) ;
305
+ self . Collider = bak ;
306
+ }
307
+
308
+ orig ( self ) ;
309
+
310
+ if ( unduckWouldGoThroughPlatform && ! self . Ducking ) {
311
+ // we just unducked, and are now inside an upside-down jumpthru.
312
+ // knock the player down if possible!
313
+ while ( self . CollideCheck < UpsideDownJumpThru > ( ) && ! self . CollideCheck < Solid > ( self . Position + new Vector2 ( 0f , 1f ) ) ) {
314
+ self . Position . Y ++ ;
315
+ }
316
+ }
317
+ }
292
318
293
319
294
320
0 commit comments