Decompiled source of PeakRandomizedChaos v1.0.0

plugins/PeakRandomizedChaos.dll

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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, int, Action)>(((string name, int weight, 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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			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)
		{
			__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)
		{
			Item val = default(Item);
			if (ItemDatabase.TryGetItem(CustomLoot.GetRandomId(), ref val))
			{
				__result = ((Component)val).gameObject;
				return false;
			}
			return true;
		}
	}
	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, 5 * 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.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Id = "PeakRandomizedChaos";

		public static ManualLogSource Log { get; private set; }

		public static string Name => "PeakRandomizedChaos";

		public static string Version => "1.0.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			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)
				{
					Thread.Sleep(TimeSpan.FromSeconds(Random.Range(30, 60) - Interlocked.CompareExchange(ref EventTimerOffset, 0, 0)));
					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, int weight, Action action)> Events = new List<(string, int, Action)>(44)
		{
			("Tornado", 5, delegate
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: 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_00e6: Expected O, but got Unknown
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				if (Singleton<MapHandler>.Instance.currentSegment > 3)
				{
					ForceEvent("Pandora");
				}
				else
				{
					Character randomCharacter = GetRandomCharacter();
					Vector3 center = randomCharacter.Center;
					int num20 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
					center += new Vector3((float)(num20 * Random.Range(100, 600)), 0f, (float)(num20 * Random.Range(100, 600)));
					if (Physics.CheckSphere(center, 100f))
					{
						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)
						{
							Plugin.Log.LogInfo((object)"No tornado wtf");
							ForceEvent("Pandora");
						}
						else
						{
							GameObject val30 = new GameObject();
							Object.Destroy((Object)(object)val30, 300f);
							val30.transform.position = randomCharacter.Center;
							val29.GetComponent<Tornado>().target = val30.transform;
							RemoveObjectAfterTime(val29, 60f);
						}
					}
					else
					{
						Plugin.Log.LogInfo((object)"Oops bad placement for a tornado");
						ForceEvent("Pandora");
					}
				}
			}),
			("Tick", 7, 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", 2, 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", 10, 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", 9, delegate
			{
				if (Random.Range(0, 10) == 0)
				{
					ForceEvent("DynamiteExtended");
					return;
				}
				foreach (Character item5 in HumanCharacters())
				{
					SummonToCharacter(item5, "Dynamite", kinematic: true);
				}
			}),
			("Zombie", 6, 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", 9, 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", 10, 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", 10, delegate
			{
				foreach (Character item9 in HumanCharacters())
				{
					SummonToCharacter(item9, ((Object)SingletonAsset<ItemDatabase>.Instance.itemLookup[CustomLoot.GetRandomId()]).name);
				}
			}),
			("RandomGoodItem", 2, delegate
			{
				foreach (Character item10 in HumanCharacters())
				{
					SummonToCharacter(item10, CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count)));
				}
			}),
			("RandomGoodItemRain", 1, 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", 2, 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", 4, 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", 4, 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", 6, delegate
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				if (HumanCharacters().Count < 2)
				{
					ForceEvent("BingBongRain");
					return;
				}
				List<Vector3> list12 = new List<Vector3>();
				foreach (Character item15 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					list12.Add(((Component)GetCharacterTransform(item15, (BodypartType)2)).transform.position);
					PrepCharacterAsTeleportDestination(item15);
					PrepCharacterAsTeleportee(item15);
				}
				Plugin.Log.LogInfo((object)string.Join(", ", list12));
				List<Vector3> list13 = list12.ToList();
				list13 = ExtCollections.Shuffle<Vector3>((IList<Vector3>)list13).ToList();
				if (list13.SequenceEqual(list12))
				{
					Plugin.Log.LogInfo((object)"BAD PLAYER SHUFFLE. DOING SHIFT.");
					Vector3 value2 = list13[0];
					for (int num7 = 0; num7 < list13.Count - 1; num7++)
					{
						list13[num7] = list13[num7 + 1];
					}
					list13[list13.Count - 1] = value2;
				}
				Plugin.Log.LogInfo((object)string.Join(", ", list13));
				int num8 = 0;
				foreach (Character item16 in HumanCharacters(excludeDead: true, excludePassedOut: false))
				{
					((MonoBehaviourPun)item16).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						list13[num8],
						true
					});
					num8++;
				}
			}),
			("WarpToLastPlayer", 4, delegate
			{
				//IL_0029: 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_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: 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_00c8: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				if (HumanCharacters().Count < 2)
				{
					ForceEvent("Zombie");
					return;
				}
				Vector3 val13 = Singleton<PeakHandler>.Instance.peakSequence.transform.position + new Vector3(0f, 20f, 0f);
				List<Character> list11 = HumanCharacters(excludeDead: true, excludePassedOut: false);
				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", 10, delegate
			{
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
				if (HumanCharacters().Count < 2)
				{
					ForceEvent("RandomItem");
				}
				else
				{
					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", 5, 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 });
				}
				else
				{
					ForceEvent("CureAll");
				}
			}),
			("ReviveAll", 2, 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 });
					}
					return;
				}
				ForceEvent("RandomGoodItemRain");
			}),
			("HealShroom", 4, 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", 8, 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", 5, 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", 6, delegate
			{
				foreach (Character item24 in HumanCharacters())
				{
					SummonToCharacter(item24, "Scorpion");
				}
			}),
			("RandomBackpackGood", 1, delegate
			{
				//IL_0038: 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_003e: 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_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_0059: 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_0067: 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)
				if (Random.Range(0, 10) == 0)
				{
					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", 6, 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", 7, 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", 1, delegate
			{
				for (int k = 0; k < 3; k++)
				{
					ForceEvent("Beanstalk");
				}
			}),
			("EnergyDrink", 3, delegate
			{
				SpawnAndFeedToAll("Energy Drink", 1);
			}),
			("Lollipop", 3, delegate
			{
				SpawnAndFeedToAll("Lollipop", 1);
			}),
			("Milk", 3, delegate
			{
				SpawnAndFeedToAll("FortifiedMilk");
			}),
			("UnlimitedPower", 1, delegate
			{
				SpawnAndFeedToAll("Energy Drink", 1);
				SpawnAndFeedToAll("Lollipop", 1);
				SpawnAndFeedToAll("FortifiedMilk");
			}),
			("TwoAtOnce", 2, delegate
			{
				ForceRandomEvent("TwoAtOnce");
				ForceRandomEvent("TwoAtOnce");
			}),
			("Skeleton", 1, delegate
			{
				if (SkeletonEventActive)
				{
					ForceEvent("CureAll");
				}
				else
				{
					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", 0, delegate
			{
				SkeletonEventActive = false;
				foreach (Character item29 in HumanCharacters())
				{
					item29.data.SetSkeleton(!item29.data.isSkeleton);
				}
			}),
			("TieBalloon", 3, delegate
			{
				foreach (Character item30 in HumanCharacters())
				{
					item30.refs.balloons.TieNewBalloon(0);
				}
			}),
			("TieThreeBalloons", 1, delegate
			{
				foreach (Character item31 in HumanCharacters())
				{
					item31.refs.balloons.TieNewBalloon(0);
					item31.refs.balloons.TieNewBalloon(0);
					item31.refs.balloons.TieNewBalloon(0);
				}
			}),
			("Web", 7, 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", 2, 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", 3, delegate
			{
				DayNightManager.instance.photonView.RPC("RPCA_SyncTime", (RpcTarget)0, new object[1] { (DayNightManager.instance.timeOfDay + 12f) % 24f });
			}),
			("Eruption", 7, delegate
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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_0068: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
				EruptionSpawner val3 = Object.FindAnyObjectByType<EruptionSpawner>();
				if ((Object)(object)val3 == (Object)null)
				{
					ForceEvent("Zombie");
				}
				else
				{
					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", 0, delegate
			{
				SpawnAndFeedToAll("AloeVera");
				SpawnAndFeedToAll("AloeVera");
			}),
			("RandomBackpackTroll", 0, 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", 0, 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", 0, 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()
		{
			int num = Events.Select<(string, int, Action), int>(((string name, int weight, Action action) e) => e.weight).Sum();
			int num2 = Random.Range(0, num);
			int num3 = 0;
			foreach (var @event in Events)
			{
				string item = @event.name;
				int item2 = @event.weight;
				Action item3 = @event.action;
				num3 += item2;
				if (num2 < num3)
				{
					EventQueueMutex.WaitOne();
					Plugin.Log.LogInfo((object)("Initiating random event: " + item));
					EventQueue.Add(item);
					EventQueueMutex.ReleaseMutex();
					break;
				}
			}
		}

		public static void QueueEvent(string type)
		{
			string type2 = type;
			if (!Events.Any<(string, int, Action)>(((string name, int weight, 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, int, Action)>(((string name, int weight, Action action) e) => e.name == type2))
			{
				Plugin.Log.LogInfo((object)("No event found for " + type2 + "!"));
				return;
			}
			Events.Where<(string, int, Action)>(((string name, int weight, Action action) e) => e.name == type2).First().Item3();
		}

		public static void ForceRandomEvent(params string[] exclude)
		{
			string[] exclude2 = exclude;
			IEnumerable<(string, int, Action)> enumerable = Events.Where<(string, int, Action)>(((string name, int weight, Action action) e) => !exclude2.Contains(e.name));
			int num = enumerable.Select<(string, int, Action), int>(((string name, int weight, Action action) e) => e.weight).Sum();
			int num2 = Random.Range(0, num);
			int num3 = 0;
			foreach (var item4 in enumerable)
			{
				string item = item4.Item1;
				int item2 = item4.Item2;
				Action item3 = item4.Item3;
				num3 += item2;
				if (num2 < num3)
				{
					ForceEvent(item);
					break;
				}
			}
		}

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