@@ -21,9 +21,48 @@ 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 ) ;
24
+ private static bool hooksActive = false ;
25
25
26
+ private static readonly Hitbox normalHitbox = new Hitbox ( 8f , 11f , - 4f , - 11f ) ;
27
+
26
28
public static void Load ( ) {
29
+ On . Celeste . LevelLoader . ctor += onLevelLoad ;
30
+ On . Celeste . OverworldLoader . ctor += onOverworldLoad ;
31
+ }
32
+
33
+ public static void Unload ( ) {
34
+ On . Celeste . LevelLoader . ctor -= onLevelLoad ;
35
+ On . Celeste . OverworldLoader . ctor -= onOverworldLoad ;
36
+ deactivateHooks ( ) ;
37
+ }
38
+
39
+ private static void onLevelLoad ( On . Celeste . LevelLoader . orig_ctor orig , LevelLoader self , Session session , Vector2 ? startPosition ) {
40
+ orig ( self , session , startPosition ) ;
41
+
42
+ if ( session . MapData ? . Levels ? . Any ( level => level . Entities ? . Any ( entity => entity . Name == "SpringCollab2020/UpsideDownJumpThru" ) ?? false ) ?? false ) {
43
+ activateHooks ( ) ;
44
+ } else {
45
+ deactivateHooks ( ) ;
46
+ }
47
+ }
48
+
49
+ private static void onOverworldLoad ( On . Celeste . OverworldLoader . orig_ctor orig , OverworldLoader self , Overworld . StartMode startMode , HiresSnow snow ) {
50
+ orig ( self , startMode , snow ) ;
51
+
52
+ if ( startMode != ( Overworld . StartMode ) ( - 1 ) ) { // -1 = in-game overworld from the collab utils
53
+ deactivateHooks ( ) ;
54
+ }
55
+ }
56
+
57
+
58
+ public static void activateHooks ( ) {
59
+ if ( hooksActive ) {
60
+ return ;
61
+ }
62
+ hooksActive = true ;
63
+
64
+ Logger . Log ( LogLevel . Info , "SpringCollab2020/UpsideDownJumpThru" , "=== Activating upside-down jumpthru hooks" ) ;
65
+
27
66
using ( new DetourContext { Before = { "*" } } ) { // these don't always call the orig methods, better apply them first.
28
67
// fix general actor/platform behavior to make them comply with jumpthrus.
29
68
On . Celeste . Actor . MoveVExact += onActorMoveVExact ;
@@ -50,7 +89,14 @@ public static void Load() {
50
89
}
51
90
}
52
91
53
- public static void Unload ( ) {
92
+ public static void deactivateHooks ( ) {
93
+ if ( ! hooksActive ) {
94
+ return ;
95
+ }
96
+ hooksActive = false ;
97
+
98
+ Logger . Log ( LogLevel . Info , "SpringCollab2020/UpsideDownJumpThru" , "=== Deactivating upside-down jumpthru hooks" ) ;
99
+
54
100
On . Celeste . Actor . MoveVExact -= onActorMoveVExact ;
55
101
On . Celeste . Platform . MoveVExactCollideSolids -= onPlatformMoveVExactCollideSolids ;
56
102
0 commit comments