refactor: phase 5 transpiler docs, mod-compat helpers, and build quality gates

This commit is contained in:
2026-06-23 23:03:13 +08:00
parent cca8b8594d
commit c2016909ff
43 changed files with 2327 additions and 135 deletions
+21 -3
View File
@@ -20,6 +20,9 @@ internal static class ArchitectModePatch
internal class UnlimitInteractive : PatchImpl<UnlimitInteractive>
{
// Harmony transpiler: PlayerAction_Inspect_GetObjectSelectDistance_Transpiler
// Target: PlayerAction_Inspect.GetObjectSelectDistance
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.GetObjectSelectDistance))]
private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GetObjectSelectDistance_Transpiler(IEnumerable<CodeInstruction> instructions)
@@ -31,6 +34,9 @@ internal static class ArchitectModePatch
internal class RemoveSomeConditionBuild : PatchImpl<RemoveSomeConditionBuild>
{
// Harmony transpiler: BuildTool_Click_CheckBuildConditions_Transpiler
// Target: BuildTool_BlueprintPaste.CheckBuildConditions, BuildTool_Click.CheckBuildConditions
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler, HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CheckBuildConditions))]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
@@ -65,7 +71,9 @@ internal static class ArchitectModePatch
matcher.Opcode = OpCodes.Brfalse;
return matcher.InstructionEnumeration();
}
// Harmony transpiler: BuildTool_Path_CheckBuildConditions_Transpiler
// Target: BuildTool_Path.CheckBuildConditions
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler, HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CheckBuildConditions))]
private static IEnumerable<CodeInstruction> BuildTool_Path_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -140,7 +148,9 @@ internal static class ArchitectModePatch
if (controller == null) return;
controller.actionBuild?.clickTool?._OnInit();
}
// Harmony transpiler: BuildTool_Click__OnInit_Transpiler
// Target: BuildTool_Click._OnInit
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnInit))]
private static IEnumerable<CodeInstruction> BuildTool_Click__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -152,7 +162,9 @@ internal static class ArchitectModePatch
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 512));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: BuildAreaLimitRemoval_Transpiler
// Target: BuildTool_Addon.CheckBuildConditions, BuildTool_Click.CheckBuildConditions, BuildTool_Dismantle.DetermineMoreChainTargets, BuildTool_Dismantle.DeterminePreviews, BuildTool_Inserter.CheckBuildConditions, BuildTool_Path.CheckBuildConditions, BuildTool_Reform.ReformAction, BuildTool_Upgrade.DetermineMoreChainTargets, BuildTool_Upgrade.DeterminePreviews
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
@@ -185,6 +197,9 @@ internal static class ArchitectModePatch
internal class LargerAreaForUpgradeAndDismantle : PatchImpl<LargerAreaForUpgradeAndDismantle>
{
// Harmony transpiler: BuildTools_CursorSizePatch_Transpiler
// Target: BuildTool_Dismantle.DeterminePreviews, BuildTool_Upgrade.DeterminePreviews
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
@@ -201,6 +216,9 @@ internal static class ArchitectModePatch
internal class LargerAreaForTerraform : PatchImpl<LargerAreaForTerraform>
{
// Harmony transpiler: BuildTool_Reform_ReformAction_Transpiler
// Target: BuildTool_Reform.ReformAction
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
+45 -13
View File
@@ -24,6 +24,9 @@ internal static class BuildToolPatch
private class BuildGizmoPatch : PatchImpl<BuildGizmoPatch>
{
// Harmony transpiler: ConnGizmoGraph_Constructor_Transpiler
// Target: ConnGizmoGraph..ctor
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(ConnGizmoGraph), MethodType.Constructor)]
private static IEnumerable<CodeInstruction> ConnGizmoGraph_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -35,7 +38,9 @@ internal static class BuildToolPatch
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: ConnGizmoGraph_SetPointCount_Transpiler
// Target: ConnGizmoGraph.SetPointCount
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(ConnGizmoGraph), nameof(ConnGizmoGraph.SetPointCount))]
private static IEnumerable<CodeInstruction> ConnGizmoGraph_SetPointCount_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -47,7 +52,9 @@ internal static class BuildToolPatch
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: BuildTool_Path__OnInit_Transpiler
// Target: BuildTool_Path._OnInit
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path._OnInit))]
private static IEnumerable<CodeInstruction> BuildTool_Path__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -59,7 +66,9 @@ internal static class BuildToolPatch
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: BuildTool_Reform_Constructor_Transpiler
// Target: BuildTool_Reform..ctor
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), MethodType.Constructor)]
private static IEnumerable<CodeInstruction> BuildTool_Reform_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
@@ -133,7 +142,9 @@ internal static class BuildToolPatch
__instance.actionBuild.model.cursorText = $"({_lastOffsetText})\n" + __instance.actionBuild.model.cursorText;
}
// Harmony transpiler: UIEntityBriefInfo__OnUpdate_Transpiler
// Target: UIEntityBriefInfo._OnUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIEntityBriefInfo), nameof(UIEntityBriefInfo._OnUpdate))]
private static IEnumerable<CodeInstruction> UIEntityBriefInfo__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -188,7 +199,9 @@ internal static class BuildToolPatch
ifBlockEntryLabel = thisIfBlockEntryLabel;
elseBlockEntryLabel = thisElseBlockEntryLabel;
}
// Harmony transpiler: AllowOffGridConstruction
// Target: BuildTool_Click.UpdateRaycast, BuildTool_Click.DeterminePreviews
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.UpdateRaycast))]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.DeterminePreviews))]
@@ -206,7 +219,9 @@ internal static class BuildToolPatch
return matcher.InstructionEnumeration();
}
// Harmony transpiler: PreventDraggingWhenOffGrid
// Target: BuildTool_Click.DeterminePreviews
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.DeterminePreviews))]
public static IEnumerable<CodeInstruction> PreventDraggingWhenOffGrid(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -233,7 +248,9 @@ internal static class BuildToolPatch
return matcher.InstructionEnumeration();
}
// Harmony transpiler: AllowOffGridConstructionForPath
// Target: BuildTool_Path.UpdateRaycast
// Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.UpdateRaycast))]
public static IEnumerable<CodeInstruction> AllowOffGridConstructionForPath(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -339,6 +356,9 @@ internal static class BuildToolPatch
internal class TreatStackingAsSingle : PatchImpl<TreatStackingAsSingle>
{
// Harmony transpiler: MonitorComponent_InternalUpdate_Transpiler
// Target: MonitorComponent.InternalUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(MonitorComponent), nameof(MonitorComponent.InternalUpdate))]
private static IEnumerable<CodeInstruction> MonitorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -491,7 +511,9 @@ internal static class BuildToolPatch
return num;
}
// Harmony transpiler: BuildTool_Click_DeterminePreviews_Transpiler
// Target: BuildTool_Click.DeterminePreviews
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.DeterminePreviews))]
private static IEnumerable<CodeInstruction> BuildTool_Click_DeterminePreviews_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -580,7 +602,9 @@ internal static class BuildToolPatch
new(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Min), [typeof(int), typeof(int)]))
];
private static readonly CodeInstruction GetRealCount = new(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryPatch), nameof(FactoryPatch._tankFastFillInAndTakeOutMultiplierRealValue)));
// Harmony transpiler: PlanetFactory_EntityFastFillIn_Transpiler
// Target: PlanetFactory.EntityFastFillIn
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.EntityFastFillIn))]
private static IEnumerable<CodeInstruction> PlanetFactory_EntityFastFillIn_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -600,7 +624,9 @@ internal static class BuildToolPatch
).RemoveInstructions(5).Insert(MultiplierWithCountCheck);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: PlanetFactory_EntityFastTakeOut_Transpiler
// Target: PlanetFactory.EntityFastTakeOut
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.EntityFastTakeOut))]
private static IEnumerable<CodeInstruction> PlanetFactory_EntityFastTakeOut_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -621,7 +647,9 @@ internal static class BuildToolPatch
).RemoveInstructions(5).Insert(MultiplierWithCountCheck);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: UITankWindow__OnUpdate_Transpiler
// Target: UITankWindow._OnUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(UITankWindow), nameof(UITankWindow._OnUpdate))]
private static IEnumerable<CodeInstruction> UITankWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -694,7 +722,9 @@ internal static class BuildToolPatch
{
nextTimei = 0;
}
// Harmony transpiler: VFInput_fastTransferWithEntityDown_Transpiler
// Target: VFInput._fastTransferWithEntityDown (getter), VFInput._fastTransferWithEntityPress (getter)
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(VFInput), nameof(VFInput._fastTransferWithEntityDown), MethodType.Getter)]
[HarmonyPatch(typeof(VFInput), nameof(VFInput._fastTransferWithEntityPress), MethodType.Getter)]
@@ -710,7 +740,9 @@ internal static class BuildToolPatch
matcher.Labels.AddRange(lables);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: PlayerAction_Inspect_GameTick_Transpiler
// Target: PlayerAction_Inspect.GameTick
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.GameTick))]
private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -67,7 +67,9 @@ internal static class BuildingBufferPatch
patch.Unpatch(AccessTools.Method(typeof(SiloComponent), nameof(SiloComponent.InternalUpdate)), AccessTools.Method(typeof(TweakBuildingBuffer), nameof(SiloComponent_InternalUpdate_Transpiler)));
patch.Patch(AccessTools.Method(typeof(SiloComponent), nameof(SiloComponent.InternalUpdate)), null, null, new HarmonyMethod(typeof(TweakBuildingBuffer), nameof(SiloComponent_InternalUpdate_Transpiler)));
}
// Harmony transpiler: PowerGeneratorComponent_GameTick_Gamma_Transpiler
// Target: PowerGeneratorComponent.GameTick_Gamma
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.GameTick_Gamma))]
private static IEnumerable<CodeInstruction> PowerGeneratorComponent_GameTick_Gamma_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -89,7 +91,9 @@ internal static class BuildingBufferPatch
matcher.Advance(2).RemoveInstructions(2).Insert(new CodeInstruction(OpCodes.Ldc_I4, FactoryPatch.ReceiverBufferCount.Value * 3600));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: AssemblerComponent_UpdateNeeds_Transpiler
// Target: AssemblerComponent.UpdateNeeds
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(AssemblerComponent), nameof(AssemblerComponent.UpdateNeeds))]
private static IEnumerable<CodeInstruction> AssemblerComponent_UpdateNeeds_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -125,7 +129,9 @@ internal static class BuildingBufferPatch
matcher.Advance(2).Operand = FactoryPatch.AssemblerBufferMininumMultiplier.Value;
return matcher.InstructionEnumeration();
}
// Harmony transpiler: LabComponent_UpdateNeedsAssemble_Transpiler
// Target: LabComponent.UpdateNeedsAssemble
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(LabComponent), nameof(LabComponent.UpdateNeedsAssemble))]
private static IEnumerable<CodeInstruction> LabComponent_UpdateNeedsAssemble_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -163,7 +169,9 @@ internal static class BuildingBufferPatch
matcher.Advance(2).SetAndAdvance(OpCodes.Ldc_I4, maxCount);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: LabComponent_UpdateNeedsResearch_Transpiler
// Target: LabComponent.UpdateNeedsResearch
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(LabComponent), nameof(LabComponent.UpdateNeedsResearch))]
private static IEnumerable<CodeInstruction> LabComponent_UpdateNeedsResearch_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -183,7 +191,9 @@ internal static class BuildingBufferPatch
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, FactoryPatch.LabBufferMaxCountForResearch.Value * 3600));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: EjectorComponent_InternalUpdate_Transpiler
// Target: EjectorComponent.InternalUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -197,7 +207,9 @@ internal static class BuildingBufferPatch
matcher.Advance(2).Set(OpCodes.Ldc_I4, FactoryPatch.EjectorBufferCount.Value);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: SiloComponent_InternalUpdate_Transpiler
// Target: SiloComponent.InternalUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(SiloComponent), nameof(SiloComponent.InternalUpdate))]
private static IEnumerable<CodeInstruction> SiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -212,7 +212,9 @@ internal static class ImmediateBuildPatch
currLevel++;
}
}
// Harmony transpiler: BuildTool_Dismantle_DeterminePreviews_Transpiler
// Target: BuildTool_Dismantle.DeterminePreviews
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
private static IEnumerable<CodeInstruction> BuildTool_Dismantle_DeterminePreviews_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -233,7 +235,9 @@ internal static class ImmediateBuildPatch
);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: BuildTool_Click__OnTick_Transpiler
// Target: BuildTool_Click._OnTick
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnTick))]
private static IEnumerable<CodeInstruction> BuildTool_Click__OnTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
+9 -3
View File
@@ -40,7 +40,9 @@ internal static class RenderingPatch
{
__instance.renderEntity = true;
}
// Harmony transpiler: RaycastLogic_GameTick_Transpiler
// Target: RaycastLogic.GameTick
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(RaycastLogic), nameof(RaycastLogic.GameTick))]
private static IEnumerable<CodeInstruction> RaycastLogic_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -156,7 +158,9 @@ internal static class RenderingPatch
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
}
}
// Harmony transpiler: StarSimulator_LateUpdate_Transpiler
// Target: StarSimulator.LateUpdate
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(StarSimulator), nameof(StarSimulator.LateUpdate))]
private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -182,7 +186,9 @@ internal static class RenderingPatch
).Advance(1).Labels.Add(label2);
return matcher.InstructionEnumeration();
}
// Harmony transpiler: PlanetSimulator_LateRefresh_Transpiler
// Target: PlanetSimulator.LateRefresh
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetSimulator), nameof(PlanetSimulator.LateRefresh))]
private static IEnumerable<CodeInstruction> PlanetSimulator_LateRefresh_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)