Decompiled source of itolib v0.3.2

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 BagConfig;
using BagConfig.Patches;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using FacilityMeltdown;
using FacilityMeltdown.API;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyTestMod;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using PizzaTowerEscapeMusic;
using Steamworks;
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("BagConfig")]
[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.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1+83b4089a5699b25d599278fd931ca4bc0e151257")]
[assembly: AssemblyProduct("itolib")]
[assembly: AssemblyTitle("itolib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.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.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("pacoito.itolib", "itolib", "0.3.2")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "pacoito.itolib";

		public const string PLUGIN_NAME = "itolib";

		public const string VERSION = "0.3.2";

		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(DoorwayPatch));
				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.3.2 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 string Description { get; set; }

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

		public BoolEntry()
		{
			Section = string.Empty;
			Key = string.Empty;
			Description = string.Empty;
			DefaultValue = false;
		}
	}
	[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("")]
		[SerializeField]
		private Animator? elevatorAnimator;

		[Tooltip("")]
		[SerializeField]
		private Animator? doorAnimatorUpper;

		[Tooltip("")]
		[SerializeField]
		private Animator? doorAnimatorLower;

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

		[Tooltip("")]
		[SerializeField]
		private InteractTrigger? callElevatorLower;

		[Tooltip("")]
		[SerializeField]
		private InteractTrigger? openDoors;

		[Tooltip("")]
		[SerializeField]
		private InteractTrigger? closeDoors;

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

		[Tooltip("")]
		[SerializeField]
		private AudioSource? doorSourceUpper;

		[Tooltip("")]
		[SerializeField]
		private AudioSource? doorSourceLower;

		[Tooltip("")]
		[SerializeField]
		private AudioClip? elevatorAudioTravel;

		[Tooltip("")]
		[SerializeField]
		private AudioClip? elevatorAudioFinish;

		[Tooltip("")]
		[SerializeField]
		private AudioClip? doorAudioOpen;

		[Tooltip("")]
		[SerializeField]
		private AudioClip? doorAudioClose;

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

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

		[Tooltip("")]
		[SerializeField]
		private UnityEvent onTopReached = new UnityEvent();

		[Tooltip("")]
		[SerializeField]
		private UnityEvent onBottomReached = new UnityEvent();

		[Tooltip("")]
		[SerializeField]
		private UnityEvent onDeactivate = new UnityEvent();

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

		[Tooltip("")]
		[SerializeField]
		private 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)]
		private 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]
		private 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)]
		private 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]
		private 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 : EventfulApparatus
	{
		[CompilerGenerated]
		private sealed class <HandleDisconnect>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			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__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bd: Expected O, but got Unknown
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_021b: Expected O, but got Unknown
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Expected O, but got Unknown
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0179: Expected O, but got Unknown
				//IL_032a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: 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();
					<>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 = ((!<>4__this.bothPulled) ? 1 : 2);
					}
					<>4__this.OnDisconnect.Invoke();
					<>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();
					<>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 = <>4__this.bothPulled;
					<>4__this.OnLightsOff.Invoke();
					<>2__current = (object)new WaitForSeconds(0.75f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					if (!<>4__this.bothPulled)
					{
						((LungProp)<>4__this).roundManager.SwitchPower(!<>4__this.bothPulled);
						<>4__this.DimLights();
						return false;
					}
					HUDManager.Instance.RadiationWarningHUD();
					<>4__this.OnDisplayWarning.Invoke();
					if (<>4__this.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();
			}
		}

		private bool bothPulled;

		public TwinApparatus? LongLostTwin { get; private set; }

		protected override void HandleCompatibility()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (FacilityMeltdownCompatibility.Enabled)
			{
				FacilityMeltdownCompatibility.HalveTwinValue(this);
				base.OnDisconnectEarly.AddListener((UnityAction)delegate
				{
					if (bothPulled)
					{
						FacilityMeltdownCompatibility.InitiateMeltdown();
					}
				});
			}
			if (PizzaTowerEscapeMusicCompatibility.Enabled)
			{
				base.OnDisconnectEarly.AddListener((UnityAction)delegate
				{
					PizzaTowerEscapeMusicCompatibility.SwitchTwin(LongLostTwin);
				});
			}
		}

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

		public override void EquipItem()
		{
			if (((LungProp)this).isLungDocked)
			{
				((LungProp)this).isLungDocked = false;
				((LungProp)this).isLungPowered = false;
				if (((LungProp)this).disconnectAnimation != null)
				{
					((MonoBehaviour)this).StopCoroutine(((LungProp)this).disconnectAnimation);
				}
				bothPulled = (Object)(object)LongLostTwin != (Object)null && !((LungProp)LongLostTwin).isLungDocked && !((LungProp)LongLostTwin).isLungPowered;
				((LungProp)this).disconnectAnimation = ((MonoBehaviour)this).StartCoroutine(HandleDisconnect());
				if (bothPulled)
				{
					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);
					}
				}
			}
			base.EquipItem();
		}

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

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "TwinApparatus";
		}
	}
}
namespace itolib.Patches
{
	[HarmonyPatch]
	internal sealed class DoorwayPatch
	{
		internal static bool specificDoorwayActive;

