Decompiled source of Backrooms Renewed Fixed v0.1.6

BepInEx/plugins/DiversenSato-Backrooms_Renewed_Fixed/LC-Backrooms-Renewed.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using Dusk;
using EasyTextEffects.Editor.MyBoxCopy.Extensions;
using GameNetcodeStuff;
using HarmonyLib;
using LC-Backrooms-Renewed.NetcodePatcher;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Unity.AI.Navigation;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using VELDDev.BackroomsRenewed.BackroomsManagement;
using VELDDev.BackroomsRenewed.Config;
using VELDDev.BackroomsRenewed.Generation;
using VELDDev.BackroomsRenewed.Generation.Algorithms;
using VELDDev.BackroomsRenewed.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("0.1.6")]
[assembly: AssemblyInformationalVersion("0.1.6")]
[assembly: AssemblyCompany("DiversenSato (fork of VELD-Dev's Backrooms Renewed)")]
[assembly: AssemblyProduct("B#CKR##MS R#N#W#D")]
[assembly: AssemblyCopyright("GPL-3.0 License")]
[assembly: AssemblyTitle("Backrooms Renewed Fixed")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.1.6.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 VELDDev.BackroomsRenewed
{
	[BepInPlugin("DiversenSato.BackroomsRenewedFixed", "Backrooms Renewed Fixed", "0.1.6")]
	[BepInIncompatibility("VELDDev.BackroomsRenewed")]
	public class Plugin : BaseUnityPlugin
	{
		public class AchievementAssets : AssetBundleLoader<AchievementAssets>
		{
			public AchievementAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		private Harmony harmony = new Harmony("DiversenSato.BackroomsRenewedFixed");

		internal ManualLogSource logger;

		internal AssetBundle assetBundle;

		internal GameObject BackroomsPrefab;

		internal LocalConfig Configs;

		internal readonly string PluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal DuskMod mod;

		internal AchievementAssets achievements;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			InitializeTypes();
			bool num = Chainloader.PluginInfos.ContainsKey("Neekhaulas.Backrooms");
			Instance = this;
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"/// B##CKR##MS R#N#W#D \\\\\\");
			if (num)
			{
				logger.LogError((object)">>> IMP#SSIBL# T# L##D <<BACKROOMS RENEWED>>: The other backroom mod is already here !");
				return;
			}
			harmony.PatchAll();
			logger.LogInfo((object)">>> [x] P#TCH#S #PPL##D");
			Configs = new LocalConfig(((BaseUnityPlugin)this).Config);
			logger.LogInfo((object)">>> [x] C#NF#G L##D#D");
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(PluginDir, "backroomsrenewed_assets"));
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(PluginDir, "backroomsrenewed_toc"));
			RegisterPrefabs();
			mod = DuskMod.RegisterMod((BaseUnityPlugin)(object)this, val);
			LethalConfigSupport.RegisterModIcon(mod.ModInformation.ModIcon);
			logger.LogInfo((object)">>> [x] #SS#T B#NDL# L##D#D; #SS#TS L##D#D");
			RegisterAchievements();
			logger.LogInfo((object)">>> [x] #CHI#V#EM#NTS LO#D#D");
			logger.LogInfo((object)"\\\\\\ /!\\ #RR#R: #NT#GR#T# CH#CK F##L#R# -- PR#C##D C#R#F#LL# /!\\ ///");
			logger.LogInfo((object)">>> Entering the b--#c__ro#^m:s~");
		}

		private void RegisterPrefabs()
		{
			BackroomsPrefab = assetBundle.LoadAsset<GameObject>("Backrooms");
			CellVariantInfo[] array = assetBundle.LoadAllAssets<CellVariantInfo>();
			DawnLib.RegisterNetworkPrefab(BackroomsPrefab);
			CellVariantInfo[] array2 = array;
			foreach (CellVariantInfo cellVariantInfo in array2)
			{
				DawnLib.RegisterNetworkPrefab(cellVariantInfo.variantPrefab);
				((BaseUnityPlugin)this).Logger.LogDebug((object)("Registered prefab " + ((Object)cellVariantInfo.variantPrefab).name));
			}
			BackroomThemeInfo[] array3 = assetBundle.LoadAllAssets<BackroomThemeInfo>();
			foreach (BackroomThemeInfo backroomThemeInfo in array3)
			{
				DawnLib.RegisterNetworkPrefab(backroomThemeInfo.ExitPrefab);
				((BaseUnityPlugin)this).Logger.LogDebug((object)("Registered prefab " + ((Object)backroomThemeInfo.ExitPrefab).name));
			}
		}

		private void RegisterAchievements()
		{
			achievements = new AchievementAssets(mod, "backroomsrenewed_achievements");
			mod.RegisterContentHandlers();
			mod.Content.assetBundles.Add(((AssetBundleLoader<AchievementAssets>)(object)achievements).AssetBundleData);
		}

		private static void InitializeTypes()
		{
			InitializeNetworkBehaviour(typeof(Backrooms));
			InitializeNetworkBehaviour(typeof(CellBehaviour));
			InitializeNetworkBehaviour(typeof(FairRandomizer));
			InitializeNetworkBehaviour(typeof(Cell));
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<Cell>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Cell>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<ulong>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<ulong>();
		}

		private static void InitializeNetworkBehaviour(Type type)
		{
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
				{
					methodInfo.Invoke(null, null);
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PluginName = "Backrooms Renewed Fixed";

		public const string GUID = "DiversenSato.BackroomsRenewedFixed";

		public const string Author = "DiversenSato (fork of VELD-Dev's Backrooms Renewed)";

		public const string OriginalGUID = "VELDDev.BackroomsRenewed";

		public const string Version = "0.1.6";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LC-Backrooms-Renewed";

		public const string PLUGIN_NAME = "LC-Backrooms-Renewed";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace VELDDev.BackroomsRenewed.Utils
{
	public enum FairRandomizerEvent : byte
	{
		Death,
		OpenDoor,
		Damage,
		Clipping,
		ShipTP,
		ShipRevTP
	}
	public class FairRandomizer : NetworkBehaviour
	{
		public const string DEATH_EVENT = "OnDeath";

		public const string OPEN_DOOR_EVENT = "OnEnterFacility";

		public const string DAMAGE_EVENT = "OnDamage";

		public const string CLIPPING_EVENT = "OnClipping";

		public const string SHIP_TP = "OnShipTP";

		public const string SHIP_REV_TP = "OnShipRevTP";

		private static readonly ReadOnlyDictionary<string, FairRandomizerEvent> StringToEventMap = new ReadOnlyDictionary<string, FairRandomizerEvent>(new Dictionary<string, FairRandomizerEvent>
		{
			{
				"OnDeath",
				FairRandomizerEvent.Death
			},
			{
				"OnEnterFacility",
				FairRandomizerEvent.OpenDoor
			},
			{
				"OnDamage",
				FairRandomizerEvent.Damage
			},
			{
				"OnClipping",
				FairRandomizerEvent.Clipping
			},
			{
				"OnShipTP",
				FairRandomizerEvent.ShipTP
			},
			{
				"OnShipRevTP",
				FairRandomizerEvent.ShipRevTP
			}
		});

		private NetworkList<byte> _luckKeys;

		private NetworkList<float> _luckValues;

		private void Awake()
		{
			_luckKeys = new NetworkList<byte>((IEnumerable<byte>)null, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			_luckValues = new NetworkList<float>((IEnumerable<float>)null, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				InitializeLuckValues();
			}
		}

		private void InitializeLuckValues()
		{
			TryAddLuck(FairRandomizerEvent.Death, 0f);
			TryAddLuck(FairRandomizerEvent.OpenDoor, 0f);
			TryAddLuck(FairRandomizerEvent.Damage, 0f);
			TryAddLuck(FairRandomizerEvent.Clipping, 0f);
			TryAddLuck(FairRandomizerEvent.ShipTP, 0f);
			TryAddLuck(FairRandomizerEvent.ShipRevTP, 0f);
		}

		private bool TryGetLuckIndex(FairRandomizerEvent eventType, out int index)
		{
			byte b = (byte)eventType;
			for (int i = 0; i < _luckKeys.Count; i++)
			{
				if (_luckKeys[i] == b)
				{
					index = i;
					return true;
				}
			}
			index = -1;
			return false;
		}

		private bool TryAddLuck(FairRandomizerEvent eventType, float value)
		{
			if (TryGetLuckIndex(eventType, out var _))
			{
				return false;
			}
			_luckKeys.Add((byte)eventType);
			_luckValues.Add(value);
			return true;
		}

		private void SetLuck(FairRandomizerEvent eventType, float value)
		{
			if (TryGetLuckIndex(eventType, out var index))
			{
				_luckValues[index] = value;
				return;
			}
			_luckKeys.Add((byte)eventType);
			_luckValues.Add(value);
		}

		public bool CheckChance(FairRandomizerEvent eventType, float chance)
		{
			float num;
			if (!TryGetLuckIndex(eventType, out var index))
			{
				Plugin.Instance.logger.LogWarning((object)$"FairRandomizer: Event '{eventType}' not initialized, defaulting to base threshold.");
				num = 0f;
				if (((NetworkBehaviour)this).IsServer)
				{
					TryAddLuck(eventType, 0f);
				}
			}
			else
			{
				num = _luckValues[index];
			}
			if (Random.Range(0f, 1f) < num)
			{
				if (((NetworkBehaviour)this).IsServer)
				{
					SetLuck(eventType, 0f);
				}
				else
				{
					ResetLuckServerRpc(eventType);
				}
				return true;
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				SetLuck(eventType, num + chance);
				Plugin.Instance.logger.LogWarning((object)$"FairRandomizer: Event '{eventType}' failed, increasing luck by {chance} - New chance: {GetLuck(eventType)}");
			}
			else
			{
				IncreaseLuckServerRpc(eventType, chance);
				Plugin.Instance.logger.LogDebug((object)$"Requested server to increase luck for {eventType} by {chance}");
			}
			return false;
		}

		public float GetLuck(FairRandomizerEvent eventType)
		{
			if (!TryGetLuckIndex(eventType, out var index))
			{
				return 0f;
			}
			return _luckValues[index];
		}

		public void ResetLuck(FairRandomizerEvent eventType)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				if (TryGetLuckIndex(eventType, out var index))
				{
					_luckValues[index] = 0f;
				}
			}
			else
			{
				ResetLuckServerRpc(eventType);
			}
		}

		public void ResetLuck(string eventName)
		{
			if (StringToEventMap.TryGetValue(eventName, out var value))
			{
				ResetLuck(value);
			}
		}

		public void ResetAllLuck()
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				for (int i = 0; i < _luckValues.Count; i++)
				{
					_luckValues[i] = 0f;
				}
			}
			else
			{
				ResetAllLuckServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ResetLuckServerRpc(FairRandomizerEvent eventType)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(85182172u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 85182172u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (TryGetLuckIndex(eventType, out var index))
				{
					_luckValues[index] = 0f;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void IncreaseLuckServerRpc(FairRandomizerEvent eventType, float amount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2203742615u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2203742615u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (TryGetLuckIndex(eventType, out var index))
				{
					_luckValues[index] += amount;
					Plugin.Instance.logger.LogDebug((object)$"Increased luck for {eventType} by {amount}, new value: {_luckValues[index]}");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ResetAllLuckServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1774933182u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1774933182u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				for (int i = 0; i < _luckValues.Count; i++)
				{
					_luckValues[i] = 0f;
				}
			}
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			NetworkList<byte> luckKeys = _luckKeys;
			if (luckKeys != null)
			{
				((NetworkVariableBase)luckKeys).Dispose();
			}
			NetworkList<float> luckValues = _luckValues;
			if (luckValues != null)
			{
				((NetworkVariableBase)luckValues).Dispose();
			}
		}

		protected override void __initializeVariables()
		{
			if (_luckKeys == null)
			{
				throw new Exception("FairRandomizer._luckKeys cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_luckKeys).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_luckKeys, "_luckKeys");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)_luckKeys);
			if (_luckValues == null)
			{
				throw new Exception("FairRandomizer._luckValues cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_luckValues).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_luckValues, "_luckValues");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)_luckValues);
			((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
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(85182172u, new RpcReceiveHandler(__rpc_handler_85182172), "ResetLuckServerRpc");
			((NetworkBehaviour)this).__registerRpc(2203742615u, new RpcReceiveHandler(__rpc_handler_2203742615), "IncreaseLuckServerRpc");
			((NetworkBehaviour)this).__registerRpc(1774933182u, new RpcReceiveHandler(__rpc_handler_1774933182), "ResetAllLuckServerRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_85182172(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)
			{
				FairRandomizerEvent eventType = default(FairRandomizerEvent);
				((FastBufferReader)(ref reader)).ReadValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FairRandomizer)(object)target).ResetLuckServerRpc(eventType);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2203742615(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				FairRandomizerEvent eventType = default(FairRandomizerEvent);
				((FastBufferReader)(ref reader)).ReadValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				float amount = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref amount, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FairRandomizer)(object)target).IncreaseLuckServerRpc(eventType, amount);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1774933182(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((FairRandomizer)(object)target).ResetAllLuckServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "FairRandomizer";
		}
	}
}
namespace VELDDev.BackroomsRenewed.Patches
{
	[HarmonyPatch(typeof(EntranceTeleport))]
	public class EntranceTeleport_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("TeleportPlayer")]
		public static void TeleportPlayer(EntranceTeleport __instance)
		{
			if (!Synchronizable<SyncedConfig>.Instance.TeleportOnInteractDoor)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			bool flag;
			if (Synchronizable<SyncedConfig>.Instance.UseFairRandomizer)
			{
				FairRandomizer fairRandomizer = default(FairRandomizer);
				if (!((Component)localPlayerController).TryGetComponent<FairRandomizer>(ref fairRandomizer))
				{
					fairRandomizer = ((Component)localPlayerController).gameObject.AddComponent<FairRandomizer>();
				}
				flag = fairRandomizer.CheckChance(FairRandomizerEvent.OpenDoor, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnInteractDoor / 100f);
			}
			else
			{
				flag = Random.Range(0f, 101f) < Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnInteractDoor;
			}
			if (flag)
			{
				Backrooms.Instance.TeleportPlayerToBackrooms(localPlayerController, Synchronizable<SyncedConfig>.Instance.DropHeldItemsOnTeleport);
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManager_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("StartDisconnect")]
		public static void StartDisconnect()
		{
			Synchronizable<SyncedConfig>.RevertSync();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerB_Patches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void AddFairRandomizerToPlayer(PlayerControllerB __instance)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<FairRandomizer>()))
			{
				((Component)__instance).gameObject.AddComponent<FairRandomizer>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("KillPlayer")]
		public static bool KillPlayer(PlayerControllerB __instance)
		{
			if (!((NetworkBehaviour)__instance).IsOwner)
			{
				return true;
			}
			if (!Synchronizable<SyncedConfig>.Instance.TeleportOnDeath)
			{
				return true;
			}
			bool flag;
			if (Synchronizable<SyncedConfig>.Instance.UseFairRandomizer)
			{
				FairRandomizer fairRandomizer = default(FairRandomizer);
				if (!((Component)__instance).TryGetComponent<FairRandomizer>(ref fairRandomizer))
				{
					fairRandomizer = ((Component)__instance).gameObject.AddComponent<FairRandomizer>();
				}
				flag = fairRandomizer.CheckChance(FairRandomizerEvent.Death, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnDeath / 100f);
			}
			else
			{
				flag = Random.Range(0f, 101f) < Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnDeath;
			}
			if (__instance.AllowPlayerDeath() && flag)
			{
				Backrooms.Instance.TeleportPlayerToBackrooms(__instance, Synchronizable<SyncedConfig>.Instance.DropHeldItemsOnTeleport);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("DamagePlayer")]
		public static void DamagePlayer(PlayerControllerB __instance, ref int damageNumber)
		{
			if (!((NetworkBehaviour)__instance).IsOwner || !Synchronizable<SyncedConfig>.Instance.TeleportOnDamage)
			{
				return;
			}
			bool flag;
			if (Synchronizable<SyncedConfig>.Instance.UseFairRandomizer)
			{
				FairRandomizer fairRandomizer = default(FairRandomizer);
				if (!((Component)__instance).TryGetComponent<FairRandomizer>(ref fairRandomizer))
				{
					fairRandomizer = ((Component)__instance).gameObject.AddComponent<FairRandomizer>();
				}
				flag = fairRandomizer.CheckChance(FairRandomizerEvent.Damage, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnDamage / 100f);
			}
			else
			{
				flag = Random.Range(0f, 101f) < Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnDamage;
			}
			if (flag)
			{
				Backrooms.Instance.TeleportPlayerToBackrooms(__instance, Synchronizable<SyncedConfig>.Instance.DropHeldItemsOnTeleport);
				if (__instance.health - damageNumber < 0)
				{
					damageNumber = __instance.health - 1;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (Synchronizable<SyncedConfig>.IsHost)
			{
				CustomMessagingManager messagingManager = Synchronizable<SyncedConfig>.MessagingManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = SyncedConfig.OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messagingManager.RegisterNamedMessageHandler("BackroomsRenewed_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				Synchronizable<SyncedConfig>.Synced = true;
				return;
			}
			Synchronizable<SyncedConfig>.Synced = false;
			CustomMessagingManager messagingManager2 = Synchronizable<SyncedConfig>.MessagingManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = SyncedConfig.OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messagingManager2.RegisterNamedMessageHandler("BackroomsRenewed_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			SyncedConfig.RequestSync();
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public static class RoundManager_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		public static void DespawnBackroomsAtEndOfRound(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && Object.op_Implicit((Object)(object)Backrooms.Instance))
			{
				((Component)Backrooms.Instance).GetComponent<NetworkObject>().Despawn(true);
				Object.Destroy((Object)(object)((Component)Backrooms.Instance).gameObject);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SpawnSyncedProps")]
		public static void SpawnBackroomsAtStartOfRound(RoundManager __instance)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsServer)
			{
				if (Object.op_Implicit((Object)(object)Backrooms.Instance))
				{
					((Component)Backrooms.Instance).GetComponent<NetworkObject>().Despawn(true);
					Backrooms.Instance = null;
				}
				float num = 50f;
				if ((Object)(object)__instance.dungeonGenerator != (Object)null && (Object)(object)__instance.dungeonGenerator.Root != (Object)null)
				{
					num = __instance.dungeonGenerator.Root.transform.position.y;
				}
				Object.Instantiate<GameObject>(Plugin.Instance.BackroomsPrefab, new Vector3(5000f, num, 0f), Quaternion.identity).GetComponent<NetworkObject>().Spawn(true);
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class ShipTeleporter_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("beamUpPlayer")]
		public static IEnumerator BeamUpPlayerToBackrooms(IEnumerator __result, ShipTeleporter __instance)
		{
			PlayerControllerB teleportedPlayer = StartOfRound.Instance.mapScreen.targetedPlayer;
			bool redirectedToEnemy = (Object)(object)teleportedPlayer != (Object)null && (Object)(object)teleportedPlayer.redirectToEnemy != (Object)null;
			while (__result.MoveNext())
			{
				yield return __result.Current;
			}
			if (!__instance.isInverseTeleporter && Synchronizable<SyncedConfig>.Instance.TeleportOnShipTP && Object.op_Implicit((Object)(object)Backrooms.Instance) && !((Object)(object)teleportedPlayer == (Object)null) && !((Object)(object)teleportedPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !redirectedToEnemy && !teleportedPlayer.isPlayerDead && !Backrooms.Instance.PlayersInBackrooms.Contains(teleportedPlayer.playerClientId) && CheckTeleportChance(teleportedPlayer, FairRandomizerEvent.ShipTP, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnShipTP))
			{
				Backrooms.Instance.TeleportPlayerToBackrooms(teleportedPlayer, Synchronizable<SyncedConfig>.Instance.DropHeldItemsOnTeleport);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")]
		public static void InverseTeleporterToBackrooms(ShipTeleporter __instance, int playerObj)
		{
			if (Synchronizable<SyncedConfig>.Instance.TeleportOnShipRevTP && playerObj >= 0 && playerObj < StartOfRound.Instance.allPlayerScripts.Length)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj];
				if (!((Object)(object)val == (Object)null) && Object.op_Implicit((Object)(object)Backrooms.Instance) && !((Object)(object)val != (Object)(object)GameNetworkManager.Instance.localPlayerController) && CheckTeleportChance(val, FairRandomizerEvent.ShipRevTP, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnShipRevTP))
				{
					Backrooms.Instance.TeleportPlayerToBackrooms(val, Synchronizable<SyncedConfig>.Instance.DropHeldItemsOnTeleport);
				}
			}
		}

		private static bool CheckTeleportChance(PlayerControllerB player, FairRandomizerEvent eventType, float odds)
		{
			if (Synchronizable<SyncedConfig>.Instance.UseFairRandomizer)
			{
				FairRandomizer fairRandomizer = default(FairRandomizer);
				if (!((Component)player).TryGetComponent<FairRandomizer>(ref fairRandomizer))
				{
					fairRandomizer = ((Component)player).gameObject.AddComponent<FairRandomizer>();
				}
				return fairRandomizer.CheckChance(eventType, odds / 100f);
			}
			return Random.Range(0f, 101f) < odds;
		}
	}
}
namespace VELDDev.BackroomsRenewed.Generation
{
	[CreateAssetMenu(fileName = "AmbientMusicInfo", menuName = "Ambient Music Info")]
	public class AmbientMusicInfo : ScriptableObject
	{
		public AudioClip soundtrack;

		public bool isStreamSafe = true;

		[Tooltip("If not stream safe, fallback on this track as copyright-safe.")]
		public AudioClip fallbackSoundtrack;
	}
	public class BackroomsGenerator : MonoBehaviour
	{
		public struct ExitInfo
		{
			public Vector2Int position;

			public WallFlags direction;
		}

		public enum MazeAlgorithm
		{
			Blob,
			Kruskal,
			Prim,
			Wilson,
			RandomPathMerge,
			FractalTessellation
		}

		public int width = 20;

		public int height = 20;

		public int exitCount = 1;

		[Range(0f, 1f)]
		public float wallRemovalFraction = 0.1f;

		public MazeAlgorithm algorithm = LocalConfig.Singleton.GenerationAlgorithm.Value;

		[HideInInspector]
		public Cell[,] cells = new Cell[0, 0];

		[HideInInspector]
		public List<ExitInfo> exitPositions = new List<ExitInfo>();

		private IMazeAlgorithm currentAlgorithm;

		public IEnumerator Generate()
		{
			yield return InitializeMaze();
			currentAlgorithm = algorithm switch
			{
				MazeAlgorithm.Kruskal => new KruskalAlgorithm(), 
				MazeAlgorithm.Prim => new PrimAlgorithm(), 
				MazeAlgorithm.Wilson => new WilsonAlgorithm(), 
				MazeAlgorithm.Blob => new BlobAlgorithm(), 
				_ => throw new NotImplementedException(), 
			};
			yield return currentAlgorithm.Generate(cells, width, height);
			RemoveRandomWalls(wallRemovalFraction);
			PlaceExits();
		}

		private void RemoveRandomWalls(float fraction)
		{
			//IL_0041: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (fraction <= 0f)
			{
				return;
			}
			List<(Vector2Int, WallFlags, Vector2Int, WallFlags)> list = new List<(Vector2Int, WallFlags, Vector2Int, WallFlags)>();
			for (int i = 0; i < width; i++)
			{
				for (int j = 0; j < height; j++)
				{
					if (i < width - 1 && (cells[i, j].walls & WallFlags.East) != WallFlags.None)
					{
						list.Add((new Vector2Int(i, j), WallFlags.East, new Vector2Int(i + 1, j), WallFlags.West));
					}
					if (j < height - 1 && (cells[i, j].walls & WallFlags.North) != WallFlags.None)
					{
						list.Add((new Vector2Int(i, j), WallFlags.North, new Vector2Int(i, j + 1), WallFlags.South));
					}
				}
			}
			int num = Mathf.FloorToInt((float)list.Count * fraction);
			for (int k = 0; k < num; k++)
			{
				int num2 = Random.Range(k, list.Count);
				List<(Vector2Int, WallFlags, Vector2Int, WallFlags)> list2 = list;
				int index = k;
				int index2 = num2;
				(Vector2Int, WallFlags, Vector2Int, WallFlags) value = list[num2];
				(Vector2Int, WallFlags, Vector2Int, WallFlags) value2 = list[k];
				list2[index] = value;
				list[index2] = value2;
				(Vector2Int, WallFlags, Vector2Int, WallFlags) tuple = list[k];
				cells[((Vector2Int)(ref tuple.Item1)).x, ((Vector2Int)(ref tuple.Item1)).y].walls &= (WallFlags)(byte)(~(int)tuple.Item2);
				cells[((Vector2Int)(ref tuple.Item3)).x, ((Vector2Int)(ref tuple.Item3)).y].walls &= (WallFlags)(byte)(~(int)tuple.Item4);
			}
		}

		private IEnumerator InitializeMaze()
		{
			cells = new Cell[width, height];
			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					cells[x, y] = new Cell
					{
						position = new Vector2Int(x, y)
					};
					yield return null;
				}
			}
		}

		private void PlaceExits()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			exitPositions.Clear();
			HashSet<Vector2Int> hashSet = new HashSet<Vector2Int>();
			int num = exitCount * 20;
			int num2 = 0;
			Vector2Int val = default(Vector2Int);
			while (exitPositions.Count < exitCount && num2 < num)
			{
				WallFlags wallFlags;
				switch (Random.Range(0, 4))
				{
				case 0:
					((Vector2Int)(ref val))..ctor(Random.Range(0, width), height - 1);
					wallFlags = WallFlags.North;
					break;
				case 1:
					((Vector2Int)(ref val))..ctor(width - 1, Random.Range(0, height));
					wallFlags = WallFlags.East;
					break;
				case 2:
					((Vector2Int)(ref val))..ctor(Random.Range(0, width), 0);
					wallFlags = WallFlags.South;
					break;
				default:
					((Vector2Int)(ref val))..ctor(0, Random.Range(0, height));
					wallFlags = WallFlags.West;
					break;
				}
				if (!hashSet.Contains(val))
				{
					hashSet.Add(val);
					cells[((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y].walls &= (WallFlags)(byte)(~(int)wallFlags);
					exitPositions.Add(new ExitInfo
					{
						position = val,
						direction = wallFlags
					});
				}
				num2++;
			}
		}
	}
	[CreateAssetMenu(fileName = "BackroomThemeInfo", menuName = "Backroom Theme Info", order = 1)]
	public class BackroomThemeInfo : ScriptableObject
	{
		public string themeName;

		public List<CellVariantInfo> CellsVariants;

		public AudioClip AmbientNoise;

		public GameObject ExitPrefab;

		public List<AmbientMusicInfo> AmbientMusics;

		public float weight = 1f;
	}
	[Flags]
	public enum WallFlags : byte
	{
		None = 0,
		North = 1,
		East = 2,
		South = 4,
		West = 8
	}
	[Serializable]
	public struct Cell : IEquatable<Cell>, INetworkSerializable
	{
		public WallFlags walls;

		public Vector2Int position;

		public Cell()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			position = default(Vector2Int);
			walls = WallFlags.North | WallFlags.East | WallFlags.South | WallFlags.West;
		}

		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)
			((BufferSerializer<WallFlags>*)(&serializer))->SerializeValue<WallFlags>(ref walls, default(ForEnums));
			serializer.SerializeValue(ref position);
		}

		public bool Equals(Cell? other)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!other.HasValue)
			{
				return false;
			}
			if ((object)this == (object)other)
			{
				return true;
			}
			if (walls == other?.walls)
			{
				ref Vector2Int reference = ref position;
				object obj = other?.position;
				return ((object)Unsafe.As<Vector2Int, Vector2Int>(ref reference)/*cast due to .constrained prefix*/).Equals(obj);
			}
			return false;
		}

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

		public override int GetHashCode()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return HashCode.Combine<int, Vector2Int>((int)walls, position);
		}

		public bool Equals(Cell other)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (walls == other.walls)
			{
				return ((Vector2Int)(ref position)).Equals(other.position);
			}
			return false;
		}
	}
	[RequireComponent(typeof(NetworkObject))]
	public class CellBehaviour : NetworkBehaviour
	{
		public GameObject NorthWall;

		public GameObject EastWall;

		public GameObject SouthWall;

		public GameObject WestWall;

		public GameObject LightObject;

		public MeshRenderer CeilingMR;

		public Light cellLightSource;

		public float DefaultLightIntensity = 750f;

		public bool hasLightSource;

		public bool defaultLightState;

		private Cell _representation;

		private Material lightOnMat;

		private Material lightOffMat;

		private Material ceilingMat;

		[ClientRpc]
		public void InitializeClientRpc(Cell cell, bool withLight, bool lightState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1123228270u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<Cell>(ref cell, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref withLight, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref lightState, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1123228270u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				_representation = cell;
				hasLightSource = withLight;
				defaultLightState = lightState;
				UpdateWalls();
				Plugin.Instance.logger.LogDebug((object)$"Initializing cell ceiling has {((Renderer)CeilingMR).materials.Length} materials");
				lightOnMat = ((Renderer)CeilingMR).materials[0];
				ceilingMat = ((Renderer)CeilingMR).materials[1];
				lightOffMat = ((Renderer)CeilingMR).materials[2];
				if (!hasLightSource)
				{
					Plugin.Instance.logger.LogDebug((object)$"Cell {cell.position} initialized with light source disabled.");
					LightObject.SetActive(false);
					((Renderer)CeilingMR).SetMaterials(new List<Material>(2) { ceilingMat, ceilingMat });
				}
				else
				{
					Plugin.Instance.logger.LogDebug((object)$"Cell {cell.position} initialized with light source enabled.");
					LightObject.SetActive(true);
					((Behaviour)cellLightSource).enabled = true;
					cellLightSource.intensity = (defaultLightState ? DefaultLightIntensity : 0f);
				}
			}
		}

		private void UpdateWalls()
		{
			NorthWall.SetActive((_representation.walls & WallFlags.North) != 0);
			EastWall.SetActive((_representation.walls & WallFlags.East) != 0);
			SouthWall.SetActive((_representation.walls & WallFlags.South) != 0);
			WestWall.SetActive((_representation.walls & WallFlags.West) != 0);
		}

		public Transform GetExitDoorSocket(WallFlags dir)
		{
			return (Transform)(dir switch
			{
				WallFlags.North => NorthWall.transform.GetChild(0), 
				WallFlags.East => EastWall.transform.GetChild(0), 
				WallFlags.South => SouthWall.transform.GetChild(0), 
				WallFlags.West => WestWall.transform.GetChild(0), 
				_ => null, 
			});
		}

		private void SetLightState(bool state)
		{
			if (hasLightSource)
			{
				cellLightSource.intensity = (state ? DefaultLightIntensity : 0f);
			}
		}

		public void TwinkleLight(AnimationCurve intensityCurve, float duration)
		{
			if (Object.op_Implicit((Object)(object)cellLightSource) && hasLightSource)
			{
				((MonoBehaviour)this).StartCoroutine(TwinkleCoroutine(intensityCurve, duration));
			}
		}

		private IEnumerator TwinkleCoroutine(AnimationCurve intensityCurve, float duration)
		{
			float elapsed = 0f;
			while (elapsed < duration)
			{
				elapsed += Time.deltaTime;
				float intensity = intensityCurve.Evaluate(elapsed / duration) * DefaultLightIntensity;
				cellLightSource.intensity = intensity;
				yield return null;
			}
			cellLightSource.intensity = (defaultLightState ? DefaultLightIntensity : 0f);
		}

		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
			((NetworkBehaviour)this).__registerRpc(1123228270u, new RpcReceiveHandler(__rpc_handler_1123228270), "InitializeClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1123228270(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Cell cell = default(Cell);
				((FastBufferReader)(ref reader)).ReadValueSafe<Cell>(ref cell, default(ForNetworkSerializable));
				bool withLight = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref withLight, default(ForPrimitives));
				bool lightState = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref lightState, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CellBehaviour)(object)target).InitializeClientRpc(cell, withLight, lightState);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CellBehaviour";
		}
	}
	[CreateAssetMenu(fileName = "CellVariantInfo", menuName = "Cell Variant Info", order = 0)]
	public class CellVariantInfo : ScriptableObject
	{
		public GameObject variantPrefab;

		public Material LightOffMaterial;

		public Material CeilingMaterial;

		public float weight = 1f;

		[Tooltip("Maximum amount of this variant that can be used in a single generation. Set to -1 for no limit, 1 for unique.")]
		public int maxAmount = -1;

		public bool mustSpawnAtLeastOnce;
	}
	public class ExitBackroom : NetworkBehaviour
	{
		public void TeleportOutsideTheBackrooms()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			_ = GameNetworkManager.Instance.localPlayerController.thisPlayerBody;
			localPlayerController.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[localPlayerController.playerClientId].position, false, 0f, false, true);
			localPlayerController.isInsideFactory = false;
			Backrooms.Instance.StopPlayingAmbientAudios();
			Backrooms.Instance.RemovePlayerFromBackrooms(localPlayerController.playerClientId);
		}

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

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ExitBackroom";
		}
	}
}
namespace VELDDev.BackroomsRenewed.Generation.Algorithms
{
	public class BlobAlgorithm : IMazeAlgorithm
	{
		private class Blob
		{
			public int Id { get; set; }

