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 EquipmentAndQuickSlotsPlus v3.1.1
plugins/EquipmentAndQuickSlotsPlus.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Auga; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Common; using EquipmentAndQuickSlots.src.MultiUtility; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("EquipmentAndQuickSlotsPlus")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Randy Knapp Mods")] [assembly: AssemblyProduct("EquipmentAndQuickSlotsPlus")] [assembly: AssemblyCopyright("Copyright © Randy Knapp 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("08ed5bc9-9e0c-4343-90a5-92497be6e216")] [assembly: AssemblyFileVersion("3.0.1")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("Splatform")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.0.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; } } } public sealed class ConfigurationManagerAttributes { public bool IsAdminOnly { get; set; } public bool IsAdvanced { get; set; } } public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace EquipmentAndQuickSlots { public static class API { public const int ApiVersion = 2; private static readonly List<Action<string>> slotChangedListeners = new List<Action<string>>(); private static readonly List<Action<string, ItemData, ItemData>> slotItemChangedListeners = new List<Action<string, ItemData, ItemData>>(); private static readonly Dictionary<string, ItemData> lastKnownSlotItems = new Dictionary<string, ItemData>(); public static int GetApiVersion() { return 2; } public static string GetPluginVersion() { return "3.1.1"; } public static string GetPluginId() { return "randyknapp.mods.equipmentandquickslots"; } public static bool HasEndpoint(string name) { return typeof(API).GetMethods(BindingFlags.Static | BindingFlags.Public).Any((MethodInfo m) => m.Name == name); } public static List<string> GetEndpointNames() { return (from n in (from m in typeof(API).GetMethods(BindingFlags.Static | BindingFlags.Public) select m.Name).Distinct() orderby n select n).ToList(); } public static bool AddSlot(string slotId, string ownerPluginGuid, string nameToken, Func<ItemData, bool> isValid, Func<bool> isActive) { if (string.IsNullOrEmpty(slotId)) { return false; } bool num = Slots.TryAddCustomSlot(slotId, ownerPluginGuid, () => nameToken ?? "", (ItemData item) => GuardedPredicate(ownerPluginGuid, isValid, item), () => GuardedActive(ownerPluginGuid, isActive)); if (num) { NotifySlotChanged(slotId); } return num; } public static bool RemoveSlot(string slotId) { bool num = Slots.TryRemoveCustomSlot(slotId); if (num) { lastKnownSlotItems.Remove("Custom" + slotId); NotifySlotChanged(slotId); } return num; } private static bool GuardedPredicate(string owner, Func<ItemData, bool> isValid, ItemData item) { if (isValid == null) { return true; } try { return isValid(item); } catch (Exception arg) { Debug.LogWarning((object)$"[EAQS API] isValid delegate of '{owner}' threw: {arg}"); return false; } } private static bool GuardedActive(string owner, Func<bool> isActive) { if (isActive == null) { return true; } try { return isActive(); } catch (Exception arg) { Debug.LogWarning((object)$"[EAQS API] isActive delegate of '{owner}' threw: {arg}"); return false; } } public static string GetSlotIdsJson() { StringBuilder stringBuilder = new StringBuilder("["); bool flag = true; Slots.Slot[] slots = Slots.slots; foreach (Slots.Slot slot in slots) { if (!slot.IsEmptySlot) { if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append('"').Append(Escape(PublicSlotId(slot))).Append('"'); } } return stringBuilder.Append(']').ToString(); } public static string GetSlotInfoJson(string slotId) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) Slots.Slot slot = FindPublicSlot(slotId); if (slot == null) { return null; } return "{\"id\":\"" + Escape(PublicSlotId(slot)) + "\"," + $"\"index\":{slot.Index}," + "\"nameToken\":\"" + Escape(slot.Name) + "\",\"active\":" + (slot.IsActive ? "true" : "false") + "," + $"\"gridX\":{slot.GridPosition.x}," + $"\"gridY\":{slot.GridPosition.y}," + "\"isQuickSlot\":" + (slot.IsQuickSlot ? "true" : "false") + ",\"isEquipmentSlot\":" + (slot.IsEquipmentSlot ? "true" : "false") + ",\"isCustomSlot\":" + (slot.IsCustomSlot ? "true" : "false") + ",\"ownerPluginGuid\":\"" + Escape(slot.OwnerGuid ?? "") + "\",\"occupied\":" + ((slot.Item != null) ? "true" : "false") + "}"; } public static bool TryGetSlotItem(string slotId, ref ItemData item) { Slots.Slot slot = FindPublicSlot(slotId); if (slot == null) { return false; } item = slot.Item; return item != null; } public static bool IsSlotCell(int x, int y, ref string slotId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Slots.Slot slotInGrid = Slots.GetSlotInGrid(new Vector2i(x, y)); if (slotInGrid == null || slotInGrid.IsEmptySlot) { return false; } slotId = PublicSlotId(slotInGrid); return true; } public static List<ItemData> GetQuickSlotItems() { return (from slot in Slots.GetQuickSlots() where slot.IsActive select slot.Item into item where item != null select item).ToList(); } public static List<ItemData> GetEquipmentSlotItems() { return (from slot in Slots.GetEquipmentSlots() select slot.Item into item where item != null select item).ToList(); } public static int GetVisibleRows() { return Slots.VisibleRows; } public static int GetFullHeight() { return Slots.FullHeight; } public static void AddSlotChangedListener(Action<string> listener) { if (listener != null && !slotChangedListeners.Contains(listener)) { slotChangedListeners.Add(listener); } } public static void RemoveSlotChangedListener(Action<string> listener) { slotChangedListeners.Remove(listener); } public static void AddSlotItemChangedListener(Action<string, ItemData, ItemData> listener) { if (listener != null && !slotItemChangedListeners.Contains(listener)) { slotItemChangedListeners.Add(listener); } } public static void RemoveSlotItemChangedListener(Action<string, ItemData, ItemData> listener) { slotItemChangedListeners.Remove(listener); } private static string PublicSlotId(Slots.Slot slot) { if (!slot.IsCustomSlot) { return slot.ID; } return slot.ID.Substring("Custom".Length); } private static Slots.Slot FindPublicSlot(string slotId) { if (string.IsNullOrEmpty(slotId)) { return null; } Slots.Slot slot = Slots.FindSlot(slotId) ?? Slots.FindSlot("Custom" + slotId); if (slot == null || slot.IsEmptySlot) { return null; } return slot; } private static string Escape(string value) { return value?.Replace("\\", "\\\\").Replace("\"", "\\\"") ?? ""; } private static void NotifySlotChanged(string slotId) { foreach (Action<string> item in slotChangedListeners.ToList()) { try { item(slotId); } catch (Exception arg) { Debug.LogWarning((object)$"[EAQS API] slot-changed listener threw: {arg}"); } } } internal static void DetectSlotItemChanges() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (slotItemChangedListeners.Count == 0 || (Object)Player.m_localPlayer == (Object)null) { return; } Slots.Slot[] slots = Slots.slots; foreach (Slots.Slot slot in slots) { if (slot.IsEmptySlot) { continue; } string iD = slot.ID; ItemData item = slot.Item; lastKnownSlotItems.TryGetValue(iD, out var value); if (item == value) { continue; } lastKnownSlotItems[iD] = item; string arg = PublicSlotId(slot); foreach (Action<string, ItemData, ItemData> item2 in slotItemChangedListeners.ToList()) { try { item2(arg, value, item); } catch (Exception arg2) { Debug.LogWarning((object)$"[EAQS API] slot-item-changed listener threw: {arg2}"); } } } } } public static class AugaPanel { private const string PanelName = "EAQS"; private static readonly Vector2 panelBase = new Vector2(752f, -166f); private const float panelWidth = 255f; private const float panelHeight = 352f; private const float paperdollHeight = 157f; private const float tileSize = 74f; private static readonly Vector2 equipClusterCenter = new Vector2(110.5f, -57f); private static readonly Vector2[] equipPositions = (Vector2[])(object)new Vector2[8] { new Vector2(0f, 0f), new Vector2(-36f, -72f), new Vector2(0f, -144f), new Vector2(36f, -72f), new Vector2(104f, 0f), new Vector2(-104f, 0f), new Vector2(104f, -72f), new Vector2(104f, -144f) }; private static GameObject _panel; private const int customSlotsPerColumn = 4; private static int ActiveQuickSlots { get { if (!ValConfig.QuickSlotsEnabled.Value) { return 0; } return ValConfig.QuickSlotCount.Value; } } private static Slots.Slot[] ActiveCustomSlots => (from slot in Slots.GetCustomSlots() where slot.IsActive orderby slot.Index select slot).ToArray(); private static float PanelWidth => Mathf.Max(255f, (float)ActiveQuickSlots * 74f + 20f); internal static Vector2 GetSlotPosition(Slots.Slot slot) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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) if (slot.IsEquipmentSlot) { return panelBase + equipClusterCenter + equipPositions[slot.Index - 8]; } if (slot.IsQuickSlot) { float num = (PanelWidth - (float)ActiveQuickSlots * 74f) / 2f + 5f; return panelBase + new Vector2(num + (float)slot.Index * 74f, -187f); } if (slot.IsCustomSlot) { int num2 = Math.Max(0, Array.IndexOf(ActiveCustomSlots, slot)); int num3 = num2 % 4; int num4 = num2 / 4; return panelBase + new Vector2(PanelWidth + 10f + (float)num4 * 74f, 0f - (float)num3 * 74f); } return panelBase; } internal static void UpdatePanel() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0047: 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_0066: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ad: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)InventoryGui.instance) || !Object.op_Implicit((Object)InventoryGui.instance.m_player)) { return; } if ((Object)_panel == (Object)null) { _panel = Auga.API.Panel_Create((Transform)InventoryGui.instance.m_player, new Vector2(PanelWidth, 352f), "EAQS", withCornerDecoration: false); if ((Object)_panel == (Object)null) { return; } RectTransform val = (RectTransform)_panel.transform; val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.anchoredPosition = panelBase; val.SetSizeWithCurrentAnchors((Axis)0, PanelWidth); val.SetSizeWithCurrentAnchors((Axis)1, 352f); ((Object)Object.Instantiate<GameObject>(EquipmentAndQuickSlots.Paperdolls, _panel.transform, false)).name = "Paperdolls"; ((RectTransform)Auga.API.Divider_CreateSmall(_panel.transform, "Divider", PanelWidth - 40f).transform).anchoredPosition = new Vector2(0f, -157f); } _panel.SetActive(ValConfig.EquipmentSlotsEnabled.Value || ActiveQuickSlots > 0); UpdatePaperdollGender(); } private static void UpdatePaperdollGender() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null || (Object)_panel == (Object)null) { return; } Transform val = _panel.transform.Find("Paperdolls"); if (!((Object)val == (Object)null)) { bool flag = (Object)((Humanoid)localPlayer).m_visEquipment != (Object)null && ((Humanoid)localPlayer).m_visEquipment.GetModelIndex() == 1; Transform val2 = val.Find("Male"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(!flag); } Transform val3 = val.Find("Female"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(flag); } } } internal static void Clear() { _panel = null; } } internal static class BetterArcheryCompat { public const string BetterArcheryGUID = "ishid4.mods.betterarchery"; private const string PluginTypeName = "BetterArchery.BetterArchery"; private const string QuiverConfigSection = "Quiver"; private const string QuiverConfigKey = "Enable Quiver"; private const string HoldingKeyConfigKey = "Quiver slot hotkey holding key"; private const string KnownVersion = "1.9.8x"; private static readonly int[] QuiverSlotIndices = new int[3] { 16, 17, 18 }; private const string QuiverSlotIdPrefix = "BetterArcheryQuiver"; private static PluginInfo _plugin; private static Assembly _assembly; private static ConfigEntry<bool> _quiverEnabled; private static ConfigEntry<KeyboardShortcut> _holdingKey; private static Func<bool> _isQuiverEquipped; private static Func<int, string> _getBindingLabel; private static FieldInfo _quiverRowIndex; private static bool _initialized; private static bool _quiverDisableHooked; private static bool _quiverStateWarned; internal static bool QuiverHosted { get; private set; } public static bool IsLoaded => Chainloader.PluginInfos.ContainsKey("ishid4.mods.betterarchery"); internal static void Initialize(Harmony harmony) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (_initialized) { return; } _initialized = true; if (!Chainloader.PluginInfos.TryGetValue("ishid4.mods.betterarchery", out _plugin)) { return; } PluginInfo plugin = _plugin; if ((Object)((plugin != null) ? plugin.Instance : null) == (Object)null) { return; } _assembly = ((object)_plugin.Instance).GetType().Assembly; CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(TombStone), "OnTakeAllSuccess", "BetterArchery.Tombstone+TombStone_OnTakeAllSuccess_Patch", "Postfix", "stop it dropping equipment and quick slot items when a gravestone is emptied"); if (!_plugin.Instance.Config.TryGetEntry<bool>("Quiver", "Enable Quiver", ref _quiverEnabled)) { EquipmentAndQuickSlots.LogWarning(string.Format("Better Archery is loaded but its '{0}' setting could not be read (this logic was written for {1}, the installed version is {2}). Its quiver may conflict with the equipment and quick slots.", "Enable Quiver", "1.9.8x", _plugin.Metadata.Version)); } else if (_quiverEnabled.Value) { if (!ValConfig.BetterArcheryQuiverIntegration.Value) { DisableQuiver("the Better Archery quiver integration is turned off in this mod's config"); return; } if (!BindBetterArchery() || !ClaimQuiverSlots()) { DisableQuiver("its quiver could not be hosted in the equipment panel"); return; } QuiverHosted = true; SyncQuiverRow(); CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(Player), "Awake", "BetterArchery.Player_Awake_Patch", "Prefix", "stop it replacing the player inventory with a taller one (the empty cells under the inventory)"); CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(InventoryGrid), "UpdateGui", "BetterArchery.InventoryGrid_UpdateGui_Patch", "Postfix", "let the equipment panel own the quiver cells and their positions"); CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(Inventory), "FindEmptySlot", "BetterArchery.Inventory_FindEmptySlot_Patch", "Prefix", "stop it handing out equipment and quick slot cells as free space"); CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(Inventory), "HaveEmptySlot", "BetterArchery.Inventory_HaveEmptySlot_Patch", "Prefix", "stop its hardcoded capacity arithmetic overriding the slot-aware count"); CompatibilityHelper.RemoveHarmonyPatch(harmony, _assembly, typeof(Player), "CreateTombStone", "BetterArchery.Player_CreateTombStone_Patch", "Prefix", "keep a single gravestone instead of a separate one for the quiver"); EquipmentAndQuickSlots.LogInfo($"Better Archery {_plugin.Metadata.Version} detected: its quiver is hosted in three ammo-only slots in the equipment panel."); } } private static bool BindBetterArchery() { Type type = _assembly.GetType("BetterArchery.BetterArchery"); if (type == null) { EquipmentAndQuickSlots.LogWarning("Better Archery is loaded but BetterArchery.BetterArchery could not be resolved."); return false; } _isQuiverEquipped = CompatibilityHelper.BindStatic<Func<bool>>(type, "IsQuiverEquipped"); _getBindingLabel = CompatibilityHelper.BindStatic<Func<int, string>>(type, "GetBindingLabel"); _quiverRowIndex = AccessTools.Field(type, "QuiverRowIndex"); _plugin.Instance.Config.TryGetEntry<KeyboardShortcut>("Quiver", "Quiver slot hotkey holding key", ref _holdingKey); if (_isQuiverEquipped != null && _quiverRowIndex != null && _quiverRowIndex.FieldType == typeof(int)) { return true; } EquipmentAndQuickSlots.LogWarning(string.Format("Better Archery's quiver members could not be bound (this logic was written for {0}, the installed version is {1}).", "1.9.8x", _plugin.Metadata.Version)); return false; } private static bool ClaimQuiverSlots() { int num = 0; for (int i = 0; i < QuiverSlotIndices.Length; i++) { int ordinal = i; if (!Slots.TryAddCustomSlotAt(QuiverSlotIndices[i], "BetterArcheryQuiver" + (i + 1), "ishid4.mods.betterarchery", () => SlotLabel(ordinal), IsQuiverAmmo, IsQuiverEquipped)) { break; } num++; } if (num == QuiverSlotIndices.Length && QuiverCellsAreWhereBetterArcheryExpects()) { return true; } for (int num2 = 0; num2 < num; num2++) { Slots.TryRemoveCustomSlot("BetterArcheryQuiver" + (num2 + 1)); } return false; } private static bool QuiverCellsAreWhereBetterArcheryExpects() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) int y = Slots.slots[QuiverSlotIndices[0]].GridPosition.y; for (int i = 0; i < QuiverSlotIndices.Length; i++) { Vector2i gridPosition = Slots.slots[QuiverSlotIndices[i]].GridPosition; if (gridPosition.x != i || gridPosition.y != y) { return false; } } return true; } private static bool IsQuiverEquipped() { if (_isQuiverEquipped == null) { return false; } try { return _isQuiverEquipped(); } catch (Exception ex) { if (!_quiverStateWarned) { _quiverStateWarned = true; EquipmentAndQuickSlots.LogWarning("Better Archery's IsQuiverEquipped threw; the quiver slots stay hidden: " + ex.Message); } return false; } } private static bool IsQuiverAmmo(ItemData item) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (item != null) { return (int)item.m_shared.m_itemType == 9; } return false; } private static string SlotLabel(int ordinal) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown //IL_0040: 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_0049: Unknown result type (might be due to invalid IL or missing references) string text = ((_getBindingLabel != null) ? _getBindingLabel(ordinal) : (ordinal + 1).ToString()); int num; if (_holdingKey != null) { KeyboardShortcut value = _holdingKey.Value; num = (int)((KeyboardShortcut)(ref value)).MainKey; } else { num = 0; } KeyCode val = (KeyCode)num; if ((int)val != 0) { return $"{val} + {text}"; } return text; } internal static void SyncQuiverRow() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (QuiverHosted) { int y = Slots.slots[QuiverSlotIndices[0]].GridPosition.y; if ((int)_quiverRowIndex.GetValue(null) != y) { _quiverRowIndex.SetValue(null, y); } } } private static void DisableQuiver(string reason) { if (_quiverEnabled == null || !_quiverEnabled.Value) { return; } if (!_quiverDisableHooked) { _quiverDisableHooked = true; _quiverEnabled.SettingChanged += delegate { DisableQuiver(reason); }; } _quiverEnabled.Value = false; EquipmentAndQuickSlots.LogWarning(string.Format("Better Archery's quiver was disabled because {0}. Arrows already in it are not lost -- they move into your inventory. Use the quick slots for ammo instead. (This logic was written for Better Archery {1}; the installed version is {2}.)", reason, "1.9.8x", _plugin.Metadata.Version)); } } internal static class BetterUICompat { public const string BetterUIGUID = "MK_BetterUI"; private static bool _handoffNoted; public static bool IsLoaded => Chainloader.PluginInfos.ContainsKey("MK_BetterUI"); internal static void NoteQuickBarHandoff(HotkeyBar quickBar) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if (!_handoffNoted && !((Object)quickBar == (Object)null)) { _handoffNoted = true; if (IsLoaded && (Object)((Component)quickBar).GetComponent<ConfigPositionedElement>() == (Object)null) { EquipmentAndQuickSlots.LogInfo("BetterUI's HUD editor is positioning the quick slot bar; 'Quick Slots Anchor' and 'Quick Slots Position' only set where it starts. Move the bar with BetterUI's HUD edit key (F7 by default)."); } } } } internal static class CompatibilityHelper { internal static bool RemoveHarmonyPatch(Harmony harmony, Assembly assembly, Type patchedType, string patchedMethod, string patcherClassName, string patcherClassMethod, string reason) { if (harmony == null || assembly == null) { return false; } Type type = assembly.GetType(patcherClassName); if (type == null) { EquipmentAndQuickSlots.LogInfo("Compatibility: " + patcherClassName + " not found; nothing to unpatch"); return false; } MethodInfo methodInfo = AccessTools.Method(patchedType, patchedMethod, (Type[])null, (Type[])null); if ((object)methodInfo == null) { EquipmentAndQuickSlots.LogInfo("Compatibility: " + patchedType.Name + "." + patchedMethod + " not found; nothing to unpatch"); return false; } MethodInfo methodInfo2 = AccessTools.Method(type, patcherClassMethod, (Type[])null, (Type[])null); if ((object)methodInfo2 == null) { EquipmentAndQuickSlots.LogInfo("Compatibility: " + patcherClassName + "." + patcherClassMethod + " not found; nothing to unpatch"); return false; } try { harmony.Unpatch((MethodBase)methodInfo, methodInfo2); } catch (Exception ex) { EquipmentAndQuickSlots.LogWarning("Compatibility: failed to unpatch " + patcherClassName + "." + patcherClassMethod + ": " + ex.Message); return false; } EquipmentAndQuickSlots.LogInfo("Compatibility: unpatched " + patcherClassName + "." + patcherClassMethod + " from " + patchedType.Name + "." + patchedMethod + " to " + reason); return true; } internal static TDelegate BindStatic<TDelegate>(Type type, string methodName) where TDelegate : class { if (type == null) { return null; } MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); if ((object)methodInfo == null || !methodInfo.IsStatic) { return null; } try { return Delegate.CreateDelegate(typeof(TDelegate), methodInfo, throwOnBindFailure: false) as TDelegate; } catch (Exception) { return null; } } } internal static class ContainerExpansion { [HarmonyPatch(typeof(Container), "Awake")] private static class Container_Awake_ApplyExtraChestRows { [HarmonyPriority(900)] private static void Prefix(Container __instance) { ApplyRows(__instance); } } [HarmonyPatch(typeof(Container), "Load")] private static class Container_Load_ApplyExtraChestRows { private static void Postfix(Container __instance) { ApplyRows(__instance); } } [HarmonyPatch(typeof(InventoryGui), "Awake")] private static class InventoryGui_Awake_CaptureContainerPanel { private static void Postfix(InventoryGui __instance) { TrackPanel(__instance); } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] private static class InventoryGui_UpdateContainer_ResizeExpandedChest { private static void Prefix(InventoryGui __instance) { ApplyCurrentContainerRows(__instance); } private static void Postfix(InventoryGui __instance) { ApplyContainerPanelSize(__instance); } } private sealed class RowState { public int Rows { get; } public RowState(int rows) { Rows = rows; } } private sealed class PanelState { public float BaseContainerHeight { get; } public PanelState(float baseContainerHeight) { BaseContainerHeight = baseContainerHeight; } } private const int MaxExtraRows = 3; private static readonly ConditionalWeakTable<Container, RowState> ContainerBaseRows = new ConditionalWeakTable<Container, RowState>(); private static readonly ConditionalWeakTable<InventoryGui, PanelState> GuiPanelStates = new ConditionalWeakTable<InventoryGui, PanelState>(); private static int ExtraRows => Mathf.Clamp(ValConfig.ExtraChestRows?.Value ?? 0, 0, 3); internal static void OnChestRowsChanged() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ConfigFile cfg = ValConfig.cfg; if (cfg != null) { cfg.Save(); } InventoryGui instance = InventoryGui.instance; if (Object.op_Implicit((Object)instance)) { ApplyCurrentContainerRows(instance); Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer != (Object)null) { instance.UpdateContainer(localPlayer); } ApplyContainerPanelSize(instance); } } private static void ApplyCurrentContainerRows(InventoryGui gui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (Object.op_Implicit((Object)gui)) { Container currentContainer = gui.m_currentContainer; if (Object.op_Implicit((Object)currentContainer)) { ApplyRows(currentContainer); } } } private static void ApplyRows(Container container) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown if (Object.op_Implicit((Object)container) && !IsTombstone(container)) { int baseRows = GetBaseRows(container); Inventory inventory = container.m_inventory; int num = Math.Max(val2: RequiredRows(inventory), val1: baseRows + ExtraRows); if (container.m_height != num) { container.m_height = num; } if (inventory != null && inventory.m_height != num) { inventory.m_height = num; inventory.Changed(false, false); } } } private static int GetBaseRows(Container container) { if (ContainerBaseRows.TryGetValue(container, out var value)) { return value.Rows; } int num = Math.Max(1, container.m_height); ContainerBaseRows.Add(container, new RowState(num)); return num; } private static int RequiredRows(Inventory inventory) { if (inventory == null || inventory.m_inventory == null || inventory.m_inventory.Count == 0) { return 1; } return Math.Max(1, inventory.m_inventory.Max((ItemData item) => item.m_gridPos.y + 1)); } private static bool IsTombstone(Container container) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Component val = (Component)container; if ((Object)val.GetComponent<TombStone>() != (Object)null) { return true; } return (Object)val.GetComponentInParent<TombStone>() != (Object)null; } private static void TrackPanel(InventoryGui gui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)gui) && Object.op_Implicit((Object)gui.m_container)) { GuiPanelStates.Remove(gui); GuiPanelStates.Add(gui, new PanelState(gui.m_container.sizeDelta.y)); } } private static void ApplyContainerPanelSize(InventoryGui gui) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)gui) || !Object.op_Implicit((Object)gui.m_container)) { return; } Container currentContainer = gui.m_currentContainer; if (Object.op_Implicit((Object)currentContainer)) { Inventory inventory = currentContainer.GetInventory(); if (inventory != null) { PanelState panelState = GetPanelState(gui); int num = Math.Max(0, inventory.m_height - GetBaseRows(currentContainer)); float num2 = ((gui.m_invGridHeight > 0f) ? gui.m_invGridHeight : GetFallbackRowHeight(gui)); Vector2 sizeDelta = gui.m_container.sizeDelta; sizeDelta.y = panelState.BaseContainerHeight + (float)num * num2; gui.m_container.sizeDelta = sizeDelta; } } } private static PanelState GetPanelState(InventoryGui gui) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (GuiPanelStates.TryGetValue(gui, out var value)) { return value; } value = new PanelState(Object.op_Implicit((Object)gui.m_container) ? gui.m_container.sizeDelta.y : 0f); GuiPanelStates.Add(gui, value); return value; } private static float GetFallbackRowHeight(InventoryGui gui) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (Object.op_Implicit((Object)gui.m_containerGrid) && gui.m_containerGrid.m_elementSpace > 0f) { return gui.m_containerGrid.m_elementSpace; } return 70f; } } public static class DeathPatches { private class KeptItem { public ItemData item; public bool wasEquipped; } [HarmonyPatch(typeof(Character), "CheckDeath")] private static class Character_CheckDeath_OnDeathWrapping { [HarmonyPriority(800)] private static void Prefix(Character __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (Slots.IsValidPlayer(__instance) && !__instance.IsDead() && __instance.GetHealth() <= 0f) { OnDeathPrefix((Player)__instance); } } [HarmonyFinalizer] [HarmonyPriority(0)] private static Exception Finalizer(Character __instance, Exception __exception) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (Slots.IsValidPlayer(__instance)) { OnDeathPostfix((Player)__instance); } return __exception; } } [HarmonyPatch(typeof(Player), "OnDeath")] private static class Player_OnDeath_RestoreKeptItems { [HarmonyPriority(0)] private static void Postfix(Player __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown if (Slots.IsValidPlayer((Character)__instance)) { OnDeathPostfix(__instance); } } [HarmonyFinalizer] [HarmonyPriority(0)] private static Exception Finalizer(Player __instance, Exception __exception) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown if (Slots.IsValidPlayer((Character)__instance)) { OnDeathPostfix(__instance); } return __exception; } } [HarmonyPatch(typeof(Container), "Awake")] private static class Container_Awake_TombstoneHeightAdjustment { private static void Prefix(Container __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!(__instance.m_name != "Grave") || Object.op_Implicit((Object)((Component)__instance).GetComponentInParent<TombStone>())) { int num = TargetGraveHeight(__instance.m_width); if (num > __instance.m_height) { __instance.m_height = num; } } } private static void Postfix(Container __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown ZNetView nview = __instance.m_nview; if ((Object)(object)nview != (Object)null && nview.IsValid() && __instance.m_nview.IsOwner() && (Object)((Component)__instance).GetComponent<TombStone>() != (Object)null && __instance.m_height > 4) { string name = ((object)__instance).GetType().Name; __instance.m_nview.GetZDO().Set("HasFields", true); __instance.m_nview.GetZDO().Set(StringExtensionMethods.GetStableHashCode("HasFields" + name), true); __instance.m_nview.GetZDO().Set(name + ".m_height", __instance.m_height); } } } [HarmonyPatch(typeof(TombStone), "Setup")] private static class TombStone_Setup_PersistGraveDimensions { private static void Postfix(TombStone __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Container val = (((Object)__instance.m_container != (Object)null) ? __instance.m_container : ((Component)__instance).GetComponent<Container>()); if (!((Object)val == (Object)null) && val.m_inventory != null) { val.m_width = Mathf.Max(val.m_width, val.m_inventory.m_width); val.m_height = Mathf.Max(val.m_height, val.m_inventory.m_height); ZNetView nview = val.m_nview; if ((Object)(object)nview != (Object)null && nview.IsValid() && val.m_nview.IsOwner()) { string name = ((object)val).GetType().Name; ZDO zDO = val.m_nview.GetZDO(); zDO.Set("HasFields", true); zDO.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name), true); zDO.Set(name + ".m_width", val.m_width); zDO.Set(name + ".m_height", val.m_height); } } } } [HarmonyPatch(typeof(TombStone), "Interact")] private static class TombStone_Interact_AdjustHeight { [HarmonyPriority(800)] private static void Prefix(TombStone __instance, bool hold) { if (!hold) { int num = TargetGraveHeight(__instance.m_container.m_width); if (num > __instance.m_container.m_height) { __instance.m_container.m_height = num; __instance.m_container.m_inventory.m_height = num; __instance.m_container.m_lastRevision = 0u; __instance.m_container.Load(); } } } } [HarmonyPatch(typeof(TombStone), "EasyFitInInventory")] private static class TombStone_EasyFitInInventory_SlotAwareCounting { private static float GetDynamicWeightChange(StatusEffect se) { float result = 0f; se.ModifyMaxCarryWeight(0f, ref result); return result; } private static void Prefix(TombStone __instance, Player player, ref float __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown if (!Slots.IsValidPlayer((Character)player)) { return; } StatusEffect lootStatusEffect = __instance.m_lootStatusEffect; __state = ((SE_Stats)(((lootStatusEffect is SE_Stats) ? lootStatusEffect : null)?)).m_addMaxCarryWeight ?? 0f; if (ValConfig.AutoEquipCarryWeightItems.Value || ValConfig.InstantlyReequipArmorOnPickup.Value) { __state += __instance.m_container.GetInventory().GetAllItems().Where(delegate(ItemData item) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (item != null && (Object)item.m_shared.m_equipStatusEffect != (Object)null) { Slots.Slot slotInGrid = Slots.GetSlotInGrid(item.m_gridPos); if (slotInGrid != null) { return slotInGrid.IsEquipmentSlot; } } return false; }) .Sum((ItemData item) => GetDynamicWeightChange(item.m_shared.m_equipStatusEffect)); } Player localPlayer = Player.m_localPlayer; localPlayer.m_maxCarryWeight += __state; } private static void Postfix(TombStone __instance, Player player, float __state, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!Slots.IsValidPlayer((Character)player)) { return; } Player localPlayer = Player.m_localPlayer; localPlayer.m_maxCarryWeight -= __state; if (__result || __instance.m_container.GetInventory().NrOfItems() > Slots.InventorySizeActive) { return; } int num = 0; takenSlots.Clear(); foreach (ItemData item in __instance.m_container.GetInventory().GetAllItemsInGridOrder()) { Slots.Slot slotInGrid = Slots.GetSlotInGrid(item.m_gridPos); if (slotInGrid == null || takenSlots.Contains(slotInGrid)) { num++; continue; } takenSlots.Add(slotInGrid); if (!slotInGrid.IsEquipmentSlot || !slotInGrid.IsFree || !Slots.WouldFitEquipmentSlot(slotInGrid, item)) { num++; } } __result = num <= Slots.PlayerInventory.GetEmptySlots() && ((Humanoid)player).GetInventory().GetTotalWeight() + __instance.m_container.GetInventory().GetTotalWeight() < player.GetMaxCarryWeight() + __state; } } [HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")] private static class TombStone_OnTakeAllSuccess_AutoEquip { private static void Postfix() { AutoEquipAndParkReturnedItems(); } } [HarmonyPatch(typeof(InventoryGui), "OnTakeAll")] private static class InventoryGui_OnTakeAll_AutoEquip { private static void Postfix(InventoryGui __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if ((Object)__instance.m_currentContainer != (Object)null && (Object)((Component)__instance.m_currentContainer).GetComponent<TombStone>() != (Object)null) { AutoEquipAndParkReturnedItems(); } } } private static readonly List<KeptItem> itemsToKeep = new List<KeptItem>(); private static readonly HashSet<Slots.Slot> takenSlots = new HashSet<Slots.Slot>(); public static readonly int AfterdeathGhost = StringExtensionMethods.GetStableHashCode("Afterdeath Ghost"); private const string legacyEquipmentKey = "eaqs-e"; private const string legacyQuickSlotKey = "eaqs-qs"; public static void OnDeathPrefix(Player player) { if (itemsToKeep.Count != 0) { return; } Slots.SaveLastEquippedSlotsToItems(); SaveLastEquippedWeaponShieldToItems(player); Slots.Slot[] slots = Slots.slots; foreach (Slots.Slot slot in slots) { if (IsSlotToKeep(slot)) { ItemData item = slot.Item; itemsToKeep.Add(new KeptItem { item = item, wasEquipped = (item.m_equipped || ((Humanoid)player).IsItemEquiped(item)) }); ((Humanoid)player).GetInventory().m_inventory.Remove(item); } } Slots.ClearCachedItems(); } private static bool IsSlotToKeep(Slots.Slot slot) { if (slot.Item == null) { return false; } if ((!slot.IsEquipmentSlot && !slot.IsCustomSlot) || !ValConfig.DontDropEquipmentOnDeath.Value) { if (slot.IsQuickSlot) { return ValConfig.DontDropQuickslotsOnDeath.Value; } return false; } return true; } public static void OnDeathPostfix(Player player) { if (itemsToKeep.Count == 0) { return; } foreach (KeptItem item in itemsToKeep) { item.item.m_equipped = item.wasEquipped; ((Humanoid)player).GetInventory().m_inventory.Add(item.item); } itemsToKeep.Clear(); Slots.ClearCachedItems(); } private static void SaveLastEquippedWeaponShieldToItems(Player player) { long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); if (((Humanoid)player).LeftItem != null) { ((Humanoid)player).LeftItem.m_customData["eaqs_weaponshield"] = playerID.ToString(); } if (((Humanoid)player).RightItem != null) { ((Humanoid)player).RightItem.m_customData["eaqs_weaponshield"] = playerID.ToString(); } } private static int TargetGraveHeight(int width) { return (Slots.InventorySizeFull - 1) / Mathf.Max(1, width) + 1; } private static void AutoEquipAndParkReturnedItems() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player currentPlayer = Slots.CurrentPlayer; if ((Object)currentPlayer == (Object)null || Slots.PlayerInventory == null || ((Character)currentPlayer).IsDead()) { return; } string playerID = Game.instance.GetPlayerProfile().GetPlayerID().ToString(); foreach (ItemData item in Slots.PlayerInventory.GetAllItems().ToList()) { if (item == null) { continue; } if (item.m_equipped && !((Humanoid)currentPlayer).IsItemEquiped(item)) { item.m_equipped = false; } HandleLegacyMarkers(currentPlayer, item); if (IsItemToEquip(currentPlayer, item, playerID)) { PruneWeaponShieldKey(item); if (!((Humanoid)currentPlayer).IsItemEquiped(item)) { ((Humanoid)currentPlayer).EquipItem(item, false); } } else if (!((Humanoid)currentPlayer).IsItemEquiped(item)) { Slots.Slot itemSlot = Slots.GetItemSlot(item); if (itemSlot != null && itemSlot.IsEquipmentSlot && Slots.WouldFitEquipmentSlot(itemSlot, item)) { itemSlot.Park(item); } } } } private static bool IsItemToEquip(Player player, ItemData item, string playerID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (ValConfig.AutoEquipCarryWeightItems.Value) { StatusEffect equipStatusEffect = item.m_shared.m_equipStatusEffect; SE_Stats val = (SE_Stats)((equipStatusEffect is SE_Stats) ? equipStatusEffect : null); if ((Object)(object)val != (Object)null && val.m_addMaxCarryWeight > 0f) { return true; } } if (ValConfig.AutoEquipWeaponShield.Value && item.m_customData.TryGetValue("eaqs_weaponshield", out var value) && value == playerID) { return true; } if (ValConfig.InstantlyReequipArmorOnPickup.Value && item.m_customData.TryGetValue("eaqs_player", out var value2) && value2 == playerID && item.m_customData.TryGetValue("eaqs_slot", out var value3)) { Slots.Slot slot = Slots.FindSlot(value3); if (slot != null && slot.IsEquipmentSlot) { return true; } } return false; } private static void PruneWeaponShieldKey(ItemData item) { item.m_customData.Remove("eaqs_weaponshield"); } private static void HandleLegacyMarkers(Player player, ItemData item) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (item.m_customData.Remove("eaqs-e") && ValConfig.InstantlyReequipArmorOnPickup.Value && !((Humanoid)player).IsItemEquiped(item)) { ((Humanoid)player).EquipItem(item, false); } if (!item.m_customData.TryGetValue("eaqs-qs", out var value)) { return; } item.m_customData.Remove("eaqs-qs"); string[] array = value.Split(new char[1] { ',' }); if (array.Length >= 1 && int.TryParse(array[0], out var result) && result >= 0 && result < 6) { Slots.Slot slot = Slots.slots[result]; if (slot != null && slot.IsFreeQuickSlot()) { item.m_gridPos = slot.GridPosition; slot.ClearItemCache(); ((Humanoid)player).GetInventory().Changed(false, false); } } } } internal static class EpicLootCompat { public const string EpicLootGUID = "randyknapp.mods.epicloot"; private const string ApiTypeName = "EpicLoot.API, EpicLoot"; private const string ProviderId = "randyknapp.mods.equipmentandquickslots"; private static bool _initialized; private static MethodInfo _invalidatePlayerEffectCache; public static bool IsLoaded => Chainloader.PluginInfos.ContainsKey("randyknapp.mods.epicloot"); internal static void Initialize() { if (_initialized || !IsLoaded) { return; } _initialized = true; try { Type type = Type.GetType("EpicLoot.API, EpicLoot"); if (type == null) { EquipmentAndQuickSlots.LogWarning("Epic Loot is loaded but EpicLoot.API could not be resolved; slot items will not contribute magic effects"); return; } MethodInfo method = type.GetMethod("RegisterEquipmentProvider", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(string), typeof(Func<Player, List<ItemData>>) }, null); MethodInfo method2 = type.GetMethod("RegisterSacrificeFilter", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(string), typeof(Func<ItemData, bool>) }, null); _invalidatePlayerEffectCache = type.GetMethod("InvalidatePlayerEffectCache", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Player) }, null); if (method == null || _invalidatePlayerEffectCache == null) { EquipmentAndQuickSlots.LogWarning("Epic Loot's equipment provider API is missing (older Epic Loot?); custom slot items will not contribute magic effects"); return; } Func<Player, List<ItemData>> func = GetCustomSlotEquipment; method.Invoke(null, new object[2] { "randyknapp.mods.equipmentandquickslots", func }); if (method2 != null) { Func<ItemData, bool> func2 = CanSacrifice; method2.Invoke(null, new object[2] { "randyknapp.mods.equipmentandquickslots", func2 }); } API.AddSlotItemChangedListener(OnSlotItemChanged); API.AddSlotChangedListener(delegate { InvalidateEffectCache(); }); EquipmentAndQuickSlots.Log("Epic Loot equipment provider registered for custom slots"); } catch (Exception arg) { EquipmentAndQuickSlots.LogWarning($"Epic Loot integration failed: {arg}"); } } private static List<ItemData> GetCustomSlotEquipment(Player player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000f: 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_0023: Expected O, but got Unknown //IL_0023: Expected O, but got Unknown if ((Object)player == (Object)null || (Object)player != (Object)Player.m_localPlayer) { return null; } return (from slot in Slots.GetCustomSlots() where slot.IsActive select slot.Item into item where item != null select item).ToList(); } private static bool CanSacrifice(ItemData item) { Slots.Slot itemSlot = Slots.GetItemSlot(item); if (itemSlot != null) { if (!itemSlot.IsCustomSlot) { return !itemSlot.IsEquipmentSlot; } return false; } return true; } private static void OnSlotItemChanged(string slotId, ItemData oldItem, ItemData newItem) { Slots.Slot slot = Slots.FindSlot("Custom" + slotId); if (slot != null && slot.IsCustomSlot) { InvalidateEffectCache(); } } internal static void InvalidateEffectCache() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null || _invalidatePlayerEffectCache == null) { return; } try { _invalidatePlayerEffectCache.Invoke(null, new object[1] { localPlayer }); } catch (Exception arg) { EquipmentAndQuickSlots.LogWarning($"Epic Loot InvalidatePlayerEffectCache failed: {arg}"); } } } [BepInPlugin("randyknapp.mods.equipmentandquickslots", "EquipmentAndQuickSlotsPlus", "3.1.1")] [BepInIncompatibility("Azumatt.AzuExtendedPlayerInventory")] [BepInIncompatibility("aedenthorn.ExtendedPlayerInventory")] [BepInIncompatibility("shudnal.ExtraSlots")] [BepInIncompatibility("com.bruce.valheim.comfyquickslots")] public class EquipmentAndQuickSlots : BaseUnityPlugin { public const string PluginId = "randyknapp.mods.equipmentandquickslots"; public const string Version = "3.1.1"; public static Sprite PaperdollMale; public static Sprite PaperdollFemale; public static GameObject Paperdolls; private static EquipmentAndQuickSlots _instance; private Harmony _harmony; public static bool HasAuga { get; private set; } private void Awake() { _instance = this; HasAuga = Auga.API.IsLoaded(); new ValConfig(((BaseUnityPlugin)this).Config); FixQuickSlotPositionForAuga(); LoadAssets(); Slots.InitializeSlots(); EpicLootCompat.Initialize(); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "randyknapp.mods.equipmentandquickslots"); BetterArcheryCompat.Initialize(_harmony); } private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null) { return; } Slots.Slot[] slots = Slots.slots; foreach (Slots.Slot slot in slots) { if (slot.IsHotkeySlot && slot.IsShortcutDownWithItem()) { ((Humanoid)localPlayer).UseItem((Inventory)null, slot.Item, false); } } } private void LateUpdate() { SlotValidation.Validate(); API.DetectSlotItemChanges(); } private static void FixQuickSlotPositionForAuga() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (HasAuga) { Vector2 val = (Vector2)((ConfigEntryBase)ValConfig.QuickSlotsPosition).DefaultValue; if (!(ValConfig.QuickSlotsPosition.Value != val)) { ValConfig.QuickSlotsPosition.Value = new Vector2(val.x, 86f); } } } private static void LoadAssets() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown AssetBundle val = LoadAssetBundle("eaqs"); if ((Object)val == (Object)null) { LogError("Failed to load the 'eaqs' asset bundle. The paperdoll will not be shown."); return; } PaperdollMale = val.LoadAsset<Sprite>("PaperdollMale"); PaperdollFemale = val.LoadAsset<Sprite>("PaperdollFemale"); Paperdolls = val.LoadAsset<GameObject>("Paperdolls"); } public static AssetBundle LoadAssetBundle(string filename) { return AssetBundleLoader.LoadFromResources(filename, typeof(EquipmentAndQuickSlots).Assembly); } public static void Log(string message) { if (ValConfig.LoggingEnabled.Value) { ((BaseUnityPlugin)_instance).Logger.LogMessage((object)message); } } public static void LogWarning(string message) { ((BaseUnityPlugin)_instance).Logger.LogWarning((object)message); } public static void LogError(string message) { ((BaseUnityPlugin)_instance).Logger.LogError((object)message); } public static void LogInfo(string message) { ((BaseUnityPlugin)_instance).Logger.LogInfo((object)message); } } public static class EquipmentPanel { private class PanelDragHandle : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private bool _dragging; private float _scaleFactor = 1f; public void OnBeginDrag(PointerEventData eventData) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (CanDrag && (int)eventData.button == 0) { _dragging = true; _dragPosition = PanelBase; Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(); _scaleFactor = (((Object)(object)componentInParent != (Object)null) ? componentInParent.scaleFactor : 1f); if (_scaleFactor <= 0f) { _scaleFactor = 1f; } } } public void OnDrag(PointerEventData eventData) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (_dragging && _dragPosition.HasValue) { _dragPosition = _dragPosition.Value + eventData.delta / _scaleFactor; } } public void OnEndDrag(PointerEventData eventData) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (_dragging) { _dragging = false; if (_dragPosition.HasValue) { ValConfig.EquipmentPanelPosition.Value = _dragPosition.Value; } _dragPosition = null; } } private void OnDisable() { if (_dragging) { OnEndDrag(null); } } } [HarmonyPatch(typeof(InventoryGui), "OnDestroy")] private static class InventoryGui_OnDestroy_ClearPanel { private static void Postfix() { ClearPanel(); AugaPanel.Clear(); } } [HarmonyPatch(typeof(InventoryGui), "Update")] private static class InventoryGui_Update_UpdateEquipmentPanel { private static void Postfix() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown if (Object.op_Implicit((Object)Player.m_localPlayer) && InventoryGui.IsVisible()) { if (EquipmentAndQuickSlots.HasAuga) { AugaPanel.UpdatePanel(); } else { UpdateEquipmentBackground(); } } } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGamepad")] private static class InventoryGrid_UpdateGamepad_SkipInactiveSlotCells { private static void Postfix(InventoryGrid __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002b: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00ee: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)InventoryGui.instance) || (Object)__instance != (Object)InventoryGui.instance.m_playerGrid) { return; } Vector2i selected = __instance.m_selected; if (selected.y < Slots.VisibleRows) { return; } int num = (selected.y - Slots.VisibleRows) * Slots.InventoryWidth + selected.x; if (num >= 0 && num < Slots.slots.Length && Slots.slots[num].IsActive) { return; } int num2 = -1; int num3 = int.MaxValue; for (int i = 0; i < Slots.slots.Length; i++) { if (Slots.slots[i].IsActive) { int num4 = Math.Abs(i - num); if (num4 < num3) { num3 = num4; num2 = i; } } } __instance.m_selected = (Vector2i)((num2 >= 0) ? Slots.slots[num2].GridPosition : new Vector2i(Math.Min(selected.x, Slots.InventoryWidth - 1), Slots.VisibleRows - 1)); } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] private static class InventoryGrid_UpdateGui_RelocateSlotElements { private static void Postfix(InventoryGrid __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002b: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (Object.op_Implicit((Object)InventoryGui.instance) && !((Object)__instance != (Object)InventoryGui.instance.m_playerGrid) && !((Object)Player.m_localPlayer == (Object)null)) { UpdateInventorySlots(); } } } private static Vector2? _dragPosition; private const float elementSpace = 70f; private const float slotSpacing = 80f; private static readonly Vector2 equipmentOrigin = new Vector2(60.5f, -27f); private static readonly Vector2[] equipmentOffsets = (Vector2[])(object)new Vector2[8] { new Vector2(0f, 0f), new Vector2(0f, -80f), new Vector2(0f, -160f), new Vector2(80f, -40f), new Vector2(80f, -120f), new Vector2(80f, -200f), new Vector2(160f, -120f), new Vector2(160f, -200f) }; private static readonly Vector2 equipmentBackgroundCenter = new Vector2(132.5f, -159f); private static readonly Vector2 equipmentBackgroundSize = new Vector2(210f, 300f); private static readonly Vector2 equipmentLabelPosition = new Vector2(32f, 5f); private const float rowLeft = 25.5f; private const float rowGap = 20f; private const float quickRowTop = -342f; private const float rowBackgroundLeft = 14.5f; private const float rowBackgroundHeight = 90f; private const float rowBackgroundPitch = 74f; private const float customRowTop = -452f; private const int customSlotsPerRow = 3; private static readonly Vector2 paperdollOffset = new Vector2(-35f, 0f); private static float originalLabelFontSize; private static RectTransform inventoryBackground; private static Image inventoryBackgroundImage; private static RectTransform inventoryDarken; private static RectTransform inventorySelectedFrame; private static Vector2? containerOriginalPivot; private static RectTransform equipmentBackground; private static RectTransform quickBackground; private static RectTransform customBackground; private static RectTransform slotRoot; private static RectTransform hiddenRoot; private static GameObject paperdoll; private static RectTransform[] paperdollImages; private static Color normalColor = Color.clear; private static Color highlightedColor = Color.clear; private static Vector2 PanelBase => (Vector2)(((??)_dragPosition) ?? ValConfig.EquipmentPanelPosition.Value); private static bool CanDrag { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) if (!ValConfig.EquipmentPanelDraggable.Value) { KeyboardShortcut value = ValConfig.EquipmentPanelDragKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { value = ValConfig.EquipmentPanelDragKey.Value; return ZInput.GetKey(((KeyboardShortcut)(ref value)).MainKey, true); } return false; } return true; } } private static float ExtraUtilityColumnWidth { get { if (Slots.ActiveExtraUtilitySlots <= 0) { return 0f; } return 80f; } } private static Vector2 EquipmentBackgroundSize => equipmentBackgroundSize + new Vector2(ExtraUtilityColumnWidth, 0f); private static Vector2 EquipmentBackgroundCenter => equipmentBackgroundCenter + new Vector2(ExtraUtilityColumnWidth / 2f, 0f); private static int ActiveQuickSlots { get { if (!ValConfig.QuickSlotsEnabled.Value) { return 0; } return ValConfig.QuickSlotCount.Value; } } private static bool EquipmentVisible => ValConfig.EquipmentSlotsEnabled.Value; private static Slots.Slot[] ActiveCustomSlots => (from slot in Slots.GetCustomSlots() where slot.IsActive orderby slot.Index select slot).ToArray(); internal static Vector2 GetSlotPosition(Slots.Slot slot) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) if (slot.IsEquipmentSlot) { return PanelBase + equipmentOrigin + equipmentOffsets[slot.Index - 8]; } if (slot.IsQuickSlot) { return PanelBase + new Vector2(25.5f + (float)slot.Index * 70f, -342f); } if (slot.IsCustomSlot) { int num = Math.Max(0, Array.IndexOf(ActiveCustomSlots, slot)); int num2 = num % 3; int num3 = num / 3; return PanelBase + new Vector2(25.5f + (float)num2 * 70f, -452f - (float)num3 * 70f); } return PanelBase; } internal static void UpdateEquipmentBackground() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown if (!Object.op_Implicit((Object)InventoryGui.instance) || !Object.op_Implicit((Object)InventoryGui.instance.m_player)) { return; } if ((Object)inventoryBackground == (Object)null) { Transform val = ((Transform)InventoryGui.instance.m_player).Find("Bkg"); inventoryBackground = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<RectTransform>() : null); RectTransform val2 = inventoryBackground; inventoryBackgroundImage = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Image>() : null); Transform val3 = ((Transform)InventoryGui.instance.m_player).Find("Darken"); inventoryDarken = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<RectTransform>() : null); UIGroupHandler component = ((Component)InventoryGui.instance.m_player).GetComponent<UIGroupHandler>(); object obj; if ((Object)(object)component == (Object)null) { obj = null; } else { GameObject enableWhenActiveAndGamepad = component.m_enableWhenActiveAndGamepad; obj = (((Object)(object)enableWhenActiveAndGamepad != (Object)null) ? enableWhenActiveAndGamepad.transform.GetChild(0) : null); } inventorySelectedFrame = (RectTransform)((obj is RectTransform) ? obj : null); } if (!((Object)inventoryBackground == (Object)null)) { UpdateInventoryPanelForExtraRows(); if (!Object.op_Implicit((Object)equipmentBackground)) { equipmentBackground = CreateBackground("EaqsEquipmentBkg"); } if (!Object.op_Implicit((Object)quickBackground)) { quickBackground = CreateBackground("EaqsQuickSlotBkg"); } if (!Object.op_Implicit((Object)customBackground)) { customBackground = CreateBackground("EaqsCustomSlotBkg"); } SyncBackground(equipmentBackground, EquipmentVisible, PanelBase + EquipmentBackgroundCenter, EquipmentBackgroundSize); UpdatePaperdoll(); int activeQuickSlots = ActiveQuickSlots; SyncBackground(quickBackground, activeQuickSlots > 0, RowBackgroundCenter(activeQuickSlots, -342f), RowBackgroundSize(activeQuickSlots)); int num = ActiveCustomSlots.Length; int rows = (num + 3 - 1) / 3; SyncBackground(customBackground, num > 0, CustomBackgroundCenter(num, rows), CustomBackgroundSize(num, rows)); } } private static void UpdatePaperdoll() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown if (!ValConfig.ShowPaperdoll.Value || !EquipmentVisible || !((Object)EquipmentAndQuickSlots.Paperdolls != (Object)null) || !Object.op_Implicit((Object)equipmentBackground)) { if (Object.op_Implicit((Object)paperdoll)) { paperdoll.SetActive(false); } return; } if (!Object.op_Implicit((Object)paperdoll)) { paperdoll = Object.Instantiate<GameObject>(EquipmentAndQuickSlots.Paperdolls, (Transform)equipmentBackground, false); ((Object)paperdoll).name = "Paperdolls"; RectTransform component = paperdoll.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.pivot = new Vector2(0.5f, 0.5f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((Transform)component).SetAsFirstSibling(); Image[] componentsInChildren = paperdoll.GetComponentsInChildren<Image>(true); paperdollImages = (RectTransform[])(object)new RectTransform[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { ((Graphic)componentsInChildren[i]).raycastTarget = false; componentsInChildren[i].preserveAspect = true; paperdollImages[i] = ((Graphic)componentsInChildren[i]).rectTransform; } } paperdoll.SetActive(true); Vector2 anchoredPosition = paperdollOffset - new Vector2(ExtraUtilityColumnWidth / 2f, 0f); RectTransform[] array = paperdollImages; for (int j = 0; j < array.Length; j++) { array[j].anchoredPosition = anchoredPosition; } Player localPlayer = Player.m_localPlayer; bool flag = (Object)localPlayer != (Object)null && (Object)((Humanoid)localPlayer).m_visEquipment != (Object)null && ((Humanoid)localPlayer).m_visEquipment.GetModelIndex() == 1; Transform val = paperdoll.transform.Find("Male"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(!flag); } Transform val2 = paperdoll.transform.Find("Female"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(flag); } } private static void UpdateInventoryPanelForExtraRows() { //IL_0032: 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_004b: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) int extraRows = Slots.ExtraRows; float num = -1f * ((float)extraRows / (float)Slots.BaseRows - 0.01f * (float)Math.Max(extraRows - 1, 0)); inventoryBackground.anchorMin = new Vector2(0f, num); if (Object.op_Implicit((Object)inventoryDarken)) { inventoryDarken.anchorMin = inventoryBackground.anchorMin; } if (Object.op_Implicit((Object)inventorySelectedFrame)) { inventorySelectedFrame.anchorMin = inventoryBackground.anchorMin; } RectTransform container = InventoryGui.instance.m_container; if (Object.op_Implicit((Object)container)) { if (!containerOriginalPivot.HasValue) { containerOriginalPivot = container.pivot; } container.pivot = new Vector2(containerOriginalPivot.Value.x, containerOriginalPivot.Value.y + (float)extraRows * 0.2f); } } private static Vector2 RowBackgroundSize(int slotCount) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Vector2(74f * (float)slotCount + 10f, 90f); } private static Vector2 CustomBackgroundSize(int slotCount, int rows) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new Vector2(74f * (float)Math.Min(slotCount, 3) + 10f, 90f + (float)Math.Max(0, rows - 1) * 70f); } private static Vector2 CustomBackgroundCenter(int slotCount, int rows) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return PanelBase + new Vector2(14.5f + CustomBackgroundSize(slotCount, rows).x / 2f, -484f - (float)Math.Max(0, rows - 1) * 70f / 2f); } private static Vector2 RowBackgroundCenter(int slotCount, float rowTop) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) return PanelBase + new Vector2(14.5f + RowBackgroundSize(slotCount).x / 2f, rowTop - 32f); } private static RectTransform CreateBackground(string name) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_010a: Expected O, but got Unknown Transform val = (Transform)InventoryGui.instance.m_player; UIGroupHandler component = ((Component)val).GetComponent<UIGroupHandler>(); object obj; if ((Object)(object)component == (Object)null) { obj = null; } else { GameObject enableWhenActiveAndGamepad = component.m_enableWhenActiveAndGamepad; obj = (((Object)(object)enableWhenActiveAndGamepad != (Object)null) ? enableWhenActiveAndGamepad.transform : null); } Transform val2 = (Transform)obj; Transform val3 = val.Find("Darken"); RectTransform obj2 = Object.Instantiate<RectTransform>(inventoryBackground, val, false); ((Object)obj2).name = name; int num = (((Object)val2 != (Object)null) ? val2.GetSiblingIndex() : (((Object)val3 != (Object)null) ? val3.GetSiblingIndex() : ((Transform)inventoryBackground).GetSiblingIndex())); ((Transform)obj2).SetSiblingIndex(num + 1); obj2.anchorMin = new Vector2(0f, 1f); obj2.anchorMax = new Vector2(0f, 1f); obj2.pivot = new Vector2(0.5f, 0.5f); ((Transform)obj2).localScale = Vector3.one; Image component2 = ((Component)obj2).GetComponent<Image>(); if (Object.op_Implicit((Object)component2)) { ((Graphic)component2).raycastTarget = true; } ((Component)obj2).gameObject.AddComponent<PanelDragHandle>(); return obj2; } private static void SyncBackground(RectTransform background, bool visible, Vector2 center, Vector2 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_003d: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)background)) { return; } ((Component)background).gameObject.SetActive(visible); if (visible) { background.sizeDelta = size; background.anchoredPosition = center; Image component = ((Component)background).GetComponent<Image>(); if (Object.op_Implicit((Object)component) && Object.op_Implicit((Object)inventoryBackgroundImage)) { component.sprite = inventoryBackgroundImage.sprite; component.overrideSprite = inventoryBackgroundImage.overrideSprite; ((Graphic)component).color = ((Graphic)inventoryBackgroundImage).color; } } } private static RectTransform EnsureSlotRoot(InventoryGrid grid) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) //IL_00f4: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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) RectTransform gridRoot = grid.m_gridRoot; if (!Object.op_Implicit((Object)gridRoot) || !Object.op_Implicit((Object)((Transform)gridRoot).parent) || !Object.op_Implicit((Object)InventoryGui.instance.m_player)) { return null; } if (!Object.op_Implicit((Object)slotRoot)) { slotRoot = new GameObject("EaqsSlotRoot", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)slotRoot).SetParent((Transform)InventoryGui.instance.m_player, false); ((Transform)slotRoot).localScale = Vector3.one; ((Transform)slotRoot).localRotation = Quaternion.identity; ((Transform)slotRoot).SetAsLastSibling(); } slotRoot.anchorMin = Vector2.zero; slotRoot.anchorMax = Vector2.zero; slotRoot.pivot = gridRoot.pivot; RectTransform obj = slotRoot; Rect rect = gridRoot.rect; obj.sizeDelta = ((Rect)(ref rect)).size; Vector3 point = ((Transform)gridRoot).localPosition - Vector2.op_Implicit(gridRoot.anchoredPosition); if (TryTransformToPanelSpace(((Transform)gridRoot).parent, ((Transform)slotRoot).parent, ref point)) { ((Transform)slotRoot).localPosition = point; } else { ((Transform)slotRoot).position = ((Transform)gridRoot).parent.TransformPoint(point); } return slotRoot; } private static bool TryTransformToPanelSpace(Transform from, Transform panel, ref Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001c: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point; Transform val2 = from; while ((Object)val2 != (Object)null) { if ((Object)val2 == (Object)panel) { point = val; return true; } val = val2.localPosition + val2.localRotation * Vector3.Scale(val2.localScale, val); val2 = val2.parent; } return false; } private static RectTransform EnsureHiddenRoot() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0073: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)hiddenRoot) || !Object.op_Implicit((Object)InventoryGui.instance.m_player)) { return hiddenRoot; } hiddenRoot = new GameObject("EaqsHiddenSlotRoot", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)hiddenRoot).SetParent((Transform)InventoryGui.instance.m_player, false); ((Transform)hiddenRoot).localScale = Vector3.one; ((Transform)hiddenRoot).localRotation = Quaternion.identity; hiddenRoot.anchorMin = Vector2.zero; hiddenRoot.anchorMax = Vector2.zero; hiddenRoot.anchoredPosition = new Vector2(-100000f, 0f); ((Component)hiddenRoot).gameObject.SetActive(false); return hiddenRoot; } private static void ParkHiddenCell(GameObject go, RectTransform holder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003c: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (Object.op_Implicit((Object)go)) { go.SetActive(false); if (Object.op_Implicit((Object)holder) && (Object)go.transform.parent != (Object)holder) { go.transform.SetParent((Transform)holder, false); } } } internal static void UpdateInventorySlots() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00f4: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) InventoryGrid playerGrid = InventoryGui.instance.m_playerGrid; playerGrid.m_gridRoot.SetSizeWithCurrentAnchors((Axis)1, (float)Slots.VisibleRows * playerGrid.m_elementSpace); int inventorySizeVisible = Slots.InventorySizeVisible; ItemData dragItem = InventoryGui.instance.m_dragItem; RectTransform val = EnsureSlotRoot(playerGrid); RectTransform holder = EnsureHiddenRoot(); Transform val2 = (Transform)(Object.op_Implicit((Object)val) ? val : playerGrid.m_gridRoot); for (int i = 0; i < Math.Min(Slots.slots.Length, playerGrid.m_elements.Count - inventorySizeVisible); i++) { InventoryElement val3 = playerGrid.m_elements[inventorySizeVisible + i]; Slots.Slot slot = Slots.slots[i]; GameObject val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null); if (!Object.op_Implicit((Object)val4)) { continue; } if (!slot.IsActive) { ParkHiddenCell(val4, holder); continue; } val4.SetActive(true); if (Object.op_Implicit((Object)val2) && (Object)val4.transform.parent != (Object)val2) { val4.transform.SetParent(val2, false); } val4.GetComponent<RectTransform>().anchoredPosition = (EquipmentAndQuickSlots.HasAuga ? AugaPanel.GetSlotPosition(slot) : GetSlotPosition(slot)); SetSlotLabel(val4.transform.Find("binding"), slot); SetSlotColor(val4.GetComponent<Button>(), dragItem != null && !DragItemFits(slot, dragItem)); } for (int j = inventorySizeVisible + Slots.slots.Length; j < playerGrid.m_elements.Count; j++) { InventoryElement val5 = playerGrid.m_elements[j]; ParkHiddenCell(((Object)(object)val5 != (Object)null) ? ((Component)val5).gameObject : null, holder); } } private static bool DragItemFits(Slots.Slot slot, ItemData dragItem) { if (slot.IsEquipmentSlot) { return Slots.WouldFitEquipmentSlot(slot, dragItem); } return slot.ItemFits(dragItem); } private static void SetSlotLabel(Transform binding, Slots.Slot slot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00a4: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)binding)) { return; } TMP_Text component = ((Component)binding).GetComponent<TMP_Text>(); if (!Object.op_Implicit((Object)component)) { return; } if (EquipmentAndQuickSlots.HasAuga && slot.IsEquipmentSlot) { ((Behaviour)component).enabled = false; return; } if (originalLabelFontSize <= 0f && !component.enableAutoSizing) { originalLabelFontSize = component.fontSize; } ((Component)binding).gameObject.SetActive(true); ((Behaviour)component).enabled = true; component.overflowMode = (TextOverflowModes)0; component.textWrappingMode = (TextWrappingModes)0; component.text = (slot.IsHotkeySlot ? slot.GetShortcutText() : slot.Name); if (slot.IsEquipmentSlot) { component.rectTransform.anchoredPosition = equipmentLabelPosition; } if (slot.IsCustomSlot) { component.rectTransform.anchoredPosition = equipmentLabelPosition; component.rectTransform.sizeDelta = new Vector2(64f, component.rectTransform.sizeDelta.y); component.overflowMode = (TextOverflowModes)1; if (originalLabelFontSize > 0f) { component.fontSizeMax = originalLabelFontSize; component.fontSizeMin = Mathf.Min(10f, originalLabelFontSize); component.enableAutoSizing = true; } } } private static void SetSlotColor(Button button, bool unfit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)button)) { if (normalColor == Color.clear) { ColorBlock colors = ((Selectable)button).colors; normalColor = ((ColorBlock)(ref colors)).normalColor; colors = ((Selectable)button).colors; highlightedColor = ((ColorBlock)(ref colors)).highlightedColor; } ColorBlock colors2 = ((Selectable)button).colors; ((ColorBlock)(ref colors2)).normalColor = (Color)(unfit ? new Color(0.8f, 0.2f, 0.2f, 0.5f) : normalColor); ((ColorBlock)(ref colors2)).highlightedColor = (Color)(unfit ? new Color(0.9f, 0.3f, 0.3f, 0.7f) : highlightedColor); ((Selectable)button).colors = colors2; } } private static void ClearPanel() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) inventoryBackground = null; inventoryBackgroundImage = null; inventoryDarken = null; inventorySelectedFrame = null; containerOriginalPivot = null; equipmentBackground = null; quickBackground = null; customBackground = null; slotRoot = null; hiddenRoot = null; paperdoll = null; paperdollImages = null; _dragPosition = null; normalColor = Color.clear; highlightedColor = Color.clear; } } internal class HotkeyBarRefreshGate { [HarmonyPatch] private static class InventoryEvents_BumpRevision { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(Player), "OnInventoryChanged", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Humanoid), "EquipItem", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Humanoid), "UnequipItem", (Type[])null, (Type[])null)