		[HarmonyPatch(typeof(DoorwayPairFinder), "IsValidDoorwayPairing")]
		[HarmonyPostfix]
		private static void IsValidDoorwayPairingPost(ref bool __result, DoorwayProxy a, DoorwayProxy b, TileProxy previousTile, ref float weight)
		{
			if (!__result || !specificDoorwayActive)
			{
				return;
			}
			if (a.DoorwayComponent is SpecificDoorway specificDoorway)
			{
				if (specificDoorway.AllowSwap)
				{
					foreach (DoorwayProxy usedDoorway in previousTile.UsedDoorways)
					{
						if (usedDoorway != a)
						{
							Doorway doorwayComponent = usedDoorway.DoorwayComponent;
							if (doorwayComponent != null && doorwayComponent is SpecificDoorway specificDoorway2 && specificDoorway2.AllowSwap && specificDoorway2.DoorwayType == specificDoorway.DoorwayType)
							{
								__result = false;
								weight = 0f;
								return;
							}
						}
					}
				}
				__result = ModifyWeights(specificDoorway, next: false, ref weight);
				if (!__result)
				{
					return;
				}
			}
			if (b.DoorwayComponent is SpecificDoorway doorway)
			{
				__result = ModifyWeights(doorway, next: true, ref weight);
			}
		}

		private static bool ModifyWeights(SpecificDoorway doorway, bool next, ref float weight)
		{
			if (doorway.DoorwayType == DoorwayType.Neither || (next && doorway.DoorwayType == DoorwayType.Exit && !doorway.AllowSwap) || (!next && doorway.DoorwayType == DoorwayType.Entrance))
			{
				weight = 0f;
				return false;
			}
			if (doorway.WeightOverride != 0f)
			{
				weight = doorway.WeightOverride;
			}
			else
			{
				weight *= doorway.WeightMultiplier;
			}
			return true;
		}
	}
	[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
	{
		private static bool firstLoad = true;

		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPrefix]
		private static void MenuManagerStartPre()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (firstLoad)
			{
				firstLoad = false;
				if (BagConfigCompatibility.Enabled && !GameNetworkManager.Instance.disableSteam && (SteamId.op_Implicit(SteamClient.SteamId) == 76561198072744265L || SteamId.op_Implicit(SteamClient.SteamId) == 76561198086325047L))
				{
					Plugin.Harmony.PatchAll(typeof(BagConfigCompatibility));
				}
				if (CrowdControlCompatibility.Enabled)
				{
					Plugin.Harmony.PatchAll(typeof(CrowdControlCompatibility));
				}
			}
		}
	}
}
namespace itolib.Interfaces
{
	public interface IEventfulItem
	{
		UnityEvent<bool, bool> OnActivate { get; set; }

		UnityEvent<Collider> OnActivatePhysicsTrigger { get; set; }

		UnityEvent OnBatteryCharge { get; set; }

		UnityEvent OnBatteryDrain { get; set; }

		UnityEvent OnCollect { get; set; }

		UnityEvent OnCollectEarly { get; set; }

		UnityEvent<PlayerControllerB> OnDestroyHeldEarly { get; set; }

		UnityEvent OnDiscard { get; set; }

		UnityEvent OnDiscardEarly { get; set; }

		UnityEvent OnDiscardSFX { get; set; }

		UnityEvent OnDiscardSFXEarly { get; set; }

		UnityEvent<EnemyAI> OnEnemyGrab { get; set; }

		UnityEvent OnEnemyDiscard { get; set; }

		UnityEvent OnEquip { get; set; }

		UnityEvent OnEquipEarly { get; set; }

		UnityEvent OnGrab { get; set; }

		UnityEvent OnGroundReached { get; set; }

		UnityEvent<int> OnGroundReachedVariant { get; set; }

		UnityEvent OnInspect { get; set; }

		UnityEvent OnInspectEarly { get; set; }

		UnityEvent OnInteract { get; set; }

		UnityEvent OnInteractLeft { get; set; }

