using 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 Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.UIElements; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Joive")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Configurable player inventory slots for Burglin Gnomes.")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("BG Inventory QoL")] [assembly: AssemblyTitle("BG-InventoryQoL-Joive")] [assembly: AssemblyVersion("1.3.0.0")] [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 Joive.BurglinGnomes.Inventory { [BepInPlugin("joive.bg.inventoryqol", "BG Inventory QoL", "1.3.0")] public sealed class InventoryQoLPlugin : BaseUnityPlugin { private const string PluginGuid = "joive.bg.inventoryqol"; private const string PluginName = "BG Inventory QoL"; private const string PluginVersion = "1.3.0"; private const int VanillaEquipmentSlotCount = 2; private const int EquipmentSlotCountWithBackpack = 3; private const int EquipmentSlotCountWithExtra = 4; private const int HatSlot = 0; private const int BootsSlot = 1; private const int BackpackSlot = 2; private const int ExtraEquipmentSlot = 3; private const int MaxTotalSlots = 40; private const int MaxHotkeySlots = 10; private const string DefaultExtraEquipmentKeywords = "glider,planer,plane,wing,wings,fairy,планер"; private static readonly Dictionary>> extraWearableHandlers = new Dictionary>>(); private static InventoryQoLPlugin instance; private static ConfigEntry configVersion; private static ConfigEntry enableMod; private static ConfigEntry useVanillaSlots; private static ConfigEntry baseExtraSlots; private static ConfigEntry backpackBonusSlots; private static ConfigEntry overrideBaseSlots; private static ConfigEntry overrideBackpackSlots; private static ConfigEntry enableThreeEquipmentSlots; private static ConfigEntry enableExtraEquipmentSlot; private static ConfigEntry extraSlotAcceptsAnyWearable; private static ConfigEntry extraEquipmentKeywords; private static ConfigEntry enableExtendedHotkeys; private static ConfigEntry enableMouseWheelSelection; private static ConfigEntry pauseGameInMenu; private static ConfigEntry menuKey; private static ConfigEntry debugLogs; private Harmony harmony; private bool menuOpen; private bool pauseApplied; private float previousTimeScale = 1f; private float nextPassiveApplyTime; private string statusMessage = "Ready."; private Rect windowRect = new Rect(90f, 70f, 760f, 560f); private Vector2 menuScroll; private GUIStyle windowStyle; private GUIStyle headerStyle; private GUIStyle labelStyle; private GUIStyle smallLabelStyle; private GUIStyle sectionStyle; private GUIStyle sectionHeaderStyle; private GUIStyle buttonStyle; private GUIStyle activeButtonStyle; internal static bool Enabled { get { if (enableMod != null) { return enableMod.Value; } return false; } } internal static bool CustomSlotsEnabled { get { if (Enabled && useVanillaSlots != null) { return !useVanillaSlots.Value; } return false; } } internal static bool ManagedInventoryEnabled { get { if (Enabled) { if (!CustomSlotsEnabled && !ThreeEquipmentSlotsEnabled) { return ExtraEquipmentSlotEnabled; } return true; } return false; } } internal static bool ThreeEquipmentSlotsEnabled { get { if (Enabled && enableThreeEquipmentSlots != null) { return enableThreeEquipmentSlots.Value; } return false; } } internal static bool ExtraEquipmentSlotEnabled { get { if (ThreeEquipmentSlotsEnabled && enableExtraEquipmentSlot != null) { return enableExtraEquipmentSlot.Value; } return false; } } internal static bool ExtendedHotkeysEnabled { get { if (ManagedInventoryEnabled && enableExtendedHotkeys != null) { return enableExtendedHotkeys.Value; } return false; } } internal static bool MouseWheelSelectionEnabled { get { if (ManagedInventoryEnabled && enableMouseWheelSelection != null) { return enableMouseWheelSelection.Value; } return false; } } internal static int EquipmentSlotCount { get { if (!ExtraEquipmentSlotEnabled) { if (!ThreeEquipmentSlotsEnabled) { return 2; } return 3; } return 4; } } private void Awake() { //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown instance = this; configVersion = ((BaseUnityPlugin)this).Config.Bind("General", "ConfigVersion", "", "Internal config version."); enableMod = ((BaseUnityPlugin)this).Config.Bind("General", "EnableMod", true, "Enable inventory quality-of-life changes."); useVanillaSlots = ((BaseUnityPlugin)this).Config.Bind("Inventory", "UseVanillaSlots", true, "Keep vanilla inventory sizes. Turn this off to use the options below."); baseExtraSlots = ((BaseUnityPlugin)this).Config.Bind("Inventory", "BaseExtraSlots", 0, "Extra slots added to the normal inventory."); backpackBonusSlots = ((BaseUnityPlugin)this).Config.Bind("Inventory", "BackpackBonusSlots", 0, "Extra slots added on top of the backpack's normal bonus."); overrideBaseSlots = ((BaseUnityPlugin)this).Config.Bind("Inventory", "OverrideBaseSlots", 0, "Exact total slots without backpack. 0 means automatic."); overrideBackpackSlots = ((BaseUnityPlugin)this).Config.Bind("Inventory", "OverrideBackpackSlots", 0, "Exact total slots with backpack. 0 means automatic."); enableThreeEquipmentSlots = ((BaseUnityPlugin)this).Config.Bind("Equipment", "EnableThreeEquipmentSlots", true, "Use separate Hat, Boots, and Backpack equipment slots."); enableExtraEquipmentSlot = ((BaseUnityPlugin)this).Config.Bind("Equipment", "EnableExtraEquipmentSlot", true, "Add a fourth equipment slot for glider-style wearable items."); extraSlotAcceptsAnyWearable = ((BaseUnityPlugin)this).Config.Bind("Equipment", "ExtraSlotAcceptsAnyWearable", false, "Let the fourth equipment slot accept any wearable item that is not Hat, Boots, or Backpack."); extraEquipmentKeywords = ((BaseUnityPlugin)this).Config.Bind("Equipment", "ExtraEquipmentKeywords", "glider,planer,plane,wing,wings,fairy,планер", "Comma-separated item name parts that go into the fourth equipment slot."); enableExtendedHotkeys = ((BaseUnityPlugin)this).Config.Bind("Controls", "EnableExtendedHotkeys", true, "Allow number keys 1-0 to select up to 10 hand slots."); enableMouseWheelSelection = ((BaseUnityPlugin)this).Config.Bind("Controls", "EnableMouseWheelSelection", true, "Use the mouse wheel to cycle hand/item slots."); pauseGameInMenu = ((BaseUnityPlugin)this).Config.Bind("Controls", "PauseGameInMenu", true, "Pause the local game while the Inventory QoL menu is open."); menuKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "MenuKey", (KeyCode)290, "Open the BG Inventory QoL menu."); debugLogs = ((BaseUnityPlugin)this).Config.Bind("Debug", "DebugLogs", false, "Write inventory resize messages to BepInEx LogOutput.log."); if (string.IsNullOrEmpty(configVersion.Value)) { ResetToVanillaDefaults(); configVersion.Value = "1.3.0"; ((BaseUnityPlugin)this).Config.Save(); } else if (!string.Equals(configVersion.Value, "1.3.0", StringComparison.Ordinal)) { enableThreeEquipmentSlots.Value = true; enableExtraEquipmentSlot.Value = true; if (string.IsNullOrWhiteSpace(extraEquipmentKeywords.Value)) { extraEquipmentKeywords.Value = "glider,planer,plane,wing,wings,fairy,планер"; } configVersion.Value = "1.3.0"; ((BaseUnityPlugin)this).Config.Save(); } ClampConfigValues(); harmony = new Harmony("joive.bg.inventoryqol"); harmony.PatchAll(typeof(InventoryQoLPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BG Inventory QoL 1.3.0 loaded."); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(menuKey.Value)) { SetMenuOpen(!menuOpen); } if (ManagedInventoryEnabled && Time.unscaledTime >= nextPassiveApplyTime) { nextPassiveApplyTime = Time.unscaledTime + 2f; ApplyToAllPlayers(); } HandleMouseWheelSelection(); } private void OnGUI() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (menuOpen) { EnsureStyles(); windowRect = GUI.Window(4724993, windowRect, new WindowFunction(DrawWindow), string.Empty, windowStyle); } } private void OnDestroy() { RestorePause(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } private void SetMenuOpen(bool open) { menuOpen = open; Cursor.visible = menuOpen; Cursor.lockState = (CursorLockMode)(!menuOpen); if (menuOpen && pauseGameInMenu.Value) { if (!pauseApplied) { previousTimeScale = Time.timeScale; Time.timeScale = 0f; pauseApplied = true; } } else { RestorePause(); } } private void RestorePause() { if (pauseApplied) { Time.timeScale = ((previousTimeScale <= 0f) ? 1f : previousTimeScale); pauseApplied = false; } } private void DrawWindow(int id) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Inventory QoL", headerStyle, Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("Joive build", smallLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); GUILayout.Label("Small inventory changes that still feel like Burglin' Gnomes.", smallLabelStyle, Array.Empty()); GUILayout.Space(8f); menuScroll = GUILayout.BeginScrollView(menuScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(Mathf.Max(300f, ((Rect)(ref windowRect)).height - 118f)) }); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Vanilla", useVanillaSlots.Value ? activeButtonStyle : buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { useVanillaSlots.Value = true; SaveAndApply(); } if (GUILayout.Button("Custom", (!useVanillaSlots.Value) ? activeButtonStyle : buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { useVanillaSlots.Value = false; SaveAndApply(); } GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.BeginVertical(sectionStyle, Array.Empty()); GUILayout.Label("Quick add", sectionHeaderStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("+1 slot now", activeButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) })) { AddLocalSlot(1); } if (GUILayout.Button("-1", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(72f), GUILayout.Height(42f) })) { AddLocalSlot(-1); } if (GUILayout.Button("Apply", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(42f) })) { SaveAndApply(); statusMessage = "Applied."; } GUILayout.EndHorizontal(); GUILayout.Label(GetLiveInventoryText(), smallLabelStyle, Array.Empty()); GUILayout.Label(statusMessage, smallLabelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(sectionStyle, Array.Empty()); DrawToggle("Mod enabled", enableMod); DrawToggle("Hotbar keys 1-0", enableExtendedHotkeys); DrawToggle("Mouse wheel hotbar", enableMouseWheelSelection); DrawToggle("Pause while open", pauseGameInMenu); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(sectionStyle, Array.Empty()); GUILayout.Label("Equipment slots", sectionHeaderStyle, Array.Empty()); DrawToggle("Hat / Boots / Backpack", enableThreeEquipmentSlots); DrawToggle("Extra glider slot", enableExtraEquipmentSlot); DrawToggle("Extra accepts any wearable", extraSlotAcceptsAnyWearable); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Extra item names", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }); string text = GUILayout.TextField(extraEquipmentKeywords.Value ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }); if (!string.Equals(text, extraEquipmentKeywords.Value, StringComparison.Ordinal)) { extraEquipmentKeywords.Value = text; } GUILayout.EndHorizontal(); GUILayout.Label(GetEquipmentSummaryText(), smallLabelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Apply now", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { SaveAndApply(); } if (GUILayout.Button("Vanilla", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { useVanillaSlots.Value = true; baseExtraSlots.Value = 0; backpackBonusSlots.Value = 0; overrideBaseSlots.Value = 0; overrideBackpackSlots.Value = 0; enableThreeEquipmentSlots.Value = true; enableExtraEquipmentSlot.Value = true; extraSlotAcceptsAnyWearable.Value = false; extraEquipmentKeywords.Value = "glider,planer,plane,wing,wings,fairy,планер"; SaveAndApply(); statusMessage = "Vanilla inventory settings restored."; } if (GUILayout.Button("Close", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { SetMenuOpen(open: false); } GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.Label(GetSummaryText(), smallLabelStyle, Array.Empty()); GUILayout.Label("F9 opens this menu. Mouse wheel cycles item slots; 1-0 still works for the first 10.", smallLabelStyle, Array.Empty()); GUILayout.Label("Support: https://ko-fi.com/joive", smallLabelStyle, Array.Empty()); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 42f)); } private void DrawToggle(string text, ConfigEntry entry) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(text, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }); if (GUILayout.Button(entry.Value ? "ON" : "OFF", entry.Value ? activeButtonStyle : buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(90f), GUILayout.Height(26f) })) { entry.Value = !entry.Value; SaveAndApply(); } GUILayout.EndHorizontal(); } private void SaveAndApply() { ClampConfigValues(); configVersion.Value = "1.3.0"; ((BaseUnityPlugin)this).Config.Save(); if (!pauseGameInMenu.Value) { RestorePause(); } ApplyToAllPlayers(); } private void AddLocalSlot(int delta) { PlayerInventory val = FindLocalInventory(); if ((Object)(object)val == (Object)null) { statusMessage = "Local inventory was not found yet. Join a round first."; return; } if (!((NetworkBehaviour)val).IsServer) { statusMessage = "Only the host can change inventory size."; return; } useVanillaSlots.Value = false; bool flag = HasBackpackEquipped(val); int slotCount = ((InventoryBase)val).SlotCount; int num = ClampTotalSlots(slotCount + delta); if (num == slotCount) { statusMessage = "Slot count is already at the limit."; return; } if (flag) { overrideBackpackSlots.Value = num; } else { overrideBaseSlots.Value = num; } ((InventoryBase)val).ResizeInventory(num); ((BaseUnityPlugin)this).Config.Save(); RefreshLocalEquipment(val); statusMessage = "Inventory slots: " + slotCount + " -> " + num + "."; Log(statusMessage); } private void HandleMouseWheelSelection() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!MouseWheelSelectionEnabled || menuOpen || Mathf.Abs(Input.mouseScrollDelta.y) < 0.01f || (Cursor.visible && (int)Cursor.lockState != 1)) { return; } PlayerInventory val = FindLocalInventory(); if ((Object)(object)val == (Object)null) { return; } EquipmentController component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { return; } int num = Mathf.Max(0, ((InventoryBase)val).SlotCount - EquipmentSlotCount); if (num > 0) { int num2 = ((!(Input.mouseScrollDelta.y > 0f)) ? 1 : (-1)); int activeSelectedItemSlot = component.ActiveSelectedItemSlot; int num3 = (((activeSelectedItemSlot >= 0) ? activeSelectedItemSlot : ((num2 > 0) ? (-1) : 0)) + num2) % num; if (num3 < 0) { num3 += num; } component.SetActiveHandSlot(num3); } } private string GetLiveInventoryText() { PlayerInventory val = FindLocalInventory(); if ((Object)(object)val == (Object)null) { return "Current inventory: not found yet."; } string text = (((NetworkBehaviour)val).IsServer ? "host" : "client"); string text2 = (HasBackpackEquipped(val) ? "backpack on" : "no backpack"); return "Current slots: " + ((InventoryBase)val).SlotCount + " | " + text2 + " | " + text + "."; } private string GetSummaryText() { string obj = (useVanillaSlots.Value ? "Vanilla mode: custom values are saved but inactive." : "Custom mode: active."); string text = (ExtraEquipmentSlotEnabled ? "Hat, boots, backpack, and extra equipment slots are active." : (ThreeEquipmentSlotsEnabled ? "Hat, boots, and backpack slots are active." : "Equipment slots stay vanilla.")); return obj + " " + text; } private string GetEquipmentSummaryText() { if (!ThreeEquipmentSlotsEnabled) { return "Vanilla: two wearable slots."; } if (!ExtraEquipmentSlotEnabled) { return "Active: Hat, Boots, Backpack. Normal item slots start after those."; } string text = (extraSlotAcceptsAnyWearable.Value ? "The extra slot accepts any other wearable." : "The extra slot uses the item name list above."); return "Active: Hat, Boots, Backpack, Extra. " + text; } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown if (windowStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.window) { padding = new RectOffset(22, 22, 18, 18) }; val.normal.background = MakeTex(new Color(0.045f, 0.028f, 0.016f, 0.94f)); windowStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 24, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val2.normal.textColor = new Color(1f, 0.7f, 0.22f); headerStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 13 }; val3.normal.textColor = new Color(1f, 0.88f, 0.62f); labelStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 11, wordWrap = true }; val4.normal.textColor = new Color(0.8f, 0.61f, 0.36f); smallLabelStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.box) { padding = new RectOffset(12, 12, 10, 10), margin = new RectOffset(0, 0, 2, 2) }; val5.normal.background = MakeTex(new Color(0.13f, 0.065f, 0.032f, 0.88f)); sectionStyle = val5; GUIStyle val6 = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1 }; val6.normal.textColor = new Color(1f, 0.27f, 0.08f); sectionHeaderStyle = val6; GUIStyle val7 = new GUIStyle(GUI.skin.button) { fontSize = 12 }; val7.normal.textColor = new Color(0.97f, 0.82f, 0.55f); val7.normal.background = MakeTex(new Color(0.22f, 0.1f, 0.045f, 1f)); val7.hover.textColor = Color.white; val7.hover.background = MakeTex(new Color(0.43f, 0.18f, 0.055f, 1f)); val7.active.textColor = Color.white; val7.active.background = MakeTex(new Color(0.58f, 0.22f, 0.045f, 1f)); buttonStyle = val7; GUIStyle val8 = new GUIStyle(buttonStyle); val8.normal.textColor = Color.white; val8.normal.background = MakeTex(new Color(0.78f, 0.3f, 0.055f, 1f)); activeButtonStyle = val8; } } private static Texture2D MakeTex(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); val.Apply(); return val; } internal static int WantedUiSlots(PlayerInventory inventory) { if (!ManagedInventoryEnabled) { return 0; } return GetTargetSlotCount(inventory); } internal static int GetTargetSlotCount(PlayerInventory inventory) { return GetTargetSlotCount(inventory, HasBackpackEquipped(inventory)); } internal static int GetTargetSlotCount(PlayerInventory inventory, bool hasBackpack) { if ((Object)(object)inventory == (Object)null) { return 0; } int num = EquipmentSlotCount - 2; int num2 = Mathf.Max(2, ((InventoryBase)inventory).InitialSlotCount) + num; int num3 = Mathf.Max(num2, GetVanillaBackpackSlots(inventory) + num); int num4 = Mathf.Max(0, num3 - num2); int value = ((overrideBaseSlots.Value > 0) ? overrideBaseSlots.Value : (num2 + (CustomSlotsEnabled ? baseExtraSlots.Value : 0))); value = ClampTotalSlots(value); if (!hasBackpack) { return Mathf.Max(value, EquipmentSlotCount + 1); } return Mathf.Max(ClampTotalSlots((overrideBackpackSlots.Value > 0) ? overrideBackpackSlots.Value : (value + num4 + (CustomSlotsEnabled ? backpackBonusSlots.Value : 0))), EquipmentSlotCount + 1); } internal static int GetVanillaBackpackSlots(PlayerInventory inventory) { try { return (int)(AccessTools.Field(typeof(PlayerInventory), "inventorySizeWithBackpack")?.GetValue(inventory) ?? ((object)((InventoryBase)inventory).InitialSlotCount)); } catch { return ((Object)(object)inventory != (Object)null) ? ((InventoryBase)inventory).InitialSlotCount : 0; } } internal static int ClampTotalSlots(int value) { return Mathf.Clamp(value, EquipmentSlotCount, 40); } internal static void ClampConfigValues() { baseExtraSlots.Value = Mathf.Clamp(baseExtraSlots.Value, -10, 30); backpackBonusSlots.Value = Mathf.Clamp(backpackBonusSlots.Value, -10, 30); overrideBaseSlots.Value = Mathf.Clamp(overrideBaseSlots.Value, 0, 40); overrideBackpackSlots.Value = Mathf.Clamp(overrideBackpackSlots.Value, 0, 40); if (string.IsNullOrWhiteSpace(extraEquipmentKeywords.Value)) { extraEquipmentKeywords.Value = "glider,planer,plane,wing,wings,fairy,планер"; } } internal static void ResetToVanillaDefaults() { useVanillaSlots.Value = true; baseExtraSlots.Value = 0; backpackBonusSlots.Value = 0; overrideBaseSlots.Value = 0; overrideBackpackSlots.Value = 0; enableThreeEquipmentSlots.Value = true; enableExtraEquipmentSlot.Value = true; extraSlotAcceptsAnyWearable.Value = false; extraEquipmentKeywords.Value = "glider,planer,plane,wing,wings,fairy,планер"; enableExtendedHotkeys.Value = true; enableMouseWheelSelection.Value = true; } internal static void ApplyToAllPlayers() { PlayerInventory[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerInventory obj in array) { ApplyCurrentSize(obj); EquipmentController component = ((Component)obj).GetComponent(); if ((Object)(object)component != (Object)null) { component.UpdateEquipmentState(); } } } internal static void ApplyCurrentSize(PlayerInventory inventory) { if (ManagedInventoryEnabled && !((Object)(object)inventory == (Object)null) && ((NetworkBehaviour)inventory).IsServer) { int targetSlotCount = GetTargetSlotCount(inventory); if (targetSlotCount > 0 && ((InventoryBase)inventory).SlotCount != targetSlotCount) { ((InventoryBase)inventory).ResizeInventory(targetSlotCount); Log("Player inventory resized to " + targetSlotCount + " slot(s)."); } } } internal static PlayerInventory FindLocalInventory() { try { PlayerNetworking localPlayer = ServerManager.GetLocalPlayer(); if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Inventory != (Object)null) { return localPlayer.Inventory; } } catch { } PlayerInventory[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerInventory val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsLocalPlayer) { return val; } } return null; } internal static void RefreshLocalEquipment(PlayerInventory inventory) { if (!((Object)(object)inventory == (Object)null)) { EquipmentController component = ((Component)inventory).GetComponent(); if ((Object)(object)component != (Object)null) { component.UpdateEquipmentState(); } } } internal static bool TryHandleBackpackEquipChange(PlayerInventory inventory, string itemName, bool equipped) { if (!ManagedInventoryEnabled || (Object)(object)inventory == (Object)null || !((NetworkBehaviour)inventory).IsServer) { return false; } ItemData backpackItem = GetBackpackItem(inventory); if ((Object)(object)backpackItem == (Object)null || !string.Equals(itemName, ((Object)backpackItem).name, StringComparison.Ordinal)) { return false; } int targetSlotCount = GetTargetSlotCount(inventory, equipped); if (((InventoryBase)inventory).SlotCount != targetSlotCount) { ((InventoryBase)inventory).ResizeInventory(targetSlotCount); } return true; } internal static bool HasBackpackEquipped(PlayerInventory inventory) { ItemData backpackItem = GetBackpackItem(inventory); if ((Object)(object)backpackItem != (Object)null) { return ((InventoryBase)inventory).GetItemCount(((CraftableItemBase)backpackItem).Name) > 0; } return false; } internal static ItemData GetBackpackItem(PlayerInventory inventory) { try { object? obj = AccessTools.Field(typeof(PlayerInventory), "backpack")?.GetValue(inventory); return (ItemData)((obj is ItemData) ? obj : null); } catch { return null; } } internal static bool IsWearableSlot(int slotIndex) { if (slotIndex >= 0) { return slotIndex < EquipmentSlotCount; } return false; } internal static int ExtraWearableStart(PlayerInventory inventory) { return 2; } internal static bool IsReservedWearableSlot(PlayerInventory inventory, int slotIndex) { if (slotIndex < 0 || (Object)(object)inventory == (Object)null) { return false; } return slotIndex < EquipmentSlotCount; } internal static bool AllowedPlayerSlot(PlayerInventory inventory, ItemData itemData, int slotIndex) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 if (!ManagedInventoryEnabled || (Object)(object)inventory == (Object)null || (Object)(object)itemData == (Object)null) { return true; } if (slotIndex == -1) { return true; } if (slotIndex < 0 || slotIndex >= ((InventoryBase)inventory).SlotCount) { return false; } if ((int)itemData.equipmentType != 2) { return slotIndex >= EquipmentSlotCount; } if (!ThreeEquipmentSlotsEnabled) { if (slotIndex != 0) { return slotIndex == 1; } return true; } int requiredEquipmentSlot = GetRequiredEquipmentSlot(inventory, itemData); if (requiredEquipmentSlot >= 0) { return slotIndex == requiredEquipmentSlot; } if (slotIndex != 0) { return slotIndex == 1; } return true; } internal static bool CanFitPlayerItem(PlayerInventory inventory, ItemData itemData) { if (!ManagedInventoryEnabled || (Object)(object)inventory == (Object)null || (Object)(object)itemData == (Object)null) { return true; } for (int i = 0; i < ((InventoryBase)inventory).SlotCount; i++) { if (AllowedPlayerSlot(inventory, itemData, i) && ((InventoryBase)inventory).IsSlotFree(i)) { return true; } } return false; } internal static bool TryCanContainPlayerItem(PlayerInventory inventory, ItemData itemData, int slotIndex, ref ItemContainmentResult result) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if (!ManagedInventoryEnabled || (Object)(object)inventory == (Object)null || (Object)(object)itemData == (Object)null) { return true; } if (slotIndex != -1 && (slotIndex < 0 || slotIndex >= ((InventoryBase)inventory).SlotCount)) { result = (ItemContainmentResult)4; return false; } if ((int)itemData.equipmentType != 2) { return true; } if (((InventoryBase)inventory).GetItemCount(((CraftableItemBase)itemData).Name) > 0) { result = (ItemContainmentResult)2; return false; } if ((Object)(object)FindBlockingEquipment(inventory, itemData) != (Object)null) { result = (ItemContainmentResult)3; return false; } if (slotIndex == -1) { result = (ItemContainmentResult)(!CanFitPlayerItem(inventory, itemData)); return false; } result = (ItemContainmentResult)((!AllowedPlayerSlot(inventory, itemData, slotIndex)) ? 4 : 0); return false; } internal static ItemData FindBlockingEquipment(PlayerInventory inventory, ItemData itemData) { if (itemData.dontAllowEquipTogetherWith == null) { return null; } ItemData[] dontAllowEquipTogetherWith = itemData.dontAllowEquipTogetherWith; foreach (ItemData val in dontAllowEquipTogetherWith) { if (!((Object)(object)val == (Object)null) && ((InventoryBase)inventory).GetItemCount(((CraftableItemBase)val).Name) > 0 && (!ThreeEquipmentSlotsEnabled || !IsManagedEquipmentItem(inventory, itemData) || !IsManagedEquipmentItem(inventory, val))) { return val; } } return null; } internal static bool IsManagedEquipmentItem(PlayerInventory inventory, ItemData itemData) { return GetRequiredEquipmentSlot(inventory, itemData) >= 0; } internal static int GetRequiredEquipmentSlot(PlayerInventory inventory, ItemData itemData) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if ((Object)(object)inventory == (Object)null || (Object)(object)itemData == (Object)null || (int)itemData.equipmentType != 2) { return -1; } if (IsBackpackItem(inventory, itemData)) { return 2; } NormalMovement component = ((Component)inventory).GetComponent(); ItemData movementItem = GetMovementItem(component, "springShoesItemData"); if (SameItem(itemData, movementItem) || NameContains(itemData, "boot", "shoe", "spring")) { return 1; } ItemData movementItem2 = GetMovementItem(component, "helmetItemData"); if (SameItem(itemData, movementItem2) || NameContains(itemData, "hat", "helmet", "cap")) { return 0; } if (IsExtraEquipmentItem(inventory, itemData)) { return 3; } return -1; } internal static bool IsExtraEquipmentItem(PlayerInventory inventory, ItemData itemData) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 if (!ExtraEquipmentSlotEnabled || (Object)(object)inventory == (Object)null || (Object)(object)itemData == (Object)null || (int)itemData.equipmentType != 2) { return false; } if (extraSlotAcceptsAnyWearable != null && extraSlotAcceptsAnyWearable.Value) { return true; } string text = ((((CraftableItemBase)itemData).Name ?? ((Object)itemData).name) ?? string.Empty).ToLowerInvariant(); string[] array = (extraEquipmentKeywords?.Value ?? "glider,planer,plane,wing,wings,fairy,планер").Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim().ToLowerInvariant(); if (text2.Length > 0 && text.Contains(text2)) { return true; } } return false; } internal static bool IsBackpackItem(PlayerInventory inventory, ItemData itemData) { ItemData backpackItem = GetBackpackItem(inventory); if (!SameItem(itemData, backpackItem)) { return NameContains(itemData, "backpack"); } return true; } private static ItemData GetMovementItem(NormalMovement movement, string fieldName) { if ((Object)(object)movement == (Object)null) { return null; } try { object? obj = AccessTools.Field(typeof(NormalMovement), fieldName)?.GetValue(movement); return (ItemData)((obj is ItemData) ? obj : null); } catch { return null; } } private static bool SameItem(ItemData a, ItemData b) { if ((Object)(object)a != (Object)null && (Object)(object)b != (Object)null) { if (a != b && !string.Equals(((CraftableItemBase)a).Name, ((CraftableItemBase)b).Name, StringComparison.OrdinalIgnoreCase)) { return string.Equals(((Object)a).name, ((Object)b).name, StringComparison.OrdinalIgnoreCase); } return true; } return false; } private static bool NameContains(ItemData itemData, params string[] parts) { object obj = ((CraftableItemBase)itemData).Name ?? ((Object)itemData).name; if (obj == null) { obj = string.Empty; } string text = ((string)obj).ToLowerInvariant(); foreach (string value in parts) { if (text.Contains(value)) { return true; } } return false; } internal static void EnsureUiHasSlots(InventoryPanelControl panel, int requiredSlots) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (!ManagedInventoryEnabled || panel == null || panel.slots == null) { return; } if (requiredSlots > panel.slots.Count) { VisualElement val = (VisualElement)(((object)FindSlotParent(panel)) ?? ((object)panel)); while (panel.slots.Count < requiredSlots) { InventorySlotView val2 = new InventorySlotView(); val.Add((VisualElement)(object)val2); ((InventoryItemElement)val2).Init(panel); panel.slots.Add(val2); TryActivateDrag(val2, panel); } ExpandSlotContainer(val); Log("Inventory UI expanded to " + panel.slots.Count + " slot(s)."); } DecorateEquipmentSlots(panel); } internal static void ApplyUiSlotVisibility(InventoryPanelControl panel, int visibleSlots) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (ManagedInventoryEnabled && panel != null && panel.slots != null) { EnsureUiHasSlots(panel, visibleSlots); ExpandSlotContainer((VisualElement)(((object)FindSlotParent(panel)) ?? ((object)panel))); for (int i = 0; i < panel.slots.Count; i++) { ((VisualElement)panel.slots[i]).style.display = StyleEnum.op_Implicit((DisplayStyle)((i >= visibleSlots) ? 1 : 0)); } DecorateEquipmentSlots(panel); } } internal static void DecorateEquipmentSlots(InventoryPanelControl panel) { if (!ThreeEquipmentSlotsEnabled || panel == null) { return; } InventoryBase inventory = panel.Inventory; PlayerInventory val = (PlayerInventory)(object)((inventory is PlayerInventory) ? inventory : null); if (val != null && panel.slots != null) { SetSlotLabel(panel, val, 0, "Hat"); SetSlotLabel(panel, val, 1, "Boots"); SetSlotLabel(panel, val, 2, "Backpack"); if (ExtraEquipmentSlotEnabled) { SetSlotLabel(panel, val, 3, "Glider"); } } } private static void SetSlotLabel(InventoryPanelControl panel, PlayerInventory inventory, int slotIndex, string text) { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0052: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if (slotIndex >= 0 && slotIndex < panel.slots.Count) { InventorySlotView val = panel.slots[slotIndex]; Label val2 = UQueryExtensions.Q