Decompiled source of Backrooms Renewed v0.1.0

BepInEx/plugins/BackroomsRenewed/LC-Backrooms-Renewed.dll

Decompiled 4 hours 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyCompany("VELD-Dev")]
[assembly: AssemblyProduct("B#CKR##MS R#N#W#D")]
[assembly: AssemblyCopyright("GPL-3.0 License")]
[assembly: AssemblyTitle("Backrooms Renewed")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VELDDev.BackroomsRenewed
{
	[BepInPlugin("VELDDev.BackroomsRenewed", "Backrooms Renewed", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public class AchievementAssets : AssetBundleLoader<AchievementAssets>
		{
			public AchievementAssets(DuskMod mod, string filePath)
				: base(mod, filePath)
			{
			}
		}

		private Harmony harmony = new Harmony("VELDDev.BackroomsRenewed");

		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 flag = Chainloader.PluginInfos.ContainsKey("Neekhaulas.Backrooms");
			Instance = this;
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"/// B##CKR##MS R#N#W#D \\\\\\");
			if (flag)
			{
				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);
			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");
			CellBehaviour[] array = assetBundle.LoadAllAssets<CellBehaviour>();
			DawnLib.RegisterNetworkPrefab(BackroomsPrefab);
			CellBehaviour[] array2 = array;
			foreach (CellBehaviour cellBehaviour in array2)
			{
				DawnLib.RegisterNetworkPrefab(((Component)cellBehaviour).gameObject);
			}
		}

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

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

		public const string GUID = "VELDDev.BackroomsRenewed";

		public const string Author = "VELD-Dev";

		public const string Version = "0.1.0";
	}
	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 = null;

		private NetworkList<float> _luckValues = null;

		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];
			}
			float num2 = Random.Range(0f, 1f);
			if (num2 < 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)
		{
			int index;
			return TryGetLuckIndex(eventType, out index) ? _luckValues[index] : 0f;
		}

		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 val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(85182172u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 85182172u, val, (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 val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2203742615u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<FairRandomizerEvent>(ref eventType, default(ForEnums));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2203742615u, val, (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 val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1774933182u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1774933182u, val, (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_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_006b: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsServer)
			{
				if (Object.op_Implicit((Object)(object)Backrooms.Instance))
				{
					((Component)Backrooms.Instance).GetComponent<NetworkObject>().Despawn(true);
					Backrooms.Instance = null;
				}
				GameObject val = Object.Instantiate<GameObject>(Plugin.Instance.BackroomsPrefab, new Vector3(1000f, 50f, 0f), Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(true);
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class ShipTeleporter_Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch("beamUpPlayer")]
		public static void BeamUpPlayerToBackrooms(ShipTeleporter __instance)
		{
			if (!__instance.isInverseTeleporter && Synchronizable<SyncedConfig>.Instance.TeleportOnShipTP)
			{
				PlayerControllerB targetedPlayer = StartOfRound.Instance.mapScreen.targetedPlayer;
				if (!((Object)(object)targetedPlayer == (Object)null) && !Backrooms.Instance.PlayersInBackrooms.Contains(targetedPlayer.playerClientId) && CheckTeleportChance(targetedPlayer, FairRandomizerEvent.ShipTP, Synchronizable<SyncedConfig>.Instance.TeleportationOddsOnShipTP))
				{
					Backrooms.Instance.TeleportPlayerToBackrooms(targetedPlayer, 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) && 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
		}

		[CompilerGenerated]
		private sealed class <Generate>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BackroomsGenerator <>4__this;

			private MazeAlgorithm <>s__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = <>4__this.InitializeMaze();
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					<>s__1 = <>4__this.algorithm;
					if (1 == 0)
					{
					}
					IMazeAlgorithm currentAlgorithm = <>s__1 switch
					{
						MazeAlgorithm.Kruskal => new KruskalAlgorithm(), 
						MazeAlgorithm.Prim => new PrimAlgorithm(), 
						MazeAlgorithm.Wilson => new WilsonAlgorithm(), 
						MazeAlgorithm.Blob => new BlobAlgorithm(), 
						_ => throw new NotImplementedException(), 
					};
					if (1 == 0)
					{
					}
					<>4__this.currentAlgorithm = currentAlgorithm;
					<>2__current = <>4__this.currentAlgorithm.Generate(<>4__this.cells, <>4__this.width, <>4__this.height);
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					<>4__this.RemoveRandomWalls(<>4__this.wallRemovalFraction);
					<>4__this.PlaceExits();
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <InitializeMaze>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BackroomsGenerator <>4__this;

			private int <x>5__1;

			private int <y>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<y>5__2++;
					goto IL_00c4;
				}
				<>1__state = -1;
				<>4__this.cells = new Cell[<>4__this.width, <>4__this.height];
				<x>5__1 = 0;
				goto IL_00ec;
				IL_00c4:
				if (<y>5__2 < <>4__this.height)
				{
					<>4__this.cells[<x>5__1, <y>5__2] = new Cell
					{
						position = new Vector2Int(<x>5__1, <y>5__2)
					};
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<x>5__1++;
				goto IL_00ec;
				IL_00ec:
				if (<x>5__1 < <>4__this.width)
				{
					<y>5__2 = 0;
					goto IL_00c4;
				}
				return false;
			}

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

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

		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;

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

		private void RemoveRandomWalls(float fraction)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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) != 0)
					{
						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) != 0)
					{
						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);
			}
		}

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

		private void PlaceExits()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0007: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<WallFlags>*)(&serializer))->SerializeValue<WallFlags>(ref walls, default(ForEnums));
			serializer.SerializeValue(ref position);
		}

		public bool Equals(Cell? other)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!other.HasValue)
			{
				return false;
			}
			if ((object)this == (object)other)
			{
				return true;
			}
			return walls == other?.walls && ((object)(Vector2Int)(ref position)).Equals((object?)other?.position);
		}

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

		public override int GetHashCode()
		{
			//IL_0008: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			return walls == other.walls && ((Vector2Int)(ref position)).Equals(other.position);
		}
	}
	[RequireComponent(typeof(NetworkObject))]
	public class CellBehaviour : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <TwinkleCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AnimationCurve intensityCurve;

			public float duration;

			public CellBehaviour <>4__this;

			private float <elapsed>5__1;

			private float <intensity>5__2;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<elapsed>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__1 < duration)
				{
					<elapsed>5__1 += Time.deltaTime;
					<intensity>5__2 = intensityCurve.Evaluate(<elapsed>5__1 / duration) * <>4__this.DefaultLightIntensity;
					<>4__this.cellLightSource.intensity = <intensity>5__2;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.cellLightSource.intensity = (<>4__this.defaultLightState ? <>4__this.DefaultLightIntensity : 0f);
				return false;
			}

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

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

		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 = false;

		public bool defaultLightState = false;

		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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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 val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1123228270u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<Cell>(ref cell, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref withLight, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref lightState, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1123228270u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			_representation = cell;
			hasLightSource = withLight;
			defaultLightState = lightState;
			UpdateWalls();
			Plugin.Instance.logger.LogInfo((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.LogWarning((object)$"Cell {cell.position} initialized with light source disabled.");
				LightObject.SetActive(false);
				((Renderer)CeilingMR).SetMaterials(new List<Material>(2) { ceilingMat, ceilingMat });
				return;
			}
			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);
			if (!defaultLightState)
			{
				((Renderer)CeilingMR).SetMaterials(new List<Material>(2) { lightOffMat, ceilingMat });
			}
		}

		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));
				Plugin.Instance.logger.LogInfo((object)$"Twinkle started for duration:{duration} seconds");
			}
		}

		[IteratorStateMachine(typeof(<TwinkleCoroutine>d__19))]
		private IEnumerator TwinkleCoroutine(AnimationCurve intensityCurve, float duration)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TwinkleCoroutine>d__19(0)
			{
				<>4__this = this,
				intensityCurve = intensityCurve,
				duration = duration
			};
		}

		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 = false;
	}
	public class ExitBackroom : NetworkBehaviour
	{
		public void TeleportOutsideTheBackrooms()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			Transform thisPlayerBody = GameNetworkManager.Instance.localPlayerController.thisPlayerBody;
			localPlayerController.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[localPlayerController.playerClientId].position, false, 0f, false, true);
			localPlayerController.isInsideFactory = false;
			Backrooms.Instance.StopPlayingAmbientAudios();
			Backrooms.Instance.PlayersInBackrooms.Remove(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;
		}

		[CompilerGenerated]
		private sealed class <Generate>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Cell[,] maze;

			public int width;

			public int height;

			public BlobAlgorithm <>4__this;

			private Dictionary<Vector2Int, Blob> <cellToBlob>5__1;

			private List<Blob> <blobs>5__2;

			private int <blobIdCounter>5__3;

			private Stopwatch <perfSw>5__4;

			private List<Vector2Int> <allCells>5__5;

			private int <x>5__6;

			private int <y>5__7;

			private Vector2Int <pos>5__8;

			private Blob <blob>5__9;

			private int <x>5__10;

			private int <y>5__11;

			private Vector2Int <currentCell>5__12;

			private Blob <currentBlob>5__13;

			private List<MergeCandidate> <mergeCandidates>5__14;

			private MergeCandidate <merge>5__15;

			private Blob <blobA>5__16;

			private Blob <blobB>5__17;

			private List<Vector2Int>.Enumerator <>s__18;

			private Vector2Int <cell>5__19;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<cellToBlob>5__1 = null;
				<blobs>5__2 = null;
				<perfSw>5__4 = null;
				<allCells>5__5 = null;
				<blob>5__9 = null;
				<currentBlob>5__13 = null;
				<mergeCandidates>5__14 = null;
				<merge>5__15 = null;
				<blobA>5__16 = null;
				<blobB>5__17 = null;
				<>s__18 = default(List<Vector2Int>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0293: Unknown result type (might be due to invalid IL or missing references)
				//IL_0298: 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_02bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0409: Unknown result type (might be due to invalid IL or missing references)
				//IL_040e: Unknown result type (might be due to invalid IL or missing references)
				//IL_041b: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<cellToBlob>5__1 = new Dictionary<Vector2Int, Blob>();
					<blobs>5__2 = new List<Blob>();
					<blobIdCounter>5__3 = 0;
					<perfSw>5__4 = Stopwatch.StartNew();
					<x>5__6 = 0;
					goto IL_0170;
				case 1:
					<>1__state = -1;
					<perfSw>5__4.Restart();
					goto IL_0132;
				case 2:
					<>1__state = -1;
					<perfSw>5__4.Restart();
					goto IL_0201;
				case 3:
					<>1__state = -1;
					goto IL_04cd;
				case 4:
					{
						<>1__state = -1;
						<perfSw>5__4.Restart();
						goto IL_04be;
					}
					IL_04cd:
					if (<blobs>5__2.Count > 1)
					{
						<currentCell>5__12 = <allCells>5__5[Random.Range(0, <allCells>5__5.Count)];
						<currentBlob>5__13 = <cellToBlob>5__1[<currentCell>5__12];
						<mergeCandidates>5__14 = <>4__this.FindMergeCandidates(<currentCell>5__12, <currentBlob>5__13, <cellToBlob>5__1, width, height);
						if (<mergeCandidates>5__14.Count > 0)
						{
							<merge>5__15 = <mergeCandidates>5__14[Random.Range(0, <mergeCandidates>5__14.Count)];
							maze[((Vector2Int)(ref <merge>5__15.CellA)).x, ((Vector2Int)(ref <merge>5__15.CellA)).y].walls &= (WallFlags)(byte)(~(int)<merge>5__15.WallA);
							maze[((Vector2Int)(ref <merge>5__15.CellB)).x, ((Vector2Int)(ref <merge>5__15.CellB)).y].walls &= (WallFlags)(byte)(~(int)<merge>5__15.WallB);
							<blobA>5__16 = <cellToBlob>5__1[<merge>5__15.CellA];
							<blobB>5__17 = <cellToBlob>5__1[<merge>5__15.CellB];
							<blobA>5__16.Merge(<blobB>5__17);
							<>s__18 = <blobB>5__17.Cells.GetEnumerator();
							try
							{
								while (<>s__18.MoveNext())
								{
									<cell>5__19 = <>s__18.Current;
									<cellToBlob>5__1[<cell>5__19] = <blobA>5__16;
								}
							}
							finally
							{
								((IDisposable)<>s__18).Dispose();
							}
							<>s__18 = default(List<Vector2Int>.Enumerator);
							<blobs>5__2.Remove(<blobB>5__17);
							<merge>5__15 = null;
							<blobA>5__16 = null;
							<blobB>5__17 = null;
						}
						if (<perfSw>5__4.ElapsedMilliseconds > 16)
						{
							<>2__current = null;
							<>1__state = 4;
							return true;
						}
						goto IL_04be;
					}
					<perfSw>5__4.Stop();
					return false;
					IL_0237:
					if (<x>5__10 < width)
					{
						<y>5__11 = 0;
						goto IL_0212;
					}
					<>2__current = <>4__this.ShuffleCells(<allCells>5__5);
					<>1__state = 3;
					return true;
					IL_0132:
					<blob>5__9 = null;
					<y>5__7++;
					goto IL_014a;
					IL_0212:
					if (<y>5__11 < height)
					{
						<allCells>5__5.Add(new Vector2Int(<x>5__10, <y>5__11));
						if (<perfSw>5__4.ElapsedMilliseconds > 16)
						{
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
						goto IL_0201;
					}
					<x>5__10++;
					goto IL_0237;
					IL_0201:
					<y>5__11++;
					goto IL_0212;
					IL_014a:
					if (<y>5__7 < height)
					{
						<pos>5__8 = new Vector2Int(<x>5__6, <y>5__7);
						<blob>5__9 = new Blob(<blobIdCounter>5__3++);
						<blob>5__9.Cells.Add(<pos>5__8);
						<blobs>5__2.Add(<blob>5__9);
						<cellToBlob>5__1[<pos>5__8] = <blob>5__9;
						if (<perfSw>5__4.ElapsedMilliseconds > 16)
						{
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
						goto IL_0132;
					}
					<x>5__6++;
					goto IL_0170;
					IL_04be:
					<currentBlob>5__13 = null;
					<mergeCandidates>5__14 = null;
					goto IL_04cd;
					IL_0170:
					if (<x>5__6 < width)
					{
						<y>5__7 = 0;
						goto IL_014a;
					}
					<allCells>5__5 = new List<Vector2Int>();
					<x>5__10 = 0;
					goto IL_0237;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <ShuffleCells>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public List<Vector2Int> cells;

			public BlobAlgorithm <>4__this;

			private Stopwatch <perfSw>5__1;

			private int <i>5__2;

			private int <j>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//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_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<perfSw>5__1.Restart();
					goto IL_00ea;
				}
				<>1__state = -1;
				<perfSw>5__1 = Stopwatch.StartNew();
				<i>5__2 = cells.Count - 1;
				goto IL_00fb;
				IL_00ea:
				<i>5__2--;
				goto IL_00fb;
				IL_00fb:
				if (<i>5__2 > 0)
				{
					<j>5__3 = Random.Range(0, <i>5__2 + 1);
					List<Vector2Int> list = cells;
					int index = <i>5__2;
					List<Vector2Int> list2 = cells;
					int index2 = <j>5__3;
					Vector2Int value = cells[<j>5__3];
					Vector2Int value2 = cells[<i>5__2];
					list[index] = value;
					list2[index2] = value2;
					if (<perfSw>5__1.ElapsedMilliseconds > 16)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_00ea;
				}
				<perfSw>5__1.Stop();
				return false;
			}

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

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

		[IteratorStateMachine(typeof(<Generate>d__2))]
		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Generate>d__2(0)
			{
				<>4__this = this,
				maze = maze,
				width = width,
				height = height
			};
		}

		private List<MergeCandidate> FindMergeCandidates(Vector2Int cell, Blob currentBlob, Dictionary<Vector2Int, Blob> cellToBlob, int width, int height)
		{
			//IL_0011: 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_003b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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)
			};
			(Vector2Int, WallFlags, WallFlags)[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				(Vector2Int, WallFlags, WallFlags) tuple = array2[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;
		}

		[IteratorStateMachine(typeof(<ShuffleCells>d__4))]
		private IEnumerator ShuffleCells(List<Vector2Int> cells)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ShuffleCells>d__4(0)
			{
				<>4__this = this,
				cells = cells
			};
		}
	}
	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;
			}
		}

		[CompilerGenerated]
		private sealed class <Generate>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Cell[,] maze;

			public int width;

			public int height;

			public KruskalAlgorithm <>4__this;

			private List<Edge> <edges>5__1;

			private Stopwatch <perfSw>5__2;

			private UnionFind <uf>5__3;

			private int <x>5__4;

			private int <y>5__5;

			private List<Edge>.Enumerator <>s__6;

			private Edge <edge>5__7;

			private int <idA>5__8;

			private int <idB>5__9;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 3)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<edges>5__1 = null;
				<perfSw>5__2 = null;
				<uf>5__3 = null;
				<>s__6 = default(List<Edge>.Enumerator);
				<edge>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<edges>5__1 = new List<Edge>();
						<perfSw>5__2 = Stopwatch.StartNew();
						<x>5__4 = 0;
						goto IL_01b6;
					case 1:
						<>1__state = -1;
						<perfSw>5__2.Restart();
						goto IL_0179;
					case 2:
						<>1__state = -1;
						<uf>5__3 = new UnionFind(width * height);
						<>s__6 = <edges>5__1.GetEnumerator();
						<>1__state = -3;
						goto IL_0388;
					case 3:
						{
							<>1__state = -3;
							<perfSw>5__2.Restart();
							goto IL_0380;
						}
						IL_0388:
						if (<>s__6.MoveNext())
						{
							<edge>5__7 = <>s__6.Current;
							<idA>5__8 = ((Vector2Int)(ref <edge>5__7.CellA)).y * width + ((Vector2Int)(ref <edge>5__7.CellA)).x;
							<idB>5__9 = ((Vector2Int)(ref <edge>5__7.CellB)).y * width + ((Vector2Int)(ref <edge>5__7.CellB)).x;
							if (<uf>5__3.Union(<idA>5__8, <idB>5__9))
							{
								maze[((Vector2Int)(ref <edge>5__7.CellA)).x, ((Vector2Int)(ref <edge>5__7.CellA)).y].walls &= (WallFlags)(byte)(~(int)<edge>5__7.WallA);
								maze[((Vector2Int)(ref <edge>5__7.CellB)).x, ((Vector2Int)(ref <edge>5__7.CellB)).y].walls &= (WallFlags)(byte)(~(int)<edge>5__7.WallB);
							}
							if (<perfSw>5__2.ElapsedMilliseconds > 16)
							{
								<>2__current = null;
								<>1__state = 3;
								return true;
							}
							goto IL_0380;
						}
						<>m__Finally1();
						<>s__6 = default(List<Edge>.Enumerator);
						<perfSw>5__2.Stop();
						return false;
						IL_01b6:
						if (<x>5__4 < width)
						{
							<y>5__5 = 0;
							goto IL_018c;
						}
						<>2__current = <>4__this.Shuffle(<edges>5__1);
						<>1__state = 2;
						return true;
						IL_0179:
						<y>5__5++;
						goto IL_018c;
						IL_018c:
						if (<y>5__5 < height)
						{
							if (<x>5__4 < width - 1)
							{
								<edges>5__1.Add(new Edge
								{
									CellA = new Vector2Int(<x>5__4, <y>5__5),
									CellB = new Vector2Int(<x>5__4 + 1, <y>5__5),
									WallA = WallFlags.East,
									WallB = WallFlags.West
								});
							}
							if (<y>5__5 < height - 1)
							{
								<edges>5__1.Add(new Edge
								{
									CellA = new Vector2Int(<x>5__4, <y>5__5),
									CellB = new Vector2Int(<x>5__4, <y>5__5 + 1),
									WallA = WallFlags.North,
									WallB = WallFlags.South
								});
							}
							if (<perfSw>5__2.ElapsedMilliseconds > 16)
							{
								<>2__current = null;
								<>1__state = 1;
								return true;
							}
							goto IL_0179;
						}
						<x>5__4++;
						goto IL_01b6;
						IL_0380:
						<edge>5__7 = null;
						goto IL_0388;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__6).Dispose();
			}

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

		[CompilerGenerated]
		private sealed class <Shuffle>d__3<T> : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public List<T> list;

			public KruskalAlgorithm <>4__this;

			private Stopwatch <perfSw>5__1;

			private int <i>5__2;

			private int <j>5__3;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<perfSw>5__1.Restart();
					goto IL_00ea;
				}
				<>1__state = -1;
				<perfSw>5__1 = Stopwatch.StartNew();
				<i>5__2 = this.list.Count - 1;
				goto IL_00fb;
				IL_00ea:
				<i>5__2--;
				goto IL_00fb;
				IL_00fb:
				if (<i>5__2 > 0)
				{
					<j>5__3 = Random.Range(0, <i>5__2 + 1);
					List<T> list = this.list;
					int index = <i>5__2;
					List<T> obj = this.list;
					int index2 = <j>5__3;
					T value = this.list[<j>5__3];
					T value2 = this.list[<i>5__2];
					list[index] = value;
					obj[index2] = value2;
					if (<perfSw>5__1.ElapsedMilliseconds > 16)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_00ea;
				}
				<perfSw>5__1.Stop();
				return false;
			}

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

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

		[IteratorStateMachine(typeof(<Generate>d__2))]
		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Generate>d__2(0)
			{
				<>4__this = this,
				maze = maze,
				width = width,
				height = height
			};
		}

		[IteratorStateMachine(typeof(<Shuffle>d__3<>))]
		private IEnumerator Shuffle<T>(List<T> list)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Shuffle>d__3<T>(0)
			{
				<>4__this = this,
				list = list
			};
		}
	}
	public class PrimAlgorithm : IMazeAlgorithm
	{
		private class WallInfo
		{
			public Vector2Int Cell;

			public WallFlags Wall;

			public Vector2Int Neighbor;
		}

		[CompilerGenerated]
		private sealed class <Generate>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Cell[,] maze;

			public int width;

			public int height;

			public PrimAlgorithm <>4__this;

			private bool[,] <inMaze>5__1;

			private List<WallInfo> <walls>5__2;

			private Stopwatch <perfSw>5__3;

			private int <startX>5__4;

			private int <startY>5__5;

			private int <index>5__6;

			private WallInfo <wall>5__7;

			private int <nx>5__8;

			private int <ny>5__9;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<inMaze>5__1 = null;
				<walls>5__2 = null;
				<perfSw>5__3 = null;
				<wall>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<perfSw>5__3.Restart();
					goto IL_0257;
				}
				<>1__state = -1;
				<inMaze>5__1 = new bool[width, height];
				<walls>5__2 = new List<WallInfo>();
				<perfSw>5__3 = Stopwatch.StartNew();
				<startX>5__4 = Random.Range(0, width);
				<startY>5__5 = Random.Range(0, height);
				<inMaze>5__1[<startX>5__4, <startY>5__5] = true;
				<>4__this.AddWalls(maze, <walls>5__2, <inMaze>5__1, <startX>5__4, <startY>5__5, width, height);
				goto IL_025f;
				IL_0257:
				<wall>5__7 = null;
				goto IL_025f;
				IL_025f:
				if (<walls>5__2.Count > 0)
				{
					<index>5__6 = Random.Range(0, <walls>5__2.Count);
					<wall>5__7 = <walls>5__2[<index>5__6];
					<walls>5__2.RemoveAt(<index>5__6);
					<nx>5__8 = ((Vector2Int)(ref <wall>5__7.Neighbor)).x;
					<ny>5__9 = ((Vector2Int)(ref <wall>5__7.Neighbor)).y;
					if (!<inMaze>5__1[<nx>5__8, <ny>5__9])
					{
						maze[((Vector2Int)(ref <wall>5__7.Cell)).x, ((Vector2Int)(ref <wall>5__7.Cell)).y].walls &= (WallFlags)(byte)(~(int)<wall>5__7.Wall);
						maze[<nx>5__8, <ny>5__9].walls &= (WallFlags)(byte)(~(int)<>4__this.GetOppositeWall(<wall>5__7.Wall));
						<inMaze>5__1[<nx>5__8, <ny>5__9] = true;
						<>4__this.AddWalls(maze, <walls>5__2, <inMaze>5__1, <nx>5__8, <ny>5__9, width, height);
					}
					if (<perfSw>5__3.ElapsedMilliseconds > 16)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_0257;
				}
				<perfSw>5__3.Stop();
				return false;
			}

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

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

		[IteratorStateMachine(typeof(<Generate>d__1))]
		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Generate>d__1(0)
			{
				<>4__this = this,
				maze = maze,
				width = width,
				height = height
			};
		}

		private void AddWalls(Cell[,] maze, List<WallInfo> walls, bool[,] inMaze, int x, int y, int width, int height)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_007e: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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)
		{
			if (1 == 0)
			{
			}
			WallFlags result = wall switch
			{
				WallFlags.North => WallFlags.South, 
				WallFlags.South => WallFlags.North, 
				WallFlags.East => WallFlags.West, 
				WallFlags.West => WallFlags.East, 
				_ => WallFlags.None, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	public class WilsonAlgorithm : IMazeAlgorithm
	{
		[CompilerGenerated]
		private sealed class <Generate>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Cell[,] maze;

			public int width;

			public int height;

			public WilsonAlgorithm <>4__this;

			private bool[,] <inMaze>5__1;

			private Vector2Int[] <path>5__2;

			private Stopwatch <perfSw>5__3;

			private int <startX>5__4;

			private int <startY>5__5;

			private int <x>5__6;

			private int <y>5__7;

			private int <pathLength>5__8;

			private int <i>5__9;

			private Vector2Int <current>5__10;

			private Vector2Int <next>5__11;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<inMaze>5__1 = null;
				<path>5__2 = null;
				<perfSw>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					<perfSw>5__3.Restart();
					goto IL_01e9;
				}
				<>1__state = -1;
				<inMaze>5__1 = new bool[width, height];
				<path>5__2 = (Vector2Int[])(object)new Vector2Int[width * height];
				<perfSw>5__3 = Stopwatch.StartNew();
				<startX>5__4 = Random.Range(0, width);
				<startY>5__5 = Random.Range(0, height);
				<inMaze>5__1[<startX>5__4, <startY>5__5] = true;
				<x>5__6 = 0;
				goto IL_0221;
				IL_0221:
				if (<x>5__6 < width)
				{
					<y>5__7 = 0;
					goto IL_01f9;
				}
				<perfSw>5__3.Stop();
				return false;
				IL_01f9:
				if (<y>5__7 < height)
				{
					if (!<inMaze>5__1[<x>5__6, <y>5__7])
					{
						<pathLength>5__8 = <>4__this.RandomWalk(<x>5__6, <y>5__7, <inMaze>5__1, <path>5__2, width, height);
						<i>5__9 = 0;
						while (<i>5__9 < <pathLength>5__8 - 1)
						{
							<current>5__10 = <path>5__2[<i>5__9];
							<next>5__11 = <path>5__2[<i>5__9 + 1];
							<>4__this.RemoveWallBetween(maze, <current>5__10, <next>5__11);
							<inMaze>5__1[((Vector2Int)(ref <current>5__10)).x, ((Vector2Int)(ref <current>5__10)).y] = true;
							<i>5__9++;
						}
						if (<perfSw>5__3.ElapsedMilliseconds > 16)
						{
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
					}
					goto IL_01e9;
				}
				<x>5__6++;
				goto IL_0221;
				IL_01e9:
				<y>5__7++;
				goto IL_01f9;
			}

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

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

		[IteratorStateMachine(typeof(<Generate>d__0))]
		public IEnumerator Generate(Cell[,] maze, int width, int height)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Generate>d__0(0)
			{
				<>4__this = this,
				maze = maze,
				width = width,
				height = height
			};
		}

		private int RandomWalk(int startX, int startY, bool[,] inMaze, Vector2Int[] path, int width, int height)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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.GetValueOrDefault();
				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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: 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_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: 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_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Expected O, but got Unknown
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Expected O, but got Unknown
			//IL_0352: Expected O, but got Unknown
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected O, but got Unknown
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_03c0: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Expected O, but got Unknown
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Expected O, but got Unknown
			//IL_042e: Expected O, but got Unknown
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Expected O, but got Unknown
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: 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_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Expected O, but got Unknown
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Expected O, but got Unknown
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Expected O, but got Unknown
			//IL_049c: Expected O, but got Unknown
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Expected O, but got Unknown
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Expected O, but got Unknown
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Expected O, but got Unknown
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Expected O, but got Unknown
			//IL_050a: Expected O, but got Unknown
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Expected O, but got Unknown
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Expected O, but got Unknown
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Expected O, but got Unknown
			//IL_0558: 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_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Expected O, but got Unknown
			//IL_0578: Expected O, but got Unknown
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Expected O, but got Unknown
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Expected O, but got Unknown
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Expected O, but got Unknown
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Expected O, but got Unknown
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Expected O, but got Unknown
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Expected O, but got Unknown
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Expected O, but got Unknown
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Expected O, but got Unknown
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Expected O, but got Unknown
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Expected O, but got Unknown
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Expected O, but got Unknown
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c4: Expected O, but got Unknown
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Expected O, but got Unknown
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references