mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 23:33:33 +08:00
LabOpt: v0.3.4
This commit is contained in:
@@ -348,7 +348,35 @@ public static class LabOptPatchFunctions
|
|||||||
return (uint)(lab.products[0] - LabComponent.matrixIds[0] + 1);
|
return (uint)(lab.products[0] - LabComponent.matrixIds[0] + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetFunctionNew(ref LabComponent lab, bool researchMode, int recpId, int techId, SignData[] signPool, LabComponent[] labPool)
|
public static void SetFunctionManually(ref LabComponent lab, bool researchMode, int recpId, int techId, SignData[] signPool, LabComponent[] labPool)
|
||||||
|
{
|
||||||
|
var rootLabId = (int)RootLabIdField.GetValue(lab);
|
||||||
|
if (rootLabId > 0)
|
||||||
|
{
|
||||||
|
ref var rootLab = ref labPool[rootLabId];
|
||||||
|
if (researchMode != rootLab.researchMode)
|
||||||
|
{
|
||||||
|
SetFunctionInternal(ref rootLab, researchMode, recpId, techId, signPool, labPool);
|
||||||
|
}
|
||||||
|
else if (researchMode)
|
||||||
|
{
|
||||||
|
if (rootLab.techId != techId)
|
||||||
|
{
|
||||||
|
SetFunctionInternal(ref rootLab, true, recpId, techId, signPool, labPool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rootLab.recipeId != recpId)
|
||||||
|
{
|
||||||
|
SetFunctionInternal(ref rootLab, false, recpId, techId, signPool, labPool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetFunctionInternal(ref lab, researchMode, recpId, techId, signPool, labPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetFunctionInternal(ref LabComponent lab, bool researchMode, int recpId, int techId, SignData[] signPool, LabComponent[] labPool)
|
||||||
{
|
{
|
||||||
// LabOptPatch.Logger.LogDebug($"SetFunctionNew: {lab.id} {(int)RootLabIdField.GetValue(lab)} {researchMode} {recpId} {techId}");
|
// LabOptPatch.Logger.LogDebug($"SetFunctionNew: {lab.id} {(int)RootLabIdField.GetValue(lab)} {researchMode} {recpId} {techId}");
|
||||||
lab.replicating = false;
|
lab.replicating = false;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class LabOptPatch : BaseUnityPlugin
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect call of LabComponent.SetFunction() to SetFunctionNew()
|
// Redirect call of LabComponent.SetFunction() to SetFunctionManually()
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(BuildingParameters), nameof(BuildingParameters.ApplyPrebuildParametersToEntity))]
|
[HarmonyPatch(typeof(BuildingParameters), nameof(BuildingParameters.ApplyPrebuildParametersToEntity))]
|
||||||
private static IEnumerable<CodeInstruction> BuildingParameters_ApplyPrebuildParametersToEntity_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> BuildingParameters_ApplyPrebuildParametersToEntity_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
@@ -186,7 +186,7 @@ public class LabOptPatch : BaseUnityPlugin
|
|||||||
new CodeInstruction(OpCodes.Ldloc_2),
|
new CodeInstruction(OpCodes.Ldloc_2),
|
||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
||||||
).SetInstructionAndAdvance(
|
).SetInstructionAndAdvance(
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionNew)))
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionManually)))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
@@ -205,7 +205,7 @@ public class LabOptPatch : BaseUnityPlugin
|
|||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetFactory), nameof(PlanetFactory.factorySystem))),
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetFactory), nameof(PlanetFactory.factorySystem))),
|
||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
||||||
).SetInstructionAndAdvance(
|
).SetInstructionAndAdvance(
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionNew)))
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionManually)))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
@@ -227,7 +227,7 @@ public class LabOptPatch : BaseUnityPlugin
|
|||||||
new CodeInstruction(OpCodes.Ldarg_0),
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
||||||
).SetInstructionAndAdvance(
|
).SetInstructionAndAdvance(
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionNew)))
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionManually)))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
@@ -247,7 +247,7 @@ public class LabOptPatch : BaseUnityPlugin
|
|||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UILabWindow), nameof(UILabWindow.factorySystem))),
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UILabWindow), nameof(UILabWindow.factorySystem))),
|
||||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.labPool)))
|
||||||
).SetInstructionAndAdvance(
|
).SetInstructionAndAdvance(
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionNew)))
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetFunctionManually)))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<AssemblyName>LabOpt</AssemblyName>
|
<AssemblyName>LabOpt</AssemblyName>
|
||||||
<BepInExPluginGuid>org.soardev.labopt</BepInExPluginGuid>
|
<BepInExPluginGuid>org.soardev.labopt</BepInExPluginGuid>
|
||||||
<Description>DSP MOD - LabOpt</Description>
|
<Description>DSP MOD - LabOpt</Description>
|
||||||
<Version>0.3.3</Version>
|
<Version>0.3.4</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#### 优化研究站性能
|
#### 优化研究站性能
|
||||||
|
|
||||||
## Updates
|
## Updates
|
||||||
|
* 0.3.4
|
||||||
|
* Fix various crashes on recipe/research mode changing on labs that are not base level.
|
||||||
* 0.3.3
|
* 0.3.3
|
||||||
* Add a lock to `PlanetFactory.PickFrom()` to avoid thread-conflicts.
|
* Add a lock to `PlanetFactory.PickFrom()` to avoid thread-conflicts.
|
||||||
* 0.3.2
|
* 0.3.2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "LabOpt",
|
"name": "LabOpt",
|
||||||
"version_number": "0.3.3",
|
"version_number": "0.3.4",
|
||||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LabOpt",
|
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LabOpt",
|
||||||
"description": "Optimize Lab performance / 优化研究站性能",
|
"description": "Optimize Lab performance / 优化研究站性能",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
Reference in New Issue
Block a user