using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HZ_InventoryKeybinds")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HZ_InventoryKeybinds")] [assembly: AssemblyTitle("HZ_InventoryKeybinds")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExtendedInventory { internal sealed class ConfigurationManagerAttributes { public Action CustomDrawer; public bool? Browsable; public int? Order; } internal class EquipmentPanel : MonoBehaviour { private class SlotElement { public GameObject Go; public Image Icon; public GuiBar Durability; public UITooltip Tooltip; } private static readonly ItemType[] SlotTypes; private const float SlotScale = 0.69f; private const float BaseVerticalSpacing = 70f; private const float VerticalSpacing = 48.3f; private readonly SlotElement[] _slots = new SlotElement[SlotTypes.Length]; private bool _built; private Transform _content; private void Update() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) bool flag = ModConfig.IsInitialized && ModConfig.ShowEquipmentPanel.Value; if (!_built) { Build(); } if ((Object)(object)_content != (Object)null && ((Component)_content).gameObject.activeSelf != flag) { ((Component)_content).gameObject.SetActive(flag); } if (!flag) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } for (int i = 0; i < _slots.Length; i++) { SlotElement slotElement = _slots[i]; if (slotElement == null) { continue; } ItemData equippedItem = GetEquippedItem(localPlayer, SlotTypes[i]); if (equippedItem != null) { ((Behaviour)slotElement.Icon).enabled = true; slotElement.Icon.sprite = equippedItem.GetIcon(); if ((Object)(object)slotElement.Durability != (Object)null) { bool flag2 = equippedItem.m_shared.m_useDurability && equippedItem.m_durability < equippedItem.GetMaxDurability(); ((Component)slotElement.Durability).gameObject.SetActive(flag2); if (flag2) { if (equippedItem.m_durability <= 0f) { slotElement.Durability.SetValue(1f); slotElement.Durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f))); } else { slotElement.Durability.SetValue(equippedItem.GetDurabilityPercentage()); slotElement.Durability.ResetColor(); } } } if ((Object)(object)slotElement.Tooltip != (Object)null) { slotElement.Tooltip.m_text = Localization.instance.Localize(equippedItem.m_shared.m_name); } } else { ((Behaviour)slotElement.Icon).enabled = false; if ((Object)(object)slotElement.Durability != (Object)null) { ((Component)slotElement.Durability).gameObject.SetActive(false); } if ((Object)(object)slotElement.Tooltip != (Object)null) { slotElement.Tooltip.m_text = ""; } } } } private static ItemData GetEquippedItem(Player player, ItemType type) { //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) foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (allItem.m_equipped && allItem.m_shared.m_itemType == type) { return allItem; } } return null; } private void Build() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_006f: 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_00d8: Unknown result type (might be due to invalid IL or missing references) _built = true; HotkeyBar val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null || (Object)(object)val.m_elementPrefab == (Object)null) { Plugin.Log.LogWarning((object)"EquipmentPanel: HotkeyBar ou m_elementPrefab não encontrado."); return; } GameObject val2 = new GameObject("Content", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(((Component)this).transform, false); Transform transform = val2.transform; ((RectTransform)((transform is RectTransform) ? transform : null)).anchoredPosition = Vector2.zero; _content = val2.transform; for (int i = 0; i < SlotTypes.Length; i++) { GameObject val3 = Object.Instantiate(val.m_elementPrefab, _content); val3.SetActive(true); Transform transform2 = val3.transform; Transform obj = ((transform2 is RectTransform) ? transform2 : null); obj.localScale = new Vector3(0.69f, 0.69f, 1f); ((RectTransform)obj).anchoredPosition = new Vector2(0f, (float)(-i) * 48.3f); SlotElement obj2 = new SlotElement { Go = val3 }; Transform obj3 = val3.transform.Find("icon"); obj2.Icon = ((obj3 != null) ? ((Component)obj3).GetComponent() : null); Transform obj4 = val3.transform.Find("durability"); obj2.Durability = ((obj4 != null) ? ((Component)obj4).GetComponent() : null); obj2.Tooltip = val3.GetComponent(); SlotElement slotElement = obj2; Transform val4 = val3.transform.Find("amount"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } Transform val5 = val3.transform.Find("binding"); if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive(false); } Transform val6 = val3.transform.Find("queued"); if ((Object)(object)val6 != (Object)null) { ((Component)val6).gameObject.SetActive(false); } Transform val7 = val3.transform.Find("selected"); if ((Object)(object)val7 != (Object)null) { ((Component)val7).gameObject.SetActive(false); } Transform val8 = val3.transform.Find("equiped"); if ((Object)(object)val8 != (Object)null) { ((Component)val8).gameObject.SetActive(false); } _slots[i] = slotElement; } } static EquipmentPanel() { ItemType[] array = new ItemType[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); SlotTypes = (ItemType[])(object)array; } } [HarmonyPatch(typeof(Hud), "Awake")] internal class EquipmentPanelInstallPatch { internal static RectTransform PanelRect; [HarmonyPostfix] private static void Postfix(Hud __instance) { //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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.m_rootObject == (Object)null)) { if ((Object)(object)Object.FindFirstObjectByType() == (Object)null) { Plugin.Log.LogWarning((object)"EquipmentPanelInstallPatch: HotkeyBar não encontrado na cena."); return; } GameObject val = new GameObject("InventorySets_EquipmentPanel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(__instance.m_rootObject.transform, false); PanelRect = val.GetComponent(); PanelRect.anchorMin = new Vector2(0f, 0.5f); PanelRect.anchorMax = new Vector2(0f, 0.5f); PanelRect.pivot = new Vector2(0f, 0.5f); PanelRect.anchoredPosition = new Vector2(50f, ModConfig.EquipmentPanelYOffset.Value); val.AddComponent(); } } internal static void ApplyPosition() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PanelRect != (Object)null) { PanelRect.anchoredPosition = new Vector2(50f, ModConfig.EquipmentPanelYOffset.Value); } } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] internal class InventoryGridLabelPatch { private static readonly FieldRef ElementsField = AccessTools.FieldRefAccess("m_elements"); [HarmonyPostfix] private static void Postfix(InventoryGrid __instance, Player player) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0071: 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_0094: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !ModConfig.IsInitialized) { return; } int value = ModConfig.SecondRowSlotCount.Value; if (value <= 0) { return; } IList list = ElementsField.Invoke(__instance); if (list == null) { return; } foreach (object item in list) { Type type = item.GetType(); Vector2i val = (Vector2i)AccessTools.Field(type, "m_pos").GetValue(item); if (val.y != 1 || val.x >= value) { continue; } GameObject val2 = (GameObject)AccessTools.Field(type, "m_go").GetValue(item); if ((Object)(object)val2 == (Object)null) { continue; } Transform val3 = val2.transform.Find("binding"); if (!((Object)(object)val3 == (Object)null)) { TMP_Text component = ((Component)val3).GetComponent(); if (!((Object)(object)component == (Object)null)) { ((Behaviour)component).enabled = true; component.text = ModConfig.GetRow2ShortcutDisplayName(val.x); } } } } } internal static class KeyCodePathMap { private static readonly Dictionary Map = new Dictionary { { (KeyCode)48, "/0" }, { (KeyCode)49, "/1" }, { (KeyCode)50, "/2" }, { (KeyCode)51, "/3" }, { (KeyCode)52, "/4" }, { (KeyCode)53, "/5" }, { (KeyCode)54, "/6" }, { (KeyCode)55, "/7" }, { (KeyCode)56, "/8" }, { (KeyCode)57, "/9" }, { (KeyCode)97, "/a" }, { (KeyCode)98, "/b" }, { (KeyCode)99, "/c" }, { (KeyCode)100, "/d" }, { (KeyCode)101, "/e" }, { (KeyCode)102, "/f" }, { (KeyCode)103, "/g" }, { (KeyCode)104, "/h" }, { (KeyCode)105, "/i" }, { (KeyCode)106, "/j" }, { (KeyCode)107, "/k" }, { (KeyCode)108, "/l" }, { (KeyCode)109, "/m" }, { (KeyCode)110, "/n" }, { (KeyCode)111, "/o" }, { (KeyCode)112, "/p" }, { (KeyCode)113, "/q" }, { (KeyCode)114, "/r" }, { (KeyCode)115, "/s" }, { (KeyCode)116, "/t" }, { (KeyCode)117, "/u" }, { (KeyCode)118, "/v" }, { (KeyCode)119, "/w" }, { (KeyCode)120, "/x" }, { (KeyCode)121, "/y" }, { (KeyCode)122, "/z" }, { (KeyCode)282, "/f1" }, { (KeyCode)283, "/f2" }, { (KeyCode)284, "/f3" }, { (KeyCode)285, "/f4" }, { (KeyCode)286, "/f5" }, { (KeyCode)287, "/f6" }, { (KeyCode)288, "/f7" }, { (KeyCode)289, "/f8" }, { (KeyCode)290, "/f9" }, { (KeyCode)291, "/f10" }, { (KeyCode)292, "/f11" }, { (KeyCode)293, "/f12" }, { (KeyCode)32, "/space" }, { (KeyCode)9, "/tab" }, { (KeyCode)301, "/capsLock" }, { (KeyCode)8, "/backspace" }, { (KeyCode)13, "/enter" }, { (KeyCode)27, "/escape" }, { (KeyCode)304, "/leftShift" }, { (KeyCode)303, "/rightShift" }, { (KeyCode)306, "/leftCtrl" }, { (KeyCode)305, "/rightCtrl" }, { (KeyCode)308, "/leftAlt" }, { (KeyCode)307, "/rightAlt" }, { (KeyCode)273, "/upArrow" }, { (KeyCode)274, "/downArrow" }, { (KeyCode)276, "/leftArrow" }, { (KeyCode)275, "/rightArrow" }, { (KeyCode)277, "/insert" }, { (KeyCode)127, "/delete" }, { (KeyCode)278, "/home" }, { (KeyCode)279, "/end" }, { (KeyCode)280, "/pageUp" }, { (KeyCode)281, "/pageDown" }, { (KeyCode)61, "/equals" }, { (KeyCode)45, "/minus" }, { (KeyCode)96, "/backquote" }, { (KeyCode)91, "/leftBracket" }, { (KeyCode)93, "/rightBracket" }, { (KeyCode)59, "/semicolon" }, { (KeyCode)39, "/quote" }, { (KeyCode)44, "/comma" }, { (KeyCode)46, "/period" }, { (KeyCode)47, "/slash" }, { (KeyCode)92, "/backslash" }, { (KeyCode)256, "/numpad0" }, { (KeyCode)257, "/numpad1" }, { (KeyCode)258, "/numpad2" }, { (KeyCode)259, "/numpad3" }, { (KeyCode)260, "/numpad4" }, { (KeyCode)261, "/numpad5" }, { (KeyCode)262, "/numpad6" }, { (KeyCode)263, "/numpad7" }, { (KeyCode)264, "/numpad8" }, { (KeyCode)265, "/numpad9" }, { (KeyCode)266, "/numpadPeriod" }, { (KeyCode)267, "/numpadDivide" }, { (KeyCode)268, "/numpadMultiply" }, { (KeyCode)269, "/numpadMinus" }, { (KeyCode)270, "/numpadPlus" }, { (KeyCode)271, "/numpadEnter" }, { (KeyCode)323, "/leftButton" }, { (KeyCode)324, "/rightButton" }, { (KeyCode)325, "/middleButton" }, { (KeyCode)326, "/button3" }, { (KeyCode)327, "/button4" }, { (KeyCode)328, "/button5" }, { (KeyCode)329, "/button6" } }; public static string ToPath(KeyCode key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Map.TryGetValue(key, out var value)) { return value; } return null; } } internal static class MessageHudOffsetPatch { private static Vector2? _originalTextPos; private static Vector2? _originalIconPos; [HarmonyPatch(typeof(MessageHud), "Awake")] [HarmonyPostfix] private static void Postfix(MessageHud __instance) { CacheOriginalPositions(__instance); ((MonoBehaviour)__instance).StartCoroutine(DelayedApply(__instance)); } private static IEnumerator DelayedApply(MessageHud hud) { ApplyOffset(hud); yield return (object)new WaitForSeconds(1.5f); ApplyOffset(hud); yield return (object)new WaitForSeconds(2f); ApplyOffset(hud); yield return (object)new WaitForSeconds(3f); ApplyOffset(hud); } private static void CacheOriginalPositions(MessageHud instance) { //IL_0044: 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) if (!((Object)(object)instance == (Object)null)) { TMP_Text messageText = instance.m_messageText; Transform obj = ((messageText != null) ? messageText.transform : null); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); Image messageIcon = instance.m_messageIcon; Transform obj2 = ((messageIcon != null) ? ((Component)messageIcon).transform : null); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val != (Object)null) { _originalTextPos = val.anchoredPosition; } if ((Object)(object)val2 != (Object)null) { _originalIconPos = val2.anchoredPosition; } } } public static void ApplyOffset(MessageHud instance = null) { //IL_009f: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (instance == null) { instance = MessageHud.instance; } if (!((Object)(object)instance == (Object)null)) { if (!_originalTextPos.HasValue || !_originalIconPos.HasValue) { CacheOriginalPositions(instance); } float num = ((ModConfig.IsInitialized && ModConfig.SecondRowSlotCount.Value >= 1) ? ModConfig.TopLeftMessageOffset.Value : 0f); TMP_Text messageText = instance.m_messageText; Transform obj = ((messageText != null) ? messageText.transform : null); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); Image messageIcon = instance.m_messageIcon; Transform obj2 = ((messageIcon != null) ? ((Component)messageIcon).transform : null); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val != (Object)null) { val.anchoredPosition = _originalTextPos.Value + new Vector2(0f, 0f - num); } if ((Object)(object)val2 != (Object)null) { val2.anchoredPosition = _originalIconPos.Value + new Vector2(0f, 0f - num); } Plugin.Log.LogInfo((object)$"ApplyOffset executado | Offset = {num}"); } } } internal static class ModConfig { private const string GeneralSection = "General"; private const string SecondRowSection = "SecondRow"; public const int MaxRowSlots = 8; private static ConfigEntry[] _row2Shortcuts; public static bool IsInitialized { get; private set; } public static ConfigEntry ShowEquipmentPanel { get; private set; } public static ConfigEntry SecondRowSlotCount { get; private set; } public static ConfigEntry EquipmentPanelYOffset { get; private set; } public static ConfigEntry TopLeftMessageOffset { get; private set; } public static void Init(ConfigFile config) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) MessageHudOffsetPatch.ApplyOffset(); ShowEquipmentPanel = config.Bind("General", "ShowEquipmentPanel", true, "Mostra o painel vertical com o set equipado (capacete, peito, pernas, capa), mesmo com o inventário fechado."); EquipmentPanelYOffset = config.Bind("General", "EquipmentPanelYOffset", -50f, new ConfigDescription("Ajusta a posição vertical do painel de equipamentos.", (AcceptableValueBase)(object)new AcceptableValueRange(-50f, 100f), Array.Empty())); SecondRowSlotCount = config.Bind("General", "SecondRowSlotCount", 0, new ConfigDescription("Quantos slots da 2ª linha do inventário recebem atalho de teclado, habilitados da esquerda pra direita. 0 desativa a 2ª linha.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 8), Array.Empty())); _row2Shortcuts = new ConfigEntry[8]; TopLeftMessageOffset = config.Bind("General", "Message-Offset", 75f, "Quantos pixels empurrar pra baixo as mensagens de status (cansado, molhado, abrigado etc.) quando a 2ª linha da hotbar estiver ativa (1+ slots), pra evitar sobreposição visual."); SecondRowSlotCount.SettingChanged += delegate { MessageHudOffsetPatch.ApplyOffset(); }; TopLeftMessageOffset.SettingChanged += delegate { MessageHudOffsetPatch.ApplyOffset(); }; EquipmentPanelYOffset.SettingChanged += delegate { EquipmentPanelInstallPatch.ApplyPosition(); }; for (int num = 0; num < 8; num++) { int slot = num; _row2Shortcuts[num] = config.Bind("SecondRow", $"Row2Slot{num + 1}", new KeyboardShortcut((KeyCode)0, Array.Empty()), $"Atalho para o slot {num + 1} da 2ª linha do inventário."); _row2Shortcuts[num].SettingChanged += delegate { ApplyToZInput(slot); }; } IsInitialized = true; MessageHudOffsetPatch.ApplyOffset(); EquipmentPanelInstallPatch.ApplyPosition(); if (ZInput.instance != null) { ApplyAllToZInput(ZInput.instance); MessageHudOffsetPatch.ApplyOffset(); } } public static string Row2ActionName(int slotIndex) { return $"HotbarRow2Slot{slotIndex + 1}"; } public static KeyboardShortcut GetRow2Shortcut(int slotIndex) { //IL_0015: 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) if (_row2Shortcuts == null || slotIndex < 0 || slotIndex >= _row2Shortcuts.Length) { return KeyboardShortcut.Empty; } return _row2Shortcuts[slotIndex].Value; } public static string GetRow2ShortcutDisplayName(int slotIndex) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut row2Shortcut = GetRow2Shortcut(slotIndex); if ((int)((KeyboardShortcut)(ref row2Shortcut)).MainKey == 0) { return ""; } return KeyCodeToShortLabel(((KeyboardShortcut)(ref row2Shortcut)).MainKey); } public static void ApplyToZInput(int slotIndex, ZInput zInput = null) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (zInput == null) { zInput = ZInput.instance; } if (zInput == null) { return; } KeyboardShortcut row2Shortcut = GetRow2Shortcut(slotIndex); string text = (((int)((KeyboardShortcut)(ref row2Shortcut)).MainKey == 0) ? "/None" : KeyCodePathMap.ToPath(((KeyboardShortcut)(ref row2Shortcut)).MainKey)); if (string.IsNullOrEmpty(text)) { Plugin.Log.LogWarning((object)$"Não foi possível mapear {((KeyboardShortcut)(ref row2Shortcut)).MainKey} pro slot {slotIndex + 1} da 2ª linha."); return; } ButtonDef buttonDef = zInput.GetButtonDef(Row2ActionName(slotIndex)); if (buttonDef != null) { buttonDef.Rebind(text); } } public static void ApplyAllToZInput(ZInput zInput = null) { for (int i = 0; i < 8; i++) { ApplyToZInput(i, zInput); } } private unsafe static string KeyCodeToShortLabel(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected I4, but got Unknown if ((int)key >= 48 && (int)key <= 57) { return (key - 48).ToString(); } if ((int)key >= 97) { _ = 122; return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); } return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); } } [BepInPlugin("hz.inventory_keybinds", "HZ_InventoryKeybinds", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "hz.inventory_keybinds"; public const string ModName = "HZ_InventoryKeybinds"; public const string ModVersion = "1.0.0"; internal static Plugin Instance { get; private set; } internal static Harmony Harmony { get; private set; } internal static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Instance = this; ModConfig.Init(((BaseUnityPlugin)this).Config); Harmony = new Harmony("hz.inventory_keybinds"); Harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"HZ_InventoryKeybinds 1.0.0 loaded."); } private void OnDestroy() { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal class SecondHotbarRow : MonoBehaviour { private class SlotElement { public GameObject Go; public Image Icon; public TMP_Text Amount; public TMP_Text Binding; public GameObject Equiped; public GameObject Queued; public GuiBar Durability; } private readonly List _slots = new List(); private int _builtCount = -1; private void Update() { //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; int num = (ModConfig.IsInitialized ? ModConfig.SecondRowSlotCount.Value : 0); if (num != _builtCount) { Rebuild(num); } if ((Object)(object)localPlayer == (Object)null) { return; } for (int i = 0; i < _slots.Count; i++) { SlotElement slotElement = _slots[i]; ItemData itemAt = ((Humanoid)localPlayer).GetInventory().GetItemAt(i, 1); bool flag = itemAt != null; if (slotElement.Go.activeSelf != flag) { slotElement.Go.SetActive(flag); } if (!flag) { continue; } ((Behaviour)slotElement.Icon).enabled = true; slotElement.Icon.sprite = itemAt.GetIcon(); if (itemAt.m_shared.m_maxStackSize > 1) { ((Behaviour)slotElement.Amount).enabled = true; slotElement.Amount.text = $"{itemAt.m_stack}/{itemAt.m_shared.m_maxStackSize}"; } else { ((Behaviour)slotElement.Amount).enabled = false; } if ((Object)(object)slotElement.Equiped != (Object)null) { slotElement.Equiped.SetActive(itemAt.m_equipped); } if ((Object)(object)slotElement.Queued != (Object)null) { slotElement.Queued.SetActive(localPlayer.IsEquipActionQueued(itemAt)); } if ((Object)(object)slotElement.Durability != (Object)null) { bool flag2 = itemAt.m_shared.m_useDurability && itemAt.m_durability < itemAt.GetMaxDurability(); ((Component)slotElement.Durability).gameObject.SetActive(flag2); if (flag2) { if (itemAt.m_durability <= 0f) { slotElement.Durability.SetValue(1f); slotElement.Durability.SetColor((Color)((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f))); } else { slotElement.Durability.SetValue(itemAt.GetDurabilityPercentage()); slotElement.Durability.ResetColor(); } } } slotElement.Binding.text = ModConfig.GetRow2ShortcutDisplayName(i); } } private void Rebuild(int count) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) foreach (SlotElement slot in _slots) { Object.Destroy((Object)(object)slot.Go); } _slots.Clear(); HotkeyBar val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null || (Object)(object)val.m_elementPrefab == (Object)null) { Plugin.Log.LogWarning((object)"SecondHotbarRow: HotkeyBar ou m_elementPrefab não encontrado."); _builtCount = count; return; } for (int i = 0; i < count; i++) { GameObject val2 = Object.Instantiate(val.m_elementPrefab, ((Component)this).transform); val2.SetActive(true); Transform transform = val2.transform; ((RectTransform)((transform is RectTransform) ? transform : null)).anchoredPosition = new Vector2((float)i * val.m_elementSpace, 0f); SlotElement obj = new SlotElement { Go = val2 }; Transform obj2 = val2.transform.Find("icon"); obj.Icon = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); Transform obj3 = val2.transform.Find("amount"); obj.Amount = ((obj3 != null) ? ((Component)obj3).GetComponent() : null); Transform obj4 = val2.transform.Find("binding"); obj.Binding = ((obj4 != null) ? ((Component)obj4).GetComponent() : null); Transform obj5 = val2.transform.Find("equiped"); obj.Equiped = ((obj5 != null) ? ((Component)obj5).gameObject : null); Transform obj6 = val2.transform.Find("queued"); obj.Queued = ((obj6 != null) ? ((Component)obj6).gameObject : null); Transform obj7 = val2.transform.Find("durability"); obj.Durability = ((obj7 != null) ? ((Component)obj7).GetComponent() : null); SlotElement item = obj; Transform val3 = val2.transform.Find("selected"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } _slots.Add(item); } _builtCount = count; } } [HarmonyPatch(typeof(Hud), "Awake")] internal class SecondHotbarRowInstallPatch { [HarmonyPostfix] private static void Postfix(Hud __instance) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0076: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) if (!((Object)(object)__instance.m_rootObject == (Object)null)) { HotkeyBar val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"SecondHotbarRowInstallPatch: HotkeyBar não encontrado na cena."); return; } GameObject val2 = new GameObject("InventorySets_SecondHotbarRow", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(__instance.m_rootObject.transform, false); Transform transform = ((Component)val).transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); RectTransform component = val2.GetComponent(); component.anchorMin = val3.anchorMin; component.anchorMax = val3.anchorMax; component.pivot = val3.pivot; component.anchoredPosition = val3.anchoredPosition + new Vector2(0f, -80f); val2.AddComponent(); MessageHudOffsetPatch.ApplyOffset(); } } } [HarmonyPatch(typeof(Player), "Update")] internal class SecondRowHotbarInputPatch { [HarmonyPostfix] private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !ModConfig.IsInitialized) { return; } int value = ModConfig.SecondRowSlotCount.Value; for (int i = 0; i < value; i++) { if (ZInput.GetButtonDown(ModConfig.Row2ActionName(i))) { ItemData itemAt = ((Humanoid)__instance).GetInventory().GetItemAt(i, 1); if (itemAt != null) { ((Humanoid)__instance).UseItem((Inventory)null, itemAt, false); } } } } } [HarmonyPatch(typeof(ZInput), "Reset")] internal class ZInputResetPatch { private static readonly MethodInfo AddButtonMethod = AccessTools.Method(typeof(ZInput), "AddButton", (Type[])null, (Type[])null); [HarmonyPostfix] private static void Postfix(ZInput __instance) { for (int i = 0; i < 8; i++) { string text = ModConfig.Row2ActionName(i); AddButtonMethod.Invoke(__instance, new object[7] { text, "/None", false, true, false, 0f, 0f }); } MessageHudOffsetPatch.ApplyOffset(); ModConfig.ApplyAllToZInput(__instance); } } }