1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 15:33:31 +08:00

minor fix

This commit is contained in:
2025-08-11 13:32:40 +08:00
parent a9dd130f76
commit 7a7943b001

View File

@@ -431,12 +431,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
{ {
var matcher = new CodeMatcher(instructions, generator); var matcher = new CodeMatcher(instructions, generator);
/* search for: /* search for:
* ldloc.s V_8 (8) * ldloc.s V_8 (8)
* ldfld class PrefabDesc BuildPreview::desc * ldfld class PrefabDesc BuildPreview::desc
* ldfld bool PrefabDesc::isInserter * ldfld bool PrefabDesc::isInserter
* brtrue 2358 (1C12) ldloc.s V_8 (8) * brtrue 2358 (1C12) ldloc.s V_8 (8)
* ldloca.s V_10 (10) * ldloca.s V_10 (10)
* call instance float32 [UnityEngine.CoreModule]UnityEngine.Vector3::get_magnitude() * call instance float32 [UnityEngine.CoreModule]UnityEngine.Vector3::get_magnitude()
*/ */
matcher.MatchForward(false, matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldloc_S), new CodeMatch(OpCodes.Ldloc_S),
@@ -446,20 +446,16 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
new CodeMatch(OpCodes.Ldloca_S), new CodeMatch(OpCodes.Ldloca_S),
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(Vector3), nameof(Vector3.magnitude))) new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(Vector3), nameof(Vector3.magnitude)))
); );
var ldlocOpr = matcher.InstructionAt(0).operand; /* Change to:
var jumpPos = matcher.InstructionAt(3).operand; * Ldloc.s V_8 (8)
/* Insert after btrue:
* Ldloc.s V_8 (8)
* ldfld class PrefabDesc BuildPreview::desc * ldfld class PrefabDesc BuildPreview::desc
* ldfld bool PrefabDesc::isPowerGen * ldfld bool PrefabDesc::isEjector
* brtrue 2358 (1C12) ldloc.s V_8 (8) * brfalse 2358 (1C12) ldloc.s V_8 (8)
*/ */
matcher.Advance(4).InsertAndAdvance( matcher.Advance(2);
new CodeInstruction(OpCodes.Ldloc_S, ldlocOpr), matcher.Operand = AccessTools.Field(typeof(PrefabDesc), nameof(PrefabDesc.isEjector));
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.desc))), matcher.Advance(1);
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PrefabDesc), nameof(PrefabDesc.isPowerGen))), matcher.Opcode = OpCodes.Brfalse;
new CodeInstruction(OpCodes.Brtrue_S, jumpPos)
);
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }