@@ -216,18 +216,28 @@ public static IEnumerable<CodeInstruction> FactorySystem_GameTickLabResearchMode
216216 {
217217 var matcher = new CodeMatcher ( instructions ) ;
218218
219+ /*
220+ IL_02f0: ldloc.s local_V_30
221+ IL_02f2: ldloc.s power
222+ IL_02f4: ldloc.s techSpeed
223+ IL_02f6: ldloc.s consumeRegister
224+ IL_02f8: ldloca.s ts
225+ IL_02fa: ldloca.s techHashedThisFrame
226+ IL_02fc: ldloca.s matrixPointUploaded
227+ IL_02fe: ldloca.s hashRegister
228+ IL_0300: call instance unsigned int32 LabComponent::InternalUpdateResearch(float32, float32, int32[], valuetype TechState&, int32&, int64&, int64&)
229+ IL_0305: stloc.s _state
230+ */
231+
219232 matcher . MatchForward ( false ,
220233 new CodeMatch ( new CodeInstruction ( OpCodes . Call ,
221234 AccessTools . Method ( typeof ( LabComponent ) , nameof ( LabComponent . InternalUpdateResearch ) ) ) ) ) ;
222235
223- object techSpeed = matcher . Advance ( - 6 ) . Operand ;
224-
225- object local = matcher . Advance ( - 2 ) . Operand ;
226-
227- matcher . InsertAndAdvance ( new CodeInstruction ( OpCodes . Ldarg_0 ) , new CodeInstruction ( OpCodes . Ldloc_S , local ) ,
228- new CodeInstruction ( OpCodes . Ldloc_S , techSpeed ) ,
229- new CodeInstruction ( OpCodes . Call , AccessTools . Method ( typeof ( ResearchLabPatches ) , nameof ( SetResearchSpeed ) ) ) ,
230- new CodeInstruction ( OpCodes . Stloc_S , techSpeed ) ) ;
236+ object local = matcher . Advance ( - 8 ) . Operand ;
237+
238+ // change techSpeed
239+ matcher . Advance ( 3 ) . InsertAndAdvance ( new CodeInstruction ( OpCodes . Ldarg_0 ) , new CodeInstruction ( OpCodes . Ldloc_S , local ) ,
240+ new CodeInstruction ( OpCodes . Call , AccessTools . Method ( typeof ( ResearchLabPatches ) , nameof ( SetResearchSpeed ) ) ) ) ;
231241
232242 return matcher . InstructionEnumeration ( ) ;
233243 }
@@ -240,7 +250,7 @@ public static float UISetResearchSpeed(float techSpeed, UILabWindow window)
240250 return techSpeed * labResearchSpeed ;
241251 }
242252
243- public static float SetResearchSpeed ( FactorySystem system , ref LabComponent component , float techSpeed )
253+ public static float SetResearchSpeed ( float techSpeed , FactorySystem system , ref LabComponent component )
244254 {
245255 short modelIndex = system . factory . entityPool [ component . entityId ] . modelIndex ;
246256 float labResearchSpeed = PlanetFactory . PrefabDescByModelIndex [ modelIndex ] . labResearchSpeed ;
0 commit comments