Decompiled source of itolib v0.6.0

BepInEx/plugins/itolib.dll

Decompiled a week 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.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepinControl;
using Dawn;
using DunGen;
using DunGen.Graph;
using FacilityMeltdown;
using FacilityMeltdown.API;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using PizzaTowerEscapeMusic;
using TMPro;
using TVLoader.Patches;
using TVLoader.Utils;
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 WeatherTweaks.Definitions;
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;
using itolib.Structs;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("CrowdControl")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FacilityMeltdown")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("PizzaTowerEscapeMusic")]
[assembly: IgnoresAccessChecksTo("TVLoader")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("itolib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Wondrous gizmos and gadgets for the restless mind.")]
[assembly: AssemblyFileVersion("0.6.0.0")]
[assembly: AssemblyInformationalVersion("0.6.0+97e6a7c666aaca60828d92a1f6dc8a59c5d64a7c")]
[assembly: AssemblyProduct("itolib")]
[assembly: AssemblyTitle("itolib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.6.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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.5.1")]
	[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.6.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "pacoito.itolib";

		public const string PLUGIN_NAME = "itolib";

		public const string VERSION = "0.6.0";

		internal static ManualLogSource StaticLogger { get; private set; }

		internal static Harmony Harmony { get; private set; }

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Harmony = new Harmony("pacoito.itolib");
				SerializeNetworkVariables();
				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.6.0 loaded!");
			}
			catch (Exception arg)
			{
				StaticLogger.LogError((object)string.Format("Error while initializing '{0}': {1}", "itolib", arg));
			}
		}

		private static void SerializeNetworkVariables()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<ItemInfo>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<ItemInfo>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<HiveInfo>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<HiveInfo>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<NetworkObjectReference>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<NetworkObjectReference>();
		}
	}
}
namespace itolib.Structs
{
	[Serializable]
	public struct HitInfo : INetworkSerializable
	{
		[Header("Hit Info")]
		[Tooltip("")]
		public int damage;

		[Tooltip("")]
		public Vector3 direction;

		[Tooltip("")]
		public int hitID;

		[HideInInspector]
		public bool hitByPlayer;

		[HideInInspector]
		public NetworkBehaviourReference playerReference;

