Decompiled source of PeakRandomizedChaos v1.1.1

plugins/PeakRandomizedChaos.dll

Decompiled a week 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 Photon.Pun;
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("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+c47a393827f46b60bcf03c30e98983a0976b22cd")]
[assembly: AssemblyProduct("PeakRandomizedChaos")]
[assembly: AssemblyTitle("PeakRandomizedChaos")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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 CharacterPatch
	{
		private static Dictionary<Character, (ItemInstanceData? data, int count)> Tracker = new Dictionary<Character, (ItemInstanceData, int)>();

		[HarmonyPatch(typeof(Character), "Update")]
		[HarmonyPostfix]
		public static void Postfix(Character __instance)
		{
			_ = PhotonNetwork.IsMasterClient;
		}
	}
	public class CustomLoot
	{
		public static readonly HashSet<string> ExcludedItemNames = new HashSet<string> { "Cheat Compass", "ScoutCookies_Vanilla", "ClimbingChalk", "Skull", "Warp Compass", "AncientIdol", "Passport" };

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

		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", "Dynamite", "Scorpion" };

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

		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)
		{
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			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
				{
					Plugin.Log.LogInfo((object)("ATTEMPT DESTROYING THING " + ((Object)item).name));
					if ((Object)(object)item != (Object)null)
					{
						Plugin.Log.LogInfo((object)("DESTROYING VALID THING " + ((Object)item).name));
						PhotonNetwork.Destroy(item);
					}
				}
				catch (Exception arg2)
				{
					Plugin.Log.LogWarning((object)$"Error when trying to DESTROY THING: {arg2}");
				}
			}
			RandomizerEvents.DestroyQueue.Clear();
			RandomizerEvents.DestroyQueueMutex.ReleaseMutex();
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (!allCharacter.isBot)
				{
					Player player = allCharacter.player;
					if (!player.tempFullSlot.IsEmpty() && (!allCharacter.refs.items.currentSelectedSlot.IsSome || allCharacter.refs.items.currentSelectedSlot.Value != 250))
					{
						player.tempFullSlot.EmptyOut();
						byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot));
						player.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array, true });
						Plugin.Log.LogInfo((object)"Fixed weird inventory thing");
					}
				}
			}
			return true;
		}
	}
	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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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) : ((Spawner)__instance).spawnedObjectPrefab);
				if ((Object)(object)val != (Object)null)
				{
					Item component = PhotonNetwork.InstantiateItemRoom(((Object)val).name, list2[index].position, Quaternion.identity).GetComponent<Item>();
					list.Add(((Component)component).GetComponent<PhotonView>());
					if (Object.op_Implicit((Object)(object)((Spawner)__instance).spawnUpTowardsTarget))
					{
						Transform transform = ((Component)component).transform;
						Vector3 val2 = ((Spawner)__instance).spawnUpTowardsTarget.position - ((Component)component).transform.position;
						transform.up = ((Vector3)(ref val2)).normalized;
						((Component)component).transform.Rotate(Vector3.up, Random.Range(0f, 360f), (Space)1);
					}
					if (((Spawner)__instance).spawnTransformIsSpawnerTransform)
					{
						((Component)component).transform.rotation = list2[index].rotation;
						((Component)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)component).transform.position,
							((Component)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<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 (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", 10, "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.");
		}
	}
	public class MountainProgressHandlerPatch
	{
		[HarmonyPatch(typeof(MountainProgressHandler), "TriggerReached")]
		[HarmonyPrefix]
		public static bool Prefix(MountainProgressHandler __instance, ProgressPoint progressPoint)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				if (Singleton<MapHandler>.Instance.currentSegment == 0)
				{
					RandomEventTask.StartTask();
				}
				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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
				{
					Plugin.Log.LogInfo((object)("DELETING " + ((object)val).GetType().FullName + " GARBAGE: " + ((Object)(object)val).name));
					try
					{
						PhotonNetwork.Destroy(((Component)(object)val).gameObject);
					}
					catch (Exception ex)
					{
						Plugin.Log.LogWarning((object)ex);
					}
				}
			}
		}

		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>();
		}
	}
	public class PauseMenuMainPagePatch
	{
		[HarmonyPatch(typeof(PauseMenuMainPage), "OnQuitClicked")]
		[HarmonyPrefix]
		public static bool Prefix(PauseMenuMainPage __instance)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				RandomEventTask.StopTask();
			}
			return true;
		}
	}
	[BepInPlugin("PeakRandomizedChaos", "PeakRandomizedChaos", "1.1.1")]
	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 => "1.1.1";

		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(LoadingScreenHandlerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(GameHandlerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(AchievementManagerPatch), (string)null);
		}
	}
	public class RandomEventTask
	{
		private static Task task = new Task(delegate
		{
		});

		public static int ShouldStopTask = 0;

		public static int EventTimerOffset = 0;

		public static void StartTask()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Interlocked.Exchange(ref EventTimerOffset, 0);
			Interlocked.Exchange(ref ShouldStopTask, 0);
			RandomizerEvents.SkeletonEventActive = false;
			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));
					RandomizerEvents.RandomEvent();
				}
				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");
			}
		}
	}
	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 bool SkeletonEventActive = false;

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

		public static readonly List<(string name, ConfigEntry<int>? weightConfigEntry, Action action)> Events = new List<(string, ConfigEntry<int>, Action)>(44)
		{
			("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 num20 = 0; num20 < 10; num20++)
				{
					Character randomCharacter = GetRandomCharacter();
					Vector3 center = randomCharacter.Center;
					int num21 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
					center += new Vector3((float)(num21 * Random.Range(100, 600)), 0f, (float)(num21 * Random.Range(100, 600)));
					if (Physics.CheckSphere(center, 50f))
					{
						Plugin.Log.LogInfo((object)$"Spawning tornado at: {center.x}, {center.y}, {center.z}");
						GameObject val29 = PhotonNetwork.Instantiate("Tornado", center, Quaternion.identity, (byte)0, (object[])null);
						if (!((Object)(object)val29 == (Object)null))
						{
							GameObject val30 = new GameObject();
							Object.Destroy((Object)(object)val30, 300f);
							val30.transform.position = randomCharacter.Center;
							val29.GetComponent<Tornado>().target = val30.transform;
							RemoveObjectAfterTime(val29, 60f);
							return;
						}
						Plugin.Log.LogInfo((object)$"No tornado wtf (Attempt {num20 + 1}/10)");
					}
					else
					{
						Plugin.Log.LogInfo((object)$"Oops bad placement for a tornado (Attempt {num20 + 1}/10)");
					}
				}
				Plugin.Log.LogInfo((object)"Oops bad placement for a tornado after all attempts");
				ForceEvent("Pandora");
			}),
			("Tick", ModConfig.Tick, delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item2 in HumanCharacters())
				{
					GameObject val28 = PhotonNetwork.Instantiate("BugfixOnYou", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
					val28.GetComponent<PhotonView>().RPC("AttachBug", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)item2).photonView.ViewID });
				}
			}),
			("Bees", ModConfig.Bees, 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_002e: 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)
				foreach (Character item3 in HumanCharacters())
				{
					Vector3 position18 = ((Component)GetCharacterTransform(item3, (BodypartType)4)).transform.position;
					GameObject val27 = PhotonNetwork.Instantiate("BeeSwarm", position18, Quaternion.identity, (byte)0, (object[])null);
					((MonoBehaviourPun)val27.GetComponent<BeeSwarm>()).photonView.RPC("SetBeesAngryRPC", (RpcTarget)3, new object[1] { true });
					RemoveObjectAfterTime(val27, 3f);
				}
			}),
			("Tumbleweed", ModConfig.Tumbleweed, 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_004f: 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_0078: 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_008b: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item4 in HumanCharacters())
				{
					Vector3 val26 = ((Component)GetCharacterTransform(item4, (BodypartType)14)).transform.position;
					for (int num17 = 0; num17 < Random.Range(2, 5); num17++)
					{
						int num18 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
						int num19 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
						val26 += new Vector3((float)(num18 * Random.Range(1, 10)), 0f, (float)(num19 * Random.Range(1, 10)));
						if (Physics.CheckSphere(val26, 10f))
						{
							GameObject obj6 = PhotonNetwork.Instantiate("TumbleWeed", val26, Quaternion.identity, (byte)0, (object[])null);
							RemoveObjectAfterTime(obj6, 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
			{
				//IL_003b: 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_0063: 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_008c: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
				List<GameObject> zombies = new List<GameObject>();
				foreach (Character item6 in ExtCollections.Shuffle<Character>((IList<Character>)HumanCharacters()))
				{
					Vector3 position17 = ((Component)GetCharacterTransform(item6, (BodypartType)2)).transform.position;
					MushroomZombie[] array9 = Object.FindObjectsByType<MushroomZombie>((FindObjectsSortMode)0);
					bool flag3 = false;
					MushroomZombie[] array10 = array9;
					foreach (MushroomZombie val25 in array10)
					{
						if (Vector3.Distance(((Component)val25).transform.position, position17) <= 30f)
						{
							flag3 = true;
							break;
						}
					}
					if (!flag3 && Physics.CheckSphere(position17, 5f))
					{
						zombies.Add(PhotonNetwork.Instantiate("MushroomZombie", position17, Quaternion.identity, (byte)0, (object[])null));
					}
				}
				Task.Run(delegate
				{
					Thread.Sleep(TimeSpan.FromSeconds(25.0));
					DestroyQueueMutex.WaitOne();
					DestroyQueue.AddRange(zombies);
					DestroyQueueMutex.ReleaseMutex();
				});
			}),
			("Mandrake", ModConfig.Mandrake, delegate
			{
				//IL_002a: 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_0051: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: 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)
				foreach (Character item7 in ExtCollections.Shuffle<Character>((IList<Character>)HumanCharacters()))
				{
					Vector3 position16 = ((Component)GetCharacterTransform(item7, (BodypartType)4)).transform.position;
					bool flag2 = false;
					Mandrake[] array7 = Object.FindObjectsByType<Mandrake>((FindObjectsSortMode)0);
					Mandrake[] array8 = array7;
					foreach (Mandrake val22 in array8)
					{
						if (Vector3.Distance(((Component)val22).transform.position, position16) <= 25f)
						{
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						Vector3 val23 = position16 + new Vector3(0f, 2f, 0f);
						if (!Physics.CheckSphere(val23, 2f))
						{
							val23 = position16;
						}
						GameObject val24 = PhotonNetwork.InstantiateItemRoom("Mandrake", val23, Quaternion.identity);
						((ItemComponent)val24.GetComponent<Mandrake>()).photonView.RPC("RPC_Scream", (RpcTarget)3, Array.Empty<object>());
						RemoveObjectAfterTime(val24, 10f);
					}
				}
			}),
			("Cactus", ModConfig.Cactus, 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 item8 in HumanCharacters())
				{
					Vector3 position15 = ((Component)GetCharacterTransform(item8, (BodypartType)13)).transform.position;
					GameObject obj5 = PhotonNetwork.InstantiateItemRoom("CactusBall", position15, Quaternion.identity);
					RemoveObjectAfterTime(obj5, 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_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_0030: 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_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)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: 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_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item11 in HumanCharacters())
				{
					Vector3 position14 = ((Component)GetCharacterTransform(item11, (BodypartType)4)).transform.position;
					int num12;
					Vector3 val19;
					for (num12 = 5; num12 > 0; num12--)
					{
						val19 = position14 + new Vector3(0f, (float)num12, 0f);
						if (Physics.CheckSphere(val19, 5f))
						{
							break;
						}
					}
					val19 = position14 + new Vector3(0f, (float)num12, 0f);
					for (int num13 = -2; num13 < 2; num13 += 2)
					{
						for (int num14 = -2; num14 < 2; num14 += 2)
						{
							Vector3 val20 = val19 + new Vector3((float)num13 + Random.Range(-1f, 1f), Random.Range(-2f, 2f), (float)num14 + Random.Range(-1f, 1f));
							if (Physics.CheckSphere(val20, 5f))
							{
								string text2 = CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count));
								if (text2 == "Cure-All")
								{
									text2 = "FortifiedMilk";
								}
								GameObject val21 = PhotonNetwork.InstantiateItemRoom(text2, val20, Quaternion.identity);
								val21.GetComponent<Item>().SetKinematicNetworked(false);
								RemoveObjectAfterTime(val21);
							}
						}
					}
				}
			}),
			("BingBongRain", ModConfig.BingBongRain, 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_0030: 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_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)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: 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_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: 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)
				//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)
				foreach (Character item12 in HumanCharacters())
				{
					Vector3 position13 = ((Component)GetCharacterTransform(item12, (BodypartType)4)).transform.position;
					int num9;
					Vector3 val17;
					for (num9 = 5; num9 > 0; num9--)
					{
						val17 = position13 + new Vector3(0f, (float)num9, 0f);
						if (Physics.CheckSphere(val17, 5f))
						{
							break;
						}
					}
					val17 = position13 + new Vector3(0f, (float)num9, 0f);
					for (int num10 = -2; num10 < 2; num10 += 2)
					{
						for (int num11 = -2; num11 < 2; num11 += 2)
						{
							Vector3 val18 = val17 + new Vector3((float)num10 + Random.Range(-1f, 1f), Random.Range(-2f, 2f), (float)num11 + Random.Range(-1f, 1f));
							if (Physics.CheckSphere(val18, 5f))
							{
								GameObject obj4 = PhotonNetwork.InstantiateItemRoom("BingBong", val18, Quaternion.identity);
								RemoveObjectAfterTime(obj4, 5f);
							}
						}
					}
				}
			}),
			("CureAll", ModConfig.CureAll, 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_002e: 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)
				foreach (Character item13 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					Vector3 position12 = ((Component)GetCharacterTransform(item13, (BodypartType)4)).transform.position;
					GameObject val16 = PhotonNetwork.InstantiateItemRoom("Cure-All", position12, Quaternion.identity);
					Item component5 = val16.GetComponent<Item>();
					if (component5 != null)
					{
						ItemCooking cooking = component5.cooking;
						if (cooking != null)
						{
							((ItemComponent)cooking).photonView.RPC("RPC_CookingExplode", (RpcTarget)0, Array.Empty<object>());
						}
					}
					RemoveObjectAfterTime(val16, 5f);
				}
			}),
			("Pandora", ModConfig.Pandora, 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_002e: 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)
				foreach (Character item14 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					Vector3 position11 = ((Component)GetCharacterTransform(item14, (BodypartType)4)).transform.position;
					GameObject val15 = PhotonNetwork.InstantiateItemRoom("PandorasBox", position11, Quaternion.identity);
					((ItemComponent)val15.GetComponent<Item>().cooking).photonView.RPC("RPC_CookingExplode", (RpcTarget)0, Array.Empty<object>());
					RemoveObjectAfterTime(val15, 5f);
				}
			}),
			("SwapPlayers", ModConfig.SwapPlayers, delegate
			{
				//IL_0058: 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_00d0: 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_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list12 = (from c in HumanCharacters(excludeDead: true, excludePassedOut: false)
					where !c.data.isInFog
					select c).ToList();
				List<Vector3> list13 = new List<Vector3>();
				foreach (Character item15 in list12)
				{
					list13.Add(((Component)GetCharacterTransform(item15, (BodypartType)2)).transform.position);
					PrepCharacterAsTeleportDestination(item15);
					PrepCharacterAsTeleportee(item15);
				}
				Plugin.Log.LogInfo((object)string.Join(", ", list13));
				List<Vector3> list14 = list13.ToList();
				list14 = ExtCollections.Shuffle<Vector3>((IList<Vector3>)list14).ToList();
				if (list14.SequenceEqual(list13))
				{
					Plugin.Log.LogInfo((object)"BAD PLAYER SHUFFLE. DOING SHIFT.");
					Vector3 value2 = list14[0];
					for (int num7 = 0; num7 < list14.Count - 1; num7++)
					{
						list14[num7] = list14[num7 + 1];
					}
					list14[list14.Count - 1] = value2;
				}
				Plugin.Log.LogInfo((object)string.Join(", ", list14));
				int num8 = 0;
				foreach (Character item16 in list12)
				{
					((MonoBehaviourPun)item16).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						list14[num8],
						true
					});
					num8++;
				}
			}),
			("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_0067: 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_0093: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: 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_0118: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val13 = Singleton<PeakHandler>.Instance.peakSequence.transform.position + new Vector3(0f, 20f, 0f);
				List<Character> list11 = (from c in HumanCharacters(excludeDead: true, excludePassedOut: false)
					where !c.data.isInFog
					select c).ToList();
				Character val14 = list11[0];
				float num5 = Vector3.Distance(val13, GetCharacterTransform(val14, (BodypartType)2).position);
				foreach (Character item17 in list11.Skip(1))
				{
					float num6 = Vector3.Distance(val13, GetCharacterTransform(item17, (BodypartType)2).position);
					if (num6 > num5)
					{
						num5 = num6;
						val14 = item17;
					}
				}
				PrepCharacterAsTeleportDestination(val14);
				Vector3 position10 = GetCharacterTransform(val14, (BodypartType)2).position;
				foreach (Character item18 in list11)
				{
					if (!((Object)(object)item18 == (Object)(object)val14))
					{
						Vector3 posForTeleportingTo3 = GetPosForTeleportingTo(val14);
						((MonoBehaviourPun)item18).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { posForTeleportingTo3, true });
					}
				}
			}),
			("SwapPlayerItems", ModConfig.SwapPlayerItems, delegate
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0280: Unknown result type (might be due to invalid IL or missing references)
				//IL_0287: Unknown result type (might be due to invalid IL or missing references)
				//IL_0291: Unknown result type (might be due to invalid IL or missing references)
				//IL_0296: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list7 = HumanCharacters();
				List<byte[]> list8 = new List<byte[]>();
				List<SlotData> list9 = new List<SlotData>();
				InventorySyncData val10 = default(InventorySyncData);
				foreach (Character item19 in list7)
				{
					Player player = item19.player;
					((InventorySyncData)(ref val10))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
					byte[] item = IBinarySerializable.ToManagedArray<InventorySyncData>(val10);
					list8.Add(item);
					list9.Add(val10.tempSlot);
					ItemSlot[] itemSlots = player.itemSlots;
					foreach (ItemSlot val11 in itemSlots)
					{
						val11.EmptyOut();
					}
					((ItemSlot)player.backpackSlot).EmptyOut();
					player.tempFullSlot.EmptyOut();
					byte[] array5 = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot));
					item19.player.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array5, true });
					item19.refs.items.photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty<object>());
				}
				List<byte[]> list10 = list8.ToList();
				list10 = ExtCollections.Shuffle<byte[]>((IList<byte[]>)list10).ToList();
				if (list10.SequenceEqual(list8))
				{
					Plugin.Log.LogInfo((object)"BAD SWAP SHUFFLE. DOING SHIFT.");
					byte[] value = list10[0];
					for (int num3 = 0; num3 < list10.Count - 1; num3++)
					{
						list10[num3] = list10[num3 + 1];
					}
					list10[list10.Count - 1] = value;
				}
				for (int num4 = 0; num4 < list7.Count; num4++)
				{
					Character val12 = list7[num4];
					Player player2 = list7[num4].player;
					InventorySyncData fromManagedArray = IBinarySerializable.GetFromManagedArray<InventorySyncData>(list10[num4]);
					fromManagedArray.tempSlot = list9[num4];
					byte[] array6 = IBinarySerializable.ToManagedArray<InventorySyncData>(fromManagedArray);
					player2.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array6, true });
					if (val12.refs.items.currentSelectedSlot.IsSome)
					{
						ItemSlot itemSlot = val12.player.GetItemSlot(val12.refs.items.currentSelectedSlot.Value);
						if (!itemSlot.IsEmpty())
						{
							Transform transform = ((Component)val12.GetBodypart((BodypartType)2)).transform;
							PhotonView component4 = PhotonNetwork.Instantiate("0_Items/" + itemSlot.GetPrefabName(), transform.position + transform.forward * 0.6f, Quaternion.identity, (byte)0, (object[])null).GetComponent<PhotonView>();
							component4.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { itemSlot.data });
							int viewID = component4.ViewID;
							val12.refs.items.photonView.RPC("EquipSlotRpc", (RpcTarget)0, new object[2]
							{
								(int)val12.refs.items.currentSelectedSlot.Value,
								viewID
							});
						}
					}
				}
			}),
			("ReviveOne", ModConfig.ReviveOne, delegate
			{
				//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_005c: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list5 = DeadHumanCharacters();
				if (list5.Count() > 0)
				{
					List<Character> list6 = HumanCharacters();
					Character scout2 = list6[Random.Range(0, list6.Count())];
					PrepCharacterAsTeleportDestination(scout2);
					Vector3 posForTeleportingTo2 = GetPosForTeleportingTo(scout2);
					((MonoBehaviourPun)list5[Random.Range(0, list5.Count())]).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[2] { posForTeleportingTo2, false });
				}
			}),
			("ReviveAll", ModConfig.ReviveAll, delegate
			{
				//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_0063: Unknown result type (might be due to invalid IL or missing references)
				List<Character> list3 = DeadHumanCharacters();
				if (list3.Count() > 0)
				{
					foreach (Character item20 in list3)
					{
						List<Character> list4 = HumanCharacters();
						Character scout = list4[Random.Range(0, list4.Count())];
						PrepCharacterAsTeleportDestination(scout);
						Vector3 posForTeleportingTo = GetPosForTeleportingTo(scout);
						((MonoBehaviourPun)item20).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[2] { posForTeleportingTo, false });
					}
				}
			}),
			("HealShroom", ModConfig.HealShroom, 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)
				foreach (Character item21 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					GameObject obj3 = PhotonNetwork.InstantiateItemRoom("HealingPuffShroomSpawn", GetCharacterTransform(item21, (BodypartType)2).position, Quaternion.identity);
					RemoveObjectAfterTime(obj3);
				}
			}),
			("BounceShroom", ModConfig.BounceShroom, delegate
			{
				//IL_001f: 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_002d: 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_0038: 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_003f: 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_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)
				foreach (Character item22 in HumanCharacters())
				{
					Vector3 position8 = GetCharacterTransform(item22, (BodypartType)13).position;
					Vector3 position9 = GetCharacterTransform(item22, (BodypartType)16).position;
					GameObject obj2 = PhotonNetwork.InstantiateItemRoom("BounceShroomSpawn", Vector3.Lerp(position8, position9, 0.5f) - new Vector3(0f, 0.5f, 0f), Quaternion.identity);
					RemoveObjectAfterTime(obj2);
				}
			}),
			("MoraleBoost", ModConfig.MoraleBoost, delegate
			{
				List<Character> list2 = HumanCharacters(excludeDead: true, excludePassedOut: false);
				foreach (Character item23 in list2)
				{
					((MonoBehaviourPun)item23).photonView.RPC("MoraleBoost", (RpcTarget)0, new object[2]
					{
						1f,
						list2.Count()
					});
				}
			}),
			("Scorpion", ModConfig.Scorpion, delegate
			{
				foreach (Character item24 in HumanCharacters())
				{
					SummonToCharacter(item24, "Scorpion");
				}
			}),
			("RandomBackpackGood", ModConfig.RandomBackpackGood, delegate
			{
				//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_005e: 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_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: 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 position7 = ((Component)GetCharacterTransform(item25, (BodypartType)4)).transform.position;
					Vector3 val9 = position7 + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val9, 4f))
					{
						val9 = position7;
					}
					string[] array4 = new string[4];
					for (int m = 0; m < 4; m++)
					{
						array4[m] = IEnumerableExtensions.RandomElement<string>((IEnumerable<string>)CustomLoot.GoodItemsBackpack);
					}
					RemoveObjectAfterTime(SpawnBackpackWithItems(val9, array4));
				}
			}),
			("RandomBackpack", ModConfig.RandomBackpack, 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_002c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: 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_0054: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item26 in HumanCharacters())
				{
					Vector3 position6 = ((Component)GetCharacterTransform(item26, (BodypartType)4)).transform.position;
					Vector3 val8 = position6 + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val8, 4f))
					{
						val8 = position6;
					}
					string[] array3 = new string[4];
					for (int l = 0; l < 4; l++)
					{
						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;
						}
						array3[l] = text;
					}
					RemoveObjectAfterTime(SpawnBackpackWithItems(val8, array3));
				}
			}),
			("Beanstalk", ModConfig.Beanstalk, 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_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_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_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_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: 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_0066: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val7 = default(Vector3);
				foreach (Character item27 in HumanCharacters())
				{
					Vector3 position4 = GetCharacterTransform(item27, (BodypartType)13).position;
					Vector3 position5 = GetCharacterTransform(item27, (BodypartType)16).position;
					Vector3 val5 = Vector3.Lerp(position4, position5, 0.5f);
					GameObject val6 = PhotonNetwork.InstantiateItemRoom("MagicBean", val5, Quaternion.identity);
					MagicBean component3 = val6.GetComponent<MagicBean>();
					float vineDistance = component3.GetVineDistance(val5, component3.averageNormal);
					((Vector3)(ref val7))..ctor(Random.Range(-1f, 1f), Random.Range(0f, 1f), Random.Range(-1f, 1f));
					((ItemComponent)component3).photonView.RPC("GrowVineRPC", (RpcTarget)0, new object[3] { val5, val7, vineDistance });
					RemoveObjectAfterTime(val6, 60f);
				}
			}),
			("BeanstalkSpam", ModConfig.BeanstalkSpam, delegate
			{
				for (int k = 0; k < 3; k++)
				{
					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
			{
				ForceRandomEvent("TwoAtOnce");
				ForceRandomEvent("TwoAtOnce");
			}),
			("Skeleton", ModConfig.Skeleton, delegate
			{
				SkeletonEventActive = true;
				foreach (Character item28 in HumanCharacters())
				{
					item28.data.SetSkeleton(!item28.data.isSkeleton);
				}
				Task.Run(delegate
				{
					Thread.Sleep(TimeSpan.FromSeconds(Random.Range(30, 60)));
					QueueEvent("SkeletonCure");
				});
			}),
			("SkeletonCure", null, delegate
			{
				SkeletonEventActive = false;
				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
			{
				//IL_0021: 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)
				foreach (Character item32 in HumanCharacters())
				{
					item32.TryStickBodypart(item32.GetBodypart((BodypartType)4), default(Vector3), (STATUSTYPE)11, 0.25f);
				}
			}),
			("Antirope", ModConfig.Antirope, 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)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				foreach (Character item33 in HumanCharacters())
				{
					Vector3 position3 = ((Component)GetCharacterTransform(item33, (BodypartType)4)).transform.position;
					GameObject val4 = PhotonNetwork.Instantiate("RopeAnchorForRopeShooterAnti", position3, 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;
					}
					val4.GetComponent<RopeAnchorProjectile>().photonView.RPC("GetShot", (RpcTarget)3, new object[4]
					{
						position3,
						0f,
						num,
						Vector3.up
					});
					RemoveObjectAfterTime(val4, 120f);
					RemoveObjectAfterTime(val4.GetComponent<RopeAnchorWithRope>().ropeInstance, 120f);
				}
			}),
			("DayNight", ModConfig.DayNight, delegate
			{
				DayNightManager.instance.photonView.RPC("RPCA_SyncTime", (RpcTarget)0, new object[1] { (DayNightManager.instance.timeOfDay + 12f) % 24f });
			}),
			("Eruption", ModConfig.Eruption, delegate
			{
				//IL_0037: 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_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_0054: 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_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				EruptionSpawner val3 = Object.FindAnyObjectByType<EruptionSpawner>();
				List<Vector3> list = new List<Vector3>();
				foreach (Character item34 in ExtCollections.Shuffle<Character>((IList<Character>)HumanCharacters()))
				{
					Vector3 position2 = ((Component)GetCharacterTransform(item34, (BodypartType)13)).transform.position;
					bool flag = false;
					foreach (Vector3 item35 in list)
					{
						if (Vector3.Distance(item35, position2) <= 50f)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						val3.photonView.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { position2 });
						list.Add(new Vector3(position2.x, position2.y, position2.z));
					}
				}
				Task.Run(delegate
				{
					Thread.Sleep(TimeSpan.FromSeconds(25.0));
					QueueEvent("EruptionAloe");
				});
			}),
			("EruptionAloe", null, delegate
			{
				SpawnAndFeedToAll("AloeVera");
				SpawnAndFeedToAll("AloeVera");
			}),
			("RandomBackpackTroll", null, 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_002c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: 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_0054: 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_00a4: 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 val2 = position + new Vector3(0f, 4f, 0f);
					if (!Physics.CheckSphere(val2, 4f))
					{
						val2 = 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(val2, array2, array);
					RemoveObjectAfterTime(obj);
				}
			}),
			("DynamiteExtended", null, delegate
			{
				//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)
				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);
							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);
						}
					}
				}
			}),
			("ListItems", null, delegate
			{
				Plugin.Log.LogInfo((object)string.Join("\n", SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Select((Item x) => ((Object)x).name)));
			})
		};

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

		private static List<Character> HumanCharacters(bool excludeDead = true, bool excludePassedOut = true)
		{
			return Character.AllCharacters.Where((Character c) => !c.isBot && (!excludeDead || !c.data.dead) && (!excludePassedOut || !c.data.fullyPassedOut)).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 = 2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)character.GetBodypart(part)).transform;
		}

		private static void SummonToCharacter(Character scout, string itemName, bool kinematic = false)
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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)
			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)
				{
					ItemSlot itemSlot = component.character.player.GetItemSlot(component.currentSelectedSlot.Value);
					component.photonView.RPC("DropItemRpc", (RpcTarget)0, new object[7]
					{
						0f,
						component.currentSelectedSlot.Value,
						((Component)component.character.data.currentItem).transform.position,
						Vector3.zero,
						((Component)component.character.data.currentItem).transform.rotation,
						itemSlot.data,
						true
					});
				}
				GameUtils.instance.photonView.RPC("InstantiateAndGrabRPC", (RpcTarget)2, new object[3]
				{
					itemName,
					((MonoBehaviourPun)scout).photonView,
					0
				});
			}
			else
			{
				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);
				val2.GetComponent<Item>().SetKinematicNetworked(kinematic);
			}
		}

		public static void AddItemsToBackpack(Backpack backpack, params string[] items)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			string[] items2 = items;
			BackpackData data = ((Item)backpack).GetData<BackpackData>((DataEntryKey)7);
			byte i;
			for (i = 0; i < items2.Length; i++)
			{
				Item val = SingletonAsset<ItemDatabase>.Instance.itemLookup.Values.Where((Item thing) => ((Object)thing).name == items2[i]).First();
				data.AddItem(val, new ItemInstanceData(default(Guid)), 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)
			string[] actualItems2 = actualItems;
			BackpackReference fromBackpackItem = BackpackReference.GetFromBackpackItem((Item)(object)backpack);
			byte i;
			for (i = 0; i < actualItems2.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 == actualItems2[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);
			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);
			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);
				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 missing references)
			//IL_003b: 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_008f: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0070: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = GetCharacterTransform(scout, (BodypartType)2).position;
			Vector3 val = Random.insideUnitSphere * 2f + position;
			val.y = ((val.y < position.y) ? position.y : val.y);
			int num = 0;
			while (Physics.OverlapSphere(val, 1f).Length != 0)
			{
				if (num < 5)
				{
					val = position;
					break;
				}
				val = Random.insideUnitSphere * 2f + position;
				val.y = ((val.y < position.y) ? position.y : val.y);
				num++;
			}
			return val;
		}

		public static void SpawnAndFeedToAll(string itemName, int cookedAmount = 0, bool excludePassedOut = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PhotonNetwork.InstantiateItemRoom(itemName, OutOfSight, Quaternion.identity);
			Item component = val.GetComponent<Item>();
			((MonoBehaviourPun)component).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { cookedAmount });
			foreach (Character item in HumanCharacters(excludeDead: true, excludePassedOut))
			{
				item.FeedItem(component);
			}
			RemoveObjectAfterTime(val, 1f);
		}

		public static void RandomEvent()
		{
			if (Interlocked.CompareExchange(ref RandomEventTask.ShouldStopTask, 0, 0) != 0)
			{
				Plugin.Log.LogInfo((object)"Random event halted due to StopTask being True");
			}
			else if (PhotonNetwork.OfflineMode && Time.timeScale == 0f)
			{
				Plugin.Log.LogInfo((object)"Random event halted due to game being paused in singleplayer");
			}
			else
			{
				QueueRandomEvent();
			}
		}

		public static void QueueRandomEvent()
		{
			string randomEventName = GetRandomEventName();
			EventQueueMutex.WaitOne();
			Plugin.Log.LogInfo((object)("Initiating random event: " + randomEventName));
			EventQueue.Add(randomEventName);
			EventQueueMutex.ReleaseMutex();
		}

		public static void QueueEvent(string type)
		{
			string type2 = type;
			if (!Events.Any<(string, ConfigEntry<int>, Action)>(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.name == type2))
			{
				Plugin.Log.LogInfo((object)("No event found for " + type2 + "!"));
				return;
			}
			EventQueueMutex.WaitOne();
			Plugin.Log.LogInfo((object)("Initiating event: " + type2));
			EventQueue.Add(type2);
			EventQueueMutex.ReleaseMutex();
		}

		public static void ForceEvent(string type)
		{
			string type2 = type;
			if (!Events.Any<(string, ConfigEntry<int>, Action)>(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.name == type2))
			{
				Plugin.Log.LogInfo((object)("No event found for " + type2 + "!"));
				return;
			}
			Events.Where<(string, ConfigEntry<int>, Action)>(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.name == type2).First().Item3();
		}

		public static void ForceRandomEvent(params string[] exclude)
		{
			ForceEvent(GetRandomEventName(exclude));
		}

		public static string GetRandomEventName(params string[] exclude)
		{
			IEnumerable<(string, ConfigEntry<int>, Action)> filteredEvents = GetFilteredEvents(exclude);
			int num = filteredEvents.Sum<(string, ConfigEntry<int>, Action)>(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.weightConfigEntry.Value);
			int num2 = Random.Range(0, num);
			foreach (var item4 in filteredEvents)
			{
				string item = item4.Item1;
				ConfigEntry<int> item2 = item4.Item2;
				Action item3 = item4.Item3;
				int num3 = item2?.Value ?? 0;
				if (num2 < num3)
				{
					return item;
				}
				num2 -= num3;
			}
			return "";
		}

		public static IEnumerable<(string name, ConfigEntry<int>? weightConfigEntry, Action action)> GetFilteredEvents(params string[] exclude)
		{
			string[] exclude2 = exclude;
			IEnumerable<(string name, ConfigEntry<int> weightConfigEntry, Action action)> eventsFiltered = from e in Events
				where e.weightConfigEntry != null
				where !exclude2.Contains(e.name)
				select e;
			if (HumanCharacters().Count < 2)
			{
				filterOut("SwapPlayers");
				filterOut("WarpToLastPlayer");
				filterOut("SwapPlayerItems");
			}
			if (DeadHumanCharacters().Count == 0)
			{
				filterOut("ReviveOne");
				filterOut("ReviveAll");
			}
			if (Singleton<MapHandler>.Instance.currentSegment > 3 && !ModConfig.EnableTornadoAtKiln.Value)
			{
				filterOut("Tornado");
			}
			if (SkeletonEventActive)
			{
				filterOut("Skeleton");
			}
			if ((Object)(object)Object.FindAnyObjectByType<EruptionSpawner>() == (Object)null)
			{
				filterOut("Eruption");
			}
			return eventsFiltered;
			void filterOut(string nameToExclude)
			{
				string nameToExclude2 = nameToExclude;
				eventsFiltered = eventsFiltered.Where(((string name, ConfigEntry<int> weightConfigEntry, Action action) e) => e.name != nameToExclude2);
			}
		}

		public static List<string> EventNames()
		{
			return Events.Select<(string, ConfigEntry<int>, Action), string>(((string name, ConfigEntry<int> weightConfigEntry, Action action) item) => item.name).ToList();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}