Decompiled source of SpawnMenu v1.16.0

SpawnMenu.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SpawnMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SpawnMenu")]
[assembly: AssemblyTitle("SpawnMenu")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SpawnMenu
{
	public enum SpawnKind
	{
		Item,
		Valuable,
		Enemy,
		Money,
		CosmeticBox
	}
	public enum Category
	{
		Upgrades,
		Guns,
		Utilities,
		Medical,
		Valuables,
		Enemies,
		CosmeticBoxes
	}
	public sealed class Entry
	{
		public SpawnKind Kind;

		public string Id = "";

		public string Label = "";

		public string Price = "";

		public float SortPrice = -1f;

		public Func<GameObject?> Prefab = () => (GameObject?)null;
	}
	public static class Catalog
	{
		private static readonly FieldInfo? MultField = typeof(ShopManager).GetField("itemValueMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		public static List<Entry> Build(Category category)
		{
			return category switch
			{
				Category.Upgrades => ItemEntries(IsUpgrade), 
				Category.Guns => ItemEntries(IsGun), 
				Category.Medical => ItemEntries((Item i) => (int)i.itemType == 8), 
				Category.Utilities => ItemEntries((Item i) => !IsUpgrade(i) && !IsGun(i) && (int)i.itemType != 8), 
				Category.Valuables => ValuableEntries(), 
				Category.CosmeticBoxes => CosmeticBoxEntries(), 
				_ => EnemyEntries(), 
			};
		}

		private static List<Entry> CosmeticBoxEntries()
		{
			List<CosmeticWorldObjectSetup> list = ValuableDirector.instance?.cosmeticWorldObjectSetups;
			if (list == null)
			{
				return new List<Entry>();
			}
			return (from s in list
				where s != null && s.prefab != null && ((PrefabRef<GameObject>)(object)s.prefab).IsValid()
				select new Entry
				{
					Kind = SpawnKind.CosmeticBox,
					Id = ((PrefabRef<GameObject>)(object)s.prefab).PrefabName,
					Label = Pretty(((PrefabRef<GameObject>)(object)s.prefab).PrefabName, "Cosmetic World Object "),
					Price = ((object)Unsafe.As<Rarity, Rarity>(ref s.rarity)/*cast due to .constrained prefix*/).ToString(),
					SortPrice = (float)s.rarity,
					Prefab = () => ((PrefabRef<GameObject>)(object)s.prefab).Prefab
				} into e
				group e by e.Id into g
				select g.First()).ToList();
		}

		public static PrefabRef? FindCosmeticBox(string id)
		{
			return ValuableDirector.instance?.cosmeticWorldObjectSetups?.FirstOrDefault((Func<CosmeticWorldObjectSetup, bool>)((CosmeticWorldObjectSetup s) => s != null && s.prefab != null && ((PrefabRef<GameObject>)(object)s.prefab).PrefabName == id))?.prefab;
		}

		private static bool IsUpgrade(Item item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			return (int)item.itemType == 3 || (int)item.itemType == 4;
		}

		private static bool IsGun(Item item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			return (int)item.itemType == 9 || (int)item.itemType == 15;
		}

		private static List<Entry> ItemEntries(Func<Item, bool> keep)
		{
			return (from e in Items.AllItems.Where((Item i) => (Object)(object)i != (Object)null && i.prefab != null && ((PrefabRef<GameObject>)(object)i.prefab).IsValid() && keep(i)).Select(delegate(Item i)
				{
					var (num, max) = ItemPrice(i);
					return new Entry
					{
						Kind = SpawnKind.Item,
						Id = ((Object)i).name,
						Label = (string.IsNullOrEmpty(i.itemName) ? ((Object)i).name : i.itemName),
						Price = Money(num, max),
						SortPrice = num,
						Prefab = () => ((PrefabRef<GameObject>)(object)i.prefab).Prefab
					};
				})
				orderby e.Label
				select e).ToList();
		}

		private static List<Entry> ValuableEntries()
		{
			return (from e in Valuables.AllValuables.Where((PrefabRef v) => ((PrefabRef<GameObject>)(object)v)?.IsValid() ?? false).Select(delegate(PrefabRef v)
				{
					var (num, max) = ValuablePrice(v);
					return new Entry
					{
						Kind = SpawnKind.Valuable,
						Id = ((PrefabRef<GameObject>)(object)v).PrefabName,
						Label = Pretty(((PrefabRef<GameObject>)(object)v).PrefabName, "Valuable "),
						Price = Money(num, max),
						SortPrice = num,
						Prefab = () => ((PrefabRef<GameObject>)(object)v).Prefab
					};
				})
				group e by e.Id into g
				select g.First() into e
				orderby e.Label
				select e).ToList();
		}

		private static List<Entry> EnemyEntries()
		{
			return (from e in Enemies.AllEnemies
				where (Object)(object)e != (Object)null
				select new Entry
				{
					Kind = SpawnKind.Enemy,
					Id = ((Object)e).name,
					Label = (((Object)e).name.StartsWith("Enemy Group - ") ? (Pretty(((Object)e).name, "Enemy Group - ") + " (group)") : Pretty(((Object)e).name, "Enemy - ")),
					Prefab = () => FirstEnemyPrefab(e)
				} into e
				group e by e.Id into g
				select g.First() into e
				orderby e.Label
				select e).ToList();
		}

		public static Item? FindItem(string id)
		{
			return ((IEnumerable<Item>)Items.AllItems).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && ((Object)i).name == id));
		}

		public static PrefabRef? FindValuable(string id)
		{
			return ((IEnumerable<PrefabRef>)Valuables.AllValuables).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef v) => v != null && ((PrefabRef<GameObject>)(object)v).PrefabName == id));
		}

		public static EnemySetup? FindEnemy(string id)
		{
			return ((IEnumerable<EnemySetup>)Enemies.AllEnemies).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup e) => (Object)(object)e != (Object)null && ((Object)e).name == id));
		}

		private static string Money(float min, float max)
		{
			if (min < 0f)
			{
				return "";
			}
			bool k = max >= 1000f;
			string text = (k ? "K" : "");
			return Mathf.Approximately(min, max) ? ("$" + Fmt(max) + text) : ("$" + Fmt(min) + "-" + Fmt(max) + text);
			string Fmt(float v)
			{
				return k ? (v / 1000f).ToString("0.#") : v.ToString("0");
			}
		}

		private static (float min, float max) ItemPrice(Item item)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Invalid comparison between Unknown and I4
			try
			{
				if ((Object)(object)item.value == (Object)null)
				{
					return (min: -1f, max: -1f);
				}
				ShopManager instance = ShopManager.instance;
				float num = (((Object)(object)instance != (Object)null && MultField?.GetValue(instance) is float num2) ? num2 : 4f);
				float num3 = Mathf.Ceil(item.value.valueMin * num / 1000f);
				float num4 = Mathf.Ceil(item.value.valueMax * num / 1000f);
				if ((Object)(object)instance != (Object)null)
				{
					if (IsUpgrade(item))
					{
						num3 = instance.UpgradeValueGet(num3, item);
						num4 = instance.UpgradeValueGet(num4, item);
					}
					else if ((int)item.itemType == 8)
					{
						num3 = instance.HealthPackValueGet(num3);
						num4 = instance.HealthPackValueGet(num4);
					}
					else if ((int)item.itemType == 5)
					{
						num3 = instance.CrystalValueGet(num3);
						num4 = instance.CrystalValueGet(num4);
					}
				}
				return (min: num3 * 1000f, max: num4 * 1000f);
			}
			catch
			{
				return (min: -1f, max: -1f);
			}
		}

		private static (float min, float max) ValuablePrice(PrefabRef valuable)
		{
			try
			{
				GameObject prefab = ((PrefabRef<GameObject>)(object)valuable).Prefab;
				Value val = ((prefab == null) ? null : prefab.GetComponent<ValuableObject>()?.valuePreset);
				if ((Object)(object)val == (Object)null)
				{
					return (min: -1f, max: -1f);
				}
				return (min: val.valueMin, max: val.valueMax);
			}
			catch
			{
				return (min: -1f, max: -1f);
			}
		}

		private static GameObject? FirstEnemyPrefab(EnemySetup setup)
		{
			try
			{
				return ((PrefabRef<GameObject>)(object)setup.spawnObjects?.FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef p) => ((PrefabRef<GameObject>)(object)p)?.IsValid() ?? false)))?.Prefab;
			}
			catch
			{
				return null;
			}
		}

		private static string Pretty(string name, string prefix)
		{
			return name.StartsWith(prefix) ? name.Substring(prefix.Length) : name;
		}
	}
	public static class Cheats
	{
		public sealed class Upgrade
		{
			public string Label = "";

			public string Field = "";

			public string Method = "";
		}

		[HarmonyPatch]
		private static class BatteryPatches
		{
			private static readonly MethodInfo? BarsGet = AccessTools.Method(typeof(ItemBattery), "BatteryBarsGet", (Type[])null, (Type[])null);

			private static readonly FieldInfo? LifeInt = AccessTools.Field(typeof(ItemBattery), "batteryLifeInt");

			[HarmonyPrefix]
			[HarmonyPatch(typeof(ItemBattery), "Drain")]
			[HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")]
			[HarmonyPatch(typeof(ItemBattery), "TriggerSmallBatteryDeduction")]
			[HarmonyPatch(typeof(ItemBattery), "DrainContinuous")]
			private static bool SkipDrain()
			{
				return !InfItemsAny;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ItemBattery), "Update")]
			private static void KeepFull(ItemBattery __instance)
			{
				if (InfItemsAny && !(__instance.batteryLife >= 100f))
				{
					__instance.batteryLife = 100f;
					if (BarsGet != null && LifeInt != null)
					{
						LifeInt.SetValue(__instance, BarsGet.Invoke(__instance, null));
					}
				}
			}
		}

		[HarmonyPatch]
		private static class ConsumablePatches
		{
			private static readonly FieldInfo? UsedField = AccessTools.Field(typeof(ItemHealthPack), "used");

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObject")]
			private static void RespawnConsumable(PhysGrabObjectImpactDetector __instance)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Invalid comparison between Unknown and I4
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Invalid comparison between Unknown and I4
				//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_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				if (InfItemsAny && !((Object)(object)__instance == (Object)null))
				{
					ItemAttributes component = ((Component)__instance).GetComponent<ItemAttributes>();
					Item val = (((Object)(object)component != (Object)null) ? component.item : null);
					if (!((Object)(object)val == (Object)null) && ((int)val.itemType == 6 || (int)val.itemType == 11 || (Object)(object)((Component)__instance).GetComponent<ItemReviveItem>() != (Object)null))
					{
						Spawner.Respawn(val, ((Component)__instance).transform.position + Vector3.up * 0.3f, ((Component)__instance).GetComponent<PhotonView>());
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ItemHealthPack), "UsedRPC")]
			private static void ReuseHealthPack(ItemHealthPack __instance)
			{
				if (InfItemsAny && UsedField != null)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Unuse(__instance));
				}
			}

			private static IEnumerator Unuse(ItemHealthPack pack)
			{
				yield return (object)new WaitForSeconds(1.5f);
				if ((Object)(object)pack != (Object)null)
				{
					UsedField.SetValue(pack, false);
				}
			}
		}

		[HarmonyPatch]
		private static class GrabPatches
		{
			private static readonly FieldInfo? DeadSet = AccessTools.Field(typeof(PlayerAvatar), "deadSet");

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabber), "OverrideGrabRelease")]
			[HarmonyPatch(typeof(PhysGrabber), "OverrideGrabDisable")]
			[HarmonyPatch(typeof(PhysGrabber), "GrabDisableZapTrigger")]
			private static bool KeepHolding(PhysGrabber __instance)
			{
				return ((!NoDrop && !AntiStun) || !((Object)(object)__instance == (Object)(object)PhysGrabber.instance)) && !RemoteHas(__instance, RemoteFlags.Bit.NoDrop);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabber), "ReleaseObjectRPC")]
			private static bool BlockKnockOut(PhysGrabber __instance)
			{
				return ((!NoDrop && !AntiStun) || !((Object)(object)__instance == (Object)(object)PhysGrabber.instance)) && !RemoteHas(__instance, RemoteFlags.Bit.NoDrop);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(EnemySnatcher), "ReleasePhysObjectPlayerGrabs")]
			private static bool NoSnatch()
			{
				return !NoDrop && !AntiStun && !RemoteFlags.Any(RemoteFlags.Bit.NoDrop);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(EnemyRigidbody), "GrabRelease")]
			private static bool KeepMonster()
			{
				return !HoldMonsters && !RemoteFlags.Any(RemoteFlags.Bit.HoldMonsters);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabber), "ReleaseObject")]
			private static bool StillHolding(PhysGrabber __instance)
			{
				if ((Object)(object)__instance != (Object)(object)PhysGrabber.instance || (!HoldMonsters && !NoDrop && !AntiStun))
				{
					return true;
				}
				if ((Object)(object)InputManager.instance == (Object)null || !InputManager.instance.KeyHold((InputKey)10, false))
				{
					return true;
				}
				PlayerAvatar instance = PlayerAvatar.instance;
				if (!((Object)(object)instance == (Object)null))
				{
					object obj = DeadSet?.GetValue(instance);
					bool flag = default(bool);
					int num;
					if (obj is bool)
					{
						flag = (bool)obj;
						num = 1;
					}
					else
					{
						num = 0;
					}
					if (((uint)num & (flag ? 1u : 0u)) == 0)
					{
						object? obj2 = GrabbedRb?.GetValue(__instance);
						Rigidbody val = (Rigidbody)((obj2 is Rigidbody) ? obj2 : null);
						if (val == null || (Object)(object)val == (Object)null)
						{
							return true;
						}
						return ((Object)(object)((Component)val).GetComponentInParent<EnemyRigidbody>() != (Object)null) ? (!HoldMonsters) : (!NoDrop && !AntiStun);
					}
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabber), "PhysGrabOverCharge")]
			[HarmonyPatch(typeof(PhysGrabber), "PhysGrabOverChargeImpact")]
			private static bool NoOverCharge(PhysGrabber __instance)
			{
				return (!SafeMonsterGrab || !((Object)(object)__instance == (Object)(object)PhysGrabber.instance)) && !RemoteHas(__instance, RemoteFlags.Bit.SafeMonsterGrab);
			}
		}

		[HarmonyPatch]
		private static class RevolverPatches
		{
			private static readonly FieldInfo? Loaded = AccessTools.Field(typeof(ItemGunRevolver), "loadedChambers");

			private static readonly FieldInfo? Count = AccessTools.Field(typeof(ItemGunRevolver), "chamberCount");

			private static readonly Dictionary<ItemGunRevolver, (float align, float recover, float index, float settle)> Orig = new Dictionary<ItemGunRevolver, (float, float, float, float)>();

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ItemGunRevolver), "Update")]
			private static void Tick(ItemGunRevolver __instance)
			{
				if (!Orig.TryGetValue(__instance, out (float, float, float, float) value))
				{
					value = (__instance.alignmentTolerance, __instance.recoverTime, __instance.indexTime, __instance.settleTime);
					Orig[__instance] = value;
				}
				if (InfiniteItems && Loaded != null && Count != null)
				{
					int num = (int)Count.GetValue(__instance);
					if (num <= 0 && __instance.bullets != null)
					{
						num = __instance.bullets.Length;
					}
					int num2 = (1 << Mathf.Clamp(num, 1, 30)) - 1;
					if ((int)Loaded.GetValue(__instance) != num2)
					{
						Loaded.SetValue(__instance, num2);
					}
				}
				float alignmentTolerance;
				if (!InfiniteItems)
				{
					(alignmentTolerance, _, _, _) = value;
				}
				else
				{
					alignmentTolerance = 360f;
				}
				__instance.alignmentTolerance = alignmentTolerance;
				float num3 = 1f / (float)Mathf.Max(1, FireRate);
				__instance.recoverTime = value.Item2 * num3;
				__instance.indexTime = value.Item3 * num3;
				__instance.settleTime = value.Item4 * num3;
			}
		}

		[HarmonyPatch]
		private static class GunPatches
		{
			private static readonly Dictionary<ItemGun, (float cooldown, float recoil)> Orig = new Dictionary<ItemGun, (float, float)>();

			[HarmonyPrefix]
			[HarmonyPatch(typeof(ItemGun), "Update")]
			private static void Tick(ItemGun __instance)
			{
				if (!Orig.TryGetValue(__instance, out (float, float) value))
				{
					value = (__instance.shootCooldown, __instance.gunRecoilForce);
					Orig[__instance] = value;
				}
				__instance.shootCooldown = value.Item1 / (float)Mathf.Max(1, FireRate);
				__instance.gunRecoilForce = (NoRecoil ? 0f : value.Item2);
			}
		}

		[HarmonyPatch]
		private static class AutoFirePatches
		{
			private static float _timer;

			private static readonly FieldInfo? Disabled = AccessTools.Field(typeof(ItemToggle), "disabled");

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ItemToggle), "Update")]
			private static void Repeat(ItemToggle __instance)
			{
				if (!AutoFire)
				{
					return;
				}
				object obj = Disabled?.GetValue(__instance);
				bool flag = default(bool);
				int num;
				if (obj is bool)
				{
					flag = (bool)obj;
					num = 1;
				}
				else
				{
					num = 0;
				}
				if (((uint)num & (flag ? 1u : 0u)) != 0)
				{
					return;
				}
				PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>();
				if ((Object)(object)component == (Object)null || !component.grabbedLocal)
				{
					return;
				}
				ItemGun component2 = ((Component)__instance).GetComponent<ItemGun>();
				if ((Object)(object)component2 == (Object)null || (Object)(object)InputManager.instance == (Object)null)
				{
					return;
				}
				if (!InputManager.instance.KeyHold((InputKey)2, false))
				{
					_timer = 0f;
					return;
				}
				_timer += Time.deltaTime;
				float num2 = Mathf.Max(0.03f, component2.shootCooldown);
				if (!(_timer < num2))
				{
					_timer = 0f;
					__instance.ToggleItem(!__instance.toggleState, SemiFunc.PhotonViewIDPlayerAvatarLocal());
				}
			}
		}

		[HarmonyPatch]
		private static class AntiStunPatches
		{
			private static bool Mine(PlayerTumble t)
			{
				return (Object)(object)t != (Object)null && (Object)(object)t.playerAvatar == (Object)(object)PlayerAvatar.instance;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleRequest")]
			private static bool Request(PlayerTumble __instance, bool _isTumbling, bool _playerInput)
			{
				return !(AntiStun && Mine(__instance) && _isTumbling) || _playerInput;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleRequestRPC")]
			private static bool RequestRpc(PlayerTumble __instance, bool _isTumbling, bool _playerInput)
			{
				return !(AntiStun && Mine(__instance) && _isTumbling) || _playerInput;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleSet")]
			private static bool Set(PlayerTumble __instance, bool _isTumbling, bool _playerInput)
			{
				return !(AntiStun && Mine(__instance) && _isTumbling) || _playerInput;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleStunTime")]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleStunTimeRPC")]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleOverrideTime")]
			[HarmonyPatch(typeof(PlayerTumble), "TumbleOverrideTimeRPC")]
			private static bool Stun(PlayerTumble __instance)
			{
				return !AntiStun || !Mine(__instance);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerAvatar), "ForceImpulse")]
			[HarmonyPatch(typeof(PlayerAvatar), "ForceImpulseRPC")]
			private static bool AvatarPush(PlayerAvatar __instance)
			{
				return !AntiStun || !((Object)(object)__instance == (Object)(object)PlayerAvatar.instance);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlayerController), "ForceImpulse")]
			[HarmonyPatch(typeof(PlayerController), "MoveForce")]
			[HarmonyPatch(typeof(PlayerController), "AntiGravity")]
			private static bool ControllerPush(PlayerController __instance)
			{
				return !AntiStun || !((Object)(object)__instance == (Object)(object)PlayerController.instance);
			}
		}

		[HarmonyPatch]
		private static class NoBreakPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Break")]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakHeavy")]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakMedium")]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakLight")]
			private static bool AllowBreak(PhysGrabObjectImpactDetector __instance)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				if (UnbreakableAny && IsLoot(component))
				{
					return false;
				}
				return !NoBreakHeldAny || !component.grabbed;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObject")]
			private static bool NoDestroy(PhysGrabObjectImpactDetector __instance, bool forced)
			{
				if (!UnbreakableAny || forced || (Object)(object)__instance == (Object)null)
				{
					return true;
				}
				PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>();
				if ((Object)(object)component == (Object)null || !IsLoot(component))
				{
					return true;
				}
				return !((Object)(object)((Component)component).GetComponent<ValuableObject>() != (Object)null) && !PitSafePatches.InHurt;
			}
		}

		[HarmonyPatch]
		private static class PitSafePatches
		{
			internal static bool InPit;

			private static readonly FieldInfo? ColliderOwner = AccessTools.Field(AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(HurtCollider), "ColliderCheck", (Type[])null, (Type[])null))?.DeclaringType, "<>4__this");

			internal static bool InHurt;

			[HarmonyTargetMethod]
			private static MethodBase TargetMethod()
			{
				return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(HurtCollider), "ColliderCheck", (Type[])null, (Type[])null));
			}

			[HarmonyPrefix]
			private static void Enter(object __instance)
			{
				InHurt = true;
				int inPit;
				if (PitSafeAny || UnbreakableAny)
				{
					object? obj = ColliderOwner?.GetValue(__instance);
					HurtCollider val = (HurtCollider)((obj is HurtCollider) ? obj : null);
					if (val != null && (Object)(object)val != (Object)null)
					{
						inPit = (val.deathPit ? 1 : 0);
						goto IL_0042;
					}
				}
				inPit = 0;
				goto IL_0042;
				IL_0042:
				InPit = (byte)inPit != 0;
			}

			[HarmonyFinalizer]
			private static void Leave()
			{
				InPit = false;
				InHurt = false;
			}
		}

		[HarmonyPatch]
		private static class PitSafeObjectPatches
		{
			private static readonly FieldInfo? LastHolder = AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing");

			private static readonly FieldInfo? DeadSet = AccessTools.Field(typeof(PlayerAvatar), "deadSet");

			private static bool _inPit => PitSafePatches.InPit;

			private static bool Saveable(PhysGrabObject? pgo)
			{
				return (Object)(object)pgo != (Object)null && (Object)(object)pgo.rb != (Object)null && IsLoot(pgo);
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObject")]
			private static bool NoPitDestroy(PhysGrabObjectImpactDetector __instance, bool forced)
			{
				if (!_inPit || forced)
				{
					return true;
				}
				PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>();
				if (!Saveable(component))
				{
					return true;
				}
				Rescue(component);
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")]
			private static bool NoPitHurt(PhysGrabObject physGrabObject, ref bool __result)
			{
				if (!_inPit || !Saveable(physGrabObject))
				{
					return true;
				}
				Rescue(physGrabObject);
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PhysGrabObject), "Update")]
			private static void OutOfMap(PhysGrabObject __instance)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if ((PitSafeAny || UnbreakableAny) && !(((Component)__instance).transform.position.y >= -50f) && Saveable(__instance) && SemiFunc.IsMasterClientOrSingleplayer())
				{
					Rescue(__instance);
				}
			}

			private static void Rescue(PhysGrabObject pgo)
			{
				//IL_009d: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				object? obj = LastHolder?.GetValue(pgo);
				PlayerAvatar val = (PlayerAvatar)((obj is PlayerAvatar) ? obj : null);
				if ((Object)(object)val == (Object)null || (DeadSet?.GetValue(val) is int num && num != 0))
				{
					val = PlayerAvatar.instance;
				}
				Vector3 val2;
				Quaternion rotation;
				if ((Object)(object)val != (Object)null)
				{
					object obj2 = DeadSet?.GetValue(val);
					if (!(obj2 is bool) || !(bool)obj2)
					{
						Transform transform = ((Component)val).transform;
						val2 = transform.position + transform.forward * 1.2f + Vector3.up * 1f;
						rotation = transform.rotation;
						goto IL_010f;
					}
				}
				if ((Object)(object)TruckSafetySpawnPoint.instance != (Object)null)
				{
					val2 = ((Component)TruckSafetySpawnPoint.instance).transform.position;
					rotation = ((Component)TruckSafetySpawnPoint.instance).transform.rotation;
					goto IL_010f;
				}
				return;
				IL_010f:
				pgo.OverrideIndestructible(3f);
				pgo.Teleport(val2, rotation);
				if (!pgo.rb.isKinematic)
				{
					pgo.rb.linearVelocity = Vector3.zero;
					pgo.rb.angularVelocity = Vector3.zero;
				}
			}
		}

		[HarmonyPatch]
		private static class CosmeticBoxPatches
		{
			private static bool _extracting;

			[HarmonyPrefix]
			[HarmonyPatch(typeof(CosmeticWorldObject), "ExtractRPC")]
			private static void Begin()
			{
				_extracting = true;
			}

			[HarmonyFinalizer]
			[HarmonyPatch(typeof(CosmeticWorldObject), "ExtractRPC")]
			private static void End()
			{
				_extracting = false;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet")]
			private static void NoLimit(ref int __result)
			{
				if (_extracting && (UnlimitedCosmeticBoxes || RemoteFlags.Any(RemoteFlags.Bit.CosmeticBoxes)))
				{
					__result = 9999;
				}
			}
		}

		public static bool GodMode;

		public static bool InfiniteJump;

		public static bool InfiniteItems;

		public static bool InfiniteStamina;

		public static bool UnlimitedCosmeticBoxes;

		public static bool GrabFar;

		public static bool NoDrop;

		public static bool LightGrab;

		public static bool SafeMonsterGrab;

		public static bool NoBreakHeld;

		public static int FireRate = 1;

		public static bool AntiStun;

		public static bool AutoFire;

		public static bool NoRecoil;

		public static bool HoldMonsters;

		public static bool PitSafe;

		public static bool AntiStuck;

		public static bool Unbreakable;

		private static readonly FieldInfo? DebugInfiniteBattery = AccessTools.Field(typeof(RoundDirector), "debugInfiniteBattery");

		private static bool _debugBatterySet;

		private static float? _savedRange;

		private static float? _savedMaxDist;

		private static float? _savedRelease;

		private static float? _savedStrength;

		private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly FieldInfo? GodField = typeof(PlayerHealth).GetField("godMode", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo? JumpExtraCurrentField = typeof(PlayerController).GetField("JumpExtraCurrent", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo? SteamIdField = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool _godApplied;

		private static float _refillTimer;

		private static readonly FieldInfo? GrabbedRb = AccessTools.Field(typeof(PhysGrabber), "grabbedObject");

		private static readonly FieldInfo? GrabbedPgo = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject");

		private static readonly Dictionary<PhysGrabber, float> StuckTime = new Dictionary<PhysGrabber, float>();

		private static float _unstickScan;

		private static PhysGrabber[] _grabbers = (PhysGrabber[])(object)new PhysGrabber[0];

		public static readonly List<Upgrade> Upgrades = new List<Upgrade>
		{
			new Upgrade
			{
				Label = "Health",
				Field = "playerUpgradeHealth",
				Method = "UpgradePlayerHealth"
			},
			new Upgrade
			{
				Label = "Stamina",
				Field = "playerUpgradeStamina",
				Method = "UpgradePlayerEnergy"
			},
			new Upgrade
			{
				Label = "Extra Jump",
				Field = "playerUpgradeExtraJump",
				Method = "UpgradePlayerExtraJump"
			},
			new Upgrade
			{
				Label = "Sprint Speed",
				Field = "playerUpgradeSpeed",
				Method = "UpgradePlayerSprintSpeed"
			},
			new Upgrade
			{
				Label = "Strength",
				Field = "playerUpgradeStrength",
				Method = "UpgradePlayerGrabStrength"
			},
			new Upgrade
			{
				Label = "Throw",
				Field = "playerUpgradeThrow",
				Method = "UpgradePlayerThrowStrength"
			},
			new Upgrade
			{
				Label = "Range",
				Field = "playerUpgradeRange",
				Method = "UpgradePlayerGrabRange"
			},
			new Upgrade
			{
				Label = "Tumble Launch",
				Field = "playerUpgradeLaunch",
				Method = "UpgradePlayerTumbleLaunch"
			},
			new Upgrade
			{
				Label = "Tumble Climb",
				Field = "playerUpgradeTumbleClimb",
				Method = "UpgradePlayerTumbleClimb"
			},
			new Upgrade
			{
				Label = "Tumble Wings",
				Field = "playerUpgradeTumbleWings",
				Method = "UpgradePlayerTumbleWings"
			},
			new Upgrade
			{
				Label = "Crouch Rest",
				Field = "playerUpgradeCrouchRest",
				Method = "UpgradePlayerCrouchRest"
			},
			new Upgrade
			{
				Label = "Death Head Battery",
				Field = "playerUpgradeDeathHeadBattery",
				Method = "UpgradeDeathHeadBattery"
			},
			new Upgrade
			{
				Label = "Map Player Count",
				Field = "playerUpgradeMapPlayerCount",
				Method = "UpgradeMapPlayerCount"
			}
		};

		private static bool InfItemsAny => InfiniteItems || RemoteFlags.Any(RemoteFlags.Bit.InfiniteItems);

		private static bool UnbreakableAny => Unbreakable || RemoteFlags.Any(RemoteFlags.Bit.Unbreakable);

		private static bool PitSafeAny => PitSafe || RemoteFlags.Any(RemoteFlags.Bit.PitSafe);

		private static bool NoBreakHeldAny => NoBreakHeld || RemoteFlags.Any(RemoteFlags.Bit.NoBreakHeld);

		private static bool RemoteHas(PhysGrabber g, RemoteFlags.Bit b)
		{
			return (Object)(object)g.playerAvatar != (Object)null && RemoteFlags.Of(g.playerAvatar.photonView, b);
		}

		public static void Init(Harmony harmony)
		{
			harmony.PatchAll(typeof(BatteryPatches));
			harmony.PatchAll(typeof(ConsumablePatches));
			harmony.PatchAll(typeof(CosmeticBoxPatches));
			harmony.PatchAll(typeof(GrabPatches));
			harmony.PatchAll(typeof(RevolverPatches));
			harmony.PatchAll(typeof(GunPatches));
			harmony.PatchAll(typeof(NoBreakPatches));
			harmony.PatchAll(typeof(AntiStunPatches));
			harmony.PatchAll(typeof(AutoFirePatches));
			harmony.PatchAll(typeof(PitSafePatches));
			harmony.PatchAll(typeof(PitSafeObjectPatches));
		}

		private static float Override(bool on, ref float? saved, float current, float cheatValue)
		{
			if (on)
			{
				if (!saved.HasValue)
				{
					saved = current;
				}
				return cheatValue;
			}
			if (saved.HasValue)
			{
				float value = saved.Value;
				saved = null;
				return value;
			}
			return current;
		}

		private static void TickGrabber()
		{
			PhysGrabber instance = PhysGrabber.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if ((NoDrop || AntiStun) && instance.grabbed)
			{
				object? obj = GrabbedRb?.GetValue(instance);
				Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null);
				if (val != null && (Object)(object)val != (Object)null)
				{
					PhysGrabObject component = ((Component)val).GetComponent<PhysGrabObject>();
					if ((Object)(object)component != (Object)null)
					{
						component.OverrideKnockOutOfGrabDisable(0.5f);
					}
				}
			}
			instance.grabRange = Override(GrabFar, ref _savedRange, instance.grabRange, 100f);
			instance.maxDistanceFromPlayer = Override(GrabFar, ref _savedMaxDist, instance.maxDistanceFromPlayer, 100f);
			instance.grabReleaseDistance = Override(GrabFar || NoDrop, ref _savedRelease, instance.grabReleaseDistance, 1000f);
			instance.grabStrength = Override(LightGrab, ref _savedStrength, instance.grabStrength, Mathf.Max(_savedStrength ?? instance.grabStrength, 1f) * 10f);
		}

		private static void TickUnstick()
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_0132: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: 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_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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: 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)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: 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)
			if ((!AntiStuck && !RemoteFlags.Any(RemoteFlags.Bit.AntiStuck)) || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				StuckTime.Clear();
				return;
			}
			_unstickScan -= Time.deltaTime;
			if (_unstickScan <= 0f)
			{
				_unstickScan = 2f;
				_grabbers = Object.FindObjectsOfType<PhysGrabber>();
			}
			PhysGrabber[] grabbers = _grabbers;
			foreach (PhysGrabber val in grabbers)
			{
				if ((Object)(object)val == (Object)null || !val.grabbed || (Object)(object)val.physGrabPoint == (Object)null)
				{
					if ((Object)(object)val != (Object)null)
					{
						StuckTime.Remove(val);
					}
					continue;
				}
				object? obj = GrabbedPgo?.GetValue(val);
				PhysGrabObject val2 = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null);
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2.rb == (Object)null || val2.rb.isKinematic || !IsLoot(val2))
				{
					continue;
				}
				Vector3 val3 = val.physGrabPointPullerPosition;
				Vector3 val4 = val3 - val.physGrabPoint.position;
				if (((Vector3)(ref val4)).magnitude < 1.5f)
				{
					StuckTime.Remove(val);
					continue;
				}
				StuckTime.TryGetValue(val, out var value);
				value += Time.deltaTime;
				StuckTime[val] = value;
				if (value < 0.3f)
				{
					continue;
				}
				StuckTime.Remove(val);
				? val5;
				if (!((Object)(object)val.playerAvatar != (Object)null))
				{
					val5 = ((Component)val).transform.position;
				}
				else
				{
					PlayerVisionTarget playerVisionTarget = val.playerAvatar.PlayerVisionTarget;
					Vector3? obj2;
					if (playerVisionTarget == null)
					{
						obj2 = null;
					}
					else
					{
						Transform visionTransform = playerVisionTarget.VisionTransform;
						obj2 = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null));
					}
					val5 = ((??)obj2) ?? ((Component)val).transform.position;
				}
				Vector3 val6 = (Vector3)val5;
				Vector3 val7 = val3 - val6;
				RaycastHit[] array = Physics.RaycastAll(val6, ((Vector3)(ref val7)).normalized, ((Vector3)(ref val7)).magnitude);
				for (int j = 0; j < array.Length; j++)
				{
					RaycastHit val8 = array[j];
					if (!((RaycastHit)(ref val8)).collider.isTrigger && !((Object)(object)((Component)((RaycastHit)(ref val8)).collider).GetComponentInParent<PhysGrabObject>() == (Object)(object)val2) && !((Object)(object)((Component)((RaycastHit)(ref val8)).collider).GetComponentInParent<PlayerAvatar>() != (Object)null))
					{
						Vector3 val9 = ((RaycastHit)(ref val8)).point - ((Vector3)(ref val7)).normalized * 0.4f;
						Vector3 val10 = val9 - val6;
						float sqrMagnitude = ((Vector3)(ref val10)).sqrMagnitude;
						val10 = val3 - val6;
						if (sqrMagnitude < ((Vector3)(ref val10)).sqrMagnitude)
						{
							val3 = val9;
						}
					}
				}
				val2.OverrideIndestructible(1f);
				val2.Teleport(val2.rb.position + (val3 - val.physGrabPoint.position), val2.rb.rotation);
				val2.rb.linearVelocity = Vector3.zero;
				val2.rb.angularVelocity = Vector3.zero;
			}
		}

		public static void Tick()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerHealth != (Object)null && GodField != null && (GodMode || _godApplied))
			{
				GodField.SetValue(instance.playerHealth, GodMode);
				_godApplied = GodMode;
			}
			if (InfiniteJump && (Object)(object)PlayerController.instance != (Object)null && JumpExtraCurrentField != null)
			{
				JumpExtraCurrentField.SetValue(PlayerController.instance, 99);
			}
			TickGrabber();
			TickUnstick();
			if ((Object)(object)RoundDirector.instance != (Object)null && DebugInfiniteBattery != null && (InfItemsAny || _debugBatterySet))
			{
				DebugInfiniteBattery.SetValue(RoundDirector.instance, InfItemsAny);
				_debugBatterySet = InfItemsAny;
			}
			if (InfiniteStamina && (Object)(object)PlayerController.instance != (Object)null)
			{
				PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart;
			}
			if (!InfItemsAny || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			_refillTimer -= Time.deltaTime;
			if (!(_refillTimer <= 0f))
			{
				return;
			}
			_refillTimer = 1f;
			ItemBattery[] array = Object.FindObjectsOfType<ItemBattery>();
			foreach (ItemBattery val in array)
			{
				if (val.batteryLife < 100f)
				{
					val.SetBatteryLife(100);
				}
			}
		}

		public static string? LocalSteamId()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			return ((Object)(object)instance != (Object)null) ? (SteamIdField?.GetValue(instance) as string) : null;
		}

		public static int GetLevel(Upgrade u)
		{
			string text = LocalSteamId();
			Dictionary<string, int> dictionary = typeof(StatsManager).GetField(u.Field, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(StatsManager.instance) as Dictionary<string, int>;
			int value;
			return (text != null && dictionary != null && dictionary.TryGetValue(text, out value)) ? value : 0;
		}

		public static void SetLevel(Upgrade u, int level)
		{
			string text = LocalSteamId();
			PunManager instance = PunManager.instance;
			if (text == null || (Object)(object)instance == (Object)null || (Object)(object)StatsManager.instance == (Object)null)
			{
				return;
			}
			int num = level - GetLevel(u);
			if (num != 0)
			{
				MethodInfo method = typeof(PunManager).GetMethod(u.Method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
				{
					typeof(string),
					typeof(int)
				}, null);
				if (method == null)
				{
					Plugin.Log.LogWarning((object)("Upgrade method " + u.Method + " not found"));
					return;
				}
				method.Invoke(instance, new object[2] { text, num });
			}
		}

		internal static bool IsLoot(PhysGrabObject pgo)
		{
			return ((Object)(object)((Component)pgo).GetComponent<ItemAttributes>() != (Object)null || (Object)(object)((Component)pgo).GetComponent<ValuableObject>() != (Object)null) && (Object)(object)((Component)pgo).GetComponentInParent<EnemyRigidbody>() == (Object)null && (Object)(object)((Component)pgo).GetComponentInParent<EnemyParent>() == (Object)null;
		}
	}
	public static class IconRenderer
	{
		private const int Size = 128;

		private const int Layer = 31;

		private static readonly Vector3 StagePos = new Vector3(0f, -5000f, 0f);

		private static Camera? _cam;

		private static RenderTexture? _rt;

		private static readonly Dictionary<string, Texture2D?> Cache = new Dictionary<string, Texture2D>();

		private static readonly Queue<(Entry entry, RawImage target)> Pending = new Queue<(Entry, RawImage)>();

		private static bool _running;

		public static void Request(Entry entry, RawImage target)
		{
			if (Cache.TryGetValue(entry.Id, out Texture2D value))
			{
				Apply(target, value);
				return;
			}
			Pending.Enqueue((entry, target));
			if (!_running)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(Work());
			}
		}

		private static IEnumerator Work()
		{
			_running = true;
			while (Pending.Count > 0)
			{
				for (int i = 0; i < 3; i++)
				{
					if (Pending.Count <= 0)
					{
						break;
					}
					var (entry, target) = Pending.Dequeue();
					if (!Cache.TryGetValue(entry.Id, out Texture2D tex))
					{
						tex = Render(entry.Prefab());
						Cache[entry.Id] = tex;
					}
					if ((Object)(object)target != (Object)null)
					{
						Apply(target, tex);
					}
					tex = null;
				}
				yield return null;
			}
			_running = false;
		}

		private static void Apply(RawImage target, Texture2D? tex)
		{
			//IL_003b: 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)
			if (!((Object)(object)target == (Object)null))
			{
				target.texture = (Texture)(object)tex;
				((Graphic)target).color = (Color)(((Object)(object)tex != (Object)null) ? Color.white : new Color(1f, 1f, 1f, 0f));
			}
		}

		private static Texture2D? Render(GameObject? prefab)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: 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_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_0178: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				return null;
			}
			Setup();
			GameObject val = new GameObject("SpawnMenuIcon");
			val.transform.position = StagePos;
			try
			{
				bool flag = false;
				Bounds bounds = default(Bounds);
				((Bounds)(ref bounds))..ctor(StagePos, Vector3.zero);
				Matrix4x4 worldToLocalMatrix = prefab.transform.worldToLocalMatrix;
				Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren)
				{
					if (!val2.enabled || !ActiveInPrefab(((Component)val2).transform, prefab.transform) || IsVolumeHelper(((Component)val2).transform, prefab.transform))
					{
						continue;
					}
					SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null);
					object obj;
					if (val3 == null)
					{
						if (!(val2 is MeshRenderer))
						{
							obj = null;
						}
						else
						{
							MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
							obj = ((component != null) ? component.sharedMesh : null);
						}
					}
					else
					{
						obj = val3.sharedMesh;
					}
					Mesh val4 = (Mesh)obj;
					if (!((Object)(object)val4 == (Object)null))
					{
						Matrix4x4 val5 = worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
						GameObject val6 = new GameObject("part")
						{
							layer = 31
						};
						val6.transform.SetParent(val.transform, false);
						val6.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val5)).GetColumn(3));
						val6.transform.localRotation = ((Matrix4x4)(ref val5)).rotation;
						val6.transform.localScale = ((Matrix4x4)(ref val5)).lossyScale;
						val6.AddComponent<MeshFilter>().sharedMesh = val4;
						MeshRenderer val7 = val6.AddComponent<MeshRenderer>();
						((Renderer)val7).sharedMaterials = val2.sharedMaterials;
						if (!flag)
						{
							bounds = ((Renderer)val7).bounds;
							flag = true;
						}
						else
						{
							((Bounds)(ref bounds)).Encapsulate(((Renderer)val7).bounds);
						}
					}
				}
				if (!flag || (Object)(object)_cam == (Object)null || (Object)(object)_rt == (Object)null)
				{
					return null;
				}
				Vector3 val8 = Quaternion.Euler(25f, 145f, 0f) * Vector3.forward;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				float num = Mathf.Max(((Vector3)(ref extents)).magnitude, 0.05f);
				float num2 = num / Mathf.Sin(_cam.fieldOfView * 0.5f * (MathF.PI / 180f)) * 1.05f;
				((Component)_cam).transform.position = ((Bounds)(ref bounds)).center - val8 * num2;
				((Component)_cam).transform.rotation = Quaternion.LookRotation(val8);
				_cam.nearClipPlane = Mathf.Max(0.01f, num2 - num * 2f);
				_cam.farClipPlane = num2 + num * 2f;
				_cam.Render();
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = _rt;
				Texture2D val9 = new Texture2D(128, 128, (TextureFormat)4, false);
				val9.ReadPixels(new Rect(0f, 0f, 128f, 128f), 0, 0);
				val9.Apply();
				RenderTexture.active = active;
				return val9;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Icon render failed for " + ((Object)prefab).name + ": " + ex.Message));
				return null;
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		private static bool IsVolumeHelper(Transform t, Transform root)
		{
			Transform val = t;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root)
			{
				if ((Object)(object)((Component)val).GetComponent<ItemVolume>() != (Object)null || (Object)(object)((Component)val).GetComponent<ValuableVolume>() != (Object)null || (Object)(object)((Component)val).GetComponent<RoomVolume>() != (Object)null || ((Object)val).name.IndexOf("volume", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static bool ActiveInPrefab(Transform t, Transform root)
		{
			Transform val = t;
			while ((Object)(object)val != (Object)null)
			{
				if (!((Component)val).gameObject.activeSelf)
				{
					return false;
				}
				if ((Object)(object)val == (Object)(object)root)
				{
					break;
				}
				val = val.parent;
			}
			return true;
		}

		private static void Setup()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_008a: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_cam != (Object)null))
			{
				_rt = new RenderTexture(128, 128, 24, (RenderTextureFormat)0);
				GameObject val = new GameObject("SpawnMenuIconCamera");
				Object.DontDestroyOnLoad((Object)(object)val);
				_cam = val.AddComponent<Camera>();
				((Behaviour)_cam).enabled = false;
				_cam.cullingMask = int.MinValue;
				_cam.clearFlags = (CameraClearFlags)2;
				_cam.backgroundColor = new Color(0f, 0f, 0f, 0f);
				_cam.fieldOfView = 30f;
				_cam.targetTexture = _rt;
				Light val2 = new GameObject("SpawnMenuIconLight").AddComponent<Light>();
				Object.DontDestroyOnLoad((Object)(object)((Component)val2).gameObject);
				val2.type = (LightType)1;
				val2.intensity = 1.3f;
				val2.cullingMask = int.MinValue;
				((Component)val2).transform.rotation = Quaternion.Euler(40f, 120f, 0f);
			}
		}
	}
	[BepInPlugin("YourName.SpawnMenu", "SpawnMenu", "1.16.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private enum SortMode
		{
			Name,
			PriceLow,
			PriceHigh
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<bool> <>9__15_0;

			public static Action<bool> <>9__15_1;

			public static Action<bool> <>9__15_2;

			public static Action<bool> <>9__15_3;

			public static Action<bool> <>9__15_4;

			public static Action<bool> <>9__15_5;

			public static Action<bool> <>9__15_6;

			public static Action<bool> <>9__15_7;

			public static Action<bool> <>9__15_8;

			public static Action<bool> <>9__15_9;

			public static Action<bool> <>9__15_10;

			public static Action<bool> <>9__15_11;

			public static Action<bool> <>9__15_12;

			public static Action<bool> <>9__15_13;

			public static Action<bool> <>9__15_14;

			public static Action<bool> <>9__15_15;

			public static Action<int> <>9__15_18;

			public static ScrollViewBuilderDelegate <>9__15_16;

			public static Action<bool> <>9__15_17;

			public static Action <>9__17_0;

			public static Action <>9__18_0;

			public static Action <>9__18_1;

			public static Action <>9__18_2;

			public static Action <>9__18_3;

			public static Action <>9__18_4;

			public static Action <>9__18_5;

			public static Action <>9__18_6;

			public static Action <>9__21_0;

			public static Func<Entry, bool> <>9__21_5;

			public static Func<Entry, float> <>9__21_6;

			public static Func<Entry, string> <>9__21_7;

			public static Func<Entry, float> <>9__21_8;

			public static Func<Entry, string> <>9__21_9;

			public static Func<Entry, string> <>9__21_10;

			public static Action<string> <>9__23_2;

			public static ScrollViewBuilderDelegate <>9__23_0;

			public static Action <>9__23_3;

			public static Action <>9__23_1;

			internal void <OpenCheatsPage>b__15_0(bool v)
			{
				Cheats.GodMode = v;
			}

			internal void <OpenCheatsPage>b__15_1(bool v)
			{
				Cheats.InfiniteJump = v;
			}

			internal void <OpenCheatsPage>b__15_2(bool v)
			{
				Cheats.InfiniteItems = v;
			}

			internal void <OpenCheatsPage>b__15_3(bool v)
			{
				Cheats.InfiniteStamina = v;
			}

			internal void <OpenCheatsPage>b__15_4(bool v)
			{
				Cheats.GrabFar = v;
			}

			internal void <OpenCheatsPage>b__15_5(bool v)
			{
				Cheats.NoDrop = v;
			}

			internal void <OpenCheatsPage>b__15_6(bool v)
			{
				Cheats.LightGrab = v;
			}

			internal void <OpenCheatsPage>b__15_7(bool v)
			{
				Cheats.SafeMonsterGrab = v;
			}

			internal void <OpenCheatsPage>b__15_8(bool v)
			{
				Cheats.HoldMonsters = v;
			}

			internal void <OpenCheatsPage>b__15_9(bool v)
			{
				Cheats.NoBreakHeld = v;
			}

			internal void <OpenCheatsPage>b__15_10(bool v)
			{
				Cheats.Unbreakable = v;
			}

			internal void <OpenCheatsPage>b__15_11(bool v)
			{
				Cheats.PitSafe = v;
			}

			internal void <OpenCheatsPage>b__15_12(bool v)
			{
				Cheats.AntiStuck = v;
			}

			internal void <OpenCheatsPage>b__15_13(bool v)
			{
				Cheats.AntiStun = v;
			}

			internal void <OpenCheatsPage>b__15_14(bool v)
			{
				Cheats.AutoFire = v;
			}

			internal void <OpenCheatsPage>b__15_15(bool v)
			{
				Cheats.NoRecoil = v;
			}

			internal RectTransform <OpenCheatsPage>b__15_16(Transform scrollView)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				return ((REPOElement)MenuAPI.CreateREPOSlider("Fire Rate", "1 = normal", (Action<int>)delegate(int v)
				{
					Cheats.FireRate = v;
				}, scrollView, Vector2.zero, 1, 20, Cheats.FireRate, "x", "", (BarBehavior)0)).rectTransform;
			}

			internal void <OpenCheatsPage>b__15_18(int v)
			{
				Cheats.FireRate = v;
			}

			internal void <OpenCheatsPage>b__15_17(bool v)
			{
				Cheats.UnlimitedCosmeticBoxes = v;
			}

			internal void <OpenUpgradesPage>b__17_0()
			{
			}

			internal void <OpenCategoryPage>b__18_0()
			{
				OpenListPage("Upgrades", Category.Upgrades);
			}

			internal void <OpenCategoryPage>b__18_1()
			{
				OpenListPage("Guns", Category.Guns);
			}

			internal void <OpenCategoryPage>b__18_2()
			{
				OpenListPage("Utilities", Category.Utilities);
			}

			internal void <OpenCategoryPage>b__18_3()
			{
				OpenListPage("Medical", Category.Medical);
			}

			internal void <OpenCategoryPage>b__18_4()
			{
				OpenListPage("Valuables", Category.Valuables);
			}

			internal void <OpenCategoryPage>b__18_5()
			{
				OpenListPage("Enemies", Category.Enemies);
			}

			internal void <OpenCategoryPage>b__18_6()
			{
				OpenListPage("Cosmetic Boxes", Category.CosmeticBoxes);
			}

			internal void <OpenListPage>b__21_0()
			{
			}

			internal bool <OpenListPage>b__21_5(Entry e)
			{
				return e.SortPrice >= 0f;
			}

			internal float <OpenListPage>b__21_6(Entry e)
			{
				return e.SortPrice;
			}

			internal string <OpenListPage>b__21_7(Entry e)
			{
				return e.Label;
			}

			internal float <OpenListPage>b__21_8(Entry e)
			{
				return e.SortPrice;
			}

			internal string <OpenListPage>b__21_9(Entry e)
			{
				return e.Label;
			}

			internal string <OpenListPage>b__21_10(Entry e)
			{
				return e.Label;
			}

			internal RectTransform <OpenMoneyPage>b__23_0(Transform scrollView)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				return ((REPOElement)MenuAPI.CreateREPOInputField("Amount $", (Action<string>)delegate(string text)
				{
					_moneyText = text;
				}, scrollView, Vector2.zero, false, "10000", _moneyText)).rectTransform;
			}

			internal void <OpenMoneyPage>b__23_2(string text)
			{
				_moneyText = text;
			}

			internal void <OpenMoneyPage>b__23_1()
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				string s = new string(_moneyText.Where(char.IsDigit).ToArray());
				if (int.TryParse(s, out var result))
				{
					Spawner.SpawnMoney(result);
				}
				else
				{
					MenuAPI.OpenPopup("Money Bag", Color.red, "Type a number, e.g. 25000", (Action)delegate
					{
					}, (Action)null);
				}
			}

			internal void <OpenMoneyPage>b__23_3()
			{
			}
		}

		public const string Guid = "YourName.SpawnMenu";

		public const string Name = "SpawnMenu";

		public const string Version = "1.16.0";

		internal static ManualLogSource Log = null;

		internal static Plugin Instance = null;

		internal static ConfigEntry<bool> AllowClients = null;

		internal static ConfigEntry<bool> ClientDirectSpawn = null;

		internal const float ItemDistance = 2f;

		internal const float EnemyDistance = 5f;

		private const float RowWidth = 260f;

		private const float RowHeight = 44f;

		private const float IconSize = 40f;

		private static ConfigEntry<KeyCode> _hotkey = null;

		private static SortMode _sort = SortMode.Name;

		private static string _moneyText = "10000";

		private void Awake()
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			ConfigEntry<float> posX = ((BaseUnityPlugin)this).Config.Bind<float>("EscapeButton", "PosX", 126f, "Spawn Menu button X in the Esc menu");
			ConfigEntry<float> posY = ((BaseUnityPlugin)this).Config.Bind<float>("EscapeButton", "PosY", 12f, "Spawn Menu button Y in the Esc menu");
			AllowClients = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "AllowClients", true, "When you are host: let other players who have SpawnMenu spawn things in your game");
			ClientDirectSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "ClientDirectSpawn", true, "When you joined someone: spawn items/valuables yourself in private (friends) rooms, so the host does not need the mod. Public rooms and enemies still need the host to have SpawnMenu");
			_hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Menu", "Hotkey", (KeyCode)303, "Key that opens Spawn Menu in a level");
			Spawner.Init();
			RemoteFlags.Init();
			Cheats.Init(new Harmony("YourName.SpawnMenu"));
			MenuAPI.AddElementToEscapeMenu((BuilderDelegate)delegate(Transform parent)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Spawn Menu", (Action)OpenCategoryPage, parent, new Vector2(posX.Value, posY.Value));
			});
			Log.LogInfo((object)"SpawnMenu 1.16.0 loaded");
		}

		private void Update()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			Cheats.Tick();
			RemoteFlags.Tick();
			if (Input.GetKeyDown(_hotkey.Value) && (Object)(object)PlayerController.instance != (Object)null && (Object)(object)MenuManager.instance != (Object)null)
			{
				try
				{
					MenuManager.instance.PageOpen((MenuPageIndex)1, false);
					OpenCategoryPage();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Hotkey open failed: " + ex.Message));
				}
			}
		}

		private static void OpenCheatsPage()
		{
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			MenuAPI.CloseAllPagesAddedOnTop();
			REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Cheats", (PresetSide)1, false, false, 1.5f);
			AddToggle(val, "God Mode", Cheats.GodMode, delegate(bool v)
			{
				Cheats.GodMode = v;
			});
			AddToggle(val, "Infinite Jump", Cheats.InfiniteJump, delegate(bool v)
			{
				Cheats.InfiniteJump = v;
			});
			AddToggle(val, "Infinite Items", Cheats.InfiniteItems, delegate(bool v)
			{
				Cheats.InfiniteItems = v;
			});
			AddToggle(val, "Infinite Stamina", Cheats.InfiniteStamina, delegate(bool v)
			{
				Cheats.InfiniteStamina = v;
			});
			AddToggle(val, "Grab From Far", Cheats.GrabFar, delegate(bool v)
			{
				Cheats.GrabFar = v;
			});
			AddToggle(val, "Never Drop", Cheats.NoDrop, delegate(bool v)
			{
				Cheats.NoDrop = v;
			});
			AddToggle(val, "Everything Light", Cheats.LightGrab, delegate(bool v)
			{
				Cheats.LightGrab = v;
			});
			AddToggle(val, "Safe Monster Grab", Cheats.SafeMonsterGrab, delegate(bool v)
			{
				Cheats.SafeMonsterGrab = v;
			});
			AddToggle(val, "Hold Monsters", Cheats.HoldMonsters, delegate(bool v)
			{
				Cheats.HoldMonsters = v;
			});
			AddToggle(val, "Held Items Don't Break", Cheats.NoBreakHeld, delegate(bool v)
			{
				Cheats.NoBreakHeld = v;
			});
			AddToggle(val, "Unbreakable (all items)", Cheats.Unbreakable, delegate(bool v)
			{
				Cheats.Unbreakable = v;
			});
			AddToggle(val, "Pit Safe", Cheats.PitSafe, delegate(bool v)
			{
				Cheats.PitSafe = v;
			});
			AddToggle(val, "Anti Stuck", Cheats.AntiStuck, delegate(bool v)
			{
				Cheats.AntiStuck = v;
			});
			AddToggle(val, "Anti Stun", Cheats.AntiStun, delegate(bool v)
			{
				Cheats.AntiStun = v;
			});
			AddToggle(val, "Hold To Auto Fire", Cheats.AutoFire, delegate(bool v)
			{
				Cheats.AutoFire = v;
			});
			AddToggle(val, "No Recoil", Cheats.NoRecoil, delegate(bool v)
			{
				Cheats.NoRecoil = v;
			});
			object obj = <>c.<>9__15_16;
			if (obj == null)
			{
				ScrollViewBuilderDelegate val2 = (Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOSlider("Fire Rate", "1 = normal", (Action<int>)delegate(int v)
				{
					Cheats.FireRate = v;
				}, scrollView, Vector2.zero, 1, 20, Cheats.FireRate, "x", "", (BarBehavior)0)).rectTransform;
				<>c.<>9__15_16 = val2;
				obj = (object)val2;
			}
			val.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
			AddToggle(val, "Unlimited Cosmetic Boxes", Cheats.UnlimitedCosmeticBoxes, delegate(bool v)
			{
				Cheats.UnlimitedCosmeticBoxes = v;
			});
			AddTextButton(val, "Upgrade Levels", OpenUpgradesPage);
			val.OpenPage(true);
		}

		private static void AddToggle(REPOPopupPage page, string text, bool value, Action<bool> onChange)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOToggle(text, onChange, scrollView, Vector2.zero, "ON", "OFF", value)).rectTransform), 0f, 0f);
		}

		private static void OpenUpgradesPage()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			if (Cheats.LocalSteamId() == null || (Object)(object)StatsManager.instance == (Object)null)
			{
				MenuAPI.OpenPopup("Upgrades", Color.red, "Start a level first.", (Action)delegate
				{
				}, (Action)null);
				return;
			}
			MenuAPI.CloseAllPagesAddedOnTop();
			REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Upgrade Levels", (PresetSide)1, false, false, 1.5f);
			foreach (Cheats.Upgrade upgrade2 in Cheats.Upgrades)
			{
				Cheats.Upgrade upgrade = upgrade2;
				val.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOSlider(upgrade.Label, "", (Action<int>)delegate(int v)
				{
					Cheats.SetLevel(upgrade, v);
				}, scrollView, Vector2.zero, 0, 50, Cheats.GetLevel(upgrade), "", "", (BarBehavior)0)).rectTransform), 0f, 0f);
			}
			AddTextButton(val, "Back", OpenCheatsPage);
			val.OpenPage(true);
		}

		private static void OpenCategoryPage()
		{
			REPOPopupPage page = MenuAPI.CreateREPOPopupPage("Spawn Menu", (PresetSide)0, false, true, 1.5f);
			AddTextButton(page, "Upgrades", delegate
			{
				OpenListPage("Upgrades", Category.Upgrades);
			});
			AddTextButton(page, "Guns", delegate
			{
				OpenListPage("Guns", Category.Guns);
			});
			AddTextButton(page, "Utilities", delegate
			{
				OpenListPage("Utilities", Category.Utilities);
			});
			AddTextButton(page, "Medical", delegate
			{
				OpenListPage("Medical", Category.Medical);
			});
			AddTextButton(page, "Valuables", delegate
			{
				OpenListPage("Valuables", Category.Valuables);
			});
			AddTextButton(page, "Enemies", delegate
			{
				OpenListPage("Enemies", Category.Enemies);
			});
			AddTextButton(page, "Cosmetic Boxes", delegate
			{
				OpenListPage("Cosmetic Boxes", Category.CosmeticBoxes);
			});
			AddTextButton(page, "Money Bag", OpenMoneyPage);
			AddTextButton(page, "Cheats", OpenCheatsPage);
			AddTextButton(page, "Close", delegate
			{
				page.ClosePage(true);
			});
			page.OpenPage(false);
		}

		private static void OpenListPage(string header, Category category)
		{
			MenuAPI.CloseAllPagesAddedOnTop();
			REPOPopupPage val = MenuAPI.CreateREPOPopupPage(header, (PresetSide)1, false, false, 1.5f);
			List<Entry> list = Catalog.Build(category);
			if (list.Count == 0)
			{
				AddTextButton(val, "(empty - start a level first)", delegate
				{
				});
			}
			if (list.Count > 1)
			{
				AddTextButton(val, Mark(SortMode.Name, "Sort: Name A-Z"), delegate
				{
					_sort = SortMode.Name;
					OpenListPage(header, category);
				});
				if (list.Any((Entry e) => e.SortPrice >= 0f))
				{
					AddTextButton(val, Mark(SortMode.PriceLow, "Sort: Price low-high"), delegate
					{
						_sort = SortMode.PriceLow;
						OpenListPage(header, category);
					});
					AddTextButton(val, Mark(SortMode.PriceHigh, "Sort: Price high-low"), delegate
					{
						_sort = SortMode.PriceHigh;
						OpenListPage(header, category);
					});
				}
			}
			SortMode sort = _sort;
			if (1 == 0)
			{
			}
			IOrderedEnumerable<Entry> orderedEnumerable = sort switch
			{
				SortMode.PriceLow => from e in list
					orderby e.SortPrice, e.Label
					select e, 
				SortMode.PriceHigh => from e in list
					orderby e.SortPrice descending, e.Label
					select e, 
				_ => list.OrderBy((Entry e) => e.Label), 
			};
			if (1 == 0)
			{
			}
			IEnumerable<Entry> enumerable = orderedEnumerable;
			foreach (Entry item in enumerable)
			{
				AddEntryRow(val, item);
			}
			val.OpenPage(true);
			static string Mark(SortMode m, string text)
			{
				return (_sort == m) ? ("<color=#FFD54A>" + text + "</color>") : text;
			}
		}

		private static void OpenMoneyPage()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			MenuAPI.CloseAllPagesAddedOnTop();
			REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Money Bag", (PresetSide)1, false, false, 1.5f);
			object obj = <>c.<>9__23_0;
			if (obj == null)
			{
				ScrollViewBuilderDelegate val2 = (Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOInputField("Amount $", (Action<string>)delegate(string text)
				{
					_moneyText = text;
				}, scrollView, Vector2.zero, false, "10000", _moneyText)).rectTransform;
				<>c.<>9__23_0 = val2;
				obj = (object)val2;
			}
			val.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
			AddTextButton(val, "Spawn", delegate
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				string s = new string(_moneyText.Where(char.IsDigit).ToArray());
				if (int.TryParse(s, out var result))
				{
					Spawner.SpawnMoney(result);
				}
				else
				{
					MenuAPI.OpenPopup("Money Bag", Color.red, "Type a number, e.g. 25000", (Action)delegate
					{
					}, (Action)null);
				}
			});
			int[] array = new int[4] { 1000, 10000, 50000, 100000 };
			foreach (int quick in array)
			{
				AddTextButton(val, $"Spawn ${quick:N0}", delegate
				{
					Spawner.SpawnMoney(quick);
				});
			}
			val.OpenPage(true);
		}

		private static void AddTextButton(REPOPopupPage page, string text, Action onClick)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			page.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton(text, onClick, scrollView, default(Vector2))).rectTransform), 0f, 0f);
		}

		private static void AddEntryRow(REPOPopupPage page, Entry entry)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
			{
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: 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_00c0: Expected O, but got Unknown
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Expected O, but got Unknown
				//IL_00ed: 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_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				string arg = ((entry.Price.Length > 0) ? ("  <color=#7CFF6B>" + entry.Price + "</color>") : "");
				string text = $"<space={46f}>{entry.Label}{arg}";
				Action obj = delegate
				{
					Spawner.Spawn(entry);
				};
				Vector2 val = default(Vector2);
				REPOButton val2 = MenuAPI.CreateREPOButton(text, obj, scrollView, val);
				val2.overrideButtonSize = new Vector2(260f, 44f);
				GameObject val3 = new GameObject("Icon", new Type[1] { typeof(RectTransform) });
				RectTransform val4 = (RectTransform)val3.transform;
				((Transform)val4).SetParent((Transform)(object)((REPOElement)val2).rectTransform, false);
				((Vector2)(ref val))..ctor(0f, 0.5f);
				val4.anchorMax = val;
				val4.anchorMin = val;
				val4.pivot = new Vector2(0f, 0.5f);
				val4.anchoredPosition = new Vector2(2f, 0f);
				val4.sizeDelta = new Vector2(40f, 40f);
				RawImage val5 = val3.AddComponent<RawImage>();
				((Graphic)val5).raycastTarget = false;
				((Graphic)val5).color = new Color(1f, 1f, 1f, 0f);
				IconRenderer.Request(entry, val5);
				return ((REPOElement)val2).rectTransform;
			}, 0f, 0f);
		}
	}
	public static class RemoteFlags
	{
		[Flags]
		public enum Bit
		{
			None = 0,
			Unbreakable = 1,
			PitSafe = 2,
			AntiStuck = 4,
			NoBreakHeld = 8,
			NoDrop = 0x10,
			HoldMonsters = 0x20,
			InfiniteItems = 0x40,
			CosmeticBoxes = 0x80,
			SafeMonsterGrab = 0x100
		}

		private static NetworkedEvent? _event;

		private static readonly Dictionary<int, Bit> ByActor = new Dictionary<int, Bit>();

		private static Bit _sent = (Bit)(-1);

		private static float _timer;

		public static Bit Others { get; private set; }

		public static bool Any(Bit b)
		{
			return (Others & b) != 0;
		}

		public static bool Of(PhotonView? view, Bit b)
		{
			Bit value;
			return (Object)(object)view != (Object)null && view.Owner != null && ByActor.TryGetValue(view.Owner.ActorNumber, out value) && (value & b) != 0;
		}

		public static void Init()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			_event = new NetworkedEvent("SpawnMenu Flags", (Action<EventData>)OnFlags);
		}

		private static Bit Mine()
		{
			Bit bit = Bit.None;
			if (Cheats.Unbreakable)
			{
				bit |= Bit.Unbreakable;
			}
			if (Cheats.PitSafe)
			{
				bit |= Bit.PitSafe;
			}
			if (Cheats.AntiStuck)
			{
				bit |= Bit.AntiStuck;
			}
			if (Cheats.NoBreakHeld)
			{
				bit |= Bit.NoBreakHeld;
			}
			if (Cheats.NoDrop || Cheats.AntiStun)
			{
				bit |= Bit.NoDrop;
			}
			if (Cheats.HoldMonsters)
			{
				bit |= Bit.HoldMonsters;
			}
			if (Cheats.InfiniteItems)
			{
				bit |= Bit.InfiniteItems;
			}
			if (Cheats.UnlimitedCosmeticBoxes)
			{
				bit |= Bit.CosmeticBoxes;
			}
			if (Cheats.SafeMonsterGrab)
			{
				bit |= Bit.SafeMonsterGrab;
			}
			return bit;
		}

		public static void Tick()
		{
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			if (_event == null || !PhotonNetwork.InRoom)
			{
				ByActor.Clear();
				Others = Bit.None;
				_sent = (Bit)(-1);
			}
			else if (PhotonNetwork.IsMasterClient)
			{
				_timer -= Time.unscaledDeltaTime;
				if (_timer > 0f)
				{
					return;
				}
				_timer = 3f;
				HashSet<int> here = new HashSet<int>(PhotonNetwork.PlayerList.Select((Player p) => p.ActorNumber));
				foreach (int item in ByActor.Keys.Where((int a) => !here.Contains(a)).ToList())
				{
					ByActor.Remove(item);
				}
				Recompute();
			}
			else
			{
				Bit bit = Mine();
				_timer -= Time.unscaledDeltaTime;
				if (bit != _sent || !(_timer > 0f))
				{
					_timer = 3f;
					_sent = bit;
					_event.RaiseEvent((object)(int)bit, NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable);
				}
			}
		}

		private static void OnFlags(EventData e)
		{
			if (PhotonNetwork.IsMasterClient && e.Sender != PhotonNetwork.LocalPlayer.ActorNumber)
			{
				ByActor[e.Sender] = (Bit)(int)e.CustomData;
				Recompute();
			}
		}

		private static void Recompute()
		{
			Others = ByActor.Values.Aggregate(Bit.None, (Bit a, Bit b) => a | b);
		}
	}
	public static class Spawner
	{
		private static NetworkedEvent? _request;

		private static NetworkedEvent? _ack;

		private static int _waitingFor;

		private static int _counter;

		public const int MaxMoney = 10000000;

		private static readonly FieldInfo? ValueOverrideField = typeof(ValuableObject).GetField("dollarValueOverride", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			_request = new NetworkedEvent("SpawnMenu Request", (Action<EventData>)OnRequest);
			_ack = new NetworkedEvent("SpawnMenu Ack", (Action<EventData>)OnAck);
		}

		public static void SpawnMoney(int amount)
		{
			if (amount <= 0 || amount > 10000000)
			{
				Popup($"Amount must be 1 - {10000000:N0}");
				return;
			}
			Spawn(new Entry
			{
				Kind = SpawnKind.Money,
				Id = amount.ToString(),
				Label = $"${amount:N0} bag"
			});
		}

		public static void Spawn(Entry entry)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			var (val, num) = SpawnPoint((entry.Kind == SpawnKind.Enemy) ? 5f : 2f);
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (!DoSpawn(entry.Kind, entry.Id, val, num))
				{
					Popup("Could not spawn " + entry.Label);
				}
				return;
			}
			if ((entry.Kind == SpawnKind.Item || entry.Kind == SpawnKind.Valuable || entry.Kind == SpawnKind.CosmeticBox) && Plugin.ClientDirectSpawn.Value && IsPrivateRoom())
			{
				if (!ClientSpawn(entry, val, num))
				{
					Popup("Could not spawn " + entry.Label);
				}
				return;
			}
			int num2 = (_waitingFor = ++_counter);
			_request.RaiseEvent((object)new object[7]
			{
				(int)entry.Kind,
				entry.Id,
				val.x,
				val.y,
				val.z,
				num,
				num2
			}, NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable);
			((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForAck(num2));
		}

		private static IEnumerator WaitForAck(int n)
		{
			yield return (object)new WaitForSecondsRealtime(3f);
			if (_waitingFor == n)
			{
				_waitingFor = 0;
				Popup("The host did not answer.\nThe host must also have SpawnMenu installed.");
			}
		}

		private static void OnRequest(EventData e)
		{
			//IL_005b: 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_00ba: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClient())
			{
				object[] array = (object[])e.CustomData;
				int num = (int)array[6];
				bool flag = Plugin.AllowClients.Value && DoSpawn((SpawnKind)(int)array[0], (string)array[1], new Vector3((float)array[2], (float)array[3], (float)array[4]), (float)array[5]);
				NetworkedEvent? ack = _ack;
				object[] obj = new object[3]
				{
					num,
					flag,
					flag ? "" : (Plugin.AllowClients.Value ? "Spawn failed" : "Host turned off client spawning")
				};
				RaiseEventOptions val = new RaiseEventOptions();
				val.TargetActors = new int[1] { e.Sender };
				ack.RaiseEvent((object)obj, val, SendOptions.SendReliable);
			}
		}

		private static void OnAck(EventData e)
		{
			object[] array = (object[])e.CustomData;
			if ((int)array[0] == _waitingFor)
			{
				_waitingFor = 0;
				if (!(bool)array[1])
				{
					Popup((string)array[2]);
				}
			}
		}

		private static bool DoSpawn(SpawnKind kind, string id, Vector3 pos, float yaw)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			//IL_0051: 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_0072: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw + 180f, 0f);
			switch (kind)
			{
			case SpawnKind.Item:
			{
				Item val3 = Catalog.FindItem(id);
				return (Object)(object)val3 != (Object)null && MakeFresh(Items.SpawnItem(val3, pos, val));
			}
			case SpawnKind.Valuable:
			{
				PrefabRef val2 = Catalog.FindValuable(id);
				return val2 != null && (Object)(object)Valuables.SpawnValuable(val2, pos, val) != (Object)null;
			}
			case SpawnKind.Enemy:
			{
				EnemySetup val4 = Catalog.FindEnemy(id);
				return (Object)(object)val4 != (Object)null && Enemies.SpawnEnemy(val4, pos, val, false) != null;
			}
			case SpawnKind.CosmeticBox:
			{
				PrefabRef val5 = Catalog.FindCosmeticBox(id);
				return val5 != null && (Object)(object)NetworkPrefabs.SpawnNetworkPrefab(val5, pos, val, (byte)0, (object[])null) != (Object)null;
			}
			case SpawnKind.Money:
			{
				int result;
				return int.TryParse(id, out result) && result > 0 && result <= 10000000 && DoSpawnMoney(result, pos, val);
			}
			default:
				return false;
			}
		}

		public static void Respawn(Item item, Vector3 pos, PhotonView? view)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(RespawnLater(() => MakeFresh(Items.SpawnItem(item, pos, Quaternion.identity))));
			}
			else if ((Object)(object)view != (Object)null && view.IsMine && Plugin.ClientDirectSpawn.Value && IsPrivateRoom())
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(RespawnLater(() => MakeFresh(PhotonNetwork.Instantiate(((PrefabRef<GameObject>)(object)item.prefab).ResourcePath, pos, Quaternion.identity, (byte)0, (object[])null))));
			}
		}

		private static IEnumerator RespawnLater(Func<bool> spawn)
		{
			yield return (object)new WaitForSeconds(1f);
			spawn();
		}

		private static bool MakeFresh(GameObject? go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			((MonoBehaviour)Plugin.Instance).StartCoroutine(RefillLater(go));
			return true;
		}

		private static IEnumerator RefillLater(GameObject go)
		{
			yield return (object)new WaitForSeconds(0.5f);
			if (!((Object)(object)go == (Object)null))
			{
				ItemBattery[] componentsInChildren = go.GetComponentsInChildren<ItemBattery>(true);
				foreach (ItemBattery battery in componentsInChildren)
				{
					battery.SetBatteryLife(100);
				}
			}
		}

		private static bool DoSpawnMoney(int amount, Vector3 pos, Quaternion rot)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			AssetManager instance = AssetManager.instance;
			if ((Object)(object)instance == (Object)null || ValueOverrideField == null)
			{
				return false;
			}
			GameObject val = ((amount < 10000) ? instance.surplusValuableSmall : ((amount < 30000) ? instance.surplusValuableMedium : instance.surplusValuableBig));
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, pos, rot, (byte)0, (object[])null) : Object.Instantiate<GameObject>(val, pos, rot));
			ValuableObject val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<ValuableObject>() : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return false;
			}
			ValueOverrideField.SetValue(val3, amount);
			return true;
		}

		internal static bool IsPrivateRoom()
		{
			Room currentRoom = PhotonNetwork.CurrentRoom;
			bool flag = currentRoom != null && !currentRoom.IsVisible;
			Plugin.Log.LogInfo((object)$"Room '{((currentRoom != null) ? currentRoom.Name : null)}' visible={((currentRoom != null) ? new bool?(currentRoom.IsVisible) : ((bool?)null))} -> private={flag}");
			return flag;
		}

		private static bool ClientSpawn(Entry entry, Vector3 pos, float yaw)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			PrefabRef val = (PrefabRef)((entry.Kind != SpawnKind.Item) ? ((object)((entry.Kind == SpawnKind.CosmeticBox) ? Catalog.FindCosmeticBox(entry.Id) : Catalog.FindValuable(entry.Id))) : ((object)Catalog.FindItem(entry.Id)?.prefab));
			if (val == null || !((PrefabRef<GameObject>)(object)val).IsValid())
			{
				return false;
			}
			try
			{
				return MakeFresh(PhotonNetwork.Instantiate(((PrefabRef<GameObject>)(object)val).ResourcePath, pos, Quaternion.Euler(0f, yaw + 180f, 0f), (byte)0, (object[])null));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Client spawn failed for " + entry.Id + ": " + ex.Message));
				return false;
			}
		}

		private static (Vector3 pos, float yaw) SpawnPoint(float distance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return (pos: Vector3.zero, yaw: 0f);
			}
			Vector3 val = ((Component)main).transform.forward;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = ((Component)main).transform.up;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 position = ((Component)main).transform.position;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(position, val, ref val2, distance))
			{
				distance = Mathf.Max(0.5f, ((RaycastHit)(ref val2)).distance - 0.5f);
			}
			Vector3 item = position + val * distance;
			Quaternion val3 = Quaternion.LookRotation(val);
			return (pos: item, yaw: ((Quaternion)(ref val3)).eulerAngles.y);
		}

		private static void Popup(string text)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			MenuAPI.OpenPopup("Spawn Menu", Color.red, text, (Action)delegate
			{
			}, (Action)null);
		}
	}
}