		public HitInfo()
		{
			//IL_0008: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			damage = 1;
			direction = Vector3.zero;
			hitID = 1;
			hitByPlayer = false;
			playerReference = default(NetworkBehaviourReference);
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0033: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref damage, default(ForPrimitives));
			serializer.SerializeValue(ref direction);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref hitID, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref hitByPlayer, default(ForPrimitives));
			if (hitByPlayer)
			{
				((BufferSerializer<NetworkBehaviourReference>*)(&serializer))->SerializeValue<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
			}
		}
	}
	[Serializable]
	public struct HiveInfo : INetworkSerializable, IEquatable<HiveInfo>
	{
		[Header("Hive Info")]
		[Tooltip("")]
		public ItemInfo itemInfo;

		[Tooltip("")]
		public NetworkBehaviourReference beesReference;

		[Space(5f)]
		[Header("Hive Override")]
		[Tooltip("")]
		public bool overrideHive;

		[Tooltip("")]
		public NetworkBehaviourReference hiveReference;

		public HiveInfo()
		{
			//IL_0012: 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)
			itemInfo = default(ItemInfo);
			beesReference = default(NetworkBehaviourReference);
			overrideHive = false;
			hiveReference = default(NetworkBehaviourReference);
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0032: 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)
			itemInfo.NetworkSerialize<T>(serializer);
			((BufferSerializer<NetworkBehaviourReference>*)(&serializer))->SerializeValue<NetworkBehaviourReference>(ref beesReference, default(ForNetworkSerializable));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref overrideHive, default(ForPrimitives));
			if (overrideHive)
			{
				((BufferSerializer<NetworkBehaviourReference>*)(&serializer))->SerializeValue<NetworkBehaviourReference>(ref hiveReference, default(ForNetworkSerializable));
			}
		}

		public readonly bool Equals(HiveInfo other)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (itemInfo == other.itemInfo)
			{
				NetworkBehaviourReference val = beesReference;
				if (((NetworkBehaviourReference)(ref val)).Equals(other.beesReference) && overrideHive == other.overrideHive)
				{
					val = hiveReference;
					return ((NetworkBehaviourReference)(ref val)).Equals(other.hiveReference);
				}
			}
			return false;
		}

		public override readonly bool Equals(object obj)
		{
			if (obj is HiveInfo other)
			{
				return Equals(other);
			}
			return false;
		}

		public static bool operator ==(HiveInfo left, HiveInfo right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(HiveInfo left, HiveInfo right)
		{
			return !(left == right);
		}

		public override readonly int GetHashCode()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return HashCode.Combine<ItemInfo, NetworkBehaviourReference, bool, NetworkBehaviourReference>(itemInfo, beesReference, overrideHive, hiveReference);
		}
	}
	[Serializable]
	public struct ItemInfo : INetworkSerializable, IEquatable<ItemInfo>
	{
		[Header("Item Info")]
		[Tooltip("")]
		public TransformInfo transformInfo;

		[Tooltip("")]
		public NetworkBehaviourReference itemReference;

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

		[Tooltip("")]
		[Min(-1f)]
		public int meshVariant;

		[Tooltip("")]
		[Min(-1f)]
		public int materialVariant;

		public ItemInfo()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			transformInfo = default(TransformInfo);
			itemReference = default(NetworkBehaviourReference);
			scrapValue = 0;
			meshVariant = -1;
			materialVariant = -1;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			transformInfo.NetworkSerialize<T>(serializer);
			((BufferSerializer<NetworkBehaviourReference>*)(&serializer))->SerializeValue<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref scrapValue, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref meshVariant, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref materialVariant, default(ForPrimitives));
		}

		public readonly bool Equals(ItemInfo other)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			if (transformInfo == other.transformInfo)
			{
				NetworkBehaviourReference val = itemReference;
				if (((NetworkBehaviourReference)(ref val)).Equals(other.itemReference) && scrapValue == other.scrapValue && meshVariant == other.meshVariant)
				{
					return materialVariant == other.materialVariant;
				}
			}
			return false;
		}

		public override readonly bool Equals(object obj)
		{
			if (obj is ItemInfo other)
			{
				return Equals(other);
			}
			return false;
		}

		public static bool operator ==(ItemInfo left, ItemInfo right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(ItemInfo left, ItemInfo right)
		{
			return !(left == right);
		}

		public override readonly int GetHashCode()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return HashCode.Combine<TransformInfo, NetworkBehaviourReference, int, int, int>(transformInfo, itemReference, scrapValue, meshVariant, materialVariant);
		}
	}
	[Serializable]
	public struct ScanNodeInfo : INetworkSerializable
	{
		[Header("Scan Node Info")]
		[Tooltip("")]
		public string headerText;

		[Tooltip("")]
		public string subText;

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

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

		[Tooltip("")]
		[Min(-1f)]
		public int creatureScanID;

		[Tooltip("")]
		[Min(-1f)]
		public int nodeType;

		[Tooltip("")]
		public bool requiresLineOfSight;

		public ScanNodeInfo()
		{
			nodeType = 0;
			headerText = string.Empty;
			subText = string.Empty;
			minRange = 5;
			maxRange = 7;
			creatureScanID = -1;
			requiresLineOfSight = true;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			serializer.SerializeValue(ref headerText, false);
			serializer.SerializeValue(ref subText, false);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref minRange, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref maxRange, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref creatureScanID, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref nodeType, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref requiresLineOfSight, default(ForPrimitives));
		}
	}
	[Serializable]
	public struct TransformInfo : INetworkSerializable, IEquatable<TransformInfo>
	{
		[Header("Transform Info")]
		[Tooltip("")]
		public Vector3 position;

		[Tooltip("")]
		public Quaternion rotation;

		public TransformInfo()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			rotation = Quaternion.identity;
		}

		public TransformInfo(Transform transform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			position = Vector3.zero;
			rotation = Quaternion.identity;
			position = transform.position;
			rotation = transform.rotation;
		}

		public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			serializer.SerializeValue(ref position);
			serializer.SerializeValue(ref rotation);
		}

		public readonly bool Equals(TransformInfo other)
		{
			//IL_0001: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (position == other.position)
			{
				return rotation == other.rotation;
			}
			return false;
		}

		public override readonly bool Equals(object obj)
		{
			if (obj is TransformInfo other)
			{
				return Equals(other);
			}
			return false;
		}

		public static bool operator ==(TransformInfo left, TransformInfo right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(TransformInfo left, TransformInfo right)
		{
			return !(left == right);
		}

		public override readonly int GetHashCode()
		{
			//IL_0001: 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)
			return HashCode.Combine<Vector3, Quaternion>(position, rotation);
		}
	}
}
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; }

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


		public void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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 sealed class ScriptableEvent : ScriptableObject
	{
		[CompilerGenerated]
		[Tooltip("Name of the event. Object name will be used as fallback if the field is left blank.")]
		[SerializeField]
		private string <EventName>k__BackingField = string.Empty;

		internal static Dictionary<Guid, ScriptableEvent> AllEvents { get; } = new Dictionary<Guid, ScriptableEvent>();


		[field: Header("Scriptable Event")]
		[field: Tooltip("Source of the event (e.g. mod, moon, interior), to avoid conflicting event names.")]
		[field: SerializeField]
		public string EventSource { get; private set; } = string.Empty;


		public string EventName
		{
			get
			{
				if (<EventName>k__BackingField.IsNullOrEmpty())
				{
					<EventName>k__BackingField = ((Object)this).name;
				}
				return <EventName>k__BackingField;
			}
		}

		private event Action? OnEventRaise;

		private void Awake()
		{
			string value = EventSource + ":" + EventName;
			if (!value.TryComputeGUID(out var result) || !AllEvents.TryAdd(result, this))
			{
				Object.Destroy((Object)(object)this);
			}
		}

		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;
		}
	}
	[CreateAssetMenu(fileName = "ScriptableNetworkPrefab", menuName = "itolib/Networking/ScriptableNetworkPrefab")]
	public sealed class ScriptableNetworkPrefab : ScriptableObject
	{
		[SerializeField]
		private NetworkObject[]? prefabsToRegister;

		private static Dictionary<string, NetworkObject> RegisteredPrefabs { get; } = new Dictionary<string, NetworkObject>();


		private void Awake()
		{
			for (int i = 0; i < prefabsToRegister?.Length; i++)
			{
				NetworkObject val = prefabsToRegister[i];
				if ((Object)(object)val != (Object)null)
				{
					LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(((Component)val).gameObject);
					RegisteredPrefabs.TryAdd(((Object)val).name, val);
				}
			}
		}

		public static bool TryGetPrefab(out NetworkObject prefab, string name)
		{
			prefab = null;
			if (!name.IsNullOrEmpty())
			{
				return RegisteredPrefabs.TryGetValue(name, out prefab);
			}
			return false;
		}
	}
}
namespace itolib.PlayZone
{
	public class PlayZoneElevator : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <DeactivateElevatorDelayed>d__34 : 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__34(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				PlayZoneElevator playZoneElevator = <>4__this;
				switch (num)
				{
				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;
					playZoneElevator.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)
		{
			if (CurrentState != newState && CurrentState != ElevatorState.Deactivated)
			{
				SwitchStateLocal(newState);
				if (((NetworkBehaviour)this).IsSpawned)
				{
					SwitchStateRpc(newState);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SwitchStateRpc(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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2402193886u, val2, val, (SendTo)5, (RpcDelivery)0);
					((FastBufferWriter)(ref val3)).WriteValueSafe<ElevatorState>(ref newState, default(ForEnums));
					((NetworkBehaviour)this).__endSendRpc(ref val3, 2402193886u, val2, val, (SendTo)5, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					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)
		{
			if (CurrentState != ElevatorState.Deactivated)
			{
				ToggleDoorsLocal(open);
				if (((NetworkBehaviour)this).IsSpawned)
				{
					ToggleDoorsRpc(open);
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ToggleDoorsRpc(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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val2 = default(RpcParams);
					FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(4028709194u, val2, val, (SendTo)5, (RpcDelivery)0);
					((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref open, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendRpc(ref val3, 4028709194u, val2, val, (SendTo)5, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					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__34))]
		private IEnumerator DeactivateElevatorDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DeactivateElevatorDelayed>d__34(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();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2402193886u, new RpcReceiveHandler(__rpc_handler_2402193886), "SwitchStateRpc");
			((NetworkBehaviour)this).__registerRpc(4028709194u, new RpcReceiveHandler(__rpc_handler_4028709194), "ToggleDoorsRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

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

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

			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()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Expected O, but got Unknown
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Expected O, but got Unknown
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				TwinApparatus twinApparatus = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)twinApparatus.apparatusAudio != (Object)null)
					{
						twinApparatus.apparatusAudio.Stop();
						if (twinApparatus.playDisconnectSFX)
						{
							twinApparatus.apparatusAudio.PlayOneShot(((LungProp)twinApparatus).disconnectSFX, 0.7f);
						}
					}
					twinApparatus.OnDisconnectEarly.Invoke();
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (twinApparatus.playSparkPFX)
					{
						((LungProp)twinApparatus).sparkParticle.SetActive(true);
					}
					if ((Object)(object)twinApparatus.apparatusAudio != (Object)null && twinApparatus.playRemoveFromMachineSFX)
					{
						twinApparatus.apparatusAudio.PlayOneShot(((LungProp)twinApparatus).removeFromMachineSFX);
					}
					if (twinApparatus.modifyEnemySpawns && ((NetworkBehaviour)twinApparatus).IsHost && Random.Range(0, 100) < 70 && ((LungProp)twinApparatus).roundManager.minEnemiesToSpawn < 2)
					{
						((LungProp)twinApparatus).roundManager.minEnemiesToSpawn = ((!twinApparatus.bothPulled) ? 1 : 2);
					}
					twinApparatus.OnDisconnect.Invoke();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					if (twinApparatus.flickerLights)
					{
						((LungProp)twinApparatus).roundManager.FlickerLights(false, false);
					}
					twinApparatus.OnLightsFlicker.Invoke();
					<>2__current = (object)new WaitForSeconds(2.5f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if (twinApparatus.shutOffPower)
					{
						((LungProp)twinApparatus).roundManager.SwitchPower(false);
						((LungProp)twinApparatus).roundManager.powerOffPermanently = twinApparatus.shutOffPowerPermanently;
					}
					twinApparatus.OnLightsOff.Invoke();
					<>2__current = (object)new WaitForSeconds(0.75f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					if (!twinApparatus.bothPulled)
					{
						if (twinApparatus.shutOffPower)
						{
							((LungProp)twinApparatus).roundManager.SwitchPower(!twinApparatus.bothPulled);
							twinApparatus.DimLights();
						}
						return false;
					}
					if (twinApparatus.displayRadiationWarning)
					{
						HUDManager.Instance.RadiationWarningHUD();
					}
					twinApparatus.OnDisplayWarning.Invoke();
					if (twinApparatus.awakenOldBirds && twinApparatus.bothPulled && ((NetworkBehaviour)twinApparatus).IsHost && (Object)(object)((LungProp)twinApparatus).radMechEnemyType != (Object)null)
					{
						EnemyAINestSpawnObject[] array = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsSortMode)0);
						for (int i = 0; i < array.Length; i++)
						{
							if ((Object)(object)array[i].enemyType == (Object)(object)((LungProp)twinApparatus).radMechEnemyType)
							{
								((LungProp)twinApparatus).roundManager.SpawnEnemyGameObject(((LungProp)twinApparatus).roundManager.outsideAINodes[i].transform.position, 0f, -1, ((LungProp)twinApparatus).radMechEnemyType);
							}
						}
					}
					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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (FacilityMeltdownCompatibility.Enabled)
			{
				FacilityMeltdownCompatibility.HalveTwinValue(this);
				if (triggerFacilityMeltdown)
				{
					base.OnDisconnectEarly.AddListener((UnityAction)delegate
					{
						if (bothPulled)
						{
							FacilityMeltdownCompatibility.InitiateMeltdown();
						}
					});
				}
			}
			if (PizzaTowerEscapeMusicCompatibility.Enabled)
			{
				base.OnDisconnectEarly.AddListener((UnityAction)delegate
				{
					PizzaTowerEscapeMusicCompatibility.SwitchApparatus(triggerEscapeMusic ? LongLostTwin : null);
				});
			}
		}

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

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

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

		[HarmonyPrepare]
		private static void PrepareDoorwayPatch(MethodBase original)
		{
			if (original == null)
			{
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onBeforeDungeonGenerate).AddListener((Action)delegate
				{
					specificDoorwayActive = null;
				});
			}
		}

		[HarmonyPatch(typeof(DoorwayPairFinder), "IsValidDoorwayPairing")]
		[HarmonyPostfix]
		private static void IsValidDoorwayPairingPost(ref bool __result, DoorwayProxy a, DoorwayProxy b, TileProxy previousTile, ref float weight)
		{
			bool valueOrDefault = specificDoorwayActive.GetValueOrDefault();
			if (!specificDoorwayActive.HasValue)
			{
				valueOrDefault = a.DoorwayComponent is SpecificDoorway;
				specificDoorwayActive = valueOrDefault;
			}
			if (!__result || specificDoorwayActive == false)
			{
				return;
			}
			if (a.DoorwayComponent is SpecificDoorway specificDoorway)
			{
				if (specificDoorway.AllowSwap)
				{
					foreach (DoorwayProxy usedDoorway in previousTile.UsedDoorways)
					{
						if (usedDoorway != a && (Object)(object)usedDoorway.DoorwayComponent != (Object)null && usedDoorway.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()
		{
			if (firstLoad)
			{
				firstLoad = false;
				if (CrowdControlCompatibility.Enabled)
				{
					Plugin.Harmony.PatchAll(typeof(CrowdControlCompatibility));
				}
			}
		}
	}
}
namespace itolib.Interfaces
{
	public interface IActivationScript : IDungeonCompleteReceiver
	{
		IActivationScript ActivationSelf { get; }

		ActivationTime ActivationTime { get; set; }

		bool PerformedActivation { get; set; }

		void Initialize()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			if (PerformedActivation)
			{
				return;
			}
			switch (ActivationTime)
			{
			case ActivationTime.Immediate:
				PerformActivation();
				break;
			case ActivationTime.ScrapSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects).AddListener((Action)PerformActivation);
				break;
			case ActivationTime.HazardSpawn:
				((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects).AddListener((Action)PerformActivation);
				break;
			case ActivationTime.StartOfRound:
				if ((Object)(object)StartOfRound.Instance != (Object)null)
				{
					((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).AddListener(new UnityAction(PerformActivation));
				}
				break;
			case ActivationTime.DungeonComplete:
			case ActivationTime.Manual:
				break;
			}
		}

		void PerformActivation(ActivationTime activationTime);

		private void PerformActivation()
		{
			if (!PerformedActivation && ActivationTime != ActivationTime.Manual)
			{
				PerformedActivation = true;
				UnsubscribeFromEvents();
				PerformActivation(ActivationTime);
			}
		}

		void UnsubscribeFromEvents()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedScrapObjects).RemoveListener((Action)PerformActivation);
			((ExtendedEvent)DungeonManager.GlobalDungeonEvents.onSpawnedMapObjects).RemoveListener((Action)PerformActivation);
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).RemoveListener(new UnityAction(PerformActivation));
			}
		}

		void OnDungeonComplete()
		{
			if (ActivationTime == ActivationTime.DungeonComplete)
			{
				PerformActivation();
			}
		}
	}
	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; }

		UnityEvent OnReactToSellCounter { 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 _)
		{
			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;
			}
			if (NextPooledObject != null)
			{
				return NextPooledObject.TryAssignInstance(taker, maxInstances, out pooledObject);
			}
			return false;
		}

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

		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>
	{
		private static int? _seedOffset;

		ISeededScript<T> SeededSelf { get; }

		static Random SeededRandom
		{
			get
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null && <SeededRandom>k__BackingField == null)
				{
					<SeededRandom>k__BackingField = new Random(StartOfRound.Instance.randomMapSeed + SeedOffset);
					LevelManager.GlobalLevelEvents.onLevelLoaded.AddListener((Action)ResetRandom);
				}
				return <SeededRandom>k__BackingField ?? new Random();
			}
			[CompilerGenerated]
			private set
			{
				<SeededRandom>k__BackingField = value;
			}
		}

		static int SeedOffset
		{
			get
			{
				int valueOrDefault = _seedOffset.GetValueOrDefault();
				if (!_seedOffset.HasValue)
				{
					valueOrDefault = ComputeSeedOffset();
					_seedOffset = valueOrDefault;
				}
				return _seedOffset.GetValueOrDefault();
			}
			set
			{
				_seedOffset = value;
			}
		}

		private static int ComputeSeedOffset()
		{
			byte[] value = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(typeof(T).Name ?? ""));
			return BitConverter.ToInt32(value, 0);
		}

		private static void ResetRandom()
		{
			LevelManager.GlobalLevelEvents.onLevelLoaded.RemoveListener((Action)ResetRandom);
			SeededRandom = null;
		}

		Random GetSeededRandom()
		{
			return SeededRandom;
		}
	}
	public interface IWeightedEntry
	{
		int Weight { get; set; }

