@@ -407,33 +407,42 @@ public static IEnumerable<CodeInstruction> LabComponent_UpdateOutputToNext_Trans
407
407
{
408
408
var matcher = new CodeMatcher ( instructions ) ;
409
409
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 ) ) ;
413
411
414
412
object leaveLabel = matcher . Advance ( 1 ) . Operand ;
415
413
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 ) ,
417
417
new CodeMatch ( OpCodes . Ldfld , AccessTools . Field ( typeof ( LabComponent ) , nameof ( LabComponent . needs ) ) ) ,
418
418
new CodeMatch ( OpCodes . Ldc_I4_0 ) , new CodeMatch ( OpCodes . Ldelem_I4 ) ) ;
419
419
420
- matcher . InsertAndAdvance ( new CodeInstruction ( OpCodes . Ldarg_0 ) , new CodeInstruction ( OpCodes . Ldarg_1 ) ,
420
+ matcher . InsertAndAdvance (
421
421
new CodeInstruction ( OpCodes . Call ,
422
422
AccessTools . Method ( typeof ( ResearchLabPatches ) , nameof ( LabComponent_UpdateOutputToNext_Patch_Method ) ) ) ,
423
423
new CodeInstruction ( OpCodes . Br , leaveLabel ) ) ;
424
424
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
+
425
430
return matcher . InstructionEnumeration ( ) ;
426
431
}
427
432
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 )
429
434
{
430
435
for ( var i = 0 ; i < LabComponent . matrixIds . Length ; i ++ )
431
436
{
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 )
433
440
{
441
+ int p = ( labComponent . matrixServed [ 0 ] - 7200 ) / 3600 * 3600 ;
442
+ if ( p > 36000 ) p = 36000 ;
434
443
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 ;
437
446
}
438
447
}
439
448
}
0 commit comments