Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CurrencyPocket v1.0.12
CurrencyPocket.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CurrencyPocket.Compatibility; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("CurrencyPocket")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("CurrencyPocket")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.0.12")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.12.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace CurrencyPocket { public class CurrencyPocket { [HarmonyPatch(typeof(InventoryGui), "Awake")] public static class InventoryGuiUpdatePatch { public static Button ExtractButton; public static GameObject pocketUI; public static Sprite coinSprite; [HarmonyAfter(new string[] { "org.bepinex.plugins.jewelcrafting" })] private static void Postfix(InventoryGui __instance) { if ((Object)(object)pocketUI == (Object)null) { CreatePocketUI(__instance); } if ((Object)(object)ExtractButton == (Object)null && (Object)(object)pocketUI != (Object)null) { CreateButton(__instance); } } } [HarmonyPatch(typeof(InventoryGui), "Show")] private static class InventoryGuiShowPatch { private static GameObject? cached; private static Coroutine? coroutine; private static void Prefix() { UpdatePocketUI(); } [HarmonyPriority(100)] private static void Postfix(InventoryGui __instance) { InventoryGui __instance2 = __instance; if (Object.op_Implicit((Object)(object)cached)) { if (coroutine != null) { ((MonoBehaviour)__instance2).StopCoroutine(coroutine); } } else { cached = ((Component)__instance2).gameObject; coroutine = ((MonoBehaviour)__instance2).StartCoroutine(WaitOneFrame()); } IEnumerator WaitOneFrame() { yield return null; Transform transform = ((Component)__instance2.m_player).transform; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); bool flag; switch (((Object)child).name) { case "Armor": case "Weight": case "Jewelcrafting Synergy": case "CoinPocketUI": case "Trash": flag = true; break; default: flag = false; break; } if (flag) { RectTransform component = ((Component)child).gameObject.GetComponent<RectTransform>(); if (Object.op_Implicit((Object)(object)component)) { string name = ((Object)child).name; if (!(name == "CoinPocketUI")) { if (name == "Weight" && !MiscFunctions.IsOverlappingUIModInstalled()) { continue; } } else if (!MiscFunctions.IsOverlappingUIModInstalled()) { component.anchoredPosition += new Vector2(0f, -45f); continue; } component.anchoredPosition += new Vector2(0f, 45f); } } } } } } [HarmonyPatch(typeof(StoreGui), "GetPlayerCoins")] private static class StoreGuiGetPlayerCoinsPatch { private static void Postfix(StoreGui __instance, ref int __result) { __result += MiscFunctions.GetPlayerCoinsFromCustomData(); } } [HarmonyPatch(typeof(Humanoid), "Pickup")] private static class AddItemToInventory { [HarmonyPriority(300)] private static bool Prefix(Humanoid __instance, GameObject go, bool autoPickupDelay, bool __runOriginal, ref bool __result) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (__runOriginal) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { ItemDrop component = go.GetComponent<ItemDrop>(); if (component != null && !((Character)val).IsTeleporting() && component.CanPickup(autoPickupDelay) && component.m_nview.GetZDO() != null) { ItemData itemData = component.m_itemData; if (itemData.m_dropPrefab == null) { itemData.m_dropPrefab = ObjectDB.instance.GetItemPrefab(Utils.GetPrefabName(((Component)component).gameObject)); } string name = component.m_itemData.m_shared.m_name; int stack = component.m_itemData.m_stack; CheckAutoPickupActive.PickingUp = false; if (name == "$item_coins") { MiscFunctions.UpdatePlayerCustomData(MiscFunctions.GetPlayerCoinsFromCustomData() + stack); UpdatePocketUI(); ZNetScene.instance.Destroy(go); ((Humanoid)val).m_pickupEffects.Create(((Component)val).transform.position, Quaternion.identity, (Transform)null, 1f, -1); ((Character)val).ShowPickupMessage(component.m_itemData, stack); __result = true; return false; } return true; } } } return true; } } [HarmonyPatch(typeof(Player), "AutoPickup")] private static class CheckAutoPickupActive { public static bool PickingUp; private static void Prefix() { PickingUp = true; } private static void Finalizer() { PickingUp = false; } } [HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[] { typeof(ItemData), typeof(int) })] private static class AutoPickupItemsWithFullInventory { private static void Postfix(Inventory __instance, ItemData item, ref bool __result) { if (!__result && CheckAutoPickupActive.PickingUp && item?.m_shared?.m_name == "$item_coins") { __result = true; } } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(string), typeof(int), typeof(int), typeof(bool) })] public static class Inventory_RemoveItem_Patch { public static void Postfix(Inventory __instance, string name, int amount, int itemQuality, bool worldLevelBased) { if (!((Object)(object)Player.m_localPlayer == (Object)null) && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { int playerCoinsFromCustomData = MiscFunctions.GetPlayerCoinsFromCustomData(); if (name == "$item_coins" && MiscFunctions.GetPlayerCoinsFromCustomData() >= amount) { playerCoinsFromCustomData -= amount; MiscFunctions.UpdatePlayerCustomData(playerCoinsFromCustomData); UpdatePocketUI(); } } } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData), typeof(int), typeof(int), typeof(int) })] private static class InventoryMoveItemToThisPatch { private static bool Prefix(Inventory __instance, Inventory fromInventory, ItemData item, int amount, int x, int y, ref bool __result) { Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return true; } if (item?.m_shared?.m_name != "$item_coins" || __instance != ((Humanoid)localPlayer).GetInventory()) { return true; } ItemData itemAt = __instance.GetItemAt(x, y); if (itemAt != null) { SharedData shared = itemAt.m_shared; if (shared != null && shared.m_name == "$item_coins") { int maxStackSize = itemAt.m_shared.m_maxStackSize; int num = Math.Min(Math.Min(Math.Max(0, maxStackSize - itemAt.m_stack), amount), item.m_stack); if (num > 0) { itemAt.m_stack += num; item.m_stack -= num; if (item.m_stack <= 0 && fromInventory != null) { fromInventory.RemoveItem(item); } __instance.Changed(); if (fromInventory != null) { fromInventory.Changed(); } __result = true; return false; } __result = false; return false; } } int stack = item.m_stack; bool flag = __instance.AddItem(item, amount, x, y); if (Math.Max(0, stack - item.m_stack) > 0) { if (item.m_stack <= 0 && fromInventory != null) { fromInventory.RemoveItem(item); } if (fromInventory != null) { fromInventory.Changed(); } __instance.Changed(); } __result = flag; return false; } } internal static bool CoinExtractionInProgress; internal static void UpdatePocketUI() { if ((Object)(object)InventoryGuiUpdatePatch.pocketUI == (Object)null) { return; } Transform val = Utils.FindChild(InventoryGuiUpdatePatch.pocketUI.transform, "ac_text", (IterativeSearchType)0); if (!((Object)(object)val == (Object)null)) { TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>(); if (!((Object)(object)component == (Object)null)) { ((TMP_Text)component).text = $"{MiscFunctions.GetPlayerCoinsFromCustomData()}"; } } } private static void CreatePocketUI(InventoryGui instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)instance.m_player).transform; InventoryGuiUpdatePatch.pocketUI = Object.Instantiate<GameObject>(((Component)transform.Find("Armor")).gameObject, transform); ((Object)InventoryGuiUpdatePatch.pocketUI).name = "CoinPocketUI"; RectTransform component = InventoryGuiUpdatePatch.pocketUI.GetComponent<RectTransform>(); CurrencyPocketPlugin.CurrencyPocketLogger.LogDebug((object)$"Creating pocket UI at {component.anchoredPosition}"); if (MiscFunctions.IsOverlappingUIModInstalled()) { component.anchoredPosition += new Vector2(0f, -234f); } else { RectTransform component2 = ((Component)transform.Find("Armor")).GetComponent<RectTransform>(); RectTransform component3 = ((Component)transform.Find("Weight")).GetComponent<RectTransform>(); InventoryGuiUpdatePatch.pocketUI.transform.SetSiblingIndex(transform.Find("Armor").GetSiblingIndex()); component.anchoredPosition = new Vector2(component2.anchoredPosition.x, (component2.anchoredPosition.y + component3.anchoredPosition.y) / 2f); } CurrencyPocketPlugin.CurrencyPocketLogger.LogDebug((object)$"Creating pocket UI at {component.anchoredPosition}"); InventoryGuiUpdatePatch.coinSprite = ObjectDB.instance.GetItemPrefab("Coins").GetComponent<ItemDrop>().m_itemData.GetIcon(); ((Component)InventoryGuiUpdatePatch.pocketUI.transform.Find("armor_icon")).GetComponent<Image>().sprite = InventoryGuiUpdatePatch.coinSprite; InventoryGuiUpdatePatch.pocketUI.transform.SetSiblingIndex(transform.Find("Armor").GetSiblingIndex()); ((TMP_Text)((Component)InventoryGuiUpdatePatch.pocketUI.transform.Find("ac_text")).GetComponent<TextMeshProUGUI>()).text = $"{MiscFunctions.GetPlayerCoinsFromCustomData()}"; InventoryGuiUpdatePatch.pocketUI.AddComponent<PocketDrop>(); } private static void CreateButton(InventoryGui __instance) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)InventoryGuiUpdatePatch.ExtractButton != (Object)null)) { InventoryGuiUpdatePatch.ExtractButton = Object.Instantiate<Button>(__instance.m_takeAllButton, InventoryGuiUpdatePatch.pocketUI.transform); ((Object)InventoryGuiUpdatePatch.ExtractButton).name = "ExtractCoinsButton"; ((TMP_Text)((Component)InventoryGuiUpdatePatch.ExtractButton).GetComponentInChildren<TextMeshProUGUI>()).text = "\ud83d\udce6"; ((Component)InventoryGuiUpdatePatch.ExtractButton).transform.SetParent(InventoryGuiUpdatePatch.pocketUI.transform, false); InventoryGuiUpdatePatch.ExtractButton.onClick = new ButtonClickedEvent(); ((UnityEvent)InventoryGuiUpdatePatch.ExtractButton.onClick).AddListener(new UnityAction(MiscFunctions.ExtractCoins)); UIGamePad component = ((Component)InventoryGuiUpdatePatch.ExtractButton).GetComponent<UIGamePad>(); if (Object.op_Implicit((Object)(object)component.m_hint)) { Object.Destroy((Object)(object)component.m_hint); } component.m_hint = null; component.m_zinputKey = string.Empty; component.m_keyCode = (KeyCode)0; RectTransform val = ((Component)InventoryGuiUpdatePatch.ExtractButton).GetComponent<RectTransform>(); if ((Object)(object)val == (Object)null) { val = ((Component)InventoryGuiUpdatePatch.ExtractButton).gameObject.AddComponent<RectTransform>(); } ((Transform)val).localPosition = new Vector3(2.5f, -20f, 0f); ((Component)InventoryGuiUpdatePatch.ExtractButton).transform.localScale = new Vector3(0.4f, 0.4f, 1f); } } private static void CreateIcon() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Sprite icon = ObjectDB.instance.GetItemPrefab("Coins").GetComponent<ItemDrop>().m_itemData.GetIcon(); GameObject val = new GameObject("CoinIcon"); val.transform.SetParent(InventoryGuiUpdatePatch.pocketUI.transform, false); Image obj = val.AddComponent<Image>(); obj.sprite = icon; obj.preserveAspect = true; } } [HarmonyPatch(typeof(InventoryGui), "OnSplitOk")] internal static class InventoryGuiOnSplitOkPatch { internal static Inventory throwAwayInventory; internal static void Prefix(InventoryGui __instance) { if (!(__instance.m_splitItem?.m_shared.m_name != "$item_coins") && CurrencyPocket.CoinExtractionInProgress) { __instance.m_splitInventory = throwAwayInventory; MiscFunctions.UpdatePlayerCustomData(MiscFunctions.GetPlayerCoinsFromCustomData() - (int)__instance.m_splitSlider.value); CurrencyPocket.UpdatePocketUI(); CurrencyPocket.CoinExtractionInProgress = false; } } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] internal static class PreventSetupDrag { private static bool Prefix(InventoryGui __instance) { if (Object.op_Implicit((Object)(object)__instance.m_currentContainer) && __instance.m_currentContainer.IsOwner()) { return true; } Inventory dragInventory = __instance.m_dragInventory; return dragInventory == null || !(dragInventory.m_name == "CoinPocket_CoinCount"); } } public class MiscFunctions { public static string GetPrefabName(string name) { char[] anyOf = new char[2] { '(', ' ' }; int num = name.IndexOfAny(anyOf); if (num >= 0) { return name.Substring(0, num); } return name; } internal static GameObject? GetItemPrefabFromGameObject(ItemDrop itemDropComponent, GameObject inputGameObject) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(GetPrefabName(((Object)inputGameObject).name)); itemDropComponent.m_itemData.m_dropPrefab = itemPrefab; if (!((Object)(object)itemPrefab != (Object)null)) { return null; } return itemPrefab; } internal static bool CheckItemDropIntegrity(ItemDrop itemDropComp) { return itemDropComp.m_itemData?.m_shared != null; } internal static void ProcessRequirements(Requirement[] requirements, int qualityLevel, Player instance, int itemQuality) { foreach (Requirement val in requirements) { if (IsValidRequirement(val)) { int amount = val.GetAmount(qualityLevel); if (amount > 0 && val.m_resItem.m_itemData.m_shared.m_name == "$item_coins") { string value; int num = (instance.m_customData.TryGetValue("CoinPocket_CoinCount", out value) ? int.Parse(value) : 0); UpdatePlayerCustomData(num - Math.Min(num, amount), instance); CurrencyPocket.UpdatePocketUI(); } } } } private static bool IsValidRequirement(Requirement requirement) { if (Object.op_Implicit((Object)(object)requirement.m_resItem)) { ItemData itemData = requirement.m_resItem.m_itemData; if (itemData != null) { return itemData.m_shared != null; } return false; } return false; } internal static void UpdatePlayerCustomData(int coinCount, Player? player = null) { coinCount = Math.Max(0, coinCount); if ((Object)(object)player == (Object)null) { player = Player.m_localPlayer; } if ((Object)(object)player != (Object)null) { player.m_customData["CoinPocket_CoinCount"] = coinCount.ToString(); } } internal static int GetPlayerCoinsFromCustomData() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && localPlayer.m_customData.TryGetValue("CoinPocket_CoinCount", out var value)) { return int.Parse(value); } return 0; } internal static void ExtractCoins() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if ((Object)(object)Player.m_localPlayer != (Object)null && GetPlayerCoinsFromCustomData() > 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Coins"); InventoryGuiOnSplitOkPatch.throwAwayInventory = new Inventory("CoinPocket_CoinCount", itemPrefab.GetComponent<ItemDrop>().m_itemData.GetIcon(), 1, 1); InventoryGuiOnSplitOkPatch.throwAwayInventory.AddItem(itemPrefab, GetPlayerCoinsFromCustomData()); InventoryGui.instance.ShowSplitDialog(InventoryGuiOnSplitOkPatch.throwAwayInventory.m_inventory.FirstOrDefault(), InventoryGuiOnSplitOkPatch.throwAwayInventory); CurrencyPocket.CoinExtractionInProgress = true; } } internal static bool IsOverlappingUIModInstalled() { Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos; if (!pluginInfos.ContainsKey("goldenrevolver.quick_stack_store")) { return pluginInfos.ContainsKey("org.bepinex.plugins.jewelcrafting"); } return true; } } [BepInPlugin("Azumatt.CurrencyPocket", "CurrencyPocket", "1.0.12")] public class CurrencyPocketPlugin : BaseUnityPlugin { internal const string ModName = "CurrencyPocket"; internal const string ModVersion = "1.0.12"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.CurrencyPocket"; internal readonly Harmony _harmony = new Harmony("Azumatt.CurrencyPocket"); public static readonly ManualLogSource CurrencyPocketLogger = Logger.CreateLogSource("CurrencyPocket"); internal static Sprite DownloadSprite = null; public static CurrencyPocketPlugin instance = null; public void Awake() { instance = this; Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); DownloadSprite = loadSprite("download.png"); } public void Start() { RapidLoadoutsCompat.Init(); ExtraSlotsCompat.FuckOff(); } private static byte[] ReadEmbeddedFileBytes(string name) { using MemoryStream memoryStream = new MemoryStream(); Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream); return memoryStream.ToArray(); } private static Texture2D loadTexture(string name) { //IL_0002: 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_001d: Expected O, but got Unknown //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(0, 0); ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("assets." + name)); return val; } internal static Sprite loadSprite(string name) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Texture2D val = loadTexture(name); if (!((Object)(object)val != (Object)null)) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Constants { public const string CoinPocketUIName = "CoinPocketUI"; public const string ExtractCoinsButtonName = "ExtractCoinsButton"; public const string ArmorName = "Armor"; public const string WeightName = "Weight"; public const string JewelcraftingSynergyName = "Jewelcrafting Synergy"; public const string TrashButtonName = "Trash"; public const string FavoritingToggleButton = "favoritingTogglingButton"; public const string QuickStackAreaButton = "quickStackAreaButton"; public const string RestockAreaButton = "restockAreaButton"; public const string SortInventoryButton = "sortInventoryButton"; internal const string CoinCountCustomData = "CoinPocket_CoinCount"; internal const string CoinIconName = "CoinIcon"; internal const string CoinToken = "$item_coins"; internal const string CoinsPrefabName = "Coins"; internal const string AcText = "ac_text"; internal const string ArmorIconName = "armor_icon"; internal const string RandyQuickslots = "randyknapp.mods.equipmentandquickslots"; internal const string AzuEPIGUID = "Azumatt.AzuExtendedPlayerInventory"; internal const string QuickStackStoreGUID = "goldenrevolver.quick_stack_store"; internal const string JewelcraftingGUID = "org.bepinex.plugins.jewelcrafting"; internal const string RapidLoadoutsGUID = "Azumatt.RapidLoadouts"; internal const string ExtraSlotsGuid = "shudnal.ExtraSlots"; internal const string EsSectionName = "Mods compatibility - Reduced inventory size"; } public class PocketDrop : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { private UITooltip? uiTooltip; private GameObject m_tooltipPrefab; internal static bool clicked; internal static Image armorImage; private void Awake() { TryCreateTooltip(); armorImage = ((Component)((Component)this).transform.Find("armor_icon")).GetComponent<Image>(); } private void Update() { if (!Object.op_Implicit((Object)(object)InventoryGui.m_instance) || !Object.op_Implicit((Object)(object)InventoryGui.m_instance.m_dragGo) || InventoryGui.m_instance.m_dragItem == null || InventoryGui.m_instance.m_dragItem.m_shared.m_name != "$item_coins") { if ((Object)(object)armorImage != (Object)null && (Object)(object)armorImage.sprite != (Object)(object)CurrencyPocket.InventoryGuiUpdatePatch.coinSprite) { armorImage.sprite = CurrencyPocket.InventoryGuiUpdatePatch.coinSprite; } } else { armorImage.sprite = CurrencyPocketPlugin.DownloadSprite; } } public void OnPointerEnter(PointerEventData eventData) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) TryCreateTooltip(); if (Object.op_Implicit((Object)(object)InventoryGui.m_instance) && !((Object)(object)uiTooltip == (Object)null) && Object.op_Implicit((Object)(object)InventoryGui.m_instance.m_dragGo) && InventoryGui.m_instance.m_dragItem != null) { uiTooltip.Set("Coin Drop", "Click here to store coins in your pocket.", (RectTransform)null, default(Vector2)); uiTooltip.OnHoverStart(((Component)this).gameObject); } } public void OnPointerExit(PointerEventData eventData) { if ((Object)(object)uiTooltip != (Object)null) { UITooltip.HideTooltip(); } } public void OnPointerClick(PointerEventData eventData) { if (Object.op_Implicit((Object)(object)InventoryGui.m_instance) && Object.op_Implicit((Object)(object)InventoryGui.m_instance.m_dragGo) && InventoryGui.m_instance.m_dragItem != null && (!(InventoryGui.m_instance.m_dragItem.m_shared.m_name != "$item_coins") || InventoryGui.m_instance.m_dragItem.m_shared.m_value > 0) && InventoryGui.m_instance.m_dragInventory != null) { bool num = InventoryGui.m_instance.m_dragItem.m_shared.m_value > 0 && InventoryGui.m_instance.m_dragItem.m_shared.m_name != "$item_coins"; clicked = true; if (!num) { MiscFunctions.UpdatePlayerCustomData(MiscFunctions.GetPlayerCoinsFromCustomData() + InventoryGui.m_instance.m_dragAmount); } else { MiscFunctions.UpdatePlayerCustomData(MiscFunctions.GetPlayerCoinsFromCustomData() + InventoryGui.m_instance.m_dragAmount * InventoryGui.m_instance.m_dragItem.m_shared.m_value); } CurrencyPocket.UpdatePocketUI(); if (InventoryGui.m_instance.m_dragAmount == InventoryGui.m_instance.m_dragItem.m_stack) { InventoryGui.m_instance.m_dragInventory.RemoveItem(InventoryGui.m_instance.m_dragItem); } else { InventoryGui.m_instance.m_dragInventory.RemoveItem(InventoryGui.m_instance.m_dragItem, InventoryGui.m_instance.m_dragAmount); } clicked = false; InventoryGui.m_instance.SetupDragItem((ItemData)null, (Inventory)null, 1); InventoryGuiOnSplitOkPatch.throwAwayInventory = null; } } private void TryCreateTooltip() { uiTooltip = ((Component)this).GetComponent<UITooltip>(); if (!((Object)(object)uiTooltip != (Object)null) && !((Object)(object)InventoryGui.instance.m_playerGrid == (Object)null)) { Element? obj = InventoryGui.instance.m_playerGrid.m_elements.FirstOrDefault(); uiTooltip = ((obj != null) ? ((Component)obj.m_tooltip).GetComponent<UITooltip>() : null); m_tooltipPrefab = InventoryGui.instance.m_playerGrid.m_elements.FirstOrDefault()?.m_tooltip.m_tooltipPrefab; } } } } namespace CurrencyPocket.Compatibility { internal static class ExtraSlotsCompat { private static bool _handlingChange; public static void FuckOff() { if (Chainloader.PluginInfos.TryGetValue("shudnal.ExtraSlots", out var value)) { ConfigFile config = value.Instance.Config; if (false | AttachSanitizer(config, "Panels to show with 1 row", 1) | AttachSanitizer(config, "Panels to show with 2 rows", 2) | AttachSanitizer(config, "Panels to show with 3 rows", 3)) { config.Save(); } } } private static bool AttachSanitizer(ConfigFile cfg, string key, int? maxAllowedItems) { ConfigEntry<string> entry = default(ConfigEntry<string>); if (!cfg.TryGetEntry<string>("Mods compatibility - Reduced inventory size", key, ref entry)) { return false; } bool result = SanitizeEntry(entry, maxAllowedItems); entry.SettingChanged += delegate { if (_handlingChange) { return; } try { _handlingChange = true; SanitizeEntry(entry, maxAllowedItems); } finally { _handlingChange = false; } }; return result; } private static bool SanitizeEntry(ConfigEntry<string> entry, int? maxAllowedItems) { string text = entry.Value ?? string.Empty; if (maxAllowedItems.GetValueOrDefault() == 1 && text.Trim().Equals("CoinPocketUI", StringComparison.OrdinalIgnoreCase)) { return false; } string text2 = SanitizeCsv(text, "CoinPocketUI", maxAllowedItems); if (text2 == text) { return false; } entry.Value = text2; return true; } private static string SanitizeCsv(string csv, string targetEntry, int? maxAllowedItems) { if (string.IsNullOrWhiteSpace(csv)) { return string.Empty; } string[] array = csv.Split(new char[1] { ',' }); int num = 0; for (int i = 0; i < array.Length; i++) { if (!string.IsNullOrWhiteSpace(array[i])) { num++; } } if (num <= maxAllowedItems) { return csv; } List<string> list = new List<string>(array.Length); bool flag = false; string[] array2 = array; foreach (string text in array2) { if (text.Trim().Equals(targetEntry, StringComparison.OrdinalIgnoreCase)) { flag = true; } else { list.Add(text); } } if (!flag) { return csv; } if (list.Count != 0) { return string.Join(",", list); } return string.Empty; } } public class RapidLoadoutsCompat { public static void Init() { if (Chainloader.PluginInfos.TryGetValue("Azumatt.RapidLoadouts", out var value) && value != null && Object.op_Implicit((Object)(object)value.Instance)) { CurrencyPocketPlugin.instance._harmony.PatchAll(typeof(RapidLoadoutsCompat)); } } [HarmonyPatch("RapidLoadouts.UI.PurchasableLoadoutGui, RapidLoadouts", "GetPlayerCoins")] [HarmonyPostfix] public static void GetPlayerCoins(ref int __result, ref ItemDrop ___m_coinPrefab) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Object)(object)___m_coinPrefab == (Object)null) && ___m_coinPrefab.m_itemData.m_shared.m_name == "$item_coins") { __result += (Player.m_localPlayer.m_customData.TryGetValue("CoinPocket_CoinCount", out var value) ? int.Parse(value) : 0); } } } }