Decompiled source of itolib v0.2.0

BepInEx/plugins/itolib.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using FacilityMeltdown;
using FacilityMeltdown.API;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyTestMod;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using PizzaTowerEscapeMusic;
using TVLoader.Patches;
using TVLoader.Utils;
using Unity.AI.Navigation;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
using UnityEngine.Video;
using WeatherRegistry;
using WeatherRegistry.Networking;
using itolib.Behaviours.Detectors;
using itolib.Behaviours.Effects;
using itolib.Behaviours.Grabbables;
using itolib.Behaviours.Helpers;
using itolib.Behaviours.Networking;
using itolib.Compatibility;
using itolib.Enums;
using itolib.Extensions;
using itolib.Interfaces;
using itolib.NetcodePatcher;
using itolib.Patches;
using itolib.PlayZone;
using itolib.ScriptableObjects;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("CrowdControl")]
[assembly: IgnoresAccessChecksTo("FacilityMeltdown")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("PizzaTowerEscapeMusic")]
[assembly: IgnoresAccessChecksTo("TVLoader")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("itolib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Wondrous gizmos and gadgets for the restless mind.")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+786aa752ba53f4918f184c9f5a28f25d0b9495e2")]
[assembly: AssemblyProduct("itolib")]
[assembly: AssemblyTitle("itolib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
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 itolib
{
	public class Config
	{
		public Config(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			ClearOrphanedEntries(cfg);
			cfg.SaveOnConfigSet = true;
			cfg.Save();
		}

		private static void ClearOrphanedEntries(ConfigFile config)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			((Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config))?.Clear();
		}
	}
	[BepInDependency("imabatby.lethallevelloader", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("pacoito.itolib", "itolib", "0.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "pacoito.itolib";

		public const string PLUGIN_NAME = "itolib";

		public const string VERSION = "0.2.0";

		internal static ManualLogSource StaticLogger { get; private set; }

		internal static Harmony Harmony { get; private set; }

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Harmony = new Harmony("pacoito.itolib");
				NetcodePatcher();
				Harmony.PatchAll(typeof(LoadPatch));
				if (Chainloader.PluginInfos["imabatby.lethallevelloader"].Metadata.Version.CompareTo(new Version(1, 4, 11)) <= 0)
				{
					LLLStoryLogPatch.LLLStoryLogNodes = new Dictionary<int, TerminalNode>();
					Harmony.PatchAll(typeof(LLLStoryLogPatch));
				}
				if (WeatherRegistryCompatibility.Enabled)
				{
					Harmony.PatchAll(typeof(WeatherRegistryCompatibility));
				}
				StaticLogger.LogInfo((object)"itolib v0.2.0 loaded!");
			}
			catch (Exception arg)
			{
				StaticLogger.LogError((object)string.Format("Error while initializing '{0}': {1}", "itolib", arg));
			}
		}

		private static void NetcodePatcher()
		{
			Type[] array;
			try
			{
				array = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				array = ex.Types.Where((Type type) => type != null).ToArray();
			}
			Type[] array2 = array;
			foreach (Type type2 in array2)
			{
				MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace itolib.ScriptableObjects
{
	[Serializable]
	public struct BoolEntry : IScriptableConfigEntry<bool>
	{
		[field: SerializeField]
		public string Section { get; set; }

		[field: SerializeField]
		public string Key { get; set; }

		[field: SerializeField]
		public bool DefaultValue { get; set; }

		[field: SerializeField]
		public string Description { get; set; }
	}
	[CreateAssetMenu(fileName = "ScriptableEvent", menuName = "itolib/Config/ScriptableConfig")]
	public class ScriptableConfig : ScriptableObject
	{
		[Header("Scriptable Config")]
		[Tooltip("")]
		public string authorName = "";

		[Tooltip("")]
		public string modName = "";

		[Tooltip("")]
		public List<BoolEntry> boolEntries = new List<BoolEntry>();

		public ConfigFile Config { get; private set; } = null;


		public List<ConfigEntryBase> ConfigEntries { get; private set; } = new List<ConfigEntryBase>();


		public void Awake()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			string text = (Application.isEditor ? "." : Paths.ConfigPath);
			Config = new ConfigFile(Utility.CombinePaths(new string[2]
			{
				text,
				authorName + "." + modName + ".cfg"
			}), false, (BepInPlugin)null)
			{
				SaveOnConfigSet = false
			};
			foreach (BoolEntry boolEntry in boolEntries)
			{
				ConfigEntry<bool> item = Config.Bind<bool>(boolEntry.Section, boolEntry.Key, boolEntry.DefaultValue, boolEntry.Description);
				ConfigEntries.Add((ConfigEntryBase)(object)item);
			}
			ClearOrphanedEntries(Config);
			Config.SaveOnConfigSet = true;
			Config.Save();
		}

		public static void ClearOrphanedEntries(ConfigFile config)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			((Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config))?.Clear();
		}
	}
	[CreateAssetMenu(fileName = "ScriptableEvent", menuName = "itolib/Events/ScriptableEvent")]
	public class ScriptableEvent : ScriptableObject
	{
		private event Action? OnEventRaise;

		public void RaiseEvent()
		{
			this.OnEventRaise?.Invoke();
		}

		public void AddListener(Action listener)
		{
			OnEventRaise += listener;
		}

		public void RemoveListener(Action listener)
		{
			OnEventRaise -= listener;
		}

		public void ClearListeners()
		{
			this.OnEventRaise = null;
		}
	}
}
namespace itolib.PlayZone
{
	public class PlayZoneElevator : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <DeactivateElevatorDelayed>d__36 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayZoneElevator <>4__this;

			object? IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object? IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DeactivateElevatorDelayed>d__36(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.SwitchState(ElevatorState.Deactivated);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("PlayZone Elevator")]
		[Tooltip("")]
		public Animator? elevatorAnimator;

		[Tooltip("")]
		public Animator? doorAnimatorUpper;

		[Tooltip("")]
		public Animator? doorAnimatorLower;

		[Header("Buttons")]
		[Tooltip("")]
		public InteractTrigger? callElevatorUpper;

		[Tooltip("")]
		public InteractTrigger? callElevatorLower;

		[Tooltip("")]
		public InteractTrigger? openDoors;

		[Tooltip("")]
		public InteractTrigger? closeDoors;

		[Header("Audio")]
		[Tooltip("")]
		public AudioSource? elevatorSource;

		[Tooltip("")]
		public AudioSource? doorSourceUpper;

		[Tooltip("")]
		public AudioSource? doorSourceLower;

		[Tooltip("")]
		public AudioClip? elevatorAudioTravel;

		[Tooltip("")]
		public AudioClip? elevatorAudioFinish;

		[Tooltip("")]
		public AudioClip? doorAudioOpen;

		[Tooltip("")]
		public AudioClip? doorAudioClose;

		[Header("Events")]
		[Tooltip("")]
		public UnityEvent<bool> onElevatorTravelStart = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onElevatorTravelFinish = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent onTopReached = new UnityEvent();

		[Tooltip("")]
		public UnityEvent onBottomReached = new UnityEvent();

		[Tooltip("")]
		public UnityEvent onDeactivate = new UnityEvent();

		[Tooltip("")]
		public UnityEvent<bool> onDoorsOpen = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onDoorsClose = new UnityEvent<bool>();

		public ElevatorState CurrentState { get; private set; } = ElevatorState.IdleDown;


		public void SwitchState(ElevatorState newState)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentState != newState && CurrentState != ElevatorState.Deactivated)
			{
				SwitchStateLocal(newState);
				SwitchStateServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)GameNetworkManager.Instance.localPlayerController), newState);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SwitchStateServerRpc(NetworkBehaviourReference playerReference, ElevatorState newState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2237745972u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ElevatorState>(ref newState, default(ForEnums));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2237745972u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SwitchStateClientRpc(playerReference, newState);
				}
			}
		}

		[ClientRpc]
		public void SwitchStateClientRpc(NetworkBehaviourReference playerReference, ElevatorState newState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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(732950694u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ElevatorState>(ref newState, default(ForEnums));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 732950694u, val, (RpcDelivery)0);
				}
				PlayerControllerB player = default(PlayerControllerB);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviourReference)(ref playerReference)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null) && !player.IsLocalClient())
				{
					SwitchStateLocal(newState);
				}
			}
		}

		public void SwitchStateLocal(ElevatorState newState)
		{
			if (CurrentState == newState)
			{
				return;
			}
			switch (newState)
			{
			case ElevatorState.IdleUp:
			case ElevatorState.IdleDown:
			{
				bool flag = newState == ElevatorState.IdleUp;
				if ((Object)(object)elevatorAudioFinish != (Object)null && (Object)(object)elevatorSource != (Object)null)
				{
					elevatorSource.Stop();
					elevatorSource.PlayOneShot(elevatorAudioFinish);
				}
				if ((Object)(object)callElevatorUpper != (Object)null && (Object)(object)callElevatorLower != (Object)null)
				{
					callElevatorUpper.hoverTip = (flag ? "Open door : [LMB]" : "Call : [LMB]");
					callElevatorLower.hoverTip = (flag ? "Call : [LMB]" : "Open door : [LMB]");
				}
				CurrentState = newState;
				if (flag)
				{
					onTopReached.Invoke();
				}
				else
				{
					onBottomReached.Invoke();
				}
				onElevatorTravelFinish.Invoke(flag);
				break;
			}
			case ElevatorState.GoingUp:
			case ElevatorState.GoingDown:
			{
				bool flag = newState == ElevatorState.GoingUp;
				if ((Object)(object)elevatorAudioFinish != (Object)null && (Object)(object)elevatorSource != (Object)null)
				{
					elevatorSource.Play();
				}
				if ((Object)(object)elevatorAnimator != (Object)null)
				{
					elevatorAnimator.SetBool("ElevatorGoingUp", flag);
				}
				onElevatorTravelStart.Invoke(flag);
				CurrentState = newState;
				break;
			}
			case ElevatorState.Deactivated:
				if ((Object)(object)elevatorAnimator != (Object)null)
				{
					elevatorAnimator.SetTrigger("Deactivated");
				}
				CurrentState = newState;
				break;
			}
		}

		public void CallElevator(bool up)
		{
			switch (CurrentState)
			{
			case ElevatorState.IdleUp:
				if (!up)
				{
					SwitchState(ElevatorState.GoingDown);
				}
				else
				{
					ToggleDoors(open: true);
				}
				break;
			case ElevatorState.IdleDown:
				if (up)
				{
					SwitchState(ElevatorState.GoingUp);
				}
				else
				{
					ToggleDoors(open: true);
				}
				break;
			case ElevatorState.GoingUp:
			case ElevatorState.GoingDown:
			case ElevatorState.Deactivated:
				break;
			}
		}

		public void CallElevatorLocal(bool up)
		{
			switch (CurrentState)
			{
			case ElevatorState.IdleUp:
				if (!up)
				{
					SwitchStateLocal(ElevatorState.GoingDown);
				}
				else
				{
					ToggleDoorsLocal(open: true);
				}
				break;
			case ElevatorState.IdleDown:
				if (up)
				{
					SwitchStateLocal(ElevatorState.GoingUp);
				}
				else
				{
					ToggleDoorsLocal(open: true);
				}
				break;
			case ElevatorState.GoingUp:
			case ElevatorState.GoingDown:
			case ElevatorState.Deactivated:
				break;
			}
		}

		public void ToggleDoors(bool open)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentState != ElevatorState.Deactivated)
			{
				ToggleDoorsLocal(open);
				ToggleDoorsServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)GameNetworkManager.Instance.localPlayerController), open);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ToggleDoorsServerRpc(NetworkBehaviourReference playerReference, bool open)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(228610214u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 228610214u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ToggleDoorsClientRpc(playerReference, open);
				}
			}
		}

		[ClientRpc]
		public void ToggleDoorsClientRpc(NetworkBehaviourReference playerReference, bool open)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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(2597611336u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2597611336u, val, (RpcDelivery)0);
				}
				PlayerControllerB player = default(PlayerControllerB);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviourReference)(ref playerReference)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null) && !player.IsLocalClient())
				{
					ToggleDoorsLocal(open);
				}
			}
		}

		public void ToggleDoorsLocal(bool open)
		{
			switch (CurrentState)
			{
			case ElevatorState.IdleUp:
				if ((Object)(object)doorAnimatorUpper != (Object)null && doorAnimatorUpper.GetBool("Open") == !open)
				{
					if ((Object)(object)doorSourceUpper != (Object)null && (Object)(object)doorAudioOpen != (Object)null)
					{
						doorSourceUpper.PlayOneShot(doorAudioOpen);
					}
					doorAnimatorUpper.SetBool("Open", open);
					if (open)
					{
						onDoorsOpen.Invoke(true);
					}
					else
					{
						onDoorsClose.Invoke(true);
					}
				}
				break;
			case ElevatorState.IdleDown:
				if ((Object)(object)doorAnimatorLower != (Object)null && doorAnimatorLower.GetBool("Open") == !open)
				{
					if ((Object)(object)doorSourceLower != (Object)null && (Object)(object)doorAudioOpen != (Object)null)
					{
						doorSourceLower.PlayOneShot(doorAudioOpen);
					}
					doorAnimatorLower.SetBool("Open", open);
					if (open)
					{
						onDoorsOpen.Invoke(false);
					}
					else
					{
						onDoorsClose.Invoke(false);
					}
				}
				break;
			case ElevatorState.GoingUp:
			case ElevatorState.GoingDown:
			case ElevatorState.Deactivated:
				break;
			}
		}

		public void DeactivateElevator()
		{
			switch (CurrentState)
			{
			case ElevatorState.IdleUp:
				SwitchState(ElevatorState.GoingDown);
				break;
			case ElevatorState.IdleDown:
				SwitchState(ElevatorState.GoingUp);
				break;
			}
			if ((Object)(object)doorAnimatorLower != (Object)null && doorAnimatorLower.GetBool("Open"))
			{
				doorAnimatorLower.SetBool("Open", false);
				if ((Object)(object)doorSourceLower != (Object)null && (Object)(object)doorAudioOpen != (Object)null)
				{
					doorSourceLower.PlayOneShot(doorAudioClose);
				}
			}
			if ((Object)(object)doorAnimatorUpper != (Object)null && doorAnimatorUpper.GetBool("Open"))
			{
				doorAnimatorUpper.SetBool("Open", false);
				if ((Object)(object)doorSourceUpper != (Object)null && (Object)(object)doorAudioOpen != (Object)null)
				{
					doorSourceUpper.PlayOneShot(doorAudioClose);
				}
			}
			((MonoBehaviour)this).StartCoroutine(DeactivateElevatorDelayed());
		}

		[IteratorStateMachine(typeof(<DeactivateElevatorDelayed>d__36))]
		private IEnumerator DeactivateElevatorDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DeactivateElevatorDelayed>d__36(0)
			{
				<>4__this = this
			};
		}

		public void OnDeactivate()
		{
			onDeactivate.Invoke();
			if ((Object)(object)elevatorAudioFinish != (Object)null && (Object)(object)elevatorSource != (Object)null)
			{
				elevatorSource.Stop();
				elevatorSource.PlayOneShot(elevatorAudioFinish);
			}
			if ((Object)(object)doorSourceLower != (Object)null && (Object)(object)doorAudioOpen != (Object)null)
			{
				doorSourceLower.PlayOneShot(doorAudioOpen);
			}
			if ((Object)(object)doorAnimatorLower != (Object)null && (Object)(object)doorAnimatorUpper != (Object)null)
			{
				doorAnimatorLower.SetBool("Open", true);
				doorAnimatorUpper.SetBool("Open", false);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PlayZoneElevator()
		{
			//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(2237745972u, new RpcReceiveHandler(__rpc_handler_2237745972));
			NetworkManager.__rpc_func_table.Add(732950694u, new RpcReceiveHandler(__rpc_handler_732950694));
			NetworkManager.__rpc_func_table.Add(228610214u, new RpcReceiveHandler(__rpc_handler_228610214));
			NetworkManager.__rpc_func_table.Add(2597611336u, new RpcReceiveHandler(__rpc_handler_2597611336));
		}

		private static void __rpc_handler_2237745972(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_004a: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				ElevatorState newState = default(ElevatorState);
				((FastBufferReader)(ref reader)).ReadValueSafe<ElevatorState>(ref newState, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlayZoneElevator)(object)target).SwitchStateServerRpc(playerReference, newState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_732950694(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_004a: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				ElevatorState newState = default(ElevatorState);
				((FastBufferReader)(ref reader)).ReadValueSafe<ElevatorState>(ref newState, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayZoneElevator)(object)target).SwitchStateClientRpc(playerReference, newState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_228610214(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_004a: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				bool open = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref open, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlayZoneElevator)(object)target).ToggleDoorsServerRpc(playerReference, open);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2597611336(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_004a: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				bool open = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref open, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlayZoneElevator)(object)target).ToggleDoorsClientRpc(playerReference, open);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "PlayZoneElevator";
		}
	}
	public class TwinApparatus : LungProp
	{
		[CompilerGenerated]
		private sealed class <HandleDisconnect>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public bool bothPulled;

			public TwinApparatus <>4__this;

			private EnemyAINestSpawnObject[] <enemyNests>5__1;

			private int <i>5__2;

			object? IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object? IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <HandleDisconnect>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<enemyNests>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Expected O, but got Unknown
				//IL_021f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Expected O, but got Unknown
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected O, but got Unknown
				//IL_0176: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Expected O, but got Unknown
				//IL_032f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0345: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)<>4__this.apparatusAudio != (Object)null)
					{
						<>4__this.apparatusAudio.Stop();
						<>4__this.apparatusAudio.PlayOneShot(((LungProp)<>4__this).disconnectSFX, 0.7f);
					}
					<>4__this.onDisconnectEarly.Invoke(bothPulled);
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((LungProp)<>4__this).sparkParticle.SetActive(true);
					if ((Object)(object)<>4__this.apparatusAudio != (Object)null)
					{
						<>4__this.apparatusAudio.PlayOneShot(((LungProp)<>4__this).removeFromMachineSFX);
					}
					if (((NetworkBehaviour)<>4__this).IsHost && Random.Range(0, 100) < 70 && ((LungProp)<>4__this).roundManager.minEnemiesToSpawn < 2)
					{
						((LungProp)<>4__this).roundManager.minEnemiesToSpawn = ((!bothPulled) ? 1 : 2);
					}
					<>4__this.onDisconnect.Invoke(bothPulled);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					((LungProp)<>4__this).roundManager.FlickerLights(false, false);
					<>4__this.onLightsFlicker.Invoke(bothPulled);
					<>2__current = (object)new WaitForSeconds(2.5f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					((LungProp)<>4__this).roundManager.SwitchPower(false);
					((LungProp)<>4__this).roundManager.powerOffPermanently = bothPulled;
					<>4__this.onLightsOff.Invoke(bothPulled);
					<>2__current = (object)new WaitForSeconds(0.75f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					if (!bothPulled)
					{
						((LungProp)<>4__this).roundManager.SwitchPower(!bothPulled);
						<>4__this.DimLights();
						return false;
					}
					HUDManager.Instance.RadiationWarningHUD();
					<>4__this.onDisplayWarning.Invoke(bothPulled);
					if (bothPulled && ((NetworkBehaviour)<>4__this).IsHost && (Object)(object)((LungProp)<>4__this).radMechEnemyType != (Object)null)
					{
						<enemyNests>5__1 = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsSortMode)0);
						<i>5__2 = 0;
						while (<i>5__2 < <enemyNests>5__1.Length)
						{
							if ((Object)(object)<enemyNests>5__1[<i>5__2].enemyType == (Object)(object)((LungProp)<>4__this).radMechEnemyType)
							{
								((LungProp)<>4__this).roundManager.SpawnEnemyGameObject(((LungProp)<>4__this).roundManager.outsideAINodes[<i>5__2].transform.position, 0f, -1, ((LungProp)<>4__this).radMechEnemyType);
							}
							<i>5__2++;
						}
						<enemyNests>5__1 = null;
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("Twin Apparatus")]
		[Tooltip("")]
		public AudioSource? apparatusAudio;

		[Header("Events")]
		[Tooltip("")]
		public UnityEvent onActivate = new UnityEvent();

		[Tooltip("")]
		public UnityEvent<bool> onDisconnectEarly = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onDisconnect = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onLightsFlicker = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onLightsOff = new UnityEvent<bool>();

		[Tooltip("")]
		public UnityEvent<bool> onDisplayWarning = new UnityEvent<bool>();

		public TwinApparatus? LongLostTwin { get; private set; }

		public static BreakerBox? BreakerBoxInstance { get; private set; }

		public override void Start()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				Activate();
			}
			((LungProp)this).Start();
			if (FacilityMeltdownCompatibility.Enabled)
			{
				FacilityMeltdownCompatibility.HalveTwinValue(this);
				onDisconnectEarly.AddListener((UnityAction<bool>)FacilityMeltdownCompatibility.TwinMeltdown);
			}
			if (PizzaTowerEscapeMusicCompatibility.Enabled)
			{
				onDisconnectEarly.AddListener((UnityAction<bool>)delegate
				{
					PizzaTowerEscapeMusicCompatibility.SwitchTwin(LongLostTwin);
				});
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (!((NetworkBehaviour)this).IsHost)
			{
				Activate();
			}
		}

		public override void EquipItem()
		{
			if (base.isLungDocked)
			{
				base.isLungDocked = false;
				base.isLungPowered = false;
				if (base.disconnectAnimation != null)
				{
					((MonoBehaviour)this).StopCoroutine(base.disconnectAnimation);
				}
				bool flag = (Object)(object)LongLostTwin != (Object)null && !((LungProp)LongLostTwin).isLungDocked && !((LungProp)LongLostTwin).isLungPowered;
				base.disconnectAnimation = ((MonoBehaviour)this).StartCoroutine(HandleDisconnect(flag));
				if (flag)
				{
					if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow != (Object)null)
					{
						DungeonManager.CurrentExtendedDungeonFlow.DungeonEvents.onApparatusTaken.Invoke((LungProp)(object)this);
						DungeonManager.GlobalDungeonEvents.onApparatusTaken.Invoke((LungProp)(object)this);
					}
					if ((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null)
					{
						LevelManager.CurrentExtendedLevel.LevelEvents.onApparatusTaken.Invoke((LungProp)(object)this);
						LevelManager.GlobalLevelEvents.onApparatusTaken.Invoke((LungProp)(object)this);
					}
				}
			}
			((LungProp)this).EquipItem();
		}

		public void Activate()
		{
			if (!((GrabbableObject)this).isInShipRoom)
			{
				base.isLungDocked = true;
				base.isLungPowered = true;
				base.radMechEnemyType = ActivateApparatus.OldBirdEnemyType;
				if ((Object)(object)apparatusAudio != (Object)null)
				{
					apparatusAudio.loop = true;
					apparatusAudio.Play();
				}
				onActivate.Invoke();
			}
		}

		public void AssignTwin(GrabbableObject possibleTwin)
		{
			if ((Object)(object)LongLostTwin == (Object)null && possibleTwin is TwinApparatus twinApparatus)
			{
				LongLostTwin = twinApparatus;
				twinApparatus.LongLostTwin = this;
			}
		}

		public void DimLights()
		{
			for (int i = 0; i < base.roundManager.allPoweredLightsAnimators.Count; i++)
			{
				Animator val = base.roundManager.allPoweredLightsAnimators[i];
				val.SetBool("Dim", true);
			}
		}

		[IteratorStateMachine(typeof(<HandleDisconnect>d__21))]
		private IEnumerator HandleDisconnect(bool bothPulled)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HandleDisconnect>d__21(0)
			{
				<>4__this = this,
				bothPulled = bothPulled
			};
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "TwinApparatus";
		}
	}
}
namespace itolib.Patches
{
	[HarmonyPatch]
	internal sealed class LLLStoryLogPatch
	{
		public static Dictionary<int, TerminalNode?>? LLLStoryLogNodes { get; internal set; }

