using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using PhotonCustomPropsUtils;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.TextCore;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.Serizalization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("dusher4.PEAKShop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("dusher4.PEAKShop")]
[assembly: AssemblyTitle("PEAKSHOP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
[CompilerGenerated]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace PEAKSHOP
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dusher4.PEAKShop", "PEAKSHOP", "0.1.0")]
public class Plugin : BaseUnityPlugin, IInRoomCallbacks, IConnectionCallbacks, IMatchmakingCallbacks
{
private Coroutine? _inputDetectionCoroutine;
private bool _lastShopKeyState;
private bool _lastDebugKeyState;
private bool _debugMode;
private string? _cachedBiome;
private GameObject? audioHost;
private AudioSource? audioSource;
private AudioClip? coinSoundClip;
private GameObject? notificationCanvas;
private GameObject? currentNotificationObj;
private TMP_FontAsset? gameFont;
private TMP_FontAsset? _cachedGameFont;
private Harmony _harmony;
private PhotonScopedManager _propsManager;
public bool IsHost;
public bool allowSummitShop;
private ConfigEntry<KeyCode> openSummitSupplyShop;
private ConfigEntry<bool> useModifierKey;
private ConfigEntry<KeyCode> modifierKey;
private ConfigEntry<string> customItems;
private ConfigEntry<float> coinSoundVolume;
private ConfigEntry<bool> showCoinNotifications;
private ConfigEntry<int> coinNotificationSize;
private ConfigEntry<string> coinNotificationColor;
private ConfigEntry<bool> persistCoinsBetweenRuns;
private readonly Dictionary<string, ConfigEntry<bool>> itemEnableConfigs = new Dictionary<string, ConfigEntry<bool>>();
private readonly Dictionary<string, ConfigEntry<int>> itemPriceConfigs = new Dictionary<string, ConfigEntry<int>>();
private readonly Dictionary<string, ConfigEntry<int>> luggageMinConfigs = new Dictionary<string, ConfigEntry<int>>();
private readonly Dictionary<string, ConfigEntry<int>> luggageMaxConfigs = new Dictionary<string, ConfigEntry<int>>();
private readonly Dictionary<string, (int price, ushort itemId, string itemName)> shopItems = new Dictionary<string, (int, ushort, string)>();
private readonly Dictionary<string, (int price, ushort itemId, string itemName, bool enabledByDefault)> allItems = new Dictionary<string, (int, ushort, string, bool)>
{
{
"Airline Food",
(15, 0, "Airline Food", true)
},
{
"Anti-Rope Spool",
(25, 1, "Anti-Rope Spool", true)
},
{
"Antidote",
(25, 2, "Antidote", true)
},
{
"Green Crispberry",
(0, 3, "Green Crispberry", false)
},
{
"Red Crispberry",
(5, 4, "Red Crispberry", true)
},
{
"Yellow Crispberry",
(7, 5, "Yellow Crispberry", true)
},
{
"Backpack",
(25, 6, "Backpack", true)
},
{
"Bandages",
(5, 7, "Bandages", true)
},
{
"Beehive",
(20, 8, "Beehive", false)
},
{
"Blue Berrynana",
(10, 9, "Blue Berrynana", true)
},
{
"Brown Berrynana",
(10, 10, "Brown Berrynana", true)
},
{
"Pink Berrynana",
(0, 11, "Pink Berrynana", false)
},
{
"Yellow Berrynana",
(5, 12, "Yellow Berrynana", true)
},
{
"Bing Bong",
(0, 13, "Bing Bong", false)
},
{
"Binoculars",
(0, 14, "Binoculars", false)
},
{
"Bugle",
(1, 15, "Bugle", true)
},
{
"Bugle of Friendship",
(10, 16, "Bugle of Friendship", true)
},
{
"Chain Launcher",
(25, 17, "Chain Launcher", true)
},
{
"Piton",
(20, 18, "Piton", true)
},
{
"Black Clusterberry",
(5, 19, "Black Clusterberry", true)
},
{
"Red Clusterberry",
(10, 20, "Red Clusterberry", true)
},
{
"Yellow Clusterberry",
(5, 21, "Yellow Clusterberry", true)
},
{
"Green Clusterberry",
(10, 22, "Green Clusterberry", true)
},
{
"Compass",
(0, 23, "Compass", false)
},
{
"Cure-All",
(20, 24, "Cure-All", true)
},
{
"Cursed Skull",
(5, 25, "Cursed Skull", true)
},
{
"Egg",
(0, 26, "Egg", false)
},
{
"Energy Drink",
(5, 27, "Energy Drink", true)
},
{
"Stick",
(0, 28, "Stick", false)
},
{
"First Aid Kit",
(10, 29, "First Aid Kit", true)
},
{
"Checkpoint Flag",
(0, 30, "Checkpoint Flag", false)
},
{
"Basketball",
(0, 31, "Basketball", false)
},
{
"Flare",
(1, 32, "Flare", true)
},
{
"Granola Bar",
(7, 33, "Granola Bar", true)
},
{
"Guidebook",
(0, 34, "Guidebook", false)
},
{
"Heat Pack",
(5, 35, "Heat Pack", true)
},
{
"Coconut",
(4, 36, "Coconut", true)
},
{
"Balloon Bunch",
(18, 37, "Balloon Bunch", true)
},
{
"Honeycomb",
(7, 38, "Honeycomb", true)
},
{
"Berrynana Peel (Pink)",
(0, 39, "Berrynana Peel (Pink)", false)
},
{
"Purple Kingberry",
(10, 40, "Purple Kingberry", true)
},
{
"Yellow Kingberry",
(0, 41, "Yellow Kingberry", false)
},
{
"Lantern",
(5, 42, "Lantern", true)
},
{
"Faerie Lantern",
(15, 43, "Faerie Lantern", true)
},
{
"Big Lollipop",
(7, 44, "Big Lollipop", true)
},
{
"Magic Bean",
(7, 45, "Magic Bean", true)
},
{
"Marshmallow",
(7, 46, "Marshmallow", true)
},
{
"Ancient Idol",
(50, 47, "Ancient Idol", false)
},
{
"Cactus",
(0, 48, "Cactus", false)
},
{
"Scroll",
(0, 49, "Scroll", false)
},
{
"Torn Page (Intro)",
(0, 50, "Torn Page (Intro)", false)
},
{
"Weird Shroom",
(0, 51, "Weird Shroom", false)
},
{
"Torn Page (Campfire)",
(0, 52, "Torn Page (Campfire)", false)
},
{
"Torn Page (Revival)",
(0, 53, "Torn Page (Revival)", false)
},
{
"Torn Page (Crashout)",
(0, 54, "Torn Page (Crashout)", false)
},
{
"Coconut Half",
(2, 55, "Coconut Half", true)
},
{
"Green Kingberry",
(0, 56, "Green Kingberry", false)
},
{
"Big Egg",
(10, 57, "Big Egg", true)
},
{
"Pandora's Lunchbox",
(25, 58, "Pandora's Lunchbox", true)
},
{
"Passport",
(0, 59, "Passport", false)
},
{
"Scorchberry",
(5, 60, "Scorchberry", true)
},
{
"Pirate's Compass",
(10, 61, "Pirate's Compass", true)
},
{
"Portable Stove",
(10, 62, "Portable Stove", true)
},
{
"Rope Cannon",
(25, 63, "Rope Cannon", true)
},
{
"Anti-Rope Cannon",
(25, 64, "Anti-Rope Cannon", true)
},
{
"Rope Spool",
(10, 65, "Rope Spool", true)
},
{
"Scout Cookies",
(15, 66, "Scout Cookies", true)
},
{
"Scout Effigy",
(25, 67, "Scout Effigy", true)
},
{
"Shelf Fungus",
(10, 68, "Shelf Fungus", true)
},
{
"Conch",
(0, 69, "Conch", false)
},
{
"Blowgun",
(10, 70, "Blowgun", true)
},
{
"Sports Drink",
(10, 71, "Sports Drink", true)
},
{
"Stone",
(0, 72, "Stone", false)
},
{
"Trail Mix",
(7, 73, "Trail Mix", true)
},
{
"Warp Compass",
(15, 74, "Warp Compass", true)
},
{
"Orange Winterberry",
(5, 75, "Orange Winterberry", true)
},
{
"Yellow Winterberry",
(10, 76, "Yellow Winterberry", true)
},
{
"Scoutmaster's Bugle",
(0, 77, "Scoutmaster's Bugle", false)
},
{
"Megaphone",
(0, 78, "Megaphone", false)
},
{
"Bounce Fungus",
(5, 79, "Bounce Fungus", true)
},
{
"Torn Page (Blank)",
(0, 80, "Torn Page (Blank)", false)
},
{
"Medicinal Root",
(5, 81, "Medicinal Root", true)
},
{
"Torn Page (Mushrooms)",
(0, 82, "Torn Page (Mushrooms)", false)
},
{
"Chubby Shroom",
(5, 83, "Chubby Shroom", true)
},
{
"Cluster Shroom (Poisonous)",
(0, 84, "Cluster Shroom (Poisonous)", false)
},
{
"Torn Page (Body Heat)",
(0, 85, "Torn Page (Body Heat)", false)
},
{
"Torn Page (Sleepy)",
(0, 86, "Torn Page (Sleepy)", false)
},
{
"Torn Page (Awake)",
(0, 87, "Torn Page (Awake)", false)
},
{
"Cluster Shroom",
(5, 88, "Cluster Shroom", true)
},
{
"Bugle Shroom (Poisonous)",
(0, 89, "Bugle Shroom (Poisonous)", false)
},
{
"Remedy Fungus",
(10, 90, "Remedy Fungus", true)
},
{
"Berrynana Peel (Blue)",
(0, 91, "Berrynana Peel (Blue)", false)
},
{
"Berrynana Peel (Brown)",
(0, 92, "Berrynana Peel (Brown)", false)
},
{
"Bugle Shroom",
(5, 93, "Bugle Shroom", true)
},
{
"Berrynana Peel (Yellow)",
(0, 94, "Berrynana Peel (Yellow)", false)
},
{
"Tick",
(0, 95, "Tick", false)
},
{
"Torn Page (First Teams)",
(0, 96, "Torn Page (First Teams)", false)
},
{
"Button Shroom (Poisonous)",
(0, 97, "Button Shroom (Poisonous)", false)
},
{
"Parasol",
(10, 98, "Parasol", true)
},
{
"Flying Disc",
(1, 99, "Flying Disc", true)
},
{
"Rescue Claw",
(25, 100, "Rescue Claw", true)
},
{
"Aloe Vera",
(5, 101, "Aloe Vera", true)
},
{
"Button Shroom",
(5, 102, "Button Shroom", true)
},
{
"Gold Prickleberry",
(0, 103, "Gold Prickleberry", false)
},
{
"Sunscreen",
(10, 104, "Sunscreen", true)
},
{
"Balloon",
(7, 105, "Balloon", true)
},
{
"Dynamite",
(5, 106, "Dynamite", true)
},
{
"Scout Cannon",
(10, 107, "Scout Cannon", true)
},
{
"Red Prickleberry",
(0, 108, "Red Prickleberry", false)
},
{
"Torch",
(0, 109, "Torch", false)
},
{
"Napberry",
(10, 110, "Napberry", true)
},
{
"Scorpion",
(0, 111, "Scorpion", false)
},
{
"Strange Gem",
(0, 112, "Strange Gem", false)
},
{
"Turkey Egg",
(0, 114, "Turkey Egg", false)
},
{
"The Book of Bones",
(0, 115, "The Book of Bones", false)
},
{
"Climbing Chalk",
(10, 116, "Climbing Chalk", true)
},
{
"Cloud Fungus",
(5, 117, "Cloud Fungus", true)
},
{
"Fortified Milk",
(10, 152, "Fortified Milk", true)
},
{
"Hot Dog (Cattail)",
(7, 153, "Hot Dog (Cattail)", true)
},
{
"Hot Dog",
(7, 154, "Hot Dog", true)
},
{
"Mandrake",
(10, 155, "Mandrake", true)
},
{
"Mandrake (Hidden)",
(0, 156, "Mandrake (Hidden)", false)
},
{
"Scout Cookies (Vanilla)",
(0, 157, "Scout Cookies (Vanilla)", false)
},
{
"Blue Shroomberry",
(7, 158, "Blue Shroomberry", true)
},
{
"Green Shroomberry",
(7, 159, "Green Shroomberry", true)
},
{
"Purple Shroomberry",
(7, 160, "Purple Shroomberry", true)
},
{
"Red Shroomberry",
(7, 161, "Red Shroomberry", true)
},
{
"Yellow Shroomberry",
(7, 162, "Yellow Shroomberry", true)
},
{
"Skull",
(0, 163, "Skull", false)
},
{
"Parasol (Roots)",
(0, 164, "Parasol (Roots)", false)
},
{
"Snowball",
(1, 165, "Snowball", true)
},
{
"Fanny Pack",
(20, 166, "Fanny Pack", true)
},
{
"Jetpack",
(40, 168, "Jetpack", true)
},
{
"Rocketpack",
(45, 169, "Rocketpack", true)
},
{
"Scout's Initiative",
(30, 170, "Scout's Initiative", false)
},
{
"Candlestick",
(5, 171, "Candlestick", true)
},
{
"Frog",
(0, 172, "Frog", false)
},
{
"Ritual Dagger",
(0, 173, "Ritual Dagger", false)
},
{
"Glider",
(35, 174, "Glider", true)
},
{
"Warpsketball",
(0, 175, "Warpsketball", false)
},
{
"Auto-Parachute",
(30, 176, "Auto-Parachute", true)
},
{
"Raven Egg",
(0, 177, "Raven Egg", false)
},
{
"Small Egg",
(0, 178, "Small Egg", false)
},
{
"Scout's Ambition",
(30, 179, "Scout's Ambition", false)
},
{
"Scout's Generosity",
(30, 180, "Scout's Generosity", false)
},
{
"Warp Fungus",
(10, 181, "Warp Fungus", true)
},
{
"Scout's Tenacity",
(30, 182, "Scout's Tenacity", false)
},
{
"Scout's Honor",
(0, 183, "Scout's Honor", false)
},
{
"The Early Worm",
(0, 184, "The Early Worm", false)
},
{
"Frog Legs",
(5, 185, "Frog Legs", false)
},
{
"Torn Page (Poison)",
(0, 186, "Torn Page (Poison)", false)
},
{
"Torn Page (Zombies)",
(0, 187, "Torn Page (Zombies)", false)
},
{
"Torn Page (Burning Sun)",
(0, 188, "Torn Page (Burning Sun)", false)
},
{
"Torn Page (Magma)",
(0, 189, "Torn Page (Magma)", false)
},
{
"Torn Page (Gloom)",
(0, 190, "Torn Page (Gloom)", false)
},
{
"Scoutmaster's Soul",
(0, 191, "Scoutmaster's Soul", false)
},
{
"Anti-Zooka",
(25, 192, "Anti-Zooka", true)
}
};
private readonly Dictionary<string, Dictionary<string, (int min, int max)>> defaultLuggageRanges = new Dictionary<string, Dictionary<string, (int, int)>>
{
{
"Shore",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(0, 3)
},
{
"LuggageBig",
(3, 5)
},
{
"LuggageEpic",
(5, 5)
}
}
},
{
"Tropics",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(2, 5)
},
{
"LuggageBig",
(4, 7)
},
{
"LuggageEpic",
(7, 7)
}
}
},
{
"Alpine",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(5, 5)
},
{
"LuggageBig",
(5, 7)
},
{
"LuggageEpic",
(7, 10)
}
}
},
{
"Mesa",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(5, 5)
},
{
"LuggageBig",
(5, 7)
},
{
"LuggageEpic",
(7, 10)
}
}
},
{
"Volcano",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(5, 5)
},
{
"LuggageBig",
(5, 7)
},
{
"LuggageEpic",
(7, 10)
}
}
},
{
"Kiln",
new Dictionary<string, (int, int)>
{
{
"LuggageSmall",
(5, 5)
},
{
"LuggageBig",
(7, 7)
},
{
"LuggageEpic",
(10, 10)
}
}
}
};
private static readonly HashSet<ushort> BackpackSlotItemIds = new HashSet<ushort> { 6, 166, 168, 169 };
private bool showShop;
private int playerCoins;
private bool _cursorStateSet;
private readonly Dictionary<ushort, Texture2D> _itemIconCache = new Dictionary<ushort, Texture2D>();
private GUIStyle _disabledButtonStyle;
private GUIStyle _enabledButtonStyle;
private bool _guiStylesInitialized;
private bool _uiCacheValid;
private int _cachedItemsPerRow;
private int _cachedTotalItems;
private int _cachedRows;
private float _cachedTotalWidth;
private float _cachedTotalHeight;
private float _cachedTotalWindowWidth;
private float _cachedTotalWindowHeight;
private float _cachedWindowX;
private float _cachedWindowY;
private readonly Dictionary<string, bool> _cachedCanAfford = new Dictionary<string, bool>();
private Vector2 scrollPosition = Vector2.zero;
private const float itemIconSize = 128f;
private const float itemWidth = 200f;
private const float itemHeight = 200f;
private const float spacing = 2f;
public const string Id = "dusher4.PEAKShop";
internal static Plugin Instance { get; private set; } = null;
internal static ManualLogSource Log { get; private set; } = null;
public static string Name => "PEAKSHOP";
public static string Version => "0.1.0";
private void StartInputDetection()
{
StopInputDetection();
_inputDetectionCoroutine = ((MonoBehaviour)this).StartCoroutine(InputDetectionCoroutine());
}
private void StopInputDetection()
{
if (_inputDetectionCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(_inputDetectionCoroutine);
_inputDetectionCoroutine = null;
}
}
private IEnumerator InputDetectionCoroutine()
{
while (true)
{
if (allowSummitShop)
{
bool flag = ((!useModifierKey.Value) ? Input.GetKey(openSummitSupplyShop.Value) : (Input.GetKey(modifierKey.Value) && Input.GetKey(openSummitSupplyShop.Value)));
if (flag && !_lastShopKeyState)
{
showShop = !showShop;
_cursorStateSet = false;
}
_lastShopKeyState = flag;
bool key = Input.GetKey((KeyCode)281);
if (key && !_lastDebugKeyState)
{
_debugMode = !_debugMode;
if (_debugMode)
{
playerCoins += 10;
InvalidateUICache();
Log.LogInfo((object)$"Debug mode enabled, added 10 coins. Total: {playerCoins}");
}
else
{
Log.LogInfo((object)"Debug mode disabled.");
}
}
_lastDebugKeyState = key;
}
yield return (object)new WaitForSeconds(0.1f);
}
}
private void TryPatchLuggage()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
try
{
_harmony.Patch((MethodBase)AccessTools.Method(typeof(GlobalEvents), "TriggerLuggageOpened", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "OnLuggageOpened", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
Log.LogError((object)("Failed to patch luggage: " + ex.Message));
}
}
public static void OnLuggageOpened(Luggage luggage, Character character)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance == (Object)null || !Instance.allowSummitShop)
{
return;
}
string luggageConfigKey = GetLuggageConfigKey(((Spawner)luggage).spawnPool, ((Object)((Component)luggage).gameObject).name);
if (!string.IsNullOrEmpty(luggageConfigKey) && Instance.luggageMinConfigs.TryGetValue(luggageConfigKey, out ConfigEntry<int> value) && Instance.luggageMaxConfigs.TryGetValue(luggageConfigKey, out ConfigEntry<int> value2))
{
int num = Random.Range(value.Value, value2.Value + 1);
Instance.playerCoins += num;
Instance.InvalidateUICache();
if (num > 0)
{
Instance.ShowCoinNotification(num);
Instance.PlayCoinSound();
}
}
}
private unsafe static string? GetLuggageConfigKey(SpawnPool luggageType, string gameObjectName)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (((int)luggageType == 32768 || (int)luggageType == 65536 || (int)luggageType == 131072) ? true : false)
{
return ((object)(*(SpawnPool*)(&luggageType))/*cast due to .constrained prefix*/).ToString();
}
if ((int)luggageType == 16384 || gameObjectName == "LuggageClimber")
{
return Instance.DetectCurrentBiomeOnDemand() + "_LuggageEpic";
}
if ((int)luggageType == 0)
{
string text = Instance.DetectCurrentBiomeOnDemand();
string text2 = ((gameObjectName == "LuggageClimber") ? "LuggageEpic" : gameObjectName);
return text + "_" + text2;
}
return null;
}
private string DetectCurrentBiomeOnDemand()
{
if (!string.IsNullOrEmpty(_cachedBiome))
{
return _cachedBiome;
}
try
{
MountainProgressHandler instance = Singleton<MountainProgressHandler>.Instance;
if (instance?.progressPoints != null)
{
for (int num = instance.progressPoints.Length - 1; num >= 0; num--)
{
if (instance.progressPoints[num].Reached)
{
_cachedBiome = ((object)Unsafe.As<BiomeType, BiomeType>(ref instance.progressPoints[num].biome)/*cast due to .constrained prefix*/).ToString();
return _cachedBiome;
}
}
}
Biome[] array = Object.FindObjectsByType<Biome>((FindObjectsSortMode)0);
if (array != null && array.Length > 0)
{
_cachedBiome = ((object)Unsafe.As<BiomeType, BiomeType>(ref array[0].biomeType)/*cast due to .constrained prefix*/).ToString();
return _cachedBiome;
}
_cachedBiome = "Unknown";
return _cachedBiome;
}
catch
{
_cachedBiome = "Unknown";
return _cachedBiome;
}
}
private IEnumerator InitializeAudioAndUI()
{
yield return (object)new WaitForSeconds(1f);
yield return LoadCoinSoundWithRetry();
SetupNotificationCanvas();
FindGameFont();
}
private IEnumerator LoadCoinSoundWithRetry()
{
int attempt = 0;
while (attempt < 3 && !IsAudioSystemReady())
{
attempt++;
yield return LoadCoinSound();
if (!IsAudioSystemReady())
{
Log.LogWarning((object)$"Audio loading attempt {attempt} failed, retrying...");
yield return (object)new WaitForSeconds(2f);
}
}
if (!IsAudioSystemReady())
{
Log.LogError((object)"Failed to load audio after all attempts.");
}
else
{
Log.LogInfo((object)"Audio system ready!");
}
}
private IEnumerator LoadCoinSound()
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
Log.LogInfo((object)("Looking for audio files in: " + directoryName));
string[] array = Directory.GetFiles(directoryName, "*.ogg", SearchOption.AllDirectories).Concat(Directory.GetFiles(directoryName, "*.wav", SearchOption.AllDirectories)).ToArray();
if (array.Length == 0)
{
Log.LogWarning((object)("No .wav or .ogg files found in " + directoryName + ". Audio will be disabled - shop will work without sound."));
yield break;
}
string text = array[0];
Log.LogInfo((object)("Loading audio from " + text));
string text2 = "file://" + Path.GetFullPath(text).Replace("\\", "/");
AudioType val = (AudioType)(text.EndsWith(".ogg") ? 14 : 20);
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text2, val);
try
{
yield return www.SendWebRequest();
if ((int)www.result != 1)
{
Log.LogError((object)("Failed to load audio: " + www.error));
yield break;
}
coinSoundClip = DownloadHandlerAudioClip.GetContent(www);
if ((Object)(object)coinSoundClip == (Object)null)
{
Log.LogError((object)"Failed to create audio clip.");
yield break;
}
audioHost = new GameObject("SummitSupplyShopAudioHost");
audioSource = audioHost.AddComponent<AudioSource>();
audioSource.clip = coinSoundClip;
audioSource.loop = false;
audioSource.playOnAwake = false;
audioSource.spatialBlend = 0f;
audioSource.dopplerLevel = 0f;
audioSource.rolloffMode = (AudioRolloffMode)1;
audioSource.minDistance = 1f;
audioSource.maxDistance = 500f;
audioSource.ignoreListenerPause = true;
audioSource.bypassEffects = false;
audioSource.bypassListenerEffects = false;
audioSource.bypassReverbZones = true;
AudioMixerGroup val2 = TryGetGameMixerGroup();
if ((Object)(object)val2 != (Object)null)
{
audioSource.outputAudioMixerGroup = val2;
}
Object.DontDestroyOnLoad((Object)(object)audioHost);
Log.LogInfo((object)"Coin sound loaded successfully.");
}
finally
{
((IDisposable)www)?.Dispose();
}
}
private static AudioMixerGroup TryGetGameMixerGroup()
{
AudioSource val = ((IEnumerable<AudioSource>)Object.FindObjectsByType<AudioSource>((FindObjectsSortMode)0)).FirstOrDefault((Func<AudioSource, bool>)((AudioSource a) => (Object)(object)a != (Object)null && ((Behaviour)a).isActiveAndEnabled && (Object)(object)a.outputAudioMixerGroup != (Object)null));
if (!((Object)(object)val != (Object)null))
{
return null;
}
return val.outputAudioMixerGroup;
}
private void SetupNotificationCanvas()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (!((Object)(object)notificationCanvas != (Object)null))
{
notificationCanvas = new GameObject("SummitSupplyShopNotificationCanvas");
Canvas val = notificationCanvas.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 999;
notificationCanvas.AddComponent<CanvasScaler>();
notificationCanvas.AddComponent<GraphicRaycaster>();
Object.DontDestroyOnLoad((Object)(object)notificationCanvas);
}
}
private void FindGameFont()
{
if ((Object)(object)_cachedGameFont != (Object)null)
{
gameFont = _cachedGameFont;
return;
}
try
{
_cachedGameFont = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset f)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
FaceInfo faceInfo = ((TMP_Asset)f).faceInfo;
return ((FaceInfo)(ref faceInfo)).familyName == "Daruma Drop One";
});
gameFont = _cachedGameFont;
}
catch (Exception ex)
{
Log.LogWarning((object)("Error finding game font: " + ex.Message));
}
}
private void ShowCoinNotification(int coinsGained)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (showCoinNotifications.Value)
{
if ((Object)(object)currentNotificationObj != (Object)null)
{
Object.Destroy((Object)(object)currentNotificationObj);
}
currentNotificationObj = new GameObject("CoinNotification");
currentNotificationObj.transform.SetParent(notificationCanvas.transform);
TextMeshProUGUI val = currentNotificationObj.AddComponent<TextMeshProUGUI>();
SetupCoinNotificationText(val, $"+{coinsGained} COINS");
RectTransform component = ((Component)val).GetComponent<RectTransform>();
component.sizeDelta = new Vector2(800f, 200f);
component.anchoredPosition = new Vector2(0f, 200f);
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
Object.Destroy((Object)(object)currentNotificationObj, 3f);
}
}
private void SetupCoinNotificationText(TextMeshProUGUI tmp, string message)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
((TMP_Text)tmp).text = message;
((TMP_Text)tmp).fontSize = coinNotificationSize.Value;
((TMP_Text)tmp).alignment = (TextAlignmentOptions)514;
((Graphic)tmp).color = ParseHexColor(coinNotificationColor.Value);
((Graphic)tmp).raycastTarget = false;
((TMP_Text)tmp).textWrappingMode = (TextWrappingModes)1;
((TMP_Text)tmp).fontStyle = (FontStyles)1;
if ((Object)(object)gameFont != (Object)null)
{
((TMP_Text)tmp).font = gameFont;
}
}
private Color ParseHexColor(string hexColor)
{
//IL_0056: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = hexColor.TrimStart('#');
int num = Convert.ToInt32(text.Substring(0, 2), 16);
int num2 = Convert.ToInt32(text.Substring(2, 2), 16);
int num3 = Convert.ToInt32(text.Substring(4, 2), 16);
return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f);
}
catch
{
Log.LogWarning((object)("Failed to parse hex color '" + hexColor + "', using yellow as fallback."));
return Color.yellow;
}
}
private bool IsAudioSystemReady()
{
if ((Object)(object)audioSource != (Object)null)
{
return (Object)(object)coinSoundClip != (Object)null;
}
return false;
}
private void PlayCoinSound()
{
if (IsAudioSystemReady())
{
audioSource.volume = Mathf.Clamp(coinSoundVolume.Value, 0f, 100f) / 100f;
audioSource.Play();
}
}
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("dusher4.PEAKShop");
BindConfig();
TryPatchLuggage();
BuildShopItems();
((MonoBehaviour)this).StartCoroutine(InitializeAudioAndUI());
InitializePhotonManager();
StartInputDetection();
((MonoBehaviour)this).StartCoroutine(HostStatusWatchdog());
PhotonNetwork.AddCallbackTarget((object)this);
SceneManager.activeSceneChanged += OnSceneChanged;
Log.LogInfo((object)("Plugin " + Name + " is loaded! Press Alt+B to open the shop."));
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
SceneManager.activeSceneChanged -= OnSceneChanged;
PhotonNetwork.RemoveCallbackTarget((object)this);
StopInputDetection();
}
private void OnSceneChanged(Scene oldScene, Scene newScene)
{
if (!persistCoinsBetweenRuns.Value && ((Scene)(ref newScene)).name == "Airport")
{
playerCoins = 0;
InvalidateUICache();
Log.LogInfo((object)"Coins reset to 0 at airport.");
}
_cachedBiome = null;
if (!IsAudioSystemReady())
{
((MonoBehaviour)this).StartCoroutine(LoadCoinSoundWithRetry());
}
}
private void BindConfig()
{
openSummitSupplyShop = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "OpenSummitSupplyShop", (KeyCode)98, "Key to open the summit supply shop");
useModifierKey = ((BaseUnityPlugin)this).Config.Bind<bool>("Keybinds", "UseModifierKey", true, "Whether to require a modifier key (Alt) to open shop");
modifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "ModifierKey", (KeyCode)308, "Modifier key to hold while pressing the shop key");
customItems = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomItems", "", "Custom items in CSV format: itemName,price,itemID");
coinSoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "CoinSoundVolume", 100f, "Volume level for coin sound (0 to 100)");
showCoinNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowCoinNotifications", true, "Show coin notification popups");
coinNotificationSize = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "CoinNotificationSize", 60, "Size of coin notification text");
coinNotificationColor = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "CoinNotificationColor", "#FFD700", "Color of coin notification text (hex format, e.g. #FFD700)");
persistCoinsBetweenRuns = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PersistCoinsBetweenRuns", false, "Keep coins between runs (false = reset to 0 at airport)");
CreateItemConfigs();
CreateLuggageConfigs();
LoadCustomItems();
}
private void CreateItemConfigs()
{
foreach (KeyValuePair<string, (int, ushort, string, bool)> allItem in allItems)
{
allItem.Deconstruct(out var key, out var value);
string text = key;
(int, ushort, string, bool) tuple = value;
string text2 = SanitizeConfigKey(text);
itemEnableConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", text2 + "_Enable", tuple.Item4, "Enable/disable " + text + " in shop");
itemPriceConfigs[text] = ((BaseUnityPlugin)this).Config.Bind<int>("Items", text2 + "_Price", tuple.Item1, "Price for " + text + " in coins");
}
}
private static string SanitizeConfigKey(string key)
{
return key.Replace("'", "");
}
private void CreateLuggageConfigs()
{
luggageMinConfigs["LuggageAncient"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageAncient_Min", 15, "Minimum coins from LuggageAncient");
luggageMaxConfigs["LuggageAncient"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageAncient_Max", 20, "Maximum coins from LuggageAncient");
luggageMinConfigs["LuggageCursed"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageCursed_Min", 15, "Minimum coins from LuggageCursed");
luggageMaxConfigs["LuggageCursed"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageCursed_Max", 20, "Maximum coins from LuggageCursed");
luggageMinConfigs["RespawnCoffin"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "RespawnCoffin_Min", 15, "Minimum coins from RespawnCoffin");
luggageMaxConfigs["RespawnCoffin"] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "RespawnCoffin_Max", 20, "Maximum coins from RespawnCoffin");
string[] array = new string[6] { "Shore", "Tropics", "Alpine", "Mesa", "Volcano", "Kiln" };
string[] array2 = new string[3] { "LuggageSmall", "LuggageBig", "LuggageEpic" };
string[] array3 = array;
foreach (string text in array3)
{
string[] array4 = array2;
foreach (string text2 in array4)
{
string text3 = text + "_" + text2;
var (num, num2) = defaultLuggageRanges[text][text2];
luggageMinConfigs[text3] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", text3 + "_Min", num, "Minimum coins from " + text2 + " in " + text);
luggageMaxConfigs[text3] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", text3 + "_Max", num2, "Maximum coins from " + text2 + " in " + text);
}
}
}
private void LoadCustomItems()
{
try
{
string value = customItems.Value;
if (string.IsNullOrEmpty(value))
{
return;
}
string[] array = value.Split(',');
if (array.Length % 3 != 0)
{
Log.LogWarning((object)"Custom items CSV format invalid.");
return;
}
int num = 0;
for (int i = 0; i + 2 < array.Length; i += 3)
{
string text = array[i].Trim();
if (int.TryParse(array[i + 1].Trim(), out var result) && ushort.TryParse(array[i + 2].Trim(), out var result2))
{
allItems[text] = (result, result2, text, true);
num++;
}
}
if (num > 0)
{
Log.LogInfo((object)$"Loaded {num} custom items.");
}
}
catch (Exception ex)
{
Log.LogError((object)("Error loading custom items: " + ex.Message));
}
}
private void BuildShopItems()
{
shopItems.Clear();
foreach (var (key, tuple2) in allItems)
{
if (itemEnableConfigs.TryGetValue(key, out ConfigEntry<bool> value) ? value.Value : tuple2.Item4)
{
int num;
if (!itemPriceConfigs.TryGetValue(key, out ConfigEntry<int> value2))
{
(num, _, _, _) = tuple2;
}
else
{
num = value2.Value;
}
int item = num;
shopItems[key] = (item, tuple2.Item2, tuple2.Item3);
}
}
}
private void BuyItem(string itemName, int price, ushort itemId)
{
if (allowSummitShop && playerCoins >= price)
{
playerCoins -= price;
InvalidateUICache();
SpawnItemForPlayer(itemId);
PlayCoinSound();
}
}
private void SpawnItemForPlayer(ushort itemId)
{
try
{
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null)
{
Log.LogWarning((object)"Local character is null, cannot spawn item.");
return;
}
string prefabNameFromItemId = GetPrefabNameFromItemId(itemId);
if (string.IsNullOrEmpty(prefabNameFromItemId))
{
Log.LogError((object)$"Could not find prefab name for itemID {itemId}.");
return;
}
if (TryGiveItemToInventory(localCharacter, itemId, prefabNameFromItemId))
{
Log.LogInfo((object)$"Item {prefabNameFromItemId} (ID: {itemId}) added to inventory/backpack.");
return;
}
localCharacter.refs.items.SpawnItemInHand(prefabNameFromItemId);
Log.LogInfo((object)$"Item {prefabNameFromItemId} (ID: {itemId}) spawned above head (inventory full).");
}
catch (Exception ex)
{
Log.LogError((object)("Failed to spawn item: " + ex.Message));
}
}
private bool TryGiveItemToInventory(Character character, ushort itemId, string itemPrefabName)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
try
{
Player player = character.player;
if ((Object)(object)player == (Object)null)
{
return false;
}
if (BackpackSlotItemIds.Contains(itemId))
{
return false;
}
ItemSlot val = default(ItemSlot);
if (HasPocketSpace(player) && player.AddItem(itemId, (ItemInstanceData)null, ref val) && val != null && val.itemSlotID <= 2)
{
return true;
}
if (TryGetBackpackFreeSlot(player, out BackpackData data, out byte freeIndex))
{
Item val2 = default(Item);
if (!ItemDatabase.TryGetItem(itemId, ref val2))
{
return false;
}
ItemInstanceData val3 = new ItemInstanceData(Guid.NewGuid());
ItemInstanceDataHandler.AddInstanceData(val3);
data.AddItem(val2, val3, freeIndex);
SyncInventory(player);
Log.LogInfo((object)$"Item {itemPrefabName} added to backpack slot {freeIndex}.");
return true;
}
return false;
}
catch (Exception ex)
{
Log.LogError((object)("Error trying to give item to inventory: " + ex.Message));
return false;
}
}
private static void SyncInventory(Player player)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
InventorySyncData val = default(InventorySyncData);
((InventorySyncData)(ref val))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
{
IBinarySerializable.ToManagedArray<InventorySyncData>(val),
false
});
}
private string? GetPrefabNameFromItemId(ushort itemId)
{
try
{
Item val = default(Item);
if (ItemDatabase.TryGetItem(itemId, ref val))
{
return ((Object)val).name;
}
foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)SingletonAsset<ItemDatabase>.Instance).Objects)
{
if (@object.itemID == itemId)
{
return ((Object)@object).name;
}
}
Log.LogWarning((object)$"Item with ID {itemId} not found in database.");
return null;
}
catch (Exception ex)
{
Log.LogError((object)$"Error looking up item by ID {itemId}: {ex.Message}");
return null;
}
}
private static bool HasPocketSpace(Player player)
{
ItemSlot[] itemSlots = player.itemSlots;
foreach (ItemSlot val in itemSlots)
{
if (val.IsEmpty())
{
return true;
}
}
return false;
}
private static bool TryGetBackpackFreeSlot(Player player, out BackpackData data, out byte freeIndex)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
data = null;
freeIndex = byte.MaxValue;
if (player.backpackSlot == null || (int)player.backpackSlot.backpackType == 0 || ((ItemSlot)player.backpackSlot).data == null)
{
return false;
}
if (!((ItemSlot)player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref data) || data == null)
{
if (PhotonNetwork.IsMasterClient)
{
((ItemSlot)player.backpackSlot).data.RegisterNewEntry<BackpackData>((DataEntryKey)7);
((ItemSlot)player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref data);
}
if (data == null)
{
return false;
}
}
for (byte b = 0; b < data.itemSlots.Length; b++)
{
if (data.itemSlots[b].IsEmpty())
{
freeIndex = b;
return true;
}
}
return false;
}
private void InitializePhotonManager()
{
if (PhotonCustomPropsUtilsPlugin.IsReady)
{
SetupPhotonManager();
}
else
{
PhotonCustomPropsUtilsPlugin.OnReady += SetupPhotonManager;
}
}
private void SetupPhotonManager()
{
_propsManager = PhotonCustomPropsUtilsPlugin.GetManager("dusher4.PEAKShop");
_propsManager.RegisterOnJoinedRoom((Action<Player>)delegate
{
CheckHostStatus();
});
_propsManager.RegisterRoomProperty<string>("shopConfig", (RoomEventType)2, (Action<string>)delegate(string configData)
{
if (!IsHost && !string.IsNullOrEmpty(configData))
{
UnpackConfigData(configData);
allowSummitShop = true;
BuildShopItems();
}
});
}
private void CheckHostStatus()
{
if (!PhotonNetwork.InRoom)
{
return;
}
if (PhotonNetwork.IsMasterClient)
{
if (!IsHost)
{
IsHost = true;
allowSummitShop = true;
PublishHostConfig();
}
}
else if (IsHost)
{
IsHost = false;
allowSummitShop = false;
}
}
private void PublishHostConfig()
{
if (PhotonNetwork.IsMasterClient && _propsManager != null)
{
_propsManager.SetRoomProperty("shopConfig", (object)PackConfigData());
}
}
private IEnumerator HostStatusWatchdog()
{
WaitForSeconds wait = new WaitForSeconds(2f);
while (true)
{
CheckHostStatus();
yield return wait;
}
}
private string PackConfigData()
{
StringBuilder stringBuilder = new StringBuilder();
string key;
foreach (KeyValuePair<string, ConfigEntry<bool>> itemEnableConfig in itemEnableConfigs)
{
itemEnableConfig.Deconstruct(out key, out var value);
string arg = key;
ConfigEntry<bool> val = value;
stringBuilder.AppendLine($"ENABLE_{arg}={val.Value}");
}
ConfigEntry<int> value2;
foreach (KeyValuePair<string, ConfigEntry<int>> itemPriceConfig in itemPriceConfigs)
{
itemPriceConfig.Deconstruct(out key, out value2);
string arg2 = key;
ConfigEntry<int> val2 = value2;
stringBuilder.AppendLine($"PRICE_{arg2}={val2.Value}");
}
foreach (KeyValuePair<string, ConfigEntry<int>> luggageMinConfig in luggageMinConfigs)
{
luggageMinConfig.Deconstruct(out key, out value2);
string arg3 = key;
ConfigEntry<int> val3 = value2;
stringBuilder.AppendLine($"MIN_{arg3}={val3.Value}");
}
foreach (KeyValuePair<string, ConfigEntry<int>> luggageMaxConfig in luggageMaxConfigs)
{
luggageMaxConfig.Deconstruct(out key, out value2);
string arg4 = key;
ConfigEntry<int> val4 = value2;
stringBuilder.AppendLine($"MAX_{arg4}={val4.Value}");
}
stringBuilder.AppendLine($"PERSIST_COINS={persistCoinsBetweenRuns.Value}");
return Convert.ToBase64String(Encoding.UTF8.GetBytes(stringBuilder.ToString()));
}
private void UnpackConfigData(string configData)
{
try
{
string text = Encoding.UTF8.GetString(Convert.FromBase64String(configData));
string[] array = text.Split('\n');
foreach (string text2 in array)
{
if (string.IsNullOrWhiteSpace(text2))
{
continue;
}
string[] array2 = text2.Split(new char[1] { '=' }, 2);
if (array2.Length != 2)
{
continue;
}
string text3 = array2[0];
string text4 = array2[1];
bool result5;
if (text3.StartsWith("ENABLE_"))
{
string key = text3.Substring("ENABLE_".Length);
if (bool.TryParse(text4, out var result) && itemEnableConfigs.ContainsKey(key))
{
itemEnableConfigs[key].Value = result;
}
}
else if (text3.StartsWith("PRICE_"))
{
string key2 = text3.Substring("PRICE_".Length);
if (int.TryParse(text4, out var result2) && itemPriceConfigs.ContainsKey(key2))
{
itemPriceConfigs[key2].Value = result2;
}
}
else if (text3.StartsWith("MIN_"))
{
string key3 = text3.Substring("MIN_".Length);
if (int.TryParse(text4, out var result3) && luggageMinConfigs.ContainsKey(key3))
{
luggageMinConfigs[key3].Value = result3;
}
}
else if (text3.StartsWith("MAX_"))
{
string key4 = text3.Substring("MAX_".Length);
if (int.TryParse(text4, out var result4) && luggageMaxConfigs.ContainsKey(key4))
{
luggageMaxConfigs[key4].Value = result4;
}
}
else if (text3 == "PERSIST_COINS" && bool.TryParse(text4, out result5))
{
persistCoinsBetweenRuns.Value = result5;
}
}
}
catch (Exception ex)
{
Log.LogError((object)("Error unpacking config: " + ex.Message));
}
}
public void OnJoinedRoom()
{
CheckHostStatus();
}
public void OnLeftRoom()
{
IsHost = false;
allowSummitShop = false;
}
public void OnMasterClientSwitched(Player newMasterClient)
{
CheckHostStatus();
}
public void OnPlayerEnteredRoom(Player newPlayer)
{
if (IsHost && _propsManager != null)
{
PublishHostConfig();
}
}
public void OnPlayerLeftRoom(Player otherPlayer)
{
}
public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
{
}
public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
{
}
public void OnConnected()
{
}
public void OnConnectedToMaster()
{
}
public void OnDisconnected(DisconnectCause cause)
{
}
public void OnRegionListReceived(RegionHandler regionHandler)
{
}
public void OnCustomAuthenticationResponse(Dictionary<string, object> data)
{
}
public void OnCustomAuthenticationFailed(string debugMessage)
{
}
public void OnFriendListUpdate(List<FriendInfo> friendList)
{
}
public void OnCreatedRoom()
{
}
public void OnCreateRoomFailed(short returnCode, string message)
{
}
public void OnJoinRoomFailed(short returnCode, string message)
{
}
public void OnJoinRandomFailed(short returnCode, string message)
{
}
private void InvalidateUICache()
{
_uiCacheValid = false;
_cachedCanAfford.Clear();
}
private void InitializeGUIStyles()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
if (!_guiStylesInitialized)
{
_disabledButtonStyle = new GUIStyle(GUI.skin.button);
_disabledButtonStyle.normal.textColor = new Color(0.3f, 0.3f, 0.3f, 0.8f);
_disabledButtonStyle.hover.textColor = new Color(0.3f, 0.3f, 0.3f, 0.8f);
_disabledButtonStyle.active.textColor = new Color(0.3f, 0.3f, 0.3f, 0.8f);
_disabledButtonStyle.normal.background = MakeTexture(2, 2, new Color(0.2f, 0.2f, 0.2f, 0.6f));
_enabledButtonStyle = new GUIStyle(GUI.skin.button);
_enabledButtonStyle.normal.textColor = Color.white;
_enabledButtonStyle.hover.textColor = Color.white;
_enabledButtonStyle.active.textColor = Color.white;
_guiStylesInitialized = true;
}
}
private void UpdateUICache()
{
if (_uiCacheValid)
{
return;
}
_cachedItemsPerRow = Mathf.Max(3, Mathf.FloorToInt(((float)Screen.width - 100f) / 202f));
_cachedTotalItems = shopItems.Count;
_cachedRows = Mathf.CeilToInt((float)_cachedTotalItems / (float)_cachedItemsPerRow);
_cachedTotalWidth = 202f * (float)_cachedItemsPerRow - 2f;
_cachedTotalHeight = 202f * (float)_cachedRows - 2f;
_cachedTotalWindowWidth = _cachedTotalWidth + 20f + 20f;
_cachedTotalWindowHeight = Mathf.Min(_cachedTotalHeight + 80f, (float)Screen.height - 100f);
_cachedWindowX = Mathf.Clamp(((float)Screen.width - _cachedTotalWindowWidth) / 2f, 10f, (float)Screen.width - _cachedTotalWindowWidth - 10f);
_cachedWindowY = Mathf.Clamp(((float)Screen.height - _cachedTotalWindowHeight) / 2f, 10f, (float)Screen.height - _cachedTotalWindowHeight - 10f);
foreach (var (key, tuple2) in shopItems)
{
_cachedCanAfford[key] = playerCoins >= tuple2.Item1;
}
_uiCacheValid = true;
}
private void OnGUI()
{
//IL_0024: 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)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
if (!showShop)
{
if (_cursorStateSet)
{
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
_cursorStateSet = false;
}
return;
}
if ((int)Cursor.lockState != 0 || !Cursor.visible)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
UpdateUICache();
InitializeGUIStyles();
GUI.Box(new Rect(_cachedWindowX, _cachedWindowY, _cachedTotalWindowWidth, _cachedTotalWindowHeight), "Summit Supply Shop");
TextAnchor alignment = GUI.skin.label.alignment;
GUI.skin.label.alignment = (TextAnchor)1;
GUI.Label(new Rect(_cachedWindowX + 10f, _cachedWindowY + 30f, _cachedTotalWindowWidth - 20f, 20f), $"Your Coins: {playerCoins}");
GUI.Label(new Rect(_cachedWindowX + 10f, _cachedWindowY + 50f, _cachedTotalWindowWidth - 20f, 20f), $"Items: {_cachedTotalItems}");
GUI.skin.label.alignment = alignment;
if (GUI.Button(new Rect(_cachedWindowX + _cachedTotalWindowWidth - 110f, _cachedWindowY + 30f, 100f, 30f), "Close"))
{
showShop = false;
}
Rect val = default(Rect);
((Rect)(ref val))..ctor(_cachedWindowX + 10f, _cachedWindowY + 80f, _cachedTotalWidth, _cachedTotalWindowHeight - 80f - 10f);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(0f, 0f, _cachedTotalWidth - 20f, _cachedTotalHeight);
scrollPosition = GUI.BeginScrollView(val, scrollPosition, val2);
int num = 0;
for (int i = 0; i < _cachedRows; i++)
{
for (int j = 0; j < _cachedItemsPerRow; j++)
{
if (num >= _cachedTotalItems)
{
break;
}
KeyValuePair<string, (int, ushort, string)> keyValuePair = shopItems.ElementAt(num);
float x = (float)j * 202f;
float y = (float)i * 202f;
DrawItemButton(keyValuePair.Key, keyValuePair.Value.Item1, keyValuePair.Value.Item2, x, y, 200f, 200f);
num++;
}
}
GUI.EndScrollView();
}
private void DrawItemButton(string itemName, int price, ushort itemId, float x, float y, float width, float height)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
GUI.Box(new Rect(x, y, width, height), "");
Texture2D itemIcon = GetItemIcon(itemId);
float num = x + (width - 128f) / 2f;
float num2 = y + 5f;
if ((Object)(object)itemIcon != (Object)null)
{
GUI.DrawTexture(new Rect(num, num2, 128f, 128f), (Texture)(object)itemIcon);
}
else
{
GUI.Box(new Rect(num, num2, 128f, 128f), "?");
}
string text = ((itemName.Length > 30) ? (itemName.Substring(0, 30) + "...") : itemName);
float num3 = y + 128f + 8f;
TextAnchor alignment = GUI.skin.label.alignment;
GUI.skin.label.alignment = (TextAnchor)1;
GUI.Label(new Rect(x + 2f, num3, width - 4f, 24f), text);
GUI.Label(new Rect(x + 2f, num3 + 12f, width - 4f, 24f), $"{price} coins");
GUI.skin.label.alignment = alignment;
bool value;
GUIStyle val = ((_cachedCanAfford.TryGetValue(itemName, out value) ? value : (playerCoins >= price)) ? _enabledButtonStyle : _disabledButtonStyle);
if (GUI.Button(new Rect(x + 2f, y + height - 26f, width - 4f, 30f), "Buy", val))
{
BuyItem(itemName, price, itemId);
}
}
private Texture2D? GetItemIcon(ushort itemId)
{
if (_itemIconCache.TryGetValue(itemId, out Texture2D value))
{
return value;
}
try
{
Item val = default(Item);
if (ItemDatabase.TryGetItem(itemId, ref val))
{
Texture2D icon = val.UIData.GetIcon();
if ((Object)(object)icon != (Object)null)
{
_itemIconCache[itemId] = icon;
}
return icon;
}
}
catch
{
}
return null;
}
private static Texture2D MakeTexture(int width, int height, Color color)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Color[] array = (Color[])(object)new Color[width * height];
for (int i = 0; i < array.Length; i++)
{
array[i] = color;
}
Texture2D val = new Texture2D(width, height);
val.SetPixels(array);
val.Apply();
return val;
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}