@@ -21,6 +21,7 @@ static class GrandmasterHeartSideHelper {
21
21
private static ILHook hookLobbyJournal ;
22
22
private static ILHook hookOverworldJournal ;
23
23
private static Hook hookLevelExitToLobby ;
24
+ private static ILHook hookPoemColors ;
24
25
25
26
public static void Load ( ) {
26
27
Assembly collabUtils = typeof ( CollabUtils2 . CollabModule ) . Assembly ;
@@ -39,6 +40,19 @@ public static void Load() {
39
40
40
41
IL . Celeste . Level . CompleteArea_bool_bool_bool += modLevelComplete ;
41
42
IL . Celeste . OuiChapterPanel . Render += renderOldGMHSCompletionStamp ;
43
+
44
+ // we are looking for a lambda in Celeste.Mod.CollabUtils2.LobbyHelper.modJournalPoemHeartColors...
45
+ // except it is located in Celeste.Mod.CollabUtils2.LobbyHelper.<>c.<modJournalPoemHeartColors>b__{someRandomNumber}_0.
46
+ // find it by bruteforcing it a bit.
47
+ Type innerType = collabUtils . GetType ( "Celeste.Mod.CollabUtils2.LobbyHelper" ) . GetNestedType ( "<>c" , BindingFlags . NonPublic ) ;
48
+ for ( int i = 0 ; i < 100 ; i ++ ) {
49
+ MethodInfo innerMethod = innerType . GetMethod ( $ "<modJournalPoemHeartColors>b__{ i } _0", BindingFlags . NonPublic | BindingFlags . Instance ) ;
50
+ if ( innerMethod != null ) {
51
+ // found it!
52
+ hookPoemColors = new ILHook ( innerMethod , modifyGMHSeartColor ) ;
53
+ break ;
54
+ }
55
+ }
42
56
}
43
57
44
58
public static void Unload ( ) {
@@ -53,6 +67,9 @@ public static void Unload() {
53
67
54
68
IL . Celeste . Level . CompleteArea_bool_bool_bool -= modLevelComplete ;
55
69
IL . Celeste . OuiChapterPanel . Render -= renderOldGMHSCompletionStamp ;
70
+
71
+ hookPoemColors ? . Dispose ( ) ;
72
+ hookPoemColors = null ;
56
73
}
57
74
58
75
private static bool modIsHeartSide ( Func < string , bool > orig , string sid ) {
@@ -173,5 +190,22 @@ private static void renderOldGMHSCompletionStamp(ILContext il) {
173
190
} ) ;
174
191
}
175
192
}
193
+
194
+ private static void modifyGMHSeartColor ( ILContext il ) {
195
+ ILCursor cursor = new ILCursor ( il ) ;
196
+
197
+ while ( cursor . TryGotoNext ( MoveType . After , instr => instr . MatchLdstr ( "_ZZ_HeartSide_A" ) , instr => instr . MatchCall < string > ( "Concat" ) ) ) {
198
+ Logger . Log ( "SpringCollab2020/GrandmasterHeartSideHelper" , $ "Modifying new GMHS heart color at { cursor . Index } in IL for { il . Method . FullName } ") ;
199
+
200
+ cursor . Emit ( OpCodes . Ldarg_2 ) ; // "poem" argument
201
+ cursor . EmitDelegate < Func < string , string , string > > ( ( orig , poem ) => {
202
+ // alter the check so that it matches on the new GMHS like it does for old GMHS.
203
+ if ( orig == "poem_SpringCollab2020/5-Grandmaster_ZZ_HeartSide_A" && poem == Dialog . Clean ( "poem_SpringCollab2020_5_Grandmaster_ZZ_NewHeartSide_A" ) ) {
204
+ return "poem_SpringCollab2020_5_Grandmaster_ZZ_NewHeartSide_A" ;
205
+ }
206
+ return orig ;
207
+ } ) ;
208
+ }
209
+ }
176
210
}
177
211
}
0 commit comments