		[HarmonyPatch(typeof(TerminalManager), "CreateStoryLogTerminalData")]
		[HarmonyPostfix]
		internal static void CacheStoryLog(ExtendedStoryLog newStoryLog)
		{
			Dictionary<int, TerminalNode?>? lLLStoryLogNodes = LLLStoryLogNodes;
			if (lLLStoryLogNodes != null)
			{
				int newStoryLogID = newStoryLog.newStoryLogID;
				object value;
				if (!((Object)(object)Patches.Terminal != (Object)null))
				{
					value = null;
				}
				else
				{
					List<TerminalNode> logEntryFiles = Patches.Terminal.logEntryFiles;
					value = logEntryFiles[logEntryFiles.Count - 1];
				}
				lLLStoryLogNodes.Add(newStoryLogID, (TerminalNode)value);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyAfter(new string[] { "imabatby.lethallevelloader" })]
		[HarmonyPrefix]
		internal static void PopulateStoryLogs()
		{
			Dictionary<int, TerminalNode?>? lLLStoryLogNodes = LLLStoryLogNodes;
			if (lLLStoryLogNodes == null || lLLStoryLogNodes.Count <= 0 || !((Object)(object)Patches.Terminal != (Object)null))
			{
				return;
			}
			foreach (ExtendedMod extendedMod in PatchedContent.ExtendedMods)
			{
				if (extendedMod.ExtendedStoryLogs.Count <= 0)
				{
					continue;
				}
				foreach (ExtendedStoryLog extendedStoryLog in extendedMod.ExtendedStoryLogs)
				{
					if ((Object)(object)LLLStoryLogNodes?[extendedStoryLog.newStoryLogID] != (Object)null)
					{
						Patches.Terminal.logEntryFiles.Add(LLLStoryLogNodes[extendedStoryLog.newStoryLogID]);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal sealed class LoadPatch
	{
		public static bool FirstLoad { get; private set; } = true;


		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPrefix]
		private static void MenuManagerStartPre()
		{
			if (FirstLoad)
			{
				FirstLoad = false;
				if (CrowdControlCompatibility.Enabled)
				{
					Plugin.Harmony.PatchAll(typeof(CrowdControlCompatibility));
				}
			}
		}
	}
}
namespace itolib.Interfaces
{
	public interface IPooledObject
	{
		int ObjectID { get; set; }

		GameObject TakenBy { get; set; }

		IPooledObject NextPooledObject { get; set; }

		IPooledObject CreateInstance();

		bool TryAssignInstance(GameObject taker, int maxInstances, out IPooledObject pooledObject)
		{
			pooledObject = null;
			if ((Object)(object)TakenBy == (Object)null)
			{
				pooledObject = this;
			}
			else if (NextPooledObject == null && ObjectID < maxInstances)
			{
				NextPooledObject = CreateInstance();
				NextPooledObject.ObjectID = ObjectID + 1;
				pooledObject = NextPooledObject;
			}
			if (pooledObject != null)
			{
				pooledObject.TakenBy = taker;
				IPooledObject obj = pooledObject;
				MonoBehaviour val = (MonoBehaviour)((obj is MonoBehaviour) ? obj : null);
				if ((Object)(object)val != (Object)null && !((Behaviour)val).enabled)
				{
					((Behaviour)val).enabled = true;
				}
				return true;
			}
			return NextPooledObject?.TryAssignInstance(taker, maxInstances, out pooledObject) ?? false;
		}

		bool TryFreeInstance(GameObject possibleOwner, out IPooledObject pooledObject)
		{
			pooledObject = null;
			if (possibleOwner == TakenBy)
			{
				pooledObject = this;
				TakenBy = null;
				MonoBehaviour val = (MonoBehaviour)((this is MonoBehaviour) ? this : null);
				if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
				{
					((Behaviour)val).enabled = false;
				}
				return true;
			}
			return NextPooledObject?.TryFreeInstance(possibleOwner, out pooledObject) ?? false;
		}
	}
	public interface IScriptableConfigEntry<T>
	{
		string Section { get; set; }

		string Key { get; set; }

		T DefaultValue { get; set; }

		string Description { get; set; }
	}
}
namespace itolib.Extensions
{
	public static class PlayerExtensions
	{
		public static bool IsLocalClient(this PlayerControllerB player)
		{
			return player.actualClientId == GameNetworkManager.Instance.localPlayerController.actualClientId;
		}
	}
}
namespace itolib.Enums
{
	public enum ActivationTime
	{
		[Tooltip("")]
		Immediate = -1,
		[Tooltip("")]
		DungeonComplete,
		[Tooltip("")]
		ScrapSpawn,
		[Tooltip("")]
		HazardSpawn,
		[Tooltip("")]
		StartOfRound,
		[Tooltip("")]
		Manual
	}
	public enum ElevatorState
	{
		[Tooltip("")]
		IdleUp,
		[Tooltip("")]
		IdleDown,
		[Tooltip("")]
		GoingUp,
		[Tooltip("")]
		GoingDown,
		[Tooltip("")]
		Deactivated
	}
	public enum RotationSource
	{
		[Tooltip("")]
		Player,
		[Tooltip("")]
		Launcher,
		[Tooltip("")]
		Absolute
	}
	public enum WearablePosition
	{
		[Tooltip("")]
		Custom = -1,
		[Tooltip("")]
		Head,
		[Tooltip("")]
		Belt
	}
}
namespace itolib.Compatibility
{
	[HarmonyPatch]
	internal sealed class CrowdControlCompatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("WarpWorld.CrowdControl");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		public static LevelWeatherType CurrentWeather { get; internal set; }

		public static event Action<LevelWeatherType, LevelWeatherType>? OnCCWeatherChanged;

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		[HarmonyPatch(typeof(TestMod), "CrowdControlCommands")]
		[HarmonyPostfix]
		internal static void CCWeatherCheck()
		{
			//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_004c: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null && TimeOfDay.Instance.currentLevel.currentWeather != CurrentWeather)
			{
				CrowdControlCompatibility.OnCCWeatherChanged?.Invoke(CurrentWeather, TimeOfDay.Instance.currentLevel.currentWeather);
				CurrentWeather = TimeOfDay.Instance.currentLevel.currentWeather;
			}
		}
	}
	internal sealed class FacilityMeltdownCompatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("me.loaforc.facilitymeltdown");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void HalveTwinValue(TwinApparatus twinApparatus)
		{
			if (MeltdownPlugin.config.OverrideApparatusValue)
			{
				((GrabbableObject)twinApparatus).scrapValue = ((GrabbableObject)twinApparatus).scrapValue / 2;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void TwinMeltdown(bool bothPulled)
		{
			if (bothPulled && NetworkManager.Singleton.IsHost)
			{
				MeltdownAPI.StartMeltdown("pacoito.itolib");
			}
		}
	}
	internal sealed class PizzaTowerEscapeMusicCompatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("bgn.pizzatowerescapemusic");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SwitchTwin(TwinApparatus? twin)
		{
			if ((Object)(object)twin != (Object)null && ((LungProp)twin).isLungDocked)
			{
				GameEventListener.dockedApparatus = (LungProp)(object)twin;
			}
		}
	}
	[HarmonyPatch]
	internal sealed class TVLoaderCompatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("rattenbonkers.TVLoader");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void PrepareVideo(TVScript tv)
		{
			if ((Object)(object)TVScriptPatches.currentVideoPlayer == (Object)null)
			{
				TVScriptPatches.currentVideoPlayer = ((Component)tv).GetComponent<VideoPlayer>();
				TVScriptPatches.renderTexture = TVScriptPatches.currentVideoPlayer.targetTexture;
				if (VideoManager.Videos.Count > 0)
				{
					TVScriptPatches.PrepareVideo(tv, -1);
				}
			}
		}
	}
	[HarmonyPatch]
	internal sealed class WeatherRegistryCompatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _enabled.GetValueOrDefault();
				if (!_enabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("mrov.WeatherRegistry");
					_enabled = valueOrDefault;
				}
				return _enabled.Value;
			}
		}