		UnityEvent OnInteractRight { get; set; }

		UnityEvent OnPlace { get; set; }

		UnityEvent OnPocket { get; set; }

		UnityEvent OnPocketEarly { get; set; }

		Action? FallWithCurveOverride { get; set; }

		bool HideOnPocket { get; set; }

		bool SaveMaterialVariant { get; set; }

		bool SaveMeshVariant { get; set; }

		int VariantIndex { get; set; }

		void ResetCurveOverride()
		{
			FallWithCurveOverride = null;
		}

		void ResetCurveOverride(EnemyAI enemy)
		{
			ResetCurveOverride();
		}
	}
	public interface IPooledObject<T>
	{
		int ObjectID { get; set; }

		T TakenBy { get; set; }

		IPooledObject<T> NextPooledObject { get; set; }

		IPooledObject<T> CreateInstance();

		bool TryAssignInstance(T taker, int maxInstances, out IPooledObject<T> pooledObject)
		{
			pooledObject = null;
			if (TakenBy == null || (object)taker == (object)TakenBy)
			{
				pooledObject = this;
			}
			else if (NextPooledObject == null && ObjectID < maxInstances)
			{
				NextPooledObject = CreateInstance();
				NextPooledObject.ObjectID = ObjectID + 1;
				pooledObject = NextPooledObject;
			}
			if (pooledObject != null)
			{
				pooledObject.TakenBy = taker;
				return true;
			}
			return NextPooledObject != null && NextPooledObject.TryAssignInstance(taker, maxInstances, out pooledObject);
		}

		bool TryFreeInstance(T possibleOwner, out IPooledObject<T> pooledObject)
		{
			pooledObject = null;
			if ((object)possibleOwner == (object)TakenBy)
			{
				pooledObject = this;
				TakenBy = default(T);
				return true;
			}
			return NextPooledObject != null && NextPooledObject.TryFreeInstance(possibleOwner, out pooledObject);
		}

		void PrepareInstances(int instancesLeft)
		{
			if (instancesLeft != 0)
			{
				NextPooledObject = CreateInstance();
				NextPooledObject.ObjectID = ObjectID + 1;
				NextPooledObject.PrepareInstances(instancesLeft - 1);
			}
		}
	}
	public interface IScriptableConfigEntry<T>
	{
		string Section { get; set; }

		string Key { get; set; }

		T DefaultValue { get; set; }

		string Description { get; set; }
	}
	public interface ISeededScript<T> where T : ISeededScript<T>
	{
		static Random SeededRandom
		{
			get
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.randomMapSeed != CurrentSeed)
				{
					<SeededRandom>k__BackingField = new Random(StartOfRound.Instance.randomMapSeed + SeedOffset);
					CurrentSeed = StartOfRound.Instance.randomMapSeed;
				}
				return <SeededRandom>k__BackingField ?? new Random();
			}
			[CompilerGenerated]
			private set
			{
				<SeededRandom>k__BackingField = value;
			}
		}

		private static int CurrentSeed { get; set; } = -1;


		static int SeedOffset { get; set; }
	}
	public interface IWeightedEntry
	{
		int Weight { get; set; }

		bool SingleUse { get; set; }
	}
	public interface IWeightedScript<T> where T : IWeightedEntry
	{
		T[]? WeightedEntries { get; set; }

		int[]? CumulativeWeights { get; set; }

		int TotalWeight { get; set; }

		void Initialize()
		{
			if (WeightedEntries != null && WeightedEntries.Length != 0)
			{
				CumulativeWeights = new int[WeightedEntries.Length];
				for (int i = 0; i < WeightedEntries.Length; i++)
				{
					TotalWeight += WeightedEntries[i].Weight;
					CumulativeWeights[i] = TotalWeight;
				}
			}
		}

		void RemoveWeight(int index)
		{
			T[]? weightedEntries = WeightedEntries;
			ModifyWeight(index, (weightedEntries != null) ? (-weightedEntries[index].Weight) : 0);
		}

		void ModifyWeight(int index, int weight)
		{
			if (CumulativeWeights == null || index < 0 || index >= CumulativeWeights.Length || CumulativeWeights[index] == weight)
			{
				return;
			}
			TotalWeight += weight;
			for (int i = index; i < CumulativeWeights.Length; i++)
			{
				if (i == index || CumulativeWeights[i] > 0)
				{
					CumulativeWeights[i] += weight;
				}
			}
		}

		bool TryObtainEntry(out T entry, int weightIndex)
		{
			entry = default(T);
			if (weightIndex >= 0 && weightIndex < WeightedEntries?.Length)
			{
				entry = WeightedEntries[weightIndex];
				if (entry.SingleUse)
				{
					RemoveWeight(weightIndex);
				}
				return true;
			}
			return false;
		}

		bool TryObtainRandomEntry(out T entry, Random? random = null)
		{
			entry = default(T);
			if (!TryObtainRandomEntryIndex(out var weightIndex, random))
			{
				return false;
			}
			entry = WeightedEntries[weightIndex];
			if (entry.SingleUse)
			{
				RemoveWeight(weightIndex);
			}
			return true;
		}

		bool TryObtainRandomEntryIndex(out int weightIndex, Random? random = null)
		{
			weightIndex = -1;
			if (WeightedEntries == null || WeightedEntries.Length == 0 || CumulativeWeights == null || CumulativeWeights.Length == 0)
			{
				return false;
			}
			int randomWeight = random?.Next(0, TotalWeight + 1) ?? Random.RandomRangeInt(0, TotalWeight + 1);
			weightIndex = Array.FindIndex(CumulativeWeights, (int weight) => randomWeight <= weight);
			return weightIndex >= 0 && weightIndex < WeightedEntries.Length;
		}
	}
}
namespace itolib.Extensions
{
	public static class ContentTagExtensions
	{
		public static bool CompareTag(this ContentTag tagA, ContentTag tagB)
		{
			return tagA.contentTagName.CompareOrdinal(tagB.contentTagName);
		}
	}
	public static class PlayerExtensions
	{
		public static bool IsLocalClient(this PlayerControllerB player)
		{
			return player.actualClientId == GameNetworkManager.Instance.localPlayerController.actualClientId;
		}

