using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FixedBankTabs;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreBankTabs;
using SnivysUI;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MoreBankTabs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreBankTabs")]
[assembly: AssemblyTitle("MoreBankTabs")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SnivysUI
{
public class LeftRightTextbox : MonoBehaviour
{
[SerializeField]
private Text textbox;
[SerializeField]
private Button leftButton;
[SerializeField]
private Button rightButton;
[SerializeField]
private RectTransform background;
public ButtonClickedEvent GetOnLeftClick()
{
return leftButton.onClick;
}
public ButtonClickedEvent GetOnRightClick()
{
return rightButton.onClick;
}
public void SetText(string text)
{
textbox.text = text;
}
public void SetWidth(float width)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
background.sizeDelta = new Vector2(width - 15.3043f, 27.952f);
((Component)leftButton).GetComponent<RectTransform>().anchoredPosition = new Vector2((0f - width) / 2f, 0f);
((Component)rightButton).GetComponent<RectTransform>().anchoredPosition = new Vector2(width / 2f, 0f);
}
}
}
namespace FixedBankTabs
{
public static class BankPatches
{
private class BankTabData
{
public List<ItemData> ItemDatas;
public int[] StorageSizes;
public ItemStorage_Profile ItemStorageProfile;
public BankTabData()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ItemDatas = new List<ItemData>();
StorageSizes = new int[3];
ItemStorageProfile = new ItemStorage_Profile();
}
}
private static int BASENUMOFBUTTONS = 3;
private static int MAXPAGES = 100;
private static Dictionary<int, BankTabData> BankTabs;
public static void init()
{
BankTabs = new Dictionary<int, BankTabData>();
}
private static void SetStorageTab(ItemStorageManager instance, int index)
{
if (index < 3)
{
if (index < 1)
{
instance.SetStorageTab_00();
}
else if (index < 2)
{
instance.SetStorageTab_01();
}
else
{
instance.SetStorageTab_02();
}
}
else
{
Plugin.Logger.LogInfo((object)("index is " + index));
instance._selectedStorageTab = index;
}
}
private static bool CheckOutOfBounds(int index)
{
if (index < BASENUMOFBUTTONS)
{
return true;
}
return false;
}
[HarmonyPatch(typeof(ItemStorageManager), "Awake")]
[HarmonyPostfix]
private static void StorageManagerAwakePatch(ItemStorageManager __instance)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Expected O, but got Unknown
Button[] array = (Button[])(object)new Button[BASENUMOFBUTTONS];
array[0] = __instance._storageTabButton_00;
array[1] = __instance._storageTabButton_01;
array[2] = __instance._storageTabButton_02;
GameObject val = Object.Instantiate<GameObject>(AssetHandler.FetchFromBundle<GameObject>("morebanktabs", "LeftRightTextbox"), ((Component)array[0]).transform.parent);
RectTransform component = val.GetComponent<RectTransform>();
LeftRightTextbox handler = val.GetComponent<LeftRightTextbox>();
val.transform.SetSiblingIndex(0);
((Component)__instance._storageTabHighlight).gameObject.SetActive(false);
component.anchoredPosition = new Vector2(0f, -150f);
Button[] array2 = array;
foreach (Button val2 in array2)
{
((Component)val2).gameObject.SetActive(false);
}
ButtonClickedEvent onLeftClick = handler.GetOnLeftClick();
ButtonClickedEvent onRightClick = handler.GetOnRightClick();
handler.SetText($"Page {__instance._selectedStorageTab + 1} / {MAXPAGES}");
((UnityEventBase)onLeftClick).RemoveAllListeners();
((UnityEventBase)onRightClick).RemoveAllListeners();
((UnityEvent)onLeftClick).AddListener((UnityAction)delegate
{
if (__instance._selectedStorageTab > 0)
{
SetStorageTab(__instance, __instance._selectedStorageTab - 1);
}
handler.SetText($"Page {__instance._selectedStorageTab + 1} / {MAXPAGES}");
});
((UnityEvent)onRightClick).AddListener((UnityAction)delegate
{
if (__instance._selectedStorageTab < MAXPAGES)
{
SetStorageTab(__instance, __instance._selectedStorageTab + 1);
}
handler.SetText($"Page {__instance._selectedStorageTab + 1} / {MAXPAGES}");
});
((UnityEvent)onLeftClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)onRightClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)onLeftClick).AddListener(new UnityAction(__instance.Init_StorageListing));
((UnityEvent)onRightClick).AddListener(new UnityAction(__instance.Init_StorageListing));
}
[HarmonyPatch(typeof(ItemStorageManager), "Begin_StorageListing")]
[HarmonyPrefix]
private static bool BeginStorageListingPatch(ItemStorageManager __instance)
{
if (CheckOutOfBounds(__instance._selectedStorageTab))
{
return true;
}
ItemData[] array = null;
array = BankTabs[__instance._selectedStorageTab].ItemDatas.ToArray();
for (int i = 0; i < array.Length; i++)
{
ItemData val = array[i];
ScriptableItem val2 = GameManager._current.Locate_Item(val._itemName);
if (val._quantity > 0 && Object.op_Implicit((Object)(object)val2))
{
__instance.Create_StorageEntry(val, val2, i, val._slotNumber);
}
}
return false;
}
[HarmonyPatch(typeof(ItemStorageManager), "Create_StorageEntry")]
[HarmonyPrefix]
private static bool CreateStorageEntryPatch(ItemStorageManager __instance, ItemData _itemData, ScriptableItem _scriptItem, int _index, int _slotNumber)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected I4, but got Unknown
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
if (CheckOutOfBounds(__instance._selectedStorageTab))
{
return true;
}
if (!Object.op_Implicit((Object)(object)GameManager._current.Locate_Item(_itemData._itemName)))
{
return false;
}
if (_itemData._modifierID > 0 && !Object.op_Implicit((Object)(object)GameManager._current.Locate_StatModifier(_itemData._modifierID)))
{
_itemData._modifierID = 0;
}
BankTabData bankTabData = BankTabs[__instance._selectedStorageTab];
if (bankTabData.StorageSizes[_scriptItem._itemType] >= 48)
{
return false;
}
bankTabData.StorageSizes[_scriptItem._itemType]++;
GameObject val = Object.Instantiate<GameObject>(__instance._storageEntryPrefab);
ItemListDataEntry component = val.GetComponent<ItemListDataEntry>();
ItemType itemType = _scriptItem._itemType;
ItemType val2 = itemType;
switch ((int)val2)
{
case 0:
val.transform.SetParent(__instance._gearTabContainer);
break;
case 1:
val.transform.SetParent(__instance._consumableTabContainer);
break;
case 2:
val.transform.SetParent(__instance._tradeItemTabContainer);
break;
}
((ListDataEntry)component)._dataID = _index;
component._itemData = _itemData;
component._scriptableItem = _scriptItem;
component._entryType = (ItemListEntryType)2;
((Component)component).transform.localScale = Vector3.one;
component._itemData._slotNumber = _slotNumber;
component._parentItemSlotUI = __instance._storageItemSlots[_slotNumber];
component.Apply_ItemDataInfo();
__instance._storageListEntries.Add(component);
return false;
}
[HarmonyPatch(typeof(ItemStorageManager), "Delete_StorageEntry")]
[HarmonyPrefix]
private static bool DeleteStorageEntryPatch(ItemStorageManager __instance, ItemData _itemData)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (CheckOutOfBounds(__instance._selectedStorageTab))
{
return true;
}
ScriptableItem val = GameManager._current.Locate_Item(_itemData._itemName);
if (!Object.op_Implicit((Object)(object)val))
{
return false;
}
BankTabData bankTabData = BankTabs[__instance._selectedStorageTab];
bankTabData.ItemDatas.Remove(_itemData);
bankTabData.StorageSizes[val._itemType]--;
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);
return false;
}
}
return false;
}
[HarmonyPatch(typeof(ItemStorageManager), "Update")]
[HarmonyPostfix]
private static void UpdatePatch(ItemStorageManager __instance)
{
if (__instance._isOpen)
{
if (!CheckOutOfBounds(__instance._selectedStorageTab) && BankTabs.ContainsKey(__instance._selectedStorageTab))
{
BankTabData bankTabData = BankTabs[__instance._selectedStorageTab];
__instance._counter_gearItemSize.text = $"{bankTabData.StorageSizes[0]}/48";
__instance._counter_consumableItemSize.text = $"{bankTabData.StorageSizes[1]}/48";
__instance._counter_tradeItemSize.text = $"{bankTabData.StorageSizes[2]}/48";
}
__instance.Handle_TabVisibility();
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Load_ItemStorageData")]
[HarmonyPostfix]
private static void LoadItemStorageDataPatch(ProfileDataManager __instance)
{
string[] files = Directory.GetFiles(__instance._dataPath, "atl_itemBank_*");
foreach (string path in files)
{
if (int.TryParse(Path.GetFileName(path).Substring(13), out var result) && result >= BASENUMOFBUTTONS)
{
BankTabs[result] = new BankTabData();
BankTabData bankTabData = BankTabs[result];
ItemStorage_Profile itemStorageProfile = JsonUtility.FromJson<ItemStorage_Profile>(File.ReadAllText(path));
bankTabData.ItemStorageProfile = itemStorageProfile;
bankTabData.ItemDatas = bankTabData.ItemStorageProfile._heldItemStorage.ToList();
}
}
if (Object.op_Implicit((Object)(object)ItemStorageManager._current))
{
ItemStorageManager current = ItemStorageManager._current;
if (!CheckOutOfBounds(current._selectedStorageTab) && !BankTabs.ContainsKey(current._selectedStorageTab))
{
BankTabs[current._selectedStorageTab] = new BankTabData();
}
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Save_ItemStorageData")]
[HarmonyPostfix]
private static void SaveItemStorageDataPatch(ProfileDataManager __instance)
{
foreach (KeyValuePair<int, BankTabData> bankTab in BankTabs)
{
string path = Path.Combine(__instance._dataPath, "atl_itemBank_" + bankTab.Key.ToString("00"));
BankTabData value = bankTab.Value;
value.ItemStorageProfile._heldItemStorage = value.ItemDatas.ToArray();
if (value.ItemStorageProfile._heldItemStorage.Length == 0)
{
if (File.Exists(path))
{
File.Delete(path);
}
}
else
{
string contents = JsonUtility.ToJson((object)value.ItemStorageProfile, true);
File.WriteAllText(path, contents);
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemListDataEntry), "Init_PutItemIntoStorage")]
private static bool PutItemIntoStoragePatch(ItemListDataEntry __instance, int _setItemSlot)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
ItemStorageManager current = ItemStorageManager._current;
if (CheckOutOfBounds(current._selectedStorageTab))
{
return true;
}
if ((int)__instance._entryType > 0)
{
return false;
}
BankTabData bankTabData = BankTabs[current._selectedStorageTab];
if (bankTabData.StorageSizes[__instance._scriptableItem._itemType] >= 48)
{
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.Init_SaveProfiles();
ProfileDataManager._current.Save_ItemStorageData();
return false;
}
}
current._commandBuffer = 0.25f;
current.Create_StorageEntry(__instance._itemData, __instance._scriptableItem, ItemStorageManager._current._storageListEntries.Count, _setItemSlot);
bankTabData.ItemDatas.Add(__instance._itemData);
Player._mainPlayer._pInventory.Remove_Item(__instance._itemData, 0);
__instance.Init_SaveProfiles();
ProfileDataManager._current.Save_ItemStorageData();
return false;
}
}
[BepInPlugin("MoreBankTabs", "MoreBankTabs", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private Harmony patcher;
private void Awake()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin MoreBankTabs is loaded!");
Logger.LogInfo((object)"Patching functions...");
patcher = new Harmony("FixedMoreBankTabs");
patcher.PatchAll(typeof(BankPatches));
Logger.LogInfo((object)"Done!");
Logger.LogInfo((object)"Registering Assets...");
AssetHandler.GetAssetBundle("morebanktabs");
Logger.LogInfo((object)"Initializing Extra Data...");
BankPatches.init();
Logger.LogInfo((object)"Setup Complete!");
}
}
}
namespace MoreBankTabs
{
public static class AssetHandler
{
public static Dictionary<string, AssetBundle> bundles = new Dictionary<string, AssetBundle>();
public static void GetAssetBundle(string bundlename)
{
Plugin.Logger.LogInfo((object)("Loading bundle: " + bundlename));
AssetBundle value = AssetBundle.LoadFromFile(Path.Combine(Utilities.path, bundlename));
bundles.Add(bundlename, value);
Plugin.Logger.LogInfo((object)("Bundle " + bundlename + " Loaded!"));
}
public static T FetchFromBundle<T>(string bundle, string key) where T : Object
{
return bundles[bundle].LoadAsset<T>(key);
}
}
public static class Utilities
{
public static string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static string pluginsFolder = Paths.PluginPath;
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MoreBankTabs";
public const string PLUGIN_NAME = "MoreBankTabs";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}