mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
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:
1 parent
367a72b375
commit
ac4210fe5d
15 files changed
+214
-131
No files matched your search
@@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.Patching;
|
||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
@@ -265,23 +266,37 @@ public static class TechPatch
|
||||
{
|
||||
// Harmony transpiler: UITechNode_UpdateInfoDynamic_Transpiler
|
||||
// Target: UITechNode.UpdateInfoDynamic
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
// Fallback: TranspilerGuard returns original instructions when the buyout visibility expression is not found.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.UpdateInfoDynamic))]
|
||||
private static IEnumerable<CodeInstruction> UITechNode_UpdateInfoDynamic_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UITechTree), nameof(UITechTree.showProperty))),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.And)
|
||||
).Advance(1).SetAndAdvance(OpCodes.Ldloc_3, null).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Ceq)
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(UITechTree), nameof(UITechTree.showProperty)))
|
||||
);
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(UITechNode_UpdateInfoDynamic_Transpiler));
|
||||
var start = matcher.Pos;
|
||||
var labels = matcher.Labels.ToArray();
|
||||
matcher.MatchForward(false, new CodeMatch(instruction => instruction.IsStloc()));
|
||||
if (matcher.IsInvalid)
|
||||
return matcher.Finish(instructions, UXAssist.Logger, nameof(UITechNode_UpdateInfoDynamic_Transpiler));
|
||||
var count = matcher.Pos - start;
|
||||
matcher.Start().Advance(start).RemoveInstructions(count).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UITechNode), nameof(UITechNode.techProto))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(BatchBuyoutTech), nameof(CanShowBuyoutButton)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static bool CanShowBuyoutButton(TechProto techProto)
|
||||
{
|
||||
return UITechTree.showProperty && !GameMain.sandboxToolsEnabled &&
|
||||
!techProto.IsHiddenTech && !techProto.IsObsolete && !GameMain.history.TechUnlocked(techProto.ID);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.OnBuyoutButtonClick))]
|
||||
private static bool UITechNode_OnBuyoutButtonClick_Prefix(UITechNode __instance)
|
||||
|
||||
Reference in new issue
Block a user