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

UXAssist 1.2.14 & CheatEnabler 2.3.27

This commit is contained in:
2025-01-24 19:20:51 +08:00
parent f224b72838
commit 0a8fa9971c
9 changed files with 63 additions and 38 deletions

View File

@@ -389,20 +389,36 @@ public class DysonSpherePatch: PatchImpl<DysonSpherePatch>
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
// if (this.orbitId == 0
// if (this.runtimeOrbitId == 0
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.orbitId))),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.runtimeOrbitId))),
new CodeMatch(OpCodes.Brtrue)
).Advance(2).Insert(
).Advance(2).InsertAndAdvance(
// || !StopEjectOnNodeComplete.AnyNodeForAbsorb(this.starData.index))
new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Cgt),
new CodeInstruction(OpCodes.Ldarg_2),
new CodeInstruction(OpCodes.Ldarg_3),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.starData))),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(AnyNodeForAbsorb))),
new CodeInstruction(OpCodes.And)
);
// Do not search for next orbit if runtimeOrbitId is not 0 (which means nodes are completed)
Label? jmpTarget = null;
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.autoOrbit))),
new CodeMatch(ci => ci.Branches(out jmpTarget))
);
if (jmpTarget == null) return matcher.InstructionEnumeration();
var labels = matcher.Labels;
matcher.Labels = null;
matcher.Insert(
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.runtimeOrbitId))),
new CodeInstruction(OpCodes.Brtrue, jmpTarget.Value)
);
return matcher.InstructionEnumeration();
}