		public static event Action<LevelWeatherType[]>? OnWeatherEffectsApply;

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		[HarmonyPatch(typeof(WeatherEffectData), "ApplyWeatherEffects")]
		[HarmonyPostfix]
		internal static void ApplyWeatherEffectsPost(LevelWeatherType[] weatherType)
		{
			WeatherRegistryCompatibility.OnWeatherEffectsApply?.Invoke(weatherType);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static bool ApplyWeatherOverrides(Action<LevelWeatherType[]> weatherAction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			if ((int)WeatherManager.GetCurrentLevelWeather().Type == 0)
			{
				return false;
			}
			OnWeatherEffectsApply += weatherAction;
			return true;
		}
	}
}
namespace itolib.Behaviours.Props
{
	public class ConnectorMerger : DetectRegion<ConnectorMerger>
	{
		[Header("Connector Merger")]
		[Tooltip("")]
		public float tolerance = 1f;

		[Tooltip("")]
		public bool moveToCenter = true;

		[Tooltip("")]
		public int priority = 1;

		[Tooltip("")]
		public string nameFilter = "";

		public int ConnectorsFound { get; private set; }

		public override void Reset()
		{
			//IL_0018: 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)
			maxObjects = 8;
			layerMask = LayerMask.op_Implicit(1 << LayerMask.NameToLayer("Room"));
		}

