Decompiled source of Project Chaos v1.1.1

TwitchChaosWithoutTwitch.dll

Decompiled 11 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using TwitchChaosWithoutTwitch.Components;
using TwitchChaosWithoutTwitch.NetcodePatcher;
using TwitchChaosWithoutTwitch.Patches;
using TwitchChaosWithoutTwitch.Properties;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("TwitchChaosWithoutTwitch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+756e413d9858f23eacedab8a9ac1af877fe631ce")]
[assembly: AssemblyProduct("TwitchChaosWithoutTwitch")]
[assembly: AssemblyTitle("TwitchChaosWithoutTwitch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 TwitchChaosWithoutTwitch
{
	[BepInPlugin("grug.lethalcompany.TwitchChaosNoTwitch", "TwitchChaosNoTwitch", "0.1.0.0")]
	public class NoMoreTwitch : BaseUnityPlugin
	{
		public const string modGUID = "grug.lethalcompany.TwitchChaosNoTwitch";

		public const string modName = "TwitchChaosNoTwitch";

		public const string modVersion = "0.1.0.0";

		private readonly Harmony harmony = new Harmony("grug.lethalcompany.TwitchChaosNoTwitch");

		public static ConfigEntry<string>? configTimerEvents;

		public static ConfigEntry<string>? configLandingEvents;

		public static ConfigEntry<float>? configTimerInterval;

		public static ManualLogSource mls;

		public static NoMoreTwitch? instance;

		public static GameObject? chaosHolder;

		public static List<EnemyAI> objects = new List<EnemyAI>();

		public static GameObject? chaosContainer;

		public static bool configShowAllDebug = true;

		public static AssetBundle assetBundle = AssetBundle.LoadFromMemory(Resources.forcefield);

		public static GameObject forcefieldPrefab = assetBundle.LoadAsset<GameObject>("Assets/Sphere.prefab");

		public GameObject? despawnableobject;

		private (uint, uint, uint, uint) QuadHash(int SALT = 0)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			Hash128 val = default(Hash128);
			((Hash128)(ref val)).Append("grug.lethalcompany.TwitchChaosNoTwitch");
			((Hash128)(ref val)).Append(SALT);
			return ((uint)val.u64_0, (uint)(val.u64_0 >> 32), (uint)val.u64_1, (uint)(val.u64_1 >> 32));
		}

		public void Awake()
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_0147: 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)
			//IL_015a: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			mls = ((BaseUnityPlugin)this).Logger;
			configTimerInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Event Controls", "Timer Interval", 60f, "Controls the time in between each event");
			configLandingEvents = ((BaseUnityPlugin)this).Config.Bind<string>("Event Controls", "Possible Landing Events", "Upgrades,Tools,Scrap,Weaken,Death", "Put any of the following seperated by a comma to add them to the events that happen when you land\nNoSprint,Teleport,InfiniteSprint,Slippery,Immortal\nFast,Less,Kill,More,Bombs\nUpgrades,Tools,Scrap,Weaken,Death\nOutside,Broken,Inside,FasterTime,FakeApp");
			configTimerEvents = ((BaseUnityPlugin)this).Config.Bind<string>("Event Controls", "Event whitelist", "NoSprint,Teleport,InfiniteSprint,Slippery,Immortal,Fast,Less,Kill,More,Bombs,Outside,Broken,Inside,FasterTime,FakeApp", "Put any of the following seperated by a comma in order to whitelist them to the timer\nNoSprint,Teleport,InfiniteSprint,Slippery,Immortal\nFast,Less,Kill,More,Bombs\nUpgrades,Tools,Scrap,Weaken,Death\nOutside,Broken,Inside,FasterTime,FakeApp");
			if ((Object)(object)forcefieldPrefab == (Object)null)
			{
				mls.LogInfo((object)"forcefield is null");
			}
			foreach (Type item2 in from myType in Assembly.GetAssembly(typeof(EnemyAI)).GetTypes()
				where myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(EnemyAI))
				select myType)
			{
				objects.Add((EnemyAI)Activator.CreateInstance(item2));
			}
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			else
			{
				Object.DestroyImmediate((Object)(object)this);
			}
			if ((Object)(object)chaosContainer == (Object)null)
			{
				chaosContainer = new GameObject("disabled")
				{
					hideFlags = (HideFlags)61
				};
				chaosContainer.SetActive(false);
			}
			if ((Object)(object)chaosHolder == (Object)null)
			{
				chaosHolder = new GameObject("ChaosHolder");
				chaosHolder.transform.SetParent(chaosContainer.transform);
				((Object)chaosHolder).hideFlags = (HideFlags)61;
				chaosHolder.AddComponent<ChaosManager>();
				chaosHolder.AddComponent<EnemyEventManager>();
				chaosHolder.AddComponent<MoonEventManager>();
				chaosHolder.AddComponent<LandingEventManager>();
				chaosHolder.AddComponent<PlayersEventManager>();
				chaosHolder.AddComponent<NetworkObject>();
				uint item = QuadHash().Item1;
				chaosHolder.GetComponent<NetworkObject>().GlobalObjectIdHash = item;
			}
			HUDManager.SubmitChat_performed += new hook_SubmitChat_performed(SubmitChatPatch);
			EnemyAI.Start += new hook_Start(EnemyAI_Start);
			EnemyAI.OnDestroy += new hook_OnDestroy(EnemyAI_OnDestroy);
			PlayerControllerB.DamagePlayer += new hook_DamagePlayer(PlayerControllerB_DamagePlayer);
			PlayerControllerB.KillPlayer += new hook_KillPlayer(PlayerControllerB_KillPlayer);
			PlayerControllerB.Start += new hook_Start(PlayerControllerB_Start);
			PlayerControllerB.AllowPlayerDeath += new hook_AllowPlayerDeath(PlayerControllerB_AllowPlayerDeath);
			RoundManager.DetectElevatorIsRunning += new hook_DetectElevatorIsRunning(RoundManager_DetectElevatorIsRunning);
			StartOfRound.openingDoorsSequence += new hook_openingDoorsSequence(StartOfRound_openingDoorsSequence);
			GameNetworkManager.Start += new hook_Start(GameNetworkManager_Start);
			StartOfRound.Awake += new hook_Awake(StartOfRound_Awake);
			harmony.PatchAll(typeof(OnCollideWithPlayerPatch));
			NetcodePatcher();
		}

		private IEnumerator StartOfRound_openingDoorsSequence(orig_openingDoorsSequence orig, StartOfRound self)
		{
			TimeOfDay.Instance.globalTimeSpeedMultiplier = 1f;
			PlayersEventManager.Instance.ResetStatsClientRpc();
			MoonEventManager.Instance.doBrokenForceField = false;
			LandingEventManager.Instance.deathFieldOn = false;
			LandingEventManager.Instance.alreadyLandEvented = false;
			Object.DestroyImmediate((Object)(object)LandingEventManager.Instance.deathfieldObject);
			EnemyEventManager.Instance.enemiesSpawnExplosions = false;
			return orig.Invoke(self);
		}

		private void RoundManager_DetectElevatorIsRunning(orig_DetectElevatorIsRunning orig, RoundManager self)
		{
			orig.Invoke(self);
			MoonEventManager.Instance.doBrokenForceField = false;
		}

		private bool PlayerControllerB_AllowPlayerDeath(orig_AllowPlayerDeath orig, PlayerControllerB self)
		{
			PlayerStatModifiers playerStatModifiers = default(PlayerStatModifiers);
			if (((Component)self).TryGetComponent<PlayerStatModifiers>(ref playerStatModifiers) && playerStatModifiers.immortal)
			{
				return false;
			}
			return orig.Invoke(self);
		}

		private void PlayerControllerB_Start(orig_Start orig, PlayerControllerB self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<PlayerStatModifiers>();
		}

		private void PlayerControllerB_KillPlayer(orig_KillPlayer orig, PlayerControllerB self, Vector3 bodyVelocity, bool spawnBody, CauseOfDeath causeOfDeath, int deathAnimation)
		{
			//IL_0003: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, bodyVelocity, spawnBody, causeOfDeath, deathAnimation);
			if ((Object)(object)EnemyEventManager.Instance != (Object)null && EnemyEventManager.Instance.enemiesSpawnExplosions && (int)causeOfDeath != 1 && (int)causeOfDeath != 2)
			{
				ChaosManager.Instance.SpawnExplosionIn5SecondsClientRpc(((Component)self).transform.position);
			}
		}

		private void PlayerControllerB_DamagePlayer(orig_DamagePlayer orig, PlayerControllerB self, int damageNumber, bool hasDamageSFX, bool callRPC, CauseOfDeath causeOfDeath, int deathAnimation, bool fallDamage, Vector3 force)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			orig.Invoke(self, damageNumber, hasDamageSFX, callRPC, causeOfDeath, deathAnimation, fallDamage, force);
			if ((Object)(object)EnemyEventManager.Instance != (Object)null && self.AllowPlayerDeath() && EnemyEventManager.Instance.enemiesSpawnExplosions && !fallDamage && (int)causeOfDeath != 1 && !((Component)self).GetComponent<PlayerStatModifiers>().immortal)
			{
				ChaosManager.Instance.SpawnExplosionIn5SecondsClientRpc(((Component)self).transform.position);
			}
		}

		private void EnemyAI_Start(orig_Start orig, EnemyAI self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<EnemyStatModifiers>();
			if ((Object)(object)EnemyEventManager.Instance != (Object)null)
			{
				EnemyEventManager.Instance.spawnedEnemies.Add(self);
			}
		}

		private void EnemyAI_OnDestroy(orig_OnDestroy orig, EnemyAI self)
		{
			if ((Object)(object)EnemyEventManager.Instance != (Object)null)
			{
				EnemyEventManager.Instance.spawnedEnemies.Remove(self);
			}
			orig.Invoke(self);
		}

		private void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)chaosHolder != (Object)null)
			{
				despawnableobject = Object.Instantiate<GameObject>(chaosHolder);
				NetworkObject val = default(NetworkObject);
				if (despawnableobject.TryGetComponent<NetworkObject>(ref val) && !val.IsSpawned)
				{
					val.Spawn(false);
					mls.LogInfo((object)"Spawning object");
				}
			}
		}

		private void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			NetworkManager.Singleton.AddNetworkPrefab(chaosHolder);
		}

		private void SubmitChatPatch(orig_SubmitChat_performed orig, HUDManager self, CallbackContext context)
		{
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			string[] array = self.chatTextField.text.Split(' ');
			if (array[0] == "/chc" && array.Length == 3 && ((NetworkBehaviour)self).IsHost)
			{
				string text = array[1];
				string text2 = text;
				if (!(text2 == "c"))
				{
					if (text2 == "s")
					{
						if (array[2].Split('*').Length == 2)
						{
							ChaosManager.NetworkDisplayTip(array[2].Replace('|', ' ').Split('*')[0], array[2].Replace('|', ' ').Split('*')[1]);
						}
						else
						{
							HUDManager.Instance.DisplayTip("Improper string format!", "Proper string format is /chc s Header*Body with spaces being the '|' character", false, false, "LC_Tip1");
						}
					}
					else
					{
						HUDManager.Instance.DisplayTip("Unknown command!", "Acceptable commands are to call(/chc c) and to display a tip(/chc s head*body)", false, false, "LC_Tip1");
					}
				}
				else
				{
					ChaosManager.Instance.PickEventByName(array[2]);
				}
				self.localPlayer.isTypingChat = false;
				self.chatTextField.text = "";
				((Behaviour)self.typingIndicator).enabled = false;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			else if (array.Length != 3 && array[0] == "/chc" && (Object)(object)self.localPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				HUDManager.Instance.DisplayTip("Improper command entered!", "Make sure its written as below:\n/chc c [event] or /chc s Header|s|p|a|c|e|d|o|u|t*Body", false, false, "LC_Tip1");
				self.localPlayer.isTypingChat = false;
				self.chatTextField.text = "";
				((Behaviour)self.typingIndicator).enabled = false;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			else
			{
				orig.Invoke(self, context);
			}
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace TwitchChaosWithoutTwitch.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("TwitchChaosWithoutTwitch.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] forcefield
		{
			get
			{
				object @object = ResourceManager.GetObject("forcefield", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace TwitchChaosWithoutTwitch.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal static class OnCollideWithPlayerPatch
	{
		[HarmonyTargetMethods]
		public static IEnumerable<MethodBase> TargetMethods()
		{
			foreach (EnemyAI obj in NoMoreTwitch.objects)
			{
				yield return AccessTools.Method(((object)obj).GetType(), "OnCollideWithPlayer", (Type[])null, (Type[])null);
			}
		}

		[HarmonyPrefix]
		public static bool Prefix(EnemyAI __instance, Collider other)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = default(PlayerControllerB);
			((Component)other).TryGetComponent<PlayerControllerB>(ref val);
			EnemyStatModifiers enemyStatModifiers = default(EnemyStatModifiers);
			if (((Component)__instance).TryGetComponent<EnemyStatModifiers>(ref enemyStatModifiers) && ((Component)other).TryGetComponent<PlayerControllerB>(ref val))
			{
				switch (enemyStatModifiers.currentMod)
				{
				case EnemyStatModifiers.DamageModifiers.Zero:
					return false;
				case EnemyStatModifiers.DamageModifiers.More:
					val.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0);
					return false;
				default:
					return true;
				case EnemyStatModifiers.DamageModifiers.None:
					break;
				}
			}
			return true;
		}
	}
}
namespace TwitchChaosWithoutTwitch.Components
{
	public class ChaosEvent
	{
		public delegate void EventDelegate();

		public string name;

		public EventDelegate delegatedEvent;

		public bool availableForTimer;

		public ChaosEvent(EventDelegate eventDelegate, string _name = "", bool _availableForTimer = false)
		{
			name = _name;
			if (_name == "")
			{
				name = $"Unnamed Event {ChaosManager.listOfAllEvents.Count}";
			}
			NoMoreTwitch.mls.LogInfo((object)(name + " was loaded!"));
			delegatedEvent = eventDelegate;
			availableForTimer = _availableForTimer;
		}
	}
	public class ChaosManager : NetworkBehaviour
	{
		public static ChaosManager Instance;

		public LandingEventManager LEMinstance;

		public EnemyEventManager EEMinstance;

		public MoonEventManager MEMinstance;

		public PlayersEventManager PEMinstance;

		public StartOfRound SOR;

		public bool shipLandedLastFrame = false;

		public float timeTillNextEvent = 0f;

		public float timeBetweenEvents = 60f;

		public static List<ChaosEvent> listOfAllEvents = new List<ChaosEvent>();

		public List<ChaosEvent> timerEvents = new List<ChaosEvent>();

		public void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)Instance);
			}
			Instance = this;
		}

		public void Update()
		{
			timeTillNextEvent += Time.deltaTime;
			if ((Object)(object)SOR == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				SOR = StartOfRound.Instance;
			}
			if ((Object)(object)LEMinstance == (Object)null && (Object)(object)LandingEventManager.Instance != (Object)null)
			{
				LEMinstance = LandingEventManager.Instance;
			}
			if ((Object)(object)SOR != (Object)null && (Object)(object)LEMinstance != (Object)null && shipLandedLastFrame != SOR.shipHasLanded && SOR.shipHasLanded && SOR.currentLevel.levelID != 3 && ((NetworkBehaviour)this).IsHost && ((NetworkBehaviour)this).IsServer)
			{
				LandingStuff();
			}
			if ((Object)(object)SOR != (Object)null && (!SOR.shipHasLanded || SOR.currentLevel.levelID == 3))
			{
				timeTillNextEvent = 0f;
			}
			if (timeTillNextEvent > 60f && ((NetworkBehaviour)this).IsHost && ((NetworkBehaviour)this).IsServer)
			{
				timeTillNextEvent = 0f;
				timerEvents = listOfAllEvents.Where((ChaosEvent x) => x.availableForTimer).ToList();
				if (timerEvents.Count != 0)
				{
					timerEvents[Random.Range(0, timerEvents.Count)].delegatedEvent();
				}
			}
		}

		public void LandingStuff()
		{
			if (!((Object)(object)LEMinstance == (Object)null) && !((Object)(object)SOR == (Object)null))
			{
				LEMinstance.ChooseRandomEvent();
			}
		}

		public static void CheckConfig(List<ChaosEvent> events)
		{
			if (NoMoreTwitch.configTimerEvents == null)
			{
				return;
			}
			string[] source = NoMoreTwitch.configTimerEvents.Value.Split(',');
			foreach (ChaosEvent @event in events)
			{
				@event.availableForTimer = source.Contains(@event.name);
			}
		}

		public void PickEventByName(string name)
		{
			foreach (ChaosEvent listOfAllEvent in listOfAllEvents)
			{
				if (listOfAllEvent.name == name)
				{
					listOfAllEvent.delegatedEvent();
					return;
				}
			}
			HUDManager.Instance.DisplayTip("Didn't find an event by the name " + name, "", false, false, "LC_Tip1");
		}

		[ClientRpc]
		public void AllPlayerTipClientRpc(string header, string body)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_008e: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2540404827u, val, (RpcDelivery)0);
				bool flag = header != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(header, false);
				}
				bool flag2 = body != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(body, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2540404827u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				HUDManager.Instance.DisplayTip(header, body, false, false, "LC_Tip1");
			}
		}

		public static void NetworkDisplayTip(string header, string body)
		{
			Instance.AllPlayerTipClientRpc(header, body);
		}

		[ClientRpc]
		public void SpawnExplosionIn5SecondsClientRpc(Vector3 player)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2252351690u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref player);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2252351690u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)Instance).StartCoroutine(DelayedExplosion(player));
				}
			}
		}

		public static IEnumerator DelayedExplosion(Vector3 player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 6; i > 0; i--)
			{
				yield return (object)new WaitForSeconds(1f);
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.DisplayTip("Explosion in", $"{i - 1}", false, false, "LC_Tip1");
				}
			}
			Landmine.SpawnExplosion(player, true, 5f, 15f);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ChaosManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2540404827u, new RpcReceiveHandler(__rpc_handler_2540404827));
			NetworkManager.__rpc_func_table.Add(2252351690u, new RpcReceiveHandler(__rpc_handler_2252351690));
		}

		private static void __rpc_handler_2540404827(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string header = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref header, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string body = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref body, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChaosManager)(object)target).AllPlayerTipClientRpc(header, body);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2252351690(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 player = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref player);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChaosManager)(object)target).SpawnExplosionIn5SecondsClientRpc(player);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ChaosManager";
		}
	}
	public class EnemyEventManager : NetworkBehaviour
	{
		public static EnemyEventManager Instance;

		public RoundManager? roundManagerInstance;

		public List<ChaosEvent> enemyEvents = new List<ChaosEvent>();

		public List<EnemyAI> spawnedEnemies = new List<EnemyAI>();

		public bool enemiesSpawnExplosions = false;

		public NetworkVariable<int> temp = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)Instance);
			}
			Instance = this;
			temp.Value = Random.Range(0, 2);
		}

		public void Update()
		{
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				roundManagerInstance = RoundManager.Instance;
			}
			if (enemyEvents.Count == 0)
			{
				PopulateEnemyEvents();
			}
		}

		[ClientRpc]
		public void RandomFastEnemyClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1111830160u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1111830160u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			temp.Value = Random.Range(0, spawnedEnemies.Count);
			if (spawnedEnemies.Count != 0)
			{
				if ((Object)(object)spawnedEnemies[temp.Value] != (Object)null && (Object)(object)((Component)spawnedEnemies[temp.Value]).GetComponent<EnemyStatModifiers>() != (Object)null)
				{
					((Component)spawnedEnemies[temp.Value]).GetComponent<EnemyStatModifiers>().increaseSpeed = true;
				}
				ChaosManager.NetworkDisplayTip(spawnedEnemies[temp.Value].enemyType.enemyName + " has been made way faster", "\nIt must've gotten dem j's");
			}
		}

		public void KillAllEnemies()
		{
			foreach (EnemyAI spawnedEnemy in spawnedEnemies)
			{
				if ((Object)(object)((Component)spawnedEnemy).GetComponent<NetworkObject>() != (Object)null)
				{
					((Component)spawnedEnemy).GetComponent<NetworkObject>().Despawn(true);
				}
			}
			ChaosManager.NetworkDisplayTip("The metaphorical sun rises", "All the 'mobs' are burning!");
		}

		[ClientRpc]
		public void DoLessDamageClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1685776673u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1685776673u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			foreach (EnemyAI spawnedEnemy in spawnedEnemies)
			{
				if ((Object)(object)((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>() != (Object)null && ((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>().currentMod == EnemyStatModifiers.DamageModifiers.None)
				{
					((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>().currentMod = EnemyStatModifiers.DamageModifiers.Zero;
				}
			}
			ChaosManager.NetworkDisplayTip("Some of the enemies have decided to be nicer!", "\nThey won't hurt you at all anymore!");
		}

		[ClientRpc]
		public void DoMoreDamageClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1624287820u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1624287820u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			foreach (EnemyAI spawnedEnemy in spawnedEnemies)
			{
				if ((Object)(object)((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>() != (Object)null && ((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>().currentMod == EnemyStatModifiers.DamageModifiers.None)
				{
					((Component)spawnedEnemy).GetComponent<EnemyStatModifiers>().currentMod = EnemyStatModifiers.DamageModifiers.More;
				}
			}
		}

		[ClientRpc]
		public void SpawnExplosionsOnAttackClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1264535435u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1264535435u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					enemiesSpawnExplosions = true;
					ChaosManager.NetworkDisplayTip("WARNING:", "THE ENEMIES HAVE LEANRED GUERILLA WARFARE!");
				}
			}
		}

		public void RegisterEnemyEvent(ChaosEvent chaosEvent)
		{
			if (!enemyEvents.Contains(chaosEvent))
			{
				enemyEvents.Add(chaosEvent);
			}
		}

		public void PopulateEnemyEvents()
		{
			RegisterEnemyEvent(new ChaosEvent(RandomFastEnemyClientRpc, "Fast", _availableForTimer: true));
			RegisterEnemyEvent(new ChaosEvent(DoLessDamageClientRpc, "Less", _availableForTimer: true));
			RegisterEnemyEvent(new ChaosEvent(KillAllEnemies, "Kill", _availableForTimer: true));
			RegisterEnemyEvent(new ChaosEvent(DoMoreDamageClientRpc, "More", _availableForTimer: true));
			RegisterEnemyEvent(new ChaosEvent(SpawnExplosionsOnAttackClientRpc, "Bombs", _availableForTimer: true));
			ChaosManager.CheckConfig(enemyEvents);
			ChaosManager.listOfAllEvents.AddRange(enemyEvents);
		}

		protected override void __initializeVariables()
		{
			if (temp == null)
			{
				throw new Exception("EnemyEventManager.temp cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)temp).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)temp, "temp");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)temp);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_EnemyEventManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1111830160u, new RpcReceiveHandler(__rpc_handler_1111830160));
			NetworkManager.__rpc_func_table.Add(1685776673u, new RpcReceiveHandler(__rpc_handler_1685776673));
			NetworkManager.__rpc_func_table.Add(1624287820u, new RpcReceiveHandler(__rpc_handler_1624287820));
			NetworkManager.__rpc_func_table.Add(1264535435u, new RpcReceiveHandler(__rpc_handler_1264535435));
		}

		private static void __rpc_handler_1111830160(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnemyEventManager)(object)target).RandomFastEnemyClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1685776673(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnemyEventManager)(object)target).DoLessDamageClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1624287820(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnemyEventManager)(object)target).DoMoreDamageClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1264535435(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnemyEventManager)(object)target).SpawnExplosionsOnAttackClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "EnemyEventManager";
		}
	}
	internal class EnemyStatModifiers : MonoBehaviour
	{
		public enum DamageModifiers
		{
			None,
			Zero,
			More
		}

		public DamageModifiers currentMod = DamageModifiers.None;

		public bool increaseSpeed = false;

		public void Update()
		{
			EnemyAI val = default(EnemyAI);
			if (increaseSpeed && ((Component)this).gameObject.TryGetComponent<EnemyAI>(ref val))
			{
				val.agent.speed = 50f;
			}
		}
	}
	public class LandingEventManager : NetworkBehaviour
	{
		public static LandingEventManager Instance;

		public bool deathFieldOn = false;

		public bool alreadyLandEvented = false;

		public StartOfRound SOR;

		public List<ChaosEvent> landingEvents = new List<ChaosEvent>();

		public GameObject? deathfieldObject;

		public float DeathFieldRange = 35f;

		public List<PlayerControllerB> activePlayers = new List<PlayerControllerB>();

		public void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)Instance);
			}
			Instance = this;
		}

		public void Update()
		{
			if ((Object)(object)SOR == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				SOR = StartOfRound.Instance;
			}
			if ((Object)(object)SOR != (Object)null && deathFieldOn)
			{
				deathFieldOn = SOR.shipHasLanded;
			}
			if (deathFieldOn)
			{
				DeathField();
			}
			if (landingEvents.Count == 0)
			{
				PopulateLandingEvents();
			}
		}

		public void ChooseRandomEvent(int overrideRandom = -1, bool restrictToOnce = true)
		{
			if (!(alreadyLandEvented && restrictToOnce))
			{
				if (overrideRandom == -1)
				{
					overrideRandom = Random.Range(0, landingEvents.Count);
				}
				landingEvents[overrideRandom].delegatedEvent();
				alreadyLandEvented = true;
			}
		}

		public void UnlockUpgrades()
		{
			if (((NetworkBehaviour)SOR.localPlayerController).IsHost)
			{
				List<UnlockableItem> list = StartOfRound.Instance.unlockablesList.unlockables.Where((UnlockableItem un) => !un.hasBeenUnlockedByPlayer && !un.alreadyUnlocked).ToList();
				for (int i = 0; i < 5; i++)
				{
					if (list.Count > 0)
					{
						SOR.UnlockShipObject(SOR.unlockablesList.unlockables.IndexOf(list[Random.Range(0, list.Count)]));
					}
					if (Random.Range(0, 2) == 1)
					{
						break;
					}
				}
			}
			ChaosManager.NetworkDisplayTip("Have some upgrades!", "Enjoy decorations, suits, or even upgrades!");
		}

		public void WalksAndFlashes()
		{
			//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)
			int index = 14;
			for (int i = 0; i < 2; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					GameObject val = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[index].spawnPrefab, ((Component)SOR.middleOfShipNode).transform.position, Quaternion.identity);
					val.GetComponent<GrabbableObject>().fallTime = 0f;
					val.GetComponent<NetworkObject>().Spawn(true);
					val.AddComponent<ScanNodeProperties>().scrapValue = 0;
					val.GetComponent<GrabbableObject>().SetScrapValue(0);
				}
				index = ((Random.Range(0, 2) != 1) ? 3 : 9);
			}
			ChaosManager.NetworkDisplayTip("Enjoy some tools!", "There are four walkies and four flashlights in the ship!");
		}

		public void FiveHundredScrap()
		{
			//IL_0034: 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_0082: 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)
			for (int i = 0; i < 4; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[25].spawnPrefab, ((Component)SOR.middleOfShipNode).transform.position, Quaternion.identity);
				val.GetComponent<GrabbableObject>().fallTime = 0f;
				val.GetComponent<NetworkObject>().Spawn(false);
				val.GetComponent<GrabbableObject>().SetScrapValue(125);
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()) }, new int[1] { 125 });
			}
			ChaosManager.NetworkDisplayTip("Praise the honkmother!", "There are four clownhorns on the ship!\nIf you dont pick it up, they'll despawn!");
		}

		public void RandomDamagePlayer()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			activePlayers.Clear();
			PlayerControllerB[] allPlayerScripts = SOR.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.isPlayerControlled)
				{
					activePlayers.Add(val);
				}
			}
			int num = Random.Range(1, 50);
			int num2 = Random.Range(0, activePlayers.Count);
			activePlayers[num2].DamagePlayerFromOtherClientServerRpc(num, Vector3.zero, num2);
			ChaosManager.NetworkDisplayTip("Space debris!", $"One of your suits has been damaged! Sorry!\nSuit integrity:{activePlayers[num2].health}");
		}

		public void DeathField()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			deathFieldOn = true;
			if (!((Object)(object)SOR != (Object)null) || !((Object)(object)SOR.middleOfShipNode != (Object)null) || !((Object)(object)EnemyEventManager.Instance != (Object)null))
			{
				return;
			}
			foreach (EnemyAI spawnedEnemy in EnemyEventManager.Instance.spawnedEnemies)
			{
				if ((Object)(object)spawnedEnemy != (Object)null && Vector3.Distance(((Component)spawnedEnemy).transform.position, ((Component)SOR.middleOfShipNode).transform.position) < DeathFieldRange / 2f)
				{
					((Component)spawnedEnemy).GetComponent<NetworkObject>().Despawn(true);
				}
			}
		}

		[ClientRpc]
		public void TurnOnDeathFieldClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1737654164u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1737654164u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
				{
					deathFieldOn = true;
				}
				deathfieldObject = Object.Instantiate<GameObject>(NoMoreTwitch.forcefieldPrefab);
				deathfieldObject.transform.localScale = Vector3.one * DeathFieldRange;
				deathfieldObject.transform.position = SOR.middleOfShipNode.position;
				deathfieldObject.GetComponent<Renderer>().sharedMaterial.SetFloat("_StartTime", Time.time);
				ChaosManager.NetworkDisplayTip("Ship defense activated!", "Any enemies that get too close get EVAPORATED");
			}
		}

		public void RegisterLandingEvent(ChaosEvent chaosEvent)
		{
			if (!landingEvents.Contains(chaosEvent))
			{
				landingEvents.Add(chaosEvent);
			}
		}

		public void PopulateLandingEvents()
		{
			RegisterLandingEvent(new ChaosEvent(UnlockUpgrades, "Upgrades"));
			RegisterLandingEvent(new ChaosEvent(WalksAndFlashes, "Tools"));
			RegisterLandingEvent(new ChaosEvent(FiveHundredScrap, "Scrap"));
			RegisterLandingEvent(new ChaosEvent(RandomDamagePlayer, "Weaken"));
			RegisterLandingEvent(new ChaosEvent(TurnOnDeathFieldClientRpc, "Death"));
			ChaosManager.CheckConfig(landingEvents);
			ChaosManager.listOfAllEvents.AddRange(landingEvents);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LandingEventManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1737654164u, new RpcReceiveHandler(__rpc_handler_1737654164));
		}

		private static void __rpc_handler_1737654164(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LandingEventManager)(object)target).TurnOnDeathFieldClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LandingEventManager";
		}
	}
	public class MoonEventManager : NetworkBehaviour
	{
		public static MoonEventManager Instance;

		public RoundManager rMInstance;

		public EnemyVent furthestVent;

		public bool doBrokenForceField = false;

		public GameObject brokenForceField;

		public float timeTillDamage = 0f;

		public List<ChaosEvent> moonEvents = new List<ChaosEvent>();

		public Coroutine? scaleCoroutine;

		public void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)Instance);
			}
			Instance = this;
		}

		public void Update()
		{
			if ((Object)(object)rMInstance == (Object)null && (Object)(object)RoundManager.Instance != (Object)null)
			{
				rMInstance = RoundManager.Instance;
			}
			if (StartOfRound.Instance.shipHasLanded && doBrokenForceField)
			{
				doBrokenForceField = StartOfRound.Instance.shipHasLanded;
			}
			if (doBrokenForceField)
			{
				DoBrokenForceField();
			}
			if (moonEvents.Count == 0)
			{
				PopulateMoonEvents();
			}
			if (!StartOfRound.Instance.shipHasLanded && TimeOfDay.Instance.globalTime == 2f)
			{
				TimeOfDay.Instance.globalTimeSpeedMultiplier = 1f;
			}
			timeTillDamage += Time.deltaTime;
		}

		public void SpawnAllOutsideEnemies()
		{
			GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
			for (int i = 0; i < array.Length; i++)
			{
				rMInstance.SpawnRandomOutsideEnemy(array, 17f);
			}
			ChaosManager.NetworkDisplayTip("Warning: Multiple Enemies Detected", "\nThe outside is a risky place to be.");
		}

		public void DoBrokenForceField()
		{
			//IL_0045: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)brokenForceField == (Object)null)
			{
				return;
			}
			foreach (EnemyAI spawnedEnemy in EnemyEventManager.Instance.spawnedEnemies)
			{
				if (!((Object)(object)spawnedEnemy == (Object)null) && Vector3.Distance(((Component)spawnedEnemy).transform.position, ((Component)furthestVent).transform.position) < brokenForceField.transform.localScale.x / 2f)
				{
					((Component)spawnedEnemy).GetComponent<NetworkObject>().Despawn(true);
				}
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && Vector3.Distance(((Component)val).transform.position, ((Component)furthestVent).transform.position) < brokenForceField.transform.localScale.x / 2f && timeTillDamage >= 1f)
				{
					timeTillDamage = 0f;
					val.DamagePlayerFromOtherClientServerRpc(3, Vector3.zero, 0);
				}
			}
		}

		public void BrokenFFServerEvent()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			furthestVent = RoundManager.Instance.allEnemyVents.OrderByDescending((EnemyVent x) => Vector3.Distance(((Component)x).transform.position, RoundManager.FindMainEntrancePosition(false, false))).First();
			BrokenForcefieldSomewhereClientRpc(NetworkObjectReference.op_Implicit(((Component)furthestVent).GetComponent<NetworkObject>()));
		}

		[ClientRpc]
		public void BrokenForcefieldSomewhereClientRpc(NetworkObjectReference ventObj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1456263284u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref ventObj, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1456263284u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref ventObj)).TryGet(ref val3, (NetworkManager)null))
				{
					furthestVent = ((Component)val3).GetComponent<EnemyVent>();
				}
				brokenForceField = Object.Instantiate<GameObject>(NoMoreTwitch.forcefieldPrefab);
				brokenForceField.transform.position = ((Component)furthestVent).transform.position;
				scaleCoroutine = ((MonoBehaviour)this).StartCoroutine(ChangeScale(brokenForceField.transform, Vector3.one, Vector3.one * (Vector3.Distance(brokenForceField.transform.position, RoundManager.FindMainEntrancePosition(false, false)) * 2f), 300f));
				doBrokenForceField = true;
				ChaosManager.NetworkDisplayTip("A forcefield has broken", "Do not enter the red field. Your suits will protect you for a few seconds.");
			}
		}

		public void SpawnAllInsideEnemies()
		{
			EnemyVent[] allEnemyVents = rMInstance.allEnemyVents;
			foreach (EnemyVent val in allEnemyVents)
			{
				val.spawnTime = 0f;
				if (!val.ventIsOpen)
				{
					rMInstance.AssignRandomEnemyToVent(val, 0f);
					RoundManager obj = rMInstance;
					obj.currentMaxInsidePower += 10;
					rMInstance.SpawnEnemyFromVent(val);
					val.OpenVentClientRpc();
				}
			}
			ChaosManager.NetworkDisplayTip("Multiple enemies detected", "Are you sure that tattered metal sheet is worth it?");
		}

		[ClientRpc]
		public void MakeTimeFasterClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3753267133u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3753267133u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					TimeOfDay.Instance.globalTimeSpeedMultiplier = 2f;
					ChaosManager.NetworkDisplayTip("The earth rumbles", "The day is getting shorter!");
				}
			}
		}

		[ClientRpc]
		public void PullFakeApparatusClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1014018037u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1014018037u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(FakeApparatus());
				}
			}
		}

		public static IEnumerator FakeApparatus()
		{
			ChaosManager.NetworkDisplayTip("WARNING: POWER SURGE DETECTED", "");
			yield return (object)new WaitForSeconds(0.5f);
			RoundManager.Instance.FlickerLights(false, false);
			yield return (object)new WaitForSeconds(0.5f);
			RoundManager.Instance.FlickerLights(false, false);
			yield return (object)new WaitForSeconds(0.5f);
			RoundManager.Instance.FlickerLights(false, false);
			yield return (object)new WaitForSeconds(2.5f);
			RoundManager.Instance.SwitchPower(false);
			RoundManager.Instance.powerOffPermanently = true;
			yield return (object)new WaitForSeconds(3f);
			ChaosManager.NetworkDisplayTip("Facitily diagnostics report:\nElectric system fried\nLights+Doors are broken", "");
		}

		public void RegisterMoonEvent(ChaosEvent chaosEvent)
		{
			if (!moonEvents.Contains(chaosEvent))
			{
				moonEvents.Add(chaosEvent);
			}
		}

		public void PopulateMoonEvents()
		{
			RegisterMoonEvent(new ChaosEvent(SpawnAllOutsideEnemies, "Outside", _availableForTimer: true));
			RegisterMoonEvent(new ChaosEvent(BrokenFFServerEvent, "Broken", _availableForTimer: true));
			RegisterMoonEvent(new ChaosEvent(SpawnAllInsideEnemies, "Inside", _availableForTimer: true));
			RegisterMoonEvent(new ChaosEvent(MakeTimeFasterClientRpc, "FasterTime", _availableForTimer: true));
			RegisterMoonEvent(new ChaosEvent(PullFakeApparatusClientRpc, "FakeApp", _availableForTimer: true));
			ChaosManager.CheckConfig(moonEvents);
			ChaosManager.listOfAllEvents.AddRange(moonEvents);
		}

		public static IEnumerator ChangeScale(Transform target, Vector3 startScale, Vector3 endScale, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			float startTime = Time.time;
			target.localScale = startScale;
			while (Time.time - startTime <= duration)
			{
				float progress = (Time.time - startTime) / duration;
				target.localScale = Vector3.Lerp(startScale, endScale, progress);
				yield return null;
			}
			target.localScale = endScale;
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MoonEventManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1456263284u, new RpcReceiveHandler(__rpc_handler_1456263284));
			NetworkManager.__rpc_func_table.Add(3753267133u, new RpcReceiveHandler(__rpc_handler_3753267133));
			NetworkManager.__rpc_func_table.Add(1014018037u, new RpcReceiveHandler(__rpc_handler_1014018037));
		}

		private static void __rpc_handler_1456263284(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference ventObj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref ventObj, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MoonEventManager)(object)target).BrokenForcefieldSomewhereClientRpc(ventObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3753267133(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MoonEventManager)(object)target).MakeTimeFasterClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1014018037(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MoonEventManager)(object)target).PullFakeApparatusClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MoonEventManager";
		}
	}
	public class PlayersEventManager : NetworkBehaviour
	{
		public static PlayersEventManager Instance;

		public List<PlayerControllerB> activePlayers = new List<PlayerControllerB>();

		public List<ChaosEvent> playerEvents = new List<ChaosEvent>();

		private NetworkVariable<int> temp = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)Instance);
			}
			Instance = this;
			temp.Value = Random.Range(0, activePlayers.Count());
		}

		public void Update()
		{
			activePlayers = StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.isPlayerControlled).ToList();
			if (playerEvents.Count == 0)
			{
				PopulatePlayerEvents();
			}
		}

		[ClientRpc]
		public void ResetStatsClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2287547899u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2287547899u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			PlayerStatModifiers playerStatModifiers = default(PlayerStatModifiers);
			foreach (PlayerControllerB activePlayer in activePlayers)
			{
				if (((Component)activePlayer).TryGetComponent<PlayerStatModifiers>(ref playerStatModifiers))
				{
					playerStatModifiers.immortal = false;
					playerStatModifiers.infiniteSprint = false;
				}
			}
		}

		[ClientRpc]
		public void DrainPlayerSprintClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(920105313u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 920105313u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					temp.Value = Random.Range(0, activePlayers.Count());
					activePlayers[temp.Value].sprintMeter = 0f;
					ChaosManager.NetworkDisplayTip(activePlayers[temp.Value].playerUsername + " is really tired...", "\nBeing on their feet all day and running from monsters is busy and tiring work.");
				}
			}
		}

		[ClientRpc]
		public void TeleportPlayerUpClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1244144628u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1244144628u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					temp.Value = Random.Range(0, activePlayers.Count());
					activePlayers[temp.Value].TeleportPlayer(new Vector3(((Component)activePlayers[temp.Value]).transform.position.x, ((Component)activePlayers[temp.Value]).transform.position.y + 100f, ((Component)activePlayers[temp.Value]).transform.position.z), false, 0f, false, true);
					ChaosManager.NetworkDisplayTip("The simulation is breaking", activePlayers[temp.Value].playerUsername + "'s bit has been flipped");
				}
			}
		}

		[ClientRpc]
		public void RandomPlayerGetsInfiniteSprintClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2021414874u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2021414874u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				temp.Value = Random.Range(0, activePlayers.Count());
				PlayerStatModifiers playerStatModifiers = default(PlayerStatModifiers);
				if (((Component)activePlayers[temp.Value]).TryGetComponent<PlayerStatModifiers>(ref playerStatModifiers))
				{
					playerStatModifiers.infiniteSprint = true;
				}
				ChaosManager.NetworkDisplayTip(activePlayers[temp.Value].playerUsername + " has infinite sprint", "They must have the runner trait or something...");
			}
		}

		public void Dropitems()
		{
			temp.Value = Random.Range(0, activePlayers.Count());
			activePlayers[temp.Value].DropAllHeldItemsAndSync();
			ChaosManager.NetworkDisplayTip(activePlayers[temp.Value].playerUsername + " has butterfingers!", "Maybe you shouldn't eat so many chips next time.");
		}

		[ClientRpc]
		public void MakeRandomPlayerImmortalClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2902574198u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2902574198u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				temp.Value = Random.Range(0, activePlayers.Count());
				PlayerControllerB val3 = activePlayers[temp.Value];
				PlayerStatModifiers playerStatModifiers = default(PlayerStatModifiers);
				if (((Component)val3).TryGetComponent<PlayerStatModifiers>(ref playerStatModifiers))
				{
					playerStatModifiers.immortal = true;
				}
				ChaosManager.NetworkDisplayTip(activePlayers[temp.Value].playerUsername + " has toggled god mode", "\nThey're tired of dying to that damn hoarding bug.");
			}
		}

		public void RegisterPlayerEvent(ChaosEvent chaosEvent)
		{
			if (!playerEvents.Contains(chaosEvent))
			{
				playerEvents.Add(chaosEvent);
			}
		}

		public void PopulatePlayerEvents()
		{
			RegisterPlayerEvent(new ChaosEvent(DrainPlayerSprintClientRpc, "NoSprint", _availableForTimer: true));
			RegisterPlayerEvent(new ChaosEvent(TeleportPlayerUpClientRpc, "Teleport", _availableForTimer: true));
			RegisterPlayerEvent(new ChaosEvent(RandomPlayerGetsInfiniteSprintClientRpc, "InfiniteSprint", _availableForTimer: true));
			RegisterPlayerEvent(new ChaosEvent(Dropitems, "Slippery", _availableForTimer: true));
			RegisterPlayerEvent(new ChaosEvent(MakeRandomPlayerImmortalClientRpc, "Immortal", _availableForTimer: true));
			ChaosManager.CheckConfig(playerEvents);
			ChaosManager.listOfAllEvents.AddRange(playerEvents);
		}

		protected override void __initializeVariables()
		{
			if (temp == null)
			{
				throw new Exception("PlayersEventManager.temp cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)temp).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)temp, "temp");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)temp);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PlayersEventManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2287547899u, new RpcReceiveHandler(__rpc_handler_2287547899));
			NetworkManager.__rpc_func_table.Add(920105313u, new RpcReceiveHandler(__rpc_handler_920105313));
			NetworkManager.__rpc_func_table.Add(1244144628u, new RpcReceiveHandler(__rpc_handler_1244144628));
			NetworkManager.__rpc_func_table.Add(2021414874u, new RpcReceiveHandler(__rpc_handler_2021414874));
			NetworkManager.__rpc_func_table.Add(2902574198u, new RpcReceiveHandler(__rpc_handler_2902574198));
		}

		private static void __rpc_handler_2287547899(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayersEventManager)(object)target).ResetStatsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_920105313(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayersEventManager)(object)target).DrainPlayerSprintClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1244144628(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayersEventManager)(object)target).TeleportPlayerUpClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2021414874(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayersEventManager)(object)target).RandomPlayerGetsInfiniteSprintClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2902574198(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayersEventManager)(object)target).MakeRandomPlayerImmortalClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PlayersEventManager";
		}
	}
	internal class PlayerStatModifiers : MonoBehaviour
	{
		public bool immortal = false;

		public bool infiniteSprint = false;

		public void Update()
		{
			PlayerControllerB val = default(PlayerControllerB);
			if (infiniteSprint && ((Component)this).TryGetComponent<PlayerControllerB>(ref val))
			{
				val.sprintMeter = 1f;
			}
		}

		public void MakeTemporarilyImmortal(float time = 15f)
		{
			((MonoBehaviour)this).StartCoroutine(MakeImmortalForTime(time));
		}

		public IEnumerator MakeImmortalForTime(float timeOverride)
		{
			immortal = true;
			yield return (object)new WaitForSeconds(timeOverride);
			immortal = false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace TwitchChaosWithoutTwitch.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}