using System;
using System.Collections;
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.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.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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)(object)component != (Object)null)
{
component.anchoredPosition += new Vector2(0f, 45f);
}
}
if (Chainloader.PluginInfos.ContainsKey("randyknapp.mods.equipmentandquickslots") || Chainloader.PluginInfos.ContainsKey("Azumatt.AzuExtendedPlayerInventory"))
{
switch (((Object)child).name)
{
case "sortInventoryButton":
case "restockAreaButton":
case "quickStackAreaButton":
case "favoritingTogglingButton":
flag = true;
break;
default:
flag = false;
break;
}
if (flag)
{
RectTransform component2 = ((Component)child).gameObject.GetComponent<RectTransform>();
if ((Object)(object)component2 != (Object)null)
{
if (((Object)child).name == "favoritingTogglingButton")
{
component2.anchoredPosition += new Vector2(0f, 20f);
}
else if (!Chainloader.PluginInfos.ContainsKey("randyknapp.mods.equipmentandquickslots") && Chainloader.PluginInfos.ContainsKey("Azumatt.AzuExtendedPlayerInventory"))
{
component2.anchoredPosition += new Vector2(0f, -15f);
}
else
{
component2.anchoredPosition += new Vector2(0f, -30f);
}
}
}
}
}
}
}
}
[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 (__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)
})]
private static class TransferBetweenInventories
{
private static bool Prefix(Inventory __instance, Inventory fromInventory, ItemData item)
{
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return true;
}
if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_currentContainer != (Object)null && fromInventory == InventoryGui.instance.m_currentContainer.GetInventory())
{
if (item.m_shared.m_name != "$item_coins" || __instance != ((Humanoid)Player.m_localPlayer).GetInventory())
{
return true;
}
MiscFunctions.GetPlayerCoinsFromCustomData();
MiscFunctions.UpdatePlayerCustomData(MiscFunctions.GetPlayerCoinsFromCustomData() + item.m_stack);
UpdatePocketUI();
fromInventory.RemoveItem(item);
__instance.Changed();
fromInventory.Changed();
return false;
}
return true;
}
public static bool CouldAdd(Inventory inventory, ItemData item)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
bool result = true;
if (item.m_shared.m_maxStackSize > 1)
{
for (int i = 0; i < item.m_stack; i++)
{
ItemData val = inventory.FindFreeStackItem(item.m_shared.m_name, item.m_quality, (float)item.m_worldLevel);
if (val != null)
{
val.m_stack++;
continue;
}
int stack = item.m_stack - i;
item.m_stack = stack;
if (inventory.FindEmptySlot(inventory.TopFirst(item)).x < 0)
{
result = false;
}
break;
}
}
else if (inventory.FindEmptySlot(inventory.TopFirst(item)).x < 0)
{
result = false;
}
inventory.Changed();
return result;
}
}
internal const string CoinCountCustomData = "CoinPocket_CoinCount";
internal const string CoinToken = "$item_coins";
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_004a: 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_009b: 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";
CurrencyPocketPlugin.CurrencyPocketLogger.LogDebug((object)$"Creating pocket UI at {InventoryGuiUpdatePatch.pocketUI.GetComponent<RectTransform>().anchoredPosition}");
RectTransform component = InventoryGuiUpdatePatch.pocketUI.GetComponent<RectTransform>();
component.anchoredPosition += new Vector2(0f, -234f);
CurrencyPocketPlugin.CurrencyPocketLogger.LogDebug((object)$"Creating pocket UI at {InventoryGuiUpdatePatch.pocketUI.GetComponent<RectTransform>().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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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));
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)
{
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;
}
}
}
[BepInPlugin("Azumatt.CurrencyPocket", "CurrencyPocket", "1.0.5")]
public class CurrencyPocketPlugin : BaseUnityPlugin
{
internal const string ModName = "CurrencyPocket";
internal const string ModVersion = "1.0.5";
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();
}
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);
}
}
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);
clicked = false;
}
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
{
public class RapidLoadoutsCompat
{
public static void Init()
{
if (Chainloader.PluginInfos.TryGetValue("Azumatt.RapidLoadouts", out var value) && value != null && (Object)(object)value.Instance != (Object)null)
{
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)(object)Player.m_localPlayer != (Object)null && (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);
}
}
}
}