Decompiled source of Summit Supply Shop v1.0.1

tony4twentys-Summit Supply Shop.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Summit Supply Shop")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Summit Supply Shop")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d7cd2170-3a27-4456-acd7-52eba587f343")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace tony4twentys.Summit_Supply_Shop
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("tony4twentys.Summit_Supply_Shop", "Summit Supply Shop", "1.0.1")]
	public class SummitSupplyShopPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <InitializeAudioAndUI>d__83 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public SummitSupplyShopPlugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitializeAudioAndUI>d__83(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = <>4__this.LoadCoinSoundWithRetry();
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.SetupNotificationCanvas();
					<>4__this.FindGameFont();
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <InputDetectionCoroutine>d__60 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public SummitSupplyShopPlugin <>4__this;

			private bool <currentShopKeyState>5__1;

			private bool <currentDebugKeyState>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InputDetectionCoroutine>d__60(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Expected O, but got Unknown
				//IL_0071: 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)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<>4__this.allowSummitShop)
				{
					<currentShopKeyState>5__1 = ((!<>4__this.useModifierKey.Value) ? Input.GetKey(<>4__this.openSummitSupplyShop.Value) : (Input.GetKey(<>4__this.modifierKey.Value) && Input.GetKey(<>4__this.openSummitSupplyShop.Value)));
					if (<currentShopKeyState>5__1 && !<>4__this._lastShopKeyState)
					{
						<>4__this.showShop = !<>4__this.showShop;
						<>4__this._cursorStateSet = false;
					}
					<>4__this._lastShopKeyState = <currentShopKeyState>5__1;
					<currentDebugKeyState>5__2 = Input.GetKey((KeyCode)281);
					if (<currentDebugKeyState>5__2 && !<>4__this._lastDebugKeyState)
					{
						<>4__this._debugMode = !<>4__this._debugMode;
						if (<>4__this._debugMode)
						{
							<>4__this.playerCoins += 10;
							<>4__this.InvalidateUICache();
							((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Debug mode enabled, added 10 coins. Total: {<>4__this.playerCoins} ===");
						}
						else
						{
							((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Debug mode disabled ===");
						}
					}
					<>4__this._lastDebugKeyState = <currentDebugKeyState>5__2;
				}
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadCoinSound>d__85 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public SummitSupplyShopPlugin <>4__this;

			private string <pluginLocation>5__1;

			private string <pluginDirectory>5__2;

			private string[] <audioFiles>5__3;

			private string <soundFile>5__4;

			private string <url>5__5;

			private AudioType <audioType>5__6;

			private UnityWebRequest <www>5__7;

			private AudioMixerGroup <gameMixerGroup>5__8;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadCoinSound>d__85(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<pluginLocation>5__1 = null;
				<pluginDirectory>5__2 = null;
				<audioFiles>5__3 = null;
				<soundFile>5__4 = null;
				<url>5__5 = null;
				<www>5__7 = null;
				<gameMixerGroup>5__8 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c8: Invalid comparison between Unknown and I4
				//IL_0170: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Expected O, but got Unknown
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						break;
					case 0:
						<>1__state = -1;
						<pluginLocation>5__1 = ((BaseUnityPlugin)<>4__this).Info.Location;
						<pluginDirectory>5__2 = Path.GetDirectoryName(<pluginLocation>5__1);
						((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)("=== SUMMIT SUPPLY SHOP: Looking for audio files in: " + <pluginDirectory>5__2 + " ==="));
						<audioFiles>5__3 = Directory.GetFiles(<pluginDirectory>5__2, "*.ogg", SearchOption.AllDirectories).Concat(Directory.GetFiles(<pluginDirectory>5__2, "*.wav", SearchOption.AllDirectories)).ToArray();
						if (<audioFiles>5__3.Length == 0)
						{
							((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)("=== SUMMIT SUPPLY SHOP: No .wav or .ogg files found in " + <pluginDirectory>5__2 + " ==="));
							((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Audio will be disabled - shop will work without sound ===");
							result = false;
							break;
						}
						<soundFile>5__4 = <audioFiles>5__3[0];
						((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)("=== SUMMIT SUPPLY SHOP: Loading audio from " + <soundFile>5__4 + " ==="));
						<url>5__5 = "file://" + Path.GetFullPath(<soundFile>5__4).Replace("\\", "/");
						<audioType>5__6 = (AudioType)(<soundFile>5__4.EndsWith(".ogg") ? 14 : 20);
						<www>5__7 = UnityWebRequestMultimedia.GetAudioClip(<url>5__5, <audioType>5__6);
						<>1__state = -3;
						<>2__current = <www>5__7.SendWebRequest();
						<>1__state = 1;
						result = true;
						break;
					case 1:
						<>1__state = -3;
						if ((int)<www>5__7.result != 1)
						{
							((BaseUnityPlugin)<>4__this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Failed to load audio: " + <www>5__7.error + " ==="));
							result = false;
						}
						else
						{
							<>4__this.coinSoundClip = DownloadHandlerAudioClip.GetContent(<www>5__7);
							if (!((Object)(object)<>4__this.coinSoundClip == (Object)null))
							{
								<>4__this.audioHost = new GameObject("SummitSupplyShopAudioHost");
								<>4__this.audioSource = <>4__this.audioHost.AddComponent<AudioSource>();
								<>4__this.audioSource.clip = <>4__this.coinSoundClip;
								<>4__this.audioSource.loop = false;
								<>4__this.audioSource.playOnAwake = false;
								<>4__this.audioSource.spatialBlend = 0f;
								<>4__this.audioSource.dopplerLevel = 0f;
								<>4__this.audioSource.rolloffMode = (AudioRolloffMode)1;
								<>4__this.audioSource.minDistance = 1f;
								<>4__this.audioSource.maxDistance = 500f;
								<>4__this.audioSource.ignoreListenerPause = true;
								<>4__this.audioSource.bypassEffects = false;
								<>4__this.audioSource.bypassListenerEffects = false;
								<>4__this.audioSource.bypassReverbZones = true;
								<gameMixerGroup>5__8 = TryGetGameMixerGroup();
								if ((Object)(object)<gameMixerGroup>5__8 != (Object)null)
								{
									<>4__this.audioSource.outputAudioMixerGroup = <gameMixerGroup>5__8;
								}
								Object.DontDestroyOnLoad((Object)(object)<>4__this.audioHost);
								((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Coin sound loaded successfully ===");
								<gameMixerGroup>5__8 = null;
								<>m__Finally1();
								<www>5__7 = null;
								result = false;
								break;
							}
							((BaseUnityPlugin)<>4__this).Logger.LogError((object)"=== SUMMIT SUPPLY SHOP: Failed to create audio clip ===");
							result = false;
						}
						<>m__Finally1();
						break;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<www>5__7 != null)
				{
					((IDisposable)<www>5__7).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadCoinSoundWithRetry>d__84 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public SummitSupplyShopPlugin <>4__this;

			private int <maxAttempts>5__1;

			private int <attempt>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadCoinSoundWithRetry>d__84(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<maxAttempts>5__1 = 3;
					<attempt>5__2 = 0;
					break;
				case 1:
					<>1__state = -1;
					if (!<>4__this.IsAudioSystemReady())
					{
						((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)$"=== SUMMIT SUPPLY SHOP: Audio loading attempt {<attempt>5__2} failed, retrying... ===");
						<>2__current = (object)new WaitForSeconds(2f);
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<attempt>5__2 < <maxAttempts>5__1 && !<>4__this.IsAudioSystemReady())
				{
					<attempt>5__2++;
					<>2__current = <>4__this.LoadCoinSound();
					<>1__state = 1;
					return true;
				}
				if (!<>4__this.IsAudioSystemReady())
				{
					((BaseUnityPlugin)<>4__this).Logger.LogError((object)"=== SUMMIT SUPPLY SHOP: Failed to load audio after all attempts ===");
				}
				else
				{
					((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Audio system ready! ===");
				}
				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();
			}
		}

		public static SummitSupplyShopPlugin Instance;

		private Harmony harmony;

		private PhotonScopedManager photonManager;

		public bool IsHost = false;

		public bool allowSummitShop = false;

		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 Dictionary<string, ConfigEntry<bool>> itemEnableConfigs = new Dictionary<string, ConfigEntry<bool>>();

		private Dictionary<string, ConfigEntry<int>> itemPriceConfigs = new Dictionary<string, ConfigEntry<int>>();

		private Dictionary<string, ConfigEntry<int>> luggageMinConfigs = new Dictionary<string, ConfigEntry<int>>();

		private Dictionary<string, ConfigEntry<int>> luggageMaxConfigs = new Dictionary<string, ConfigEntry<int>>();

		private 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 bool showShop = false;

		private int playerCoins = 0;

		private bool _debugMode = false;

		private string _cachedBiome = null;

		private Dictionary<ushort, Texture2D> _itemIconCache = new Dictionary<ushort, Texture2D>();

		private TMP_FontAsset _cachedGameFont = null;

		private Coroutine _inputDetectionCoroutine = null;

		private bool _lastShopKeyState = false;

		private bool _lastDebugKeyState = false;

		private bool _cursorStateSet = false;

		private GUIStyle _disabledButtonStyle = null;

		private GUIStyle _enabledButtonStyle = null;

		private bool _guiStylesInitialized = false;

		private bool _uiCacheValid = false;

		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 Dictionary<string, bool> _cachedCanAfford = new Dictionary<string, bool>();

		private GameObject audioHost;

		private AudioSource audioSource;

		private AudioClip coinSoundClip;

		private GameObject notificationCanvas;

		private GameObject currentNotificationObj;

		private TMP_FontAsset gameFont;

		private Dictionary<string, (int price, ushort itemId, string itemName, bool enabledByDefault)> allItems = new Dictionary<string, (int, ushort, string, bool)>
		{
			{
				"Airplane Food",
				(15, 0, "Airplane Food", true)
			},
			{
				"Aloe Vera",
				(5, 101, "Aloe Vera", true)
			},
			{
				"Anti-Rope Spool",
				(25, 1, "Anti-Rope Spool", true)
			},
			{
				"Antidote",
				(25, 2, "Antidote", true)
			},
			{
				"Red Crispberry",
				(5, 4, "Red Crispberry", true)
			},
			{
				"Yellow Crispberry",
				(7, 5, "Yellow Crispberry", true)
			},
			{
				"Backpack",
				(25, 6, "Backpack", true)
			},
			{
				"Balloon",
				(7, 105, "Balloon", true)
			},
			{
				"Balloon Bunch",
				(18, 37, "Balloon Bunch", true)
			},
			{
				"Bandages",
				(5, 7, "Bandages", true)
			},
			{
				"Blue Berrynana",
				(10, 9, "Blue Berrynana", true)
			},
			{
				"Brown Berrynana",
				(10, 10, "Brown Berrynana", true)
			},
			{
				"Yellow Berrynana",
				(5, 12, "Yellow Berrynana", true)
			},
			{
				"Bounce Fungus",
				(5, 79, "Bounce Fungus", true)
			},
			{
				"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)
			},
			{
				"Cure-All",
				(20, 24, "Cure-All", true)
			},
			{
				"Cursed Skull",
				(5, 25, "Cursed Skull", true)
			},
			{
				"Dynamite",
				(5, 106, "Dynamite", true)
			},
			{
				"Energy Drink",
				(5, 27, "Energy Drink", true)
			},
			{
				"First Aid Kit",
				(10, 29, "First Aid Kit", true)
			},
			{
				"Flare",
				(1, 32, "Flare", true)
			},
			{
				"Frisbee",
				(1, 99, "Frisbee", true)
			},
			{
				"Granola Bar",
				(7, 33, "Granola Bar", true)
			},
			{
				"Blowgun",
				(10, 70, "Blowgun", true)
			},
			{
				"Remedy Fungus",
				(10, 90, "Remedy Fungus", true)
			},
			{
				"Heat Pack",
				(5, 35, "Heat Pack", true)
			},
			{
				"Coconut",
				(4, 36, "Coconut", true)
			},
			{
				"Coconut Half",
				(2, 55, "Coconut Half", true)
			},
			{
				"Honeycomb",
				(7, 38, "Honeycomb", true)
			},
			{
				"Purple Kingberry",
				(10, 40, "Purple Kingberry", true)
			},
			{
				"Lantern",
				(5, 42, "Lantern", true)
			},
			{
				"Faerie Lantern",
				(15, 43, "Faerie Lantern", true)
			},
			{
				"Lollipop",
				(7, 44, "Lollipop", true)
			},
			{
				"Magic Bean",
				(7, 45, "Magic Bean", true)
			},
			{
				"Marshmallow",
				(7, 46, "Marshmallow", true)
			},
			{
				"Medicinal Root",
				(5, 81, "Medicinal Root", true)
			},
			{
				"Chubby Mushroom",
				(5, 83, "Chubby Mushroom", true)
			},
			{
				"Clustershroom",
				(5, 88, "Clustershroom", true)
			},
			{
				"Bugleshroom",
				(5, 93, "Bugleshroom", true)
			},
			{
				"Buttonshroom",
				(5, 102, "Buttonshroom", true)
			},
			{
				"Napberry",
				(10, 110, "Napberry", true)
			},
			{
				"Big Egg",
				(10, 57, "Big Egg", true)
			},
			{
				"Pandoras Lunchbox",
				(25, 58, "Pandoras Lunchbox", true)
			},
			{
				"Parasol",
				(10, 98, "Parasol", true)
			},
			{
				"Scorchberry",
				(5, 60, "Scorchberry", true)
			},
			{
				"Pirates Compass",
				(10, 61, "Pirates Compass", true)
			},
			{
				"Portable Stove",
				(10, 62, "Portable Stove", true)
			},
			{
				"Rescue Hook",
				(25, 100, "Rescue Hook", 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 Cannon",
				(10, 107, "Scout Cannon", true)
			},
			{
				"Scout Cookies",
				(15, 66, "Scout Cookies", true)
			},
			{
				"Scout Effigy",
				(25, 67, "Scout Effigy", true)
			},
			{
				"Shelf Fungus",
				(10, 68, "Shelf Fungus", true)
			},
			{
				"Sports Drink",
				(10, 71, "Sports Drink", true)
			},
			{
				"Sunscreen",
				(10, 104, "Sunscreen", true)
			},
			{
				"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)
			},
			{
				"Beehive",
				(20, 8, "Beehive", false)
			},
			{
				"Roasted Chicken",
				(10, 114, "Roasted Chicken", false)
			},
			{
				"Egg",
				(10, 26, "Egg", false)
			},
			{
				"Ancient Idol",
				(50, 47, "Ancient Idol", false)
			},
			{
				"Glowshroom",
				(0, 51, "Glowshroom", false)
			},
			{
				"Strange Gem",
				(0, 112, "Strange Gem", false)
			},
			{
				"Gold Prickleberry",
				(0, 103, "Gold Prickleberry", false)
			},
			{
				"Red Prickleberry",
				(0, 108, "Red Prickleberry", false)
			},
			{
				"Megaphone",
				(0, 78, "Megaphone", false)
			},
			{
				"Green Kingberry",
				(0, 56, "Green Kingberry", false)
			},
			{
				"Yellow Kingberry",
				(0, 41, "Yellow Kingberry", false)
			},
			{
				"Pink Berrynana",
				(0, 11, "Pink Berrynana", false)
			},
			{
				"Stone",
				(0, 72, "Stone", false)
			},
			{
				"Stick",
				(0, 28, "Stick", false)
			},
			{
				"Poisonous Clustershroom",
				(0, 84, "Poisonous Clustershroom", false)
			},
			{
				"Poisonous Bugleshroom",
				(0, 89, "Poisonous Bugleshroom", false)
			},
			{
				"Poisonous Buttonshroom",
				(0, 97, "Poisonous Buttonshroom", false)
			},
			{
				"Passport",
				(0, 59, "Passport", false)
			},
			{
				"Conch",
				(0, 69, "Conch", false)
			},
			{
				"Torch",
				(0, 109, "Torch", false)
			},
			{
				"Scorpion",
				(0, 111, "Scorpion", false)
			},
			{
				"Seagull Flag",
				(0, 30, "Seagull Flag", false)
			},
			{
				"Turtle Flag",
				(0, 31, "Turtle Flag", false)
			},
			{
				"Compass",
				(0, 23, "Compass", false)
			},
			{
				"Scoutmasters Bugle",
				(0, 77, "Scoutmasters Bugle", false)
			},
			{
				"Cactus Ball",
				(0, 48, "Cactus Ball", false)
			},
			{
				"Bing Bong",
				(0, 13, "Bing Bong", false)
			},
			{
				"Binoculars",
				(0, 14, "Binoculars", false)
			},
			{
				"Blue Berrynana Peel",
				(0, 91, "Blue Berrynana Peel", false)
			},
			{
				"Brown Berrynana Peel",
				(0, 92, "Brown Berrynana Peel", false)
			},
			{
				"Pink Berrynana Peel",
				(0, 39, "Pink Berrynana Peel", false)
			},
			{
				"Tick",
				(0, 95, "Tick", false)
			},
			{
				"Yellow Berrynana Peel",
				(0, 94, "Yellow Berrynana Peel", false)
			},
			{
				"Green Crispberry",
				(0, 3, "Green Crispberry", false)
			},
			{
				"Guidebook",
				(0, 34, "Guidebook", false)
			},
			{
				"Scroll",
				(0, 49, "Scroll", false)
			},
			{
				"Torn Page Blank",
				(0, 80, "Torn Page Blank", false)
			},
			{
				"Torn Page 1",
				(0, 50, "Torn Page 1", false)
			},
			{
				"Torn Page 2",
				(0, 82, "Torn Page 2", false)
			},
			{
				"Torn Page 3",
				(0, 52, "Torn Page 3", false)
			},
			{
				"Torn Page 4",
				(0, 53, "Torn Page 4", false)
			},
			{
				"Torn Page 5",
				(0, 85, "Torn Page 5", false)
			},
			{
				"Torn Page 6",
				(0, 86, "Torn Page 6", false)
			},
			{
				"Torn Page 7",
				(0, 87, "Torn Page 7", false)
			},
			{
				"Torn Page 8",
				(0, 54, "Torn Page 8", false)
			},
			{
				"Torn Page 9",
				(0, 96, "Torn Page 9", false)
			}
		};

		private Dictionary<string, (int price, ushort itemId, string itemName)> shopItems = new Dictionary<string, (int, ushort, string)>();

		private Vector2 scrollPosition = Vector2.zero;

		private float itemIconSize = 128f;

		private float itemWidth = 200f;

		private float itemHeight = 200f;

		private float spacing = 2f;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Instance = this;
			harmony = new Harmony("tony4twentyds.Summit_Supply_Shop");
			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();
			TryPatchLuggage();
			LoadCustomItems();
			BuildShopItems();
			((MonoBehaviour)this).StartCoroutine(InitializeAudioAndUI());
			InitializePhotonManager();
			StartInputDetection();
			PhotonNetwork.AddCallbackTarget((object)this);
			SceneManager.activeSceneChanged += OnSceneChanged;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Loaded! Press Alt+B to open shop ===");
		}

		private void CreateItemConfigs()
		{
			foreach (KeyValuePair<string, (int, ushort, string, bool)> allItem in allItems)
			{
				string key = allItem.Key;
				bool item = allItem.Value.Item4;
				int item2 = allItem.Value.Item1;
				itemEnableConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", key + "_Enable", item, "Enable/disable " + key + " in shop");
				itemPriceConfigs[key] = ((BaseUnityPlugin)this).Config.Bind<int>("Items", key + "_Price", item2, "Price for " + key + " in coins");
			}
		}

		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;
					(int, int) tuple = defaultLuggageRanges[text][text2];
					luggageMinConfigs[text3] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", text3 + "_Min", tuple.Item1, "Minimum coins from " + text2 + " in " + text);
					luggageMaxConfigs[text3] = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", text3 + "_Max", tuple.Item2, "Maximum coins from " + text2 + " in " + text);
				}
			}
		}

		private void LoadCustomItems()
		{
			try
			{
				string value = customItems.Value;
				if (string.IsNullOrEmpty(value))
				{
					return;
				}
				string[] array = value.Split(new char[1] { ',' });
				if (array.Length % 3 != 0)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"=== SUMMIT SUPPLY SHOP: Custom items CSV format invalid ===");
					return;
				}
				int num = 0;
				for (int i = 0; i < array.Length; i += 3)
				{
					if (i + 2 < array.Length)
					{
						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)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Loaded {num} custom items ===");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Error loading custom items: " + ex.Message + " ==="));
			}
		}

		private void BuildShopItems()
		{
			shopItems.Clear();
			foreach (KeyValuePair<string, (int, ushort, string, bool)> allItem in allItems)
			{
				if (itemEnableConfigs.ContainsKey(allItem.Key) ? itemEnableConfigs[allItem.Key].Value : allItem.Value.Item4)
				{
					int item = (itemPriceConfigs.ContainsKey(allItem.Key) ? itemPriceConfigs[allItem.Key].Value : allItem.Value.Item1);
					shopItems[allItem.Key] = (item, allItem.Value.Item2, allItem.Value.Item3);
				}
			}
		}

		private void TryPatchLuggage()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			try
			{
				harmony.Patch((MethodBase)AccessTools.Method(typeof(GlobalEvents), "TriggerLuggageOpened", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SummitSupplyShopPlugin), "OnLuggageOpened", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Failed to patch luggage: " + ex.Message + " ==="));
			}
		}

		public static void OnLuggageOpened(Luggage luggage, Character character)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null || !Instance.allowSummitShop)
			{
				return;
			}
			SpawnPool spawnPool = ((Spawner)luggage).spawnPool;
			string luggageConfigKey = GetLuggageConfigKey(spawnPool, ((Object)((Component)luggage).gameObject).name);
			if (!string.IsNullOrEmpty(luggageConfigKey) && Instance.luggageMinConfigs.ContainsKey(luggageConfigKey) && Instance.luggageMaxConfigs.ContainsKey(luggageConfigKey))
			{
				int value = Instance.luggageMinConfigs[luggageConfigKey].Value;
				int value2 = Instance.luggageMaxConfigs[luggageConfigKey].Value;
				int num = Random.Range(value, value2 + 1);
				Instance.playerCoins += num;
				Instance.InvalidateUICache();
				if (num > 0)
				{
					Instance.ShowCoinNotification(num);
					Instance.PlayCoinSound();
				}
			}
		}

		private static string GetLuggageConfigKey(SpawnPool luggageType, string gameObjectName)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			if ((int)luggageType == 32768 || (int)luggageType == 65536 || (int)luggageType == 131072)
			{
				return ((object)(SpawnPool)(ref luggageType)).ToString();
			}
			if ((int)luggageType == 16384 || gameObjectName == "LuggageClimber")
			{
				string text = Instance.DetectCurrentBiomeOnDemand();
				return text + "_LuggageEpic";
			}
			if ((int)luggageType == 0)
			{
				string text2 = Instance.DetectCurrentBiomeOnDemand();
				string text3 = gameObjectName;
				if (text3 == "LuggageClimber")
				{
					text3 = "LuggageEpic";
				}
				return text2 + "_" + text3;
			}
			return null;
		}

		private void StartInputDetection()
		{
			if (_inputDetectionCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_inputDetectionCoroutine);
			}
			_inputDetectionCoroutine = ((MonoBehaviour)this).StartCoroutine(InputDetectionCoroutine());
		}

		[IteratorStateMachine(typeof(<InputDetectionCoroutine>d__60))]
		private IEnumerator InputDetectionCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InputDetectionCoroutine>d__60(0)
			{
				<>4__this = this
			};
		}

		private void InvalidateUICache()
		{
			_uiCacheValid = false;
			_cachedCanAfford.Clear();
		}

		private void InitializeGUIStyles()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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) / (itemWidth + spacing)));
			_cachedTotalItems = shopItems.Count;
			_cachedRows = Mathf.CeilToInt((float)_cachedTotalItems / (float)_cachedItemsPerRow);
			_cachedTotalWidth = (itemWidth + spacing) * (float)_cachedItemsPerRow - spacing;
			_cachedTotalHeight = (itemHeight + spacing) * (float)_cachedRows - spacing;
			float num = 80f;
			float num2 = 20f;
			_cachedTotalWindowWidth = _cachedTotalWidth + num2 + 20f;
			_cachedTotalWindowHeight = Mathf.Min(_cachedTotalHeight + num, (float)Screen.height - 100f);
			_cachedWindowX = ((float)Screen.width - _cachedTotalWindowWidth) / 2f;
			_cachedWindowY = ((float)Screen.height - _cachedTotalWindowHeight) / 2f;
			_cachedWindowX = Mathf.Clamp(_cachedWindowX, 10f, (float)Screen.width - _cachedTotalWindowWidth - 10f);
			_cachedWindowY = Mathf.Clamp(_cachedWindowY, 10f, (float)Screen.height - _cachedTotalWindowHeight - 10f);
			foreach (KeyValuePair<string, (int, ushort, string)> shopItem in shopItems)
			{
				_cachedCanAfford[shopItem.Key] = playerCoins >= shopItem.Value.Item1;
			}
			_uiCacheValid = true;
		}

		private void OnGUI()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: 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;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Cursor restored to locked and invisible. LockState: {Cursor.lockState}, Visible: {Cursor.visible} ===");
				}
				return;
			}
			if ((int)Cursor.lockState != 0 || !Cursor.visible)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Forcing cursor visible. LockState: {Cursor.lockState}, Visible: {Cursor.visible} ===");
			}
			UpdateUICache();
			InitializeGUIStyles();
			GUI.Box(new Rect(_cachedWindowX, _cachedWindowY, _cachedTotalWindowWidth, _cachedTotalWindowHeight), "Summit Supply Shop");
			TextAnchor alignment = GUI.skin.label.alignment;
			GUI.skin.label.alignment = (TextAnchor)4;
			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;
			}
			float num = 80f;
			float num2 = 20f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(_cachedWindowX + 10f, _cachedWindowY + num, _cachedTotalWidth, _cachedTotalWindowHeight - num - 10f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(0f, 0f, _cachedTotalWidth - num2, _cachedTotalHeight);
			scrollPosition = GUI.BeginScrollView(val, scrollPosition, val2);
			int num3 = 0;
			for (int i = 0; i < _cachedRows; i++)
			{
				for (int j = 0; j < _cachedItemsPerRow; j++)
				{
					if (num3 >= _cachedTotalItems)
					{
						break;
					}
					KeyValuePair<string, (int, ushort, string)> keyValuePair = shopItems.ElementAt(num3);
					float x = (float)j * (itemWidth + spacing);
					float y = (float)i * (itemHeight + spacing);
					DrawItemButton(keyValuePair.Key, keyValuePair.Value.Item1, keyValuePair.Value.Item2, keyValuePair.Key, x, y, itemWidth, itemHeight);
					num3++;
				}
			}
			GUI.EndScrollView();
		}

		private void DrawItemButton(string itemName, int price, ushort itemId, string displayName, float x, float y, float width, float height)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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 - itemIconSize) / 2f;
			float num2 = y + 5f;
			if ((Object)(object)itemIcon != (Object)null)
			{
				GUI.DrawTexture(new Rect(num, num2, itemIconSize, itemIconSize), (Texture)(object)itemIcon);
			}
			else
			{
				GUI.Box(new Rect(num, num2, itemIconSize, itemIconSize), "?");
			}
			string text = ((itemName.Length > 30) ? (itemName.Substring(0, 30) + "...") : itemName);
			float num3 = y + itemIconSize + 8f;
			TextAnchor alignment = GUI.skin.label.alignment;
			GUI.skin.label.alignment = (TextAnchor)4;
			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, displayName);
			}
		}

		private Texture2D GetItemIcon(ushort itemId)
		{
			if (_itemIconCache.TryGetValue(itemId, out var 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 Texture2D MakeTexture(int width, int height, Color color)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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;
		}

		private void BuyItem(string itemName, int price, ushort itemId, string itemPrefabName)
		{
			if (allowSummitShop && playerCoins >= price)
			{
				playerCoins -= price;
				InvalidateUICache();
				SpawnItemForPlayer(itemId, itemPrefabName);
				PlayCoinSound();
			}
		}

		private void SpawnItemForPlayer(ushort itemId, string itemPrefabName)
		{
			try
			{
				Character localCharacter = Character.localCharacter;
				if ((Object)(object)localCharacter == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"=== SUMMIT SUPPLY SHOP: Local character is null, cannot spawn item ===");
					return;
				}
				string prefabNameFromItemId = GetPrefabNameFromItemId(itemId);
				if (string.IsNullOrEmpty(prefabNameFromItemId))
				{
					((BaseUnityPlugin)this).Logger.LogError((object)$"=== SUMMIT SUPPLY SHOP: Could not find prefab name for itemID {itemId} ===");
					return;
				}
				if (TryGiveItemToInventory(localCharacter, itemId, prefabNameFromItemId))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Item {prefabNameFromItemId} (ID: {itemId}) added to inventory/backpack ===");
					return;
				}
				localCharacter.refs.items.SpawnItemInHand(prefabNameFromItemId);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Item {prefabNameFromItemId} (ID: {itemId}) spawned above head (inventory full) ===");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Failed to spawn item: " + ex.Message + " ==="));
			}
		}

		private bool TryGiveItemToInventory(Character character, ushort itemId, string itemPrefabName)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Player player = character.player;
				if ((Object)(object)player == (Object)null)
				{
					return false;
				}
				if (IsBackpackItem(itemId))
				{
					return TryEquipBackpack(character, itemId, itemPrefabName);
				}
				ItemSlot val = default(ItemSlot);
				if (HasPocketSpace(player) && player.AddItem(itemId, (ItemInstanceData)null, ref val) && val != null && val.itemSlotID <= 2)
				{
					return true;
				}
				Item val2 = default(Item);
				if (TryGetBackpackFreeSlot(player, out var data, out var freeIndex) && ItemDatabase.TryGetItem(itemId, ref val2))
				{
					ItemInstanceData val3 = new ItemInstanceData(Guid.NewGuid());
					ItemInstanceDataHandler.AddInstanceData(val3);
					data.AddItem(val2, val3, freeIndex);
					InventorySyncData val4 = default(InventorySyncData);
					((InventorySyncData)(ref val4))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
					((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
					{
						IBinarySerializable.ToManagedArray<InventorySyncData>(val4),
						false
					});
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"=== SUMMIT SUPPLY SHOP: Item {itemPrefabName} added to backpack slot {freeIndex} ===");
					return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Error trying to give item to inventory: " + ex.Message + " ==="));
				return false;
			}
		}

		private bool IsBackpackItem(ushort itemId)
		{
			try
			{
				Item val = default(Item);
				if (ItemDatabase.TryGetItem(itemId, ref val))
				{
					return ((Component)val).GetComponent<BackpackData>() != null || ((Object)val).name.ToLower().Contains("backpack") || ((Object)val).name.ToLower().Contains("bag");
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private bool TryEquipBackpack(Character character, ushort itemId, string itemPrefabName)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Player player = character.player;
				if ((Object)(object)player == (Object)null)
				{
					return false;
				}
				if (player.backpackSlot != null && player.backpackSlot.hasBackpack)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("=== SUMMIT SUPPLY SHOP: Player already has backpack, spawning " + itemPrefabName + " above head ==="));
					return false;
				}
				if (player.backpackSlot != null)
				{
					if (((ItemSlot)player.backpackSlot).data == null)
					{
						ItemInstanceData val = new ItemInstanceData(Guid.NewGuid());
						ItemInstanceDataHandler.AddInstanceData(val);
						((ItemSlot)player.backpackSlot).data = val;
					}
					BackpackData val2 = default(BackpackData);
					if (!((ItemSlot)player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2) || val2 == null)
					{
						((ItemSlot)player.backpackSlot).data.RegisterNewEntry<BackpackData>((DataEntryKey)7);
						((ItemSlot)player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2);
					}
					player.backpackSlot.hasBackpack = true;
					InventorySyncData val3 = default(InventorySyncData);
					((InventorySyncData)(ref val3))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
					((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
					{
						IBinarySerializable.ToManagedArray<InventorySyncData>(val3),
						false
					});
					((BaseUnityPlugin)this).Logger.LogInfo((object)("=== SUMMIT SUPPLY SHOP: Backpack " + itemPrefabName + " equipped successfully ==="));
					return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Error equipping backpack: " + ex.Message + " ==="));
				return false;
			}
		}

		private string GetPrefabNameFromItemId(ushort itemId)
		{
			try
			{
				Item val = default(Item);
				if (ItemDatabase.TryGetItem(itemId, ref val))
				{
					return ((Object)val).name;
				}
				List<Item> objects = ((DatabaseAsset<ItemDatabase, Item>)(object)SingletonAsset<ItemDatabase>.Instance).Objects;
				foreach (Item item in objects)
				{
					if (item.itemID == itemId)
					{
						return ((Object)item).name;
					}
				}
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"=== SUMMIT SUPPLY SHOP: Item with ID {itemId} not found in database ===");
				return null;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"=== SUMMIT SUPPLY SHOP: Error looking up item by ID {itemId}: {ex.Message} ===");
				return null;
			}
		}

		private bool TryGiveItemTo(Character c, ushort itemId, string itemName)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Player player = c.player;
				if ((Object)(object)player == (Object)null)
				{
					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 var data, out var 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);
					InventorySyncData val4 = default(InventorySyncData);
					((InventorySyncData)(ref val4))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
					((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
					{
						IBinarySerializable.ToManagedArray<InventorySyncData>(val4),
						false
					});
					return true;
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private static bool HasPocketSpace(Player p)
		{
			for (int i = 0; i < p.itemSlots.Length; i++)
			{
				if (p.itemSlots[i].IsEmpty())
				{
					return true;
				}
			}
			return false;
		}

		private static bool TryGetBackpackFreeSlot(Player p, out BackpackData data, out byte freeIndex)
		{
			data = null;
			freeIndex = byte.MaxValue;
			if (p.backpackSlot == null || !p.backpackSlot.hasBackpack || ((ItemSlot)p.backpackSlot).data == null)
			{
				return false;
			}
			if (!((ItemSlot)p.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref data) || data == null)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					((ItemSlot)p.backpackSlot).data.RegisterNewEntry<BackpackData>((DataEntryKey)7);
					((ItemSlot)p.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 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)(BiomeType)(ref instance.progressPoints[num].biome)).ToString();
							return _cachedBiome;
						}
					}
				}
				Biome[] array = Object.FindObjectsByType<Biome>((FindObjectsSortMode)0);
				if (array != null && array.Length != 0)
				{
					_cachedBiome = ((object)(BiomeType)(ref array[0].biomeType)).ToString();
					return _cachedBiome;
				}
				_cachedBiome = "Unknown";
				return _cachedBiome;
			}
			catch
			{
				_cachedBiome = "Unknown";
				return _cachedBiome;
			}
		}

		[IteratorStateMachine(typeof(<InitializeAudioAndUI>d__83))]
		private IEnumerator InitializeAudioAndUI()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeAudioAndUI>d__83(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<LoadCoinSoundWithRetry>d__84))]
		private IEnumerator LoadCoinSoundWithRetry()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadCoinSoundWithRetry>d__84(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<LoadCoinSound>d__85))]
		private IEnumerator LoadCoinSound()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadCoinSound>d__85(0)
			{
				<>4__this = this
			};
		}

		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));
			return ((Object)(object)val != (Object)null) ? val.outputAudioMixerGroup : null;
		}

		private void SetupNotificationCanvas()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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
			{
				TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				_cachedGameFont = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset fontAsset)
				{
					//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)fontAsset).faceInfo;
					return ((FaceInfo)(ref faceInfo)).familyName == "Daruma Drop One";
				});
				gameFont = _cachedGameFont;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("=== SUMMIT SUPPLY SHOP: Error finding game font: " + ex.Message + " ==="));
			}
		}

		private void ShowCoinNotification(int coinsGained)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0035: 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)0;
			((TMP_Text)tmp).fontStyle = (FontStyles)1;
			if ((Object)(object)gameFont != (Object)null)
			{
				((TMP_Text)tmp).font = gameFont;
			}
		}

		private Color ParseHexColor(string hexColor)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = hexColor.TrimStart(new char[1] { '#' });
				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
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("=== SUMMIT SUPPLY SHOP: Failed to parse hex color '" + hexColor + "', using yellow as fallback ==="));
				return Color.yellow;
			}
		}

		private bool IsAudioSystemReady()
		{
			return (Object)(object)audioSource != (Object)null && (Object)(object)coinSoundClip != (Object)null;
		}

		private void PlayCoinSound()
		{
			if (IsAudioSystemReady())
			{
				audioSource.volume = Mathf.Clamp(coinSoundVolume.Value, 0f, 100f) / 100f;
				audioSource.Play();
			}
		}

		private void InitializePhotonManager()
		{
			if (PhotonCustomPropsUtilsPlugin.IsReady)
			{
				SetupPhotonManager();
			}
			else
			{
				PhotonCustomPropsUtilsPlugin.OnReady += SetupPhotonManager;
			}
		}

		private void SetupPhotonManager()
		{
			photonManager = PhotonCustomPropsUtilsPlugin.GetManager("tony4twentyds.Summit_Supply_Shop");
			photonManager.RegisterOnJoinedRoom((Action<Player>)delegate
			{
				CheckHostStatus();
			});
			photonManager.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 && photonManager != null)
			{
				string text = PackConfigData();
				photonManager.SetRoomProperty("shopConfig", (object)text);
			}
		}

		private string PackConfigData()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, ConfigEntry<bool>> itemEnableConfig in itemEnableConfigs)
			{
				stringBuilder.AppendLine($"ENABLE_{itemEnableConfig.Key}={itemEnableConfig.Value.Value}");
			}
			foreach (KeyValuePair<string, ConfigEntry<int>> itemPriceConfig in itemPriceConfigs)
			{
				stringBuilder.AppendLine($"PRICE_{itemPriceConfig.Key}={itemPriceConfig.Value.Value}");
			}
			foreach (KeyValuePair<string, ConfigEntry<int>> luggageMinConfig in luggageMinConfigs)
			{
				stringBuilder.AppendLine($"MIN_{luggageMinConfig.Key}={luggageMinConfig.Value.Value}");
			}
			foreach (KeyValuePair<string, ConfigEntry<int>> luggageMaxConfig in luggageMaxConfigs)
			{
				stringBuilder.AppendLine($"MAX_{luggageMaxConfig.Key}={luggageMaxConfig.Value.Value}");
			}
			stringBuilder.AppendLine($"PERSIST_COINS={persistCoinsBetweenRuns.Value}");
			return Convert.ToBase64String(Encoding.UTF8.GetBytes(stringBuilder.ToString()));
		}

		private void UnpackConfigData(string configData)
		{
			try
			{
				string @string = Encoding.UTF8.GetString(Convert.FromBase64String(configData));
				string[] array = @string.Split(new char[1] { '\n' });
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (string.IsNullOrWhiteSpace(text))
					{
						continue;
					}
					string[] array3 = text.Split(new char[1] { '=' }, 2);
					if (array3.Length != 2)
					{
						continue;
					}
					string text2 = array3[0];
					string text3 = array3[1];
					bool result5;
					if (text2.StartsWith("ENABLE_"))
					{
						string key = text2.Substring(7);
						if (bool.TryParse(text3, out var result) && itemEnableConfigs.ContainsKey(key))
						{
							itemEnableConfigs[key].Value = result;
						}
					}
					else if (text2.StartsWith("PRICE_"))
					{
						string key2 = text2.Substring(6);
						if (int.TryParse(text3, out var result2) && itemPriceConfigs.ContainsKey(key2))
						{
							itemPriceConfigs[key2].Value = result2;
						}
					}
					else if (text2.StartsWith("MIN_"))
					{
						string key3 = text2.Substring(4);
						if (int.TryParse(text3, out var result3) && luggageMinConfigs.ContainsKey(key3))
						{
							luggageMinConfigs[key3].Value = result3;
						}
					}
					else if (text2.StartsWith("MAX_"))
					{
						string key4 = text2.Substring(4);
						if (int.TryParse(text3, out var result4) && luggageMaxConfigs.ContainsKey(key4))
						{
							luggageMaxConfigs[key4].Value = result4;
						}
					}
					else if (text2 == "PERSIST_COINS" && bool.TryParse(text3, out result5))
					{
						persistCoinsBetweenRuns.Value = result5;
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("=== SUMMIT SUPPLY SHOP: Error unpacking config: " + ex.Message + " ==="));
			}
		}

		private void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			if (!persistCoinsBetweenRuns.Value && ((Scene)(ref newScene)).name == "Airport")
			{
				playerCoins = 0;
				InvalidateUICache();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"=== SUMMIT SUPPLY SHOP: Coins reset to 0 at airport ===");
			}
			_cachedBiome = null;
			if (!IsAudioSystemReady())
			{
				((MonoBehaviour)this).StartCoroutine(LoadCoinSoundWithRetry());
			}
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			SceneManager.activeSceneChanged -= OnSceneChanged;
			PhotonNetwork.RemoveCallbackTarget((object)this);
			if (_inputDetectionCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_inputDetectionCoroutine);
				_inputDetectionCoroutine = null;
			}
		}

		public void OnJoinedRoom()
		{
			CheckHostStatus();
		}

		public void OnLeftRoom()
		{
			IsHost = false;
			allowSummitShop = false;
		}

		public void OnMasterClientSwitched(Player newMasterClient)
		{
			CheckHostStatus();
		}

		public void OnPlayerEnteredRoom(Player newPlayer)
		{
			if (IsHost && photonManager != 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)
		{
		}
	}
}