			public List<Vector2Int> Cells { get; set; }

			public Blob(int id)
			{
				Id = id;
				Cells = new List<Vector2Int>();
			}

			public void Merge(Blob other)
			{
				Cells.AddRange(other.Cells);
			}
		}

		private class MergeCandidate
		{
			public Vector2Int CellA;

			public Vector2Int CellB;

			public WallFlags WallA;

			public WallFlags WallB;

			public int BlobIdA;

			public int BlobIdB;
		}

		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			Dictionary<Vector2Int, Blob> cellToBlob = new Dictionary<Vector2Int, Blob>();
			List<Blob> blobs = new List<Blob>();
			int blobIdCounter = 0;
			Stopwatch perfSw = Stopwatch.StartNew();
			Vector2Int val = default(Vector2Int);
			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					((Vector2Int)(ref val))..ctor(x, y);
					Blob blob = new Blob(blobIdCounter++);
					blob.Cells.Add(val);
					blobs.Add(blob);
					cellToBlob[val] = blob;
					if (perfSw.ElapsedMilliseconds > 16)
					{
						yield return null;
						perfSw.Restart();
					}
				}
			}
			List<Vector2Int> allCells = new List<Vector2Int>();
			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					allCells.Add(new Vector2Int(x, y));
					if (perfSw.ElapsedMilliseconds > 16)
					{
						yield return null;
						perfSw.Restart();
					}
				}
			}
			yield return ShuffleCells(allCells);
			while (blobs.Count > 1)
			{
				Vector2Int val2 = allCells[Random.Range(0, allCells.Count)];
				Blob currentBlob = cellToBlob[val2];
				List<MergeCandidate> list = FindMergeCandidates(val2, currentBlob, cellToBlob, width, height);
				if (list.Count > 0)
				{
					MergeCandidate mergeCandidate = list[Random.Range(0, list.Count)];
					maze[((Vector2Int)(ref mergeCandidate.CellA)).x, ((Vector2Int)(ref mergeCandidate.CellA)).y].walls &= (WallFlags)(byte)(~(int)mergeCandidate.WallA);
					maze[((Vector2Int)(ref mergeCandidate.CellB)).x, ((Vector2Int)(ref mergeCandidate.CellB)).y].walls &= (WallFlags)(byte)(~(int)mergeCandidate.WallB);
					Blob blob2 = cellToBlob[mergeCandidate.CellA];
					Blob blob3 = cellToBlob[mergeCandidate.CellB];
					blob2.Merge(blob3);
					foreach (Vector2Int cell in blob3.Cells)
					{
						cellToBlob[cell] = blob2;
					}
					blobs.Remove(blob3);
				}
				if (perfSw.ElapsedMilliseconds > 16)
				{
					yield return null;
					perfSw.Restart();
				}
			}
			perfSw.Stop();
		}

		private List<MergeCandidate> FindMergeCandidates(Vector2Int cell, Blob currentBlob, Dictionary<Vector2Int, Blob> cellToBlob, int width, int height)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			List<MergeCandidate> list = new List<MergeCandidate>();
			(Vector2Int, WallFlags, WallFlags)[] array = new(Vector2Int, WallFlags, WallFlags)[4]
			{
				(new Vector2Int(0, 1), WallFlags.North, WallFlags.South),
				(new Vector2Int(1, 0), WallFlags.East, WallFlags.West),
				(new Vector2Int(0, -1), WallFlags.South, WallFlags.North),
				(new Vector2Int(-1, 0), WallFlags.West, WallFlags.East)
			};
			for (int i = 0; i < array.Length; i++)
			{
				(Vector2Int, WallFlags, WallFlags) tuple = array[i];
				Vector2Int item = tuple.Item1;
				WallFlags item2 = tuple.Item2;
				WallFlags item3 = tuple.Item3;
				Vector2Int val = cell + item;
				if (((Vector2Int)(ref val)).x >= 0 && ((Vector2Int)(ref val)).x < width && ((Vector2Int)(ref val)).y >= 0 && ((Vector2Int)(ref val)).y < height)
				{
					Blob blob = cellToBlob[val];
					if (blob.Id != currentBlob.Id)
					{
						list.Add(new MergeCandidate
						{
							CellA = cell,
							CellB = val,
							WallA = item2,
							WallB = item3,
							BlobIdA = currentBlob.Id,
							BlobIdB = blob.Id
						});
					}
				}
			}
			return list;
		}

		private IEnumerator ShuffleCells(List<Vector2Int> cells)
		{
			Stopwatch perfSw = Stopwatch.StartNew();
			for (int i = cells.Count - 1; i > 0; i--)
			{
				int num = Random.Range(0, i + 1);
				int index = i;
				int index2 = num;
				Vector2Int value = cells[num];
				Vector2Int value2 = cells[i];
				cells[index] = value;
				cells[index2] = value2;
				if (perfSw.ElapsedMilliseconds > 16)
				{
					yield return null;
					perfSw.Restart();
				}
			}
			perfSw.Stop();
		}
	}
	public interface IMazeAlgorithm
	{
		IEnumerator Generate(Cell[,] maze, int width, int height);
	}
	public class KruskalAlgorithm : IMazeAlgorithm
	{
		private class Edge
		{
			public Vector2Int CellA;

			public Vector2Int CellB;

			public WallFlags WallA;

			public WallFlags WallB;
		}

		private class UnionFind
		{
			private int[] parent;

			private int[] rank;

			public UnionFind(int size)
			{
				parent = new int[size];
				rank = new int[size];
				for (int i = 0; i < size; i++)
				{
					parent[i] = i;
					rank[i] = 0;
				}
			}

			public int Find(int x)
			{
				if (parent[x] != x)
				{
					parent[x] = Find(parent[x]);
				}
				return parent[x];
			}

			public bool Union(int x, int y)
			{
				int num = Find(x);
				int num2 = Find(y);
				if (num == num2)
				{
					return false;
				}
				if (rank[num] < rank[num2])
				{
					parent[num] = num2;
				}
				else if (rank[num] > rank[num2])
				{
					parent[num2] = num;
				}
				else
				{
					parent[num2] = num;
					rank[num]++;
				}
				return true;
			}
		}

		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			List<Edge> edges = new List<Edge>();
			Stopwatch perfSw = Stopwatch.StartNew();
			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					if (x < width - 1)
					{
						edges.Add(new Edge
						{
							CellA = new Vector2Int(x, y),
							CellB = new Vector2Int(x + 1, y),
							WallA = WallFlags.East,
							WallB = WallFlags.West
						});
					}
					if (y < height - 1)
					{
						edges.Add(new Edge
						{
							CellA = new Vector2Int(x, y),
							CellB = new Vector2Int(x, y + 1),
							WallA = WallFlags.North,
							WallB = WallFlags.South
						});
					}
					if (perfSw.ElapsedMilliseconds > 16)
					{
						yield return null;
						perfSw.Restart();
					}
				}
			}
			yield return Shuffle(edges);
			UnionFind uf = new UnionFind(width * height);
			foreach (Edge item in edges)
			{
				int x2 = ((Vector2Int)(ref item.CellA)).y * width + ((Vector2Int)(ref item.CellA)).x;
				int y2 = ((Vector2Int)(ref item.CellB)).y * width + ((Vector2Int)(ref item.CellB)).x;
				if (uf.Union(x2, y2))
				{
					maze[((Vector2Int)(ref item.CellA)).x, ((Vector2Int)(ref item.CellA)).y].walls &= (WallFlags)(byte)(~(int)item.WallA);
					maze[((Vector2Int)(ref item.CellB)).x, ((Vector2Int)(ref item.CellB)).y].walls &= (WallFlags)(byte)(~(int)item.WallB);
				}
				if (perfSw.ElapsedMilliseconds > 16)
				{
					yield return null;
					perfSw.Restart();
				}
			}
			perfSw.Stop();
		}

		private IEnumerator Shuffle<T>(List<T> list)
		{
			Stopwatch perfSw = Stopwatch.StartNew();
			for (int i = list.Count - 1; i > 0; i--)
			{
				int num = Random.Range(0, i + 1);
				int index = i;
				int index2 = num;
				T value = list[num];
				T value2 = list[i];
				list[index] = value;
				list[index2] = value2;
				if (perfSw.ElapsedMilliseconds > 16)
				{
					yield return null;
					perfSw.Restart();
				}
			}
			perfSw.Stop();
		}
	}
	public class PrimAlgorithm : IMazeAlgorithm
	{
		private class WallInfo
		{
			public Vector2Int Cell;

			public WallFlags Wall;

			public Vector2Int Neighbor;
		}

		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			bool[,] inMaze = new bool[width, height];
			List<WallInfo> walls = new List<WallInfo>();
			Stopwatch perfSw = Stopwatch.StartNew();
			int num = Random.Range(0, width);
			int num2 = Random.Range(0, height);
			inMaze[num, num2] = true;
			AddWalls(maze, walls, inMaze, num, num2, width, height);
			while (walls.Count > 0)
			{
				int index = Random.Range(0, walls.Count);
				WallInfo wallInfo = walls[index];
				walls.RemoveAt(index);
				int x = ((Vector2Int)(ref wallInfo.Neighbor)).x;
				int y = ((Vector2Int)(ref wallInfo.Neighbor)).y;
				if (!inMaze[x, y])
				{
					maze[((Vector2Int)(ref wallInfo.Cell)).x, ((Vector2Int)(ref wallInfo.Cell)).y].walls &= (WallFlags)(byte)(~(int)wallInfo.Wall);
					maze[x, y].walls &= (WallFlags)(byte)(~(int)GetOppositeWall(wallInfo.Wall));
					inMaze[x, y] = true;
					AddWalls(maze, walls, inMaze, x, y, width, height);
				}
				if (perfSw.ElapsedMilliseconds > 16)
				{
					yield return null;
					perfSw.Restart();
				}
			}
			perfSw.Stop();
		}

		private void AddWalls(Cell[,] maze, List<WallInfo> walls, bool[,] inMaze, int x, int y, int width, int height)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			if (y < height - 1 && !inMaze[x, y + 1])
			{
				walls.Add(new WallInfo
				{
					Cell = new Vector2Int(x, y),
					Wall = WallFlags.North,
					Neighbor = new Vector2Int(x, y + 1)
				});
			}
			if (x < width - 1 && !inMaze[x + 1, y])
			{
				walls.Add(new WallInfo
				{
					Cell = new Vector2Int(x, y),
					Wall = WallFlags.East,
					Neighbor = new Vector2Int(x + 1, y)
				});
			}
			if (y > 0 && !inMaze[x, y - 1])
			{
				walls.Add(new WallInfo
				{
					Cell = new Vector2Int(x, y),
					Wall = WallFlags.South,
					Neighbor = new Vector2Int(x, y - 1)
				});
			}
			if (x > 0 && !inMaze[x - 1, y])
			{
				walls.Add(new WallInfo
				{
					Cell = new Vector2Int(x, y),
					Wall = WallFlags.West,
					Neighbor = new Vector2Int(x - 1, y)
				});
			}
		}

		private WallFlags GetOppositeWall(WallFlags wall)
		{
			return wall switch
			{
				WallFlags.North => WallFlags.South, 
				WallFlags.South => WallFlags.North, 
				WallFlags.East => WallFlags.West, 
				WallFlags.West => WallFlags.East, 
				_ => WallFlags.None, 
			};
		}
	}
	public class WilsonAlgorithm : IMazeAlgorithm
	{
		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			bool[,] inMaze = new bool[width, height];
			Vector2Int[] path = (Vector2Int[])(object)new Vector2Int[width * height];
			Stopwatch perfSw = Stopwatch.StartNew();
			int num = Random.Range(0, width);
			int num2 = Random.Range(0, height);
			inMaze[num, num2] = true;
			for (int x = 0; x < width; x++)
			{
				for (int y = 0; y < height; y++)
				{
					if (!inMaze[x, y])
					{
						int num3 = RandomWalk(x, y, inMaze, path, width, height);
						for (int i = 0; i < num3 - 1; i++)
						{
							Vector2Int a = path[i];
							Vector2Int b = path[i + 1];
							RemoveWallBetween(maze, a, b);
							inMaze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y] = true;
						}
						if (perfSw.ElapsedMilliseconds > 16)
						{
							yield return null;
							perfSw.Restart();
						}
					}
				}
			}
			perfSw.Stop();
		}

		private int RandomWalk(int startX, int startY, bool[,] inMaze, Vector2Int[] path, int width, int height)
		{
			//IL_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<Vector2Int, int> dictionary = new Dictionary<Vector2Int, int>();
			int num = 0;
			Vector2Int val = default(Vector2Int);
			((Vector2Int)(ref val))..ctor(startX, startY);
			path[num++] = val;
			dictionary[val] = 0;
			while (!inMaze[((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y])
			{
				List<Vector2Int> neighbors = GetNeighbors(val, width, height);
				val = neighbors[Random.Range(0, neighbors.Count)];
				if (dictionary.ContainsKey(val))
				{
					num = dictionary[val] + 1;
					continue;
				}
				dictionary[val] = num;
				path[num++] = val;
			}
			return num;
		}

		private List<Vector2Int> GetNeighbors(Vector2Int pos, int width, int height)
		{
			//IL_0021: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2Int> list = new List<Vector2Int>();
			if (((Vector2Int)(ref pos)).x > 0)
			{
				list.Add(new Vector2Int(((Vector2Int)(ref pos)).x - 1, ((Vector2Int)(ref pos)).y));
			}
			if (((Vector2Int)(ref pos)).x < width - 1)
			{
				list.Add(new Vector2Int(((Vector2Int)(ref pos)).x + 1, ((Vector2Int)(ref pos)).y));
			}
			if (((Vector2Int)(ref pos)).y > 0)
			{
				list.Add(new Vector2Int(((Vector2Int)(ref pos)).x, ((Vector2Int)(ref pos)).y - 1));
			}
			if (((Vector2Int)(ref pos)).y < height - 1)
			{
				list.Add(new Vector2Int(((Vector2Int)(ref pos)).x, ((Vector2Int)(ref pos)).y + 1));
			}
			return list;
		}

		private void RemoveWallBetween(Cell[,] maze, Vector2Int a, Vector2Int b)
		{
			int num = ((Vector2Int)(ref b)).x - ((Vector2Int)(ref a)).x;
			int num2 = ((Vector2Int)(ref b)).y - ((Vector2Int)(ref a)).y;
			switch (num)
			{
			case 1:
				maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.East;
				maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.West;
				return;
			case -1:
				maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.West;
				maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.East;
				return;
			}
			switch (num2)
			{
			case 1:
				maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.North;
				maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.South;
				break;
			case -1:
				maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.South;
				maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.North;
				break;
			}
		}
	}
}
namespace VELDDev.BackroomsRenewed.Config
{
	internal static class LethalConfigSupport
	{
		private static bool? lethalConfigLoaded;

