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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreBankTabsFixed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Fixed Bank Tabs")]
[assembly: AssemblyTitle("MoreBankTabsFixed")]
[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 MyFirstPlugin
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MoreBankTabsFixed";
public const string PLUGIN_NAME = "Fixed Bank Tabs";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace FixedBankTabs
{
public static class BankPatches
{
private static int BASENUMOFBUTTONS = 3;
public static int EXTRANUMOFTABS = 6;
private static Button[] newButtons;
private static List<ItemData>[] newItemDatas;
private static int[][] newStorageSizes;
private static ItemStorage_Profile[] newItemStorageProfiles;
public static void init()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
newButtons = (Button[])(object)new Button[EXTRANUMOFTABS];
newItemDatas = new List<ItemData>[EXTRANUMOFTABS];
newStorageSizes = new int[EXTRANUMOFTABS][];
newItemStorageProfiles = (ItemStorage_Profile[])(object)new ItemStorage_Profile[EXTRANUMOFTABS];
for (int i = 0; i < EXTRANUMOFTABS; i++)
{
newStorageSizes[i] = new int[3];
newItemDatas[i] = new List<ItemData>();
newItemStorageProfiles[i] = new ItemStorage_Profile();
newItemStorageProfiles[i]._heldItemStorage = (ItemData[])(object)new ItemData[0];
}
}
private static void SetStorageTab(ItemStorageManager instance, int index)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
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;
((Component)instance._storageTabHighlight).transform.position = ((Component)newButtons[index - BASENUMOFBUTTONS]).transform.GetChild(0).position;
}
}
private static bool CheckOutOfBounds(int index)
{
if (index < BASENUMOFBUTTONS || index >= BASENUMOFBUTTONS + EXTRANUMOFTABS)
{
return true;
}
return false;
}
[HarmonyPatch(typeof(ItemStorageManager), "Awake")]
[HarmonyPostfix]
private static void StorageManagerAwakePatch(ItemStorageManager __instance)
{
//IL_0060: 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_00c5: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Expected O, but got Unknown
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: 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;
RectTransform component = ((Component)array[0]).GetComponent<RectTransform>();
RectTransform component2 = ((Component)array[1]).GetComponent<RectTransform>();
RectTransform component3 = ((Component)array[2]).GetComponent<RectTransform>();
float num = component2.anchoredPosition.x - component.anchoredPosition.x;
int num2 = ((Component)array[^1]).transform.GetSiblingIndex();
for (int i = 0; i < EXTRANUMOFTABS; i++)
{
Button val = array[i % 3];
GameObject gameObject = ((Component)val).gameObject;
newButtons[i] = Object.Instantiate<GameObject>(gameObject, ((Component)array[2]).transform.position, gameObject.transform.rotation, gameObject.transform.parent).GetComponent<Button>();
RectTransform component4 = ((Component)newButtons[i]).GetComponent<RectTransform>();
component4.anchoredPosition = component3.anchoredPosition + new Vector2(num * (float)(i + 1), 0f);
Button val2 = newButtons[i];
((Component)val2).transform.SetSiblingIndex(num2 + 1);
num2++;
Image componentInChildren = ((Component)val2).GetComponentInChildren<Image>();
((Graphic)componentInChildren).color = ((Graphic)componentInChildren).color + new Color(0.35f, 0f, 0.1f);
ButtonClickedEvent onClick = val2.onClick;
((UnityEventBase)onClick).RemoveAllListeners();
int index = i + BASENUMOFBUTTONS;
((UnityEvent)onClick).AddListener((UnityAction)delegate
{
SetStorageTab(__instance, index);
});
((UnityEvent)onClick).AddListener(new UnityAction(__instance.Clear_StorageEntries));
((UnityEvent)onClick).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 = newItemDatas[__instance._selectedStorageTab - BASENUMOFBUTTONS].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_0088: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00ed: Expected I4, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
if (CheckOutOfBounds(__instance._selectedStorageTab))
{
return true;
}
int num = __instance._selectedStorageTab - BASENUMOFBUTTONS;
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;
}
if (newStorageSizes[num][_scriptItem._itemType] >= 48)
{
return false;
}
newStorageSizes[num][_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_0063: Unknown result type (might be due to invalid IL or missing references)
if (CheckOutOfBounds(__instance._selectedStorageTab))
{
return true;
}
int num = __instance._selectedStorageTab - BASENUMOFBUTTONS;
ScriptableItem val = GameManager._current.Locate_Item(_itemData._itemName);
if (!Object.op_Implicit((Object)(object)val))
{
return false;
}
newItemDatas[num].Remove(_itemData);
newStorageSizes[num][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)
{
int num = __instance._selectedStorageTab - BASENUMOFBUTTONS;
if (__instance._isOpen)
{
if (!CheckOutOfBounds(__instance._selectedStorageTab))
{
__instance._counter_gearItemSize.text = $"{newStorageSizes[num][0]}/48";
__instance._counter_consumableItemSize.text = $"{newStorageSizes[num][1]}/48";
__instance._counter_tradeItemSize.text = $"{newStorageSizes[num][2]}/48";
}
for (int i = 0; i < EXTRANUMOFTABS; i++)
{
((Selectable)newButtons[i]).interactable = __instance._selectedStorageTab - BASENUMOFBUTTONS != i;
}
__instance.Handle_TabVisibility();
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Load_ItemStorageData")]
[HarmonyPostfix]
private static void LoadItemStorageDataPatch(ProfileDataManager __instance)
{
for (int i = 0; i < EXTRANUMOFTABS; i++)
{
string path = Path.Combine(__instance._dataPath, "atl_itemBank_" + (i + BASENUMOFBUTTONS).ToString("00"));
if (File.Exists(path))
{
ItemStorage_Profile val = JsonUtility.FromJson<ItemStorage_Profile>(File.ReadAllText(path));
newItemStorageProfiles[i] = val;
}
}
ItemStorageManager current = ItemStorageManager._current;
if (Object.op_Implicit((Object)(object)current))
{
for (int j = 0; j < EXTRANUMOFTABS; j++)
{
newStorageSizes[j][0] = 0;
newStorageSizes[j][1] = 0;
newStorageSizes[j][2] = 0;
newItemDatas[j].Clear();
newItemDatas[j].AddRange(newItemStorageProfiles[j]._heldItemStorage);
}
}
}
[HarmonyPatch(typeof(ProfileDataManager), "Save_ItemStorageData")]
[HarmonyPostfix]
private static void SaveItemStorageDataPatch(ProfileDataManager __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
for (int i = 0; i < EXTRANUMOFTABS; i++)
{
string path = Path.Combine(__instance._dataPath, "atl_itemBank_" + (i + BASENUMOFBUTTONS).ToString("00"));
if (!File.Exists(path))
{
newItemStorageProfiles[i] = new ItemStorage_Profile();
}
newItemStorageProfiles[i]._heldItemStorage = newItemDatas[i].ToArray();
string contents = JsonUtility.ToJson((object)newItemStorageProfiles[i], true);
File.WriteAllText(path, contents);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemListDataEntry), "Init_PutItemIntoStorage")]
private static bool PutItemIntoStoragePatch(ItemListDataEntry __instance, int _setItemSlot)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
ItemStorageManager current = ItemStorageManager._current;
if (CheckOutOfBounds(current._selectedStorageTab))
{
return true;
}
int num = current._selectedStorageTab - BASENUMOFBUTTONS;
if ((int)__instance._entryType > 0)
{
return false;
}
if (newStorageSizes[num][__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);
newItemDatas[num].Add(__instance._itemData);
Player._mainPlayer._pInventory.Remove_Item(__instance._itemData, 0);
__instance.Init_SaveProfiles();
ProfileDataManager._current.Save_ItemStorageData();
return false;
}
}
[BepInPlugin("MoreBankTabsFixed", "Fixed Bank Tabs", "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 MoreBankTabsFixed is loaded!");
Logger.LogInfo((object)"Patching functions...");
patcher = new Harmony("FixedMoreBankTabs");
patcher.PatchAll(typeof(BankPatches));
Logger.LogInfo((object)"Done!");
Logger.LogInfo((object)"Initializing Extra Data...");
BankPatches.init();
Logger.LogInfo((object)"Setup Complete!");
}
}
}