		public static bool IsSpectatedClient(this PlayerControllerB player)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			return localPlayerController.isPlayerDead && (Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.overrideSpectateCamera && (Object)(object)localPlayerController.spectatedPlayerScript != (Object)null && localPlayerController.spectatedPlayerScript.actualClientId == player.actualClientId;
		}

		public static bool HasLineOfSightToPosition(this PlayerControllerB player, Vector3 pos, float width = 45f, int range = 60, float proximityAwareness = -1f, LayerMask layerMask = default(LayerMask))
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)player).transform.position - pos;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			return sqrMagnitude < (float)(range * range) && (Vector3.Angle(((Component)player.playerEye).transform.forward, pos - ((Component)player.gameplayCamera).transform.position) < width || (proximityAwareness > 0f && sqrMagnitude < proximityAwareness * proximityAwareness)) && !Physics.Linecast(((Component)player.playerEye).transform.position, pos, ref player.hit, LayerMask.op_Implicit(layerMask), (QueryTriggerInteraction)1);
		}
	}
	public static class SelectableLevelExtensions
	{
		public static string GetNumberlessPlanetName(this SelectableLevel level)
		{
			if (level.PlanetName.Length == 0)
			{
				return string.Empty;
			}
			bool flag = false;
			char[] array = new char[level.PlanetName.Length];
			for (int i = 0; i < array.Length; i++)
			{
				char c = level.PlanetName[i];
				if (!flag)
				{
					if (!char.IsLetter(c))
					{
						continue;
					}
					flag = true;
				}
				array[i] = c;
			}
			return new string(array).TrimEnd('\0');
		}
	}
	public static class StringExtensions
	{
		public static bool CompareOrdinal(this string strA, string strB)
		{
			return string.CompareOrdinal(strA, strB) == 0;
		}

		public static bool IsNullOrEmpty(this string str)
		{
			return string.IsNullOrEmpty(str);
		}

		public static bool IsNullOrWhiteSpace(this string str)
		{
			return string.IsNullOrWhiteSpace(str);
		}
	}
}
namespace itolib.Enums
{
	public enum ActivationTime
	{
		[Tooltip("")]
		Immediate = -1,
		[Tooltip("")]
		DungeonComplete,
		[Tooltip("")]
		ScrapSpawn,
		[Tooltip("")]
		HazardSpawn,
		[Tooltip("")]
		StartOfRound,
		[Tooltip("")]
		Manual
	}
	public enum AudioAction
	{
		[Tooltip("")]
		Initialize = -1,
		[Tooltip("")]
		Play,
		[Tooltip("")]
		Pause,
		[Tooltip("")]
		Unpause,
		[Tooltip("")]
		Stop,
		[Tooltip("")]
		StopIncludingOneShots
	}
	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 BagConfigCompatibility
	{
		private static bool? _enabled;

		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private static GameObject? <WeedKillerPrefab>k__BackingField;

		private static readonly Vector3 BeltBagPocketDimensionPosition = new Vector3(3000f, -400f, 3000f);

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

		public static GameObject? WeedKillerPrefab
		{
			get
			{
				if ((Object)(object)<WeedKillerPrefab>k__BackingField == (Object)null)
				{
					WeedKillerPrefab = OriginalContent.Items.Find((Item item) => item.itemId == 19).spawnPrefab;
				}
				return <WeedKillerPrefab>k__BackingField;
			}
			[CompilerGenerated]
			private set
			{
				<WeedKillerPrefab>k__BackingField = value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		[HarmonyPatch(typeof(BeltBagPatch), "OverrideGrab")]
		[HarmonyPrefix]
		internal static void ManifestWeedKiller(BeltBagItem @this, bool right)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (right && ((NetworkBehaviour)@this).IsHost && Misc.DropAll.Value && @this.objectsInBag.Count >= 20 && !((Object)(object)WeedKillerPrefab == (Object)null) && @this.objectsInBag.FindIndex((GrabbableObject item) => (Object)(object)item != (Object)null && (Object)(object)item.itemProperties != (Object)null && item.itemProperties.itemId == 19) == -1)
			{
				GameObject val = Object.Instantiate<GameObject>(WeedKillerPrefab, BeltBagPocketDimensionPosition, Quaternion.identity);
				GrabbableObject val2 = default(GrabbableObject);
				NetworkObject val3 = default(NetworkObject);
				if (val.TryGetComponent<GrabbableObject>(ref val2) && val.TryGetComponent<NetworkObject>(ref val3))
				{
					val2.EnablePhysics(false);
					val2.fallTime = 0f;
					val2.targetFloorPosition = BeltBagPocketDimensionPosition;
					val2.startFallingPosition = BeltBagPocketDimensionPosition;
					val3.Spawn(false);
					@this.objectsInBag.Add(val2);
				}
			}
		}
	}
	[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; }

		internal 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)]
		internal static void HalveTwinValue(TwinApparatus twinApparatus)
		{
			if (MeltdownPlugin.config.OverrideApparatusValue)
			{
				((GrabbableObject)twinApparatus).SetScrapValue((int)((double)((GrabbableObject)twinApparatus).scrapValue * 0.5));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void InitiateMeltdown()
		{
			if (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)]
		internal 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;
			}
		}

		internal 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("")]
		[SerializeField]
		private float tolerance = 1f;

		[Tooltip("")]
		[SerializeField]
		private bool moveToCenter = true;

		[Tooltip("")]
		[SerializeField]
		private int priority = 1;

		[Tooltip("")]
		[SerializeField]
		private string nameFilter = string.Empty;

		private int connectorsFound;

		protected 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			base.CheckObjectsInRegion();
			connectorsFound = 0;
			ConnectorMerger connectorMerger = default(ConnectorMerger);
			for (int i = 0; i < objectsFound; i++)
			{
				Collider[]? array = overlapBuffer;
				Collider val = ((array != null) ? array[i] : null);
				if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).TryGetComponent<ConnectorMerger>(ref connectorMerger) && !((Object)(object)connectorMerger == (Object)(object)this) && (nameFilter.Length <= 0 || !nameFilter.CompareOrdinal(connectorMerger.nameFilter)))
				{
					if (priority < connectorMerger.priority)
					{
						return;
					}
					Vector3 val2 = ((Component)this).transform.position - ((Component)connectorMerger).transform.position;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < tolerance * tolerance)
					{
						onObjectsEach.Invoke(connectorMerger);
						connectorsFound++;
					}
				}
			}
			if (connectorsFound > 0)
			{
				onObjectsAny.Invoke(connectorsFound);
			}
		}

		public void DisableSelf(ConnectorMerger otherConnector)
		{
			//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)otherConnector).transform.position, ((Component)this).transform.position, 0.5f);
				((Component)otherConnector).transform.position = position;
			}
			((Component)this).gameObject.SetActive(false);
		}

		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);
		}

		public void DisableBothConnectors(ConnectorMerger connector)
		{
			((Component)connector).gameObject.SetActive(false);
			((Component)this).gameObject.SetActive(false);
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ConnectorMerger";
		}
	}
	public class DungeonStoryLog : StoryLog
	{
		[Space(5f)]
		[Header("Dungeon Story Log")]
		[Tooltip("")]
		[SerializeField]
		private UnityEvent<int> onLogSpawned = new UnityEvent<int>();

		[Tooltip("")]
		[SerializeField]
		private UnityEvent<int> onLogCollected = new UnityEvent<int>();

		[Tooltip("")]
		[SerializeField]
		private UnityEvent<int> onAlreadyUnlocked = new UnityEvent<int>();

		public void Start()
		{
			foreach (ExtendedStoryLog extendedStoryLog in ((ExtendedContent)DungeonManager.CurrentExtendedDungeonFlow).ExtendedMod.ExtendedStoryLogs)
			{
				if (extendedStoryLog.sceneName.CompareOrdinal(DungeonManager.CurrentExtendedDungeonFlow.DungeonName) && 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;
				}
			}
		}

		public void CollectLogSynced(PlayerControllerB player)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			CollectLogLocal(player);
			CollectLogServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player));
		}

		[ServerRpc(RequireOwnership = false)]
		private void CollectLogServerRpc(NetworkBehaviourReference playerReference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2053278011u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2053278011u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					CollectLogClientRpc(playerReference);
				}
			}
		}

		[ClientRpc]
		private void CollectLogClientRpc(NetworkBehaviourReference playerReference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			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(2066413116u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2066413116u, val, (RpcDelivery)0);
				}
				PlayerControllerB player = default(PlayerControllerB);
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkBehaviourReference)(ref playerReference)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null) && !player.IsLocalClient())
				{
					CollectLogLocal(player);
				}
			}
		}

		private void CollectLogLocal(PlayerControllerB player)
		{
			if (player.IsLocalClient())
			{
				((StoryLog)this).CollectLog();
				onLogCollected.Invoke(base.storyLogID);
			}
			else if (!base.collected && base.storyLogID != -1)
			{
				base.collected = true;
				((StoryLog)this).RemoveLogCollectible();
				onLogCollected.Invoke(base.storyLogID);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DungeonStoryLog()
		{
			//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(2053278011u, new RpcReceiveHandler(__rpc_handler_2053278011));
			NetworkManager.__rpc_func_table.Add(2066413116u, new RpcReceiveHandler(__rpc_handler_2066413116));
		}

		private static void __rpc_handler_2053278011(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DungeonStoryLog)(object)target).CollectLogServerRpc(playerReference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2066413116(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkBehaviourReference playerReference = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DungeonStoryLog)(object)target).CollectLogClientRpc(playerReference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		[Space(5f)]
		[Header("Dungeon Television")]
		[Tooltip("")]
		[SerializeField]
		private InteractTrigger? tvTrigger;

		[Tooltip("")]
		[SerializeField]
		private 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) => unlockable.unlockableName.CompareOrdinal("Television"));
				}
				return <TelevisionUnlockableItem>k__BackingField;
			}
			[CompilerGenerated]
			private set
			{
				<TelevisionUnlockableItem>k__BackingField = value;
			}
		}

		private 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
	{
		[Header("Hazard Replacement")]
		[Tooltip("")]
		public string originalHazard;

		[Tooltip("")]
		public string replacingHazard;

		public HazardReplacement()
		{
			originalHazard = string.Empty;
			replacingHazard = string.Empty;
		}
	}
	public class HazardReplacer : MonoBehaviour, IDungeonCompleteReceiver
	{
		[SerializeField]
		private HazardReplacement[]? hazardReplacements;

		public void OnDungeonComplete(Dungeon dungeon)
		{
			if (!NetworkManager.Singleton.IsHost || hazardReplacements == null)
			{
				return;
			}
			SelectableLevel selectableLevel = LevelManager.CurrentExtendedLevel.SelectableLevel;
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			string[] array = new string[selectableLevel.spawnableMapObjects.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = ((Object)selectableLevel.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;
			}
			for (int k = 0; k < hazardReplacements.Length; k++)
			{
				SpawnableMapObject val = null;
				for (int l = 0; l < array.Length; l++)
				{
					if (hazardReplacements[k].originalHazard.CompareOrdinal(array[l]))
					{
						val = selectableLevel.spawnableMapObjects[l];
						break;
					}
				}
				if (val == 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 val2 = null;
				for (int m = 0; m < array2.Length; m++)
				{
					if (hazardReplacements[k].replacingHazard.CompareOrdinal(array2[m]))
					{
						val2 = currentExtendedDungeonFlow.SpawnableMapObjects[m];
						break;
					}
				}
				if (val2 == 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
				{
					val2.numberToSpawn = val.numberToSpawn;
				}
			}
		}
	}
	public class PrefabSpawner : NetworkedSpawner<NetworkObject>
	{
		[Header("Prefab Spawner")]
		[Tooltip("")]
		public NetworkObject? prefabToSpawn;

		[Tooltip("")]
		[SerializeField]
		private Transform? parentTransform;

		[Tooltip("")]
		[SerializeField]
		private bool useLocalRotation;

		[Space(5f)]
		[Header("Other")]
		[Tooltip("")]
		[SerializeField]
		private bool skipInactive = true;

		[Tooltip("")]
		[SerializeField]
		private bool seededRandom = true;

		public static Random Random { get; private set; }

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

		public override void PerformSpawn()
		{
			if (!NetworkManager.Singleton.IsHost)
			{
				return;
			}
			int num = (seededRandom ? Random.Next(minSpawns, maxSpawns + 1) : Random.RandomRangeInt(minSpawns, maxSpawns + 1));
			if (num == 0)
			{
				return;
			}
			spawnLocations?.RemoveAll((Transform? spawnLocation) => (Object)(object)spawnLocation == (Object)null || (skipInactive && !((Component)spawnLocation).gameObject.activeInHierarchy));
			spawnAreas?.RemoveAll((BoxCollider? spawnArea) => (Object)(object)spawnArea == (Object)null || (skipInactive && !((Component)spawnArea).gameObject.activeInHierarchy));
			List<Transform?>? list = spawnLocations;
			if (list != null && list.Count > 0)
			{
				if (num == -1)
				{
					num = spawnLocations.Count;
				}
				for (int i = 0; i < num; i++)
				{
					if (spawnLocations.Count <= 0)
					{
						break;
					}
					int index = (seededRandom ? Random.Next(0, spawnLocations.Count) : Random.RandomRangeInt(0, spawnLocations.Count));
					SpawnPrefab(spawnLocations[index]);
					if (exhaustiveLocations)
					{
						spawnLocations.RemoveAt(index);
					}
				}
			}
			else
			{
				List<BoxCollider?>? list2 = spawnAreas;
				if (list2 != null && list2.Count > 0)
				{
					if (num == -1)
					{
						num = spawnAreas.Count;
					}
					for (int j = 0; j < num; j++)
					{
						if (spawnAreas.Count <= 0)
						{
							break;
						}
						int index2 = (seededRandom ? Random.Next(0, spawnAreas.Count) : Random.RandomRangeInt(0, spawnAreas.Count));
						SpawnPrefab(spawnAreas[index2]);
						if (exhaustiveAreas)
						{
							spawnAreas.RemoveAt(index2);
						}
					}
				}
				else if (!skipInactive)
				{
					SpawnPrefab(((Component)this).transform);
				}
			}
			base.PerformSpawn();
		}

		private void SpawnPrefab(Transform spawnLocation)
		{
			//IL_0017: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject val = GetPrefabToSpawn();
			if ((Object)(object)val != (Object)null)
			{
				SpawnPrefab(val, spawnLocation.position, (!useLocalRotation) ? spawnLocation.rotation : spawnLocation.localRotation);
			}
		}

		private void SpawnPrefab(BoxCollider spawnArea)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject val = GetPrefabToSpawn();
			if ((Object)(object)val != (Object)null)
			{
				Vector3 val2 = spawnArea.size * 0.5f;
				Vector3 val3 = (seededRandom ? new Vector3((float)Random.NextDouble() * val2.x * 2f - val2.x, (float)Random.NextDouble() * val2.y * 2f - val2.y, (float)Random.NextDouble() * val2.z * 2f - val2.z) : new Vector3(Random.Range(0f, 1f) * val2.x * 2f - val2.x, Random.Range(0f, 1f) * val2.y * 2f - val2.y, Random.Range(0f, 1f) * val2.z * 2f - val2.z));
				Transform transform = ((Component)spawnArea).transform;
				Vector3 spawnPosition = transform.TransformPoint(val3 + spawnArea.center);
				SpawnPrefab(val, spawnPosition, (!useLocalRotation) ? transform.rotation : transform.localRotation);
			}
		}

		private void SpawnPrefab(NetworkObject prefabToSpawn, Vector3 spawnPosition, Quaternion spawnRotation)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)prefabToSpawn).gameObject, spawnPosition, spawnRotation, ((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 Awake()
		{
			if (NetworkManager.Singleton.IsHost)
			{
				if (seededRandom && Random == null)
				{
					Random = (((Object)(object)StartOfRound.Instance != (Object)null) ? new Random(StartOfRound.Instance.randomMapSeed + 44) : new Random());
				}
				base.Awake();
			}
		}

		public override void OnDestroy()
		{
			if (seededRandom)
			{
				Random = null;
			}
			((NetworkBehaviour)this).OnDestroy();
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PrefabSpawner";
		}
	}
	public class ScrapInjector : MonoBehaviour, IDungeonCompleteReceiver
	{
		private List<SpawnableItemWithRarity>? modifiedRarities;

		public void OnDungeonComplete(Dungeon dungeon)
		{
			if (!NetworkManager.Singleton.IsHost || !((Behaviour)this).enabled)
			{
				return;
			}
			SelectableLevel selectableLevel = LevelManager.CurrentExtendedLevel.SelectableLevel;
			ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
			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 < selectableLevel.spawnableScrap.Count; i++)
				{
					SpawnableItemWithRarity val = selectableLevel.spawnableScrap[i];
					if ((Object)(object)val.spawnableItem == (Object)(object)extendedItem.Item && val.rarity < 1)
					{
						val.rarity = dynamicRarity;
						modifiedRarities.Add(val);
						break;
					}
				}
			}
		}

		public void OnDestroy()
		{
			for (int i = 0; i < modifiedRarities?.Count; i++)
			{
				modifiedRarities[i].rarity = 0;
			}
		}
	}
	[Serializable]
	public struct SyncedItem : INetworkSerializable
	{
		[Header("Synced Item")]
		[Tooltip("")]
		public Vector3 position;

		[Tooltip("")]
		public Quaternion rotation;

		[Tooltip("")]
		public int scrapValue;

		[Tooltip("")]
		public int meshVariant;

		[Tooltip("")]
		public int materialVariant;

		public SyncedItem()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			rotation = Quaternion.identity;
			scrapValue = 0;
			meshVariant = -1;
			materialVariant = -1;
		}

		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));
		}
	}
	[Serializable]
	public struct ScrapWeightEntry : IWeightedEntry
	{
		[Header("Scrap Weight Entry")]
		[Tooltip("")]
		public Item? itemToSpawn;

		[field: Tooltip("")]
		[field: Min(0f)]
		[field: SerializeField]
		public int Weight { get; set; }

		[field: Tooltip("")]
		[field: SerializeField]
		public bool SingleUse { get; set; }

		public ScrapWeightEntry()
		{
			itemToSpawn = null;
			Weight = 1;
			SingleUse = false;
		}

		public ScrapWeightEntry(SpawnableItemWithRarity itemWithRarity)
		{
			itemToSpawn = null;
			Weight = 1;
			SingleUse = false;
			itemToSpawn = itemWithRarity.spawnableItem;
			Weight = itemWithRarity.rarity;
		}
	}
	public class ScrapSpawner : NetworkedSpawner<GrabbableObject>, IWeightedScript<ScrapWeightEntry>, ISeededScript<ScrapSpawner>
	{
		[CompilerGenerated]
		private sealed class <SyncItemValuesOnSpawn>d__45 : 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__45(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.sharedMesh = <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));
						}
						if ((Object)(object)RoundManager.Instance != (Object)null)
						{
							RoundManager instance = RoundManager.Instance;
							instance.totalScrapValueInLevel += (float)syncedItem.scrapValue;
						}
						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();
			}
		}

		[Tooltip("")]
		[SerializeField]
		private ContentTag[]? tagsToSpawn;

		[Tooltip("")]
		[Min(0f)]
		[SerializeField]
		private bool requireAllTags;

		[Tooltip("")]
		[SerializeField]
		private bool useMoonScrapSpawns;

		[Tooltip("")]
		[SerializeField]
		private bool exhaustivePool;

		[Space(5f)]
		[Header("Item Properties")]
		[Tooltip("")]
		[Min(-1f)]
		[SerializeField]
		private int overrideMinValue = -1;

		[Tooltip("")]
		[Min(-1f)]
		[SerializeField]
		private int overrideMaxValue = -1;

		[Tooltip("")]
		[SerializeField]
		private bool applyScrapMultiplier = true;

		[Tooltip("")]
		[SerializeField]
		private bool allowMeshVariants = true;

		[Tooltip("")]
		[SerializeField]
		private bool allowMaterialVariants = true;

		[Space(5f)]
		[Header("Position & Rotation")]
		[Tooltip("")]
		[SerializeField]
		private bool fallToGround = true;

		[Tooltip("")]
		[SerializeField]
		private bool randomizePosition;

		[Tooltip("")]
		[SerializeField]
		private bool applyRestingRotation;

		[Space(5f)]
		[Header("Other")]
		[Tooltip("")]
		[SerializeField]
		private bool skipInactive = true;

		[Tooltip("")]
		[SerializeField]
		private bool seededRandom = true;

		[Tooltip("")]
		[SerializeField]
		private bool respectSingleItemDay;

		private IW