		public static bool LethalConfigLoaded
		{
			get
			{
				bool valueOrDefault = lethalConfigLoaded == true;
				if (!lethalConfigLoaded.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
					lethalConfigLoaded = valueOrDefault;
				}
				return lethalConfigLoaded.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void RegisterLethalConfig(LocalConfig config)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0060: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00a4: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00f4: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0144: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_0195: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01e6: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_0237: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			//IL_027d: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Expected O, but got Unknown
			//IL_02e4: Expected O, but got Unknown
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Expected O, but got Unknown
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Expected O, but got Unknown
			//IL_034b: Expected O, but got Unknown
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Expected O, but got Unknown
			//IL_03b2: Expected O, but got Unknown
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Expected O, but got Unknown
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Expected O, but got Unknown
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Expected O, but got Unknown
			//IL_0419: Expected O, but got Unknown
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Expected O, but got Unknown
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Expected O, but got Unknown
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Expected O, but got Unknown
			//IL_0480: Expected O, but got Unknown
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Expected O, but got Unknown
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Expected O, but got Unknown
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Expected O, but got Unknown
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Expected O, but got Unknown
			//IL_04e7: Expected O, but got Unknown
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Expected O, but got Unknown
			//IL_0538: Expected O, but got Unknown
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Expected O, but got Unknown
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Expected O, but got Unknown
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Expected O, but got Unknown
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Expected O, but got Unknown
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Expected O, but got Unknown
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Expected O, but got Unknown
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Expected O, but got Unknown
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Expected O, but got Unknown
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Expected O, but got Unknown
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Expected O, but got Unknown
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Expected O, but got Unknown
			//IL_0663: Expected O, but got Unknown
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Expected O, but got Unknown
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Expected O, but got Unknown
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Expected O, but got Unknown
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Expected O, but got Unknown
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("CR#T#CAL FA#LUR#: UNKN#WN #NTERV#ENTI#N D#T#CT#D -- #/1?.!1'(>>> JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME");
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(config.StreamerMode, new BoolCheckBoxOptions
			{
				Name = "Streamer Mode",
				Description = "Enable streamer mode to disable copyrighted musics and replace with copyright-free alternatives.",
				Section = "General",
				RequiresRestart = false
			});
			BoolCheckBoxConfigItem val2 = new BoolCheckBoxConfigItem(config.UseFairRandomizer, new BoolCheckBoxOptions
			{
				Name = "Use Fair Randomization",
				Description = "Whether to use fair randomization (a.k.a. Pity System) or normal randomization for random events (e.g. TP)",
				Section = "General",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(config.TeleportOnDeath, new BoolCheckBoxOptions
			{
				Name = "Teleport on Death",
				Description = "Allows teleportation on death of player. See also 'Teleportation Odds on Death'.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val4 = new BoolCheckBoxConfigItem(config.TeleportOnClipping, new BoolCheckBoxOptions
			{
				Name = "Teleport on Clipping",
				Description = "Allows teleportation on clipping through walls. See also 'Teleportation Odds on Clipping'.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(config.TeleportOnDamage, new BoolCheckBoxOptions
			{
				Name = "Teleport on Damage",
				Description = "Allows teleportation on taking damage. See also 'Teleportation Odds on Damage'.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val6 = new BoolCheckBoxConfigItem(config.TeleportOnInteractDoor, new BoolCheckBoxOptions
			{
				Name = "Teleport on Entrance/Exit",
				Description = "Allows teleportation when entering/exiting the Facility. See also 'Teleportation Odds on Entrance/Exit'.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val7 = new BoolCheckBoxConfigItem(config.TeleportOnShipTeleport, new BoolCheckBoxOptions
			{
				Name = "Teleport on Ship TP",
				Description = "Allows teleportation when being teleported with the Ship Teleporter. See also 'Teleportation Odds on Ship TP'.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			BoolCheckBoxConfigItem val8 = new BoolCheckBoxConfigItem(config.TeleportOnShipRevertTeleport, new BoolCheckBoxOptions
			{
				Name = "Teleport on Ship Revert TP",
				Description = "Allows teleportation when being reverse teleported with the ship reverse TP. See also 'Teleportation Odds on Ship Rev TP'.",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			ConfigEntry<float> teleportationOddsOnDeath = config.TeleportationOddsOnDeath;
			FloatSliderOptions val9 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Death",
				Description = "The percentage chance of teleportation occurring on death.",
				Section = "Teleportation"
			};
			((BaseRangeOptions<float>)val9).Min = 0f;
			((BaseRangeOptions<float>)val9).Max = 100f;
			((BaseOptions)val9).RequiresRestart = false;
			((BaseOptions)val9).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnDeath.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val10 = new FloatSliderConfigItem(teleportationOddsOnDeath, val9);
			ConfigEntry<float> teleportationOddsOnClipping = config.TeleportationOddsOnClipping;
			FloatSliderOptions val11 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Clipping",
				Description = "The percentage chance of teleportation occurring on clipping through walls or ground.",
				Section = "Teleportation"
			};
			((BaseRangeOptions<float>)val11).Min = 0f;
			((BaseRangeOptions<float>)val11).Max = 100f;
			((BaseOptions)val11).RequiresRestart = false;
			((BaseOptions)val11).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnClipping.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val12 = new FloatSliderConfigItem(teleportationOddsOnClipping, val11);
			ConfigEntry<float> teleportationOddsOnDamage = config.TeleportationOddsOnDamage;
			FloatSliderOptions val13 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Damage",
				Description = "The percentage chance of teleportation occurring on taking damage.",
				Section = "Teleportation"
			};
			((BaseRangeOptions<float>)val13).Min = 0f;
			((BaseRangeOptions<float>)val13).Max = 100f;
			((BaseOptions)val13).RequiresRestart = false;
			((BaseOptions)val13).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnDamage.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val14 = new FloatSliderConfigItem(teleportationOddsOnDamage, val13);
			ConfigEntry<float> teleportationOddsOnInteractDoor = config.TeleportationOddsOnInteractDoor;
			FloatSliderOptions val15 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Entrance/Exit",
				Section = "Teleportation",
				Description = "The chance percentage of teleportation occurring on entering/exiting the Facility."
			};
			((BaseRangeOptions<float>)val15).Min = 0f;
			((BaseRangeOptions<float>)val15).Max = 100f;
			((BaseOptions)val15).RequiresRestart = false;
			((BaseOptions)val15).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnInteractDoor.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val16 = new FloatSliderConfigItem(teleportationOddsOnInteractDoor, val15);
			ConfigEntry<float> teleportationOddsOnShipTeleport = config.TeleportationOddsOnShipTeleport;
			FloatSliderOptions val17 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Ship TP",
				Section = "Teleportation",
				Description = "The chance percentage of teleportation occurring when being teleported with ship TP"
			};
			((BaseRangeOptions<float>)val17).Min = 0f;
			((BaseRangeOptions<float>)val17).Max = 100f;
			((BaseOptions)val17).RequiresRestart = false;
			((BaseOptions)val17).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnShipTeleport.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val18 = new FloatSliderConfigItem(teleportationOddsOnShipTeleport, val17);
			ConfigEntry<float> teleportationOddsOnShipRevertTeleport = config.TeleportationOddsOnShipRevertTeleport;
			FloatSliderOptions val19 = new FloatSliderOptions
			{
				Name = "Teleportation Odds on Ship Revert TP",
				Section = "Teleportation",
				Description = "The chance percentage of teleportation occurring when being reverse-teleported with ship reverse TP"
			};
			((BaseRangeOptions<float>)val19).Min = 0f;
			((BaseRangeOptions<float>)val19).Max = 100f;
			((BaseOptions)val19).RequiresRestart = false;
			((BaseOptions)val19).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnShipRevertTeleport.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb())));
			FloatSliderConfigItem val20 = new FloatSliderConfigItem(teleportationOddsOnShipRevertTeleport, val19);
			BoolCheckBoxConfigItem val21 = new BoolCheckBoxConfigItem(config.DropHeldItemsOnTeleport, new BoolCheckBoxOptions
			{
				Name = "Drop Items on Teleport",
				Description = "If enabled, will drop all the items when teleporting to the backrooms.",
				Section = "Teleportation",
				RequiresRestart = false,
				CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb)
			});
			EnumDropDownConfigItem<BackroomsGenerator.MazeAlgorithm> val22 = new EnumDropDownConfigItem<BackroomsGenerator.MazeAlgorithm>(config.GenerationAlgorithm, new EnumDropDownOptions
			{
				Name = "Backrooms Generation Algorithm",
				Description = "The maze generation algorithm used for Backrooms levels. (Blob is recommended for optimal aesthetics)",
				Section = "Generation",
				RequiresRestart = true
			});
			ConfigEntry<int> minBackroomsSize = config.MinBackroomsSize;
			IntSliderOptions val23 = new IntSliderOptions
			{
				Name = "Minimum Backrooms Size",
				Description = "The minimum size in cells (width and height) of generated Backrooms levels.",
				Section = "Generation"
			};
			((BaseRangeOptions<int>)val23).Min = 10;
			((BaseRangeOptions<int>)val23).Max = 50;
			((BaseOptions)val23).RequiresRestart = false;
			IntSliderConfigItem val24 = new IntSliderConfigItem(minBackroomsSize, val23);
			ConfigEntry<int> maxBackroomsSize = config.MaxBackroomsSize;
			IntSliderOptions val25 = new IntSliderOptions
			{
				Name = "Maximum Backrooms Size",
				Description = "The maximum size in cells (width and height) of generated Backrooms levels.",
				Section = "Generation"
			};
			((BaseRangeOptions<int>)val25).Min = 10;
			((BaseRangeOptions<int>)val25).Max = 50;
			((BaseOptions)val25).RequiresRestart = false;
			IntSliderConfigItem val26 = new IntSliderConfigItem(maxBackroomsSize, val25);
			ConfigEntry<int> maxFakeExitCount = config.MaxFakeExitCount;
			IntInputFieldOptions val27 = new IntInputFieldOptions
			{
				Name = "Maximum Fake Exits Count",
				Description = "The maximum number of fake exits that will appear in the Backrooms. They do not kill, just TP to somewhere else in the backrooms.",
				Section = "Generation",
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val27).Min = 0;
			((BaseRangeOptions<int>)val27).Max = 10;
			IntInputFieldConfigItem val28 = new IntInputFieldConfigItem(maxFakeExitCount, val27);
			ConfigEntry<int> exitCount = config.ExitCount;
			IntSliderOptions val29 = new IntSliderOptions
			{
				Name = "Exit Count",
				Description = "The number of real exit doors that will spawn in the Backrooms.",
				Section = "Generation"
			};
			((BaseRangeOptions<int>)val29).Min = 1;
			((BaseRangeOptions<int>)val29).Max = 10;
			((BaseOptions)val29).RequiresRestart = false;
			IntSliderConfigItem val30 = new IntSliderConfigItem(exitCount, val29);
			BoolCheckBoxConfigItem val31 = new BoolCheckBoxConfigItem(config.LegacyNavMeshGeneration, false);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val16);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val18);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val20);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val22);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val24);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val26);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val28);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val30);
			LethalConfigManager.AddConfigItem((BaseConfigItem)val31);
			static CanModifyResult NetworkAllowModifyCb()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				return CanModifyResult.op_Implicit((Synchronizable<SyncedConfig>.Synced && Synchronizable<SyncedConfig>.IsHost && NetworkManager.Singleton.IsServer) || !Synchronizable<SyncedConfig>.Synced);
			}
		}

		internal static void RegisterModIcon(Sprite modIcon)
		{
			LethalConfigManager.SetModIcon(modIcon);
		}
	}
	public class LocalConfig
	{
		internal const string ModDescription = "CR#T#CAL FA#LUR#: UNKN#WN #NTERV#ENTI#N D#T#CT#D -- #/1?.!1'(>>> JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME";

		public readonly ConfigEntry<bool> StreamerMode;

		public readonly ConfigEntry<bool> UseFairRandomizer;

		public readonly ConfigEntry<bool> TeleportOnDeath;

		public readonly ConfigEntry<bool> TeleportOnClipping;

		public readonly ConfigEntry<bool> TeleportOnDamage;

		public readonly ConfigEntry<bool> TeleportOnInteractDoor;

		public readonly ConfigEntry<bool> TeleportOnShipTeleport;

		public readonly ConfigEntry<bool> TeleportOnShipRevertTeleport;

		public readonly ConfigEntry<float> TeleportationOddsOnDeath;

		public readonly ConfigEntry<float> TeleportationOddsOnClipping;

		public readonly ConfigEntry<float> TeleportationOddsOnDamage;

		public readonly ConfigEntry<float> TeleportationOddsOnInteractDoor;

		public readonly ConfigEntry<float> TeleportationOddsOnShipTeleport;

		public readonly ConfigEntry<float> TeleportationOddsOnShipRevertTeleport;

		public readonly ConfigEntry<bool> DropHeldItemsOnTeleport;

		public readonly ConfigEntry<BackroomsGenerator.MazeAlgorithm> GenerationAlgorithm;

		public readonly ConfigEntry<int> MinBackroomsSize;

		public readonly ConfigEntry<int> MaxBackroomsSize;

		public readonly ConfigEntry<int> MaxFakeExitCount;

		public readonly ConfigEntry<int> ExitCount;

		public readonly ConfigEntry<bool> LegacyNavMeshGeneration;

		internal ConfigFile CfgFile;

		public static LocalConfig Singleton { get; private set; }

		public LocalConfig(ConfigFile cfg)
		{
			Singleton = this;
			CfgFile = cfg;
			StreamerMode = cfg.Bind<bool>("General", "Streamer Mode", false, "Enable streamer mode to disable copyrighted musics and replace with copyright-free alternatives.");
			UseFairRandomizer = cfg.Bind<bool>("General", "Use Fair Randomization", false, "Whether to use Fair Randomization (a.k.a. Pity system) for random events (e.g. TP) or use normal randomization.");
			TeleportOnDeath = cfg.Bind<bool>("Teleportation", "Teleport on Death", true, "Enable teleportation on death.");
			TeleportOnClipping = cfg.Bind<bool>("Teleportation", "Teleport on Clipping", true, "Enable teleportation on clipping through walls.");
			TeleportOnDamage = cfg.Bind<bool>("Teleportation", "Teleport on Damage", false, "Enable teleportation on taking damage.");
			TeleportOnInteractDoor = cfg.Bind<bool>("Teleportation", "Teleport on Entrance/Exit", true, "Enable teleportation when entering/exiting the facility");
			TeleportOnShipTeleport = cfg.Bind<bool>("Teleportation", "Teleport on Ship Teleport", true, "Enable teleportation when using Ship Teleporter");
			TeleportOnShipRevertTeleport = cfg.Bind<bool>("Teleportation", "Teleport on Ship Revert TP", true, "Enable teleportation when using the Ship Revert Teleporter");
			TeleportationOddsOnDeath = cfg.Bind<float>("Teleportation", "Teleportation Odds on Death", 10f, "The percentage chance of teleportation occurring on death.");
			TeleportationOddsOnClipping = cfg.Bind<float>("Teleportation", "Teleportation Odds on Clipping", 100f, "The chance percentage of teleportation occurring on clipping through walls.");
			TeleportationOddsOnDamage = cfg.Bind<float>("Teleportation", "Teleportation Odds on Damage", 1f, "The percentage chance of teleportation occurring on taking damage.");
			TeleportationOddsOnInteractDoor = cfg.Bind<float>("Teleportation", "Telportation Odds On Entrance/Exit", 0.1f, "The chance percentage of teleportation occurring when entering or exiting the facility");
			TeleportationOddsOnShipTeleport = cfg.Bind<float>("Teleportation", "Teleportation Odds on Ship Teleport", 0.1f, "The chance percentage of teleportation occurring when using the ship teleporter.");
			TeleportationOddsOnShipRevertTeleport = cfg.Bind<float>("Teleportation", "Teleportation Odds on Ship Revert TP", 1f, "The chance percentage of teleportation occurring when using the ship revert teleporter");
			DropHeldItemsOnTeleport = cfg.Bind<bool>("Teleportation", "Drop All Held Items On TP", f