Please disclose if your mod was created primarily 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 ExtendedPlayerInventory ASHLANDS v1.9.6
ExtendedPlayerInventory.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [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("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d3038ebb517087a047c937a0b9c611726ec127a0")] [assembly: AssemblyVersion("1.0.0.0")] public class AedenthornUtils { public static bool IgnoreKeyPresses(bool extra = false) { int result; if (!extra) { 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; if (instance == null || !instance.HasFocus()) { result = (Menu.IsVisible() ? 1 : 0); goto IL_005f; } } result = 1; goto IL_005f; } 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_00d9; } } result2 = 1; goto IL_00d9; IL_005f: return (byte)result != 0; IL_00d9: return (byte)result2 != 0; } public static bool CheckKeyDown(string value) { try { return Input.GetKeyDown(value.ToLower()); } catch { return false; } } public static bool CheckKeyHeld(string value, bool req = true) { try { return Input.GetKey(value.ToLower()); } catch { return !req; } } } namespace ExtendedPlayerInventory; [BepInPlugin("aedenthorn.ExtendedPlayerInventory", "Extended Player Inventory", "1.0.1")] public class BepInExPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "Awake")] public static class Player_Awake_Patch { public static void Prefix(Player __instance, Inventory ___m_inventory) { if (modEnabled.Value) { Dbgl("Player_Awake"); int num = extraRows.Value + (addEquipmentRow.Value ? 5 : 4); AccessTools.FieldRefAccess<Inventory, int>(___m_inventory, "m_height") = num; __instance.m_tombstone.GetComponent<Container>().m_height = num; } } } [HarmonyPatch(typeof(TombStone), "Awake")] public static class TombStone_Awake_Patch { public static void Prefix(TombStone __instance) { if (modEnabled.Value) { Dbgl("TombStone_Awake"); int height = extraRows.Value + (addEquipmentRow.Value ? 5 : 4); ((Component)__instance).GetComponent<Container>().m_height = height; } } } [HarmonyPatch(typeof(TombStone), "Interact")] public static class TombStone_Interact_Patch { public static void Prefix(TombStone __instance, Container ___m_container) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (modEnabled.Value) { Dbgl("TombStone_Interact"); int height = extraRows.Value + (addEquipmentRow.Value ? 5 : 4); ((Component)__instance).GetComponent<Container>().m_height = height; Traverse val = Traverse.Create((object)___m_container); string @string = val.Field("m_nview").GetValue<ZNetView>().GetZDO() .GetString("items", ""); if (!string.IsNullOrEmpty(@string)) { ZPackage val2 = new ZPackage(@string); val.Field("m_loading").SetValue((object)true); val.Field("m_inventory").GetValue<Inventory>().Load(val2); val.Field("m_loading").SetValue((object)false); val.Field("m_lastDataString").SetValue((object)@string); } } } } [HarmonyPatch(typeof(Inventory), "MoveInventoryToGrave")] public static class MoveInventoryToGrave_Patch { public static void Postfix(Inventory __instance, Inventory original) { if (modEnabled.Value) { Dbgl("MoveInventoryToGrave"); Dbgl($"inv: {__instance.GetHeight()} orig: {original.GetHeight()}"); } } } [HarmonyPatch(typeof(InventoryGui), "Show")] public static class InventoryGui_Show_Patch { public static void Postfix(InventoryGui __instance) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && addEquipmentRow.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Dbgl("InventoryGui Show"); ArrangeEquipment(Player.m_localPlayer); if (displayEquipmentRowSeparate.Value && (Object)(object)((Transform)__instance.m_player).Find("EquipmentBkg") == (Object)null) { Transform val = Object.Instantiate<Transform>(((Transform)__instance.m_player).Find("Bkg"), (Transform)(object)__instance.m_player); val.SetAsFirstSibling(); ((Object)val).name = "EquipmentBkg"; ((Component)val).GetComponent<RectTransform>().anchorMin = new Vector2(1f, 0f); ((Component)val).GetComponent<RectTransform>().anchorMax = new Vector2(1.5f, 1f); } else if (!displayEquipmentRowSeparate.Value && Object.op_Implicit((Object)(object)((Transform)__instance.m_player).Find("EquipmentBkg"))) { Object.Destroy((Object)(object)((Component)((Transform)__instance.m_player).Find("EquipmentBkg")).gameObject); } } } } [HarmonyPatch(typeof(Inventory), "Changed")] public static class Inventory_Changed_Patch { public static void Postfix(Inventory __instance) { if (modEnabled.Value && addEquipmentRow.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { int num = extraRows.Value + (addEquipmentRow.Value ? 5 : 4); AccessTools.FieldRefAccess<Inventory, int>(__instance, "m_height") = num; ArrangeEquipment(Player.m_localPlayer); } } } [HarmonyPatch(typeof(Humanoid), "SetupEquipment")] public static class Humanoid_SetupEquipment_Patch { public static void Postfix(Humanoid __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown if (modEnabled.Value && addEquipmentRow.Value && __instance is Player && (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) || (showGearInMenu.Value && !((Object)(object)Player.m_localPlayer != (Object)null)))) { ArrangeEquipment((Player)__instance); } } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] public static class Humanoid_UnequipItem_Patch { public static void Postfix(Humanoid __instance, ItemData item) { } } [HarmonyPatch(typeof(Player), "EquipInventoryItems")] public static class Humanoid_EquipItem_Patch { public static void Postfix(Player __instance) { ArrangeEquipment(__instance); } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_Patch { public static void Postfix(Player __instance, Inventory ___m_inventory) { if (!modEnabled.Value) { return; } int num = extraRows.Value + (addEquipmentRow.Value ? 5 : 4); AccessTools.FieldRefAccess<Inventory, int>(___m_inventory, "m_height") = num; __instance.m_tombstone.GetComponent<Container>().m_height = num; if (AedenthornUtils.IgnoreKeyPresses(extra: true) || !addEquipmentRow.Value) { return; } int num2; if (AedenthornUtils.CheckKeyDown(hotKey1.Value)) { num2 = 1; } else if (AedenthornUtils.CheckKeyDown(hotKey2.Value)) { num2 = 2; } else { if (!AedenthornUtils.CheckKeyDown(hotKey3.Value)) { return; } num2 = 3; } Dbgl($"Pressed hotkey {num2}"); ItemData itemAt = ___m_inventory.GetItemAt(num2 + 4, ___m_inventory.GetHeight() - 1); if (itemAt != null) { ((Humanoid)__instance).UseItem((Inventory)null, itemAt, false); } } public static void CreateTombStone() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Dbgl($"height {Player.m_localPlayer.m_tombstone.GetComponent<Container>().m_height}"); GameObject val = Object.Instantiate<GameObject>(Player.m_localPlayer.m_tombstone, ((Character)Player.m_localPlayer).GetCenterPoint(), ((Component)Player.m_localPlayer).transform.rotation); TombStone component = val.GetComponent<TombStone>(); Dbgl($"height {val.GetComponent<Container>().m_height}"); Dbgl($"inv height {val.GetComponent<Container>().GetInventory().GetHeight()}"); Dbgl($"inv slots {val.GetComponent<Container>().GetInventory().GetEmptySlots()}"); for (int i = 0; i < val.GetComponent<Container>().GetInventory().GetEmptySlots(); i++) { val.GetComponent<Container>().GetInventory().AddItem("SwordBronze", 1, 1, 0, 0L, "", false); } Dbgl($"no items: {val.GetComponent<Container>().GetInventory().NrOfItems()}"); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); component.Setup(playerProfile.GetName(), playerProfile.GetPlayerID()); } } [HarmonyPatch(typeof(InventoryGui), "Update")] public static class InventoryGui_Update_Patch { public static void Postfix(InventoryGui __instance, Animator ___m_animator, InventoryGrid ___m_playerGrid) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !___m_animator.GetBool("visible")) { return; } ((Component)((Transform)__instance.m_player).Find("Bkg")).GetComponent<RectTransform>().anchorMin = new Vector2(0f, (float)(extraRows.Value + ((addEquipmentRow.Value && !displayEquipmentRowSeparate.Value) ? 1 : 0)) * -0.25f); if (addEquipmentRow.Value) { if (displayEquipmentRowSeparate.Value && (Object)(object)((Transform)__instance.m_player).Find("EquipmentBkg") == (Object)null) { Transform val = Object.Instantiate<Transform>(((Transform)__instance.m_player).Find("Bkg"), (Transform)(object)__instance.m_player); val.SetAsFirstSibling(); ((Object)val).name = "EquipmentBkg"; ((Component)val).GetComponent<RectTransform>().anchorMin = new Vector2(1f, 0f); ((Component)val).GetComponent<RectTransform>().anchorMax = new Vector2(1.5f, 1f); } else if (!displayEquipmentRowSeparate.Value && Object.op_Implicit((Object)(object)((Transform)__instance.m_player).Find("EquipmentBkg"))) { Object.Destroy((Object)(object)((Component)((Transform)__instance.m_player).Find("EquipmentBkg")).gameObject); } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateInventory")] public static class UpdateInventory_Patch { public static void Postfix(InventoryGrid ___m_playerGrid) { //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && addEquipmentRow.Value) { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); int num = inventory.GetWidth() * (inventory.GetHeight() - 1); SetSlotText(helmetText.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)); SetSlotText(chestText.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)); SetSlotText(legsText.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)); SetSlotText(backText.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)); SetSlotText(utilityText.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)); SetSlotText(hotKey1.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++), center: false); SetSlotText(hotKey2.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++), center: false); SetSlotText(hotKey3.Value, ((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++), center: false); if (displayEquipmentRowSeparate.Value) { num = inventory.GetWidth() * (inventory.GetHeight() - 1); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(678f, 0f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(748f, -35f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(678f, -70f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(748f, -105f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(678f, -140f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(643f, -210f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(713f, -210f); ((Component)((Component)___m_playerGrid.m_gridRoot).transform.GetChild(num++)).GetComponent<RectTransform>().anchoredPosition = new Vector2(783f, -210f); } } } } [HarmonyPatch(typeof(Inventory), "FindEmptySlot")] public static class FindEmptySlot_Patch { public static void Prefix(Inventory __instance, ref int ___m_height) { if (modEnabled.Value && addEquipmentRow.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { Dbgl("FindEmptySlot"); ___m_height--; } } public static void Postfix(Inventory __instance, ref int ___m_height) { if (modEnabled.Value && addEquipmentRow.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { ___m_height++; } } } [HarmonyPatch(typeof(Inventory), "GetEmptySlots")] public static class GetEmptySlots_Patch { public static bool Prefix(Inventory __instance, ref int __result, List<ItemData> ___m_inventory, int ___m_width, int ___m_height) { if (!modEnabled.Value || !addEquipmentRow.Value || __instance != ((Humanoid)Player.m_localPlayer).GetInventory()) { return true; } int count = ___m_inventory.FindAll((ItemData i) => i.m_gridPos.y < ___m_height - 1).Count; __result = (___m_height - 1) * ___m_width - count; return false; } } [HarmonyPatch(typeof(Inventory), "HaveEmptySlot")] public static class HaveEmptySlot_Patch { public static bool Prefix(Inventory __instance, ref bool __result, List<ItemData> ___m_inventory, int ___m_width, int ___m_height) { if (modEnabled.Value && addEquipmentRow.Value && ___m_inventory != null) { Player localPlayer = Player.m_localPlayer; if (__instance == ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null)) { int count = ___m_inventory.FindAll((ItemData i) => i?.m_gridPos.y < ___m_height - 1).Count; __result = count < ___m_width * (___m_height - 1); return false; } } return true; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] public static class Inventory_AddItem_Patch1 { public static bool Prefix(Inventory __instance, ref bool __result, List<ItemData> ___m_inventory, ItemData item) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !addEquipmentRow.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || __instance != ((Humanoid)Player.m_localPlayer).GetInventory()) { return true; } Dbgl("AddItem"); if (IsEquipmentSlotFree(__instance, item, out var which)) { item.m_gridPos = new Vector2i(which, __instance.GetHeight() - 1); ___m_inventory.Add(item); ((Humanoid)Player.m_localPlayer).EquipItem(item, false); typeof(Inventory).GetMethod("Changed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[0]); __result = true; return false; } return true; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData), typeof(int), typeof(int), typeof(int) })] public static class Inventory_AddItem_Patch2 { public static void Prefix(Inventory __instance, ref int ___m_width, ref int ___m_height, int x, int y) { if (modEnabled.Value) { if (x >= ___m_width) { ___m_width = x + 1; } if (y >= ___m_height) { ___m_height = y + 1; } } } } [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_Patch { public static void Postfix(Hud __instance) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (modEnabled.Value && addEquipmentRow.Value) { Transform val = Object.Instantiate<Transform>(__instance.m_rootObject.transform.Find("HotKeyBar")); ((Object)val).name = "QuickAccessBar"; val.SetParent(__instance.m_rootObject.transform); ((Transform)((Component)val).GetComponent<RectTransform>()).localPosition = Vector3.zero; GameObject elementPrefab = ((Component)val).GetComponent<HotkeyBar>().m_elementPrefab; QuickAccessBar quickAccessBar = ((Component)val).gameObject.AddComponent<QuickAccessBar>(); quickAccessBar.m_elementPrefab = elementPrefab; BepInExPlugin.elementPrefab = elementPrefab; Object.Destroy((Object)(object)((Component)val).GetComponent<HotkeyBar>()); } } } [HarmonyPatch(typeof(Hud), "Update")] public static class Hud_Update_Patch { public static void Postfix(Hud __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !addEquipmentRow.Value || (Object)(object)Player.m_localPlayer == (Object)null) { return; } float scaleFactor = ((Component)__instance).GetComponent<CanvasScaler>().scaleFactor; Vector3 mousePosition = Input.mousePosition; if (!modEnabled.Value) { lastMousePos = mousePosition; return; } SetElementPositions(); if (lastMousePos == Vector3.zero) { lastMousePos = mousePosition; } Transform val = ((Component)Hud.instance).transform.Find("hudroot"); if (AedenthornUtils.CheckKeyHeld(modKeyOne.Value) && AedenthornUtils.CheckKeyHeld(modKeyTwo.Value)) { Rect zero = Rect.zero; Transform obj = val.Find("QuickAccessBar"); if ((Object)(object)((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null) != (Object)null) { ((Rect)(ref zero))..ctor(((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().anchoredPosition.x * scaleFactor, ((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().anchoredPosition.y * scaleFactor + (float)Screen.height - ((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().sizeDelta.y * scaleFactor * quickAccessScale.Value, ((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().sizeDelta.x * scaleFactor * quickAccessScale.Value * 0.375f, ((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().sizeDelta.y * scaleFactor * quickAccessScale.Value); } if (((Rect)(ref zero)).Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "QuickAccessBar")) { ConfigEntry<float> quickAccessX = BepInExPlugin.quickAccessX; quickAccessX.Value += (mousePosition.x - lastMousePos.x) / scaleFactor; ConfigEntry<float> quickAccessY = BepInExPlugin.quickAccessY; quickAccessY.Value += (mousePosition.y - lastMousePos.y) / scaleFactor; currentlyDragging = "QuickAccessBar"; } else { currentlyDragging = ""; } } else { currentlyDragging = ""; } lastMousePos = mousePosition; } } [HarmonyPatch(typeof(Terminal), "InputText")] public static class InputText_Patch { public static bool Prefix(Terminal __instance) { if (!modEnabled.Value) { return true; } string text = ((TMP_InputField)__instance.m_input).text; if (text.ToLower().Equals(typeof(BepInExPlugin).Namespace.ToLower() + " reset")) { ((BaseUnityPlugin)context).Config.Reload(); ((BaseUnityPlugin)context).Config.Save(); __instance.AddString(text); __instance.AddString(((BaseUnityPlugin)context).Info.Metadata.Name + " config reloaded"); return false; } return true; } } public static BepInExPlugin context; public Harmony harmony; public static ConfigEntry<bool> modEnabled; public static ConfigEntry<bool> isDebug; public static ConfigEntry<int> nexusID; public static ConfigEntry<bool> addEquipmentRow; public static ConfigEntry<bool> showGearInMenu; public static ConfigEntry<bool> displayEquipmentRowSeparate; public static ConfigEntry<int> extraRows; public static ConfigEntry<string> helmetText; public static ConfigEntry<string> chestText; public static ConfigEntry<string> legsText; public static ConfigEntry<string> backText; public static ConfigEntry<string> utilityText; public static ConfigEntry<float> quickAccessScale; public static ConfigEntry<string> hotKey1; public static ConfigEntry<string> hotKey2; public static ConfigEntry<string> hotKey3; public static ConfigEntry<string> modKeyOne; public static ConfigEntry<string> modKeyTwo; public static ConfigEntry<string>[] hotkeys; public static ConfigEntry<float> quickAccessX; public static ConfigEntry<float> quickAccessY; public static GameObject elementPrefab; public static ItemType[] typeEnums; public static FieldInfo[] fields; public static ItemData[] equipItems; public static Vector3 lastMousePos; public static string currentlyDragging; public static void Dbgl(string str = "", bool pref = true) { if (isDebug.Value) { Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str)); } } public void Awake() { //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown context = this; modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod"); isDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsDebug", true, "Enable debug logs"); nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 1356, "Nexus mod ID for updates"); nexusID.Value = 1356; extraRows = ((BaseUnityPlugin)this).Config.Bind<int>("Toggles", "ExtraRows", 0, "Number of extra ordinary rows."); addEquipmentRow = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "AddEquipmentRow", true, "Add special row for equipped items and quick slots."); showGearInMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "ShowGearInMenu", true, "Display equipped items in the main menu."); displayEquipmentRowSeparate = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "DisplayEquipmentRowSeparate", true, "Display equipment and quickslots in their own area."); helmetText = ((BaseUnityPlugin)this).Config.Bind<string>("Strings", "HelmetText", "Head", "Text to show for helmet slot."); chestText = ((BaseUnityPlugin)this).Config.Bind<string>("Strings", "ChestText", "Chest", "Text to show for chest slot."); legsText = ((BaseUnityPlugin)this).Config.Bind<string>("Strings", "LegsText", "Legs", "Text to show for legs slot."); backText = ((BaseUnityPlugin)this).Config.Bind<string>("Strings", "BackText", "Back", "Text to show for back slot."); utilityText = ((BaseUnityPlugin)this).Config.Bind<string>("Strings", "UtilityText", "Utility", "Text to show for utility slot."); quickAccessScale = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "QuickAccessScale", 1f, "Scale of quick access bar."); hotKey1 = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkeys", "HotKey1", "v", "Hotkey 1 - Use https://docs.unity3d.com/Manual/ConventionalGameInput.html"); hotKey2 = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkeys", "HotKey2", "b", "Hotkey 2 - Use https://docs.unity3d.com/Manual/ConventionalGameInput.html"); hotKey3 = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkeys", "HotKey3", "n", "Hotkey 3 - Use https://docs.unity3d.com/Manual/ConventionalGameInput.html"); modKeyOne = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkeys", "ModKey1", "mouse 0", "First modifier key to move quick slots. Use https://docs.unity3d.com/Manual/ConventionalGameInput.html format."); modKeyTwo = ((BaseUnityPlugin)this).Config.Bind<string>("Hotkeys", "ModKey2", "left ctrl", "Second modifier key to move quick slots. Use https://docs.unity3d.com/Manual/ConventionalGameInput.html format."); quickAccessX = ((BaseUnityPlugin)this).Config.Bind<float>("ZCurrentPositions", "quickAccessX", 9999f, "Current X of Quick Slots"); quickAccessY = ((BaseUnityPlugin)this).Config.Bind<float>("ZCurrentPositions", "quickAccessY", 9999f, "Current Y of Quick Slots"); hotkeys = new ConfigEntry<string>[3] { hotKey1, hotKey2, hotKey3 }; harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); harmony.PatchAll(); } public static void ArrangeEquipment(Player __instance) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Invalid comparison between Unknown and I4 //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !addEquipmentRow.Value) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); List<ItemData> allItems = inventory.GetAllItems(); ItemData[] array = (ItemData[])(object)new ItemData[5] { AccessTools.FieldRefAccess<Humanoid, ItemData>((Humanoid)(object)__instance, "m_helmetItem"), AccessTools.FieldRefAccess<Humanoid, ItemData>((Humanoid)(object)__instance, "m_chestItem"), AccessTools.FieldRefAccess<Humanoid, ItemData>((Humanoid)(object)__instance, "m_legItem"), AccessTools.FieldRefAccess<Humanoid, ItemData>((Humanoid)(object)__instance, "m_shoulderItem"), AccessTools.FieldRefAccess<Humanoid, ItemData>((Humanoid)(object)__instance, "m_utilityItem") }; int width = inventory.GetWidth(); int num = width * (inventory.GetHeight() - 1); if (array[0] != null) { array[0].m_gridPos = new Vector2i(num % width, num / width); } num++; if (array[1] != null) { array[1].m_gridPos = new Vector2i(num % width, num / width); } num++; if (array[2] != null) { array[2].m_gridPos = new Vector2i(num % width, num / width); } num++; if (array[3] != null) { array[3].m_gridPos = new Vector2i(num % width, num / width); } num++; if (array[4] != null) { array[4].m_gridPos = new Vector2i(num % width, num / width); } for (int i = 0; i < allItems.Count; i++) { if (!IsAtEquipmentSlot(inventory, allItems[i], out var which)) { continue; } if (allItems[i] == array[which]) { allItems[i].m_equipped = true; continue; } if ((int)allItems[i].m_shared.m_itemType == (int)typeEnums[which] && equipItems[which] != allItems[i]) { ((Humanoid)__instance).EquipItem(allItems[i], true); array[which] = allItems[i]; allItems[i].m_equipped = true; continue; } Vector2i val = (Vector2i)typeof(Inventory).GetMethod("FindEmptySlot", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(inventory, new object[1] { true }); if (val.x < 0 || val.y < 0 || val.y == inventory.GetHeight() - 1) { ((Humanoid)__instance).DropItem(inventory, allItems[i], allItems[i].m_stack); } else { allItems[i].m_gridPos = val; } } equipItems = array; } public static void SetSlotText(string value, Transform transform, bool center = true) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Transform val = transform.Find("binding"); if (!Object.op_Implicit((Object)(object)val)) { val = Object.Instantiate<Transform>(elementPrefab.transform.Find("binding"), transform); } ((Behaviour)((Component)val).GetComponent<TMP_Text>()).enabled = true; ((Component)val).GetComponent<TMP_Text>().text = value; ((Component)val).GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 17f); if (center) { ((Component)val).GetComponent<RectTransform>().anchoredPosition = new Vector2(32f, -10f); } } public static bool IsEquipmentSlotFree(Inventory inventory, ItemData item, out int which) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) which = Array.IndexOf(typeEnums, item.m_shared.m_itemType); return which >= 0 && inventory.GetItemAt(which, inventory.GetHeight() - 1) == null; } public static bool IsAtEquipmentSlot(Inventory inventory, ItemData item, out int which) { if (!addEquipmentRow.Value || item.m_gridPos.x > 4 || item.m_gridPos.y < inventory.GetHeight() - 1) { which = -1; return false; } which = item.m_gridPos.x; return true; } public static void SetElementPositions() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)Hud.instance).transform.Find("hudroot"); Transform obj = val.Find("QuickAccessBar"); if ((Object)(object)((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null) != (Object)null) { if (quickAccessX.Value == 9999f) { quickAccessX.Value = ((Component)val.Find("healthpanel")).GetComponent<RectTransform>().anchoredPosition.x - 32f; } if (quickAccessY.Value == 9999f) { quickAccessY.Value = ((Component)val.Find("healthpanel")).GetComponent<RectTransform>().anchoredPosition.y - 870f; } ((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>().anchoredPosition = new Vector2(quickAccessX.Value, quickAccessY.Value); ((Transform)((Component)val.Find("QuickAccessBar")).GetComponent<RectTransform>()).localScale = new Vector3(quickAccessScale.Value, quickAccessScale.Value, 1f); } } static BepInExPlugin() { ItemType[] array = new ItemType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); typeEnums = (ItemType[])(object)array; fields = new FieldInfo[5] { AccessTools.Field(typeof(Humanoid), "m_helmetItem"), AccessTools.Field(typeof(Humanoid), "m_chestItem"), AccessTools.Field(typeof(Humanoid), "m_legItem"), AccessTools.Field(typeof(Humanoid), "m_shoulderItem"), AccessTools.Field(typeof(Humanoid), "m_utilityItem") }; equipItems = (ItemData[])(object)new ItemData[5]; } } public class QuickAccessBar : MonoBehaviour { public class ElementData { public bool m_used; public GameObject m_go; public Image m_icon; public GuiBar m_durability; public TMP_Text m_amount; public GameObject m_equiped; public GameObject m_queued; public GameObject m_selection; } public GameObject m_elementPrefab; public float m_elementSpace = 70f; public int m_selected; public List<ElementData> m_elements = new List<ElementData>(); public List<ItemData> m_items = new List<ItemData>(); public void Update() { Player localPlayer = Player.m_localPlayer; UpdateIcons(localPlayer); } public void UpdateIcons(Player player) { //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) { foreach (ElementData element in m_elements) { Object.Destroy((Object)(object)element.m_go); } m_elements.Clear(); return; } m_items.Clear(); Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory.GetItemAt(5, inventory.GetHeight() - 1) != null) { m_items.Add(inventory.GetItemAt(5, inventory.GetHeight() - 1)); } if (inventory.GetItemAt(6, inventory.GetHeight() - 1) != null) { m_items.Add(inventory.GetItemAt(6, inventory.GetHeight() - 1)); } if (inventory.GetItemAt(7, inventory.GetHeight() - 1) != null) { m_items.Add(inventory.GetItemAt(7, inventory.GetHeight() - 1)); } m_items.Sort((ItemData x, ItemData y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x)); int num = 0; foreach (ItemData item in m_items) { if (item.m_gridPos.x - 4 > num) { num = item.m_gridPos.x - 4; } } if (m_elements.Count != num) { foreach (ElementData element2 in m_elements) { Object.Destroy((Object)(object)element2.m_go); } m_elements.Clear(); for (int i = 0; i < num; i++) { ElementData elementData = new ElementData(); elementData.m_go = Object.Instantiate<GameObject>(m_elementPrefab, ((Component)this).transform); elementData.m_go.transform.localPosition = new Vector3((float)i * m_elementSpace, 0f, 0f); BepInExPlugin.SetSlotText(BepInExPlugin.hotkeys[i].Value, elementData.m_go.transform, center: false); elementData.m_icon = ((Component)((Component)elementData.m_go.transform).transform.Find("icon")).GetComponent<Image>(); elementData.m_durability = ((Component)elementData.m_go.transform.Find("durability")).GetComponent<GuiBar>(); elementData.m_amount = ((Component)elementData.m_go.transform.Find("amount")).GetComponent<TMP_Text>(); elementData.m_equiped = ((Component)elementData.m_go.transform.Find("equiped")).gameObject; elementData.m_queued = ((Component)elementData.m_go.transform.Find("queued")).gameObject; elementData.m_selection = ((Component)elementData.m_go.transform.Find("selected")).gameObject; m_elements.Add(elementData); } } foreach (ElementData element3 in m_elements) { element3.m_used = false; } bool flag = ZInput.IsGamepadActive(); for (int j = 0; j < m_items.Count; j++) { ItemData val = m_items[j]; ElementData elementData2 = m_elements[val.m_gridPos.x - 5]; elementData2.m_used = true; ((Component)elementData2.m_icon).gameObject.SetActive(true); elementData2.m_icon.sprite = val.GetIcon(); ((Component)elementData2.m_durability).gameObject.SetActive(val.m_shared.m_useDurability); if (val.m_shared.m_useDurability) { if (val.m_durability <= 0f) { elementData2.m_durability.SetValue(1f); elementData2.m_durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f))); } else { elementData2.m_durability.SetValue(val.GetDurabilityPercentage()); elementData2.m_durability.ResetColor(); } } elementData2.m_equiped.SetActive(val.m_equipped); elementData2.m_queued.SetActive(player.IsEquipActionQueued(val)); if (val.m_shared.m_maxStackSize > 1) { ((Component)elementData2.m_amount).gameObject.SetActive(true); elementData2.m_amount.text = val.m_stack + "/" + val.m_shared.m_maxStackSize; } else { ((Component)elementData2.m_amount).gameObject.SetActive(false); } } for (int k = 0; k < m_elements.Count; k++) { ElementData elementData3 = m_elements[k]; elementData3.m_selection.SetActive(flag && k == m_selected); if (!elementData3.m_used) { ((Component)elementData3.m_icon).gameObject.SetActive(false); ((Component)elementData3.m_durability).gameObject.SetActive(false); elementData3.m_equiped.SetActive(false); elementData3.m_queued.SetActive(false); ((Component)elementData3.m_amount).gameObject.SetActive(false); } } } }