		bool SingleUse { get; set; }
	}
	public interface IWeightedScript<T> where T : IWeightedEntry
	{
		IWeightedScript<T> WeightedSelf { get; }

		T[]? WeightedEntries { get; set; }

		int[]? CumulativeWeights { get; set; }

		int TotalWeight { get; set; }

		void InitializeWeights()
		{
			AddWeights(WeightedEntries);
		}

		void AddWeight(T entry)
		{
			T[]? weightedEntries = WeightedEntries;
			object weightedEntries2;
			if (weightedEntries == null || weightedEntries.Length == 0)
			{
				weightedEntries2 = new T[1] { entry };
			}
			else
			{
				T[] weightedEntries3 = WeightedEntries;
				int num = 0;
				T[] array = new T[1 + weightedEntries3.Length];
				ReadOnlySpan<T> readOnlySpan = new ReadOnlySpan<T>(weightedEntries3);
				readOnlySpan.CopyTo(new Span<T>(array).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				array[num] = entry;
				weightedEntries2 = array;
			}
			WeightedEntries = (T[]?)weightedEntries2;
			int[]? cumulativeWeights = CumulativeWeights;
			object cumulativeWeights2;
			if (cumulativeWeights == null || cumulativeWeights.Length == 0)
			{
				cumulativeWeights2 = new int[1] { entry.Weight };
			}
			else
			{
				int[] cumulativeWeights3 = CumulativeWeights;
				int num = 0;
				int[] array2 = new int[1 + cumulativeWeights3.Length];
				ReadOnlySpan<int> readOnlySpan2 = new ReadOnlySpan<int>(cumulativeWeights3);
				readOnlySpan2.CopyTo(new Span<int>(array2).Slice(num, readOnlySpan2.Length));
				num += readOnlySpan2.Length;
				array2[num] = entry.Weight;
				cumulativeWeights2 = array2;
			}
			CumulativeWeights = (int[]?)cumulativeWeights2;
			TotalWeight += entry.Weight;
		}

		void AddWeights(T[]? entries)
		{
			if (entries != null && entries.Length != 0)
			{
				T[]? weightedEntries = WeightedEntries;
				T[] weightedEntries2;
				if (weightedEntries == null || weightedEntries.Length == 0)
				{
					weightedEntries2 = entries;
				}
				else
				{
					T[] weightedEntries3 = WeightedEntries;
					int num = 0;
					T[] array = new T[weightedEntries3.Length + entries.Length];
					ReadOnlySpan<T> readOnlySpan = new ReadOnlySpan<T>(weightedEntries3);
					readOnlySpan.CopyTo(new Span<T>(array).Slice(num, readOnlySpan.Length));
					num += readOnlySpan.Length;
					ReadOnlySpan<T> readOnlySpan2 = new ReadOnlySpan<T>(entries);
					readOnlySpan2.CopyTo(new Span<T>(array).Slice(num, readOnlySpan2.Length));
					num += readOnlySpan2.Length;
					weightedEntries2 = array;
				}
				WeightedEntries = weightedEntries2;
				int[] array2 = new int[entries.Length];
				for (int i = 0; i < entries.Length; i++)
				{
					TotalWeight += entries[i].Weight;
					array2[i] = TotalWeight;
				}
				int[]? cumulativeWeights = CumulativeWeights;
				int[] cumulativeWeights2;
				if (cumulativeWeights == null || cumulativeWeights.Length == 0)
				{
					cumulativeWeights2 = array2;
				}
				else
				{
					int[] cumulativeWeights3 = CumulativeWeights;
					int[] array3 = array2;
					int num = 0;
					int[] array4 = new int[cumulativeWeights3.Length + array3.Length];
					ReadOnlySpan<int> readOnlySpan3 = new ReadOnlySpan<int>(cumulativeWeights3);
					readOnlySpan3.CopyTo(new Span<int>(array4).Slice(num, readOnlySpan3.Length));
					num += readOnlySpan3.Length;
					ReadOnlySpan<int> readOnlySpan4 = new ReadOnlySpan<int>(array3);
					readOnlySpan4.CopyTo(new Span<int>(array4).Slice(num, readOnlySpan4.Length));
					num += readOnlySpan4.Length;
					cumulativeWeights2 = array4;
				}
				CumulativeWeights = cumulativeWeights2;
			}
		}

		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);
			if (weightIndex >= 0)
			{
				return weightIndex < WeightedEntries.Length;
			}
			return false;
		}
	}
}
namespace itolib.Extensions
{
	public static class ColliderExtensions
	{
		public static Vector3 GetPointWithin(this BoxCollider collider, Random? seededRandom = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = collider.size * 0.5f;
			return (seededRandom != null) ? new Vector3(seededRandom.Next(0f - val.x, val.x), seededRandom.Next(0f - val.y, val.y), seededRandom.Next(0f - val.z, val.z)) : new Vector3(Random.Range(0f - val.x, val.x), Random.Range(0f - val.y, val.y), Random.Range(0f - val.z, val.z));
		}
	}
	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;
			if (localPlayerController.isPlayerDead && (Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.overrideSpectateCamera && (Object)(object)localPlayerController.spectatedPlayerScript != (Object)null)
			{
				return localPlayerController.spectatedPlayerScript.actualClientId == player.actualClientId;
			}
			return false;
		}

