@@ -13,9 +13,14 @@ namespace Celeste.Mod.SpringCollab2020.Entities {
1313 [ Tracked ]
1414 class SidewaysJumpThru : Entity {
1515
16+ private static ILHook hookOnUpdateSprite ;
17+
1618 private static FieldInfo actorMovementCounter = typeof ( Actor ) . GetField ( "movementCounter" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
1719
1820 public static void Load ( ) {
21+ string updateSpriteMethodToPatch = Everest . Loader . DependencyLoaded ( new EverestModuleMetadata { Name = "Everest" , Version = new Version ( 1 , 1432 ) } ) ?
22+ "orig_UpdateSprite" : "UpdateSprite" ;
23+
1924 // implement the basic collision between actors/platforms and sideways jumpthrus.
2025 using ( new DetourContext { Before = { "*" } } ) { // these don't always call the orig methods, better apply them first.
2126 On . Celeste . Actor . MoveHExact += onActorMoveHExact ;
@@ -31,10 +36,12 @@ public static void Load() {
3136 IL . Celeste . Player . ClimbBegin += modCollideChecks ; // if not applied, the player will clip through jumpthrus if trying to climb on them
3237 IL . Celeste . Player . ClimbUpdate += modCollideChecks ; // when climbing, jumpthrus are handled like walls
3338 IL . Celeste . Player . SlipCheck += modCollideChecks ; // make climbing on jumpthrus not slippery
34- IL . Celeste . Player . UpdateSprite += modCollideChecks ; // have the push animation when Madeline runs against a jumpthru for example
3539 IL . Celeste . Player . NormalUpdate += modCollideChecks ; // get the wall slide effect
3640 IL . Celeste . Player . OnCollideH += modCollideChecks ; // handle dashes against jumpthrus properly, without "shifting" down
3741
42+ // have the push animation when Madeline runs against a jumpthru for example
43+ hookOnUpdateSprite = new ILHook ( typeof ( Player ) . GetMethod ( updateSpriteMethodToPatch , BindingFlags . NonPublic | BindingFlags . Instance ) , modCollideChecks ) ;
44+
3845 // one extra hook that kills the player momentum when hitting a jumpthru so that they don't get "stuck" on them.
3946 On . Celeste . Player . NormalUpdate += onPlayerNormalUpdate ;
4047 }
@@ -50,9 +57,9 @@ public static void Unload() {
5057 IL . Celeste . Player . ClimbBegin -= modCollideChecks ;
5158 IL . Celeste . Player . ClimbUpdate -= modCollideChecks ;
5259 IL . Celeste . Player . SlipCheck -= modCollideChecks ;
53- IL . Celeste . Player . UpdateSprite -= modCollideChecks ;
5460 IL . Celeste . Player . NormalUpdate -= modCollideChecks ;
5561 IL . Celeste . Player . OnCollideH -= modCollideChecks ;
62+ hookOnUpdateSprite ? . Dispose ( ) ;
5663
5764 On . Celeste . Player . NormalUpdate -= onPlayerNormalUpdate ;
5865 }
0 commit comments