fix(uxassist): restore vein protection patch activation

Pass the miner window's struct value to a matching helper while retaining ref parameters for statistics. This prevents invalid IL from rolling back the entire vein-protection patch group.
This commit is contained in:
soarqin committed 2026-10-19 22:59:08 +08:00
1 parent cc3863cfde
commit 94e5c7884b
1 file changed
+10 -1
@@ -31,6 +31,11 @@ internal static partial class VeinProtectionPatch
return count;
}
private static int GetMiningVeinCountForWindow(MinerComponent miner, PlanetFactory factory)
{
return GetMiningVeinCount(ref miner, factory);
}
private static int GetMiningVeinAmount(ref VeinData vein, PlanetFactory factory)
{
return IsProtectedVein(ref vein, FactoryPatch.GetMiningCostRate(factory.gameData.history)) ? 0 : vein.amount;
@@ -55,7 +60,11 @@ internal static partial class VeinProtectionPatch
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(MinerComponent), nameof(MinerComponent.veinCount))),
new CodeMatch(ci => ci.opcode == OpCodes.Conv_R8 || ci.opcode == OpCodes.Conv_R4));
if (matcher.IsInvalid) return matcher.Finish(original, UXAssist.Logger, nameof(MiningSpeed_Transpiler));
matcher.Repeat(m => ReplaceRead(m, factoryLoad, nameof(GetMiningVeinCount)));
// The window loads a struct value; the statistics paths load managed references.
var veinCountHelper = __originalMethod.DeclaringType == typeof(UIMinerWindow)
? nameof(GetMiningVeinCountForWindow)
: nameof(GetMiningVeinCount);
matcher.Repeat(m => ReplaceRead(m, factoryLoad, veinCountHelper));
matcher.Start().MatchForward(false,
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(VeinData), nameof(VeinData.amount))),