		public static bool HasLineOfSightToPosition(this PlayerControllerB player, Vector3 pos, float width = 45f, float range = 60f, float proximityAwareness = -1f, LayerMask layerMask = default(LayerMask))
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0076: 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;
			if (sqrMagnitude < range * range && (Vector3.Angle(((Component)player.playerEye).transform.forward, pos - ((Component)player.gameplayCamera).transform.position) < width || (proximityAwareness > 0f && sqrMagnitude < proximityAwareness * proximityAwareness)))
			{
				return !Physics.Linecast(((Component)player.playerEye).transform.position, pos, ref player.hit, LayerMask.op_Implicit(layerMask), (QueryTriggerInteraction)1);
			}
			return false;
		}

		public static bool TryFindMovementAction(this PlayerControllerB player, out InputAction playerAction, string actionId)
		{
			playerAction = null;
			if (player.playerActions != null && player.playerActions.m_Movement != null)
			{
				playerAction = player.playerActions.m_Movement.FindAction(actionId, false);
			}
			return playerAction != null;
		}
	}
	public static class RandomExtensions
	{
		public static float Next(this Random random, float minValue, float maxValue)
		{
			return (float)(random.NextDouble() * (double)(maxValue - minValue) + (double)minValue);
		}

		public static double Next(this Random random, double minValue, double maxValue)
		{
			return random.NextDouble() * (maxValue - minValue) + minValue;
		}
	}
	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);
		}

		public static bool TryComputeGUID(this string value, out Guid result)
		{
			result = Guid.Empty;
			if (value.IsNullOrEmpty())
			{
				return false;
			}
			byte[] array = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(value));
			result = new Guid(array[..16]);
			return true;
		}
	}
}
namespace itolib.Enums
{
	public enum ActivationTime
	{
		[Tooltip("Activate immediately, as soon as possible.")]
		Immediate = -1,
		[Tooltip("Activate once the Dungeon finishes generating.")]
		DungeonComplete,
		[Tooltip("Activate right before scrap begins to spawn.")]
		ScrapSpawn,
		[Tooltip("Activate right before map objects (hazards) begin to spawn.")]
		HazardSpawn,
		[Tooltip("Activate once the round begins proper.")]
		StartOfRound,
		[Tooltip("Activate manually.")]
		Manual
	}
	[Obsolete("AudioGroup component that uses this is deprecated.")]
	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 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(LethalCompanyControl), "CrowdControlCommands")]
		[HarmonyPostfix]
		internal static void CCWeatherCheck()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0063: 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 DawnLibCompatibility
	{
		private static bool? _enabled;

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

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static EnemyType? GetDawnEnemyType(string enemyName)
		{
			foreach (DawnEnemyInfo value in ((Registry<DawnEnemyInfo>)(object)LethalContent.Enemies).Values)
			{
				if (!((DawnBaseInfo<DawnEnemyInfo>)(object)value).Key.IsVanilla() && (Object)(object)value.EnemyType != (Object)null && (Object)(object)value.EnemyType.enemyPrefab != (Object)null && ((Object)value.EnemyType.enemyPrefab).name.CompareOrdinal(enemyName))
				{
					return value.EnemyType;
				}
			}
			return null;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static Item? GetDawnItem(string itemName)
		{
			foreach (DawnItemInfo value in ((Registry<DawnItemInfo>)(object)LethalContent.Items).Values)
			{
				if (!((DawnBaseInfo<DawnItemInfo>)(object)value).Key.IsVanilla() && (Object)(object)value.Item != (Object)null && ((Object)value.Item).name.CompareOrdinal(itemName))
				{
					return value.Item;
				}
			}
			return null;
		}
	}
	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 SwitchApparatus(EventfulApparatus? apparatus)
		{
			if ((Object)(object)apparatus == (Object)null)
			{
				LungProp[] array = Object.FindObjectsByType<LungProp>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				for (int i = 0; i < array.Length; i++)
				{
					if (!(array[i] is EventfulApparatus) && array[i].isLungDocked)
					{
						GameEventListener.dockedApparatus = array[i];
						return;
					}
				}
			}
			GameEventListener.dockedApparatus = (LungProp)(object)apparatus;
		}
	}
	[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_0005: Unknown result type (might be due to invalid IL or missing references)
			if ((int)WeatherManager.GetCurrentLevelWeather().Type == 0)
			{
				return false;
			}
			OnWeatherEffectsApply += weatherAction;
			return true;
		}
	}
	internal sealed class WeatherTweaksCompatibility
	{
		private static bool? _enabled;

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

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static bool IsCombinedWeather(out LevelWeatherType[]? allWeathers, LevelWeatherType weather)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected I4, but got Unknown
			allWeathers = null;
			Weather weather2 = WeatherManager.GetWeather(weather);
			CombinedWeatherType val = (CombinedWeatherType)(object)((weather2 is CombinedWeatherType) ? weather2 : null);
			if (val != null)
			{
				allWeathers = (LevelWeatherType[]?)(object)new LevelWeatherType[((WeatherTweaksWeather)val).WeatherTypes.Count];
				for (int i = 0; i < allWeathers.Length; i++)
				{
					allWeathers[i] = (LevelWeatherType)(int)((WeatherTweaksWeather)val).WeatherTypes[i].WeatherType;
				}
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static bool IsProgressingWeather(LevelWeatherType weather)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return WeatherManager.GetWeather(weather) is ProgressingWeatherType;
		}
	}
}
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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			maxObjects = 8;
			layerMask = LayerMask.op_Implicit(LayerMask.NameToLayer("Room"));
		}

		public override void CheckObjectsInRegion()
		{
			//IL_0087: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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();
		}

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

		[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_0011: Unknown result type (might be due to invalid IL or missing references)
			CollectLogLocal(player);
			if (((NetworkBehaviour)this).IsSpawned)
			{
				CollectLogRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player));
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void CollectLogRpc(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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = new RpcAttributeParams
				{
					RequireOwnership = false
				};
				RpcParams val2 = default(RpcParams);
				FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1198879130u, val2, val, (SendTo)5, (RpcDelivery)0);
				((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendRpc(ref val3, 1198879130u, val2, val, (SendTo)5, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1)
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB player = default(PlayerControllerB);
				if (((NetworkBehaviourReference)(ref playerReference)).TryGet<PlayerControllerB>(ref player, (NetworkManager)null))
				{
					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();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1198879130u, new RpcReceiveHandler(__rpc_handler_1198879130), "CollectLogRpc");
			((StoryLog)this).__initializeRpcs();
		}

		private static void __rpc_handler_1198879130(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).CollectLogRpc(playerReference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "DungeonStoryLog";
		}
	}
	public class DungeonTelevision : TVScript
	{
		[CompilerGenerated]
		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;
			}
		}

		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 || (TVLoaderCompatibility.Enabled && (TelevisionUnlockableItem.alreadyUnlocked || TelevisionUnlockableItem.hasBeenUnlockedByPlayer)))
			{
				if ((Object)(object)tvTrigger != (Object)null)
				{
					tvTrigger.interactable = false;
				}
				((Behaviour)this).enabled = false;
			}
		}

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

		public void OnDisable()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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();
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string? __getTypeName()
		{
			return "DungeonTelevision";
		}
	}
	public class Fish : MonoBehaviour, IActivationScript, IDungeonCompleteReceiver, ISeededScript<Fish>
	{
		[CompilerGenerated]
		private static UnlockableItem? <GoldfishUnlockableItem>k__BackingField;

		[CompilerGenerated]
		private static GameObject? <FishBowl>k__BackingField;

		[Header("Fish")]
		[Tooltip("Fis