Decompiled source of ShopEnhancements v2.0.1

ShopEnhancements.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("discjenny")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fe60aa4cb3849f4fd32ddf9f39906111b9b25b68")]
[assembly: AssemblyProduct("ShopEnhancements")]
[assembly: AssemblyTitle("ShopEnhancements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShopEnhancements
{
	public enum CostScalingMode
	{
		Vanilla,
		HighestPlayer
	}
	[BepInPlugin("discjenny.ShopEnhancements", "ShopEnhancements", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ShopEnhancements : BaseUnityPlugin
	{
		private const string SECTION_ITEM_COUNT = "Shop Settings - Item Count";

		private const string SECTION_COST_SCALING = "Shop Settings - Cost Scaling";

		private const string SECTION_UPGRADE_MAX = "Upgrade Settings - Max Amount";

		private static string ASSET_BUNDLE_NAME = "moreshopitems_assets.file";

		private static string SHELF_PREFAB_NAME = "custom_soda_shelf";

		internal static ShopEnhancements Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal static GameObject? CustomItemShelf { get; private set; }

		public static ConfigEntry<int>? MinUpgradeItems { get; private set; }

		public static ConfigEntry<int>? MaxUpgradeItems { get; private set; }

		public static ConfigEntry<CostScalingMode>? UpgradeCostMode { get; private set; }

		public static ConfigEntry<float>? GlobalPriceMultiplier { get; private set; }

		public static ConfigEntry<int>? MinPocketCartItems { get; private set; }

		public static ConfigEntry<int>? MaxPocketCartItems { get; private set; }

		public static ConfigEntry<int>? MinRegularCartItems { get; private set; }

		public static ConfigEntry<int>? MaxRegularCartItems { get; private set; }

		public static ConfigEntry<int>? MinGunItems { get; private set; }

		public static ConfigEntry<int>? MaxGunItems { get; private set; }

		public static ConfigEntry<int>? MinMeleeWeaponItems { get; private set; }

		public static ConfigEntry<int>? MaxMeleeWeaponItems { get; private set; }

		public static ConfigEntry<int>? MinGrenadeItems { get; private set; }

		public static ConfigEntry<int>? MaxGrenadeItems { get; private set; }

		public static ConfigEntry<int>? MinDroneItems { get; private set; }

		public static ConfigEntry<int>? MaxDroneItems { get; private set; }

		public static ConfigEntry<int>? MinMineItems { get; private set; }

		public static ConfigEntry<int>? MaxMineItems { get; private set; }

		public static ConfigEntry<int>? MinTrackerItems { get; private set; }

		public static ConfigEntry<int>? MaxTrackerItems { get; private set; }

		public static ConfigEntry<int>? MinPowerCrystalItems { get; private set; }

		public static ConfigEntry<int>? MaxPowerCrystalItems { get; private set; }

		public static ConfigEntry<int>? MinHealthPackItems { get; private set; }

		public static ConfigEntry<int>? MaxHealthPackItems { get; private set; }

		public static ConfigEntry<int>? MaxHealthUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxEnergyUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxStrengthUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxSpeedUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxJumpUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxMapUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxLaunchUpgrades { get; private set; }

		public static ConfigEntry<int>? MaxRangeUpgrades { get; private set; }

		public static int ValidatedMinUpgrades { get; private set; }

		public static int ValidatedMaxUpgrades { get; private set; }

		public static int ValidatedMinPocketCarts { get; private set; }

		public static int ValidatedMaxPocketCarts { get; private set; }

		public static int ValidatedMinRegularCarts { get; private set; }

		public static int ValidatedMaxRegularCarts { get; private set; }

		public static int ValidatedMinGuns { get; private set; }

		public static int ValidatedMaxGuns { get; private set; }

		public static int ValidatedMinMeleeWeapons { get; private set; }

		public static int ValidatedMaxMeleeWeapons { get; private set; }

		public static int ValidatedMinGrenades { get; private set; }

		public static int ValidatedMaxGrenades { get; private set; }

		public static int ValidatedMinDrones { get; private set; }

		public static int ValidatedMaxDrones { get; private set; }

		public static int ValidatedMinMines { get; private set; }

		public static int ValidatedMaxMines { get; private set; }

		public static int ValidatedMinTrackers { get; private set; }

		public static int ValidatedMaxTrackers { get; private set; }

		public static int ValidatedMinPowerCrystals { get; private set; }

		public static int ValidatedMaxPowerCrystals { get; private set; }

		public static int ValidatedMinHealthPacks { get; private set; }

		public static int ValidatedMaxHealthPacks { get; private set; }

		public static int ValidatedMaxHealthUpgrades { get; private set; }

		public static int ValidatedMaxEnergyUpgrades { get; private set; }

		public static int ValidatedMaxStrengthUpgrades { get; private set; }

		public static int ValidatedMaxSpeedUpgrades { get; private set; }

		public static int ValidatedMaxJumpUpgrades { get; private set; }

		public static int ValidatedMaxMapUpgrades { get; private set; }

		public static int ValidatedMaxLaunchUpgrades { get; private set; }

		public static int ValidatedMaxRangeUpgrades { get; private set; }

		private void CleanupOldConfigEntries()
		{
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Expected O, but got Unknown
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Expected O, but got Unknown
			string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
			if (!File.Exists(configFilePath))
			{
				return;
			}
			Dictionary<string, HashSet<string>> validEntries = new Dictionary<string, HashSet<string>>
			{
				["Shop Settings - Item Count"] = new HashSet<string>
				{
					"MinUpgradeItems", "MaxUpgradeItems", "MinPocketCartItems", "MaxPocketCartItems", "MinRegularCartItems", "MaxRegularCartItems", "MinGunItems", "MaxGunItems", "MinMeleeWeaponItems", "MaxMeleeWeaponItems",
					"MinGrenadeItems", "MaxGrenadeItems", "MinDroneItems", "MaxDroneItems", "MinMineItems", "MaxMineItems", "MinTrackerItems", "MaxTrackerItems", "MinPowerCrystalItems", "MaxPowerCrystalItems",
					"MinHealthPackItems", "MaxHealthPackItems"
				},
				["Shop Settings - Cost Scaling"] = new HashSet<string> { "UpgradeCostScalingMode", "GlobalPriceMultiplier" },
				["Upgrade Settings - Max Amount"] = new HashSet<string> { "MaxHealthUpgrades", "MaxEnergyUpgrades", "MaxStrengthUpgrades", "MaxSpeedUpgrades", "MaxJumpUpgrades", "MaxMapUpgrades", "MaxLaunchUpgrades", "MaxRangeUpgrades" }
			};
			Dictionary<string, HashSet<string>> dictionary = new Dictionary<string, HashSet<string>>();
			string text = null;
			foreach (string item2 in File.ReadLines(configFilePath))
			{
				string text2 = item2.Trim();
				if (string.IsNullOrWhiteSpace(text2) || text2.StartsWith("#") || text2.StartsWith("//"))
				{
					continue;
				}
				if (text2.StartsWith("[") && text2.EndsWith("]"))
				{
					text = text2.Substring(1, text2.Length - 2);
					if (!dictionary.ContainsKey(text))
					{
						dictionary[text] = new HashSet<string>();
					}
				}
				else if (text != null && text2.Contains("="))
				{
					string item = text2.Split('=')[0].Trim();
					dictionary[text].Add(item);
				}
			}
			bool flag = false;
			List<string> list = dictionary.Keys.Where((string section) => !validEntries.ContainsKey(section)).ToList();
			foreach (string item3 in list)
			{
				Logger.LogInfo((object)("Found outdated section that will be removed: [" + item3 + "]"));
				flag = true;
			}
			foreach (string section3 in dictionary.Keys.Intersect(validEntries.Keys))
			{
				List<string> list2 = dictionary[section3].Where((string key) => !validEntries[section3].Contains(key)).ToList();
				foreach (string item4 in list2)
				{
					Logger.LogInfo((object)("Found outdated entry that will be removed: [" + section3 + "] " + item4));
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			try
			{
				foreach (string item5 in list)
				{
					foreach (string item6 in dictionary[item5])
					{
						ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>(item5, item6, "TEMP_VALUE_FOR_REMOVAL", (ConfigDescription)null);
						((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition(item5, item6));
					}
				}
				foreach (string section2 in dictionary.Keys.Intersect(validEntries.Keys))
				{
					IEnumerable<string> enumerable = dictionary[section2].Where((string key) => !validEntries[section2].Contains(key));
					foreach (string item7 in enumerable)
					{
						ConfigEntry<string> val2 = ((BaseUnityPlugin)this).Config.Bind<string>(section2, item7, "TEMP_VALUE_FOR_REMOVAL", (ConfigDescription)null);
						((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition(section2, item7));
					}
				}
				((BaseUnityPlugin)this).Config.Save();
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error during config cleanup: " + ex.Message));
			}
		}

		private void InitializeConfig()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Expected O, but got Unknown
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Expected O, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Expected O, but got Unknown
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Expected O, but got Unknown
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Expected O, but got Unknown
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Expected O, but got Unknown
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Expected O, but got Unknown
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Expected O, but got Unknown
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Expected O, but got Unknown
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Expected O, but got Unknown
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Expected O, but got Unknown
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Expected O, but got Unknown
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Expected O, but got Unknown
			MinUpgradeItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinUpgradeItems", 8, new ConfigDescription("Minimum number of *upgrade* items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 39), Array.Empty<object>()));
			MaxUpgradeItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxUpgradeItems", 10, new ConfigDescription("Maximum number of *upgrade* items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 39), Array.Empty<object>()));
			UpgradeCostMode = ((BaseUnityPlugin)this).Config.Bind<CostScalingMode>("Shop Settings - Cost Scaling", "UpgradeCostScalingMode", CostScalingMode.Vanilla, "Determines how upgrade costs scale:\nVanilla: Cost increases based on the total number purchased across all players.\nHighestPlayer: Cost increases based on the highest level any single player has for that specific upgrade.");
			GlobalPriceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Shop Settings - Cost Scaling", "GlobalPriceMultiplier", 1f, new ConfigDescription("Global multiplier for all shop item prices. 1.0 = normal prices, 0.5 = half price, 2.0 = double price, etc.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			MinPocketCartItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinPocketCartItems", 0, new ConfigDescription("Minimum number of pocket cart items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MaxPocketCartItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxPocketCartItems", 1, new ConfigDescription("Maximum number of pocket cart items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MinRegularCartItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinRegularCartItems", 0, new ConfigDescription("Minimum number of regular cart items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MaxRegularCartItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxRegularCartItems", 1, new ConfigDescription("Maximum number of regular cart items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MinGunItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinGunItems", 0, new ConfigDescription("Minimum number of gun items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			MaxGunItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxGunItems", 0, new ConfigDescription("Maximum number of gun items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			MinMeleeWeaponItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinMeleeWeaponItems", 0, new ConfigDescription("Minimum number of melee weapon items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
			MaxMeleeWeaponItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxMeleeWeaponItems", 2, new ConfigDescription("Maximum number of melee weapon items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
			MinGrenadeItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinGrenadeItems", 0, new ConfigDescription("Minimum number of grenade items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MaxGrenadeItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxGrenadeItems", 3, new ConfigDescription("Maximum number of grenade items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MinDroneItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinDroneItems", 0, new ConfigDescription("Minimum number of drone items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			MaxDroneItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxDroneItems", 3, new ConfigDescription("Maximum number of drone items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			MinMineItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinMineItems", 0, new ConfigDescription("Minimum number of mine items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
			MaxMineItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxMineItems", 2, new ConfigDescription("Maximum number of mine items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
			MinTrackerItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinTrackerItems", 0, new ConfigDescription("Minimum number of tracker items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MaxTrackerItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxTrackerItems", 2, new ConfigDescription("Maximum number of tracker items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MinPowerCrystalItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinPowerCrystalItems", 0, new ConfigDescription("Minimum number of power crystal items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MaxPowerCrystalItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxPowerCrystalItems", 3, new ConfigDescription("Maximum number of power crystal items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MinHealthPackItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MinHealthPackItems", 6, new ConfigDescription("Minimum number of health pack items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), Array.Empty<object>()));
			MaxHealthPackItems = ((BaseUnityPlugin)this).Config.Bind<int>("Shop Settings - Item Count", "MaxHealthPackItems", 6, new ConfigDescription("Maximum number of health pack items to try spawning in the shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), Array.Empty<object>()));
			MaxHealthUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxHealthUpgrades", 2, new ConfigDescription("Maximum number of health upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			MaxEnergyUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxEnergyUpgrades", 4, new ConfigDescription("Maximum number of energy upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MaxStrengthUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxStrengthUpgrades", 2, new ConfigDescription("Maximum number of grab strength upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			MaxSpeedUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxSpeedUpgrades", 2, new ConfigDescription("Maximum number of sprint speed upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			MaxJumpUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxJumpUpgrades", 1, new ConfigDescription("Maximum number of extra jump upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			MaxMapUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxMapUpgrades", 1, new ConfigDescription("Maximum number of map player count upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			MaxLaunchUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxLaunchUpgrades", 1, new ConfigDescription("Maximum number of tumble launch upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			MaxRangeUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrade Settings - Max Amount", "MaxRangeUpgrades", 2, new ConfigDescription("Maximum number of grab range upgrades that can appear in a single shop.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			CleanupOldConfigEntries();
			((BaseUnityPlugin)this).Config.Save();
		}

		private void ValidateConfig()
		{
			ValidatedMinUpgrades = MinUpgradeItems.Value;
			ValidatedMaxUpgrades = MaxUpgradeItems.Value;
			if (ValidatedMinUpgrades > ValidatedMaxUpgrades)
			{
				Logger.LogWarning((object)$"Configuration Error: MinUpgradeItems ({ValidatedMinUpgrades}) cannot be greater than MaxUpgradeItems ({ValidatedMaxUpgrades}). Clamping Min to Max value for this session.");
				ValidatedMinUpgrades = ValidatedMaxUpgrades;
			}
			ValidatedMinPocketCarts = MinPocketCartItems.Value;
			ValidatedMaxPocketCarts = MaxPocketCartItems.Value;
			if (ValidatedMinPocketCarts > ValidatedMaxPocketCarts)
			{
				Logger.LogWarning((object)$"Configuration Error: MinPocketCartItems ({ValidatedMinPocketCarts}) cannot be greater than MaxPocketCartItems ({ValidatedMaxPocketCarts}). Clamping Min to Max value for this session.");
				ValidatedMinPocketCarts = ValidatedMaxPocketCarts;
			}
			ValidatedMinRegularCarts = MinRegularCartItems.Value;
			ValidatedMaxRegularCarts = MaxRegularCartItems.Value;
			if (ValidatedMinRegularCarts > ValidatedMaxRegularCarts)
			{
				Logger.LogWarning((object)$"Configuration Error: MinRegularCartItems ({ValidatedMinRegularCarts}) cannot be greater than MaxRegularCartItems ({ValidatedMaxRegularCarts}). Clamping Min to Max value for this session.");
				ValidatedMinRegularCarts = ValidatedMaxRegularCarts;
			}
			ValidatedMinGuns = MinGunItems.Value;
			ValidatedMaxGuns = MaxGunItems.Value;
			if (ValidatedMinGuns > ValidatedMaxGuns)
			{
				Logger.LogWarning((object)$"Configuration Error: MinGunItems ({ValidatedMinGuns}) cannot be greater than MaxGunItems ({ValidatedMaxGuns}). Clamping Min to Max value for this session.");
				ValidatedMinGuns = ValidatedMaxGuns;
			}
			ValidatedMinMeleeWeapons = MinMeleeWeaponItems.Value;
			ValidatedMaxMeleeWeapons = MaxMeleeWeaponItems.Value;
			if (ValidatedMinMeleeWeapons > ValidatedMaxMeleeWeapons)
			{
				Logger.LogWarning((object)$"Configuration Error: MinMeleeWeaponItems ({ValidatedMinMeleeWeapons}) cannot be greater than MaxMeleeWeaponItems ({ValidatedMaxMeleeWeapons}). Clamping Min to Max value for this session.");
				ValidatedMinMeleeWeapons = ValidatedMaxMeleeWeapons;
			}
			ValidatedMinGrenades = MinGrenadeItems.Value;
			ValidatedMaxGrenades = MaxGrenadeItems.Value;
			if (ValidatedMinGrenades > ValidatedMaxGrenades)
			{
				Logger.LogWarning((object)$"Configuration Error: MinGrenadeItems ({ValidatedMinGrenades}) cannot be greater than MaxGrenadeItems ({ValidatedMaxGrenades}). Clamping Min to Max value for this session.");
				ValidatedMinGrenades = ValidatedMaxGrenades;
			}
			ValidatedMinDrones = MinDroneItems.Value;
			ValidatedMaxDrones = MaxDroneItems.Value;
			if (ValidatedMinDrones > ValidatedMaxDrones)
			{
				Logger.LogWarning((object)$"Configuration Error: MinDroneItems ({ValidatedMinDrones}) cannot be greater than MaxDroneItems ({ValidatedMaxDrones}). Clamping Min to Max value for this session.");
				ValidatedMinDrones = ValidatedMaxDrones;
			}
			ValidatedMinMines = MinMineItems.Value;
			ValidatedMaxMines = MaxMineItems.Value;
			if (ValidatedMinMines > ValidatedMaxMines)
			{
				Logger.LogWarning((object)$"Configuration Error: MinMineItems ({ValidatedMinMines}) cannot be greater than MaxMineItems ({ValidatedMaxMines}). Clamping Min to Max value for this session.");
				ValidatedMinMines = ValidatedMaxMines;
			}
			ValidatedMinTrackers = MinTrackerItems.Value;
			ValidatedMaxTrackers = MaxTrackerItems.Value;
			if (ValidatedMinTrackers > ValidatedMaxTrackers)
			{
				Logger.LogWarning((object)$"Configuration Error: MinTrackerItems ({ValidatedMinTrackers}) cannot be greater than MaxTrackerItems ({ValidatedMaxTrackers}). Clamping Min to Max value for this session.");
				ValidatedMinTrackers = ValidatedMaxTrackers;
			}
			ValidatedMinPowerCrystals = MinPowerCrystalItems.Value;
			ValidatedMaxPowerCrystals = MaxPowerCrystalItems.Value;
			if (ValidatedMinPowerCrystals > ValidatedMaxPowerCrystals)
			{
				Logger.LogWarning((object)$"Configuration Error: MinPowerCrystalItems ({ValidatedMinPowerCrystals}) cannot be greater than MaxPowerCrystalItems ({ValidatedMaxPowerCrystals}). Clamping Min to Max value for this session.");
				ValidatedMinPowerCrystals = ValidatedMaxPowerCrystals;
			}
			ValidatedMinHealthPacks = MinHealthPackItems.Value;
			ValidatedMaxHealthPacks = MaxHealthPackItems.Value;
			if (ValidatedMinHealthPacks > ValidatedMaxHealthPacks)
			{
				Logger.LogWarning((object)$"Configuration Error: MinHealthPackItems ({ValidatedMinHealthPacks}) cannot be greater than MaxHealthPackItems ({ValidatedMaxHealthPacks}). Clamping Min to Max value for this session.");
				ValidatedMinHealthPacks = ValidatedMaxHealthPacks;
			}
			ValidatedMaxHealthUpgrades = MaxHealthUpgrades.Value;
			ValidatedMaxEnergyUpgrades = MaxEnergyUpgrades.Value;
			ValidatedMaxStrengthUpgrades = MaxStrengthUpgrades.Value;
			ValidatedMaxSpeedUpgrades = MaxSpeedUpgrades.Value;
			ValidatedMaxJumpUpgrades = MaxJumpUpgrades.Value;
			ValidatedMaxMapUpgrades = MaxMapUpgrades.Value;
			ValidatedMaxLaunchUpgrades = MaxLaunchUpgrades.Value;
			ValidatedMaxRangeUpgrades = MaxRangeUpgrades.Value;
		}

		private void Awake()
		{
			Instance = this;
			InitializeConfig();
			ValidateConfig();
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			LoadAssets();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void LoadAssets()
		{
			try
			{
				string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assets", ASSET_BUNDLE_NAME);
				if (!File.Exists(text))
				{
					text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), ASSET_BUNDLE_NAME);
					if (!File.Exists(text))
					{
						Logger.LogError((object)("Asset bundle not found at: " + text));
						return;
					}
				}
				AssetBundle val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogError((object)"Failed to load asset bundle");
					return;
				}
				try
				{
					CustomItemShelf = val.LoadAsset<GameObject>(SHELF_PREFAB_NAME);
					if ((Object)(object)CustomItemShelf == (Object)null)
					{
						Logger.LogError((object)("Failed to load " + SHELF_PREFAB_NAME + " from asset bundle"));
						return;
					}
					Utilities.FixAudioMixerGroups(CustomItemShelf);
					NetworkPrefabs.RegisterNetworkPrefab(CustomItemShelf);
				}
				finally
				{
					val.Unload(false);
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error loading assets: " + ex.Message));
				Logger.LogError((object)ex.StackTrace);
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	[HarmonyPatch("ShopInitialize")]
	internal class ShopManager_ShopInitialize_Patch
	{
		private static void Postfix(ShopManager __instance)
		{
			if ((Object)(object)__instance != (Object)null && SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (ShopEnhancements.Logger == null)
				{
					Debug.LogError((object)"ShopPatch: Logger instance is null. Cannot proceed safely.");
				}
			}
			else if ((Object)(object)__instance == (Object)null)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)"ShopPatch: ShopManager instance is null in Postfix for ShopInitialize.");
				}
				else
				{
					Debug.LogError((object)"ShopPatch: ShopManager instance is null and Logger is not initialized! (ShopInitialize)");
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")]
	internal class ShopManager_GetAllItemsFromStatsManager_Patch
	{
		private static List<string> playerUpgradeAssetNames = new List<string> { "Item Upgrade Player Health", "Item Upgrade Player Energy", "Item Upgrade Player Grab Strength", "Item Upgrade Player Sprint Speed", "Item Upgrade Player Extra Jump", "Item Upgrade Map Player Count", "Item Upgrade Player Tumble Launch", "Item Upgrade Player Grab Range" };

		private static void Prefix()
		{
			ConfigEntry<CostScalingMode>? upgradeCostMode = ShopEnhancements.UpgradeCostMode;
			if (upgradeCostMode != null && upgradeCostMode.Value == CostScalingMode.HighestPlayer && SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (ShopEnhancements.Logger == null)
				{
					Debug.LogError((object)"ShopPatch: Logger instance is null. Cannot apply cost scaling patch.");
					return;
				}
				ShopEnhancements.Logger.LogDebug((object)"Applying HighestPlayer cost scaling logic...");
				UpdateUpgradeCostsBasedOnHighestPlayer();
			}
		}

		private static void UpdateUpgradeCostsBasedOnHighestPlayer()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			if (list == null || list.Count == 0)
			{
				ShopEnhancements.Logger.LogWarning((object)"HighestPlayer scaling: No players found, cannot update costs.");
				return;
			}
			foreach (string playerUpgradeAssetName in playerUpgradeAssetNames)
			{
				int num = 0;
				foreach (PlayerAvatar item in list)
				{
					string text = SemiFunc.PlayerGetSteamID(item);
					if (!string.IsNullOrEmpty(text))
					{
						int playerUpgradeLevel = GetPlayerUpgradeLevel(text, playerUpgradeAssetName);
						if (playerUpgradeLevel > num)
						{
							num = playerUpgradeLevel;
						}
					}
				}
				StatsManager.instance.SetItemsUpgradesPurchased(playerUpgradeAssetName, num);
				ShopEnhancements.Logger.LogDebug((object)$" - Set '{playerUpgradeAssetName}' effective purchased count to {num} for pricing.");
			}
		}

		private static int GetPlayerUpgradeLevel(string steamID, string upgradeAssetName)
		{
			switch (upgradeAssetName)
			{
			case "Item Upgrade Player Health":
			{
				int value7;
				return StatsManager.instance.playerUpgradeHealth.TryGetValue(steamID, out value7) ? value7 : 0;
			}
			case "Item Upgrade Player Energy":
			{
				int value2;
				return StatsManager.instance.playerUpgradeStamina.TryGetValue(steamID, out value2) ? value2 : 0;
			}
			case "Item Upgrade Player Grab Strength":
			{
				int value8;
				return StatsManager.instance.playerUpgradeStrength.TryGetValue(steamID, out value8) ? value8 : 0;
			}
			case "Item Upgrade Player Sprint Speed":
			{
				int value3;
				return StatsManager.instance.playerUpgradeSpeed.TryGetValue(steamID, out value3) ? value3 : 0;
			}
			case "Item Upgrade Player Extra Jump":
			{
				int value6;
				return StatsManager.instance.playerUpgradeExtraJump.TryGetValue(steamID, out value6) ? value6 : 0;
			}
			case "Item Upgrade Map Player Count":
			{
				int value4;
				return StatsManager.instance.playerUpgradeMapPlayerCount.TryGetValue(steamID, out value4) ? value4 : 0;
			}
			case "Item Upgrade Player Tumble Launch":
			{
				int value5;
				return StatsManager.instance.playerUpgradeLaunch.TryGetValue(steamID, out value5) ? value5 : 0;
			}
			case "Item Upgrade Player Grab Range":
			{
				int value;
				return StatsManager.instance.playerUpgradeRange.TryGetValue(steamID, out value) ? value : 0;
			}
			default:
				ShopEnhancements.Logger.LogWarning((object)("HighestPlayer scaling: Unknown upgrade asset name '" + upgradeAssetName + "' in GetPlayerUpgradeLevel."));
				return 0;
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")]
	internal class ShopManager_EmptyItemsPostfix_Patch
	{
		private static void Postfix(ShopManager __instance)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (ShopEnhancements.Logger == null)
			{
				Debug.LogError((object)"ShopPatch: Logger instance is null. Cannot modify item lists.");
				return;
			}
			__instance.potentialItems.RemoveAll((Item item) => ShopItemSpawner.IsBaseGameItem(item.itemAssetName));
			__instance.potentialItemConsumables.RemoveAll((Item item) => ShopItemSpawner.IsBaseGameItem(item.itemAssetName));
			__instance.potentialItemUpgrades.RemoveAll((Item item) => ShopItemSpawner.IsBaseGameItem(item.itemAssetName));
			__instance.potentialItemHealthPacks.RemoveAll((Item item) => ShopItemSpawner.IsBaseGameItem(item.itemAssetName));
			int itemSpawnTargetAmount = ShopEnhancements.ValidatedMaxRegularCarts + ShopEnhancements.ValidatedMaxPocketCarts + ShopEnhancements.ValidatedMaxGuns + ShopEnhancements.ValidatedMaxMeleeWeapons + ShopEnhancements.ValidatedMaxGrenades + ShopEnhancements.ValidatedMaxDrones + ShopEnhancements.ValidatedMaxMines + ShopEnhancements.ValidatedMaxTrackers + __instance.potentialItems.Count;
			__instance.itemSpawnTargetAmount = itemSpawnTargetAmount;
			__instance.itemConsumablesAmount = ShopEnhancements.ValidatedMaxPowerCrystals + __instance.potentialItemConsumables.Count;
			__instance.itemUpgradesAmount = ShopEnhancements.ValidatedMaxUpgrades + __instance.potentialItemUpgrades.Count;
			__instance.itemHealthPacksAmount = ShopEnhancements.ValidatedMaxHealthPacks + __instance.potentialItemHealthPacks.Count;
			ShopItemSpawner.PopulateShopLists(__instance);
		}
	}
	public static class ShopItemSpawner
	{
		private static readonly Dictionary<string, List<string>> ItemCategoryMap = new Dictionary<string, List<string>>
		{
			["regular_cart"] = new List<string> { "Item Cart Medium" },
			["pocket_cart"] = new List<string> { "Item Cart Small" },
			["gun"] = new List<string> { "Item Gun Handgun", "Item Gun Shotgun", "Item Gun Tranq" },
			["melee"] = new List<string> { "Item Melee Baseball Bat", "Item Melee Frying Pan", "Item Melee Inflatable Hammer", "Item Melee Sledge Hammer", "Item Melee Sword" },
			["grenade"] = new List<string> { "Item Grenade Explosive", "Item Grenade Shockwave", "Item Grenade Stun", "Item Rubber Duck" },
			["drone"] = new List<string> { "Item Drone Battery", "Item Drone Feather", "Item Drone Indestructible", "Item Drone Torque", "Item Drone Zero Gravity", "Item Orb Zero Gravity" },
			["mine"] = new List<string> { "Item Mine Explosive", "Item Mine Shockwave", "Item Mine Stun" },
			["tracker"] = new List<string> { "Item Extraction Tracker", "Item Valuable Tracker" },
			["power_crystal"] = new List<string> { "Item Power Crystal" },
			["health_pack"] = new List<string> { "Item Health Pack Small", "Item Health Pack Medium", "Item Health Pack Large" },
			["upgrade"] = new List<string> { "Item Upgrade Map Player Count", "Item Upgrade Player Energy", "Item Upgrade Player Extra Jump", "Item Upgrade Player Grab Range", "Item Upgrade Player Grab Strength", "Item Upgrade Player Health", "Item Upgrade Player Sprint Speed", "Item Upgrade Player Tumble Launch" }
		};

		private static readonly Dictionary<string, string> ItemVolumeMap = new Dictionary<string, string>
		{
			["Item Cart Medium"] = "large_wide",
			["Item Cart Small"] = "large_plus",
			["Item Gun Handgun"] = "medium",
			["Item Gun Shotgun"] = "medium",
			["Item Gun Tranq"] = "medium",
			["Item Melee Baseball Bat"] = "large_high",
			["Item Melee Frying Pan"] = "large",
			["Item Melee Inflatable Hammer"] = "large_high",
			["Item Melee Sledge Hammer"] = "large_high",
			["Item Melee Sword"] = "large_high",
			["Item Grenade Explosive"] = "small",
			["Item Grenade Shockwave"] = "small",
			["Item Grenade Stun"] = "small",
			["Item Rubber Duck"] = "small",
			["Item Drone Battery"] = "small",
			["Item Drone Feather"] = "small",
			["Item Drone Indestructible"] = "small",
			["Item Drone Torque"] = "small",
			["Item Drone Zero Gravity"] = "small",
			["Item Orb Zero Gravity"] = "small",
			["Item Mine Explosive"] = "medium",
			["Item Mine Shockwave"] = "medium",
			["Item Mine Stun"] = "medium",
			["Item Extraction Tracker"] = "large_high",
			["Item Valuable Tracker"] = "large_high",
			["Item Power Crystal"] = "power_crystal",
			["Item Health Pack Small"] = "healthPack",
			["Item Health Pack Medium"] = "healthPack",
			["Item Health Pack Large"] = "healthPack",
			["Item Upgrade Map Player Count"] = "upgrade",
			["Item Upgrade Player Energy"] = "upgrade",
			["Item Upgrade Player Extra Jump"] = "upgrade",
			["Item Upgrade Player Grab Range"] = "upgrade",
			["Item Upgrade Player Grab Strength"] = "upgrade",
			["Item Upgrade Player Health"] = "upgrade",
			["Item Upgrade Player Sprint Speed"] = "upgrade",
			["Item Upgrade Player Tumble Launch"] = "upgrade"
		};

		public static bool IsBaseGameItem(string itemName)
		{
			foreach (List<string> value in ItemCategoryMap.Values)
			{
				if (value.Contains(itemName))
				{
					return true;
				}
			}
			return false;
		}

		public static bool SpawnItem(Item item, ItemVolume volume)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null || (Object)(object)volume == (Object)null || (Object)(object)ShopManager.instance == (Object)null)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)"SpawnItem: item, volume, or ShopManager.instance is null");
				}
				return false;
			}
			try
			{
				((Component)ShopManager.instance.itemRotateHelper).transform.parent = ((Component)volume).transform;
				((Component)ShopManager.instance.itemRotateHelper).transform.localRotation = item.spawnRotationOffset;
				Quaternion rotation = ((Component)ShopManager.instance.itemRotateHelper).transform.rotation;
				((Component)ShopManager.instance.itemRotateHelper).transform.parent = ((Component)ShopManager.instance).transform;
				if (SemiFunc.IsMasterClient() && SemiFunc.IsMultiplayer())
				{
					PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)item.prefab).name, ((Component)volume).transform.position, rotation, (byte)0, (object[])null);
					if (ShopEnhancements.Logger == null)
					{
					}
				}
				else if (!SemiFunc.IsMultiplayer())
				{
					Object.Instantiate<GameObject>(item.prefab, ((Component)volume).transform.position, rotation);
					if (ShopEnhancements.Logger == null)
					{
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)("SpawnItem: Error spawning item: " + ex.Message));
				}
				return false;
			}
		}

		public static bool SpawnItemAtVolume(string itemAssetName, int volumeIndex)
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Invalid comparison between Unknown and I4
			if (string.IsNullOrEmpty(itemAssetName))
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)"SpawnItemAtVolume: Item asset name is null or empty");
				}
				return false;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogWarning((object)"SpawnItemAtVolume: Cannot spawn items as non-host player");
				}
				return false;
			}
			if ((Object)(object)ShopManager.instance == (Object)null)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)"SpawnItemAtVolume: ShopManager.instance is null");
				}
				return false;
			}
			if ((Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary == null)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)"SpawnItemAtVolume: StatsManager.instance or itemDictionary is null");
				}
				return false;
			}
			if (!StatsManager.instance.itemDictionary.TryGetValue(itemAssetName, out var value))
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)("SpawnItemAtVolume: Item '" + itemAssetName + "' not found in StatsManager.itemDictionary"));
				}
				return false;
			}
			List<ItemVolume> list = new List<ItemVolume>();
			ItemVolume[] array = Object.FindObjectsOfType<ItemVolume>();
			foreach (ItemVolume val in array)
			{
				if ((int)val.itemSecretShopType == 0)
				{
					list.Add(val);
				}
			}
			if (volumeIndex < 0 || volumeIndex >= list.Count)
			{
				if (ShopEnhancements.Logger != null)
				{
					ShopEnhancements.Logger.LogError((object)$"SpawnItemAtVolume: Volume index {volumeIndex} is out of range (0-{list.Count - 1})");
				}
				return false;
			}
			ItemVolume volume = list[volumeIndex];
			return SpawnItem(value, volume);
		}

		private static int GetRandomAmountForCategory(string category)
		{
			int num = 0;
			int num2 = 0;
			switch (category)
			{
			case "regular_cart":
				num = ShopEnhancements.ValidatedMinRegularCarts;
				num2 = ShopEnhancements.ValidatedMaxRegularCarts;
				break;
			case "pocket_cart":
				num = ShopEnhancements.ValidatedMinPocketCarts;
				num2 = ShopEnhancements.ValidatedMaxPocketCarts;
				break;
			case "gun":
				num = ShopEnhancements.ValidatedMinGuns;
				num2 = ShopEnhancements.ValidatedMaxGuns;
				break;
			case "melee":
				num = ShopEnhancements.ValidatedMinMeleeWeapons;
				num2 = ShopEnhancements.ValidatedMaxMeleeWeapons;
				break;
			case "grenade":
				num = ShopEnhancements.ValidatedMinGrenades;
				num2 = ShopEnhancements.ValidatedMaxGrenades;
				break;
			case "drone":
				num = ShopEnhancements.ValidatedMinDrones;
				num2 = ShopEnhancements.ValidatedMaxDrones;
				break;
			case "mine":
				num = ShopEnhancements.ValidatedMinMines;
				num2 = ShopEnhancements.ValidatedMaxMines;
				break;
			case "tracker":
				num = ShopEnhancements.ValidatedMinTrackers;
				num2 = ShopEnhancements.ValidatedMaxTrackers;
				break;
			case "power_crystal":
				num = ShopEnhancements.ValidatedMinPowerCrystals;
				num2 = ShopEnhancements.ValidatedMaxPowerCrystals;
				break;
			case "health_pack":
				num = ShopEnhancements.ValidatedMinHealthPacks;
				num2 = ShopEnhancements.ValidatedMaxHealthPacks;
				break;
			case "upgrade":
				num = ShopEnhancements.ValidatedMinUpgrades;
				num2 = ShopEnhancements.ValidatedMaxUpgrades;
				break;
			default:
			{
				ManualLogSource logger = ShopEnhancements.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("Unknown category '" + category + "' in GetRandomAmountForCategory"));
				}
				return 0;
			}
			}
			ManualLogSource logger2 = ShopEnhancements.Logger;
			if (logger2 != null)
			{
				logger2.LogDebug((object)$"Getting random amount for {category} (range: {num}-{num2})");
			}
			return Random.Range(num, num2 + 1);
		}

		public static void PopulateShopLists(ShopManager shopManager)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)shopManager == (Object)null)
			{
				return;
			}
			if ((Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary == null)
			{
				ManualLogSource logger = ShopEnhancements.Logger;
				if (logger != null)
				{
					logger.LogError((object)"PopulateShopLists: StatsManager.instance or itemDictionary is null");
				}
				return;
			}
			foreach (string key in ItemCategoryMap.Keys)
			{
				if (key == "upgrade")
				{
					Dictionary<string, int> upgradeTypeCounts = new Dictionary<string, int>();
					int randomAmountForCategory = GetRandomAmountForCategory(key);
					if (randomAmountForCategory <= 0)
					{
						continue;
					}
					for (int i = 0; i < randomAmountForCategory; i++)
					{
						string text = ItemCategoryMap[key][Random.Range(0, ItemCategoryMap[key].Count)];
						int valueOrDefault = upgradeTypeCounts.GetValueOrDefault(text, 0);
						int maxForUpgradeType = GetMaxForUpgradeType(text);
						if (valueOrDefault >= maxForUpgradeType)
						{
							List<string> list = ItemCategoryMap[key].Where((string upgrade) => upgradeTypeCounts.GetValueOrDefault(upgrade, 0) < GetMaxForUpgradeType(upgrade)).ToList();
							if (list.Count == 0)
							{
								break;
							}
							text = list[Random.Range(0, list.Count)];
						}
						if (!StatsManager.instance.itemDictionary.TryGetValue(text, out var value))
						{
							ManualLogSource logger2 = ShopEnhancements.Logger;
							if (logger2 != null)
							{
								logger2.LogError((object)("Item '" + text + "' not found in StatsManager.itemDictionary"));
							}
						}
						else
						{
							shopManager.potentialItemUpgrades.Add(value);
							upgradeTypeCounts[text] = upgradeTypeCounts.GetValueOrDefault(text, 0) + 1;
						}
					}
					continue;
				}
				int randomAmountForCategory2 = GetRandomAmountForCategory(key);
				if (randomAmountForCategory2 <= 0)
				{
					continue;
				}
				List<string> list2 = ItemCategoryMap[key];
				if (list2 == null || list2.Count == 0)
				{
					continue;
				}
				HashSet<string> hashSet = new HashSet<string>();
				List<string> list3 = new List<string>(list2);
				for (int num = list3.Count - 1; num > 0; num--)
				{
					int index = Random.Range(0, num + 1);
					string value2 = list3[num];
					list3[num] = list3[index];
					list3[index] = value2;
				}
				foreach (string item in list3)
				{
					if (hashSet.Count >= randomAmountForCategory2)
					{
						break;
					}
					if (!StatsManager.instance.itemDictionary.TryGetValue(item, out var value3))
					{
						ManualLogSource logger3 = ShopEnhancements.Logger;
						if (logger3 != null)
						{
							logger3.LogError((object)("Item '" + item + "' not found in StatsManager.itemDictionary"));
						}
						continue;
					}
					string text2 = key;
					string text3 = text2;
					if (!(text3 == "health_pack"))
					{
						if (text3 == "power_crystal")
						{
							shopManager.potentialItemConsumables.Add(value3);
						}
						else
						{
							shopManager.potentialItems.Add(value3);
						}
					}
					else
					{
						shopManager.potentialItemHealthPacks.Add(value3);
					}
					hashSet.Add(item);
				}
				int num2 = randomAmountForCategory2 - hashSet.Count;
				for (int j = 0; j < num2; j++)
				{
					string text4 = list2[Random.Range(0, list2.Count)];
					if (!StatsManager.instance.itemDictionary.TryGetValue(text4, out var value4))
					{
						ManualLogSource logger4 = ShopEnhancements.Logger;
						if (logger4 != null)
						{
							logger4.LogError((object)("Item '" + text4 + "' not found in StatsManager.itemDictionary"));
						}
						continue;
					}
					string text5 = key;
					string text6 = text5;
					if (!(text6 == "health_pack"))
					{
						if (text6 == "power_crystal")
						{
							shopManager.potentialItemConsumables.Add(value4);
						}
						else
						{
							shopManager.potentialItems.Add(value4);
						}
					}
					else
					{
						shopManager.potentialItemHealthPacks.Add(value4);
					}
				}
			}
		}

		private static int GetMaxForUpgradeType(string upgradeAssetName)
		{
			switch (upgradeAssetName)
			{
			case "Item Upgrade Player Health":
				return ShopEnhancements.ValidatedMaxHealthUpgrades;
			case "Item Upgrade Player Energy":
				return ShopEnhancements.ValidatedMaxEnergyUpgrades;
			case "Item Upgrade Player Grab Strength":
				return ShopEnhancements.ValidatedMaxStrengthUpgrades;
			case "Item Upgrade Player Sprint Speed":
				return ShopEnhancements.ValidatedMaxSpeedUpgrades;
			case "Item Upgrade Player Extra Jump":
				return ShopEnhancements.ValidatedMaxJumpUpgrades;
			case "Item Upgrade Map Player Count":
				return ShopEnhancements.ValidatedMaxMapUpgrades;
			case "Item Upgrade Player Tumble Launch":
				return ShopEnhancements.ValidatedMaxLaunchUpgrades;
			case "Item Upgrade Player Grab Range":
				return ShopEnhancements.ValidatedMaxRangeUpgrades;
			default:
			{
				ManualLogSource logger = ShopEnhancements.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)("Unknown upgrade type '" + upgradeAssetName + "', using default max of 1"));
				}
				return 1;
			}
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes))]
	[HarmonyPatch("GetValue")]
	internal class ItemAttributes_GetValue_Patch
	{
		private static void Postfix(ItemAttributes __instance, ref int ___value)
		{
			if (!SemiFunc.RunIsShop() || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (ShopEnhancements.Logger == null)
			{
				Debug.LogError((object)"ItemAttributes_GetValue_Patch: Logger instance is null. Cannot apply price scaling.");
				return;
			}
			float num = ___value;
			float num2 = num * ShopEnhancements.GlobalPriceMultiplier.Value;
			___value = Mathf.Max(1, Mathf.RoundToInt(num2));
			if (Mathf.Abs(num - (float)___value) > 0.01f)
			{
				ShopEnhancements.Logger.LogDebug((object)$"Price scaled from {num}K to {___value}K (multiplier: {ShopEnhancements.GlobalPriceMultiplier.Value})");
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal static class ShopShelfPatch
	{
		private static GameObject? shelf;

		[HarmonyPrefix]
		[HarmonyPatch("ShopInitialize")]
		private static void SpawnShelf()
		{
			//IL_0070: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			if (RunManager.instance.levelCurrent.ResourcePath != "Shop")
			{
				return;
			}
			GameObject val = GameObject.Find("Soda Shelf");
			GameObject val2 = GameObject.Find("Module Switch BOT");
			if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && !val2.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
			{
				SpawnCustomShelf(val.transform.position, val.transform.rotation, val2.transform);
				val.SetActive(false);
				return;
			}
			GameObject val3 = GameObject.Find("Shop Magazine Stand (1)");
			GameObject val4 = GameObject.Find("Shop Magazine Stand");
			GameObject val5 = GameObject.Find("Module Switch (1) top");
			if ((Object)(object)val3 != (Object)null && (Object)(object)val5 != (Object)null && !val5.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
			{
				SpawnCustomShelf(val3.transform.position, val3.transform.rotation * Quaternion.Euler(0f, 90f, 0f), val5.transform.parent);
				val3.SetActive(false);
				if ((Object)(object)val4 != (Object)null)
				{
					val4.SetActive(false);
				}
				return;
			}
			GameObject val6 = GameObject.Find("Module Switch (2) left");
			GameObject val7 = GameObject.Find("Candy Shelf");
			if ((Object)(object)val6 != (Object)null && !val6.GetComponent<ModulePropSwitch>().ConnectedParent.activeSelf)
			{
				Vector3 position = val6.transform.position + val6.transform.right * 0.5f - val6.transform.forward * 0.8f;
				SpawnCustomShelf(position, val6.transform.rotation * Quaternion.Euler(0f, 180f, 0f), ((val5 != null) ? val5.transform.parent : null) ?? val6.transform.parent);
				if ((Object)(object)val7 != (Object)null)
				{
					val7.SetActive(false);
				}
			}
			else
			{
				ShopEnhancements.Logger.LogWarning((object)"No suitable location found for custom shelf!");
			}
		}

		private static void SpawnCustomShelf(Vector3 position, Quaternion rotation, Transform parent)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)ShopEnhancements.CustomItemShelf == (Object)null))
				{
					if (!SemiFunc.IsMultiplayer())
					{
						shelf = Object.Instantiate<GameObject>(ShopEnhancements.CustomItemShelf, position, rotation, parent);
					}
					else if (SemiFunc.IsMasterClient())
					{
						shelf = PhotonNetwork.Instantiate(((Object)ShopEnhancements.CustomItemShelf).name, position, rotation, (byte)0, (object[])null);
						SetParent(parent, shelf);
					}
				}
			}
			catch (Exception ex)
			{
				ShopEnhancements.Logger.LogError((object)("Error spawning custom shelf: " + ex.Message));
			}
		}

		private static void SetParent(Transform parent, GameObject child)
		{
			try
			{
				PhotonView component = child.GetComponent<PhotonView>();
				PhotonView component2 = ((Component)parent).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					component.RPC("SetParentRPC", (RpcTarget)0, new object[1] { component2.ViewID });
				}
				else
				{
					child.transform.SetParent(parent, true);
				}
			}
			catch (Exception ex)
			{
				ShopEnhancements.Logger.LogError((object)("Error setting parent: " + ex.Message));
				child.transform.SetParent(parent, true);
			}
		}

		[PunRPC]
		private static void SetParentRPC(int parentViewID)
		{
			try
			{
				PhotonView val = PhotonView.Find(parentViewID);
				if ((Object)(object)val != (Object)null && (Object)(object)shelf != (Object)null)
				{
					shelf.transform.SetParent(((Component)val).transform, true);
				}
				else
				{
					ShopEnhancements.Logger.LogWarning((object)$"Failed to find parent view with ID {parentViewID} or shelf is null!");
				}
			}
			catch (Exception ex)
			{
				ShopEnhancements.Logger.LogError((object)("Error in SetParentRPC: " + ex.Message));
			}
		}
	}
}