@@ -758,6 +758,8 @@ public static void PatchLevelLoader(ILContext context, CustomAttribute attrib) {
758758 FieldReference f_currentEntityId = context . Method . DeclaringType . FindField ( "_currentEntityId" ) ! ;
759759 MethodReference m_IsInDoNotLoadIncreased = context . Method . DeclaringType . FindMethod ( "_IsInDoNotLoadIncreased" ) ! ;
760760
761+ MethodReference f_get_Transitioning = context . Method . DeclaringType . FindMethod ( "get_Transitioning" ) ;
762+
761763 ILCursor cursor = new ILCursor ( context ) ;
762764
763765 // Insert our custom entity loader and use it for levelData.Entities and levelData.Triggers
@@ -905,6 +907,24 @@ public static void PatchLevelLoader(ILContext context, CustomAttribute attrib) {
905907 ) ;
906908 cctorCursor . Emit ( OpCodes . Stsfld , f_LoadStrings ) ;
907909 } ) ;
910+
911+ // Reset to apply other patches
912+ cursor . Index = 0 ;
913+
914+ // Patch DelayAltMusic check
915+ // before: if (!levelData.DelayAltMusic) { ... }
916+ // after: if (!levelData.DelayAltMusic || !Transitioning) { ... }
917+ ILLabel setAltMusicLabel = cursor . DefineLabel ( ) ;
918+
919+ cursor . GotoNext ( MoveType . After ,
920+ instr => instr . MatchLdfld ( "Celeste.LevelData" , "DelayAltMusic" )
921+ ) ;
922+ cursor . EmitBrfalse ( setAltMusicLabel ) ;
923+ cursor . EmitLdarg0 ( ) ;
924+ cursor . EmitCallvirt ( f_get_Transitioning ) ;
925+
926+ cursor . Index ++ ; // after the brtrue
927+ cursor . MarkLabel ( setAltMusicLabel ) ;
908928 }
909929
910930 public static void PatchLevelLoaderDecalCreation ( ILContext context , CustomAttribute attrib ) {
0 commit comments