using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace RepoInventoryMod; [BepInPlugin("de.geilo.RepoInventoryMod", "RepoInventoryMod", "1.0.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource ModLog; private static Harmony _harmony; private static GameObject _managerObject; private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) ModLog = ((BaseUnityPlugin)this).Logger; try { PluginConfig.InitConfig(((BaseUnityPlugin)this).Config); _harmony = new Harmony("de.geilo.RepoInventoryMod"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); _managerObject = new GameObject("RepoInventoryMod_Manager"); Object.DontDestroyOnLoad((Object)(object)_managerObject); _managerObject.AddComponent(); if (PluginConfig.EnableLogging.Value) { ModLog.LogInfo((object)"=========================================="); ModLog.LogInfo((object)"RepoInventoryMod v1.0.0 loaded successfully!"); ModLog.LogInfo((object)$"Config - SlotCount: {PluginConfig.SlotCount.Value}"); ModLog.LogInfo((object)$"Config - RadialMenuKey: {PluginConfig.RadialMenuKey.Value}"); ModLog.LogInfo((object)"=========================================="); } } catch (Exception ex) { ModLog.LogError((object)$"Load error: {ex.Message}\n{ex.StackTrace}"); } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } if ((Object)(object)_managerObject != (Object)null) { Object.Destroy((Object)(object)_managerObject); } } } public static class PluginConfig { public static ConfigEntry SlotCount; public static ConfigEntry RadialMenuKey; public static ConfigEntry EnableLogging; public static void InitConfig(ConfigFile config) { SlotCount = config.Bind("General", "SlotCount", 5, "Die Gesamtanzahl der Inventarslots (Standard ist 3, Maximum 10)."); RadialMenuKey = config.Bind("General", "RadialMenuKey", (KeyCode)103, "Die Taste zum Oeffnen des Ausruestungsrads."); EnableLogging = config.Bind("Debug", "EnableLogging", true, "Aktiviert Debug-Meldungen in der BepInEx Konsole."); } } public class RadialMenuManager : MonoBehaviour { public static bool IsOpen = false; private Inventory _lastInventoryInstance = null; private bool _slotsDuplicated = false; private int _selectedSlotIndex = -1; private static Texture2D _whiteTexture; private static GUIStyle _textStyle; private static GUIStyle _titleStyle; private static GUIStyle _centerStyle; public static Texture2D WhiteTexture { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_whiteTexture == (Object)null) { _whiteTexture = new Texture2D(1, 1); _whiteTexture.SetPixel(0, 0, Color.white); _whiteTexture.Apply(); } return _whiteTexture; } } public static List GetInventorySpots(Inventory inv) { if ((Object)(object)inv == (Object)null) { return null; } FieldInfo field = typeof(Inventory).GetField("inventorySpots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (List)field.GetValue(inv); } return null; } public static void SetInventorySpots(Inventory inv, List spots) { if (!((Object)(object)inv == (Object)null)) { FieldInfo field = typeof(Inventory).GetField("inventorySpots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(inv, spots); } } } public static void SetBatteryVisualLogic(InventorySpot spot, BatteryVisualLogic logic) { if (!((Object)(object)spot == (Object)null)) { FieldInfo field = typeof(InventorySpot).GetField("batteryVisualLogic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(spot, logic); } } } public static void SetInventoryIcon(InventorySpot spot, Image icon) { if (!((Object)(object)spot == (Object)null)) { FieldInfo field = typeof(InventorySpot).GetField("inventoryIcon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(spot, icon); } } } public static Vector3 GetInitialPosition(SemiUI ui) { //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_004c: 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) //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_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ui == (Object)null) { return Vector3.zero; } FieldInfo field = typeof(SemiUI).GetField("initialPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (Vector3)field.GetValue(ui); } return Vector3.zero; } public static void SetInitialPosition(SemiUI ui, Vector3 value) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ui == (Object)null)) { FieldInfo field = typeof(SemiUI).GetField("initialPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(ui, value); } } } public static string GetItemInstanceName(Component itemAttributes) { if ((Object)(object)itemAttributes == (Object)null) { return ""; } FieldInfo field = ((object)itemAttributes).GetType().GetField("instanceName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (string)field.GetValue(itemAttributes); } return ""; } private void Update() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0155: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) Inventory instance = Inventory.instance; if ((Object)(object)instance != (Object)(object)_lastInventoryInstance) { _lastInventoryInstance = instance; _slotsDuplicated = false; IsOpen = false; } if ((Object)(object)instance == (Object)null) { return; } List inventorySpots = GetInventorySpots(instance); if (!_slotsDuplicated && inventorySpots != null && inventorySpots.Count >= 3) { InventorySpot val = inventorySpots[2]; if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { DuplicateSlots(instance, val); _slotsDuplicated = true; } } if (!_slotsDuplicated || inventorySpots == null) { return; } KeyCode value = PluginConfig.RadialMenuKey.Value; if (Input.GetKeyDown(value)) { IsOpen = true; _selectedSlotIndex = -1; } if (!IsOpen) { return; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)PlayerController.instance != (Object)null) { PlayerController.instance.InputDisable(0.1f); } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); Vector2 val4 = val3 - val2; float magnitude = ((Vector2)(ref val4)).magnitude; int count = inventorySpots.Count; if (magnitude > 15f && count > 0) { float num = Mathf.Atan2(val4.y, val4.x) * 57.29578f; if (num < 0f) { num += 360f; } float num2 = num - 270f; if (num2 < 0f) { num2 += 360f; } float num3 = 360f / (float)count; _selectedSlotIndex = Mathf.FloorToInt((num2 + num3 / 2f) / num3) % count; } else { _selectedSlotIndex = -1; } if (!Input.GetKeyUp(value)) { return; } IsOpen = false; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; if (_selectedSlotIndex < 0 || _selectedSlotIndex >= inventorySpots.Count) { return; } InventorySpot val5 = inventorySpots[_selectedSlotIndex]; if ((Object)(object)val5 != (Object)null) { if (PluginConfig.EnableLogging.Value) { Plugin.ModLog.LogInfo((object)$"Radial Menu: Triggering slot {_selectedSlotIndex + 1}"); } MethodInfo method = typeof(InventorySpot).GetMethod("HandleInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(val5, null); } } } private void DuplicateSlots(Inventory inv, InventorySpot templateSlot) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) //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) //IL_00b5: 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_00c5: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01b8: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) int value = PluginConfig.SlotCount.Value; if (value <= 3) { return; } List inventorySpots = GetInventorySpots(inv); if (inventorySpots == null) { return; } InventorySpot val = inventorySpots[1]; if ((Object)(object)val == (Object)null) { if (PluginConfig.EnableLogging.Value) { Plugin.ModLog.LogWarning((object)"Cannot duplicate slots: Slot 1 is null."); } return; } Vector2 val2 = ((SemiUI)templateSlot).showPosition - ((SemiUI)val).showPosition; Vector2 val3 = ((SemiUI)templateSlot).hidePosition - ((SemiUI)val).hidePosition; Vector3 val4 = GetInitialPosition((SemiUI)(object)templateSlot) - GetInitialPosition((SemiUI)(object)val); Vector3 val5 = ((Component)templateSlot).transform.localPosition - ((Component)val).transform.localPosition; Transform parent = ((Component)templateSlot).transform.parent; for (int i = 3; i < value; i++) { GameObject val6 = Object.Instantiate(((Component)templateSlot).gameObject, parent); ((Object)val6).name = "Inventory Spot " + (i + 1); InventorySpot component = val6.GetComponent(); if ((Object)(object)component == (Object)null) { if (PluginConfig.EnableLogging.Value) { Plugin.ModLog.LogError((object)"Duplicated slot does not have InventorySpot component!"); } continue; } SetInventoryIcon(component, val6.GetComponentInChildren()); SetBatteryVisualLogic(component, val6.GetComponentInChildren()); component.inventorySpotIndex = i; int num = i - 2; ((SemiUI)component).showPosition = ((SemiUI)templateSlot).showPosition + val2 * (float)num; ((SemiUI)component).hidePosition = ((SemiUI)templateSlot).hidePosition + val3 * (float)num; SetInitialPosition((SemiUI)(object)component, GetInitialPosition((SemiUI)(object)templateSlot) + val4 * (float)num); ((Component)component).transform.localPosition = ((Component)templateSlot).transform.localPosition + val5 * (float)num; if ((Object)(object)component.noItem != (Object)null) { ((TMP_Text)component.noItem).text = (i + 1).ToString(); } inv.InventorySpotAddAtIndex(component, i); if (PluginConfig.EnableLogging.Value) { Plugin.ModLog.LogInfo((object)$"Duplicated and registered slot {i + 1} at position {((Component)component).transform.localPosition}"); } } FieldInfo field = typeof(Inventory).GetField("spotsFeched", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(inv, true); } } private void OnGUI() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_008a: 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_00b6: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Expected O, but got Unknown //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Expected O, but got Unknown //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } DrawRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new Color(0f, 0f, 0f, 0.45f)); if (_textStyle == null) { _textStyle = new GUIStyle(GUI.skin.label); _textStyle.alignment = (TextAnchor)4; _textStyle.normal.textColor = Color.white; _textStyle.fontSize = 13; _titleStyle = new GUIStyle(GUI.skin.label); _titleStyle.alignment = (TextAnchor)4; _titleStyle.fontStyle = (FontStyle)1; _titleStyle.normal.textColor = new Color(0f, 0.8f, 1f, 1f); _titleStyle.fontSize = 20; _centerStyle = new GUIStyle(GUI.skin.label); _centerStyle.alignment = (TextAnchor)4; _centerStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1f); _centerStyle.fontSize = 12; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); GUI.Label(new Rect(val.x - 200f, val.y - 30f, 400f, 25f), "AUSRÜSTUNGSRAD", _titleStyle); GUI.Label(new Rect(val.x - 200f, val.y, 400f, 20f), "Maus bewegen & G loslassen zum Ausrüsten", _centerStyle); if (_selectedSlotIndex >= 0) { GUI.Label(new Rect(val.x - 200f, val.y + 20f, 400f, 20f), $"Ausgewählt: Slot {_selectedSlotIndex + 1}", _textStyle); } else { GUI.Label(new Rect(val.x - 200f, val.y + 20f, 400f, 20f), "Keine Auswahl (Mitte)", _centerStyle); } Inventory instance = Inventory.instance; if ((Object)(object)instance == (Object)null) { return; } List inventorySpots = GetInventorySpots(instance); if (inventorySpots == null) { return; } int count = inventorySpots.Count; float num = 160f; float num2 = 360f / (float)count; Rect rect = default(Rect); Rect rect2 = default(Rect); Rect val6 = default(Rect); for (int i = 0; i < count; i++) { float num3 = ((float)i * num2 - 90f) * ((float)Math.PI / 180f); Vector2 val2 = val + new Vector2(Mathf.Cos(num3), Mathf.Sin(num3)) * num; ((Rect)(ref rect))..ctor(val2.x - 45f, val2.y - 45f, 90f, 90f); bool flag = i == _selectedSlotIndex; Color color = (flag ? new Color(0f, 0.45f, 0.7f, 0.75f) : new Color(0.12f, 0.12f, 0.12f, 0.7f)); Color color2 = (flag ? new Color(0f, 0.85f, 1f, 1f) : new Color(0.3f, 0.3f, 0.3f, 0.6f)); DrawRect(rect, color); DrawBorder(rect, 1, color2); InventorySpot val3 = inventorySpots[i]; ItemEquippable val4 = (((Object)(object)val3 != (Object)null) ? val3.CurrentItem : null); Sprite val5 = null; string text = "LEER"; if ((Object)(object)val4 != (Object)null) { Component component = ((Component)val4).GetComponent("ItemAttributes"); if ((Object)(object)component != (Object)null) { FieldInfo field = ((object)component).GetType().GetField("icon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { val5 = (Sprite)field.GetValue(component); } text = GetItemInstanceName(component); } } GUI.Label(new Rect(((Rect)(ref rect)).x + 5f, ((Rect)(ref rect)).y + 2f, 20f, 20f), (i + 1).ToString(), _textStyle); if ((Object)(object)val5 != (Object)null) { ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + 20f, ((Rect)(ref rect)).y + 15f, 50f, 50f); DrawSprite(rect2, val5); } ((Rect)(ref val6))..ctor(((Rect)(ref rect)).x - 25f, ((Rect)(ref rect)).y + 92f, 140f, 20f); GUIStyle val7 = new GUIStyle(_textStyle); val7.normal.textColor = (Color)(flag ? new Color(0f, 0.85f, 1f, 1f) : (((Object)(object)val4 != (Object)null) ? Color.white : new Color(0.5f, 0.5f, 0.5f, 1f))); val7.fontSize = 11; GUI.Label(val6, text, val7); } } public static void DrawRect(Rect rect, Color color) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)WhiteTexture); GUI.color = color2; } public static void DrawBorder(Rect rect, int width, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //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) DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, (float)width), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - (float)width, ((Rect)(ref rect)).width, (float)width), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, (float)width, ((Rect)(ref rect)).height), color); DrawRect(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - (float)width, ((Rect)(ref rect)).y, (float)width, ((Rect)(ref rect)).height), color); } public static void DrawSprite(Rect rect, Sprite sprite) { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null)) { Texture2D texture = sprite.texture; if (!((Object)(object)texture == (Object)null)) { Rect rect2 = sprite.rect; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref rect2)).x / (float)((Texture)texture).width, ((Rect)(ref rect2)).y / (float)((Texture)texture).height, ((Rect)(ref rect2)).width / (float)((Texture)texture).width, ((Rect)(ref rect2)).height / (float)((Texture)texture).height); GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val); } } } } [HarmonyPatch(typeof(Inventory), "Awake")] public class Inventory_Awake_Patch { [HarmonyPostfix] public static void Postfix(Inventory __instance) { int value = PluginConfig.SlotCount.Value; List list = RadialMenuManager.GetInventorySpots(__instance); if (list == null) { list = new List(); RadialMenuManager.SetInventorySpots(__instance, list); } while (list.Count < value) { list.Add(null); } if (PluginConfig.EnableLogging.Value) { Plugin.ModLog.LogInfo((object)$"Inventory_Awake_Patch: Resized inventorySpots list to {list.Count}"); } } } [HarmonyPatch(typeof(Inventory), "GetSpotByIndex")] public class Inventory_GetSpotByIndex_Patch { [HarmonyPrefix] public static bool Prefix(Inventory __instance, int index, ref InventorySpot __result) { List inventorySpots = RadialMenuManager.GetInventorySpots(__instance); if (inventorySpots == null || index < 0 || index >= inventorySpots.Count) { __result = null; return false; } __result = inventorySpots[index]; return false; } } [HarmonyPatch(typeof(Inventory), "IsSpotOccupied")] public class Inventory_IsSpotOccupied_Patch { [HarmonyPrefix] public static bool Prefix(Inventory __instance, int index, ref bool __result) { List inventorySpots = RadialMenuManager.GetInventorySpots(__instance); if (inventorySpots == null || index < 0 || index >= inventorySpots.Count) { __result = false; return false; } InventorySpot val = inventorySpots[index]; __result = (Object)(object)val != (Object)null && val.IsOccupied(); return false; } } [HarmonyPatch(typeof(Inventory), "GetBatteryStateFromInventorySpot")] public class Inventory_GetBatteryStateFromInventorySpot_Patch { [HarmonyPrefix] public static bool Prefix(Inventory __instance, int index, ref int __result) { List inventorySpots = RadialMenuManager.GetInventorySpots(__instance); if (inventorySpots == null || index < 0 || index >= inventorySpots.Count) { __result = 0; return false; } return true; } }