Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SplitStackArrowKeyFix v1.1.1
SplitStackArrowKeyFix.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SplitStackArrowKeyFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Fixes the annoying double-increment bug in Valheim's split stack menu.")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1")] [assembly: AssemblyProduct("SplitStackArrowKeyFix")] [assembly: AssemblyTitle("SplitStackArrowKeyFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SplitStackArrowKeyFix { [BepInPlugin("com.babelthuap.splitstackarrowkeyfix", "SplitStackArrowKeyFix", "1.1.1")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.babelthuap.splitstackarrowkeyfix"; public const string PluginName = "SplitStackArrowKeyFix"; public const string PluginVersion = "1.1.1"; private readonly Harmony harmony = new Harmony("com.babelthuap.splitstackarrowkeyfix"); private void Awake() { harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SplitStackArrowKeyFix loaded"); } } public static class SplitDialogHelper { private static FieldInfo splitDialogField; public static GameObject GetSplitDialog() { if ((Object)(object)InventoryGui.instance == (Object)null) { return null; } if (splitDialogField == null) { splitDialogField = AccessTools.Field(typeof(InventoryGui), "m_splitDialog"); if (splitDialogField == null) { return null; } } object value = splitDialogField.GetValue(InventoryGui.instance); object obj = ((value is GameObject) ? value : null); if (obj == null) { object obj2 = ((value is Component) ? value : null); if (obj2 == null) { return null; } obj = ((Component)obj2).gameObject; } return (GameObject)obj; } public static bool IsSplitDialogOpen() { GameObject splitDialog = GetSplitDialog(); if ((Object)(object)splitDialog != (Object)null) { return splitDialog.activeInHierarchy; } return false; } } public static class SplitDialogState { public static float LastClosedTime = -10f; } [HarmonyPatch(typeof(InventoryGui), "OnSplitOk")] public static class InventoryGui_OnSplitOk_Patch { public static void Prefix() { SplitDialogState.LastClosedTime = Time.unscaledTime; } } [HarmonyPatch(typeof(InventoryGui), "OnSplitCancel")] public static class InventoryGui_OnSplitCancel_Patch { public static void Prefix() { SplitDialogState.LastClosedTime = Time.unscaledTime; } } [HarmonyPatch(typeof(InventoryGui), "UpdateSplitDialog")] public static class InventoryGui_UpdateSplitDialog_Patch { private const float RepeatDelay = 0.5f; private const float RepeatRate = 0.05f; private static float aHoldTime; private static float dHoldTime; private static float nextRepeatTime; public static bool Prefix(InventoryGui __instance) { GameObject splitDialog = SplitDialogHelper.GetSplitDialog(); if ((Object)(object)splitDialog != (Object)null && splitDialog.activeInHierarchy) { if (Input.GetKeyDown((KeyCode)32)) { MethodInfo methodInfo = AccessTools.Method(typeof(InventoryGui), "OnSplitOk", (Type[])null, (Type[])null); if (methodInfo != null) { SplitDialogState.LastClosedTime = Time.unscaledTime; methodInfo.Invoke(__instance, null); return false; } } bool num = Input.GetKey((KeyCode)276) || Input.GetKey((KeyCode)275); bool flag = Input.GetKey((KeyCode)97) || Input.GetKey((KeyCode)100); if (flag) { Slider componentInChildren = splitDialog.GetComponentInChildren<Slider>(true); if ((Object)(object)componentInChildren != (Object)null) { float unscaledDeltaTime = Time.unscaledDeltaTime; float unscaledTime = Time.unscaledTime; if (Input.GetKeyDown((KeyCode)97)) { componentInChildren.value -= 1f; aHoldTime = 0f; } else if (Input.GetKey((KeyCode)97)) { aHoldTime += unscaledDeltaTime; if (aHoldTime >= 0.5f && unscaledTime >= nextRepeatTime) { componentInChildren.value -= 1f; nextRepeatTime = unscaledTime + 0.05f; } } if (Input.GetKeyDown((KeyCode)100)) { componentInChildren.value += 1f; dHoldTime = 0f; } else if (Input.GetKey((KeyCode)100)) { dHoldTime += unscaledDeltaTime; if (dHoldTime >= 0.5f && unscaledTime >= nextRepeatTime) { componentInChildren.value += 1f; nextRepeatTime = unscaledTime + 0.05f; } } } } else { aHoldTime = 0f; dHoldTime = 0f; } if (num || flag) { return false; } } return true; } } [HarmonyPatch(typeof(ZInput))] public static class ZInput_Patch { [HarmonyPatch("GetButton")] [HarmonyPatch("GetButtonDown")] [HarmonyPatch("GetButtonUp")] [HarmonyPrefix] public static bool Prefix(string name, ref bool __result) { switch (name) { default: if (!(name == "Jump")) { break; } goto case "Forward"; case "Forward": case "Backward": case "Left": case "Right": if (SplitDialogHelper.IsSplitDialogOpen() || Time.unscaledTime <= SplitDialogState.LastClosedTime + 0.25f) { __result = false; return false; } break; } return true; } } [HarmonyPatch(typeof(Character), "Jump")] public static class Character_Jump_Patch { public static bool Prefix(Character __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && (SplitDialogHelper.IsSplitDialogOpen() || Time.unscaledTime <= SplitDialogState.LastClosedTime + 0.25f)) { return false; } return true; } } }