From 830a242f37dc72c3372b41ebea187d0a6c7c05a1 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Tue, 21 May 2024 03:00:54 +0800 Subject: [PATCH] WIP --- UXAssist/UXAssist.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index 77bdcf8..0ad96e0 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -413,4 +413,30 @@ public class UXAssist : BaseUnityPlugin { return false; } + + // Do not check for overflow when try to send hand items into storages + [HarmonyTranspiler] + [HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnItemIconMouseDown))] + private static IEnumerable UIStationStorage_OnItemIconMouseDown_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(LDB), nameof(LDB.items))), + new CodeMatch(OpCodes.Ldarg_0) + ); + var pos = matcher.Pos; + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldloc_S), + new CodeMatch(OpCodes.Stloc_S) + ); + var inst = matcher.InstructionAt(1).Clone(); + var pos2 = matcher.Pos + 2; + matcher.Start().Advance(pos).RemoveInstructions(pos2 - pos) + .Insert( + new CodeInstruction(OpCodes.Ldloc_1), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.inhandItemCount))), + inst + ); + return matcher.InstructionEnumeration(); + } }