using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Il2CppDG.Tweening; using Il2CppDG.Tweening.Core; using Il2CppDG.Tweening.Plugins.Options; using Il2CppSystem; using InventoryFramework; using InventoryUI; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "InventoryUI", "1.0.0", "gameknight963", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("InventoryUI")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8b331d20188ffcb1de292afb888655f917a04c0c")] [assembly: AssemblyProduct("InventoryUI")] [assembly: AssemblyTitle("InventoryUI")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 InventoryUI { public class Core : MelonMod { private ItemPicker? _picker; private Hotbar? _hotbar; public override void OnSceneWasLoaded(int buildIndex, string sceneName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (!(sceneName != "Version 1.9 POST")) { _picker?.Dispose(); _hotbar?.Dispose(); GameObject val = new GameObject("InventoryCanvas"); Canvas val2 = val.AddComponent(); val2.renderMode = (RenderMode)0; val.AddComponent(); val.AddComponent(); val.AddComponent(); _hotbar = new Hotbar(val); val.AddComponent(); _picker = new ItemPicker(val); } } } public class Hotbar { private const int SlotCount = 9; private readonly GameObject[] _slots = (GameObject[])(object)new GameObject[9]; private int _selectedIndex = 0; private static readonly Color SlotNormal = new Color(0f, 0f, 0f, 0.7f); private static readonly Color SlotSelected = new Color(1f, 1f, 1f, 0.4f); private readonly Text _itemLabel; private const float LabelDuration = 2f; private readonly Action _onChanged; public static Hotbar? Instance { get; private set; } public Hotbar(GameObject canvas) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_007b: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Instance = this; _onChanged = delegate { Refresh(InventoryManager.Instance.PlayerInventory.Items); }; InventoryManager.Instance.PlayerInventory.OnChanged += _onChanged; GameObject val = new GameObject("Hotbar"); val.transform.SetParent(canvas.transform, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = new Vector2(0.5f, 0f); val2.anchorMax = new Vector2(0.5f, 0f); val2.pivot = new Vector2(0.5f, 0f); val2.anchoredPosition = new Vector2(0f, 10f); val2.sizeDelta = new Vector2(482f, 50f); HorizontalLayoutGroup val3 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; for (int i = 0; i < 9; i++) { _slots[i] = CreateSlot(val, i); } GameObject val4 = new GameObject("ItemLabel"); val4.transform.SetParent(canvas.transform, false); RectTransform val5 = val4.AddComponent(); val5.anchorMin = new Vector2(0.5f, 0f); val5.anchorMax = new Vector2(0.5f, 0f); val5.pivot = new Vector2(0.5f, 0f); val5.anchoredPosition = new Vector2(0f, 68f); val5.sizeDelta = new Vector2(300f, 20f); _itemLabel = val4.AddComponent(); _itemLabel.font = Resources.GetBuiltinResource("Arial.ttf"); _itemLabel.fontSize = 14; _itemLabel.alignment = (TextAnchor)4; ((Graphic)_itemLabel).color = Color.white; Refresh(InventoryManager.Instance.PlayerInventory.Items); } public void Dispose() { InventoryManager.Instance.PlayerInventory.OnChanged -= _onChanged; } private GameObject CreateSlot(GameObject parent, int index) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00ac: 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) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"Slot_{index}"); val.transform.SetParent(parent.transform, false); RectTransform val2 = val.AddComponent(); val2.sizeDelta = new Vector2(50f, 50f); Image val3 = val.AddComponent(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.7f); GameObject val4 = new GameObject("Icon"); val4.transform.SetParent(val.transform, false); RectTransform val5 = val4.AddComponent(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = new Vector2(4f, 4f); val5.offsetMax = new Vector2(-4f, -4f); ((Behaviour)val4.AddComponent()).enabled = false; GameObject val6 = new GameObject("Quantity"); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent(); val7.anchorMin = new Vector2(1f, 0f); val7.anchorMax = new Vector2(1f, 0f); val7.pivot = new Vector2(1f, 0f); val7.anchoredPosition = new Vector2(-2f, 2f); Text val8 = val6.AddComponent(); val8.font = Resources.GetBuiltinResource("Arial.ttf"); val8.fontSize = 10; val8.alignment = (TextAnchor)8; ((Graphic)val8).color = Color.white; return val; } public void SelectSlot(int index) { //IL_0013: 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_00bb: Unknown result type (might be due to invalid IL or missing references) ((Graphic)_slots[_selectedIndex].GetComponent()).color = SlotNormal; _selectedIndex = index; ((Graphic)_slots[_selectedIndex].GetComponent()).color = SlotSelected; InventoryItem val = ((_selectedIndex < InventoryManager.Instance.PlayerInventory.Items.Count) ? InventoryManager.Instance.PlayerInventory.Items[_selectedIndex] : null); InventoryManager.Instance.SelectItem(val); DOTween.Kill((Object)(object)_itemLabel, false); if (val != null) { _itemLabel.text = val.Definition.Name; ((Graphic)_itemLabel).color = Color.white; TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetDelay>(DOTween.To(DOGetter.op_Implicit((Func)(() => ((Graphic)_itemLabel).color.a)), DOSetter.op_Implicit((Action)delegate(float a) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Graphic)_itemLabel).color = new Color(1f, 1f, 1f, a); }), 0f, 0.5f), 1.5f), (Object)(object)_itemLabel); } else { _itemLabel.text = ""; } } public void Refresh(IReadOnlyList items) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 9; i++) { GameObject val = _slots[i]; Image component = ((Component)val.transform.Find("Icon")).GetComponent(); Text component2 = ((Component)val.transform.Find("Quantity")).GetComponent(); Image component3 = val.GetComponent(); ((Graphic)component3).color = ((i == _selectedIndex) ? SlotSelected : SlotNormal); if (i < items.Count) { InventoryItem val2 = items[i]; ((Behaviour)component).enabled = (Object)(object)val2.Definition.Image != (Object)null; if ((Object)(object)val2.Definition.Image != (Object)null) { component.sprite = val2.Definition.Image; } else { component.sprite = null; } component2.text = ((val2.Quantity > 1) ? val2.Quantity.ToString() : ""); } else { ((Behaviour)component).enabled = false; component2.text = ""; } } } } [RegisterTypeInIl2Cpp] public class HotbarBehaviour : MonoBehaviour { public HotbarBehaviour(IntPtr ptr) : base(ptr) { } public void Update() { if (Hotbar.Instance == null) { return; } for (int i = 0; i < 9; i++) { if (Input.GetKeyDown((KeyCode)(49 + i))) { Hotbar.Instance.SelectSlot(i); } } } } public class ItemPicker { private const int Columns = 9; private const float CellSize = 50f; private const float Padding = 10f; private const float Spacing = 4f; private GameObject _root; private GameObject _grid; private bool _visible = false; private readonly Action _onItemRegistered; private CursorLockMode _previousLockState; private bool _previousCursorVisible; public static ItemPicker? Instance { get; private set; } public ItemPicker(GameObject canvas) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00b9: 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) //IL_00d4: Expected O, but got Unknown //IL_00fe: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) Instance = this; _root = new GameObject("ItemPicker"); _root.transform.SetParent(canvas.transform, false); RectTransform val = _root.AddComponent(); val.anchorMin = new Vector2(0.5f, 0.5f); val.anchorMax = new Vector2(0.5f, 0.5f); val.pivot = new Vector2(0.5f, 0.5f); val.anchoredPosition = Vector2.zero; Image val2 = _root.AddComponent(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.85f); _grid = new GameObject("Grid"); _grid.transform.SetParent(_root.transform, false); RectTransform val3 = _grid.AddComponent(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = new Vector2(10f, 10f); val3.offsetMax = new Vector2(-10f, -10f); GridLayoutGroup val4 = _grid.AddComponent(); val4.cellSize = new Vector2(50f, 70f); val4.spacing = new Vector2(4f, 4f); val4.constraint = (Constraint)1; val4.constraintCount = 9; _root.SetActive(false); Populate(); _onItemRegistered = delegate { Populate(); }; InventoryManager.Instance.OnItemRegistered += _onItemRegistered; } public void Dispose() { InventoryManager.Instance.OnItemRegistered -= _onItemRegistered; } public void Populate() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) for (int num = _grid.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)_grid.transform.GetChild(num)).gameObject); } List list = new List(InventoryManager.Instance.Registry.Values); int num2 = Mathf.CeilToInt((float)list.Count / 9f); float num3 = 502f; float num4 = (float)num2 * 70f + (float)(num2 - 1) * 4f + 20f; MelonLogger.Msg($"Items: {list.Count}, Rows: {num2}, Width: {num3}, Height: {num4}"); RectTransform component = _root.GetComponent(); component.sizeDelta = new Vector2(num3, num4); foreach (ItemDefinition item in list) { CreateCell(item); } } private void CreateCell(ItemDefinition def) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005a: 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_0095: Expected O, but got Unknown //IL_00be: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) ItemDefinition def2 = def; GameObject val = new GameObject(def2.Id); val.transform.SetParent(_grid.transform, false); val.AddComponent(); Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(0.2f, 0.2f, 0.2f, 1f); Button val3 = val.AddComponent