Decompiled source of PeakRandomizedChaos v2.0.0

plugins/PeakRandomizedChaos.dll

Decompiled 4 days 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 System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.UI.Extensions;
using Zorro.Core;
using Zorro.Core.Serizalization;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakRandomizedChaos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+a9a51a8c76debe93744f98f5072f74671e132b56")]
[assembly: AssemblyProduct("PeakRandomizedChaos")]
[assembly: AssemblyTitle("PeakRandomizedChaos")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakRandomizer
{
	public class AchievementManagerPatch
	{
		[HarmonyPatch(typeof(AchievementManager), "ThrowAchievement")]
		[HarmonyPrefix]
		private static bool Prefix(AchievementManager __instance)
		{
			return false;
		}
	}
	public class CustomLoot
	{
		public static readonly HashSet<string> ExcludedItemNames = new HashSet<string> { "ScoutCookies_Vanilla", "ClimbingChalk", "Skull", "Warp Compass", "AncientIdol", "Passport", "RescueHook_Infinite", "ScoutsHonor", "ScoutmasterSoul", "Strange Gem" };

		public static readonly HashSet<string> ExcludedItemPrefixes = new HashSet<string> { "C_", "Guidebook", "Amulet_", "Cheat Compass" };

		public static readonly HashSet<string> ExcludedItemSuffixes = new HashSet<string> { "_Prop", "_Prop Variant", "_TEMP", "Spawn", "Placed" };

		public static readonly HashSet<string> TrollItems = new HashSet<string> { "CactusBall", "Mandrake", "Scorpion", "FireWood" };

		private static readonly HashSet<string> GoodItemsBasic = new HashSet<string>
		{
			"Lantern_Faerie", "ChainShooter", "Cure-All", "FirstAidKit", "Glizzy", "Winterberry Yellow", "PandorasBox", "EggTurkey", "Napberry", "Flag_Plantable_Checkpoint",
			"AntiZooka"
		};

		private static readonly HashSet<string> GoodItemsMultiplayer = new HashSet<string> { "Bugle_Magic", "ScoutEffigy", "HealingDart Variant" };

		private static readonly HashSet<string> GoodItemsFloaty = new HashSet<string> { "BalloonBunch", "Anti-Rope Spool", "RopeShooterAnti" };

		public static HashSet<string> GoodItems
		{
			get
			{
				IEnumerable<string> enumerable = new HashSet<string>().Concat(GoodItemsBasic);
				if (Character.AllCharacters.Where((Character c) => !c.isBot).Count() > 1)
				{
					enumerable = enumerable.Concat(GoodItemsMultiplayer);
				}
				return enumerable.ToHashSet();
			}
		}

		public static HashSet<string> GoodItemsBackpack
		{
			get
			{
				IEnumerable<string> first = new HashSet<string>().Concat(GoodItemsBasic);
				if (Character.AllCharacters.Where((Character c) => !c.isBot).Count() > 1)
				{
					first = first.Concat(GoodItemsMultiplayer);
				}
				first = first.Concat(GoodItemsFloaty);
				return first.ToHashSet();
			}
		}

		public static Dictionary<ushort, Item> GetItemsDatabaseFiltered()
		{
			ItemDatabase itemDatabase = SingletonAsset<ItemDatabase>.Instance;
			return itemDatabase.itemLookup.Where((KeyValuePair<ushort, Item> set) => (Object)(object)itemDatabase.itemLookup[set.Key] != (Object)null && !ExcludedItemNames.Contains(((Object)itemDatabase.itemLookup[set.Key]).name) && !ExcludedItemPrefixes.Any((string prefix) => ((Object)itemDatabase.itemLookup[set.Key]).name.StartsWith(prefix)) && !ExcludedItemSuffixes.Any((string suffix) => ((Object)itemDatabase.itemLookup[set.Key]).name.EndsWith(suffix))).ToDictionary((KeyValuePair<ushort, Item> pair) => pair.Key, (KeyValuePair<ushort, Item> pair) => pair.Value);
		}

		public static ushort GetRandomId()
		{
			Dictionary<ushort, Item>.KeyCollection keys = GetItemsDatabaseFiltered().Keys;
			return keys.ElementAt(Random.Range(0, keys.Count()));
		}
	}
	public class GameHandlerPatch
	{
		[HarmonyPatch(typeof(GameHandler), "Update")]
		[HarmonyPrefix]
		private static bool Prefix(GameHandler __instance)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			int num = Interlocked.Exchange(ref RandomEventTask.RequestedQueueInsertions, 0);
			for (int i = 0; i < num; i++)
			{
				RandomizerEvents.RandomEvent();
			}
			RandomizerEvents.EventQueueMutex.WaitOne();
			foreach (string name in RandomizerEvents.EventQueue)
			{
				try
				{
					RandomizerEvents.Events.Where<(string, ConfigEntry<int>, Action)>(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.name == name).First().Item3();
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Error when trying to execute {name}: {arg}");
				}
			}
			RandomizerEvents.EventQueue.Clear();
			RandomizerEvents.EventQueueMutex.ReleaseMutex();
			RandomizerEvents.DestroyQueueMutex.WaitOne();
			foreach (GameObject item in RandomizerEvents.DestroyQueue)
			{
				try
				{
					if ((Object)(object)item != (Object)null)
					{
						PhotonNetwork.Destroy(item);
					}
				}
				catch (Exception arg2)
				{
					Plugin.Log.LogWarning((object)$"Error when trying to DESTROY THING: {arg2}");
				}
			}
			RandomizerEvents.DestroyQueue.Clear();
			RandomizerEvents.DestroyQueueMutex.ReleaseMutex();
			KickSwitcher.CheckKickUndoRequested();
			return true;
		}
	}
	public static class KickSwitcher
	{
		private static bool KickUndoRequested;

		public static bool ToggleKick()
		{
			int value = RunSettings.GetValue((SETTINGTYPE)10200, false);
			if (!RunSettings.SetValue((SETTINGTYPE)10200, (value + 1) % 2))
			{
				return false;
			}
			RunSettings.PushRunSettings((Player)null);
			GlobalEvents.TriggerRunSettingsUpdated();
			return true;
		}

		public static void RequestKickUndo()
		{
			KickUndoRequested = true;
		}

		public static void CheckKickUndoRequested()
		{
			if (KickUndoRequested && !Character.AllCharacters.Any(delegate(Character c)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				AnimatorStateInfo currentAnimatorStateInfo = c.refs.animator.GetCurrentAnimatorStateInfo(0);
				return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Kick");
			}))
			{
				ToggleKick();
				KickUndoRequested = false;
				EnumFlagExtensions.RemoveFlag<NoDuplicates>(RandomizerEvents.ActiveNonDuplicates, NoDuplicates.Skeleton);
			}
		}
	}
	public class LoadingScreenHandlerPatch
	{
		[HarmonyPatch(typeof(LoadingScreenHandler), "LoadSceneProcess")]
		[HarmonyPrefix]
		public static bool Prefix(LoadingScreenHandler __instance, string sceneName, bool networked, bool yieldForCharacterSpawn, float extraYieldTimeOnEnd, ref IEnumerator __result)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				switch (sceneName.ToLower())
				{
				case "airport":
				case "mainmenu":
				case "title":
				case "pretitle":
				case "wilisland":
					RandomEventTask.StopTask();
					break;
				}
			}
			return true;
		}
	}
	public static class LootTablePatch
	{
		[HarmonyPatch(typeof(LootData), "GetRandomItem")]
		[HarmonyPrefix]
		private static bool Prefix(SpawnPool spawnPool, ref GameObject __result)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if (!ModConfig.EnableItemRandomization.Value)
			{
				return true;
			}
			if ((int)spawnPool == 131072 || (int)spawnPool == 32768 || (int)spawnPool == 65536)
			{
				return true;
			}
			if (LootData.AllSpawnWeightData == null)
			{
				LootData.PopulateLootData();
			}
			Item val = default(Item);
			if (ItemDatabase.TryGetItem(CustomLoot.GetRandomId(), ref val))
			{
				__result = ((Component)val).gameObject;
			}
			return false;
		}

		[HarmonyPatch(typeof(LootData), "GetRandomItems")]
		[HarmonyPrefix]
		private static bool Prefix(SpawnPool spawnPool, int count, bool canRepeat, ref List<GameObject> __result)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if (!ModConfig.EnableItemRandomization.Value)
			{
				return true;
			}
			if ((int)spawnPool == 131072 || (int)spawnPool == 32768 || (int)spawnPool == 65536)
			{
				return true;
			}
			__result = new List<GameObject>();
			if (LootData.AllSpawnWeightData == null)
			{
				LootData.PopulateLootData();
			}
			Item val = default(Item);
			for (int i = 0; i < count; i++)
			{
				if (ItemDatabase.TryGetItem(CustomLoot.GetRandomId(), ref val))
				{
					__result.Add(((Component)val).gameObject);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(BerryBush), "SpawnItems")]
		[HarmonyPrefix]
		private static bool Prefix(BerryBush __instance, List<Transform> spawnSpots, ref List<PhotonView> __result)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.EnableItemRandomization.Value)
			{
				return true;
			}
			List<PhotonView> list = new List<PhotonView>();
			if (!PhotonNetwork.IsMasterClient)
			{
				__result = list;
				return false;
			}
			List<Transform> list2 = new List<Transform>(spawnSpots);
			float value = Random.value;
			value = Mathf.Pow(value, __instance.randomPow);
			int num = Mathf.RoundToInt(Mathf.Lerp(__instance.possibleBerries.x, __instance.possibleBerries.y, value));
			if (num > 0 && Random.Range(0, 100) > 33)
			{
				Plugin.Log.LogInfo((object)"Hijacking 0 value berry bush");
				num = Random.Range(1, spawnSpots.Count);
			}
			for (int i = 0; i < spawnSpots.Count && i < num; i++)
			{
				int index = Random.Range(0, list2.Count);
				GameObject val = (((int)((Spawner)__instance).spawnMode != 0) ? LootData.GetRandomItem(((Spawner)__instance).spawnPool, false) : ((Spawner)__instance).spawnedObjectPrefab);
				if ((Object)(object)val != (Object)null)
				{
					Item component = PhotonNetwork.InstantiateItemRoom(((Object)val).name, list2[index].position, Quaternion.identity, true).GetComponent<Item>();
					list.Add(((Component)component).GetComponent<PhotonView>());
					if (Object.op_Implicit((Object)(object)((Spawner)__instance).spawnUpTowardsTarget))
					{
						Transform transform = component.transform;
						Vector3 val2 = ((Spawner)__instance).spawnUpTowardsTarget.position - component.transform.position;
						transform.up = ((Vector3)(ref val2)).normalized;
						component.transform.Rotate(Vector3.up, Random.Range(0f, 360f), (Space)1);
					}
					if (((Spawner)__instance).spawnTransformIsSpawnerTransform)
					{
						component.transform.rotation = list2[index].rotation;
						component.transform.Rotate(Vector3.up, Random.Range(0f, 360f), (Space)1);
					}
					if ((Object)(object)component != (Object)null)
					{
						((Component)component).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
						{
							true,
							component.transform.position,
							component.transform.rotation
						});
					}
					list2.RemoveAt(index);
				}
			}
			__result = list;
			return false;
		}

		[HarmonyPatch(typeof(SpawnList), "GetSpawns")]
		[HarmonyPrefix]
		private static bool Prefix(SpawnList __instance, int count, bool canRepeat, ref List<GameObject> __result)
		{
			if (!ModConfig.EnableItemRandomization.Value)
			{
				return true;
			}
			__result = new List<GameObject>();
			Item val = default(Item);
			for (int i = 0; i < count; i++)
			{
				if (ItemDatabase.TryGetItem(CustomLoot.GetRandomId(), ref val))
				{
					__result.Add(((Component)val).gameObject);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(SpawnList), "GetSingleSpawn")]
		[HarmonyPrefix]
		private static bool Prefix(SpawnList __instance, ref GameObject __result)
		{
			if (!ModConfig.EnableItemRandomization.Value)
			{
				return true;
			}
			Item val = default(Item);
			if (ItemDatabase.TryGetItem(CustomLoot.GetRandomId(), ref val))
			{
				__result = ((Component)val).gameObject;
				return false;
			}
			return true;
		}
	}
	public static class ModConfig
	{
		public static ConfigEntry<bool> EnableItemRandomization { get; private set; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		public static ConfigEntry<bool> EnableTornadoAtKiln { get; private set; }

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

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

		public static void Startup(ConfigFile config)
		{
			EnableItemRandomization = config.Bind<bool>("Randomizer", "EnableItemRandomization", true, "Enable randomized item spawns (luggages, trees, bushes, mushrooms, etc.)");
			WaitTimeMin = config.Bind<int>("Events.Timers", "WaitTimeMin", 30, "The mod picks a random number of seconds to wait between events. This controls the minimum number (in sec).");
			WaitTimeMax = config.Bind<int>("Events.Timers", "WaitTimeMax", 60, "The mod picks a random number of seconds to wait between events. This controls the maximum number (in sec).");
			DecreaseWaitTimePerBiomeAmount = config.Bind<int>("Events.Timers", "DecreaseWaitTimePerBiomeAmount", 5, "Amount (in sec) to decrease the minimum and maximum waiting times with each biome entered");
			EnableTornadoAtKiln = config.Bind<bool>("Events.Settings", "EnableTornadoAtKiln", false, "Enable the Tornado event at the Kiln/Citadel (not recommended).");
			ExtendedDynamiteChance = config.Bind<float>("Events.Settings", "ExtendedDynamiteChance", 0.1f, "Percent chance for dynamites spawned from the Dynamite event to have an extended detonation timer. Ranges from 0.0 to 1.0");
			BoobyTrappedBackpacksChance = config.Bind<float>("Events.Settings", "BoobyTrappedBackpacksChance", 0.1f, "Percent chance for a spawned backpack from the RandomBackpackGood event to be booby-trapped. Ranges from 0.0 to 1.0");
			Tornado = config.Bind<int>("Events.Weights", "Tornado", 5, "Weight of the Tornado event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Tick = config.Bind<int>("Events.Weights", "Tick", 7, "Weight of the Tick event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Bees = config.Bind<int>("Events.Weights", "Bees", 2, "Weight of the Bees event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Tumbleweed = config.Bind<int>("Events.Weights", "Tumbleweed", 10, "Weight of the Tumbleweed event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Dynamite = config.Bind<int>("Events.Weights", "Dynamite", 9, "Weight of the Dynamite event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Zombie = config.Bind<int>("Events.Weights", "Zombie", 6, "Weight of the Zombie event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Mandrake = config.Bind<int>("Events.Weights", "Mandrake", 9, "Weight of the Mandrake event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Cactus = config.Bind<int>("Events.Weights", "Cactus", 10, "Weight of the Cactus event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			RandomItem = config.Bind<int>("Events.Weights", "RandomItem", 10, "Weight of the RandomItem event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			RandomGoodItem = config.Bind<int>("Events.Weights", "RandomGoodItem", 2, "Weight of the RandomGoodItem event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			RandomGoodItemRain = config.Bind<int>("Events.Weights", "RandomGoodItemRain", 1, "Weight of the RandomGoodItemRain event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			BingBongRain = config.Bind<int>("Events.Weights", "BingBongRain", 2, "Weight of the BingBongRain event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			CureAll = config.Bind<int>("Events.Weights", "CureAll", 4, "Weight of the CureAll event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Pandora = config.Bind<int>("Events.Weights", "Pandora", 4, "Weight of the Pandora event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			SwapPlayers = config.Bind<int>("Events.Weights", "SwapPlayers", 6, "Weight of the SwapPlayers event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			WarpToLastPlayer = config.Bind<int>("Events.Weights", "WarpToLowestPlayer", 4, "Weight of the WarpToLowestPlayer event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			SwapPlayerItems = config.Bind<int>("Events.Weights", "SwapPlayerItems", 5, "Weight of the SwapPlayerItems event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			ReviveOne = config.Bind<int>("Events.Weights", "ReviveOne", 5, "Weight of the ReviveOne event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			ReviveAll = config.Bind<int>("Events.Weights", "ReviveAll", 2, "Weight of the ReviveAll event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			HealShroom = config.Bind<int>("Events.Weights", "HealShroom", 4, "Weight of the HealShroom event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			BounceShroom = config.Bind<int>("Events.Weights", "BounceShroom", 8, "Weight of the BounceShroom event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			MoraleBoost = config.Bind<int>("Events.Weights", "MoraleBoost", 5, "Weight of the MoraleBoost event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Scorpion = config.Bind<int>("Events.Weights", "Scorpion", 6, "Weight of the Scorpion event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			RandomBackpack = config.Bind<int>("Events.Weights", "RandomBackpack", 6, "Weight of the RandomBackpack event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			RandomBackpackGood = config.Bind<int>("Events.Weights", "RandomBackpackGood", 1, "Weight of the RandomBackpackGood event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Beanstalk = config.Bind<int>("Events.Weights", "Beanstalk", 7, "Weight of the Beanstalk event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			BeanstalkSpam = config.Bind<int>("Events.Weights", "BeanstalkSpam", 1, "Weight of the BeanstalkSpam event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			EnergyDrink = config.Bind<int>("Events.Weights", "EnergyDrink", 3, "Weight of the EnergyDrink event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Lollipop = config.Bind<int>("Events.Weights", "Lollipop", 3, "Weight of the Lollipop event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Milk = config.Bind<int>("Events.Weights", "Milk", 3, "Weight of the Milk event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			UnlimitedPower = config.Bind<int>("Events.Weights", "UnlimitedPower", 1, "Weight of the UnlimitedPower (EnergyDrink + Lollipop + Milk) event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Skeleton = config.Bind<int>("Events.Weights", "Skeleton", 1, "Weight of the Skeleton event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			TieBalloon = config.Bind<int>("Events.Weights", "TieBalloon", 3, "Weight of the TieBalloon event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			TieThreeBalloons = config.Bind<int>("Events.Weights", "TieThreeBalloons", 1, "Weight of the TieThreeBalloons event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Web = config.Bind<int>("Events.Weights", "Web", 7, "Weight of the Web event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Antirope = config.Bind<int>("Events.Weights", "Antirope", 2, "Weight of the Antirope event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			DayNight = config.Bind<int>("Events.Weights", "DayNightSwap", 3, "Weight of the DayNightSwap event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Eruption = config.Bind<int>("Events.Weights", "Eruption", 7, "Weight of the Eruption event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			TwoAtOnce = config.Bind<int>("Events.Weights", "TwoAtOnce", 2, "Weight of the Two-Effects-At-Once event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Jumpscare = config.Bind<int>("Events.Weights", "Jumpscare", 4, "Weight of the Jumpscare event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Kick = config.Bind<int>("Events.Weights", "Kick", 3, "Weight of the Kick event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			SuperCookies = config.Bind<int>("Events.Weights", "SuperCookies", 1, "Weight of the SuperCookies event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Beetle = config.Bind<int>("Events.Weights", "Beetle", 4, "Weight of the Beetle event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			GhostStationary = config.Bind<int>("Events.Weights", "GhostStationary", 4, "Weight of the GhostStationary event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			GhostChaser = config.Bind<int>("Events.Weights", "GhostChaser", 4, "Weight of the GhostChaser event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			AntiGravity = config.Bind<int>("Events.Weights", "AntiGravity", 3, "Weight of the AntiGravity event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Chain = config.Bind<int>("Events.Weights", "Chain", 2, "Weight of the Chain event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
			Passport = config.Bind<int>("Events.Weights", "Passport", 5, "Weight of the Passport event. Higher weights mean a higher chance of the event happening. 0 = disabled.");
		}
	}
	public class MountainProgressHandlerPatch
	{
		[HarmonyPatch(typeof(MountainProgressHandler), "TriggerReached")]
		[HarmonyPrefix]
		public static bool Prefix(MountainProgressHandler __instance, ProgressPoint progressPoint)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				if (Singleton<MapHandler>.Instance.currentSegment == (RunSettings.isMiniRun ? RunSettings.GetValue((SETTINGTYPE)10050, false) : 0))
				{
					RandomEventTask.StartTask();
					if (!RunSettings.IsCustomRun)
					{
						RunSettings.IsCustomRun = true;
						RunSettings.SetValuesToDefault();
						RunSettings.PushRunSettings((Player)null);
					}
				}
				else
				{
					DeleteGarbage();
					Interlocked.Exchange(ref RandomEventTask.EventTimerOffset, ModConfig.DecreaseWaitTimePerBiomeAmount.Value * Math.Min(Singleton<MapHandler>.Instance.currentSegment, 4));
				}
			}
			return true;
		}

		public static void DeleteStuffOf<T>() where T : MonoBehaviour
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			MapSegment[] segments = Singleton<MapHandler>.Instance.segments;
			GameObject segmentCampfire = segments[Singleton<MapHandler>.Instance.currentSegment - 1].segmentCampfire;
			T[] array = Object.FindObjectsByType<T>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			foreach (T val in array)
			{
				if ((Object)(object)val != (Object)null && segmentCampfire.transform.position.z - ((Component)(object)val).transform.position.z > 20f)
				{
					try
					{
						PhotonNetwork.Destroy(((Component)(object)val).gameObject);
					}
					catch (Exception)
					{
					}
				}
			}
		}

		public static void DeleteGarbage()
		{
			MountainProgressHandlerPatch.DeleteStuffOf<Item>();
			MountainProgressHandlerPatch.DeleteStuffOf<Luggage>();
			MountainProgressHandlerPatch.DeleteStuffOf<RopeAnchorProjectile>();
			MountainProgressHandlerPatch.DeleteStuffOf<RopeAnchorWithRope>();
			MountainProgressHandlerPatch.DeleteStuffOf<Rope>();
			MountainProgressHandlerPatch.DeleteStuffOf<JungleVine>();
			MountainProgressHandlerPatch.DeleteStuffOf<CheckpointFlag>();
			MountainProgressHandlerPatch.DeleteStuffOf<ClimbingSpikeComponent>();
			MountainProgressHandlerPatch.DeleteStuffOf<ShittyPiton>();
			MountainProgressHandlerPatch.DeleteStuffOf<ScoutCannon>();
			MountainProgressHandlerPatch.DeleteStuffOf<Mob>();
			MountainProgressHandlerPatch.DeleteStuffOf<GhostBall>();
			MountainProgressHandlerPatch.DeleteStuffOf<BeeSwarm>();
			MountainProgressHandlerPatch.DeleteStuffOf<MushroomZombie>();
			MountainProgressHandlerPatch.DeleteStuffOf<ShelfShroom>();
			MountainProgressHandlerPatch.DeleteStuffOf<TumbleWeed>();
		}
	}
	public class PauseMenuMainPagePatch
	{
		[HarmonyPatch(typeof(PauseMenuMainPage), "Quit")]
		[HarmonyPrefix]
		public static bool Prefix(PauseMenuMainPage __instance)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				RandomEventTask.StopTask();
			}
			return true;
		}
	}
	[BepInPlugin("PeakRandomizedChaos", "PeakRandomizedChaos", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Id = "PeakRandomizedChaos";

		public static ManualLogSource Log { get; private set; }

		public static string Name => "PeakRandomizedChaos";

		public static string Version => "2.0.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			ModConfig.Startup(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(typeof(LootTablePatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(MountainProgressHandlerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(LoadingScreenHandlerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(GameHandlerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(PauseMenuMainPagePatch), (string)null);
		}
	}
	public class RandomEventTask
	{
		private static Task task = new Task(delegate
		{
		});

		public static int ShouldStopTask = 0;

		public static int EventTimerOffset = 0;

		public static int RequestedQueueInsertions = 0;

		public static void StartTask()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Interlocked.Exchange(ref EventTimerOffset, 0);
			Interlocked.Exchange(ref ShouldStopTask, 0);
			RandomizerEvents.ActiveNonDuplicates = (NoDuplicates)0;
			task = Task.Run(delegate
			{
				Plugin.Log.LogInfo((object)"Starting random event waiter loop");
				while (Interlocked.CompareExchange(ref ShouldStopTask, 0, 0) == 0)
				{
					int num = Interlocked.CompareExchange(ref EventTimerOffset, 0, 0);
					Thread.Sleep(TimeSpan.FromSeconds(Random.Range(ModConfig.WaitTimeMin.Value, ModConfig.WaitTimeMax.Value) - num));
					Interlocked.Increment(ref RequestedQueueInsertions);
				}
				Interlocked.Exchange(ref RequestedQueueInsertions, 0);
				RandomizerEvents.EventQueueMutex.WaitOne();
				RandomizerEvents.EventQueue.Clear();
				RandomizerEvents.EventQueueMutex.ReleaseMutex();
				Plugin.Log.LogInfo((object)"Stopping random event waiter loop");
			});
		}

		public static void StopTask()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Interlocked.Exchange(ref ShouldStopTask, 1);
				Plugin.Log.LogInfo((object)"Setting StopTask to 1");
				RandomizerEvents.CancelToken();
			}
		}
	}
	public class RandomizerEvents
	{
		public static List<string> EventQueue = new List<string>();

		public static Mutex EventQueueMutex = new Mutex();

		public static List<GameObject> DestroyQueue = new List<GameObject>();

		public static Mutex DestroyQueueMutex = new Mutex();

		public static NoDuplicates ActiveNonDuplicates = (NoDuplicates)0;

		public static Vector3 OutOfSight = new Vector3(0f, -9999f, 0f);

		private static CancellationTokenSource cts = new CancellationTokenSource();

		private static CancellationToken token = cts.Token;

		public static readonly List<(string name, ConfigEntry<int>? weightConfigEntry, Action action)> Events = new List<(string, ConfigEntry<int>, Action)>(54)
		{
			("Tornado", ModConfig.Tornado, delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: 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_00db: Expected O, but got Unknown
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < 10; i++)
				{
					Character randomCharacter = GetRandomCharacter();
					Vector3 center = randomCharacter.Center;
					int num = ((Random.Range(0, 2) == 0) ? 1 : (-1));
					center += new Vector3((float)(num * Random.Range(100, 600)), 0f, (float)(num * Random.Range(100, 600)));
					if (Physics.CheckSphere(center, 50f))
					{
						Plugin.Log.LogInfo((object)$"Spawning tornado at: {center.x}, {center.y}, {center.z}");
						GameObject val = PhotonNetwork.Instantiate("Tornado", center, Quaternion.identity, (byte)0, (object[])null);
						if (!((Object)(object)val == (Object)null))
						{
							GameObject val2 = new GameObject();
							Object.Destroy((Object)(object)val2, 300f);
							val2.transform.position = randomCharacter.Center;
							val.GetComponent<Tornado>().target = val2.transform;
							RemoveObjectAfterTime(val, 60f);
							return;
						}
						Plugin.Log.LogInfo((object)$"No tornado wtf (Attempt {i + 1}/10)");
					}
					else
					{
						Plugin.Log.LogInfo((object)$"Oops bad placement for a tornado (Attempt {i + 1}/10)");
					}
				}
				Plugin.Log.LogInfo((object)"Oops bad placement for a tornado after all attempts");
				ForceEvent("Pandora");
			}),
			("Tick", ModConfig.Tick, delegate
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item2 in HumanCharacters())
				{
					GameObject val = PhotonNetwork.Instantiate("BugfixOnYou", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
					val.GetComponent<Bugfix>().AttachBug(((MonoBehaviourPun)item2).photonView.ViewID);
				}
			}),
			("Bees", ModConfig.Bees, delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item3 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item3, (BodypartType)4)).transform.position;
					GameObject val = PhotonNetwork.Instantiate("BeeSwarm", position, Quaternion.identity, (byte)0, (object[])null);
					((MonoBehaviourPun)val.GetComponent<BeeSwarm>()).photonView.RPC("SetBeesAngryRPC", (RpcTarget)3, new object[1] { true });
					RemoveObjectAfterTime(val, 3f);
				}
			}),
			("Tumbleweed", ModConfig.Tumbleweed, delegate
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item4 in HumanCharacters())
				{
					Vector3 val = ((Component)GetCharacterTransform(item4, (BodypartType)14)).transform.position;
					for (int i = 0; i < Random.Range(2, 5); i++)
					{
						int num = ((Random.Range(0, 2) == 0) ? 1 : (-1));
						int num2 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
						val += new Vector3((float)(num * Random.Range(1, 10)), 0f, (float)(num2 * Random.Range(1, 10)));
						if (Physics.CheckSphere(val, 10f))
						{
							GameObject obj = PhotonNetwork.Instantiate("TumbleWeed", val, Quaternion.identity, (byte)0, (object[])null);
							RemoveObjectAfterTime(obj, 15f);
						}
					}
				}
			}),
			("Dynamite", ModConfig.Dynamite, delegate
			{
				if (Random.Range(0f, 1f) < ExtensionMethods.Clamp<float>(ModConfig.ExtendedDynamiteChance.Value, 0f, 1f))
				{
					ForceEvent("DynamiteExtended");
					return;
				}
				foreach (Character item5 in HumanCharacters())
				{
					SummonToCharacter(item5, "Dynamite", kinematic: true);
				}
			}),
			("Zombie", ModConfig.Zombie, delegate
			{
				RandomizerEvents.SpawnMobNearPlayers<MushroomZombie>("MushroomZombie", 30f, shouldDelete: true, 25f, (Func<Character, GameObject>?)null);
			}),
			("Mandrake", ModConfig.Mandrake, delegate
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item6 in ExtCollections.Shuffle<Character>((IList<Character>)HumanCharacters()))
				{
					TryFindObjects<Mandrake>(out List<Mandrake> foundObjects);
					Vector3 position = ((Component)GetCharacterTransform(item6, (BodypartType)4)).transform.position;
					bool flag = false;
					foreach (Mandrake item7 in foundObjects)
					{
						if (Vector3.Distance(((Component)item7).transform.position, position) <= 25f)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						Vector3 val = position + new Vector3(0f, 2f, 0f);
						if (!Physics.CheckSphere(val, 2f))
						{
							val = position;
						}
						GameObject val2 = PhotonNetwork.InstantiateItemRoom("Mandrake", val, Quaternion.identity, true);
						((MonoBehaviourPun)val2.GetComponent<Mandrake>()).photonView.RPC("RPC_Scream", (RpcTarget)3, Array.Empty<object>());
						RemoveObjectAfterTime(val2, 10f);
					}
				}
			}),
			("Cactus", ModConfig.Cactus, delegate
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item8 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item8, (BodypartType)13)).transform.position;
					GameObject obj = PhotonNetwork.InstantiateItemRoom("CactusBall", position, Quaternion.identity, true);
					RemoveObjectAfterTime(obj, 10f);
				}
			}),
			("RandomItem", ModConfig.RandomItem, delegate
			{
				foreach (Character item9 in HumanCharacters())
				{
					SummonToCharacter(item9, ((Object)SingletonAsset<ItemDatabase>.Instance.itemLookup[CustomLoot.GetRandomId()]).name);
				}
			}),
			("RandomGoodItem", ModConfig.RandomGoodItem, delegate
			{
				foreach (Character item10 in HumanCharacters())
				{
					SummonToCharacter(item10, CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count)));
				}
			}),
			("RandomGoodItemRain", ModConfig.RandomGoodItemRain, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: 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_0072: 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_008b: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: 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)
				foreach (Character item11 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item11, (BodypartType)4)).transform.position;
					int num;
					Vector3 val;
					for (num = 5; num > 0; num--)
					{
						val = position + new Vector3(0f, (float)num, 0f);
						if (Physics.CheckSphere(val, 5f))
						{
							break;
						}
					}
					val = position + new Vector3(0f, (float)num, 0f);
					for (int i = -2; i < 2; i += 2)
					{
						for (int j = -2; j < 2; j += 2)
						{
							Vector3 val2 = val + new Vector3((float)i + Random.Range(-1f, 1f), Random.Range(-2f, 2f), (float)j + Random.Range(-1f, 1f));
							if (Physics.CheckSphere(val2, 5f))
							{
								string text = CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count));
								if (text == "Cure-All")
								{
									text = "FortifiedMilk";
								}
								GameObject val3 = PhotonNetwork.InstantiateItemRoom(text, val2, Quaternion.identity, true);
								val3.GetComponent<Item>().SetKinematicNetworked(false);
								RemoveObjectAfterTime(val3);
							}
						}
					}
				}
			}),
			("BingBongRain", ModConfig.BingBongRain, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: 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_0072: 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_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item12 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item12, (BodypartType)4)).transform.position;
					int num;
					Vector3 val;
					for (num = 5; num > 0; num--)
					{
						val = position + new Vector3(0f, (float)num, 0f);
						if (Physics.CheckSphere(val, 5f))
						{
							break;
						}
					}
					val = position + new Vector3(0f, (float)num, 0f);
					for (int i = -2; i < 2; i += 2)
					{
						for (int j = -2; j < 2; j += 2)
						{
							Vector3 val2 = val + new Vector3((float)i + Random.Range(-1f, 1f), Random.Range(-2f, 2f), (float)j + Random.Range(-1f, 1f));
							if (Physics.CheckSphere(val2, 5f))
							{
								GameObject obj = PhotonNetwork.InstantiateItemRoom("BingBong", val2, Quaternion.identity, true);
								RemoveObjectAfterTime(obj, 5f);
							}
						}
					}
				}
			}),
			("CureAll", ModConfig.CureAll, delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item13 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					Vector3 position = ((Component)GetCharacterTransform(item13, (BodypartType)4)).transform.position;
					GameObject val = PhotonNetwork.InstantiateItemRoom("Cure-All", position, Quaternion.identity, true);
					Item component = val.GetComponent<Item>();
					if (component != null)
					{
						ItemCooking cooking = component.cooking;
						if (cooking != null)
						{
							cooking.Explode();
						}
					}
					RemoveObjectAfterTime(val, 5f);
				}
			}),
			("Pandora", ModConfig.Pandora, delegate
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item14 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					if (item14.data.isSkeleton)
					{
						ApplyStatusToCharacter(item14, (STATUSTYPE)5, 0.15f);
					}
					else
					{
						Vector3 position = ((Component)GetCharacterTransform(item14, (BodypartType)4)).transform.position;
						GameObject val = PhotonNetwork.InstantiateItemRoom("PandorasBox", position, Quaternion.identity, true);
						Item component = val.GetComponent<Item>();
						((MonoBehaviourPun)component).photonView.RPC("Consume", (RpcTarget)0, new object[1] { -1 });
						component.cooking.Explode();
						RemoveObjectAfterTime(val, 5f);
					}
				}
			}),
			("SwapPlayers", ModConfig.SwapPlayers, delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list = HumanCharacters(excludeDead: true, excludePassedOut: false, excludeInFog: true);
				List<Vector3> list2 = new List<Vector3>();
				foreach (Character item15 in list)
				{
					list2.Add(((Component)GetCharacterTransform(item15, (BodypartType)2)).transform.position);
					PrepCharacterAsTeleportDestination(item15);
					PrepCharacterAsTeleportee(item15);
				}
				Plugin.Log.LogInfo((object)string.Join(", ", list2));
				List<Vector3> source = list2.ToList();
				source = source.Degenerate().ToList();
				Plugin.Log.LogInfo((object)string.Join(", ", source));
				int num = 0;
				foreach (Character item16 in list)
				{
					((MonoBehaviourPun)item16).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						source[num],
						true
					});
					num++;
				}
			}),
			("WarpToLastPlayer", ModConfig.WarpToLastPlayer, delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Singleton<PeakHandler>.Instance.peakSequence.transform.position + new Vector3(0f, 20f, 0f);
				List<Character> list = HumanCharacters(excludeDead: true, excludePassedOut: false, excludeInFog: true);
				Character val2 = list[0];
				float num = Vector3.Distance(val, GetCharacterTransform(val2, (BodypartType)2).position);
				foreach (Character item17 in list.Skip(1))
				{
					float num2 = Vector3.Distance(val, GetCharacterTransform(item17, (BodypartType)2).position);
					if (num2 > num)
					{
						num = num2;
						val2 = item17;
					}
				}
				PrepCharacterAsTeleportDestination(val2);
				Vector3 position = GetCharacterTransform(val2, (BodypartType)2).position;
				foreach (Character item18 in list)
				{
					if (!((Object)(object)item18 == (Object)(object)val2))
					{
						Vector3 posForTeleportingTo = GetPosForTeleportingTo(val2);
						PrepCharacterAsTeleportee(item18);
						((MonoBehaviourPun)item18).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { posForTeleportingTo, true });
					}
				}
			}),
			("SwapPlayerItems", ModConfig.SwapPlayerItems, delegate
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: 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_023d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0242: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list = HumanCharacters();
				List<byte[]> list2 = new List<byte[]>();
				List<SlotData> list3 = new List<SlotData>();
				InventorySyncData val = default(InventorySyncData);
				foreach (Character item19 in list)
				{
					Player player = item19.player;
					((InventorySyncData)(ref val))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
					byte[] item = IBinarySerializable.ToManagedArray<InventorySyncData>(val);
					list2.Add(item);
					list3.Add(val.tempSlot);
					ItemSlot[] itemSlots = player.itemSlots;
					foreach (ItemSlot val2 in itemSlots)
					{
						val2.EmptyOut();
					}
					((ItemSlot)player.backpackSlot).EmptyOut();
					player.tempFullSlot.EmptyOut();
					byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot));
					item19.player.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array, true });
					item19.refs.items.photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty<object>());
				}
				List<byte[]> source = list2.ToList();
				source = source.Degenerate().ToList();
				for (int j = 0; j < list.Count; j++)
				{
					Character val3 = list[j];
					Player player2 = list[j].player;
					InventorySyncData fromManagedArray = IBinarySerializable.GetFromManagedArray<InventorySyncData>(source[j]);
					fromManagedArray.tempSlot = list3[j];
					byte[] array2 = IBinarySerializable.ToManagedArray<InventorySyncData>(fromManagedArray);
					player2.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array2, true });
					if (val3.refs.items.currentSelectedSlot.IsSome)
					{
						ItemSlot itemSlot = val3.player.GetItemSlot(val3.refs.items.currentSelectedSlot.Value);
						if (!itemSlot.IsEmpty())
						{
							Transform transform = val3.GetBodypart((BodypartType)2).transform;
							PhotonView component = PhotonNetwork.Instantiate("0_Items/" + itemSlot.GetPrefabName(), transform.position + transform.forward * 0.6f, Quaternion.identity, (byte)0, (object[])null).GetComponent<PhotonView>();
							component.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { itemSlot.data });
							int viewID = component.ViewID;
							val3.refs.items.photonView.RPC("EquipSlotRpc", (RpcTarget)0, new object[2]
							{
								(int)val3.refs.items.currentSelectedSlot.Value,
								viewID
							});
						}
					}
				}
			}),
			("ReviveOne", ModConfig.ReviveOne, delegate
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list = DeadHumanCharacters();
				if (list.Count() > 0)
				{
					List<Character> list2 = HumanCharacters();
					Character scout = list2[Random.Range(0, list2.Count())];
					PrepCharacterAsTeleportDestination(scout);
					Vector3 posForTeleportingTo = GetPosForTeleportingTo(scout);
					((MonoBehaviourPun)list[Random.Range(0, list.Count())]).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { posForTeleportingTo, false, -1 });
				}
			}),
			("ReviveAll", ModConfig.ReviveAll, delegate
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list = DeadHumanCharacters();
				if (list.Count() > 0)
				{
					foreach (Character item20 in list)
					{
						List<Character> list2 = HumanCharacters();
						Character scout = list2[Random.Range(0, list2.Count())];
						PrepCharacterAsTeleportDestination(scout);
						Vector3 posForTeleportingTo = GetPosForTeleportingTo(scout);
						((MonoBehaviourPun)item20).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { posForTeleportingTo, false, -1 });
					}
				}
			}),
			("HealShroom", ModConfig.HealShroom, delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item21 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					GameObject obj = PhotonNetwork.InstantiateItemRoom("HealingPuffShroomSpawn", GetCharacterTransform(item21, (BodypartType)2).position, Quaternion.identity, true);
					RemoveObjectAfterTime(obj);
				}
			}),
			("BounceShroom", ModConfig.BounceShroom, delegate
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item22 in HumanCharacters())
				{
					Vector3 position = GetCharacterTransform(item22, (BodypartType)13).position;
					Vector3 position2 = GetCharacterTransform(item22, (BodypartType)16).position;
					GameObject obj = PhotonNetwork.InstantiateItemRoom("BounceShroomSpawn", Vector3.Lerp(position, position2, 0.5f) - new Vector3(0f, 0.5f, 0f), Quaternion.identity, true);
					RemoveObjectAfterTime(obj);
				}
			}),
			("MoraleBoost", ModConfig.MoraleBoost, delegate
			{
				List<Character> list = HumanCharacters(excludeDead: true, excludePassedOut: false);
				foreach (Character item23 in list)
				{
					((MonoBehaviourPun)item23).photonView.RPC("MoraleBoost", (RpcTarget)0, new object[2]
					{
						1f,
						list.Count()
					});
				}
			}),
			("Scorpion", ModConfig.Scorpion, delegate
			{
				foreach (Character item24 in HumanCharacters())
				{
					SummonToCharacter(item24, "Scorpion");
				}
			}),
			("RandomBackpackGood", ModConfig.RandomBackpackGood, delegate
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				if (Random.Range(0f, 1f) < ExtensionMethods.Clamp<float>(ModConfig.BoobyTrappedBackpacksChance.Value, 0f, 1f))
				{
					ForceEvent("RandomBackpackTroll");
					return;
				}
				foreach (Character item25 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item25, (BodypartType)4)).transform.position;
					Vector3 val = position + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val, 4f))
					{
						val = position;
					}
					string[] array = new string[4];
					for (int i = 0; i < 4; i++)
					{
						array[i] = IEnumerableExtensions.RandomElement<string>((IEnumerable<string>)CustomLoot.GoodItemsBackpack);
					}
					RemoveObjectAfterTime(SpawnBackpackWithItems(val, array));
				}
			}),
			("RandomBackpack", ModConfig.RandomBackpack, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item26 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item26, (BodypartType)4)).transform.position;
					Vector3 val = position + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val, 4f))
					{
						val = position;
					}
					string[] array = new string[4];
					for (int i = 0; i < 4; i++)
					{
						string text = ((Object)IEnumerableExtensions.RandomElement<KeyValuePair<ushort, Item>>((IEnumerable<KeyValuePair<ushort, Item>>)CustomLoot.GetItemsDatabaseFiltered()).Value).name;
						switch (text)
						{
						case "Backpack":
							text = "Airplane Food";
							break;
						case "Dynamite":
							text = "TrailMix";
							break;
						case "Mandrake":
							text = "RescueHook";
							break;
						case "Scorpion":
							text = "ScoutCookies";
							break;
						}
						array[i] = text;
					}
					RemoveObjectAfterTime(SpawnBackpackWithItems(val, array));
				}
			}),
			("Beanstalk", ModConfig.Beanstalk, delegate
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val2 = default(Vector3);
				foreach (Character item27 in HumanCharacters())
				{
					Vector3 position = GetCharacterTransform(item27, (BodypartType)13).position;
					Vector3 position2 = GetCharacterTransform(item27, (BodypartType)16).position;
					Vector3 val = Vector3.Lerp(position, position2, 0.5f);
					float num = ((Random.Range(0, 2) == 0) ? 10f : 40f);
					((Vector3)(ref val2))..ctor(Random.Range(-1f, 1f), Random.Range(0f, 1f), Random.Range(-1f, 1f));
					Quaternion val3 = Quaternion.LookRotation(val2, Vector3.up);
					GameObject val4 = PhotonNetwork.InstantiateRoomObject("MagicBeanVine", val, val3, (byte)0, (object[])null);
					val4.GetComponent<PhotonView>().RPC("RPC_GrowVine", (RpcTarget)0, new object[2]
					{
						num,
						(float)PhotonNetwork.Time
					});
					RemoveObjectAfterTime(val4, 60f);
				}
			}),
			("BeanstalkSpam", ModConfig.BeanstalkSpam, delegate
			{
				for (int i = 0; i < 3; i++)
				{
					ForceEvent("Beanstalk");
				}
			}),
			("EnergyDrink", ModConfig.EnergyDrink, delegate
			{
				SpawnAndFeedToAll("Energy Drink", 1);
			}),
			("Lollipop", ModConfig.Lollipop, delegate
			{
				SpawnAndFeedToAll("Lollipop", 1);
			}),
			("Milk", ModConfig.Milk, delegate
			{
				SpawnAndFeedToAll("FortifiedMilk");
			}),
			("UnlimitedPower", ModConfig.UnlimitedPower, delegate
			{
				SpawnAndFeedToAll("Energy Drink", 1);
				SpawnAndFeedToAll("Lollipop", 1);
				SpawnAndFeedToAll("FortifiedMilk");
			}),
			("TwoAtOnce", ModConfig.TwoAtOnce, delegate
			{
				string text = ForceRandomEvent("TwoAtOnce");
				ForceRandomEvent("TwoAtOnce", text);
			}),
			("Skeleton", ModConfig.Skeleton, delegate
			{
				EnumFlagExtensions.SetFlag<NoDuplicates>(ref ActiveNonDuplicates, NoDuplicates.Skeleton);
				foreach (Character item28 in HumanCharacters())
				{
					item28.data.SetSkeleton(!item28.data.isSkeleton);
				}
				QueueEventAfterTime("SkeletonCure", Random.Range(30, 60));
			}),
			("SkeletonCure", null, delegate
			{
				EnumFlagExtensions.RemoveFlag<NoDuplicates>(ActiveNonDuplicates, NoDuplicates.Skeleton);
				foreach (Character item29 in HumanCharacters())
				{
					item29.data.SetSkeleton(!item29.data.isSkeleton);
				}
			}),
			("TieBalloon", ModConfig.TieBalloon, delegate
			{
				foreach (Character item30 in HumanCharacters())
				{
					item30.refs.balloons.TieNewBalloon(0);
				}
			}),
			("TieThreeBalloons", ModConfig.TieThreeBalloons, delegate
			{
				foreach (Character item31 in HumanCharacters())
				{
					item31.refs.balloons.TieNewBalloon(0);
					item31.refs.balloons.TieNewBalloon(0);
					item31.refs.balloons.TieNewBalloon(0);
				}
			}),
			("Web", ModConfig.Web, delegate
			{
				foreach (Character item32 in HumanCharacters())
				{
					ApplyStatusToCharacter(item32, (STATUSTYPE)11, 0.25f);
				}
			}),
			("Antirope", ModConfig.Antirope, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item33 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item33, (BodypartType)4)).transform.position;
					GameObject val = PhotonNetwork.Instantiate("RopeAnchorForRopeShooterAnti", position, Quaternion.identity, (byte)0, (object[])null);
					float num = Random.Range(25f, 60f);
					int num2 = Random.Range(0, 100);
					if (num2 < 10)
					{
						num = Random.Range(100f, 150f);
					}
					else if (num2 < 20)
					{
						num = Random.Range(1f, 10f);
					}
					else if (num2 == 99)
					{
						num = 300f;
					}
					val.GetComponent<RopeAnchorProjectile>().photonView.RPC("GetShot", (RpcTarget)3, new object[4]
					{
						position,
						0f,
						num,
						Vector3.up
					});
					RemoveObjectAfterTime(val, 120f);
					RemoveObjectAfterTime(val.GetComponent<RopeAnchorWithRope>().ropeInstance, 120f);
				}
			}),
			("DayNight", ModConfig.DayNight, delegate
			{
				DayNightManager instance = DayNightManager.instance;
				instance.photonView.RPC("RPCA_SyncTime", (RpcTarget)0, new object[2]
				{
					instance.dayCount,
					(DayNightManager.instance.timeOfDay + 12f) % 24f
				});
			}),
			("Eruption", ModConfig.Eruption, delegate
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				if (TryFindObject<EruptionSpawner>(out EruptionSpawner foundObject) && !((Object)(object)foundObject == (Object)null))
				{
					EruptionSpawner val = foundObject;
					GameObject gameObject = ((Component)((Component)val).transform.parent).gameObject;
					Plugin.Log.LogInfo((object)gameObject);
					Plugin.Log.LogInfo((object)((Object)gameObject).name);
					List<Vector3> list = new List<Vector3>();
					foreach (Character item34 in ExtCollections.Shuffle<Character>((IList<Character>)HumanCharacters()))
					{
						Vector3 position = ((Component)GetCharacterTransform(item34, (BodypartType)13)).transform.position;
						bool flag = false;
						foreach (Vector3 item35 in list)
						{
							if (Vector3.Distance(item35, position) <= 50f)
							{
								flag = true;
								break;
							}
						}
						if (!flag)
						{
							val.photonView.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { position });
							list.Add(new Vector3(position.x, position.y, position.z));
						}
					}
					QueueEventAfterTime("EruptionAloe", 25f);
				}
			}),
			("EruptionAloe", null, delegate
			{
				SpawnAndFeedToAll("AloeVera");
				SpawnAndFeedToAll("AloeVera");
			}),
			("RandomBackpackTroll", null, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item36 in HumanCharacters())
				{
					Vector3 position = ((Component)GetCharacterTransform(item36, (BodypartType)4)).transform.position;
					Vector3 val = position + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val, 4f))
					{
						val = position;
					}
					string[] array = new string[4];
					for (int i = 0; i < 4; i++)
					{
						array[i] = IEnumerableExtensions.RandomElement<string>((IEnumerable<string>)CustomLoot.GoodItemsBackpack);
					}
					string[] array2 = new string[4];
					for (int j = 0; j < 4; j++)
					{
						array2[j] = IEnumerableExtensions.RandomElement<string>((IEnumerable<string>)CustomLoot.TrollItems);
					}
					GameObject obj = SpawnBackpackWithItemsTroll(val, array2, array);
					RemoveObjectAfterTime(obj);
				}
			}),
			("DynamiteExtended", null, delegate
			{
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item37 in HumanCharacters())
				{
					if (!item37.data.dead && !item37.data.fullyPassedOut && !item37.data.passedOut)
					{
						if (item37.data.isClimbingAnything)
						{
							SummonToCharacter(item37, "Dynamite", kinematic: true);
						}
						else
						{
							GameObject val = PhotonNetwork.InstantiateItemRoom("Dynamite", OutOfSight, Quaternion.identity, true);
							Dynamite component = val.GetComponent<Dynamite>();
							Item component2 = ((Component)component).GetComponent<Item>();
							((ItemComponent)component).GetData<FloatItemData>((DataEntryKey)10, (Func<FloatItemData>)component.SetupDefaultFuel).Value = Random.Range(10f, 30f);
							((MonoBehaviourPun)component2).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component2.data });
							item37.refs.items.lastEquippedSlotTime = 0f;
							component2.Interact(item37);
						}
					}
				}
			}),
			("ShakeOnce", ModConfig.Jumpscare, delegate
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: 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)
				((MonoBehaviourPun)Character.localCharacter).photonView.RPC("RPCA_Fall", (RpcTarget)0, new object[2] { -1f, 100f });
				foreach (Character item38 in HumanCharacters())
				{
					Transform transform = ((Component)GetCharacterTransform(item38, (BodypartType)4)).transform;
					Vector3 position = transform.position;
					GameObject val = PhotonNetwork.InstantiateItemRoom("Mandrake", position, Quaternion.identity, true);
					Item component = val.GetComponent<Item>();
					component.isSecretlyOtherItemPrefab = SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Where((Item a) => ((Object)a).name == "MedicinalRoot").First();
					component.view.RPC("SetKinematicAndResetSyncData", (RpcTarget)0, new object[3]
					{
						true,
						position + transform.forward,
						Quaternion.Inverse(((Component)item38.refs.rigCreator).transform.rotation)
					});
					((MonoBehaviourPun)val.GetComponent<Mandrake>()).photonView.RPC("RPC_Scream", (RpcTarget)0, Array.Empty<object>());
					RemoveObjectAfterTime(val, 0.15f);
				}
			}),
			("Kick", ModConfig.Kick, delegate
			{
				if (KickSwitcher.ToggleKick())
				{
					EnumFlagExtensions.SetFlag<NoDuplicates>(ref ActiveNonDuplicates, NoDuplicates.Kick);
					QueueEventAfterTime("KickUndo", Random.Range(30f, 60f));
				}
			}),
			("KickUndo", null, delegate
			{
				KickSwitcher.RequestKickUndo();
			}),
			("SuperCookies", ModConfig.SuperCookies, delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item39 in HumanCharacters(excludeDead: false))
				{
					Vector3 position = ((Component)GetCharacterTransform(item39, (BodypartType)4)).transform.position;
					Vector3 val = position + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val, 4f))
					{
						val = position;
					}
					GameObject val2 = PhotonNetwork.InstantiateItemRoom("ScoutCookies_Vanilla", val, Quaternion.identity, true);
					Item component = val2.GetComponent<Item>();
					OptionableIntItemData data = component.GetData<OptionableIntItemData>((DataEntryKey)2);
					data.HasData = true;
					data.Value = int.MaxValue;
					((MonoBehaviourPun)component).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component.data });
				}
			}),
			("Beetle", ModConfig.Beetle, delegate
			{
				foreach (GameObject item40 in RandomizerEvents.SpawnMobNearPlayers<Beetle>("0_items/Beetle", 20f, shouldDelete: true, 25f, (Func<Character, GameObject>?)null))
				{
					((MonoBehaviourPun)item40.GetComponent<Mob>()).photonView.RPC("RPC_StartAttack", (RpcTarget)0, Array.Empty<object>());
				}
			}),
			("GhostStationary", ModConfig.GhostStationary, delegate
			{
				RandomizerEvents.SpawnMobNearPlayers<GhostBall>("GhostBall", 20f, shouldDelete: false, 25f, (Func<Character, GameObject>?)delegate(Character scout)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
					Transform transform = ((Component)GetCharacterTransform(scout, (BodypartType)4)).transform;
					Vector3 position = transform.position;
					GameObject val = PhotonNetwork.Instantiate("GhostBall", position - new Vector3(0f, 3f, 0f) + transform.forward * 3f, Quaternion.Inverse(((Component)scout.refs.rigCreator).transform.rotation), (byte)0, (object[])null);
					GhostBall component = val.GetComponent<GhostBall>();
					component.chaseHeight = position.y + 1f;
					component.maxHeight = position.y + 1f;
					component.timeBeforeExplosion = Random.Range(10f, 15f);
					component.timeBeforeNoGoingBackImGonnaExplode = 1f;
					component.target = scout;
					RemoveObjectAfterTime(val, component.timeBeforeExplosion + 5f);
					return val;
				});
			}),
			("GhostChaser", ModConfig.GhostChaser, delegate
			{
				RandomizerEvents.SpawnMobNearPlayers<GhostBall>("GhostBall", 20f, shouldDelete: false, 25f, (Func<Character, GameObject>?)delegate(Character scout)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
					Transform transform = ((Component)GetCharacterTransform(scout, (BodypartType)4)).transform;
					Vector3 position = transform.position;
					GameObject val = PhotonNetwork.Instantiate("GhostBall", position + new Vector3(0f, 3f, 0f) + transform.forward * 20f, Quaternion.Inverse(((Component)scout.refs.rigCreator).transform.rotation), (byte)0, (object[])null);
					GhostBall component = val.GetComponent<GhostBall>();
					component.chaseHeight = position.y + 1f;
					component.maxHeight = position.y + 1f;
					component.timeBeforeExplosion = 4f;
					component.timeBeforeNoGoingBackImGonnaExplode = 3.5f;
					component.lifetime = Random.Range(6f, 12f);
					component.target = scout;
					component.repelZoneBuffer = float.NegativeInfinity;
					RemoveObjectAfterTime(val, component.lifetime + 5f);
					return val;
				});
			}),
			("AntiGravity", ModConfig.AntiGravity, delegate
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item41 in HumanCharacters())
				{
					Transform transform = ((Component)GetCharacterTransform(item41, (BodypartType)2)).transform;
					Vector3 position = transform.position;
					PhotonNetwork.Instantiate("AntiSphere_Projectile", position, Quaternion.identity, (byte)0, (object[])null);
				}
			}),
			("Chain", ModConfig.Chain, delegate
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				RaycastHit val2 = default(RaycastHit);
				foreach (Character item42 in HumanCharacters())
				{
					Vector3 position = GetCharacterTransform(item42, (BodypartType)2).position;
					Transform characterTransform = GetCharacterTransform(item42, (BodypartType)4);
					float num = Random.Range(-3f, 0f);
					Vector3 val = position + characterTransform.forward * 60f;
					if (Physics.Raycast(position, characterTransform.forward, ref val2, 60f, LayerMask.op_Implicit(HelperExtensions.ToLayerMask((LayerType)1)), (QueryTriggerInteraction)0))
					{
						val = ((RaycastHit)(ref val2)).point;
					}
					Vector3 val3 = (position + val) / 2f + new Vector3(0f, num, 0f);
					GameObject val4 = PhotonNetwork.Instantiate("ChainShootable", position, Quaternion.identity, (byte)0, (object[])null);
					val4.GetComponent<JungleVine>().photonView.RPC("ForceBuildVine_RPC", (RpcTarget)3, new object[4] { position, val, num, val3 });
					RemoveObjectAfterTime(val4, 120f);
				}
			}),
			("Passport", ModConfig.Passport, delegate
			{
				SpawnAndFeedToAll("Passport");
				Character[] scouts = (from scout in HumanCharacters()
					where !scout.data.isGrounded
					select scout).ToArray();
				UseAmuletOnSome("Amulet_SuperJump", scouts);
				SpawnAndFeedToSome("Apple Berry Yellow", 0, scouts);
			}),
			("ListItems", null, delegate
			{
				Plugin.Log.LogInfo((object)string.Join("\n", SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Select((Item x) => ((Object)x).name)));
			})
		};

		public static void CancelToken()
		{
			cts.Cancel();
			cts = new CancellationTokenSource();
			token = cts.Token;
		}

		public static void RemoveObjectAfterTime(GameObject obj, float time = 30f)
		{
			CancellationToken tokenCopy = token;
			Task.Run(delegate
			{
				Thread.Sleep(TimeSpan.FromSeconds(time));
				if (!tokenCopy.IsCancellationRequested)
				{
					DestroyQueueMutex.WaitOne();
					DestroyQueue.Add(obj);
					DestroyQueueMutex.ReleaseMutex();
				}
			}, token);
		}

		private static List<Character> HumanCharacters(bool excludeDead = true, bool excludePassedOut = true, bool excludeInFog = false)
		{
			return Character.AllCharacters.Where((Character c) => !c.isBot && (!excludeDead || !c.data.dead) && (!excludePassedOut || !c.data.fullyPassedOut) && (!excludeInFog || (!c.data.isInFog && !LavaRising.ALL_LAVA.Any((LavaRising l) => ((Component)l.lava).transform.position.y + 2f >= GetCharacterTransform(c, (BodypartType)13).position.y)))).ToList();
		}

		private static List<Character> DeadHumanCharacters()
		{
			return Character.AllCharacters.Where((Character c) => !c.isBot && (c.data.dead || c.data.fullyPassedOut)).ToList();
		}

		private static Character GetRandomCharacter(bool excludeDead = true, bool excludePassedOut = true)
		{
			List<Character> source = HumanCharacters(excludeDead, excludePassedOut);
			return source.ElementAt(Random.Range(0, source.Count()));
		}

		private static Transform GetCharacterTransform(Character character, BodypartType part = (BodypartType)2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return character.GetBodypart(part).transform;
		}

		private static void SummonToCharacter(Character scout, string itemName, bool kinematic = false)
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (scout.data.dead || scout.data.fullyPassedOut || scout.data.passedOut)
			{
				return;
			}
			if (!scout.data.isClimbingAnything)
			{
				CharacterItems component = ((Component)scout).GetComponent<CharacterItems>();
				if (!scout.player.itemSlots.Any((ItemSlot slot) => slot.IsEmpty()) && Object.op_Implicit((Object)(object)scout.data.currentItem) && component.currentSelectedSlot.IsSome)
				{
					Vector3 position = ((Component)GetCharacterTransform(scout, (BodypartType)4)).transform.position;
					Vector3 val = position + new Vector3(0f, 2f, 0f);
					if (!Physics.CheckSphere(val, 2f))
					{
						val = position;
					}
					GameObject val2 = PhotonNetwork.InstantiateItemRoom(itemName, val, Quaternion.identity, true);
					val2.GetComponent<Item>().SetKinematicNetworked(kinematic);
				}
				GameUtils.instance.photonView.RPC("InstantiateAndGrabRPC", (RpcTarget)2, new object[3]
				{
					itemName,
					((MonoBehaviourPun)scout).photonView,
					0
				});
			}
			else
			{
				Vector3 position2 = ((Component)GetCharacterTransform(scout, (BodypartType)4)).transform.position;
				Vector3 val3 = position2 + new Vector3(0f, 2f, 0f);
				if (!Physics.CheckSphere(val3, 2f))
				{
					val3 = position2;
				}
				GameObject val4 = PhotonNetwork.InstantiateItemRoom(itemName, val3, Quaternion.identity, true);
				val4.GetComponent<Item>().SetKinematicNetworked(kinematic);
			}
		}

		private static void ApplyStatusToCharacter(Character scout, STATUSTYPE status, float amount)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			List<float> list = new List<float>();
			foreach (STATUSTYPE value in Enum.GetValues(typeof(STATUSTYPE)))
			{
				if (value == status)
				{
					list.Add(amount);
				}
				else
				{
					list.Add(0f);
				}
			}
			((MonoBehaviourPun)scout.refs.afflictions).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { list.ToArray() });
		}

		private static bool TryFindObject<T>(out T? foundObject) where T : Object
		{
			foundObject = default(T);
			try
			{
				foundObject = Object.FindAnyObjectByType<T>();
				if ((Object)(object)foundObject != (Object)null)
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
			}
			return false;
		}

		private static bool TryFindObjects<T>(out List<T> foundObjects) where T : Object
		{
			foundObjects = new List<T>();
			try
			{
				foundObjects = Object.FindObjectsByType<T>((FindObjectsSortMode)0).ToList();
				if (foundObjects.Any())
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
			}
			return false;
		}

		public static void AddItemsToBackpack(Backpack backpack, params string[] items)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			BackpackData data = ((Item)backpack).GetData<BackpackData>((DataEntryKey)7);
			byte i;
			for (i = 0; i < items.Length; i++)
			{
				Item val = SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Where((Item thing) => ((Object)thing).name == items[i]).First();
				data.AddItem(val, new ItemInstanceData(Guid.NewGuid()), i);
			}
			Item component = ((Component)backpack).GetComponent<Item>();
			((MonoBehaviourPun)component).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component.data });
			((Component)backpack).GetComponent<BackpackVisuals>().RefreshVisuals();
		}

		public static void AddTrollItemsToBackpack(Backpack backpack, string[] actualItems)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			BackpackReference fromBackpackItem = BackpackReference.GetFromBackpackItem((Item)(object)backpack);
			byte i;
			for (i = 0; i < actualItems.Length; i++)
			{
				if (((BackpackReference)(ref fromBackpackItem)).GetVisuals().spawnedVisualItems.TryGetValue(i, out var value))
				{
					value.isSecretlyOtherItemPrefab = SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Where((Item a) => ((Object)a).name == actualItems[i]).First();
				}
			}
			((Item)backpack).isSecretlyOtherItemPrefab = SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Where((Item a) => ((Object)a).name == "CactusBall").First();
		}

		public static GameObject SpawnBackpackWithItems(Vector3 position, params string[] items)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PhotonNetwork.InstantiateItemRoom("Backpack", position, Quaternion.identity, true);
			AddItemsToBackpack(val.GetComponent<Backpack>(), items);
			return val;
		}

		public static GameObject SpawnBackpackWithItemsTroll(Vector3 position, string[] actualItems, string[] fakeoutItems)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PhotonNetwork.InstantiateItemRoom("Backpack", position, Quaternion.identity, true);
			AddItemsToBackpack(val.GetComponent<Backpack>(), fakeoutItems);
			AddTrollItemsToBackpack(val.GetComponent<Backpack>(), actualItems);
			return val;
		}

		public static void PrepCharacterAsTeleportDestination(Character scout)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!scout.data.isGrounded || scout.data.isClimbingAnything)
			{
				Vector3 position = GetCharacterTransform(scout, (BodypartType)13).position;
				Vector3 position2 = GetCharacterTransform(scout, (BodypartType)16).position;
				GameObject obj = PhotonNetwork.InstantiateItemRoom("ShelfShroomSpawn", Vector3.Lerp(position, position2, 0.5f) - new Vector3(0f, 0.5f, 0f), Quaternion.identity, true);
				RemoveObjectAfterTime(obj);
			}
		}

		public static void PrepCharacterAsTeleportee(Character scout)
		{
			scout.refs.climbing.StopAnyClimbing();
		}

		public static Vector3 GetPosForTeleportingTo(Character scout)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or m