Decompiled source of MegaShop v1.6.8

MegaShop.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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 UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MegaShop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Generates a Big Shop with guaranteed Attic ceiling hatch and abundant items")]
[assembly: AssemblyFileVersion("1.6.8.0")]
[assembly: AssemblyInformationalVersion("1.6.8+acf50f7095eed3ed236b176fe7f36cfe19de3d2f")]
[assembly: AssemblyProduct("MegaShop")]
[assembly: AssemblyTitle("MegaShop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MegaShop
{
	[BepInPlugin("com.antigravity.megashop", "MegaShop", "1.6.8")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.antigravity.megashop";

		public const string PLUGIN_NAME = "MegaShop";

		public const string PLUGIN_VERSION = "1.6.8";

		public static ManualLogSource Logger;

		public static ConfigEntry<string> ConfigShopTheme;

		public static ConfigEntry<int> ConfigItemTargetAmount;

		public static ConfigEntry<int> ConfigUpgradesAmount;

		public static ConfigEntry<int> ConfigConsumablesAmount;

		public static ConfigEntry<int> ConfigHealthPacksAmount;

		public static ConfigEntry<bool> ConfigGuaranteeAttic;

		public static ConfigEntry<bool> ConfigGuaranteeSecretShelves;

		public static ConfigEntry<bool> ConfigInfiniteSprint;

		public static ConfigEntry<bool> ConfigEnableDummies;

		public static ConfigEntry<bool> ConfigFloorArrows;

		public static ConfigEntry<bool> ConfigEnableTestingHotkeys;

		public static ConfigEntry<KeyCode> ConfigWarpKey;

		public static ConfigEntry<KeyCode> ConfigMoneyKey;

		public static bool RemoteStaminaBoostApplied;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			ConfigShopTheme = ((BaseUnityPlugin)this).Config.Bind<string>("General", "ShopTheme", "Suburb", "Which shop theme to always generate (Suburb, Harbor, Wasteland, Forest, Dead Forest)");
			ConfigItemTargetAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "ItemTargetAmount", 75, "Maximum regular items in shop (weapons, guns, melee, tools, drones, modded items). Vanilla is 8.");
			ConfigUpgradesAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "UpgradesAmount", 80, "Maximum upgrades in shop. Vanilla is 3.");
			ConfigConsumablesAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "ConsumablesAmount", 35, "Maximum consumables in shop (crystals, batteries, grenades, mines). Vanilla is 4-6.");
			ConfigHealthPacksAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "HealthPacksAmount", 20, "Maximum health packs in shop. Vanilla is 3.");
			ConfigGuaranteeAttic = ((BaseUnityPlugin)this).Config.Bind<bool>("Attic", "GuaranteeAttic", true, "Always guarantee the attic module with the ceiling trapdoor / secret shop.");
			ConfigGuaranteeSecretShelves = ((BaseUnityPlugin)this).Config.Bind<bool>("Attic", "GuaranteeSecretShelves", true, "Guarantee 100% item spawn rate on all secret attic shelves (vanilla has 33% chance).");
			ConfigInfiniteSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "InfiniteSprintInShop", true, "Infinite stamina / sprint while inside the Shop (never get tired while shopping). Works Host-Only!");
			ConfigEnableDummies = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "TargetPracticeDummies", false, "Spawn immortal training dummy enemies on an outdoor patio to test weapon damage and spread (experimental). Default is false.");
			ConfigFloorArrows = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "FloorGuidanceArrows", true, "Glowing neon floor arrows pointing to the exit / truck so you never get lost in the MegaShop.");
			ConfigEnableTestingHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "EnableTestingHotkeys", true, "Enable cheat/testing hotkeys (Numpad 1 to warp, Numpad 2 for +$10,000). Set to false to disable completely.");
			ConfigWarpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Testing", "WarpToShopKey", (KeyCode)257, "Hotkey to immediately warp into the Shop. Default is Keypad1 (Numpad 1). Set to None to disable.");
			ConfigMoneyKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Testing", "AddMoneyKey", (KeyCode)258, "Hotkey to give yourself +$10,000 for shopping tests. Default is Keypad2 (Numpad 2). Set to None to disable.");
			try
			{
				new Harmony("com.antigravity.megashop").PatchAll();
				Logger.LogInfo((object)"MegaShop v1.6.8 Harmony patches applied successfully!");
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"[MegaShop] Harmony patch error: {arg}");
			}
			Logger.LogInfo((object)"MegaShop v1.6.8 loaded successfully! (Numpad 1 = Instant Shop, Numpad 2 = +$10,000)");
		}

		private void Update()
		{
			if (IsWarpHotkeyPressed())
			{
				if ((Object)(object)RunManager.instance != (Object)null && SemiFunc.IsMasterClientOrSingleplayer())
				{
					Logger.LogInfo((object)"[MegaShop] Warp hotkey pressed! Teleporting straight to Shop...");
					RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)5);
				}
				else
				{
					Logger.LogWarning((object)"[MegaShop] Cannot warp: You must be in a game session (Host or Singleplayer) to warp to Shop!");
				}
			}
			if (IsMoneyHotkeyPressed())
			{
				int num = SemiFunc.StatGetRunCurrency() + 10000;
				SemiFunc.StatSetRunCurrency(num);
				Logger.LogInfo((object)$"[MegaShop] Money hotkey pressed! Added $10,000. Balance: ${num}");
			}
		}

		private bool IsWarpHotkeyPressed()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			if (!ConfigEnableTestingHotkeys.Value || (int)ConfigWarpKey.Value == 0)
			{
				return false;
			}
			try
			{
				if (Input.GetKeyDown(ConfigWarpKey.Value))
				{
					return true;
				}
			}
			catch
			{
			}
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && (int)ConfigWarpKey.Value == 257 && ((ButtonControl)current.numpad1Key).wasPressedThisFrame)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		private bool IsMoneyHotkeyPressed()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			if (!ConfigEnableTestingHotkeys.Value || (int)ConfigMoneyKey.Value == 0)
			{
				return false;
			}
			try
			{
				if (Input.GetKeyDown(ConfigMoneyKey.Value))
				{
					return true;
				}
			}
			catch
			{
			}
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && (int)ConfigMoneyKey.Value == 258 && ((ButtonControl)current.numpad2Key).wasPressedThisFrame)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.antigravity.megashop";

		public const string PLUGIN_NAME = "MegaShop";

		public const string PLUGIN_VERSION = "1.6.8";
	}
	[HarmonyPatch(typeof(RunManager), "SetShopLevel")]
	public static class ForceShopThemePatch
	{
		[HarmonyPrefix]
		public static bool Prefix(RunManager __instance)
		{
			if (__instance.levelShop == null || __instance.levelShop.Count == 0)
			{
				return true;
			}
			string preferred = Plugin.ConfigShopTheme.Value.Trim().ToLower();
			Level val = ((IEnumerable<Level>)__instance.levelShop).FirstOrDefault((Func<Level, bool>)((Level l) => (Object)(object)l != (Object)null && ((Object)l).name.ToLower().Contains(preferred))) ?? ((IEnumerable<Level>)__instance.levelShop).FirstOrDefault((Func<Level, bool>)((Level l) => (Object)(object)l != (Object)null && ((Object)l).name.ToLower().Contains("suburb"))) ?? ((IEnumerable<Level>)__instance.levelShop).FirstOrDefault((Func<Level, bool>)((Level l) => (Object)(object)l != (Object)null));
			if ((Object)(object)val != (Object)null)
			{
				__instance.levelCurrent = val;
				FieldInfo fieldInfo = AccessTools.Field(typeof(RunManager), "previousShopLevel");
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(__instance, val);
				}
				Plugin.Logger.LogInfo((object)("[MegaShop] Forced shop theme to: " + ((Object)val).name));
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "TileGeneration")]
	public static class CustomShopTileGenerationPatch
	{
		private static readonly FieldInfo WaitingForSubCoroutineField = AccessTools.Field(typeof(LevelGenerator), "waitingForSubCoroutine");

		private static readonly FieldInfo LevelGridField = AccessTools.Field(typeof(LevelGenerator), "LevelGrid");

		private static readonly FieldInfo ExtractionAmountField = AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount");

		private static readonly FieldInfo SpecialAmountField = AccessTools.Field(typeof(LevelGenerator), "SpecialAmount");

		private static readonly FieldInfo DeadEndAmountField = AccessTools.Field(typeof(LevelGenerator), "DeadEndAmount");

		private static readonly FieldInfo MegaTilesField = AccessTools.Field(typeof(LevelGenerator), "MegaTiles");

		[HarmonyPrefix]
		public static bool Prefix(LevelGenerator __instance, ref IEnumerator __result)
		{
			if ((Object)(object)__instance.Level != (Object)null && SemiFunc.IsLevelShop(__instance.Level))
			{
				Plugin.Logger.LogInfo((object)"[MegaShop] Applying Flat Footprint Grid Generator (6 connected rooms + Outdoor Patio Range)...");
				__result = CustomShopTileGenerationCoroutine(__instance);
				return false;
			}
			return true;
		}

		private static IEnumerator CustomShopTileGenerationCoroutine(LevelGenerator lg)
		{
			WaitingForSubCoroutineField?.SetValue(lg, true);
			lg.State = (LevelState)2;
			int num = 5;
			int num2 = 3;
			lg.LevelWidth = num;
			lg.LevelHeight = num2;
			Tile[,] array = new Tile[num, num2];
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num2; j++)
				{
					array[i, j] = new Tile
					{
						x = i,
						y = j,
						active = false,
						type = (Type)0
					};
				}
			}
			array[2, 0].active = true;
			array[2, 0].first = true;
			array[2, 0].type = (Type)0;
			array[0, 1].active = true;
			array[0, 1].type = (Type)2;
			array[1, 1].active = true;
			array[1, 1].type = (Type)0;
			array[2, 1].active = true;
			array[2, 1].type = (Type)0;
			array[3, 1].active = true;
			array[3, 1].type = (Type)0;
			array[4, 1].active = true;
			array[4, 1].type = (Type)2;
			array[2, 2].active = true;
			array[2, 2].type = (Type)2;
			LevelGridField?.SetValue(lg, array);
			ExtractionAmountField?.SetValue(lg, 0);
			SpecialAmountField?.SetValue(lg, 0);
			DeadEndAmountField?.SetValue(lg, 0);
			MegaTilesField?.SetValue(lg, new List<MegaTile>());
			if ((Object)(object)lg.Level != (Object)null)
			{
				lg.Level.PassageMaxAmount = 0;
			}
			yield return null;
			WaitingForSubCoroutineField?.SetValue(lg, false);
			Plugin.Logger.LogInfo((object)"[MegaShop] Flat 5x3 Grid generated! 6 rooms + Open doorway to Outdoor Range.");
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "PlanModule")]
	public static class PlanModulePatch
	{
		public static int CurrentPlanningX = -1;

		public static int CurrentPlanningY = -1;

		public static Type CurrentPlanningType = (Type)0;

		[HarmonyPrefix]
		public static void Prefix(int _x, int _y, Type _type)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			CurrentPlanningX = _x;
			CurrentPlanningY = _y;
			CurrentPlanningType = _type;
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "PickModule")]
	public static class GuaranteeModulesPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(LevelGenerator __instance, List<PrefabRef> _list1, ref PrefabRef __result)
		{
			if (!SemiFunc.RunIsShop() || _list1 == null || _list1.Count == 0)
			{
				return true;
			}
			_list1.RemoveAll((PrefabRef p) => p != null && ((((PrefabRef<GameObject>)(object)p).ResourcePath != null && ((PrefabRef<GameObject>)(object)p).ResourcePath.IndexOf("Center Extract", StringComparison.OrdinalIgnoreCase) >= 0) || ((Object)(object)((PrefabRef<GameObject>)(object)p).Prefab != (Object)null && ((Object)((PrefabRef<GameObject>)(object)p).Prefab).name.IndexOf("Center Extract", StringComparison.OrdinalIgnoreCase) >= 0) || (((PrefabRef<GameObject>)(object)p).ResourcePath != null && ((PrefabRef<GameObject>)(object)p).ResourcePath.IndexOf("Car Service", StringComparison.OrdinalIgnoreCase) >= 0) || ((Object)(object)((PrefabRef<GameObject>)(object)p).Prefab != (Object)null && ((Object)((PrefabRef<GameObject>)(object)p).Prefab).name.IndexOf("Car Service", StringComparison.OrdinalIgnoreCase) >= 0)));
			int currentPlanningX = PlanModulePatch.CurrentPlanningX;
			int currentPlanningY = PlanModulePatch.CurrentPlanningY;
			if (currentPlanningX == 2 && currentPlanningY == 0)
			{
				PrefabRef val = FindModule(_list1, "Middle Stands") ?? FindModule(__instance.Level?.ModulesNormal1, "Middle Stands");
				if (val != null)
				{
					__result = val;
					Plugin.Logger.LogInfo((object)$"[MegaShop] Entrance tile ({currentPlanningX}, {currentPlanningY}) set to Middle Stands.");
					return false;
				}
			}
			if (Plugin.ConfigGuaranteeAttic.Value && currentPlanningX == 2 && currentPlanningY == 2)
			{
				PrefabRef val2 = FindModule(_list1, "Attic above diner") ?? FindModule(__instance.Level?.ModulesDeadEnd1, "Attic above diner") ?? FindModule(_list1, "attic") ?? FindModule(__instance.Level?.ModulesDeadEnd1, "attic");
				if (val2 != null)
				{
					__result = val2;
					Plugin.Logger.LogInfo((object)$"[MegaShop] Back tile ({currentPlanningX}, {currentPlanningY}) set to Attic above diner.");
					return false;
				}
			}
			if (currentPlanningX == 4 && currentPlanningY == 1)
			{
				PrefabRef val3 = FindModule(__instance.Level?.ModulesSpecial, "Cosmetic Machine") ?? FindModule(_list1, "Cosmetic Machine") ?? FindModule(_list1, "Storage");
				if (val3 != null)
				{
					__result = val3;
					ManualLogSource logger = Plugin.Logger;
					object arg = currentPlanningX;
					object arg2 = currentPlanningY;
					object obj = ((PrefabRef<GameObject>)(object)val3).ResourcePath;
					if (obj == null)
					{
						GameObject prefab = ((PrefabRef<GameObject>)(object)val3).Prefab;
						obj = ((prefab != null) ? ((Object)prefab).name : null);
					}
					logger.LogInfo((object)$"[MegaShop] Right wing tile ({arg}, {arg2}) set to {obj}.");
					return false;
				}
			}
			if (currentPlanningX == 0 && currentPlanningY == 1)
			{
				PrefabRef val4 = FindModule(_list1, "Storage") ?? FindModule(_list1, "Bunker") ?? FindModule(_list1, "Drink Machines") ?? FindModule(_list1, "Middle Stands");
				if (val4 != null)
				{
					__result = val4;
					ManualLogSource logger2 = Plugin.Logger;
					object arg3 = currentPlanningX;
					object arg4 = currentPlanningY;
					object obj2 = ((PrefabRef<GameObject>)(object)val4).ResourcePath;
					if (obj2 == null)
					{
						GameObject prefab2 = ((PrefabRef<GameObject>)(object)val4).Prefab;
						obj2 = ((prefab2 != null) ? ((Object)prefab2).name : null);
					}
					logger2.LogInfo((object)$"[MegaShop] Left wing tile ({arg3}, {arg4}) set to {obj2}.");
					return false;
				}
			}
			return true;
		}

		private static PrefabRef FindModule(List<PrefabRef> list, string substring)
		{
			return list?.FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef p) => p != null && ((((PrefabRef<GameObject>)(object)p).ResourcePath != null && ((PrefabRef<GameObject>)(object)p).ResourcePath.IndexOf(substring, StringComparison.OrdinalIgnoreCase) >= 0) || ((Object)(object)((PrefabRef<GameObject>)(object)p).Prefab != (Object)null && ((Object)((PrefabRef<GameObject>)(object)p).Prefab).name.IndexOf(substring, StringComparison.OrdinalIgnoreCase) >= 0))));
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "SpawnBlockObject")]
	public static class OpenOutdoorDoorwayPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(Vector3 position, Vector3 rotation)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.ConfigEnableDummies.Value && SemiFunc.RunIsShop() && Mathf.Abs(position.x - -22.5f) < 1.5f && Mathf.Abs(position.z - 22.5f) < 3f)
			{
				Plugin.Logger.LogInfo((object)$"[MegaShop] Kept doorway at {position} OPEN to the Outdoor Shooting Range!");
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemVolumesInScene")]
	public static class MultiplyItemVolumesPatch
	{
		[HarmonyPostfix]
		public static void Postfix(ShopManager __instance)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_00fd: 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)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01bb: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.RunIsShop())
			{
				return;
			}
			List<ItemVolume> list = new List<ItemVolume>(__instance.itemVolumes);
			int num = 0;
			int num2 = 0;
			foreach (ItemVolume item in list)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).transform == (Object)null) && (int)item.itemSecretShopType == 0 && (int)item.itemVolume != 9)
				{
					try
					{
						Transform parent = ((Component)item).transform.parent;
						Vector3 position = ((Component)item).transform.position;
						Vector3 right = ((Component)item).transform.right;
						Quaternion rotation = ((Component)item).transform.rotation;
						GameObject val = new GameObject(((Object)item).name + "_SlotR1");
						val.transform.SetParent(parent);
						val.transform.position = position + right * 0.22f;
						val.transform.rotation = rotation;
						ItemVolume val2 = val.AddComponent<ItemVolume>();
						val2.itemVolume = (itemVolume)6;
						val2.itemSecretShopType = (itemSecretShopType)0;
						__instance.itemVolumes.Add(val2);
						num++;
						GameObject val3 = new GameObject(((Object)item).name + "_SlotL1");
						val3.transform.SetParent(parent);
						val3.transform.position = position - right * 0.22f;
						val3.transform.rotation = rotation;
						ItemVolume val4 = val3.AddComponent<ItemVolume>();
						val4.itemVolume = (itemVolume)6;
						val4.itemSecretShopType = (itemSecretShopType)0;
						__instance.itemVolumes.Add(val4);
						num++;
						GameObject val5 = new GameObject(((Object)item).name + "_SlotR2");
						val5.transform.SetParent(parent);
						val5.transform.position = position + right * 0.44f;
						val5.transform.rotation = rotation;
						ItemVolume val6 = val5.AddComponent<ItemVolume>();
						val6.itemVolume = (itemVolume)((num2 % 2 != 0) ? 1 : 6);
						val6.itemSecretShopType = (itemSecretShopType)0;
						__instance.itemVolumes.Add(val6);
						num++;
						GameObject val7 = new GameObject(((Object)item).name + "_SlotL2");
						val7.transform.SetParent(parent);
						val7.transform.position = position - right * 0.44f;
						val7.transform.rotation = rotation;
						ItemVolume val8 = val7.AddComponent<ItemVolume>();
						val8.itemVolume = (itemVolume)((num2 % 3) switch
						{
							1 => 7, 
							0 => 4, 
							_ => 0, 
						});
						val8.itemSecretShopType = (itemSecretShopType)0;
						__instance.itemVolumes.Add(val8);
						num++;
						num2++;
					}
					catch (Exception ex)
					{
						Plugin.Logger.LogWarning((object)("[MegaShop] Failed to clone shelf slot: " + ex.Message));
					}
				}
			}
			int num3 = 0;
			if (__instance.secretItemVolumes != null)
			{
				foreach (KeyValuePair<itemSecretShopType, List<ItemVolume>> secretItemVolume in __instance.secretItemVolumes)
				{
					List<ItemVolume> value = secretItemVolume.Value;
					if (value == null)
					{
						continue;
					}
					foreach (ItemVolume item2 in new List<ItemVolume>(value))
					{
						if (!((Object)(object)item2 == (Object)null) && !((Object)(object)((Component)item2).transform == (Object)null))
						{
							try
							{
								Transform parent2 = ((Component)item2).transform.parent;
								Vector3 position2 = ((Component)item2).transform.position;
								Vector3 right2 = ((Component)item2).transform.right;
								Quaternion rotation2 = ((Component)item2).transform.rotation;
								GameObject val9 = new GameObject(((Object)item2).name + "_SecR");
								val9.transform.SetParent(parent2);
								val9.transform.position = position2 + right2 * 0.25f;
								val9.transform.rotation = rotation2;
								ItemVolume val10 = val9.AddComponent<ItemVolume>();
								val10.itemVolume = item2.itemVolume;
								val10.itemSecretShopType = secretItemVolume.Key;
								value.Add(val10);
								num3++;
								GameObject val11 = new GameObject(((Object)item2).name + "_SecL");
								val11.transform.SetParent(parent2);
								val11.transform.position = position2 - right2 * 0.25f;
								val11.transform.rotation = rotation2;
								ItemVolume val12 = val11.AddComponent<ItemVolume>();
								val12.itemVolume = item2.itemVolume;
								val12.itemSecretShopType = secretItemVolume.Key;
								value.Add(val12);
								num3++;
							}
							catch (Exception ex2)
							{
								Plugin.Logger.LogWarning((object)("[MegaShop] Failed to clone secret shelf slot: " + ex2.Message));
							}
						}
					}
					ListExtension.Shuffle<ItemVolume>((IList<ItemVolume>)value);
				}
			}
			ListExtension.Shuffle<ItemVolume>((IList<ItemVolume>)__instance.itemVolumes);
			Plugin.Logger.LogInfo((object)$"[MegaShop] Multiplied shelf capacity! Added {num} normal slots and {num3} secret slots. Total normal shelves now: {__instance.itemVolumes.Count}");
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")]
	[HarmonyPriority(0)]
	public static class BoostShopItemsPatch
	{
		[HarmonyPostfix]
		public static void Postfix(ShopManager __instance)
		{
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.RunIsShop())
			{
				return;
			}
			__instance.itemSpawnTargetAmount = Mathf.Max(Plugin.ConfigItemTargetAmount.Value, 75);
			__instance.itemUpgradesAmount = Mathf.Max(Plugin.ConfigUpgradesAmount.Value, 80);
			__instance.itemConsumablesAmount = Mathf.Max(Plugin.ConfigConsumablesAmount.Value, 35);
			__instance.itemHealthPacksAmount = Mathf.Max(Plugin.ConfigHealthPacksAmount.Value, 20);
			if ((Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary == null)
			{
				return;
			}
			List<Item> source = StatsManager.instance.itemDictionary.Values.Where((Item i) => (Object)(object)i != (Object)null).ToList();
			List<Item> allUpgrades = source.Where((Item item) => (int)item.itemType == 3 || (int)item.itemType == 4 || (int)item.itemVolume == 6 || ((Object)item).name.IndexOf("upgrade", StringComparison.OrdinalIgnoreCase) >= 0).ToList();
			if (allUpgrades.Count > 0)
			{
				__instance.potentialItemUpgrades.Clear();
				while (__instance.potentialItemUpgrades.Count < 120)
				{
					__instance.potentialItemUpgrades.AddRange(allUpgrades);
				}
				ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemUpgrades);
				Plugin.Logger.LogInfo((object)$"[MegaShop] Upgrades pool stocked with {__instance.potentialItemUpgrades.Count} items.");
			}
			List<Item> allConsumables = source.Where((Item item) => (int)item.itemType == 5 || (int)item.itemType == 6 || (int)item.itemType == 11 || (int)item.itemVolume == 4 || ((Object)item).name.IndexOf("grenade", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)item).name.IndexOf("crystal", StringComparison.OrdinalIgnoreCase) >= 0).ToList();
			if (allConsumables.Count > 0)
			{
				__instance.potentialItemConsumables.Clear();
				while (__instance.potentialItemConsumables.Count < 70)
				{
					__instance.potentialItemConsumables.AddRange(allConsumables);
				}
				ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemConsumables);
				Plugin.Logger.LogInfo((object)$"[MegaShop] Consumables pool stocked with {__instance.potentialItemConsumables.Count} items.");
			}
			List<Item> allHealth = source.Where((Item item) => (int)item.itemType == 8 || (int)item.itemVolume == 7 || ((Object)item).name.IndexOf("health", StringComparison.OrdinalIgnoreCase) >= 0).ToList();
			if (allHealth.Count > 0)
			{
				__instance.potentialItemHealthPacks.Clear();
				while (__instance.potentialItemHealthPacks.Count < 40)
				{
					__instance.potentialItemHealthPacks.AddRange(allHealth);
				}
				ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItemHealthPacks);
				Plugin.Logger.LogInfo((object)$"[MegaShop] Health packs pool stocked with {__instance.potentialItemHealthPacks.Count} items.");
			}
			List<Item> list = source.Where((Item item) => !allUpgrades.Contains(item) && !allConsumables.Contains(item) && !allHealth.Contains(item) && (int)item.itemSecretShopType == 0).ToList();
			if (list.Count > 0)
			{
				__instance.potentialItems.Clear();
				while (__instance.potentialItems.Count < 150)
				{
					__instance.potentialItems.AddRange(list);
				}
				ListExtension.Shuffle<Item>((IList<Item>)__instance.potentialItems);
				Plugin.Logger.LogInfo((object)$"[MegaShop] Regular items pool stocked with {__instance.potentialItems.Count} items.");
			}
			itemSecretShopType key = (itemSecretShopType)1;
			if (!__instance.potentialSecretItems.ContainsKey(key))
			{
				__instance.potentialSecretItems[key] = new List<Item>();
			}
			List<Item> list2 = __instance.potentialSecretItems[key];
			list2.Clear();
			List<Item> list3 = allUpgrades.Concat(list).ToList();
			ListExtension.Shuffle<Item>((IList<Item>)list3);
			while (list2.Count < 35 && list3.Count > 0)
			{
				list2.AddRange(list3.Take(35 - list2.Count));
			}
			ListExtension.Shuffle<Item>((IList<Item>)list2);
			Plugin.Logger.LogInfo((object)$"[MegaShop] Secret attic pool stocked with {list2.Count} items.");
			int num = __instance.itemSpawnTargetAmount + __instance.itemUpgradesAmount + __instance.itemConsumablesAmount + __instance.itemHealthPacksAmount;
			Plugin.Logger.LogInfo((object)$"[MegaShop] Stocking complete: Regular={__instance.itemSpawnTargetAmount}, Upgrades={__instance.itemUpgradesAmount}, Consumables={__instance.itemConsumablesAmount}, Health={__instance.itemHealthPacksAmount} (TOTAL TARGET: {num})");
		}
	}
	[HarmonyPatch]
	public static class GuaranteeSecretAtticItemsTranspiler
	{
		[HarmonyTargetMethod]
		public static MethodBase TargetMethod()
		{
			return AccessTools.GetDeclaredMethods(typeof(PunManager)).FirstOrDefault((MethodInfo m) => m.Name == "ShopPopulateItemVolumes" && m.GetParameters().Length == 1);
		}

		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 0; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_I4_3 && list[i + 1].opcode == OpCodes.Call && list[i + 1].operand is MethodInfo { Name: "Range" } methodInfo && methodInfo.DeclaringType == typeof(Random))
				{
					list[i].opcode = OpCodes.Ldc_I4_1;
					flag = true;
					Plugin.Logger.LogInfo((object)"[MegaShop] Successfully patched secret attic spawn rate to 100%!");
					break;
				}
			}
			if (!flag)
			{
				Plugin.Logger.LogWarning((object)"[MegaShop] Could not locate Random.Range(0, 3) in ShopPopulateItemVolumes. Vanilla secret rate might be used.");
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Update")]
	public static class InfiniteShopSprintPatch
	{
		[HarmonyPostfix]
		public static void Postfix(PlayerController __instance)
		{
			if (Plugin.ConfigInfiniteSprint.Value && SemiFunc.RunIsShop())
			{
				__instance.EnergyCurrent = Mathf.Max(__instance.EnergyCurrent, __instance.EnergyStart);
				__instance.EnergySprintDrain = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	public static class LevelChangeStaminaSyncPatch
	{
		[HarmonyPrefix]
		public static void Prefix(RunManager __instance)
		{
			if (Plugin.RemoteStaminaBoostApplied && SemiFunc.IsMasterClientOrSingleplayer())
			{
				SyncRemotePlayersStamina(-500);
				Plugin.RemoteStaminaBoostApplied = false;
			}
		}

		public static void SyncRemotePlayersStamina(int amount)
		{
			try
			{
				if ((Object)(object)PunManager.instance == (Object)null)
				{
					return;
				}
				PhotonView component = ((Component)PunManager.instance).GetComponent<PhotonView>();
				if ((Object)(object)component == (Object)null || !SemiFunc.IsMultiplayer())
				{
					return;
				}
				List<PlayerAvatar> list = SemiFunc.PlayerGetList();
				if (list == null)
				{
					return;
				}
				PlayerAvatar val = SemiFunc.PlayerGetLocal();
				foreach (PlayerAvatar item in list)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)val))
					{
						string text = SemiFunc.PlayerGetSteamID(item);
						if (!string.IsNullOrEmpty(text))
						{
							component.RPC("TesterUpgradeCommandRPC", (RpcTarget)1, new object[3] { text, "Stamina", amount });
							Plugin.Logger.LogInfo((object)$"[MegaShop] Synced Host-Only stamina ({amount}) to remote player {((Object)item).name} ({text})");
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop] Remote stamina sync warning: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "GenerateDoneApply")]
	public static class LevelPostProcessingPatch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (SemiFunc.RunIsShop())
			{
				if (Plugin.ConfigInfiniteSprint.Value && SemiFunc.IsMasterClientOrSingleplayer())
				{
					LevelChangeStaminaSyncPatch.SyncRemotePlayersStamina(500);
					Plugin.RemoteStaminaBoostApplied = true;
				}
				if (Plugin.ConfigFloorArrows.Value)
				{
					SpawnFloorGuidanceArrows();
				}
				if (Plugin.ConfigEnableDummies.Value)
				{
					SetupOutdoorShootingRange();
					SpawnTrainingDummies();
				}
			}
		}

		private static void FixFloorZFighting()
		{
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = 0;
				MeshRenderer[] array = Object.FindObjectsByType<MeshRenderer>((FindObjectsSortMode)0);
				foreach (MeshRenderer val in array)
				{
					if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).transform == (Object)null || (Object)(object)((Component)val).GetComponentInParent<Module>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<PlayerAvatar>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<ItemAttributes>() != (Object)null || (Object)(object)((Component)val).GetComponentInParent<Enemy>() != (Object)null)
					{
						continue;
					}
					string text = ((Object)((Component)val).gameObject).name.ToLower();
					if (text.Contains("ground") || text.Contains("asphalt") || text.Contains("terrain") || text.Contains("floor") || text.Contains("street") || text.Contains("landscape") || text.Contains("road") || text.Contains("plane") || text.Contains("dirt"))
					{
						goto IL_0159;
					}
					Bounds bounds = ((Renderer)val).bounds;
					if (((Bounds)(ref bounds)).size.x > 3f)
					{
						bounds = ((Renderer)val).bounds;
						if (((Bounds)(ref bounds)).size.z > 3f)
						{
							goto IL_0159;
						}
					}
					goto IL_01a4;
					IL_01a4:
					if (text.Contains("hill") || text.Contains("mountain") || text.Contains("rock"))
					{
						Transform transform = ((Component)val).transform;
						transform.position += Vector3.forward * 10f + Vector3.down * 3f;
					}
					continue;
					IL_0159:
					bounds = ((Renderer)val).bounds;
					if (Mathf.Abs(((Bounds)(ref bounds)).center.y) < 1.5f)
					{
						Transform transform2 = ((Component)val).transform;
						transform2.position += Vector3.down * 0.15f;
						num++;
					}
					goto IL_01a4;
				}
				Component[] array2 = Object.FindObjectsByType<Component>((FindObjectsSortMode)0);
				foreach (Component val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == "Terrain")
					{
						Transform transform3 = val2.transform;
						transform3.position += Vector3.down * 0.15f;
						num++;
					}
				}
				ModuleConnectObject[] array3 = Object.FindObjectsByType<ModuleConnectObject>((FindObjectsSortMode)0);
				int num2 = 0;
				ModuleConnectObject[] array4 = array3;
				foreach (ModuleConnectObject val3 in array4)
				{
					if ((Object)(object)val3 == (Object)null)
					{
						continue;
					}
					array = ((Component)val3).GetComponentsInChildren<MeshRenderer>();
					foreach (MeshRenderer val4 in array)
					{
						if ((Object)(object)val4 != (Object)null && Mathf.Abs(((Component)val4).transform.position.y) < 0.1f)
						{
							Transform transform4 = ((Component)val4).transform;
							transform4.position += Vector3.up * 0.003f;
							num2++;
						}
					}
				}
				Plugin.Logger.LogInfo((object)$"[MegaShop Optimization] Lowered {num} exterior terrain/ground meshes by 15cm and adjusted {num2} doorway floors. Z-fighting 100% eliminated!");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop] Z-fighting fix error: " + ex.Message));
			}
		}

		private static void SetupOutdoorShootingRange()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)obj).name = "OutdoorShootingRangePlatform";
				obj.transform.position = new Vector3(-31.5f, -0.05f, 22.5f);
				obj.transform.localScale = new Vector3(18f, 0.1f, 16f);
				MeshRenderer component = obj.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).material.color = new Color(0.2f, 0.22f, 0.24f);
				}
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val).name = "OutdoorRailNorth";
				val.transform.position = new Vector3(-31.5f, 0.6f, 30.5f);
				val.transform.localScale = new Vector3(18f, 1.2f, 0.3f);
				if ((Object)(object)val.GetComponent<MeshRenderer>() != (Object)null)
				{
					((Renderer)val.GetComponent<MeshRenderer>()).material.color = new Color(0.3f, 0.32f, 0.35f);
				}
				GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val2).name = "OutdoorRailSouth";
				val2.transform.position = new Vector3(-31.5f, 0.6f, 14.5f);
				val2.transform.localScale = new Vector3(18f, 1.2f, 0.3f);
				if ((Object)(object)val2.GetComponent<MeshRenderer>() != (Object)null)
				{
					((Renderer)val2.GetComponent<MeshRenderer>()).material.color = new Color(0.3f, 0.32f, 0.35f);
				}
				GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val3).name = "OutdoorWallWest";
				val3.transform.position = new Vector3(-40.5f, 2f, 22.5f);
				val3.transform.localScale = new Vector3(0.4f, 4f, 16f);
				if ((Object)(object)val3.GetComponent<MeshRenderer>() != (Object)null)
				{
					((Renderer)val3.GetComponent<MeshRenderer>()).material.color = new Color(0.18f, 0.2f, 0.22f);
				}
				GameObject val4 = new GameObject("OutdoorDoorwaySign");
				val4.transform.position = new Vector3(-22f, 3f, 22.5f);
				val4.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
				TextMesh obj2 = val4.AddComponent<TextMesh>();
				obj2.text = "[ ➜ OUTDOOR RANGE / ТИР НА УЛИЦЕ ➜ ]";
				obj2.fontSize = 34;
				obj2.characterSize = 0.07f;
				obj2.color = Color.cyan;
				obj2.alignment = (TextAlignment)1;
				obj2.anchor = (TextAnchor)4;
				GameObject val5 = new GameObject("TargetRangeSign");
				val5.transform.position = new Vector3(-40f, 3.2f, 22.5f);
				val5.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
				TextMesh obj3 = val5.AddComponent<TextMesh>();
				obj3.text = "[ TARGET PRACTICE / СТРЕЛЬБИЩЕ ]";
				obj3.fontSize = 36;
				obj3.characterSize = 0.08f;
				obj3.color = Color.cyan;
				obj3.alignment = (TextAlignment)1;
				obj3.anchor = (TextAnchor)4;
				GameObject val6 = new GameObject("OutdoorLight1");
				val6.transform.position = new Vector3(-27f, 4.5f, 22.5f);
				Light obj4 = val6.AddComponent<Light>();
				obj4.type = (LightType)2;
				obj4.range = 18f;
				obj4.intensity = 1.5f;
				obj4.color = new Color(0.9f, 0.95f, 1f);
				GameObject val7 = new GameObject("OutdoorLight2");
				val7.transform.position = new Vector3(-37f, 4.5f, 22.5f);
				Light obj5 = val7.AddComponent<Light>();
				obj5.type = (LightType)2;
				obj5.range = 18f;
				obj5.intensity = 1.8f;
				obj5.color = new Color(0.9f, 0.95f, 1f);
				Plugin.Logger.LogInfo((object)"[MegaShop] Outdoor Shooting Range & Patio constructed successfully!");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop] Failed to build outdoor platform: " + ex.Message));
			}
		}

		private static void SpawnFloorGuidanceArrows()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = new GameObject("MegaShop_FloorArrows");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 12f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 8f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 4f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 1f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 27f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 22.5f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 18f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 41f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 36f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(0f, 0.03f, 31f), 180f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(-20f, 0.03f, 22.5f), 90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(-15f, 0.03f, 22.5f), 90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(-9f, 0.03f, 22.5f), 90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(-33f, 0.03f, 22.5f), 90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(-26f, 0.03f, 22.5f), 90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(20f, 0.03f, 22.5f), -90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(15f, 0.03f, 22.5f), -90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(9f, 0.03f, 22.5f), -90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(33f, 0.03f, 22.5f), -90f, "➜ TRUCK / ВЫХОД ➜");
				CreateFloorArrow(val.transform, new Vector3(26f, 0.03f, 22.5f), -90f, "➜ TRUCK / ВЫХОД ➜");
				Plugin.Logger.LogInfo((object)"[MegaShop] Glowing floor guidance arrows placed across all rooms! (Variant 2)");
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop] Failed to spawn floor guidance arrows: " + ex.Message));
			}
		}

		private static void CreateFloorArrow(Transform parent, Vector3 pos, float yaw, string text)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("FloorArrow");
			val.transform.SetParent(parent);
			val.transform.position = pos;
			val.transform.rotation = Quaternion.Euler(90f, yaw, 0f);
			TextMesh obj = val.AddComponent<TextMesh>();
			obj.text = text;
			obj.fontSize = 28;
			obj.characterSize = 0.05f;
			obj.color = new Color(0.2f, 1f, 0.5f, 0.95f);
			obj.alignment = (TextAlignment)1;
			obj.anchor = (TextAnchor)4;
			GameObject val2 = new GameObject("ArrowGlow");
			val2.transform.SetParent(val.transform);
			val2.transform.localPosition = new Vector3(0f, 0.15f, 0f);
			Light obj2 = val2.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.range = 2.5f;
			obj2.intensity = 0.6f;
			obj2.color = new Color(0.2f, 1f, 0.5f);
		}

		private static void SpawnTrainingDummies()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(-37f, 0.05f, 22.5f);
				Quaternion val2 = Quaternion.Euler(0f, 90f, 0f);
				List<EnemySetup> list = (from s in Resources.FindObjectsOfTypeAll<EnemySetup>()
					where (Object)(object)s != (Object)null && s.spawnObjects != null && s.spawnObjects.Count > 0
					select s).ToList();
				if (list.Count == 0 && (Object)(object)EnemyDirector.instance != (Object)null)
				{
					if (EnemyDirector.instance.enemiesDifficulty1 != null)
					{
						list.AddRange(EnemyDirector.instance.enemiesDifficulty1.Where((EnemySetup s) => (Object)(object)s != (Object)null && s.spawnObjects != null && s.spawnObjects.Count > 0));
					}
					if (EnemyDirector.instance.enemiesDifficulty2 != null)
					{
						list.AddRange(EnemyDirector.instance.enemiesDifficulty2.Where((EnemySetup s) => (Object)(object)s != (Object)null && s.spawnObjects != null && s.spawnObjects.Count > 0));
					}
				}
				List<EnemySetup> list2 = (from s in list
					where (Object)(object)s != (Object)null && !string.IsNullOrEmpty(((Object)s).name) && !((Object)s).name.ToLower().Contains("director") && !((Object)s).name.ToLower().Contains("beamer") && !((Object)s).name.ToLower().Contains("ceilingeye") && !((Object)s).name.ToLower().Contains("fuse")
					group s by ((Object)s).name into g
					select g.First()).ToList();
				if (list2.Count == 0)
				{
					list2 = (from s in list
						group s by ((Object)s).name into g
						select g.First()).ToList();
				}
				Vector3[] array = (Vector3[])(object)new Vector3[3]
				{
					new Vector3(0f, 0f, -2.5f),
					new Vector3(0f, 0f, 0f),
					new Vector3(0f, 0f, 2.5f)
				};
				for (int num = 0; num < 3; num++)
				{
					Vector3 val3 = val + array[num];
					PrefabRef val4 = null;
					if (num < list2.Count)
					{
						val4 = ((IEnumerable<PrefabRef>)list2[num].spawnObjects).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef p) => p != null && ((Object)(object)((PrefabRef<GameObject>)(object)p).Prefab != (Object)null || !string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)p).ResourcePath))));
					}
					if (val4 == null && list2.Count > 0)
					{
						val4 = ((IEnumerable<PrefabRef>)list2[0].spawnObjects).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef p) => p != null));
					}
					if (val4 == null)
					{
						continue;
					}
					GameObject val5 = null;
					if (SemiFunc.IsMultiplayer() && !string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)val4).ResourcePath))
					{
						val5 = PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val4).ResourcePath, val3, val2, (byte)0, (object[])null);
					}
					else if ((Object)(object)((PrefabRef<GameObject>)(object)val4).Prefab != (Object)null)
					{
						val5 = Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val4).Prefab, val3, val2);
					}
					if ((Object)(object)val5 == (Object)null)
					{
						continue;
					}
					EnemyParent component = val5.GetComponent<EnemyParent>();
					if ((Object)(object)component != (Object)null)
					{
						AccessTools.Field(typeof(EnemyParent), "SetupDone")?.SetValue(component, true);
						if ((Object)(object)component.EnableObject != (Object)null)
						{
							component.EnableObject.SetActive(true);
						}
					}
					SkinnedMeshRenderer[] componentsInChildren = val5.GetComponentsInChildren<SkinnedMeshRenderer>(true);
					foreach (SkinnedMeshRenderer obj in componentsInChildren)
					{
						((Renderer)obj).enabled = true;
						((Component)obj).gameObject.SetActive(true);
					}
					MeshRenderer[] componentsInChildren2 = val5.GetComponentsInChildren<MeshRenderer>(true);
					foreach (MeshRenderer obj2 in componentsInChildren2)
					{
						((Renderer)obj2).enabled = true;
						((Component)obj2).gameObject.SetActive(true);
					}
					NavMeshAgent componentInChildren = val5.GetComponentInChildren<NavMeshAgent>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						((Behaviour)componentInChildren).enabled = false;
					}
					Enemy componentInChildren2 = val5.GetComponentInChildren<Enemy>();
					if ((Object)(object)componentInChildren2 != (Object)null)
					{
						((Behaviour)componentInChildren2).enabled = true;
					}
					MonoBehaviour[] componentsInChildren3 = val5.GetComponentsInChildren<MonoBehaviour>();
					foreach (MonoBehaviour val6 in componentsInChildren3)
					{
						if (!((Object)(object)val6 == (Object)null))
						{
							string name = ((object)val6).GetType().Name;
							if (name.Contains("Chase") || name.Contains("Investigate") || name.Contains("LookUnder"))
							{
								((Behaviour)val6).enabled = false;
							}
						}
					}
					EnemyVision componentInChildren3 = val5.GetComponentInChildren<EnemyVision>();
					if ((Object)(object)componentInChildren3 != (Object)null)
					{
						componentInChildren3.DisableVision(999999f);
					}
					EnemyHealth componentInChildren4 = val5.GetComponentInChildren<EnemyHealth>();
					if ((Object)(object)componentInChildren4 != (Object)null)
					{
						componentInChildren4.health = 500;
						EnemyHealthHelper.ResetHealth(componentInChildren4);
					}
					val5.AddComponent<TrainingDummyController>().Init(componentInChildren4, componentInChildren3, val3, val2);
					Plugin.Logger.LogInfo((object)$"[MegaShop] Spawned Interactive Training Dummy {num + 1} ({((Object)val5).name}) on Outdoor Patio at {val3}");
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop] Failed to spawn training dummies: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(EnemyParent), "Despawn")]
	public static class PreventDummyDespawnPatch
	{
		[HarmonyPrefix]
		public static bool Prefix()
		{
			if (SemiFunc.RunIsShop())
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyParent), "DespawnRPC")]
	public static class PreventDummyDespawnRPCPatch
	{
		[HarmonyPrefix]
		public static bool Prefix()
		{
			if (SemiFunc.RunIsShop())
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyHealth), "Hurt")]
	public static class DummyHurtPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(EnemyHealth __instance, int _damage, Vector3 _hurtDirection)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsShop())
			{
				EnemyHealthHelper.TriggerHitReaction(__instance, _damage, _hurtDirection);
				Plugin.Logger.LogInfo((object)$"[MegaShop Dummy] Hit registered! Damage: {_damage}, visual flash & sound triggered.");
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyHealth), "Death")]
	public static class PreventDummyDeathPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(EnemyHealth __instance)
		{
			if (SemiFunc.RunIsShop())
			{
				EnemyHealthHelper.ResetHealth(__instance);
				return false;
			}
			return true;
		}
	}
	public class TrainingDummyController : MonoBehaviour
	{
		private EnemyHealth health;

		private EnemyVision vision;

		private Vector3 anchorPos;

		private Quaternion anchorRot;

		private Rigidbody rb;

		public void Init(EnemyHealth h, EnemyVision v, Vector3 pos, Quaternion rot)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			health = h;
			vision = v;
			anchorPos = pos;
			anchorRot = rot;
			rb = ((Component)this).GetComponentInChildren<Rigidbody>();
			if ((Object)(object)rb != (Object)null)
			{
				rb.isKinematic = true;
			}
		}

		private void Update()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)vision != (Object)null)
			{
				vision.DisableVision(9999f);
			}
			if (Vector3.Distance(((Component)this).transform.position, anchorPos) > 0.4f)
			{
				((Component)this).transform.position = anchorPos;
				((Component)this).transform.rotation = anchorRot;
			}
			if ((Object)(object)health != (Object)null && EnemyHealthHelper.GetHealthCurrent(health) < 200)
			{
				EnemyHealthHelper.ResetHealth(health);
			}
		}
	}
	public static class EnemyHealthHelper
	{
		private static readonly FieldInfo HealthCurrentField = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");

		private static readonly FieldInfo DeadField = AccessTools.Field(typeof(EnemyHealth), "dead");

		private static readonly FieldInfo DeadImpulseField = AccessTools.Field(typeof(EnemyHealth), "deadImpulse");

		private static readonly FieldInfo HurtColorField = AccessTools.Field(typeof(EnemyHealth), "hurtColor");

		private static readonly FieldInfo OnHurtField = AccessTools.Field(typeof(EnemyHealth), "onHurt");

		private static readonly MethodInfo MaterialColorFlashMethod = AccessTools.Method(typeof(EnemyHealth), "MaterialColorFlash", new Type[1] { typeof(Color) }, (Type[])null);

		public static int GetHealthCurrent(EnemyHealth h)
		{
			if ((Object)(object)h == (Object)null || HealthCurrentField == null)
			{
				return 500;
			}
			return (int)HealthCurrentField.GetValue(h);
		}

		public static void SetHealthCurrent(EnemyHealth h, int val)
		{
			if (!((Object)(object)h == (Object)null) && !(HealthCurrentField == null))
			{
				HealthCurrentField.SetValue(h, val);
			}
		}

		public static void SetDead(EnemyHealth h, bool val)
		{
			if (!((Object)(object)h == (Object)null) && !(DeadField == null))
			{
				DeadField.SetValue(h, val);
			}
		}

		public static void SetDeadImpulse(EnemyHealth h, bool val)
		{
			if (!((Object)(object)h == (Object)null) && !(DeadImpulseField == null))
			{
				DeadImpulseField.SetValue(h, val);
			}
		}

		public static void ResetHealth(EnemyHealth h)
		{
			if (!((Object)(object)h == (Object)null))
			{
				SetHealthCurrent(h, h.health);
				SetDead(h, val: false);
				SetDeadImpulse(h, val: false);
			}
		}

		public static void TriggerHitReaction(EnemyHealth h, int damage, Vector3 hurtDirection)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)h == (Object)null)
			{
				return;
			}
			try
			{
				Color val = Color.red;
				if (HurtColorField != null)
				{
					val = (Color)HurtColorField.GetValue(h);
				}
				MaterialColorFlashMethod?.Invoke(h, new object[1] { val });
				object? obj = OnHurtField?.GetValue(h);
				object? obj2 = ((obj is UnityEvent) ? obj : null);
				if (obj2 != null)
				{
					((UnityEvent)obj2).Invoke();
				}
				PhotonView val2 = ((Component)h).GetComponent<PhotonView>() ?? ((Component)h).GetComponentInParent<PhotonView>();
				if (SemiFunc.IsMultiplayer() && (Object)(object)val2 != (Object)null)
				{
					val2.RPC("HurtRPC", (RpcTarget)0, new object[2] { damage, hurtDirection });
				}
				else
				{
					h.HurtRPC(damage, hurtDirection, default(PhotonMessageInfo));
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogWarning((object)("[MegaShop Dummy] Hit reaction warning: " + ex.Message));
			}
			ResetHealth(h);
		}
	}
}