The BepInEx console will not appear when launching like it does for other games on Thunderstore. This is normal (and helps prevent crashes during startup). You can turn it back on in your BepInEx.cfg file.
Decompiled source of Shops v0.6.3
lansmurf.PeakCoinMod.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; 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("lansmurf.PeakCoinMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Adds a coin and shopkeeper system to PEAK.")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+a3a2b80850bc8d2804fde94a6bf8d4164019015c")] [assembly: AssemblyProduct("lansmurf.PeakCoinMod")] [assembly: AssemblyTitle("lansmurf.PeakCoinMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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 CoinModProject { public static class PluginInfo { public const string PLUGIN_GUID = "lansmurf.PeakCoinMod"; public const string PLUGIN_NAME = "lansmurf.PeakCoinMod"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace CoinMod { [BepInPlugin("com.lansmurf.peakcoinmod", "Peak Coin Mod", "4.1.0")] public class CoinPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <InitializeWhenReady>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CoinPlugin <>4__this; private GameObject <modHostObject>5__1; private Harmony <harmony>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeWhenReady>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <modHostObject>5__1 = null; <harmony>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Player.localPlayer != (Object)null)); <>1__state = 1; return true; case 1: <>1__state = -1; Log.LogInfo((object)"Game is ready! Initializing PeakCoinMod systems..."); <modHostObject>5__1 = new GameObject("PeakCoinMod_Systems"); Object.DontDestroyOnLoad((Object)(object)<modHostObject>5__1); <modHostObject>5__1.AddComponent<ShopManager>(); <modHostObject>5__1.AddComponent<CoinUI>(); <harmony>5__2 = new Harmony("com.lansmurf.peakcoinmod.player_setup"); <harmony>5__2.Patch((MethodBase)AccessTools.Method(typeof(Player), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(CoinPlugin), "PlayerAwakePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if ((Object)(object)((Component)Player.localPlayer).GetComponent<PlayerCoinManager>() == (Object)null) { ((Component)Player.localPlayer).gameObject.AddComponent<PlayerCoinManager>(); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource Log; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Peak Coin Mod v4.1.0 is loading!"); Harmony val = new Harmony("com.lansmurf.peakcoinmod.harmony"); val.PatchAll(); ((MonoBehaviour)this).StartCoroutine(InitializeWhenReady()); Log.LogInfo((object)"Peak Coin Mod is ready and waiting for game to load..."); } [IteratorStateMachine(typeof(<InitializeWhenReady>d__2))] private IEnumerator InitializeWhenReady() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeWhenReady>d__2(0) { <>4__this = this }; } public static void PlayerAwakePostfix(Player __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent<PlayerCoinManager>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<PlayerCoinManager>(); } } } public class CoinUI : MonoBehaviour { private TextMeshProUGUI coinText; private Canvas canvas; public static CoinUI Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { CreateCoinUICanvas(); } private void CreateCoinUICanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PeakCoinMod_CoinCanvas"); canvas = val.AddComponent<Canvas>(); canvas.renderMode = (RenderMode)0; canvas.sortingOrder = 99; val.AddComponent<CanvasScaler>(); val.AddComponent<GraphicRaycaster>(); Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = new GameObject("CoinCounterText"); val2.transform.SetParent(val.transform, false); coinText = val2.AddComponent<TextMeshProUGUI>(); TextMeshProUGUI val3 = GUIManager.instance?.interactNameText; if ((Object)(object)val3 != (Object)null) { ((TMP_Text)coinText).font = ((TMP_Text)val3).font; ((TMP_Text)coinText).fontMaterial = ((TMP_Text)val3).fontMaterial; ((TMP_Text)coinText).fontSize = 24f; ((Graphic)coinText).color = Color.yellow; ((TMP_Text)coinText).alignment = (TextAlignmentOptions)513; } else { ((TMP_Text)coinText).fontSize = 24f; ((Graphic)coinText).color = Color.white; } RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(20f, -20f); UpdateCoinCount(0); } public void UpdateCoinCount(int newAmount) { if ((Object)(object)coinText != (Object)null) { ((TMP_Text)coinText).text = $"Coins: {newAmount}"; } } } public class PlayerCoinManager : MonoBehaviourPun, IInRoomCallbacks { public static PlayerCoinManager LocalInstance { get; private set; } public int SharedCoins { get; private set; } private void Awake() { if (((MonoBehaviourPun)this).photonView.IsMine) { LocalInstance = this; } } private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } private void Start() { if (!PhotonNetwork.IsMasterClient) { ((MonoBehaviourPun)this).photonView.RPC("RPC_Client_RequestSync", (RpcTarget)2, Array.Empty<object>()); CoinPlugin.Log.LogInfo((object)"Client has started. Requesting coin sync from host."); } } public void RequestPurchase(string itemName) { ((MonoBehaviourPun)this).photonView.RPC("RPC_Host_ProcessPurchaseRequest", (RpcTarget)2, new object[1] { itemName }); } public void RequestModifyCoins(int amount) { ((MonoBehaviourPun)this).photonView.RPC("RPC_Host_ProcessCoinModification", (RpcTarget)2, new object[1] { amount }); } [PunRPC] private void RPC_Host_ProcessCoinModification(int amount) { if (!PhotonNetwork.IsMasterClient) { return; } PlayerCoinManager localInstance = LocalInstance; if ((Object)(object)localInstance == (Object)null) { CoinPlugin.Log.LogError((object)"Host's local PlayerCoinManager not found! Coin modification failed."); return; } int num = localInstance.SharedCoins + amount; if (num < 0) { num = 0; } ((MonoBehaviourPun)localInstance).photonView.RPC("RPC_Client_UpdateCoins", (RpcTarget)0, new object[1] { num }); } [PunRPC] private void RPC_Host_ProcessPurchaseRequest(string itemName, PhotonMessageInfo info) { //IL_00a4: 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) if (PhotonNetwork.IsMasterClient) { PlayerCoinManager localInstance = LocalInstance; ShopItemData value; if ((Object)(object)localInstance == (Object)null) { CoinPlugin.Log.LogError((object)"Host's local PlayerCoinManager not found! Purchase failed."); } else if (ShopDatabase.ItemData.TryGetValue(itemName, out value) && localInstance.SharedCoins >= value.Price) { int num = localInstance.SharedCoins - value.Price; ((MonoBehaviourPun)localInstance).photonView.RPC("RPC_Client_UpdateCoins", (RpcTarget)0, new object[1] { num }); ((MonoBehaviourPun)this).photonView.RPC("RPC_Client_ConfirmPurchase", info.Sender, new object[1] { itemName }); CoinPlugin.Log.LogInfo((object)$"Host approved purchase of {itemName} for {info.Sender.NickName}. New coin total: {num}"); } } } [PunRPC] private void RPC_Client_ConfirmPurchase(string itemName) { if ((Object)(object)ShopManager.Instance != (Object)null) { CoinPlugin.Log.LogInfo((object)("Purchase of " + itemName + " confirmed by host. Spawning item.")); ShopManager.Instance.SpawnPurchasedItem(itemName); } } [PunRPC] private void RPC_Client_UpdateCoins(int newTotal) { if ((Object)(object)LocalInstance != (Object)null) { LocalInstance.SharedCoins = newTotal; } if ((Object)(object)CoinUI.Instance != (Object)null) { CoinUI.Instance.UpdateCoinCount(newTotal); } if ((Object)(object)ShopManager.Instance != (Object)null) { ShopManager.Instance.RefreshShopDisplay(); } CoinPlugin.Log.LogInfo((object)$"Team coin count has been updated to {newTotal}"); } [PunRPC] private void RPC_Client_RequestSync(PhotonMessageInfo info) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient) { PlayerCoinManager localInstance = LocalInstance; if (!((Object)(object)localInstance == (Object)null)) { ((MonoBehaviourPun)localInstance).photonView.RPC("RPC_Client_UpdateCoins", info.Sender, new object[1] { localInstance.SharedCoins }); CoinPlugin.Log.LogInfo((object)$"Host received sync request. Sending {localInstance.SharedCoins} coins to {info.Sender.NickName}."); } } } public void OnPlayerEnteredRoom(Player newPlayer) { if (PhotonNetwork.IsMasterClient) { PlayerCoinManager localInstance = LocalInstance; if (!((Object)(object)localInstance == (Object)null)) { ((MonoBehaviourPun)localInstance).photonView.RPC("RPC_Client_UpdateCoins", newPlayer, new object[1] { localInstance.SharedCoins }); CoinPlugin.Log.LogInfo((object)$"New player {newPlayer.NickName} joined. Host is sending them the current coin count: {localInstance.SharedCoins}."); } } } public void OnPlayerLeftRoom(Player otherPlayer) { } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnMasterClientSwitched(Player newMasterClient) { } } public enum ItemCategory { All, Food, Meds, Tools, Special } public class ShopItemData { public int Price { get; } public ItemCategory Category { get; } public ShopItemData(int price, ItemCategory category) { Price = price; Category = category; } } public static class ShopDatabase { public static readonly int DefaultPrice = 9999; public static readonly ItemCategory DefaultCategory = ItemCategory.Special; public static readonly Dictionary<string, ShopItemData> ItemData = new Dictionary<string, ShopItemData> { { "Marshmallow", new ShopItemData(16, ItemCategory.Food) }, { "Lollipop", new ShopItemData(20, ItemCategory.Food) }, { "Airplane Food", new ShopItemData(11, ItemCategory.Food) }, { "Granola Bar", new ShopItemData(7, ItemCategory.Food) }, { "ScoutCookies", new ShopItemData(12, ItemCategory.Food) }, { "TrailMix", new ShopItemData(5, ItemCategory.Food) }, { "Bandages", new ShopItemData(8, ItemCategory.Meds) }, { "Heat Pack", new ShopItemData(11, ItemCategory.Meds) }, { "Antidote", new ShopItemData(23, ItemCategory.Meds) }, { "FirstAidKit", new ShopItemData(30, ItemCategory.Meds) }, { "Cure-All", new ShopItemData(65, ItemCategory.Meds) }, { "ScoutEffigy", new ShopItemData(75, ItemCategory.Meds) }, { "Cure-Some", new ShopItemData(25, ItemCategory.Meds) }, { "EnergyElixir", new ShopItemData(32, ItemCategory.Meds) }, { "Energy Drink", new ShopItemData(15, ItemCategory.Meds) }, { "Sports Drink", new ShopItemData(10, ItemCategory.Meds) }, { "Napberry", new ShopItemData(9, ItemCategory.Meds) }, { "Flare", new ShopItemData(6, ItemCategory.Tools) }, { "Lantern", new ShopItemData(25, ItemCategory.Tools) }, { "Compass", new ShopItemData(20, ItemCategory.Tools) }, { "Bugle", new ShopItemData(18, ItemCategory.Tools) }, { "PortableStovetopItem", new ShopItemData(45, ItemCategory.Tools) }, { "RopeShooter", new ShopItemData(38, ItemCategory.Tools) }, { "RopeSpool", new ShopItemData(22, ItemCategory.Tools) }, { "Anti-Rope Spool", new ShopItemData(22, ItemCategory.Tools) }, { "RopeShooterAnti", new ShopItemData(42, ItemCategory.Tools) }, { "ChainShooter", new ShopItemData(40, ItemCategory.Tools) }, { "Piton", new ShopItemData(20, ItemCategory.Tools) }, { "ShelfShroom", new ShopItemData(5, ItemCategory.Tools) }, { "Backpack", new ShopItemData(60, ItemCategory.Tools) }, { "Binoculars", new ShopItemData(15, ItemCategory.Tools) }, { "Parasol", new ShopItemData(18, ItemCategory.Tools) }, { "Megaphone", new ShopItemData(12, ItemCategory.Tools) }, { "Bugle_Magic", new ShopItemData(88, ItemCategory.Special) }, { "Lantern_Faerie", new ShopItemData(70, ItemCategory.Special) }, { "PandorasBox", new ShopItemData(125, ItemCategory.Special) }, { "HealingDart Variant", new ShopItemData(35, ItemCategory.Special) }, { "Cursed Skull", new ShopItemData(100, ItemCategory.Special) }, { "Pirate Compass", new ShopItemData(80, ItemCategory.Special) }, { "Bugle_Scoutmaster Variant", new ShopItemData(45, ItemCategory.Special) }, { "MagicBean", new ShopItemData(40, ItemCategory.Special) }, { "Strange Gem", new ShopItemData(50, ItemCategory.Special) }, { "BounceShroom", new ShopItemData(8, ItemCategory.Special) }, { "Warp Compass", new ShopItemData(75, ItemCategory.Special) }, { "Frisbee", new ShopItemData(3, ItemCategory.Special) }, { "BingBong", new ShopItemData(9999, ItemCategory.Special) } }; } public class ShopManager : MonoBehaviour { private Campfire activeCampfire; private const float MaxInteractionDistance = 10f; private GameObject shopPanel; private RectTransform itemContentRect; private TextMeshProUGUI coinText; private GameObject itemListingPrefab; private RectTransform categoryButtonContainer; private GameObject categoryButtonPrefab; private static List<Item> allItems = new List<Item>(); private static bool hasInitializedItems = false; private ItemCategory currentCategory = ItemCategory.All; private Dictionary<ItemCategory, Button> categoryButtons = new Dictionary<ItemCategory, Button>(); public static ShopManager Instance { get; private set; } public bool isShopOpen { get; private set; } = false; public void RefreshShopDisplay() { if (isShopOpen) { PopulateItemGrid(); } } public void SpawnPurchasedItem(string itemName) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) if ((Object)(object)Character.localCharacter != (Object)null) { Vector3 val = Character.localCharacter.Center + ((Component)Character.localCharacter).transform.forward * 1.5f + Vector3.up * 0.5f; PhotonNetwork.Instantiate("0_Items/" + itemName, val, Quaternion.identity, (byte)0, (object[])null); } } private void TryToBuyItem(Item itemPrefab, int price) { Player localPlayer = Player.localPlayer; PlayerCoinManager playerCoinManager = ((localPlayer != null) ? ((Component)localPlayer).GetComponent<PlayerCoinManager>() : null); if (!((Object)(object)playerCoinManager == (Object)null)) { CoinPlugin.Log.LogInfo((object)("Requesting to purchase " + ((Object)itemPrefab).name + " from host.")); playerCoinManager.RequestPurchase(((Object)itemPrefab).name); } } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (isShopOpen && ((Object)(object)activeCampfire == (Object)null || (Object)(object)Character.localCharacter == (Object)null || Vector3.Distance(Character.localCharacter.Center, ((Component)activeCampfire).transform.position) > 10f)) { CloseShopGUI(); } } public void OpenShopGUI(Campfire campfire) { if (!isShopOpen) { if ((Object)(object)shopPanel == (Object)null) { CreateShopUI(); } activeCampfire = campfire; isShopOpen = true; shopPanel.SetActive(true); if (!hasInitializedItems) { InitializeItemList(); } SetCategory(ItemCategory.All); } } public void CloseShopGUI() { if (isShopOpen) { activeCampfire = null; isShopOpen = false; shopPanel.SetActive(false); } } private void SetCategory(ItemCategory category) { //IL_006e: 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) currentCategory = category; foreach (KeyValuePair<ItemCategory, Button> categoryButton in categoryButtons) { Image component = ((Component)categoryButton.Value).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Graphic)component).color = ((categoryButton.Key == currentCategory) ? new Color(0.3f, 0.5f, 0.8f) : new Color(0.15f, 0.25f, 0.4f)); } } PopulateItemGrid(); } private void PopulateItemGrid() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown foreach (Transform item in (Transform)itemContentRect) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } Player localPlayer = Player.localPlayer; int valueOrDefault = ((localPlayer == null) ? null : ((Component)localPlayer).GetComponent<PlayerCoinManager>()?.SharedCoins).GetValueOrDefault(); ((TMP_Text)coinText).text = $"Team Coins: {valueOrDefault}"; var orderedEnumerable = from x in allItems.Select(delegate(Item item) { ShopDatabase.ItemData.TryGetValue(((Object)item).name, out var value); return new { Item = item, Price = (value?.Price ?? ShopDatabase.DefaultPrice), Category = (value?.Category ?? ItemCategory.Special) }; }) where ShopDatabase.ItemData.ContainsKey(((Object)x.Item).name) where currentCategory == ItemCategory.All || x.Category == currentCategory orderby x.Price select x; foreach (var itemData in orderedEnumerable) { GameObject val2 = Object.Instantiate<GameObject>(itemListingPrefab, (Transform)(object)itemContentRect); Image component = ((Component)val2.transform.Find("ItemIcon")).GetComponent<Image>(); TextMeshProUGUI component2 = ((Component)val2.transform.Find("ItemName")).GetComponent<TextMeshProUGUI>(); Button component3 = ((Component)val2.transform.Find("BuyButton")).GetComponent<Button>(); TextMeshProUGUI componentInChildren = ((Component)component3).GetComponentInChildren<TextMeshProUGUI>(); if ((Object)(object)itemData.Item.UIData?.icon != (Object)null) { Texture2D icon = itemData.Item.UIData.icon; component.sprite = Sprite.Create(icon, new Rect(0f, 0f, (float)((Texture)icon).width, (float)((Texture)icon).height), new Vector2(0.5f, 0.5f)); } ((TMP_Text)component2).text = itemData.Item.UIData?.itemName ?? ((Object)itemData.Item).name; ((TMP_Text)componentInChildren).text = $"Buy ({itemData.Price})"; ((Selectable)component3).interactable = valueOrDefault >= itemData.Price; ((UnityEventBase)component3.onClick).RemoveAllListeners(); ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { TryToBuyItem(itemData.Item, itemData.Price); }); val2.SetActive(true); } } private static void InitializeItemList() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, Item> dictionary = new Dictionary<string, Item>(); Item[] array = Resources.FindObjectsOfTypeAll<Item>(); Item[] array2 = array; foreach (Item val in array2) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).handle == 0 && !string.IsNullOrEmpty(val.UIData?.itemName) && ShopDatabase.ItemData.ContainsKey(((Object)val).name) && !dictionary.ContainsKey(val.UIData.itemName)) { dictionary.Add(val.UIData.itemName, val); } } } allItems = dictionary.Values.ToList(); hasInitializedItems = true; } private void CreateShopUI() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_013b: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Expected O, but got Unknown //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Expected O, but got Unknown //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Expected O, but got Unknown //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Expected O, but got Unknown //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Expected O, but got Unknown //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Expected O, but got Unknown GameObject val = new GameObject("PeakCoinMod_ShopCanvas"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 100; val.AddComponent<CanvasScaler>(); val.AddComponent<GraphicRaycaster>(); Object.DontDestroyOnLoad((Object)(object)val); shopPanel = new GameObject("ShopPanel"); shopPanel.transform.SetParent(val.transform, false); Image val3 = shopPanel.AddComponent<Image>(); ((Graphic)val3).color = new Color(0.1f, 0.1f, 0.1f, 0.9f); RectTransform component = shopPanel.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(1000f, 750f); GameObject val4 = new GameObject("Title"); val4.transform.SetParent(shopPanel.transform, false); TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val5).text = "Campfire Shop"; ((TMP_Text)val5).fontSize = 32f; ((Graphic)val5).color = Color.white; ((TMP_Text)val5).alignment = (TextAlignmentOptions)514; RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); component2.anchoredPosition = new Vector2(0f, -20f); coinText = new GameObject("CoinText").AddComponent<TextMeshProUGUI>(); ((TMP_Text)coinText).transform.SetParent(shopPanel.transform, false); ((TMP_Text)coinText).fontSize = 20f; ((Graphic)coinText).color = Color.yellow; ((TMP_Text)coinText).alignment = (TextAlignmentOptions)514; RectTransform component3 = ((Component)coinText).GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.anchoredPosition = new Vector2(0f, -60f); GameObject val6 = new GameObject("CategoryPanel", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(shopPanel.transform, false); ((Graphic)val6.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 0.8f); RectTransform component4 = val6.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(0f, 1f); component4.pivot = new Vector2(0f, 1f); component4.offsetMin = new Vector2(20f, 80f); component4.offsetMax = new Vector2(220f, -100f); GameObject val7 = new GameObject("CategoryButtonContainer", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val6.transform, false); categoryButtonContainer = val7.GetComponent<RectTransform>(); categoryButtonContainer.anchorMin = Vector2.zero; categoryButtonContainer.anchorMax = Vector2.one; categoryButtonContainer.sizeDelta = Vector2.zero; VerticalLayoutGroup val8 = val7.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val8).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)val8).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false; GameObject val9 = new GameObject("ItemPanel", new Type[1] { typeof(RectTransform) }); val9.transform.SetParent(shopPanel.transform, false); RectTransform component5 = val9.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0f, 0f); component5.anchorMax = new Vector2(1f, 1f); component5.offsetMin = new Vector2(240f, 80f); component5.offsetMax = new Vector2(-20f, -100f); ScrollRect val10 = val9.AddComponent<ScrollRect>(); ((Graphic)val9.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f); val10.horizontal = false; val10.vertical = true; GameObject val11 = new GameObject("Viewport", new Type[1] { typeof(RectTransform) }); val11.transform.SetParent(val9.transform, false); val11.AddComponent<Mask>().showMaskGraphic = false; val11.AddComponent<Image>(); RectTransform component6 = val11.GetComponent<RectTransform>(); component6.anchorMin = Vector2.zero; component6.anchorMax = Vector2.one; component6.sizeDelta = Vector2.zero; component6.pivot = new Vector2(0f, 1f); GameObject val12 = new GameObject("ItemContent", new Type[1] { typeof(RectTransform) }); val12.transform.SetParent(val11.transform, false); itemContentRect = val12.GetComponent<RectTransform>(); itemContentRect.anchorMin = new Vector2(0f, 1f); itemContentRect.anchorMax = new Vector2(0f, 1f); itemContentRect.pivot = new Vector2(0f, 1f); itemContentRect.sizeDelta = Vector2.zero; GridLayoutGroup val13 = val12.AddComponent<GridLayoutGroup>(); ((LayoutGroup)val13).padding = new RectOffset(15, 15, 15, 15); val13.spacing = new Vector2(15f, 15f); val13.cellSize = new Vector2(150f, 180f); val13.constraint = (Constraint)1; val13.constraintCount = 4; ContentSizeFitter val14 = val12.AddComponent<ContentSizeFitter>(); val14.verticalFit = (FitMode)2; val10.viewport = component6; val10.content = itemContentRect; Button val15 = new GameObject("CloseButton", new Type[1] { typeof(RectTransform) }).AddComponent<Button>(); ((Component)val15).transform.SetParent(shopPanel.transform, false); ((Graphic)((Component)val15).gameObject.AddComponent<Image>()).color = new Color(0.8f, 0.2f, 0.2f); RectTransform component7 = ((Component)val15).GetComponent<RectTransform>(); component7.anchorMin = new Vector2(0.5f, 0f); component7.anchorMax = new Vector2(0.5f, 0f); component7.pivot = new Vector2(0.5f, 0f); component7.sizeDelta = new Vector2(150f, 40f); component7.anchoredPosition = new Vector2(0f, 20f); TextMeshProUGUI val16 = new GameObject("Text").AddComponent<TextMeshProUGUI>(); ((TMP_Text)val16).transform.SetParent(((Component)val15).transform, false); ((TMP_Text)val16).text = "Close"; ((Graphic)val16).color = Color.white; ((TMP_Text)val16).alignment = (TextAlignmentOptions)514; ((TMP_Text)val16).fontSize = 20f; ((UnityEvent)val15.onClick).AddListener(new UnityAction(CloseShopGUI)); CreateItemListingPrefab(); CreateCategoryButtonPrefab(); PopulateCategoryTabs(); shopPanel.SetActive(false); } private void PopulateCategoryTabs() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown foreach (Transform item in (Transform)categoryButtonContainer) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } categoryButtons.Clear(); foreach (ItemCategory value in Enum.GetValues(typeof(ItemCategory))) { ItemCategory localCategory = value; GameObject val2 = Object.Instantiate<GameObject>(categoryButtonPrefab, (Transform)(object)categoryButtonContainer); TextMeshProUGUI componentInChildren = val2.GetComponentInChildren<TextMeshProUGUI>(); ((TMP_Text)componentInChildren).text = localCategory.ToString(); Button component = val2.GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { SetCategory(localCategory); }); categoryButtons[localCategory] = component; val2.SetActive(true); } } private void CreateItemListingPrefab() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) itemListingPrefab = new GameObject("ItemListingPrefab"); ((Graphic)itemListingPrefab.AddComponent<Image>()).color = new Color(0.2f, 0.2f, 0.2f, 1f); VerticalLayoutGroup val = itemListingPrefab.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val).padding = new RectOffset(5, 5, 5, 5); ((HorizontalOrVerticalLayoutGroup)val).spacing = 5f; ((LayoutGroup)val).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = true; GameObject val2 = new GameObject("ItemIcon", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(itemListingPrefab.transform, false); val2.AddComponent<Image>(); LayoutElement val3 = val2.AddComponent<LayoutElement>(); val3.minHeight = 80f; val3.preferredHeight = 80f; GameObject val4 = new GameObject("ItemName", new Type[1] { typeof(RectTransform) }); val4.transform.SetParent(itemListingPrefab.transform, false); TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>(); ((Graphic)val5).color = Color.white; ((TMP_Text)val5).fontSize = 16f; ((TMP_Text)val5).alignment = (TextAlignmentOptions)514; val4.AddComponent<LayoutElement>().minHeight = 40f; GameObject val6 = new GameObject("BuyButton", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(itemListingPrefab.transform, false); val6.AddComponent<Button>(); ((Graphic)val6.AddComponent<Image>()).color = new Color(0.2f, 0.5f, 0.2f); LayoutElement val7 = val6.AddComponent<LayoutElement>(); val7.minHeight = 30f; val7.preferredHeight = 30f; GameObject val8 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val8.transform.SetParent(val6.transform, false); TextMeshProUGUI val9 = val8.AddComponent<TextMeshProUGUI>(); ((Graphic)val9).color = Color.white; ((TMP_Text)val9).fontSize = 14f; ((TMP_Text)val9).alignment = (TextAlignmentOptions)514; itemListingPrefab.SetActive(false); } private void CreateCategoryButtonPrefab() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) categoryButtonPrefab = new GameObject("CategoryButtonPrefab"); Image val = categoryButtonPrefab.AddComponent<Image>(); ((Graphic)val).color = new Color(0.15f, 0.25f, 0.4f); categoryButtonPrefab.AddComponent<LayoutElement>().minHeight = 50f; Button val2 = categoryButtonPrefab.AddComponent<Button>(); ColorBlock colors = ((Selectable)val2).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(0.2f, 0.4f, 0.6f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.1f, 0.2f, 0.3f); ((Selectable)val2).colors = colors; GameObject val3 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(categoryButtonPrefab.transform, false); TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>(); ((Graphic)val4).color = Color.white; ((TMP_Text)val4).fontSize = 20f; ((TMP_Text)val4).alignment = (TextAlignmentOptions)514; categoryButtonPrefab.SetActive(false); } } } namespace CoinMod.Patches { [HarmonyPatch(typeof(Campfire))] public static class CampfirePatches { [HarmonyPatch("GetInteractTime")] [HarmonyPrefix] public static bool SetInstantInteractTime(Campfire __instance, Character interactor, ref float __result) { if ((Object)(object)interactor != (Object)null && (Object)(object)interactor.data.currentItem == (Object)null && __instance.Lit) { __result = 0f; return false; } return true; } [HarmonyPatch("IsInteractible")] [HarmonyPostfix] public static void AllowEmptyHandedInteraction(Campfire __instance, Character interactor, ref bool __result) { if (!__result && __instance.Lit && (Object)(object)interactor?.data.currentItem == (Object)null) { __result = true; } } [HarmonyPatch("IsConstantlyInteractable")] [HarmonyPostfix] public static void AllowEmptyHandedConstantInteraction(Campfire __instance, Character interactor, ref bool __result) { if (!__result && __instance.Lit && (Object)(object)interactor?.data.currentItem == (Object)null) { __result = true; } } [HarmonyPatch("GetInteractionText")] [HarmonyPostfix] public static void OverwriteInteractionText(Campfire __instance, ref string __result) { if (__instance.Lit) { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && (Object)(object)localCharacter.data.currentItem == (Object)null) { __result = "Shop"; } } } [HarmonyPatch("Interact")] [HarmonyPrefix] public static bool HandleShopInteraction(Campfire __instance, Character interactor) { if (__instance.Lit && (Object)(object)interactor.data.currentItem == (Object)null) { if ((Object)(object)ShopManager.Instance != (Object)null) { ShopManager.Instance.OpenShopGUI(__instance); } else { CoinPlugin.Log.LogError((object)"ShopManager.Instance is null! Cannot open shop."); } return false; } return true; } } [HarmonyPatch(typeof(GUIManager))] public static class GUIManagerPatches { private static FieldInfo _windowShowingCursorField = AccessTools.Field(typeof(GUIManager), "<windowShowingCursor>k__BackingField"); private static FieldInfo _windowBlockingInputField = AccessTools.Field(typeof(GUIManager), "<windowBlockingInput>k__BackingField"); [HarmonyPatch("UpdateWindowStatus")] [HarmonyPostfix] public static void ForceCursorStateForShop(GUIManager __instance) { if ((Object)(object)ShopManager.Instance == (Object)null) { return; } if (_windowShowingCursorField == null || _windowBlockingInputField == null) { if (ShopManager.Instance.isShopOpen) { CoinPlugin.Log.LogError((object)"Could not find GUIManager fields! Cursor will not work."); } } else if (ShopManager.Instance.isShopOpen) { _windowShowingCursorField.SetValue(__instance, true); _windowBlockingInputField.SetValue(__instance, true); } } } [HarmonyPatch(typeof(Luggage))] public static class LuggagePatches { [HarmonyPatch("Interact_CastFinished")] [HarmonyPostfix] public static void GiveCoinsOnOpenPatch(Character interactor) { if ((Object)(object)interactor != (Object)null && interactor.IsLocal) { PlayerCoinManager component = ((Component)Player.localPlayer).GetComponent<PlayerCoinManager>(); if ((Object)(object)component != (Object)null) { int num = Random.Range(10, 51); component.RequestModifyCoins(num); CoinPlugin.Log.LogInfo((object)$"You opened luggage and requested {num} coins for the team!"); } } } } }