Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of EZInventory IL2CPP v1.3.3
Mods/EZInventory_IL2CPP.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using EZInventory; using EZInventory.Utils; using HarmonyLib; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Items; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Preferences; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(EZInventoryMod), "EZInventory", "1.0.2", "Kaen01", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("EZInventory")] [assembly: AssemblyConfiguration("IL2CPP")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+685498e5a26ab162747553169d55ca5f38c924ee")] [assembly: AssemblyProduct("EZInventory")] [assembly: AssemblyTitle("EZInventory")] [assembly: AssemblyVersion("1.0.0.0")] namespace EZInventory { public class EZInventoryMod : MelonMod { public static MelonPreferences_Category Config; public static MelonPreferences_Entry<string> GrabAllKey; public static MelonPreferences_Entry<bool> GrabAllAutoClose; public static MelonPreferences_Entry<string> DepositAllKey; public static MelonPreferences_Entry<bool> DepositAllAutoClose; public static MelonPreferences_Entry<string> FillStacksKey; public static MelonPreferences_Entry<bool> FillStacksAutoClose; public static MelonPreferences_Entry<string> CopyAllFilters; public static MelonPreferences_Entry<string> PasteAllFilters; public static MelonPreferences_Entry<string> ClearAllFilters; public override void OnInitializeMelon() { ((MelonBase)this).OnInitializeMelon(); MelonLogger.Msg("EZInventory loaded!"); Config = MelonPreferences.CreateCategory("EZInventory", "EZInventory Settings"); GrabAllKey = Config.CreateEntry<string>("GrabAllKey", "G", (string)null, "Hotkey for Grab All (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: GrabAllKey set to '" + GrabAllKey.Value + "'"); GrabAllAutoClose = Config.CreateEntry<bool>("GrabAllAutoClose", true, (string)null, "Automatically close the inventory screen after Grab All.", false, false, (ValueValidator)null, (string)null); DepositAllKey = Config.CreateEntry<string>("DepositAllKey", "H", (string)null, "Hotkey for Deposit All (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: DepositAllKey set to '" + DepositAllKey.Value + "'"); DepositAllAutoClose = Config.CreateEntry<bool>("DepositAllAutoClose", false, (string)null, "Automatically close the inventory after Deposit All.", false, false, (ValueValidator)null, (string)null); FillStacksKey = Config.CreateEntry<string>("FillStacksKey", "Q", (string)null, "Hotkey for Fill Stacks (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: FillStacksKey set to '" + FillStacksKey.Value + "'"); FillStacksAutoClose = Config.CreateEntry<bool>("FillStacksAutoClose", true, (string)null, "Automatically close the inventory after Fill Stacks.", false, false, (ValueValidator)null, (string)null); ClearAllFilters = Config.CreateEntry<string>("ClearAllFilters", "J", (string)null, "Hotkey for Clear All Filters (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: ClearAllFilters set to '" + ClearAllFilters.Value + "'"); CopyAllFilters = Config.CreateEntry<string>("CopyAllFilters", "K", (string)null, "Hotkey for Copy All Filters (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: CopyAllFilters set to '" + CopyAllFilters.Value + "'"); PasteAllFilters = Config.CreateEntry<string>("PasteAllFilters", "L", (string)null, "Hotkey for Paste All Filters (case-insensitive).", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("EZInventory: PasteAllFilters set to '" + PasteAllFilters.Value + "'"); MelonPreferences.Save(); } } } namespace EZInventory.Utils { internal static class EZInventoryUtils { public static List<T> ToManagedList<T>(List<T> il2cppList) { if (il2cppList == null) { return null; } List<T> list = new List<T>(il2cppList.Count); Enumerator<T> enumerator = il2cppList.GetEnumerator(); while (enumerator.MoveNext()) { T current = enumerator.Current; list.Add(current); } return list; } public static void MoveSlotContents(ItemUIManager mgr, ItemSlot source, List<ItemSlot> dest, bool fillEmptySlots = true, bool filterAware = false) { if (source.ItemInstance == null) { return; } int num = source.Quantity; int num2 = 0; foreach (ItemSlot item in dest) { if (num <= 0) { break; } if (item.ItemInstance != null && item.ItemInstance.CanStackWith(source.ItemInstance, false) && !item.IsLocked && !item.IsAddLocked) { int num3 = Math.Min(item.GetCapacityForItem(source.ItemInstance, false), num); if (num3 > 0 && (!filterAware || item.DoesItemMatchPlayerFilters(source.ItemInstance))) { item.AddItem(source.ItemInstance.GetCopy(num3), false); num -= num3; num2 += num3; } } } if (fillEmptySlots) { foreach (ItemSlot item2 in dest) { if (num <= 0) { break; } if (!item2.IsLocked && !item2.IsAddLocked) { int num4 = Math.Min(item2.GetCapacityForItem(source.ItemInstance, false), num); if (num4 > 0 && (!filterAware || item2.DoesItemMatchPlayerFilters(source.ItemInstance))) { item2.AddItem(source.ItemInstance.GetCopy(num4), false); num -= num4; num2 += num4; } } } } if (num2 > 0) { if (num <= 0) { source.ClearStoredInstance(false); } else { source.ChangeQuantity(-num2, false); } UnityEvent onItemMoved = mgr.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } } } public static class EZIClipboard { public static List<SlotFilter> CopiedFilters { get; private set; } public static bool HasFilters => CopiedFilters != null && CopiedFilters.Count > 0; public static void Copy(List<SlotFilter> filters) { if (filters == null) { CopiedFilters = null; return; } CopiedFilters = new List<SlotFilter>(filters.Count); Enumerator<SlotFilter> enumerator = filters.GetEnumerator(); while (enumerator.MoveNext()) { SlotFilter current = enumerator.Current; CopiedFilters.Add((current != null) ? current.Clone() : null); } } public static void ClearEZIClipboard() { CopiedFilters = null; } } } namespace EZInventory.HarmonyPatches { [HarmonyPatch(typeof(ItemUIManager), "SlotClicked")] internal class EZInventory_MoveByType_Patch { private static readonly FieldInfo primaryField = AccessTools.Field(typeof(ItemUIManager), "PrimarySlots"); private static readonly FieldInfo secondaryField = AccessTools.Field(typeof(ItemUIManager), "SecondarySlots"); private static bool Prefix(ItemUIManager __instance, ItemSlotUI ui) { bool button = GameInput.GetButton((ButtonCode)23); bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); if (!(button && flag)) { return true; } if (!__instance.QuickMoveEnabled) { return true; } ItemSlot assignedSlot = ui.assignedSlot; ItemInstance itemInstance = assignedSlot.ItemInstance; if (itemInstance == null) { return true; } if (itemInstance.Definition.Name == "Cash") { return true; } List<ItemSlot> list = EZInventoryUtils.ToManagedList<ItemSlot>(__instance.PrimarySlots); List<ItemSlot> list2 = EZInventoryUtils.ToManagedList<ItemSlot>(__instance.SecondarySlots); bool flag2 = list.Contains(assignedSlot); List<ItemSlot> list3 = (flag2 ? list : list2); List<ItemSlot> dest = (flag2 ? list2 : list); List<ItemSlot> val = new List<ItemSlot>(); foreach (ItemSlot item in list3) { if (!item.IsLocked && !item.IsRemovalLocked && item.ItemInstance != null && (Object)(object)item.ItemInstance.Definition == (Object)(object)itemInstance.Definition) { val.Add(item); } } Enumerator<ItemSlot> enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { ItemSlot current2 = enumerator2.Current; EZInventoryUtils.MoveSlotContents(__instance, current2, dest, fillEmptySlots: true, flag); } UnityEvent onItemMoved = __instance.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } return false; } } [HarmonyPatch(typeof(ItemUIManager), "Update")] internal class EZInventory_Input_Patch { private static HashSet<ItemSlotUI> processed = new HashSet<ItemSlotUI>(); private static readonly FieldInfo primaryField = AccessTools.Field(typeof(ItemUIManager), "PrimarySlots"); private static readonly FieldInfo secondaryField = AccessTools.Field(typeof(ItemUIManager), "SecondarySlots"); private static readonly FieldInfo itemSlotOwnerField = AccessTools.Field(typeof(ItemUIManager), "ItemSlotOwner"); private static IItemSlotOwner GetCurrentOwner(ItemUIManager mgr) { if (itemSlotOwnerField == null) { return null; } object? value = itemSlotOwnerField.GetValue(mgr); return (IItemSlotOwner)((value is IItemSlotOwner) ? value : null); } private static List<ItemSlot> GetContainerSlots(ItemUIManager mgr) { return EZInventoryUtils.ToManagedList<ItemSlot>(mgr.SecondarySlots); } private static void Postfix(ItemUIManager __instance) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null || !__instance.QuickMoveEnabled || (Object)(object)Singleton<StorageMenu>.Instance == (Object)null) { return; } bool button = GameInput.GetButton((ButtonCode)23); bool button2 = GameInput.GetButton((ButtonCode)8); bool button3 = GameInput.GetButton((ButtonCode)0); if (EZInventoryMod.GrabAllKey != null) { string text = EZInventoryMod.GrabAllKey.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result)) { if (Input.GetKeyDown(result)) { TakeEverything(__instance); if (EZInventoryMod.GrabAllAutoClose != null && EZInventoryMod.GrabAllAutoClose.Value) { StorageMenu instance = Singleton<StorageMenu>.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.OpenedStorageEntity != (Object)null) { Singleton<StorageMenu>.Instance.OpenedStorageEntity.Close(); } return; } } } else { MelonLogger.Warning("EZInventory: Invalid GrabAllKey '" + text + "'"); } } if (EZInventoryMod.DepositAllKey != null) { string text2 = EZInventoryMod.DepositAllKey.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(text2, ignoreCase: true, out KeyCode result2)) { if (Input.GetKeyDown(result2)) { DepositAll(__instance, button2); if (EZInventoryMod.DepositAllAutoClose != null && EZInventoryMod.DepositAllAutoClose.Value) { if ((Object)(object)Singleton<StorageMenu>.Instance != (Object)null && (Object)(object)Singleton<StorageMenu>.Instance.OpenedStorageEntity != (Object)null) { Singleton<StorageMenu>.Instance.OpenedStorageEntity.Close(); } return; } } } else { MelonLogger.Warning("EZInventory: Invalid DepositAllKey '" + text2 + "'"); } } if (EZInventoryMod.FillStacksKey != null) { string value = EZInventoryMod.FillStacksKey.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(value, ignoreCase: true, out KeyCode result3) && Input.GetKeyDown(result3)) { FillStacks(__instance); if (EZInventoryMod.FillStacksAutoClose != null && EZInventoryMod.FillStacksAutoClose.Value) { if ((Object)(object)Singleton<StorageMenu>.Instance != (Object)null && (Object)(object)Singleton<StorageMenu>.Instance.OpenedStorageEntity != (Object)null) { Singleton<StorageMenu>.Instance.OpenedStorageEntity.Close(); } return; } } } if (EZInventoryMod.CopyAllFilters != null) { string value2 = EZInventoryMod.CopyAllFilters.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(value2, ignoreCase: true, out KeyCode result4) && Input.GetKeyDown(result4)) { List<ItemSlot> containerSlots = GetContainerSlots(__instance); if (containerSlots == null) { return; } List<SlotFilter> val = new List<SlotFilter>(containerSlots.Count); foreach (ItemSlot item in containerSlots) { if (item.CanPlayerSetFilter) { val.Add((item.PlayerFilter != null) ? item.PlayerFilter.Clone() : null); } else { val.Add((SlotFilter)null); } } EZIClipboard.Copy(val); } } if (EZInventoryMod.PasteAllFilters != null) { string value3 = EZInventoryMod.PasteAllFilters.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(value3, ignoreCase: true, out KeyCode result5) && Input.GetKeyDown(result5)) { if (!EZIClipboard.HasFilters) { return; } List<ItemSlot> containerSlots2 = GetContainerSlots(__instance); if (containerSlots2 == null) { return; } List<SlotFilter> copiedFilters = EZIClipboard.CopiedFilters; int num = Math.Min(copiedFilters.Count, containerSlots2.Count); for (int i = 0; i < num; i++) { ItemSlot val2 = containerSlots2[i]; if (val2.CanPlayerSetFilter) { SlotFilter val3 = copiedFilters[i]; if (val3 == null) { val2.SetPlayerFilter(new SlotFilter(), false); } else { val2.SetPlayerFilter(val3.Clone(), false); } } } UnityEvent onItemMoved = __instance.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } } if (EZInventoryMod.ClearAllFilters != null) { string value4 = EZInventoryMod.ClearAllFilters.Value.ToUpperInvariant(); if (Enum.TryParse<KeyCode>(value4, ignoreCase: true, out KeyCode result6) && Input.GetKeyDown(result6)) { List<ItemSlot> containerSlots3 = GetContainerSlots(__instance); if (containerSlots3 == null) { return; } foreach (ItemSlot item2 in containerSlots3) { if (item2.CanPlayerSetFilter) { item2.SetPlayerFilter(new SlotFilter(), false); } } UnityEvent onItemMoved2 = __instance.onItemMoved; if (onItemMoved2 != null) { onItemMoved2.Invoke(); } } } if (button && button3 && __instance.QuickMoveEnabled) { ItemSlotUI hoveredSlot = __instance.HoveredSlot; if ((Object)(object)hoveredSlot != (Object)null && !processed.Contains(hoveredSlot)) { processed.Add(hoveredSlot); QuickMoveSlot(__instance, hoveredSlot, button2); } } else { processed.Clear(); } } private static void QuickMoveSlot(ItemUIManager mgr, ItemSlotUI ui, bool filterAware = false) { if (!mgr.CanDragFromSlot(ui)) { return; } ItemSlot assignedSlot = ui.assignedSlot; if (assignedSlot.ItemInstance != null && assignedSlot.ItemInstance.Definition.Name == "Cash") { return; } List<ItemSlot> quickMoveSlots = mgr.GetQuickMoveSlots(assignedSlot); List<ItemSlot> val = null; if (quickMoveSlots != null) { val = new List<ItemSlot>(quickMoveSlots.Count); Enumerator<ItemSlot> enumerator = quickMoveSlots.GetEnumerator(); while (enumerator.MoveNext()) { ItemSlot current = enumerator.Current; val.Add(current); } } if (val == null || val.Count == 0) { return; } int num = 0; Enumerator<ItemSlot> enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { ItemSlot current2 = enumerator2.Current; if (num >= assignedSlot.Quantity) { break; } if (current2.ItemInstance != null && !current2.IsLocked && !current2.IsAddLocked && !current2.IsRemovalLocked && current2.ItemInstance.CanStackWith(assignedSlot.ItemInstance, false)) { int num2 = Mathf.Min(current2.GetCapacityForItem(assignedSlot.ItemInstance, false), assignedSlot.Quantity - num); if (num2 > 0 && (!filterAware || current2.DoesItemMatchPlayerFilters(assignedSlot.ItemInstance)) && !assignedSlot.IsRemovalLocked && !assignedSlot.IsLocked) { current2.AddItem(assignedSlot.ItemInstance.GetCopy(num2), false); num += num2; } } } Enumerator<ItemSlot> enumerator3 = val.GetEnumerator(); while (enumerator3.MoveNext()) { ItemSlot current3 = enumerator3.Current; if (num >= assignedSlot.Quantity) { break; } int num3 = Mathf.Min(current3.GetCapacityForItem(assignedSlot.ItemInstance, false), assignedSlot.Quantity - num); if (num3 > 0 && !assignedSlot.IsRemovalLocked && !assignedSlot.IsLocked && (!filterAware || current3.DoesItemMatchPlayerFilters(assignedSlot.ItemInstance))) { current3.AddItem(assignedSlot.ItemInstance.GetCopy(num3), false); num += num3; } } if (num > 0) { assignedSlot.ChangeQuantity(-num, false); UnityEvent onItemMoved = mgr.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } } private static void TakeEverything(ItemUIManager mgr) { if (!mgr.QuickMoveEnabled) { return; } List<ItemSlot> list = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.PrimarySlots); List<ItemSlot> list2 = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.SecondarySlots); List<ItemSlot> list3 = list; List<ItemSlot> list4 = list2; if (list3 == null || list4 == null) { return; } foreach (ItemSlot item in list4) { if (item.ItemInstance != null && !(item.ItemInstance.Definition.Name == "Cash") && !item.IsRemovalLocked && !item.IsLocked) { EZInventoryUtils.MoveSlotContents(mgr, item, list3); } } UnityEvent onItemMoved = mgr.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } private static void DepositAll(ItemUIManager mgr, bool filterAware = false) { List<ItemSlot> list = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.PrimarySlots); List<ItemSlot> list2 = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.SecondarySlots); List<ItemSlot> list3 = list; List<ItemSlot> list4 = list2; if (list3 == null || list4 == null) { return; } foreach (ItemSlot item in list3) { if (item.ItemInstance != null && !(item.ItemInstance.Definition.Name == "Cash") && !item.IsAddLocked && !item.IsLocked) { EZInventoryUtils.MoveSlotContents(mgr, item, list4, fillEmptySlots: true, filterAware); } } UnityEvent onItemMoved = mgr.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } private static void FillStacks(ItemUIManager mgr) { if (!mgr.QuickMoveEnabled) { return; } List<ItemSlot> list = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.PrimarySlots); List<ItemSlot> list2 = EZInventoryUtils.ToManagedList<ItemSlot>(mgr.SecondarySlots); List<ItemSlot> list3 = list; List<ItemSlot> list4 = list2; if (list4 == null || list3 == null) { return; } foreach (ItemSlot item in list4) { if (item.ItemInstance != null && !(item.ItemInstance.Definition.Name == "Cash") && !item.IsRemovalLocked && !item.IsLocked) { EZInventoryUtils.MoveSlotContents(mgr, item, list3, fillEmptySlots: false); } } UnityEvent onItemMoved = mgr.onItemMoved; if (onItemMoved != null) { onItemMoved.Invoke(); } } } }