@@ -407,33 +407,42 @@ public static IEnumerable<CodeInstruction> LabComponent_UpdateOutputToNext_Trans
407407 {
408408 var matcher = new CodeMatcher ( instructions ) ;
409409
410- matcher . MatchForward ( true , new CodeMatch ( OpCodes . Ldarg_0 ) ,
411- new CodeMatch ( OpCodes . Ldfld , AccessTools . Field ( typeof ( LabComponent ) , nameof ( LabComponent . needs ) ) ) ,
412- new CodeMatch ( OpCodes . Ldc_I4_5 ) , new CodeMatch ( OpCodes . Ldelem_I4 ) ) ;
410+ matcher . MatchForward ( true , new CodeMatch ( OpCodes . Ldc_I4 , 6006 ) ) ;
413411
414412 object leaveLabel = matcher . Advance ( 1 ) . Operand ;
415413
416- matcher . Start ( ) . MatchForward ( false , new CodeMatch ( OpCodes . Ldarg_0 ) ,
414+ matcher . Start ( ) . MatchForward ( false ,
415+ new CodeMatch ( OpCodes . Ldfld , AccessTools . Field ( typeof ( LabComponent ) , nameof ( LabComponent . nextLabId ) ) ) ,
416+ new CodeMatch ( OpCodes . Ldelema ) ,
417417 new CodeMatch ( OpCodes . Ldfld , AccessTools . Field ( typeof ( LabComponent ) , nameof ( LabComponent . needs ) ) ) ,
418418 new CodeMatch ( OpCodes . Ldc_I4_0 ) , new CodeMatch ( OpCodes . Ldelem_I4 ) ) ;
419419
420- matcher . InsertAndAdvance ( new CodeInstruction ( OpCodes . Ldarg_0 ) , new CodeInstruction ( OpCodes . Ldarg_1 ) ,
420+ matcher . InsertAndAdvance (
421421 new CodeInstruction ( OpCodes . Call ,
422422 AccessTools . Method ( typeof ( ResearchLabPatches ) , nameof ( LabComponent_UpdateOutputToNext_Patch_Method ) ) ) ,
423423 new CodeInstruction ( OpCodes . Br , leaveLabel ) ) ;
424424
425+ matcher . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) ) . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) )
426+ . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) ) . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) )
427+ . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) ) . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) )
428+ . SetInstructionAndAdvance ( new CodeInstruction ( OpCodes . Nop ) ) ;
429+
425430 return matcher . InstructionEnumeration ( ) ;
426431 }
427432
428- public static void LabComponent_UpdateOutputToNext_Patch_Method ( ref LabComponent labComponent , LabComponent [ ] labPool )
433+ public static void LabComponent_UpdateOutputToNext_Patch_Method ( LabComponent [ ] labPool , ref LabComponent labComponent )
429434 {
430435 for ( var i = 0 ; i < LabComponent . matrixIds . Length ; i ++ )
431436 {
432- if ( labComponent . matrixServed [ i ] >= 3600 && labPool [ labComponent . nextLabId ] . matrixServed [ i ] < 36000 )
437+ ref LabComponent next = ref labPool [ labComponent . nextLabId ] ;
438+
439+ if ( labComponent . matrixServed [ i ] >= 3600 && next . matrixServed [ i ] < 36000 )
433440 {
441+ int p = ( labComponent . matrixServed [ 0 ] - 7200 ) / 3600 * 3600 ;
442+ if ( p > 36000 ) p = 36000 ;
434443 int num = labComponent . split_inc ( ref labComponent . matrixServed [ i ] , ref labComponent . matrixIncServed [ i ] , 3600 ) ;
435- labPool [ labComponent . nextLabId ] . matrixIncServed [ i ] += num ;
436- labPool [ labComponent . nextLabId ] . matrixServed [ i ] += 3600 ;
444+ next . matrixIncServed [ i ] += num ;
445+ next . matrixServed [ i ] += p ;
437446 }
438447 }
439448 }
0 commit comments