fix(compat): support DSP 0.10.35.29057

Adapt UXAssist and CheatEnabler to the new terrain workflows, view modes, receiver inventory, and mineral-depletion API. Preserve crafting shortcuts, batch buyout visibility, soil progression, and saved brush safety.

Refresh game references and document compatibility changes. Release builds, static compatibility checks, behavior assertions, and diff checks pass; user testing is also confirmed.
This commit is contained in:
soarqin committed 2026-09-24 01:57:04 +08:00
1 parent 367a72b375
commit ac4210fe5d
15 files changed
+214 -131

No files matched your search

+14 -45
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using BepInEx.Configuration;
using CommonAPI.Systems;
@@ -147,60 +148,28 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 1000));
return matcher.InstructionEnumeration();
}
// Harmony transpiler: UIReplicatorWindow_OnPlusButtonClick_Transpiler
// Target: UIReplicatorWindow.OnPlusButtonClick, UIReplicatorWindow.OnMinusButtonClick
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPrefix]
[HarmonyPatch(typeof(UIReplicatorWindow), nameof(UIReplicatorWindow.OnPlusButtonClick))]
[HarmonyPatch(typeof(UIReplicatorWindow), nameof(UIReplicatorWindow.OnMinusButtonClick))]
private static IEnumerable<CodeInstruction> UIReplicatorWindow_OnPlusButtonClick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
private static bool UIReplicatorWindow_ChangeMultiplier_Prefix(UIReplicatorWindow __instance, RecipeProto ___selectedRecipe, MethodBase __originalMethod)
{
var label1 = generator.DefineLabel();
var label2 = generator.DefineLabel();
var label3 = generator.DefineLabel();
var label4 = generator.DefineLabel();
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldloc_0),
new CodeMatch(OpCodes.Ldc_I4_1),
new CodeMatch(o => o.opcode == OpCodes.Add || o.opcode == OpCodes.Sub)
).Advance(1).RemoveInstruction().InsertAndAdvance(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.control))),
new CodeInstruction(OpCodes.Brfalse_S, label1),
new CodeInstruction(OpCodes.Ldc_I4_S, 10),
new CodeInstruction(OpCodes.Br_S, label4),
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.shift))).WithLabels(label1),
new CodeInstruction(OpCodes.Brfalse_S, label2),
new CodeInstruction(OpCodes.Ldc_I4_S, 100),
new CodeInstruction(OpCodes.Br_S, label4),
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.alt))).WithLabels(label2),
new CodeInstruction(OpCodes.Brfalse_S, label3),
new CodeInstruction(OpCodes.Ldc_I4, 1000),
new CodeInstruction(OpCodes.Br_S, label4),
new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(label3)
).Labels.Add(label4);
matcher.MatchForward(false,
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10))
);
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 1000));
return matcher.InstructionEnumeration();
var recipe = ___selectedRecipe;
if (recipe == null) return false;
var multiplier = __instance.multipliers.TryGetValue(recipe.ID, out var current) ? current : 1;
var step = VFInput.control ? 10 : VFInput.shift ? 100 : VFInput.alt ? 1000 : 1;
var direction = __originalMethod.Name == nameof(UIReplicatorWindow.OnPlusButtonClick) ? 1 : -1;
__instance.multipliers[recipe.ID] = Math.Max(1, Math.Min(1000, multiplier + direction * step));
return false;
}
}
private class HideTipsForSandsChanges : PatchImpl<HideTipsForSandsChanges>
{
// Harmony transpiler: Player_SetSandCount_Transpiler
// Target: Player.SetSandCount
// Fallback: None — patch will fail loudly if the target method body changes.
[HarmonyTranspiler]
[HarmonyPatch(typeof(Player), nameof(Player.SetSandCount))]
private static IEnumerable<CodeInstruction> Player_SetSandCount_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
[HarmonyPrefix]
[HarmonyPatch(typeof(UIGame), nameof(UIGame.OnSandCountChanged))]
private static bool UIGame_OnSandCountChanged_Prefix()
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.PropertySetter(typeof(Player), nameof(Player.sandCount)))
).Advance(1).Insert(new CodeInstruction(OpCodes.Ret));
return matcher.InstructionEnumeration();
return false;
}
}