		public override void CheckObjectsInRegion()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				return;
			}
			base.CheckObjectsInRegion();
			ConnectorsFound = 0;
			ConnectorMerger connectorMerger = default(ConnectorMerger);
			for (int i = 0; i < base.ObjectsFound; i++)
			{
				if (((Component)base.OverlapBuffer[i]).TryGetComponent<ConnectorMerger>(ref connectorMerger) && !((Object)(object)connectorMerger == (Object)(object)this) && (nameFilter.Length <= 0 || string.CompareOrdinal(nameFilter, connectorMerger.nameFilter) == 0))
				{
					if (priority < connectorMerger.priority)
					{
						return;
					}
					Vector3 val = ((Component)this).transform.position - ((Component)connectorMerger).transform.position;
					float magnitude = ((Vector3)(ref val)).magnitude;
					if (magnitude < tolerance)
					{
						onObjectsEach.Invoke(connectorMerger);
						ConnectorsFound++;
					}
				}
			}
			if (ConnectorsFound > 0)
			{
				onObjectsAny.Invoke(ConnectorsFound);
			}
		}

		public void DisableOtherConnector(ConnectorMerger connector)
		{
			//IL_0012: 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_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_0033: Unknown result type (might be due to invalid IL or missing references)
			if (moveToCenter)
			{
				Vector3 position = Vector3.Lerp(((Component)this).transform.position, ((Component)connector).transform.position, 0.5f);
				((Component)this).transform.position = position;
			}
			((Component)connector).gameObject.SetActive(false);
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ConnectorMerger";
		}
	}
	public class DungeonStoryLog : StoryLog
	{
		public UnityEvent<int> onLogSpawned = new UnityEvent<int>();

		public UnityEvent<int> onAlreadyUnlocked = new UnityEvent<int>();

		public void Start()
		{
			if ((Object)(object)DungeonManager.CurrentExtendedDungeonFlow == (Object)null)
			{
				return;
			}
			foreach (ExtendedStoryLog extendedStoryLog in ((ExtendedContent)DungeonManager.CurrentExtendedDungeonFlow).ExtendedMod.ExtendedStoryLogs)
			{
				if (string.CompareOrdinal(extendedStoryLog.sceneName, DungeonManager.CurrentExtendedDungeonFlow.DungeonName) == 0 && base.storyLogID == extendedStoryLog.storyLogID)
				{
					if (!TerminalManager.Terminal.unlockedStoryLogs.Contains(extendedStoryLog.newStoryLogID))
					{
						onLogSpawned.Invoke(extendedStoryLog.newStoryLogID);
						base.storyLogID = extendedStoryLog.newStoryLogID;
					}
					else
					{
						onAlreadyUnlocked.Invoke(extendedStoryLog.newStoryLogID);
						((StoryLog)this).RemoveLogCollectible();
					}
					break;
				}
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "DungeonStoryLog";
		}
	}
	public class DungeonTelevision : TVScript
	{
		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private static UnlockableItem? <TelevisionUnlockableItem>k__BackingField;

		[Header("Dungeon Television")]
		[Tooltip("")]
		public InteractTrigger? tvTrigger;

		[Tooltip("")]
		public bool startDeactivated;

		public static UnlockableItem? TelevisionUnlockableItem
		{
			get
			{
				if (<TelevisionUnlockableItem>k__BackingField == null && (Object)(object)StartOfRound.Instance != (Object)null)
				{
					<TelevisionUnlockableItem>k__BackingField = StartOfRound.Instance.unlockablesList.unlockables.Find((UnlockableItem unlockable) => string.CompareOrdinal(unlockable.unlockableName, "Television") == 0);
				}
				return <TelevisionUnlockableItem>k__BackingField;
			}
			[CompilerGenerated]
			private set
			{
				<TelevisionUnlockableItem>k__BackingField = value;
			}
		}

		public void Awake()
		{
			if (TelevisionUnlockableItem == null)
			{
				return;
			}
			Transform val = TelevisionUnlockableItem.prefabObject.transform.Find("TVScript");
			TVScript val2 = default(TVScript);
			VideoPlayer val3 = default(VideoPlayer);
			if (((Component)val).TryGetComponent<TVScript>(ref val2) && ((Component)val2).TryGetComponent<VideoPlayer>(ref val3))
			{
				base.tvClips = val2.tvClips;
				base.tvAudioClips = val2.tvAudioClips;
				base.tvOnMaterial = val2.tvOnMaterial;
				base.tvOffMaterial = val2.tvOffMaterial;
				base.switchTVOn = val2.switchTVOn;
				base.switchTVOff = val2.switchTVOff;
				((Renderer)base.tvMesh).sharedMaterials = ((Renderer)val2.tvMesh).sharedMaterials;
				VideoPlayer val4 = default(VideoPlayer);
				if (((Component)this).TryGetComponent<VideoPlayer>(ref val4))
				{
					val4.clip = base.tvClips[0];
					val4.targetTexture = val3.targetTexture;
				}
			}
			if (!startDeactivated)
			{
				if (!TVLoaderCompatibility.Enabled)
				{
					return;
				}
				UnlockableItem? televisionUnlockableItem = TelevisionUnlockableItem;
				if (televisionUnlockableItem == null || !televisionUnlockableItem.alreadyUnlocked)
				{
					UnlockableItem? televisionUnlockableItem2 = TelevisionUnlockableItem;
					if (televisionUnlockableItem2 == null || !televisionUnlockableItem2.hasBeenUnlockedByPlayer)
					{
						return;
					}
				}
			}
			if ((Object)(object)tvTrigger != (Object)null)
			{
				tvTrigger.interactable = false;
			}
			((Behaviour)this).enabled = false;
		}

		public void OnEnable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			base.video.loopPointReached += new EventHandler(TVFinishedClip);
		}

		public void OnDisable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			base.video.loopPointReached -= new EventHandler(TVFinishedClip);
		}

		public void TVFinishedClip(VideoPlayer source)
		{
			if (base.tvOn && GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				base.currentClip = (base.currentClip + 1) % base.tvClips.Length;
				base.video.clip = base.tvClips[base.currentClip];
				base.video.Play();
				base.tvSFX.clip = base.tvAudioClips[base.currentClip];
				base.tvSFX.time = 0f;
				base.tvSFX.Play();
			}
		}

		public void Update()
		{
			if (NetworkManager.Singleton.ShutdownInProgress || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			if (TVLoaderCompatibility.Enabled)
			{
				TVLoaderCompatibility.PrepareVideo((TVScript)(object)this);
			}
			else if (!base.tvOn || !GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				if (base.wasTvOnLastFrame)
				{
					base.wasTvOnLastFrame = false;
					((TVScript)this).SetTVScreenMaterial(false);
					base.currentClipTime = (float)base.video.time;
					base.video.Stop();
				}
				if (((NetworkBehaviour)this).IsHost && !base.tvOn)
				{
					base.timeSinceTurningOffTV += Time.deltaTime;
				}
				base.currentClipTime += Time.deltaTime;
				if ((double)base.currentClipTime > base.tvClips[base.currentClip].length)
				{
					base.currentClip = (base.currentClip + 1) % base.tvClips.Length;
					base.currentClipTime = 0f;
					if (base.tvOn)
					{
						base.tvSFX.clip = base.tvAudioClips[base.currentClip];
						base.tvSFX.Play();
					}
				}
			}
			else
			{
				if (!base.wasTvOnLastFrame)
				{
					base.wasTvOnLastFrame = true;
					((TVScript)this).SetTVScreenMaterial(true);
					base.video.clip = base.tvClips[base.currentClip];
					base.video.time = base.currentClipTime;
					base.video.Play();
				}
				base.currentClipTime = (float)base.video.time;
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "DungeonTelevision";
		}
	}
	[Serializable]
	public struct HazardReplacement
	{
		[Tooltip("")]
		public string originalHazard;

		[Tooltip("")]
		public string replacingHazard;
	}
	public class HazardReplacer : MonoBehaviour, IDungeonCompleteReceiver
	{
		public List<HazardReplacement> hazardReplacements = new List<HazardReplacement>();

		public void OnDungeonComplete(Dungeon dungeon)
		{
			if (!NetworkManager.Singleton.IsHost)
			{
				return;
			}
			SelectableLevel val = (((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) ? LevelManager.CurrentExtendedLevel.SelectableLevel : null);
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			if ((Object)(object)val == (Object)null || (Object)(object)currentExtendedDungeonFlow == (Object)null)
			{
				return;
			}
			string[] array = new string[val.spawnableMapObjects.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = ((Object)val.spawnableMapObjects[i].prefabToSpawn).name;
			}
			string[] array2 = new string[currentExtendedDungeonFlow.SpawnableMapObjects.Count];
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j] = ((Object)currentExtendedDungeonFlow.SpawnableMapObjects[j].prefabToSpawn).name;
			}
			int count = hazardReplacements.Count;
			for (int k = 0; k < count; k++)
			{
				SpawnableMapObject val2 = null;
				for (int l = 0; l < array.Length; l++)
				{
					if (string.CompareOrdinal(hazardReplacements[k].originalHazard, array[l]) == 0)
					{
						val2 = val.spawnableMapObjects[l];
						break;
					}
				}
				if (val2 == null)
				{
					Plugin.StaticLogger.LogWarning((object)("Could not find hazard '" + hazardReplacements[k].originalHazard + "' in the moon's SpawnableMapObject list; its spawn rates will not be modified."));
					continue;
				}
				SpawnableMapObject val3 = null;
				for (int m = 0; m < array2.Length; m++)
				{
					if (string.CompareOrdinal(hazardReplacements[k].replacingHazard, array2[m]) == 0)
					{
						val3 = currentExtendedDungeonFlow.SpawnableMapObjects[m];
						break;
					}
				}
				if (val3 == null)
				{
					Plugin.StaticLogger.LogWarning((object)("Could not find hazard '" + hazardReplacements[k].replacingHazard + "' in the dungeon's SpawnableMapObject list; its spawn rates will not be modified."));
				}
				else
				{
					val3.numberToSpawn = val2.numberToSpawn;
				}
			}
		}
	}
	public class PrefabSpawner : NetworkedSpawner<NetworkObject>
	{
		[Header("Prefab Spawner")]
		[Tooltip("")]
		public NetworkObject? prefabToSpawn;

		[Tooltip("")]
		public Transform? parentTransform;

		public override NetworkObject? GetPrefabToSpawn()
		{
			return prefabToSpawn;
		}

		public override void PerformSpawn()
		{
			if (!NetworkManager.Singleton.IsHost || (Object)(object)base.PrefabToSpawn == (Object)null)
			{
				return;
			}
			if (spawnLocations.Count == 0)
			{
				SpawnPrefab(((Component)this).transform);
			}
			else
			{
				for (int i = 0; i < spawnLocations.Count; i++)
				{
					SpawnPrefab(spawnLocations[i]);
				}
			}
			base.PerformSpawn();
		}

		private void SpawnPrefab(Transform spawnLocation)
		{
			//IL_0036: 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)
			if (!((Object)(object)base.PrefabToSpawn == (Object)null) && ((Component)spawnLocation).gameObject.activeInHierarchy)
			{
				GameObject val = Object.Instantiate<GameObject>(((Component)base.PrefabToSpawn).gameObject, spawnLocation.position, spawnLocation.rotation, ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null) ? RoundManager.Instance.mapPropsContainer.transform : null);
				if ((Object)(object)parentTransform != (Object)null)
				{
					val.transform.SetParent(parentTransform);
				}
				base.PrefabInstances.Add(val.GetComponent<NetworkObject>());
			}
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "PrefabSpawner";
		}
	}
	public class ScrapInjector : MonoBehaviour, IDungeonCompleteReceiver
	{
		public SelectableLevel? CurrentLevel { get; private set; }

		public List<SpawnableItemWithRarity>? ModifiedRarities { get; private set; }

		public void OnDungeonComplete(Dungeon dungeon)
		{
			if (!NetworkManager.Singleton.IsHost || !((Behaviour)this).enabled)
			{
				return;
			}
			CurrentLevel = (((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) ? LevelManager.CurrentExtendedLevel.SelectableLevel : null);
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			if ((Object)(object)CurrentLevel == (Object)null || (Object)(object)currentExtendedDungeonFlow == (Object)null)
			{
				return;
			}
			int count = CurrentLevel.spawnableScrap.Count;
			ModifiedRarities = new List<SpawnableItemWithRarity>(((ExtendedContent)currentExtendedDungeonFlow).ExtendedMod.ExtendedItems.Count);
			foreach (ExtendedItem extendedItem in ((ExtendedContent)currentExtendedDungeonFlow).ExtendedMod.ExtendedItems)
			{
				if (!extendedItem.Item.isScrap)
				{
					continue;
				}
				int dynamicRarity = extendedItem.DungeonMatchingProperties.GetDynamicRarity(currentExtendedDungeonFlow);
				if (dynamicRarity <= 0)
				{
					continue;
				}
				for (int i = 0; i < count; i++)
				{
					SpawnableItemWithRarity val = CurrentLevel.spawnableScrap[i];
					if ((Object)(object)val.spawnableItem == (Object)(object)extendedItem.Item && val.rarity < 1)
					{
						val.rarity = dynamicRarity;
						ModifiedRarities.Add(val);
						break;
					}
				}
			}
		}

		public void OnDestroy()
		{
			if (!((Object)(object)CurrentLevel == (Object)null) && ModifiedRarities != null)
			{
				int count = ModifiedRarities.Count;
				for (int i = 0; i < count; i++)
				{
					ModifiedRarities[i].rarity = 0;
				}
			}
		}
	}
	[Serializable]
	public struct SyncedItem : INetworkSerializable
	{
		public Vector3 position;

		public Quaternion rotation;

		public int meshVariant;

		public int materialVariant;

		public int scrapValue;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0027: 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_003e: 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_0055: 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)
			serializer.SerializeValue(ref position);
			serializer.SerializeValue(ref rotation);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref scrapValue, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref meshVariant, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref materialVariant, default(ForPrimitives));
		}
	}
	public class ScrapSpawner : NetworkedSpawner<GrabbableObject>
	{
		[CompilerGenerated]
		private sealed class <SyncItemValuesOnSpawn>d__24 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkBehaviourReference itemReference;

			public SyncedItem syncedItem;

			public ScrapSpawner <>4__this;

			private GrabbableObject <item>5__1;

			private float <startTime>5__2;

			private MeshFilter <itemFilter>5__3;

			private MeshRenderer <itemRenderer>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SyncItemValuesOnSpawn>d__24(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<item>5__1 = null;
				<itemFilter>5__3 = null;
				<itemRenderer>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Expected O, but got Unknown
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				//IL_0210: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startTime>5__2 = Time.realtimeSinceStartup;
					goto IL_005a;
				case 1:
					<>1__state = -1;
					goto IL_005a;
				case 2:
					{
						<>1__state = -1;
						if ((Object)(object)<item>5__1 == (Object)null)
						{
							return false;
						}
						<item>5__1.fallTime = 1f;
						<item>5__1.hasHitGround = true;
						<item>5__1.reachedFloorTarget = true;
						((Component)<item>5__1).transform.SetPositionAndRotation(syncedItem.position, syncedItem.rotation);
						<item>5__1.startFallingPosition = syncedItem.position;
						<item>5__1.targetFloorPosition = syncedItem.position;
						<item>5__1.SetScrapValue(syncedItem.scrapValue);
						if (syncedItem.meshVariant != -1 && ((Component)<item>5__1).TryGetComponent<MeshFilter>(ref <itemFilter>5__3))
						{
							<itemFilter>5__3.mesh = <item>5__1.itemProperties.meshVariants[syncedItem.meshVariant];
						}
						if (syncedItem.materialVariant != -1 && ((Component)<item>5__1).TryGetComponent<MeshRenderer>(ref <itemRenderer>5__4))
						{
							((Renderer)<itemRenderer>5__4).sharedMaterial = <item>5__1.itemProperties.materialVariants[syncedItem.materialVariant];
						}
						if (<>4__this.fallToGround)
						{
							<item>5__1.FallToGround(<>4__this.randomizePosition, true, default(Vector3));
						}
						return false;
					}
					IL_005a:
					if (!((NetworkBehaviourReference)(ref itemReference)).TryGet<GrabbableObject>(ref <item>5__1, (NetworkManager)null) && Time.realtimeSinceStartup - <startTime>5__2 < 8f)
					{
						<>2__current = (object)new WaitForSeconds(0.03f);
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("Item Spawner")]
		[Tooltip("")]
		public Item? itemToSpawn;

		[Tooltip("")]
		public int overrideMinValue = -1;

		[Tooltip("")]
		public int overrideMaxValue = -1;

		[Tooltip("")]
		public bool applyScrapMultiplier = true;

		[Tooltip("")]
		public bool allowMeshVariants = true;

		[Tooltip("")]
		public bool allowMaterialVariants = true;

		[Tooltip("")]
		public bool fallToGround = true;

		[Tooltip("")]
		public bool randomizePosition = false;

		[Tooltip("")]
		public bool skipInactive = true;

		public static Random Random { get; private set; }

		public List<SyncedItem> ItemsToSync { get; private set; } = new List<SyncedItem>();


		public override NetworkObject? GetPrefabToSpawn()
		{
			if ((Object)(object)base.PrefabToSpawn != (Object)null)
			{
				return base.PrefabToSpawn;
			}
			if ((Object)(object)itemToSpawn == (Object)null)
			{
				return null;
			}
			NetworkObject result = default(NetworkObject);
			if ((Object)(object)itemToSpawn.spawnPrefab != (Object)null && itemToSpawn.spawnPrefab.TryGetComponent<NetworkObject>(ref result))
			{
				return result;
			}
			Item val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => string.CompareOrdinal(((Object)item).name, ((Object)itemToSpawn).name) == 0) : null);
			NetworkObject val2 = default(NetworkObject);
			return ((Object)(object)val != (Object)null && (Object)(object)val.spawnPrefab != (Object)null && val.spawnPrefab.TryGetComponent<NetworkObject>(ref val2)) ? val2 : null;
		}

		public override void PerformSpawn()
		{
			if (!((NetworkBehaviour)this).IsHost || (Object)(object)base.PrefabToSpawn == (Object)null)
			{
				return;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				if (Random == null)
				{
					Random = new Random(StartOfRound.Instance.randomMapSeed + 44);
				}
			}
			else if (Random == null)
			{
				Random = new Random();
			}
			if (spawnLocations.Count == 0)
			{
				SpawnItem(((Component)this).transform);
			}
			else
			{
				for (int i = 0; i < spawnLocations.Count; i++)
				{
					SpawnItem(spawnLocations[i]);
				}
			}
			base.PerformSpawn();
			if (activationTime != ActivationTime.ScrapSpawn)
			{
				SyncAllItemValuesServerRpc();
			}
		}

		private void SpawnItem(Transform spawnLocation)
		{
			//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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.PrefabToSpawn == (Object)null || (skipInactive && !((Component)spawnLocation).gameObject.activeInHierarchy))
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)base.PrefabToSpawn).gameObject, spawnLocation.position, Quaternion.identity, ((Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.spawnedScrapContainer : null);
			GrabbableObject val2 = default(GrabbableObject);
			if (val.TryGetComponent<GrabbableObject>(ref val2) && (Object)(object)val2.itemProperties != (Object)null)
			{
				int num = Random.Next((overrideMinValue < 0) ? val2.itemProperties.minValue : overrideMinValue, (overrideMaxValue < 0) ? val2.itemProperties.maxValue : overrideMaxValue);
				if (applyScrapMultiplier && (Object)(object)RoundManager.Instance != (Object)null)
				{
					num = (int)((float)num * RoundManager.Instance.scrapValueMultiplier);
				}
				SyncedItem syncedItem = default(SyncedItem);
				syncedItem.position = spawnLocation.position;
				syncedItem.rotation = spawnLocation.rotation * Quaternion.Euler(val2.itemProperties.restingRotation);
				syncedItem.meshVariant = ((allowMeshVariants && val2.itemProperties.meshVariants.Length != 0) ? Random.Next(0, val2.itemProperties.meshVariants.Length) : (-1));
				syncedItem.materialVariant = ((allowMaterialVariants && val2.itemProperties.materialVariants.Length != 0) ? Random.Next(0, val2.itemProperties.materialVariants.Length) : (-1));
				syncedItem.scrapValue = num;
				SyncedItem item = syncedItem;
				base.PrefabInstances.Add(val2);
				ItemsToSync.Add(item);
			}
		}

		public override void Start()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			base.Start();
			if (NetworkManager.Singleton.IsHost)
			{
				ActivationTime activationTime = base.activationTime;
				bool flag = (uint)(activationTime - 1) <= 1u;
				if (flag && (Object)(object)StartOfRound.Instance != (Object)null)
				{
					((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).AddListener(new UnityAction(SyncAllItemValuesServerRpc));
				}
			}
		}

		public override void OnDestroy()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			Random = null;
			ActivationTime activationTime = base.activationTime;
			bool flag = (uint)(activationTime - 1) <= 1u;
			if (flag && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).RemoveListener(new UnityAction(SyncAllItemValuesServerRpc));
			}
			base.OnDestroy();
		}

		[ServerRpc]
		public void SyncAllItemValuesServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_012b: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(202319458u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 202319458u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			for (int i = 0; i < base.PrefabInstances.Count; i++)
			{
				if ((Object)(object)base.PrefabInstances[i] != (Object)null)
				{
					SyncItemValuesClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)base.PrefabInstances[i]), ItemsToSync[i]);
				}
			}
		}

		[ClientRpc]
		public void SyncItemValuesClientRpc(NetworkBehaviourReference itemReference, SyncedItem syncedItem)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1620779007u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<SyncedItem>(ref syncedItem, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1620779007u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(SyncItemValuesOnSpawn(itemReference, syncedItem));
				}
			}
		}

		[IteratorStateMachine(typeof(<SyncItemValuesOnSpawn>d__24))]
		private IEnumerator SyncItemValuesOnSpawn(NetworkBehaviourReference itemReference, SyncedItem syncedItem)
		{
			//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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SyncItemValuesOnSpawn>d__24(0)
			{
				<>4__this = this,
				itemReference = itemReference,
				syncedItem = syncedItem
			};
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ScrapSpawner()
		{
			//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(202319458u, new RpcReceiveHandler(__rpc_handler_202319458));
			NetworkManager.__rpc_func_table.Add(1620779007u, new RpcReceiveHandler(__rpc_handler_1620779007));
		}

		private static void __rpc_handler_202319458(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_008c: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScrapSpawner)(object)target).SyncAllItemValuesServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1620779007(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_004a: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference itemReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable));
				SyncedItem syncedItem = default(SyncedItem);
				((FastBufferReader)(ref reader)).ReadValueSafe<SyncedItem>(ref syncedItem, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScrapSpawner)(object)target).SyncItemValuesClientRpc(itemReference, syncedItem);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ScrapSpawner";
		}
	}
	[Serializable]
	public struct TeleportData : INetworkSerializable
	{
		public Vector3 position;

		public Quaternion rotation;

		public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			serializer.SerializeValue(ref position);
			serializer.SerializeValue(ref rotation);
		}
	}
	public class ScrapTeleporter : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <TeleportScrapDelayed>d__23 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkBehaviourReference itemReference;

			public TeleportData teleport;

			public ScrapTeleporter <>4__this;

			private GrabbableObject <item>5__1;

			private float <startTime>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TeleportScrapDelayed>d__23(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<item>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: 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_0049: Expected O, but got Unknown
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startTime>5__2 = Time.realtimeSinceStartup;
					goto IL_005a;
				case 1:
					<>1__state = -1;
					goto IL_005a;
				case 2:
					{
						<>1__state = -1;
						if ((Object)(object)<item>5__1 == (Object)null)
						{
							return false;
						}
						<item>5__1.fallTime = 1f;
						<item>5__1.hasHitGround = true;
						<item>5__1.reachedFloorTarget = true;
						((Component)<item>5__1).transform.SetPositionAndRotation(teleport.position, teleport.rotation);
						<item>5__1.startFallingPosition = teleport.position;
						<item>5__1.targetFloorPosition = teleport.position;
						if (<>4__this.fallToGround)
						{
							<item>5__1.FallToGround(<>4__this.randomizePosition, false, default(Vector3));
						}
						return false;
					}
					IL_005a:
					if (!((NetworkBehaviourReference)(ref itemReference)).TryGet<GrabbableObject>(ref <item>5__1, (NetworkManager)null) && Time.realtimeSinceStartup - <startTime>5__2 < 8f)
					{
						<>2__current = (object)new WaitForSeconds(0.03f);
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("Scrap Teleporter")]
		[Tooltip("")]
		public List<string>? specificItems;

		[Tooltip("")]
		public List<Transform>? teleportPoints;

		[Tooltip("")]
		public List<BoxCollider>? teleportAreas;

		[Tooltip("")]
		[Min(0f)]
		public int minAmount = 0;

		[Tooltip("")]
		[Min(0f)]
		public int maxAmount = 1;

		[Tooltip("")]
		public bool fallToGround = true;

		[Tooltip("")]
		public bool randomizePosition = false;

		[Tooltip("")]
		public bool exhaustivePoints = false;

		[Tooltip("")]
		public bool exhaustiveAreas = false;

		[Tooltip("")]
		public ActivationTime activationTime = ActivationTime.StartOfRound;

		public static Random Random { get; internal set; }

		public static List<GrabbableObject>? AvailableScrap { get; private set; }

		public override void OnNetworkSpawn()
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (!((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			if (Random == null)
			{
				Random = new Random(StartOfRound.Instance.randomMapSeed + 55);
			}
			DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects.AddListener((ParameterEvent<List<GrabbableObject>>)ObtainSpawnedScrap);
			switch (activationTime)
			{
			case ActivationTime.ScrapSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects).AddListener((Action)TeleportScrap);
				break;
			case ActivationTime.HazardSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects).AddListener((Action)TeleportScrap);
				break;
			case ActivationTime.StartOfRound:
				if ((Object)(object)StartOfRound.Instance != (Object)null)
				{
					((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).AddListener(new UnityAction(TeleportScrap));
				}
				break;
			case ActivationTime.Immediate:
			case ActivationTime.DungeonComplete:
			case ActivationTime.Manual:
				break;
			}
		}

		public override void OnDestroy()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			AvailableScrap = null;
			Random = null;
			DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects.RemoveListener((ParameterEvent<List<GrabbableObject>>)ObtainSpawnedScrap);
			switch (activationTime)
			{
			case ActivationTime.ScrapSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects).RemoveListener((Action)TeleportScrap);
				break;
			case ActivationTime.HazardSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects).RemoveListener((Action)TeleportScrap);
				break;
			case ActivationTime.StartOfRound:
				if ((Object)(object)StartOfRound.Instance != (Object)null)
				{
					((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).RemoveListener(new UnityAction(TeleportScrap));
				}
				break;
			}
			((NetworkBehaviour)this).OnDestroy();
		}

		public void ObtainSpawnedScrap(List<GrabbableObject> spawnedScrap)
		{
			if (!((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			List<GrabbableObject>? availableScrap = AvailableScrap;
			if (availableScrap == null || availableScrap.Count <= 0)
			{
				if (AvailableScrap == null)
				{
					AvailableScrap = spawnedScrap.ToList();
				}
				NavMeshAgent val = default(NavMeshAgent);
				AvailableScrap.RemoveAll((GrabbableObject item) => (Object)(object)item == (Object)null || item.isInShipRoom || item.isInElevator || (Object)(object)item.itemProperties == (Object)null || !item.itemProperties.isScrap || item is LungProp || ((Component)item).TryGetComponent<NavMeshAgent>(ref val));
			}
		}

		public void TeleportScrap()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsHost || AvailableScrap == null || AvailableScrap.Count == 0)
			{
				return;
			}
			int num = Random.Next(minAmount, maxAmount + 1);
			Vector3 position = default(Vector3);
			Quaternion rotation = default(Quaternion);
			Vector3 val3 = default(Vector3);
			for (int j = 0; j < num; j++)
			{
				((Component)this).transform.GetPositionAndRotation(ref position, ref rotation);
				List<Transform>? list = teleportPoints;
				if (list != null && list.Count > 0)
				{
					int index = Random.Next(0, teleportPoints.Count);
					if ((Object)(object)teleportPoints[index] != (Object)null)
					{
						teleportPoints[index].GetPositionAndRotation(ref position, ref rotation);
					}
					if (exhaustivePoints)
					{
						teleportPoints.RemoveAt(index);
					}
				}
				else
				{
					List<BoxCollider>? list2 = teleportAreas;
					if (list2 != null && list2.Count > 0)
					{
						int index2 = Random.Next(0, teleportAreas.Count);
						BoxCollider val = teleportAreas[index2];
						Vector3 val2 = val.size / 2f;
						((Vector3)(ref val3))..ctor((float)Random.NextDouble() * 2f * val2.x - val2.x, (float)Random.NextDouble() * 2f * val2.y - val2.y, (float)Random.NextDouble() * 2f * val2.z - val2.z);
						position = ((Component)val).transform.TransformPoint(val3 + val.center);
						if (exhaustiveAreas)
						{
							teleportAreas.RemoveAt(index2);
						}
					}
				}
				List<string>? list3 = specificItems;
				if (list3 != null && list3.Count > 0)
				{
					int i;
					for (i = 0; i < AvailableScrap.Count; i++)
					{
						if (!((Object)(object)AvailableScrap[i] == (Object)null) && !((Object)(object)AvailableScrap[i].itemProperties == (Object)null) && specificItems.FindIndex((string specificItem) => string.CompareOrdinal(AvailableScrap[i].itemProperties.itemName, specificItem) == 0) >= 0)
						{
							TeleportData teleportData = default(TeleportData);
							teleportData.position = position;
							teleportData.rotation = rotation;
							TeleportData teleport = teleportData;
							TeleportScrapClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)AvailableScrap[i]), teleport);
							AvailableScrap.RemoveAt(i);
							break;
						}
					}
				}
				else
				{
					int index3 = Random.Next(0, AvailableScrap.Count);
					GrabbableObject val4 = AvailableScrap[index3];
					if ((Object)(object)val4 == (Object)null)
					{
						break;
					}
					TeleportData teleportData = default(TeleportData);
					teleportData.position = position;
					teleportData.rotation = ((Component)val4).transform.rotation;
					TeleportData teleport2 = teleportData;
					TeleportScrapClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val4), teleport2);
					AvailableScrap.RemoveAt(index3);
				}
			}
		}

		[ClientRpc]
		public void TeleportScrapClientRpc(NetworkBehaviourReference itemReference, TeleportData teleport)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			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(1529903710u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe<TeleportData>(ref teleport, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1529903710u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(TeleportScrapDelayed(itemReference, teleport));
				}
			}
		}

		[IteratorStateMachine(typeof(<TeleportScrapDelayed>d__23))]
		private IEnumerator TeleportScrapDelayed(NetworkBehaviourReference itemReference, TeleportData teleport)
		{
			//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)