using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("MoreBankTabs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+31582adbf3effe8b40d78be6efd9bd81c32c3857")]
[assembly: AssemblyProduct("MoreBankTabs")]
[assembly: AssemblyTitle("MoreBankTabs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MoreBankTabs
{
public static class Extensions
{
public static T GetPrivateField<T>(this object instance, string name)
{
FieldInfo field = instance.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
return (T)field.GetValue(instance);
}
public static void InvokePrivateMethod(this object instance, string name, params object[] args)
{
MethodInfo method = instance.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(instance, args);
}
public static T InvokePrivateMethod<T>(this object instance, string name, params object[] args)
{
MethodInfo method = instance.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic);
return (T)method.Invoke(instance, args);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.16mb.morebanktabs";
public const string PLUGIN_NAME = "MoreBankTabs";
public const string PLUGIN_VERSION = "0.1.1";
}
[BepInPlugin("com.16mb.morebanktabs", "MoreBankTabs", "0.1.1")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ItemStorageManager), "Awake")]
public static class AwakePatch
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__SetStorageTab_03;
public static UnityAction <1>__SetStorageTab_04;
public static UnityAction <2>__SetStorageTab_05;
}
private static ItemStorageManager itemStorageManager;
[HarmonyPostfix]
private static void AwakePostfix(ItemStorageManager __instance)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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)
//IL_00a6: 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_00b1: Expected O, but got Unknown
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Expected O, but got Unknown
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: 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_017c: Expected O, but got Unknown
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Expected O, but got Unknown
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Expected O, but got Unknown
//IL_023c: 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)
//IL_0247: Expected O, but got Unknown
itemStorageManager = __instance;
GameObject val = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_storageBox/_button_storageTab_00");
GameObject val2 = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_storageBox/_button_storageTab_01");
GameObject val3 = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_storageBox/_button_storageTab_02");
GameObject val4 = Object.Instantiate<GameObject>(val, val.transform, true);
val4.transform.localPosition = new Vector3(132f, 0f, 0f);
_storageTabButton_03 = val4.GetComponent<Button>();
Image componentInChildren = val4.GetComponentInChildren<Image>();
((Graphic)componentInChildren).color = ((Graphic)componentInChildren).color + new Color(0.35f, 0f, 0.1f);
ButtonClickedEvent onClick = _storageTabButton_03.onClick;
object obj = <>O.<0>__SetStorageTab_03;
if (obj == null)
{
UnityAction val5 = SetStorageTab_03;
<>O.<0>__SetStorageTab_03 = val5;
obj = (object)val5;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
((UnityEvent)_storageTabButton_03.onClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)_storageTabButton_03.onClick).AddListener(new UnityAction(__instance.Init_StorageListing));
GameObject val6 = Object.Instantiate<GameObject>(val2, val2.transform, true);
val6.transform.localPosition = new Vector3(132f, 0f, 0f);
_storageTabButton_04 = val6.GetComponent<Button>();
Image componentInChildren2 = val6.GetComponentInChildren<Image>();
((Graphic)componentInChildren2).color = ((Graphic)componentInChildren2).color + new Color(0.35f, 0f, 0.1f);
ButtonClickedEvent onClick2 = _storageTabButton_04.onClick;
object obj2 = <>O.<1>__SetStorageTab_04;
if (obj2 == null)
{
UnityAction val7 = SetStorageTab_04;
<>O.<1>__SetStorageTab_04 = val7;
obj2 = (object)val7;
}
((UnityEvent)onClick2).AddListener((UnityAction)obj2);
((UnityEvent)_storageTabButton_04.onClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)_storageTabButton_04.onClick).AddListener(new UnityAction(__instance.Init_StorageListing));
GameObject val8 = Object.Instantiate<GameObject>(val3, val3.transform, true);
val8.transform.localPosition = new Vector3(132f, 0f, 0f);
_storageTabButton_05 = val8.GetComponent<Button>();
Image componentInChildren3 = val8.GetComponentInChildren<Image>();
((Graphic)componentInChildren3).color = ((Graphic)componentInChildren3).color + new Color(0.35f, 0f, 0.1f);
ButtonClickedEvent onClick3 = _storageTabButton_05.onClick;
object obj3 = <>O.<2>__SetStorageTab_05;
if (obj3 == null)
{
UnityAction val9 = SetStorageTab_05;
<>O.<2>__SetStorageTab_05 = val9;
obj3 = (object)val9;
}
((UnityEvent)onClick3).AddListener((UnityAction)obj3);
((UnityEvent)_storageTabButton_05.onClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)_storageTabButton_05.onClick).AddListener(new UnityAction(__instance.Init_StorageListing));
}
private static void SetStorageTab_03()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
itemStorageManager._selectedStorageTab = 3;
((Component)itemStorageManager.GetPrivateField<RectTransform>("_storageTabHighlight")).transform.position = ((Component)_storageTabButton_03).transform.GetChild(0).position;
}
private static void SetStorageTab_04()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
itemStorageManager._selectedStorageTab = 4;
((Component)itemStorageManager.GetPrivateField<RectTransform>("_storageTabHighlight")).transform.position = ((Component)_storageTabButton_04).transform.GetChild(0).position;
}
private static void SetStorageTab_05()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
itemStorageManager._selectedStorageTab = 5;
((Component)itemStorageManager.GetPrivateField<RectTransform>("_storageTabHighlight")).transform.position = ((Component)_storageTabButton_05).transform.GetChild(0).position;
}
}
[HarmonyPatch(typeof(ItemStorageManager), "Begin_StorageListing")]
public static class Begin_StorageListingPatch
{
[HarmonyPrefix]
private static bool Begin_StorageListingPrefix(ItemStorageManager __instance)
{
if (__instance._selectedStorageTab > 2)
{
ItemData[] array = null;
switch (__instance._selectedStorageTab)
{
case 3:
array = _itemDatas_03.ToArray();
break;
case 4:
array = _itemDatas_04.ToArray();
break;
case 5:
array = _itemDatas_05.ToArray();
break;
}
for (int i = 0; i < array.Length; i++)
{
ItemData val = array[i];
ScriptableItem val2 = GameManager._current.LocateItem(val._itemName);
if (val._quantity <= 0 || !Object.op_Implicit((Object)(object)val2))
{
break;
}
__instance.Create_StorageEntry(val, val2, i, val._slotNumber);
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ItemStorageManager), "Create_StorageEntry")]
public static class Create_StorageEntryPatch
{
[HarmonyPrefix]
private static void Create_StorageEntryPrefix(ItemStorageManager __instance, ItemData _itemData, ScriptableItem _scriptItem, int _index, int _slotNumber)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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)
switch (__instance._selectedStorageTab)
{
case 3:
if (_storageSizes_03[_scriptItem._itemType] < 48)
{
_storageSizes_03[_scriptItem._itemType]++;
}
break;
case 4:
if (_storageSizes_04[_scriptItem._itemType] < 48)
{
_storageSizes_04[_scriptItem._itemType]++;
}
break;
case 5:
if (_storageSizes_05[_scriptItem._itemType] < 48)
{
_storageSizes_05[_scriptItem._itemType]++;
}
break;
}
}
}
[HarmonyPatch(typeof(ItemStorageManager), "Delete_StorageEntry")]
public static class Delete_StorageEntryPatch
{
[HarmonyPrefix]
public static bool Delete_StorageEntryPrefix(ItemStorageManager __instance, ItemData _itemData)
{
//IL_006d: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
if (__instance._selectedStorageTab > 2)
{
ScriptableItem val = GameManager._current.LocateItem(_itemData._itemName);
if (!Object.op_Implicit((Object)(object)val))
{
return true;
}
switch (__instance._selectedStorageTab)
{
case 3:
_itemDatas_03.Remove(_itemData);
_storageSizes_03[val._itemType]--;
break;
case 4:
_itemDatas_04.Remove(_itemData);
_storageSizes_04[val._itemType]--;
break;
case 5:
_itemDatas_05.Remove(_itemData);
_storageSizes_05[val._itemType]--;
break;
}
for (int i = 0; i < __instance._storageListEntries.Count; i++)
{
if (__instance._storageListEntries[i]._itemData == _itemData)
{
Object.Destroy((Object)(object)((Component)__instance._storageListEntries[i]).gameObject);
__instance._storageListEntries.RemoveAt(i);
break;
}
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ItemStorageManager), "Update")]
public static class UpdatePatch
{
[HarmonyPrefix]
public static bool UpdatePrefix(ItemStorageManager __instance)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
((Selectable)_storageTabButton_03).interactable = __instance._selectedStorageTab != 3;
((Selectable)_storageTabButton_04).interactable = __instance._selectedStorageTab != 4;
((Selectable)_storageTabButton_05).interactable = __instance._selectedStorageTab != 5;
if (__instance._selectedStorageTab > 2)
{
__instance._isOpen = (int)DialogManager._current._currentDialogUIPrompt == 3;
MenuElement privateField = __instance.GetPrivateField<MenuElement>("_storageWindowElement");
((Component)privateField).gameObject.SetActive(__instance._isOpen);
privateField.isEnabled = __instance._isOpen;
if (__instance._isOpen)
{
switch (__instance._selectedStorageTab)
{
case 3:
__instance.GetPrivateField<Text>("_counter_gearItemSize").text = $"{_storageSizes_03[0]}/48";
__instance.GetPrivateField<Text>("_counter_consumableItemSize").text = $"{_storageSizes_03[1]}/48";
__instance.GetPrivateField<Text>("_counter_tradeItemSize").text = $"{_storageSizes_03[2]}/48";
break;
case 4:
__instance.GetPrivateField<Text>("_counter_gearItemSize").text = $"{_storageSizes_04[0]}/48";
__instance.GetPrivateField<Text>("_counter_consumableItemSize").text = $"{_storageSizes_04[1]}/48";
__instance.GetPrivateField<Text>("_counter_tradeItemSize").text = $"{_storageSizes_04[2]}/48";
break;
case 5:
__instance.GetPrivateField<Text>("_counter_gearItemSize").text = $"{_storageSizes_05[0]}/48";
__instance.GetPrivateField<Text>("_counter_consumableItemSize").text = $"{_storageSizes_05[1]}/48";
__instance.GetPrivateField<Text>("_counter_tradeItemSize").text = $"{_storageSizes_05[2]}/48";
break;
}
((Selectable)__instance.GetPrivateField<Button>("_storageTabButton_00")).interactable = true;
((Selectable)__instance.GetPrivateField<Button>("_storageTabButton_01")).interactable = true;
((Selectable)__instance.GetPrivateField<Button>("_storageTabButton_02")).interactable = true;
__instance.InvokePrivateMethod("Handle_TabVisibility");
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Load_ItemStorageData")]
public static class Load_ItemStorageDataPatch
{
[HarmonyPostfix]
private static void Load_ItemStorageDataPostfix(ProfileDataManager __instance)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
string privateField = __instance.GetPrivateField<string>("_dataPath");
_itemStorageProfile_03 = new ItemStorage_Profile();
_itemStorageProfile_03._heldItemStorage = Array.Empty<ItemData>();
_itemStorageProfile_04 = new ItemStorage_Profile();
_itemStorageProfile_04._heldItemStorage = Array.Empty<ItemData>();
_itemStorageProfile_05 = new ItemStorage_Profile();
_itemStorageProfile_05._heldItemStorage = Array.Empty<ItemData>();
if (File.Exists(privateField + "/atl_itemBank_03"))
{
ItemStorage_Profile itemStorageProfile_ = JsonUtility.FromJson<ItemStorage_Profile>(File.ReadAllText(privateField + "/atl_itemBank_03"));
_itemStorageProfile_03 = itemStorageProfile_;
}
if (File.Exists(privateField + "/atl_itemBank_04"))
{
ItemStorage_Profile itemStorageProfile_2 = JsonUtility.FromJson<ItemStorage_Profile>(File.ReadAllText(privateField + "/atl_itemBank_04"));
_itemStorageProfile_04 = itemStorageProfile_2;
}
if (File.Exists(privateField + "/atl_itemBank_05"))
{
ItemStorage_Profile itemStorageProfile_3 = JsonUtility.FromJson<ItemStorage_Profile>(File.ReadAllText(privateField + "/atl_itemBank_05"));
_itemStorageProfile_05 = itemStorageProfile_3;
}
ItemStorageManager current = ItemStorageManager._current;
if (Object.op_Implicit((Object)(object)current))
{
_storageSizes_03[0] = 0;
_storageSizes_03[1] = 0;
_storageSizes_03[2] = 0;
_storageSizes_04[0] = 0;
_storageSizes_04[1] = 0;
_storageSizes_04[2] = 0;
_storageSizes_05[0] = 0;
_storageSizes_05[1] = 0;
_storageSizes_05[2] = 0;
_itemDatas_03.Clear();
_itemDatas_04.Clear();
_itemDatas_05.Clear();
_itemDatas_03.AddRange(_itemStorageProfile_03._heldItemStorage);
_itemDatas_04.AddRange(_itemStorageProfile_04._heldItemStorage);
_itemDatas_05.AddRange(_itemStorageProfile_05._heldItemStorage);
}
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Save_ItemStorageData")]
public static class Save_ItemStorageDataPatch
{
[HarmonyPostfix]
private static void Save_ItemStorageDataPostfix(ProfileDataManager __instance)
{
string privateField = __instance.GetPrivateField<string>("_dataPath");
_itemStorageProfile_03._heldItemStorage = _itemDatas_03.ToArray();
_itemStorageProfile_04._heldItemStorage = _itemDatas_04.ToArray();
_itemStorageProfile_05._heldItemStorage = _itemDatas_05.ToArray();
string contents = JsonUtility.ToJson((object)_itemStorageProfile_03, true);
File.WriteAllText(privateField + "/atl_itemBank_03", contents);
string contents2 = JsonUtility.ToJson((object)_itemStorageProfile_04, true);
File.WriteAllText(privateField + "/atl_itemBank_04", contents2);
string contents3 = JsonUtility.ToJson((object)_itemStorageProfile_05, true);
File.WriteAllText(privateField + "/atl_itemBank_05", contents3);
}
}
[HarmonyPatch(typeof(ItemListDataEntry), "Init_PutItemIntoStorage")]
public static class Init_PutItemIntoStoragePatch
{
[HarmonyPrefix]
private static bool Init_PutItemIntoStoragePostfix(ItemListDataEntry __instance, int _setItemSlot)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (ItemStorageManager._current._selectedStorageTab > 2)
{
if ((int)__instance._entryType > 0)
{
return false;
}
bool flag = false;
switch (ItemStorageManager._current._selectedStorageTab)
{
case 3:
flag = _storageSizes_03[__instance._scriptableItem._itemType] >= 48;
break;
case 4:
flag = _storageSizes_04[__instance._scriptableItem._itemType] >= 48;
break;
case 5:
flag = _storageSizes_05[__instance._scriptableItem._itemType] >= 48;
break;
}
if (flag)
{
ErrorPromptTextManager.current.Init_ErrorPrompt("Storage Full");
__instance.Relocate_ToOriginSlot();
return false;
}
List<ItemListDataEntry> storageListEntries = ItemStorageManager._current._storageListEntries;
for (int i = 0; i < storageListEntries.Count; i++)
{
if (!Input.GetKey((KeyCode)304))
{
break;
}
if ((Object)(object)storageListEntries[i]._scriptableItem == (Object)(object)__instance._scriptableItem && storageListEntries[i]._itemData._quantity < storageListEntries[i]._itemData._maxQuantity && __instance._itemData._quantity + storageListEntries[i]._itemData._quantity <= storageListEntries[i]._itemData._maxQuantity)
{
ItemData itemData = storageListEntries[i]._itemData;
itemData._quantity += __instance._itemData._quantity;
Player._mainPlayer._pInventory.Remove_Item(__instance._itemData, 0);
__instance.InvokePrivateMethod("Init_SaveProfiles");
ProfileDataManager._current.Save_ItemStorageData();
return false;
}
}
ItemStorageManager._current._commandBuffer = 0.25f;
ItemStorageManager._current.Create_StorageEntry(__instance._itemData, __instance._scriptableItem, ItemStorageManager._current._storageListEntries.Count, _setItemSlot);
switch (ItemStorageManager._current._selectedStorageTab)
{
case 3:
_itemDatas_03.Add(__instance._itemData);
break;
case 4:
_itemDatas_04.Add(__instance._itemData);
break;
case 5:
_itemDatas_05.Add(__instance._itemData);
break;
}
Player._mainPlayer._pInventory.Remove_Item(__instance._itemData, 0);
__instance.InvokePrivateMethod("Init_SaveProfiles");
ProfileDataManager._current.Save_ItemStorageData();
return false;
}
return true;
}
}
internal static ManualLogSource Logger;
public static Button _storageTabButton_03;
public static Button _storageTabButton_04;
public static Button _storageTabButton_05;
public static List<ItemData> _itemDatas_03 = new List<ItemData>();
public static List<ItemData> _itemDatas_04 = new List<ItemData>();
public static List<ItemData> _itemDatas_05 = new List<ItemData>();
public static int[] _storageSizes_03 = new int[3];
public static int[] _storageSizes_04 = new int[3];
public static int[] _storageSizes_05 = new int[3];
public static ItemStorage_Profile _itemStorageProfile_03;
public static ItemStorage_Profile _itemStorageProfile_04;
public static ItemStorage_Profile _itemStorageProfile_05;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("MoreBankTabs").PatchAll();
Logger.LogInfo((object)"Plugin com.16mb.morebanktabs is loaded!");
}
}
}