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 HotbarSwitch v0.3.2
plugins/HotbarSwitch.dll
Decompiled 2 years agousing System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.3.2")] [assembly: AssemblyInformationalVersion("1.0.0+163364de77d67d507cb0593fda14849d47270420")] [assembly: AssemblyVersion("0.3.2.0")] public class AedenthornUtils { public static bool IgnoreKeyPresses(bool extra = false) { if (!extra) { int result; if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog()) { Chat instance = Chat.instance; result = ((instance != null && instance.HasFocus()) ? 1 : 0); } else { result = 1; } return (byte)result != 0; } int result2; if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog()) { Chat instance2 = Chat.instance; if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible()) { TextViewer instance3 = TextViewer.instance; result2 = ((instance3 != null && instance3.IsVisible()) ? 1 : 0); goto IL_00d2; } } result2 = 1; goto IL_00d2; IL_00d2: return (byte)result2 != 0; } public static bool CheckKeyDown(string value) { try { return Input.GetKeyDown(value.ToLower()); } catch { return false; } } } namespace Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal Resources() { } } } namespace HotbarSwitch { [BepInPlugin("cjayride.HotbarSwitch", "Hotbar Switch", "0.3.2")] public class BepInExPlugin : BaseUnityPlugin { private static BepInExPlugin context; public static ConfigEntry<bool> modEnabled; public static ConfigEntry<int> rowsToSwitch; public static ConfigEntry<string> hotKey; private void Awake() { context = this; modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod"); rowsToSwitch = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RowsToSwitch", 2, "Rows of inventory to switch via hotkey"); hotKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HotKey", "`", "Hotkey to initiate switch. Use https://docs.unity3d.com/Manual/ConventionalGameInput.html"); if (modEnabled.Value) { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } private void Update() { if (!modEnabled.Value || AedenthornUtils.IgnoreKeyPresses(extra: true) || !AedenthornUtils.CheckKeyDown(hotKey.Value)) { return; } int height = ((Humanoid)Player.m_localPlayer).GetInventory().GetHeight(); int num = Math.Max(1, Math.Min(height, rowsToSwitch.Value)); List<ItemData> value = Traverse.Create((object)((Humanoid)Player.m_localPlayer).GetInventory()).Field("m_inventory").GetValue<List<ItemData>>(); for (int i = 0; i < value.Count; i++) { if (value[i].m_gridPos.y < num) { value[i].m_gridPos.y--; if (value[i].m_gridPos.y < 0) { value[i].m_gridPos.y = num - 1; } } } Traverse.Create((object)((Humanoid)Player.m_localPlayer).GetInventory()).Method("Changed", Array.Empty<object>()).GetValue(); } } }