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.4")] [assembly: AssemblyInformationalVersion("0.1.4")] [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.4.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VELDDev.BackroomsRenewed { [BepInPlugin("VELDDev.BackroomsRenewed", "Backrooms Renewed", "0.1.4")] public class Plugin : BaseUnityPlugin { public class AchievementAssets : AssetBundleLoader { 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 <>: The other backroom mod is already here !"); return; } harmony.PatchAll(); logger.LogInfo((object)">>> [x] P#TCH#S #PPL##D"); Configs = new LocalConfig(((BaseUnityPlugin)this).Config); logger.LogInfo((object)">>> [x] C#NF#G L##D#D"); assetBundle = AssetBundle.LoadFromFile(Path.Combine(PluginDir, "backroomsrenewed_assets")); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(PluginDir, "backroomsrenewed_toc")); RegisterPrefabs(); mod = DuskMod.RegisterMod((BaseUnityPlugin)(object)this, val); LethalConfigSupport.RegisterModIcon(mod.ModInformation.ModIcon); logger.LogInfo((object)">>> [x] #SS#T B#NDL# L##D#D; #SS#TS L##D#D"); RegisterAchievements(); logger.LogInfo((object)">>> [x] #CHI#V#EM#NTS LO#D#D"); logger.LogInfo((object)"\\\\\\ /!\\ #RR#R: #NT#GR#T# CH#CK F##L#R# -- PR#C##D C#R#F#LL# /!\\ ///"); logger.LogInfo((object)">>> Entering the b--#c__ro#^m:s~"); } private void RegisterPrefabs() { BackroomsPrefab = assetBundle.LoadAsset("Backrooms"); CellBehaviour[] array = assetBundle.LoadAllAssets(); 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)(object)achievements).AssetBundleData); } private static void InitializeTypes() { InitializeNetworkBehaviour(typeof(Backrooms)); InitializeNetworkBehaviour(typeof(CellBehaviour)); InitializeNetworkBehaviour(typeof(FairRandomizer)); InitializeNetworkBehaviour(typeof(Cell)); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } 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.4"; } 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 StringToEventMap = new ReadOnlyDictionary(new Dictionary { { "OnDeath", FairRandomizerEvent.Death }, { "OnEnterFacility", FairRandomizerEvent.OpenDoor }, { "OnDamage", FairRandomizerEvent.Damage }, { "OnClipping", FairRandomizerEvent.Clipping }, { "OnShipTP", FairRandomizerEvent.ShipTP }, { "OnShipRevTP", FairRandomizerEvent.ShipRevTP } }); private NetworkList _luckKeys = null; private NetworkList _luckValues = null; private void Awake() { _luckKeys = new NetworkList((IEnumerable)null, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); _luckValues = new NetworkList((IEnumerable)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 val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(85182172u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref eventType, default(ForEnums)); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 85182172u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (TryGetLuckIndex(eventType, out var index)) { _luckValues[index] = 0f; } } } [ServerRpc(RequireOwnership = false)] private void IncreaseLuckServerRpc(FairRandomizerEvent eventType, float amount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2203742615u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref eventType, default(ForEnums)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref amount, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2203742615u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (TryGetLuckIndex(eventType, out var index)) { _luckValues[index] += amount; Plugin.Instance.logger.LogDebug((object)$"Increased luck for {eventType} by {amount}, new value: {_luckValues[index]}"); } } } [ServerRpc(RequireOwnership = false)] private void ResetAllLuckServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1774933182u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1774933182u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; for (int i = 0; i < _luckValues.Count; i++) { _luckValues[i] = 0f; } } } public override void OnDestroy() { ((NetworkBehaviour)this).OnDestroy(); NetworkList luckKeys = _luckKeys; if (luckKeys != null) { ((NetworkVariableBase)luckKeys).Dispose(); } NetworkList 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(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(ref eventType, default(ForEnums)); float amount = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(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.Instance.TeleportOnInteractDoor) { return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; bool flag; if (Synchronizable.Instance.UseFairRandomizer) { FairRandomizer fairRandomizer = default(FairRandomizer); if (!((Component)localPlayerController).TryGetComponent(ref fairRandomizer)) { fairRandomizer = ((Component)localPlayerController).gameObject.AddComponent(); } flag = fairRandomizer.CheckChance(FairRandomizerEvent.OpenDoor, Synchronizable.Instance.TeleportationOddsOnInteractDoor / 100f); } else { flag = Random.Range(0f, 101f) < Synchronizable.Instance.TeleportationOddsOnInteractDoor; } if (flag) { Backrooms.Instance.TeleportPlayerToBackrooms(localPlayerController, Synchronizable.Instance.DropHeldItemsOnTeleport); } } } [HarmonyPatch(typeof(GameNetworkManager))] public class GameNetworkManager_Patches { [HarmonyPostfix] [HarmonyPatch("StartDisconnect")] public static void StartDisconnect() { Synchronizable.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())) { ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPrefix] [HarmonyPatch("KillPlayer")] public static bool KillPlayer(PlayerControllerB __instance) { if (!((NetworkBehaviour)__instance).IsOwner) { return true; } if (!Synchronizable.Instance.TeleportOnDeath) { return true; } bool flag; if (Synchronizable.Instance.UseFairRandomizer) { FairRandomizer fairRandomizer = default(FairRandomizer); if (!((Component)__instance).TryGetComponent(ref fairRandomizer)) { fairRandomizer = ((Component)__instance).gameObject.AddComponent(); } flag = fairRandomizer.CheckChance(FairRandomizerEvent.Death, Synchronizable.Instance.TeleportationOddsOnDeath / 100f); } else { flag = Random.Range(0f, 101f) < Synchronizable.Instance.TeleportationOddsOnDeath; } if (__instance.AllowPlayerDeath() && flag) { Backrooms.Instance.TeleportPlayerToBackrooms(__instance, Synchronizable.Instance.DropHeldItemsOnTeleport); return false; } return true; } [HarmonyPrefix] [HarmonyPatch("DamagePlayer")] public static void DamagePlayer(PlayerControllerB __instance, ref int damageNumber) { if (!((NetworkBehaviour)__instance).IsOwner || !Synchronizable.Instance.TeleportOnDamage) { return; } bool flag; if (Synchronizable.Instance.UseFairRandomizer) { FairRandomizer fairRandomizer = default(FairRandomizer); if (!((Component)__instance).TryGetComponent(ref fairRandomizer)) { fairRandomizer = ((Component)__instance).gameObject.AddComponent(); } flag = fairRandomizer.CheckChance(FairRandomizerEvent.Damage, Synchronizable.Instance.TeleportationOddsOnDamage / 100f); } else { flag = Random.Range(0f, 101f) < Synchronizable.Instance.TeleportationOddsOnDamage; } if (flag) { Backrooms.Instance.TeleportPlayerToBackrooms(__instance, Synchronizable.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.IsHost) { CustomMessagingManager messagingManager = Synchronizable.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.Synced = true; return; } Synchronizable.Synced = false; CustomMessagingManager messagingManager2 = Synchronizable.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().Despawn(true); Object.Destroy((Object)(object)((Component)Backrooms.Instance).gameObject); } } [HarmonyPostfix] [HarmonyPatch("SpawnSyncedProps")] public static void SpawnBackroomsAtStartOfRound(RoundManager __instance) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) if (((NetworkBehaviour)__instance).IsServer) { if (Object.op_Implicit((Object)(object)Backrooms.Instance)) { ((Component)Backrooms.Instance).GetComponent().Despawn(true); Backrooms.Instance = null; } float num = 50f; if ((Object)(object)__instance.dungeonGenerator != (Object)null && (Object)(object)__instance.dungeonGenerator.Root != (Object)null) { num = __instance.dungeonGenerator.Root.transform.position.y; } GameObject val = Object.Instantiate(Plugin.Instance.BackroomsPrefab, new Vector3(5000f, num, 0f), Quaternion.identity); val.GetComponent().Spawn(true); } } } [HarmonyPatch(typeof(ShipTeleporter))] public class ShipTeleporter_Patches { [HarmonyPostfix] [HarmonyPatch("beamUpPlayer")] public static void BeamUpPlayerToBackrooms(ShipTeleporter __instance) { if (!__instance.isInverseTeleporter && Synchronizable.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.Instance.TeleportationOddsOnShipTP)) { Backrooms.Instance.TeleportPlayerToBackrooms(targetedPlayer, Synchronizable.Instance.DropHeldItemsOnTeleport); } } } [HarmonyPostfix] [HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")] public static void InverseTeleporterToBackrooms(ShipTeleporter __instance, int playerObj) { if (Synchronizable.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.Instance.TeleportationOddsOnShipRevTP)) { Backrooms.Instance.TeleportPlayerToBackrooms(val, Synchronizable.Instance.DropHeldItemsOnTeleport); } } } private static bool CheckTeleportChance(PlayerControllerB player, FairRandomizerEvent eventType, float odds) { if (Synchronizable.Instance.UseFairRandomizer) { FairRandomizer fairRandomizer = default(FairRandomizer); if (!((Component)player).TryGetComponent(ref fairRandomizer)) { fairRandomizer = ((Component)player).gameObject.AddComponent(); } return fairRandomizer.CheckChance(eventType, odds / 100f); } return Random.Range(0f, 101f) < odds; } } } namespace VELDDev.BackroomsRenewed.Generation { [CreateAssetMenu(fileName = "AmbientMusicInfo", menuName = "Ambient Music Info")] public class AmbientMusicInfo : ScriptableObject { public AudioClip soundtrack; public bool isStreamSafe = true; [Tooltip("If not stream safe, fallback on this track as copyright-safe.")] public AudioClip fallbackSoundtrack; } public class BackroomsGenerator : MonoBehaviour { public struct ExitInfo { public Vector2Int position; public WallFlags direction; } public enum MazeAlgorithm { Blob, Kruskal, Prim, Wilson, RandomPathMerge, FractalTessellation } public int width = 20; public int height = 20; public int exitCount = 1; [Range(0f, 1f)] public float wallRemovalFraction = 0.1f; public MazeAlgorithm algorithm = LocalConfig.Singleton.GenerationAlgorithm.Value; [HideInInspector] public Cell[,] cells = new Cell[0, 0]; [HideInInspector] public List exitPositions = new List(); private IMazeAlgorithm currentAlgorithm; public IEnumerator Generate() { yield return InitializeMaze(); MazeAlgorithm mazeAlgorithm = algorithm; if (1 == 0) { } IMazeAlgorithm mazeAlgorithm2 = mazeAlgorithm switch { MazeAlgorithm.Kruskal => new KruskalAlgorithm(), MazeAlgorithm.Prim => new PrimAlgorithm(), MazeAlgorithm.Wilson => new WilsonAlgorithm(), MazeAlgorithm.Blob => new BlobAlgorithm(), _ => throw new NotImplementedException(), }; if (1 == 0) { } currentAlgorithm = mazeAlgorithm2; yield return currentAlgorithm.Generate(cells, width, height); RemoveRandomWalls(wallRemovalFraction); PlaceExits(); } 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) != WallFlags.None) { list.Add((new Vector2Int(i, j), WallFlags.East, new Vector2Int(i + 1, j), WallFlags.West)); } if (j < height - 1 && (cells[i, j].walls & WallFlags.North) != WallFlags.None) { list.Add((new Vector2Int(i, j), WallFlags.North, new Vector2Int(i, j + 1), WallFlags.South)); } } } int num = Mathf.FloorToInt((float)list.Count * fraction); for (int k = 0; k < num; k++) { int num2 = Random.Range(k, list.Count); List<(Vector2Int, WallFlags, Vector2Int, WallFlags)> list2 = list; int index = k; int index2 = num2; (Vector2Int, WallFlags, Vector2Int, WallFlags) value = list[num2]; (Vector2Int, WallFlags, Vector2Int, WallFlags) value2 = list[k]; list2[index] = value; list[index2] = value2; (Vector2Int, WallFlags, Vector2Int, WallFlags) tuple = list[k]; cells[((Vector2Int)(ref tuple.Item1)).x, ((Vector2Int)(ref tuple.Item1)).y].walls &= (WallFlags)(byte)(~(int)tuple.Item2); cells[((Vector2Int)(ref tuple.Item3)).x, ((Vector2Int)(ref tuple.Item3)).y].walls &= (WallFlags)(byte)(~(int)tuple.Item4); } } private IEnumerator InitializeMaze() { cells = new Cell[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { cells[x, y] = new Cell { position = new Vector2Int(x, y) }; yield return null; } } } private void PlaceExits() { //IL_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 hashSet = new HashSet(); 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 CellsVariants; public AudioClip AmbientNoise; public GameObject ExitPrefab; public List 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, 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(BufferSerializer 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*)(&serializer))->SerializeValue(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; } int result; if (walls == other?.walls) { ref Vector2Int reference = ref position; object obj = other?.position; result = (((object)Unsafe.As(ref reference)/*cast due to .constrained prefix*/).Equals(obj) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } 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)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 { 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_0219: 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 val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1123228270u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref cell, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref withLight, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref lightState, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1123228270u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; _representation = cell; hasLightSource = withLight; defaultLightState = lightState; UpdateWalls(); Plugin.Instance.logger.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(2) { ceilingMat, ceilingMat }); } else { Plugin.Instance.logger.LogDebug((object)$"Cell {cell.position} initialized with light source enabled."); LightObject.SetActive(true); ((Behaviour)cellLightSource).enabled = true; cellLightSource.intensity = (defaultLightState ? DefaultLightIntensity : 0f); } } } private void UpdateWalls() { NorthWall.SetActive((_representation.walls & WallFlags.North) != 0); EastWall.SetActive((_representation.walls & WallFlags.East) != 0); SouthWall.SetActive((_representation.walls & WallFlags.South) != 0); WestWall.SetActive((_representation.walls & WallFlags.West) != 0); } public Transform GetExitDoorSocket(WallFlags dir) { return (Transform)(dir switch { WallFlags.North => NorthWall.transform.GetChild(0), WallFlags.East => EastWall.transform.GetChild(0), WallFlags.South => SouthWall.transform.GetChild(0), WallFlags.West => WestWall.transform.GetChild(0), _ => null, }); } private void SetLightState(bool state) { if (hasLightSource) { cellLightSource.intensity = (state ? DefaultLightIntensity : 0f); } } public void TwinkleLight(AnimationCurve intensityCurve, float duration) { if (Object.op_Implicit((Object)(object)cellLightSource) && hasLightSource) { ((MonoBehaviour)this).StartCoroutine(TwinkleCoroutine(intensityCurve, duration)); Plugin.Instance.logger.LogInfo((object)$"Twinkle started for duration:{duration} seconds"); } } private IEnumerator TwinkleCoroutine(AnimationCurve intensityCurve, float duration) { float elapsed = 0f; while (elapsed < duration) { elapsed += Time.deltaTime; float intensity = intensityCurve.Evaluate(elapsed / duration) * DefaultLightIntensity; cellLightSource.intensity = intensity; yield return null; } cellLightSource.intensity = (defaultLightState ? DefaultLightIntensity : 0f); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1123228270u, new RpcReceiveHandler(__rpc_handler_1123228270), "InitializeClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1123228270(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Cell cell = default(Cell); ((FastBufferReader)(ref reader)).ReadValueSafe(ref cell, default(ForNetworkSerializable)); bool withLight = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref withLight, default(ForPrimitives)); bool lightState = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(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 Cells { get; set; } public Blob(int id) { Id = id; Cells = new List(); } public void Merge(Blob other) { Cells.AddRange(other.Cells); } } private class MergeCandidate { public Vector2Int CellA; public Vector2Int CellB; public WallFlags WallA; public WallFlags WallB; public int BlobIdA; public int BlobIdB; } public IEnumerator Generate(Cell[,] maze, int width, int height) { Dictionary cellToBlob = new Dictionary(); List blobs = new List(); int blobIdCounter = 0; Stopwatch perfSw = Stopwatch.StartNew(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Vector2Int pos = new Vector2Int(x, y); Blob blob = new Blob(blobIdCounter++) { Cells = { pos } }; blobs.Add(blob); cellToBlob[pos] = blob; if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } } List allCells = new List(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { allCells.Add(new Vector2Int(i, j)); if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } } yield return ShuffleCells(allCells); while (blobs.Count > 1) { Vector2Int currentCell = allCells[Random.Range(0, allCells.Count)]; Blob currentBlob = cellToBlob[currentCell]; List mergeCandidates = FindMergeCandidates(currentCell, currentBlob, cellToBlob, width, height); if (mergeCandidates.Count > 0) { MergeCandidate merge = mergeCandidates[Random.Range(0, mergeCandidates.Count)]; maze[((Vector2Int)(ref merge.CellA)).x, ((Vector2Int)(ref merge.CellA)).y].walls &= (WallFlags)(byte)(~(int)merge.WallA); maze[((Vector2Int)(ref merge.CellB)).x, ((Vector2Int)(ref merge.CellB)).y].walls &= (WallFlags)(byte)(~(int)merge.WallB); Blob blobA = cellToBlob[merge.CellA]; Blob blobB = cellToBlob[merge.CellB]; blobA.Merge(blobB); foreach (Vector2Int cell in blobB.Cells) { cellToBlob[cell] = blobA; } blobs.Remove(blobB); } if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } perfSw.Stop(); } private List FindMergeCandidates(Vector2Int cell, Blob currentBlob, Dictionary 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 list = new List(); (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; } private IEnumerator ShuffleCells(List cells) { Stopwatch perfSw = Stopwatch.StartNew(); for (int i = cells.Count - 1; i > 0; i--) { int j = Random.Range(0, i + 1); int index = i; int index2 = j; Vector2Int value = cells[j]; Vector2Int value2 = cells[i]; cells[index] = value; cells[index2] = value2; if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } perfSw.Stop(); } } public interface IMazeAlgorithm { IEnumerator Generate(Cell[,] maze, int width, int height); } public class KruskalAlgorithm : IMazeAlgorithm { private class Edge { public Vector2Int CellA; public Vector2Int CellB; public WallFlags WallA; public WallFlags WallB; } private class UnionFind { private int[] parent; private int[] rank; public UnionFind(int size) { parent = new int[size]; rank = new int[size]; for (int i = 0; i < size; i++) { parent[i] = i; rank[i] = 0; } } public int Find(int x) { if (parent[x] != x) { parent[x] = Find(parent[x]); } return parent[x]; } public bool Union(int x, int y) { int num = Find(x); int num2 = Find(y); if (num == num2) { return false; } if (rank[num] < rank[num2]) { parent[num] = num2; } else if (rank[num] > rank[num2]) { parent[num2] = num; } else { parent[num2] = num; rank[num]++; } return true; } } public IEnumerator Generate(Cell[,] maze, int width, int height) { List edges = new List(); Stopwatch perfSw = Stopwatch.StartNew(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (x < width - 1) { edges.Add(new Edge { CellA = new Vector2Int(x, y), CellB = new Vector2Int(x + 1, y), WallA = WallFlags.East, WallB = WallFlags.West }); } if (y < height - 1) { edges.Add(new Edge { CellA = new Vector2Int(x, y), CellB = new Vector2Int(x, y + 1), WallA = WallFlags.North, WallB = WallFlags.South }); } if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } } yield return Shuffle(edges); UnionFind uf = new UnionFind(width * height); foreach (Edge edge in edges) { int idA = ((Vector2Int)(ref edge.CellA)).y * width + ((Vector2Int)(ref edge.CellA)).x; int idB = ((Vector2Int)(ref edge.CellB)).y * width + ((Vector2Int)(ref edge.CellB)).x; if (uf.Union(idA, idB)) { maze[((Vector2Int)(ref edge.CellA)).x, ((Vector2Int)(ref edge.CellA)).y].walls &= (WallFlags)(byte)(~(int)edge.WallA); maze[((Vector2Int)(ref edge.CellB)).x, ((Vector2Int)(ref edge.CellB)).y].walls &= (WallFlags)(byte)(~(int)edge.WallB); } if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } perfSw.Stop(); } private IEnumerator Shuffle(List list) { Stopwatch perfSw = Stopwatch.StartNew(); for (int i = list.Count - 1; i > 0; i--) { int j = Random.Range(0, i + 1); int index = i; int index2 = j; T value = list[j]; T value2 = list[i]; list[index] = value; list[index2] = value2; if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } perfSw.Stop(); } } public class PrimAlgorithm : IMazeAlgorithm { private class WallInfo { public Vector2Int Cell; public WallFlags Wall; public Vector2Int Neighbor; } public IEnumerator Generate(Cell[,] maze, int width, int height) { bool[,] inMaze = new bool[width, height]; List walls = new List(); Stopwatch perfSw = Stopwatch.StartNew(); int startX = Random.Range(0, width); int startY = Random.Range(0, height); inMaze[startX, startY] = true; AddWalls(maze, walls, inMaze, startX, startY, width, height); while (walls.Count > 0) { int index = Random.Range(0, walls.Count); WallInfo wall = walls[index]; walls.RemoveAt(index); int nx = ((Vector2Int)(ref wall.Neighbor)).x; int ny = ((Vector2Int)(ref wall.Neighbor)).y; if (!inMaze[nx, ny]) { maze[((Vector2Int)(ref wall.Cell)).x, ((Vector2Int)(ref wall.Cell)).y].walls &= (WallFlags)(byte)(~(int)wall.Wall); maze[nx, ny].walls &= (WallFlags)(byte)(~(int)GetOppositeWall(wall.Wall)); inMaze[nx, ny] = true; AddWalls(maze, walls, inMaze, nx, ny, width, height); } if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } perfSw.Stop(); } private void AddWalls(Cell[,] maze, List 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 { public IEnumerator Generate(Cell[,] maze, int width, int height) { bool[,] inMaze = new bool[width, height]; Vector2Int[] path = (Vector2Int[])(object)new Vector2Int[width * height]; Stopwatch perfSw = Stopwatch.StartNew(); int startX = Random.Range(0, width); int startY = Random.Range(0, height); inMaze[startX, startY] = true; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (!inMaze[x, y]) { int pathLength = RandomWalk(x, y, inMaze, path, width, height); for (int i = 0; i < pathLength - 1; i++) { Vector2Int current = path[i]; RemoveWallBetween(b: path[i + 1], maze: maze, a: current); inMaze[((Vector2Int)(ref current)).x, ((Vector2Int)(ref current)).y] = true; } if (perfSw.ElapsedMilliseconds > 16) { yield return null; perfSw.Restart(); } } } } perfSw.Stop(); } private int RandomWalk(int startX, int startY, bool[,] inMaze, Vector2Int[] path, int width, int height) { //IL_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 dictionary = new Dictionary(); 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 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 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 list = new List(); if (((Vector2Int)(ref pos)).x > 0) { list.Add(new Vector2Int(((Vector2Int)(ref pos)).x - 1, ((Vector2Int)(ref pos)).y)); } if (((Vector2Int)(ref pos)).x < width - 1) { list.Add(new Vector2Int(((Vector2Int)(ref pos)).x + 1, ((Vector2Int)(ref pos)).y)); } if (((Vector2Int)(ref pos)).y > 0) { list.Add(new Vector2Int(((Vector2Int)(ref pos)).x, ((Vector2Int)(ref pos)).y - 1)); } if (((Vector2Int)(ref pos)).y < height - 1) { list.Add(new Vector2Int(((Vector2Int)(ref pos)).x, ((Vector2Int)(ref pos)).y + 1)); } return list; } private void RemoveWallBetween(Cell[,] maze, Vector2Int a, Vector2Int b) { int num = ((Vector2Int)(ref b)).x - ((Vector2Int)(ref a)).x; int num2 = ((Vector2Int)(ref b)).y - ((Vector2Int)(ref a)).y; switch (num) { case 1: maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.East; maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.West; return; case -1: maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.West; maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.East; return; } switch (num2) { case 1: maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.North; maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.South; break; case -1: maze[((Vector2Int)(ref a)).x, ((Vector2Int)(ref a)).y].walls &= ~WallFlags.South; maze[((Vector2Int)(ref b)).x, ((Vector2Int)(ref b)).y].walls &= ~WallFlags.North; break; } } } } namespace VELDDev.BackroomsRenewed.Config { internal static class LethalConfigSupport { private static bool? lethalConfigLoaded; public static bool LethalConfigLoaded { get { bool valueOrDefault = lethalConfigLoaded == true; if (!lethalConfigLoaded.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); lethalConfigLoaded = valueOrDefault; } return lethalConfigLoaded.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void RegisterLethalConfig(LocalConfig config) { //IL_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) //IL_06fa: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Expected O, but got Unknown //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_0712: Expected O, but got Unknown //IL_0718: Expected O, but got Unknown //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Expected O, but got Unknown //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Expected O, but got Unknown //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Expected O, but got Unknown //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Expected O, but got Unknown //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Expected O, but got Unknown //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Expected O, but got Unknown LethalConfigManager.SetModDescription("CR#T#CAL FA#LUR#: UNKN#WN #NTERV#ENTI#N D#T#CT#D -- #/1?.!1'(>>> JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME"); BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(config.StreamerMode, new BoolCheckBoxOptions { Name = "Streamer Mode", Description = "Enable streamer mode to disable copyrighted musics and replace with copyright-free alternatives.", Section = "General", RequiresRestart = false }); ConfigEntry useFairRandomizer = config.UseFairRandomizer; BoolCheckBoxOptions val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Use Fair Randomization"; ((BaseOptions)val2).Description = "Whether to use fair randomization (a.k.a. Pity System) or normal randomization for random events (e.g. TP)"; ((BaseOptions)val2).Section = "General"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(useFairRandomizer, val2); ConfigEntry teleportOnDeath = config.TeleportOnDeath; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Death"; ((BaseOptions)val2).Description = "Allows teleportation on death of player. See also 'Teleportation Odds on Death'."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val4 = new BoolCheckBoxConfigItem(teleportOnDeath, val2); ConfigEntry teleportOnClipping = config.TeleportOnClipping; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Clipping"; ((BaseOptions)val2).Description = "Allows teleportation on clipping through walls. See also 'Teleportation Odds on Clipping'."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(teleportOnClipping, val2); ConfigEntry teleportOnDamage = config.TeleportOnDamage; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Damage"; ((BaseOptions)val2).Description = "Allows teleportation on taking damage. See also 'Teleportation Odds on Damage'."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val6 = new BoolCheckBoxConfigItem(teleportOnDamage, val2); ConfigEntry teleportOnInteractDoor = config.TeleportOnInteractDoor; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Entrance/Exit"; ((BaseOptions)val2).Description = "Allows teleportation when entering/exiting the Facility. See also 'Teleportation Odds on Entrance/Exit'."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val7 = new BoolCheckBoxConfigItem(teleportOnInteractDoor, val2); ConfigEntry teleportOnShipTeleport = config.TeleportOnShipTeleport; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Ship TP"; ((BaseOptions)val2).Description = "Allows teleportation when being teleported with the Ship Teleporter. See also 'Teleportation Odds on Ship TP'."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val8 = new BoolCheckBoxConfigItem(teleportOnShipTeleport, val2); ConfigEntry teleportOnShipRevertTeleport = config.TeleportOnShipRevertTeleport; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Teleport on Ship Revert TP"; ((BaseOptions)val2).Description = "Allows teleportation when being reverse teleported with the ship reverse TP. See also 'Teleportation Odds on Ship Rev TP'."; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val9 = new BoolCheckBoxConfigItem(teleportOnShipRevertTeleport, val2); ConfigEntry teleportationOddsOnDeath = config.TeleportationOddsOnDeath; FloatSliderOptions val10 = new FloatSliderOptions { Name = "Teleportation Odds on Death", Description = "The percentage chance of teleportation occurring on death.", Section = "Teleportation" }; ((BaseRangeOptions)val10).Min = 0f; ((BaseRangeOptions)val10).Max = 100f; ((BaseOptions)val10).RequiresRestart = false; ((BaseOptions)val10).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnDeath.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val11 = new FloatSliderConfigItem(teleportationOddsOnDeath, val10); ConfigEntry teleportationOddsOnClipping = config.TeleportationOddsOnClipping; FloatSliderOptions val12 = new FloatSliderOptions { Name = "Teleportation Odds on Clipping", Description = "The percentage chance of teleportation occurring on clipping through walls or ground.", Section = "Teleportation" }; ((BaseRangeOptions)val12).Min = 0f; ((BaseRangeOptions)val12).Max = 100f; ((BaseOptions)val12).RequiresRestart = false; ((BaseOptions)val12).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnClipping.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val13 = new FloatSliderConfigItem(teleportationOddsOnClipping, val12); ConfigEntry teleportationOddsOnDamage = config.TeleportationOddsOnDamage; FloatSliderOptions val14 = new FloatSliderOptions { Name = "Teleportation Odds on Damage", Description = "The percentage chance of teleportation occurring on taking damage.", Section = "Teleportation" }; ((BaseRangeOptions)val14).Min = 0f; ((BaseRangeOptions)val14).Max = 100f; ((BaseOptions)val14).RequiresRestart = false; ((BaseOptions)val14).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnDamage.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val15 = new FloatSliderConfigItem(teleportationOddsOnDamage, val14); ConfigEntry teleportationOddsOnInteractDoor = config.TeleportationOddsOnInteractDoor; FloatSliderOptions val16 = new FloatSliderOptions { Name = "Teleportation Odds on Entrance/Exit", Section = "Teleportation", Description = "The chance percentage of teleportation occurring on entering/exiting the Facility." }; ((BaseRangeOptions)val16).Min = 0f; ((BaseRangeOptions)val16).Max = 100f; ((BaseOptions)val16).RequiresRestart = false; ((BaseOptions)val16).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnInteractDoor.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val17 = new FloatSliderConfigItem(teleportationOddsOnInteractDoor, val16); ConfigEntry teleportationOddsOnShipTeleport = config.TeleportationOddsOnShipTeleport; FloatSliderOptions val18 = new FloatSliderOptions { Name = "Teleportation Odds on Ship TP", Section = "Teleportation", Description = "The chance percentage of teleportation occurring when being teleported with ship TP" }; ((BaseRangeOptions)val18).Min = 0f; ((BaseRangeOptions)val18).Max = 100f; ((BaseOptions)val18).RequiresRestart = false; ((BaseOptions)val18).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnShipTeleport.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val19 = new FloatSliderConfigItem(teleportationOddsOnShipTeleport, val18); ConfigEntry teleportationOddsOnShipRevertTeleport = config.TeleportationOddsOnShipRevertTeleport; FloatSliderOptions val20 = new FloatSliderOptions { Name = "Teleportation Odds on Ship Revert TP", Section = "Teleportation", Description = "The chance percentage of teleportation occurring when being reverse-teleported with ship reverse TP" }; ((BaseRangeOptions)val20).Min = 0f; ((BaseRangeOptions)val20).Max = 100f; ((BaseOptions)val20).RequiresRestart = false; ((BaseOptions)val20).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(config.TeleportOnShipRevertTeleport.Value && CanModifyResult.op_Implicit(NetworkAllowModifyCb()))); FloatSliderConfigItem val21 = new FloatSliderConfigItem(teleportationOddsOnShipRevertTeleport, val20); ConfigEntry dropHeldItemsOnTeleport = config.DropHeldItemsOnTeleport; val2 = new BoolCheckBoxOptions(); ((BaseOptions)val2).Name = "Drop Items on Teleport"; ((BaseOptions)val2).Description = "If enabled, will drop all the items when teleporting to the backrooms."; ((BaseOptions)val2).Section = "Teleportation"; ((BaseOptions)val2).RequiresRestart = false; ((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(NetworkAllowModifyCb); BoolCheckBoxConfigItem val22 = new BoolCheckBoxConfigItem(dropHeldItemsOnTeleport, val2); EnumDropDownConfigItem val23 = new EnumDropDownConfigItem(config.GenerationAlgorithm, new EnumDropDownOptions { Name = "Backrooms Generation Algorithm", Description = "The maze generation algorithm used for Backrooms levels. (Blob is recommended for optimal aesthetics)", Section = "Generation", RequiresRestart = true }); ConfigEntry minBackroomsSize = config.MinBackroomsSize; IntSliderOptions val24 = new IntSliderOptions { Name = "Minimum Backrooms Size", Description = "The minimum size in cells (width and height) of generated Backrooms levels.", Section = "Generation" }; ((BaseRangeOptions)val24).Min = 10; ((BaseRangeOptions)val24).Max = 50; ((BaseOptions)val24).RequiresRestart = false; IntSliderConfigItem val25 = new IntSliderConfigItem(minBackroomsSize, val24); ConfigEntry maxBackroomsSize = config.MaxBackroomsSize; IntSliderOptions val26 = new IntSliderOptions { Name = "Maximum Backrooms Size", Description = "The maximum size in cells (width and height) of generated Backrooms levels.", Section = "Generation" }; ((BaseRangeOptions)val26).Min = 10; ((BaseRangeOptions)val26).Max = 50; ((BaseOptions)val26).RequiresRestart = false; IntSliderConfigItem val27 = new IntSliderConfigItem(maxBackroomsSize, val26); ConfigEntry maxFakeExitCount = config.MaxFakeExitCount; IntInputFieldOptions val28 = new IntInputFieldOptions { Name = "Maximum Fake Exits Count", Description = "The maximum number of fake exits that will appear in the Backrooms. They do not kill, just TP to somewhere else in the backrooms.", Section = "Generation", RequiresRestart = false }; ((BaseRangeOptions)val28).Min = 0; ((BaseRangeOptions)val28).Max = 10; IntInputFieldConfigItem val29 = new IntInputFieldConfigItem(maxFakeExitCount, val28); ConfigEntry exitCount = config.ExitCount; IntSliderOptions val30 = new IntSliderOptions { Name = "Exit Count", Description = "The number of real exit doors that will spawn in the Backrooms.", Section = "Generation" }; ((BaseRangeOptions)val30).Min = 1; ((BaseRangeOptions)val30).Max = 10; ((BaseOptions)val30).RequiresRestart = false; IntSliderConfigItem val31 = new IntSliderConfigItem(exitCount, val30); BoolCheckBoxConfigItem val32 = new BoolCheckBoxConfigItem(config.LegacyNavMeshGeneration, false); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val22); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val13); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val15); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val17); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val19); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val9); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val23); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val25); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val27); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val29); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val31); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val32); static CanModifyResult NetworkAllowModifyCb() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return CanModifyResult.op_Implicit((Synchronizable.Synced && Synchronizable.IsHost && NetworkManager.Singleton.IsServer) || !Synchronizable.Synced); } } internal static void RegisterModIcon(Sprite modIcon) { LethalConfigManager.SetModIcon(modIcon); } } public class LocalConfig { internal const string ModDescription = "CR#T#CAL FA#LUR#: UNKN#WN #NTERV#ENTI#N D#T#CT#D -- #/1?.!1'(>>> JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME JOIN ME"; public readonly ConfigEntry StreamerMode; public readonly ConfigEntry UseFairRandomizer; public readonly ConfigEntry TeleportOnDeath; public readonly ConfigEntry TeleportOnClipping; public readonly ConfigEntry TeleportOnDamage; public readonly ConfigEntry TeleportOnInteractDoor; public readonly ConfigEntry TeleportOnShipTeleport; public readonly ConfigEntry TeleportOnShipRevertTeleport; public readonly ConfigEntry TeleportationOddsOnDeath; public readonly ConfigEntry TeleportationOddsOnClipping; public readonly ConfigEntry TeleportationOddsOnDamage; public readonly ConfigEntry TeleportationOddsOnInteractDoor; public readonly ConfigEntry TeleportationOddsOnShipTeleport; public readonly ConfigEntry TeleportationOddsOnShipRevertTeleport; public readonly ConfigEntry DropHeldItemsOnTeleport; public readonly ConfigEntry GenerationAlgorithm; public readonly ConfigEntry MinBackroomsSize; public readonly ConfigEntry MaxBackroomsSize; public readonly ConfigEntry MaxFakeExitCount; public readonly ConfigEntry ExitCount; public readonly ConfigEntry LegacyNavMeshGeneration; internal ConfigFile CfgFile; public static LocalConfig Singleton { get; private set; } public LocalConfig(ConfigFile cfg) { Singleton = this; CfgFile = cfg; StreamerMode = cfg.Bind("General", "Streamer Mode", false, "Enable streamer mode to disable copyrighted musics and replace with copyright-free alternatives."); UseFairRandomizer = cfg.Bind("General", "Use Fair Randomization", false, "Whether to use Fair Randomization (a.k.a. Pity system) for random events (e.g. TP) or use normal randomization."); TeleportOnDeath = cfg.Bind("Teleportation", "Teleport on Death", true, "Enable teleportation on death."); TeleportOnClipping = cfg.Bind("Teleportation", "Teleport on Clipping", true, "Enable teleportation on clipping through walls."); TeleportOnDamage = cfg.Bind("Teleportation", "Teleport on Damage", false, "Enable teleportation on taking damage."); TeleportOnInteractDoor = cfg.Bind("Teleportation", "Teleport on Entrance/Exit", true, "Enable teleportation when entering/exiting the facility"); TeleportOnShipTeleport = cfg.Bind("Teleportation", "Teleport on Ship Teleport", true, "Enable teleportation when using Ship Teleporter"); TeleportOnShipRevertTeleport = cfg.Bind("Teleportation", "Teleport on Ship Revert TP", true, "Enable teleportation when using the Ship Revert Teleporter"); TeleportationOddsOnDeath = cfg.Bind("Teleportation", "Teleportation Odds on Death", 10f, "The percentage chance of teleportation occurring on death."); TeleportationOddsOnClipping = cfg.Bind("Teleportation", "Teleportation Odds on Clipping", 100f, "The chance percentage of teleportation occurring on clipping through walls."); TeleportationOddsOnDamage = cfg.Bind("Teleportation", "Teleportation Odds on Damage", 1f, "The percentage chance of teleportation occurring on taking damage."); TeleportationOddsOnInteractDoor = cfg.Bind("Teleportation", "Telportation Odds On Entrance/Exit", 0.1f, "The chance percentage of teleportation occurring when entering or exiting the facility"); TeleportationOddsOnShipTeleport = cfg.Bind("Teleportation", "Teleportation Odds on Ship Teleport", 0.1f, "The chance percentage of teleportation occurring when using the ship teleporter."); TeleportationOddsOnShipRevertTeleport = cfg.Bind("Teleportation", "Teleportation Odds on Ship Revert TP", 1f, "The chance percentage of teleportation occurring when using the ship revert teleporter"); DropHeldItemsOnTeleport = cfg.Bind("Teleportation", "Drop All Held Items On TP", false, "If enabled, will drop all items on the ground when TP in the Backrooms."); GenerationAlgorithm = cfg.Bind("Generation", "Backrooms Generation Algorithm", BackroomsGenerator.MazeAlgorithm.Blob, "The maze generation algorithm used for Backrooms levels. (Blob is recommended for optimal aesthetics)"); MinBackroomsSize = cfg.Bind("Generation", "Minimum Backrooms Size", 15, "The minimum size in cells (width and length) of generated Backrooms levels."); MaxBackroomsSize = cfg.Bind("Generation", "Maximum Backrooms Size", 30, "The maximum size in cells (width and length) of generated Backrooms levels."); MaxFakeExitCount = cfg.Bind("Generation", "Maximum Fake Exits Count", 2, "The maximum number of fake exits that will appear in the Backrooms. They do not kill, just TP to somewhere else in the backrooms."); ExitCount = cfg.Bind("Generation", "Exit Count", 1, "The number of real exit doors that will spawn in the Backrooms."); LegacyNavMeshGeneration = cfg.Bind("Advanced", "Use Legacy Navmesh Generation", false, "Use this is if you encounter issues with navmeshes (entities not behaving correctly in the backrooms). Disclaimer: The legacy NavMesh generation system might freeze the game for a few seconds for the weakest configs."); if (LethalConfigSupport.LethalConfigLoaded) { LethalConfigSupport.RegisterLethalConfig(this); } SyncedConfig syncedConfig = new SyncedConfig(this); } } [Serializable] public class SyncedConfig : Synchronizable { public bool UseFairRandomizer; public bool TeleportOnDeath; public bool TeleportOnClipping; public bool TeleportOnDamage; public bool TeleportOnInteractDoor; public bool TeleportOnShipTP; public bool TeleportOnShipRevTP; public float TeleportationOddsOnDeath; public float TeleportationOddsOnClipping; public float TeleportationOddsOnDamage; public float TeleportationOddsOnInteractDoor; public float TeleportationOddsOnShipTP; public float TeleportationOddsOnShipRevTP; public bool DropHeldItemsOnTeleport; public bool LegacyNavMeshGen; [NonSerialized] private LocalConfig config; public SyncedConfig(LocalConfig cfg) { InitInstance(this); config = cfg; config.UseFairRandomizer.SettingChanged += delegate { UseFairRandomizer = config.UseFairRandomizer.Value; }; config.TeleportOnDeath.SettingChanged += delegate { TeleportOnDeath = config.TeleportOnDeath.Value; }; config.TeleportOnClipping.SettingChanged += delegate { TeleportOnClipping = config.TeleportOnClipping.Value; }; config.TeleportOnDamage.SettingChanged += delegate { TeleportOnDamage = config.TeleportOnDamage.Value; }; config.TeleportOnInteractDoor.SettingChanged += delegate { TeleportOnInteractDoor = config.TeleportOnInteractDoor.Value; }; config.TeleportOnShipTeleport.SettingChanged += delegate { TeleportOnShipTP = config.TeleportOnShipTeleport.Value; }; config.TeleportOnShipRevertTeleport.SettingChanged += delegate { TeleportOnShipRevTP = config.TeleportOnShipRevertTeleport.Value; }; config.TeleportationOddsOnDeath.SettingChanged += delegate { TeleportationOddsOnDeath = config.TeleportationOddsOnDeath.Value; }; config.TeleportationOddsOnClipping.SettingChanged += delegate { TeleportationOddsOnClipping = config.TeleportationOddsOnClipping.Value; }; config.TeleportationOddsOnDamage.SettingChanged += delegate { TeleportationOddsOnDamage = config.TeleportationOddsOnDamage.Value; }; config.TeleportationOddsOnInteractDoor.SettingChanged += delegate { TeleportationOddsOnInteractDoor = config.TeleportationOddsOnInteractDoor.Value; }; config.TeleportationOddsOnShipTeleport.SettingChanged += delegate { TeleportationOddsOnShipTP = config.TeleportationOddsOnShipTeleport.Value; }; config.TeleportationOddsOnShipRevertTeleport.SettingChanged += delegate { TeleportationOddsOnShipRevTP = config.TeleportationOddsOnShipRevertTeleport.Value; }; config.DropHeldItemsOnTeleport.SettingChanged += delegate { DropHeldItemsOnTeleport = config.DropHeldItemsOnTeleport.Value; }; config.LegacyNavMeshGeneration.SettingChanged += delegate { LegacyNavMeshGen = config.LegacyNavMeshGeneration.Value; }; cfg.CfgFile.SettingChanged += delegate { BroadcastSync(); }; UseFairRandomizer = config.UseFairRandomizer.Value; TeleportOnDeath = config.TeleportOnDeath.Value; TeleportOnClipping = config.TeleportOnClipping.Value; TeleportOnDamage = config.TeleportOnDamage.Value; TeleportOnInteractDoor = config.TeleportOnInteractDoor.Value; TeleportOnShipTP = config.TeleportOnShipTeleport.Value; TeleportOnShipRevTP = config.TeleportOnShipRevertTeleport.Value; TeleportationOddsOnDeath = config.TeleportationOddsOnDeath.Value; TeleportationOddsOnClipping = config.TeleportationOddsOnClipping.Value; TeleportationOddsOnDamage = config.TeleportationOddsOnDamage.Value; TeleportationOddsOnInteractDoor = config.TeleportationOddsOnInteractDoor.Value; TeleportationOddsOnShipTP = config.TeleportationOddsOnShipTeleport.Value; TeleportationOddsOnShipRevTP = config.TeleportationOddsOnShipRevertTeleport.Value; DropHeldItemsOnTeleport = config.DropHeldItemsOnTeleport.Value; LegacyNavMeshGen = config.LegacyNavMeshGeneration.Value; } public unsafe static void BroadcastSync() { //IL_0067: 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_008a: Unknown result type (might be due to invalid IL or missing references) if (!Synchronizable.IsHost) { return; } Plugin.Instance.logger.LogDebug((object)"Host is broadcasting their config"); byte[] array = Synchronizable.Serialize(Synchronizable.Instance); if (array == null) { return; } int num = array.Length; int num2 = FastBufferWriter.GetWriteSize(array, -1, 0) + Synchronizable.IntSize; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num2, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); Synchronizable.MessagingManager.SendNamedMessageToAll("BackroomsRenewed_OnReceiveConfigSync", val, (NetworkDelivery)4); } catch (Exception arg) { Plugin.Instance.logger.LogError((object)$"The config sync braodcast lamentably failed: {arg}"); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public unsafe static void RequestSync() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!Synchronizable.IsClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(Synchronizable.IntSize, (Allocator)2, -1); try { Synchronizable.MessagingManager.SendNamedMessage("BackroomsRenewed_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); Plugin.Instance.logger.LogInfo((object)"Requesting host's config..."); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public unsafe static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!Synchronizable.IsHost) { return; } Plugin.Instance.logger.LogDebug((object)$"Config request sync received from client {clientId}"); byte[] array = Synchronizable.Serialize(Synchronizable.Instance); if (array == null) { return; } int num = array.Length; int num2 = FastBufferWriter.GetWriteSize(array, -1, 0) + Synchronizable.IntSize; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num2, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); Synchronizable.MessagingManager.SendNamedMessage("BackroomsRenewed_OnReceiveConfigSync", clientId, val, (NetworkDelivery)4); } catch (Exception arg) { Plugin.Instance.logger.LogError((object)$"Couldn't sync configs between clients: {arg}"); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(Synchronizable.IntSize)) { Plugin.Instance.logger.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { Plugin.Instance.logger.LogError((object)"Config sync error: Announced length and data length mismatch"); return; } byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); Synchronizable.SyncInstance(data); Plugin.Instance.logger.LogInfo((object)"Config successfully synchronized with the host."); } } public class Synchronizable { [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessagingManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient { get { NetworkManager singleton = NetworkManager.Singleton; return singleton != null && singleton.IsClient; } } internal static bool IsHost { get { NetworkManager singleton = NetworkManager.Singleton; return singleton != null && singleton.IsHost; } } public static T Default { get; set; } public static T Instance { get; set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = Deserialize(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static byte[] Serialize(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { Plugin.Instance.logger.LogError((object)$"Error when trying to serialize Config Instance: {arg}"); return null; } } public static T Deserialize(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { Plugin.Instance.logger.LogError((object)$"Error when trying to deserialize Config Instance: {arg}"); return default(T); } } } } namespace VELDDev.BackroomsRenewed.BackroomsManagement { public class Backrooms : NetworkBehaviour { private const float CELL_SIZE = 16f; public static Backrooms Instance; public List themes; public Transform CellsHolder; public NavMeshSurface BackroomsNavMesh; public GameObject BackroomsLightCover; public BackroomsGenerator generator; public AnimationCurve lightTwinkleLightCurve; public AudioSource ambientMusicSource; public AudioSource ambientNoiseSource; [HideInInspector] public NetworkVariable IsGenerated = new NetworkVariable(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); [HideInInspector] public NetworkList PlayersInBackrooms; [HideInInspector] public CellBehaviour[,] Cells; private readonly Dictionary _variantUsageCount = new Dictionary(); private float _timeSinceLastTwinkleCheck = 0f; private float _nextTwinkleCheckTime = 0f; public BackroomThemeInfo CurrentTheme { get; private set; } private ManualLogSource Logger => Plugin.Instance.logger; private void Awake() { PlayersInBackrooms = new NetworkList(); if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } } private void Start() { generator.algorithm = LocalConfig.Singleton.GenerationAlgorithm.Value; int num = Random.Range(LocalConfig.Singleton.MinBackroomsSize.Value, LocalConfig.Singleton.MaxBackroomsSize.Value + 1); generator.width = num; generator.height = num; generator.exitCount = LocalConfig.Singleton.ExitCount.Value; if (((NetworkBehaviour)this).IsServer) { ((MonoBehaviour)this).StartCoroutine(GenerateBackrooms()); } } private void SelectTheme() { if (themes == null || themes.Count == 0) { Logger.LogError((object)"No themes configured! Cannot generate backrooms."); return; } if (themes.Count == 1) { CurrentTheme = themes[0]; Logger.LogInfo((object)("Theme selected: " + CurrentTheme.themeName)); return; } float num = themes.Sum((BackroomThemeInfo t) => t.weight); float num2 = Random.Range(0f, num); float num3 = 0f; foreach (BackroomThemeInfo theme in themes) { num3 += theme.weight; if (num2 <= num3) { CurrentTheme = theme; Logger.LogInfo((object)("Theme selected: " + CurrentTheme.themeName)); return; } } List list = themes; CurrentTheme = list[list.Count - 1]; Logger.LogInfo((object)("Theme selected: " + CurrentTheme.themeName)); } private void FixedUpdate() { if (((NetworkBehaviour)this).IsServer && IsGenerated.Value) { if (_timeSinceLastTwinkleCheck < _nextTwinkleCheckTime) { _timeSinceLastTwinkleCheck += Time.deltaTime; return; } TwinkleRandomLightsClientRpc(); _timeSinceLastTwinkleCheck = 0f; _nextTwinkleCheckTime = Random.Range(3f, 15f); Logger.LogInfo((object)$"Twinkle check completed, next check in {_nextTwinkleCheckTime} seconds"); } } public void TeleportPlayerToBackrooms(PlayerControllerB targetPlayer, bool dropItems = false) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { Vector3? val = PickRandomPosOnNavmesh(); Vector3 position = (Vector3)(((??)val) ?? GetFallbackPosition()); if (!val.HasValue) { Logger.LogWarning((object)"Failed to find valid NavMesh position, using fallback center position"); } TeleportPlayerClientRpc(targetPlayer.playerClientId, position, dropItems); } else { RequestTeleportServerRpc(targetPlayer.playerClientId, dropItems); } } [Obsolete("Use TeleportPlayerToBackrooms instead for server-authoritative teleportation")] public void TeleportLocalPlayerSomewhereInBackrooms(PlayerControllerB targetPlayer) { TeleportPlayerToBackrooms(targetPlayer, Synchronizable.Instance.DropHeldItemsOnTeleport); } [ServerRpc(RequireOwnership = false)] public void RequestTeleportServerRpc(ulong playerClientId, bool dropItems) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0136: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(585044176u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerClientId); ((FastBufferWriter)(ref val)).WriteValueSafe(ref dropItems, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 585044176u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Vector3? val3 = PickRandomPosOnNavmesh(); Vector3 position = (Vector3)(((??)val3) ?? GetFallbackPosition()); if (!val3.HasValue) { Logger.LogWarning((object)"Failed to find valid NavMesh position, using fallback center position"); } TeleportPlayerClientRpc(playerClientId, position, dropItems); } } [ClientRpc] private void TeleportPlayerClientRpc(ulong playerClientId, Vector3 position, bool dropItems) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0071: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3050734134u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerClientId); ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val)).WriteValueSafe(ref dropItems, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3050734134u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB playerByClientId = GetPlayerByClientId(playerClientId); if ((Object)(object)playerByClientId == (Object)null) { Logger.LogWarning((object)$"TeleportPlayerClientRpc: Could not find player with clientId {playerClientId}"); return; } if (dropItems && ((NetworkBehaviour)playerByClientId).IsOwner) { playerByClientId.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3)); playerByClientId.DisableJetpackControlsLocally(); } playerByClientId.TeleportPlayer(position, true, 0f, false, true); playerByClientId.ResetFallGravity(); playerByClientId.isInsideFactory = true; StartPlayingAmbientAudios(); PlayersInBackrooms.Add(playerClientId); } private Vector3 GetFallbackPosition() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) return new Vector3(((Component)this).transform.position.x, ((Component)this).transform.position.y + 2f, ((Component)this).transform.position.z); } private PlayerControllerB GetPlayerByClientId(ulong clientId) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.playerClientId == clientId) { return val; } } return null; } private Vector3? PickRandomPosOnNavmesh(int maxAttempts = 30) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = (float)generator.width * 16f; float num3 = 0f; float num4 = (float)generator.height * 16f; float num5 = -1000f; Vector3 val = default(Vector3); NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < maxAttempts; i++) { ((Vector3)(ref val))..ctor(Random.Range(num, num2), num5, Random.Range(num3, num4)); if (NavMesh.SamplePosition(val, ref val2, 16f, -1)) { return ((NavMeshHit)(ref val2)).position; } } return null; } private IEnumerator GenerateBackrooms() { if (!NetworkManager.Singleton.IsHost && !((NetworkBehaviour)this).IsServer) { yield break; } SelectTheme(); if (!Object.op_Implicit((Object)(object)CurrentTheme)) { Logger.LogError((object)"Couldn't generate the backrooms: Selected theme is null !"); yield break; } _variantUsageCount.Clear(); foreach (CellVariantInfo variant in CurrentTheme.CellsVariants) { _variantUsageCount[variant] = 0; } Logger.LogInfo((object)"Starting generation..."); yield return generator.Generate(); Cells = new CellBehaviour[generator.width, generator.height]; CellVariantInfo[,] variantLayout = BuildVariantLayout(); Logger.LogInfo((object)"Placing the cells in the world..."); Stopwatch sw = Stopwatch.StartNew(); Stopwatch globalSw = Stopwatch.StartNew(); for (int x = 0; x < generator.width; x++) { for (int y = 0; y < generator.height; y++) { Cell cell = generator.cells[x, y]; CellVariantInfo selectedVariant = variantLayout[x, y]; GameObject cellgo = Object.Instantiate(selectedVariant.variantPrefab, CellsHolder); cellgo.transform.localPosition = new Vector3(16f * (float)x, 0f, 16f * (float)y); cellgo.GetComponent().Spawn(true); CellBehaviour cellmono = cellgo.GetComponent(); if (y == 0) { if (x == 0) { cell.walls |= WallFlags.South | WallFlags.West; } else if (x == generator.width - 1) { cell.walls |= WallFlags.East | WallFlags.South; } else { cell.walls |= WallFlags.South; } } else if (y == generator.height - 1) { if (x == 0) { cell.walls |= WallFlags.North | WallFlags.West; } else if (x == generator.width - 1) { cell.walls |= WallFlags.North | WallFlags.East; } else { cell.walls |= WallFlags.North; } } else if (x == 0) { cell.walls |= WallFlags.West; } else if (x == generator.width - 1) { cell.walls |= WallFlags.East; } else { cell.walls &= ~(WallFlags.South | WallFlags.West); } if (Random.Range(0, 101) < 60) { cellmono.InitializeClientRpc(lightState: Random.Range(0, 101) < 90, cell: cell, withLight: true); } else { cellmono.InitializeClientRpc(cell, withLight: false, lightState: false); } Cells[x, y] = cellmono; if (sw.ElapsedMilliseconds > 16) { Logger.LogDebug((object)$"Yielding frame; {sw.ElapsedMilliseconds:N0}ms elapsed since last frame."); yield return null; sw.Restart(); } } } sw.Stop(); globalSw.Stop(); Logger.LogInfo((object)$"Generated backrooms in {globalSw.ElapsedMilliseconds:N0}ms"); Logger.LogInfo((object)$"Spawning {generator.exitPositions.Count} exit door(s)..."); foreach (BackroomsGenerator.ExitInfo exit in generator.exitPositions) { CellBehaviour[,] cells = Cells; Vector2Int position = exit.position; int x2 = ((Vector2Int)(ref position)).x; position = exit.position; CellBehaviour cellBehaviour = cells[x2, ((Vector2Int)(ref position)).y]; Transform socket = cellBehaviour.GetExitDoorSocket(exit.direction); if ((Object)(object)socket == (Object)null) { Logger.LogWarning((object)$"No exit socket found for cell {exit.position} facing {exit.direction}, skipping."); continue; } GameObject exitGo = Object.Instantiate(CurrentTheme.ExitPrefab, socket.position, socket.rotation); exitGo.GetComponent().Spawn(true); Logger.LogDebug((object)$"Spawned exit door at cell {exit.position} facing {exit.direction}"); } Logger.LogInfo((object)"Finished backrooms generation"); SetupBackroomsClientRpc(generator.width, generator.height); } [ClientRpc] private void SetupBackroomsClientRpc(int width, int length) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0071: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(356275655u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, width); BytePacker.WriteValueBitPacked(val, length); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 356275655u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor((float)width * 16f / 2f, 10f, (float)length * 16f / 2f); BackroomsLightCover.transform.localPosition = localPosition; BackroomsLightCover.transform.localScale = new Vector3((float)width, 1f, (float)length) * 1.5f; Logger.LogInfo((object)"Set backrooms light cover"); if (Synchronizable.Instance.LegacyNavMeshGen) { Stopwatch stopwatch = Stopwatch.StartNew(); BackroomsNavMesh.BuildNavMesh(); stopwatch.Stop(); Logger.LogInfo((object)$"Built navmesh in {stopwatch.ElapsedMilliseconds:N0}ms"); } else { Logger.LogInfo((object)"Refreshing Navmesh..."); Stopwatch stopwatch2 = Stopwatch.StartNew(); ((MonoBehaviour)this).StartCoroutine(RefreshNavmeshesAsync()); stopwatch2.Stop(); Logger.LogInfo((object)$"Navmesh refreshed in {stopwatch2.ElapsedMilliseconds:N0}ms"); } } } private IEnumerator RefreshNavmeshesAsync() { Vector3 backroomsCenter = new Vector3((float)generator.width * 16f / 2f, 0f, (float)generator.height * 16f / 2f); BackroomsNavMesh.center = backroomsCenter; BackroomsNavMesh.size = new Vector3((float)generator.width * 16f, 1f, (float)generator.height * 16f); BackroomsNavMesh.navMeshData = new NavMeshData(); BackroomsNavMesh.AddData(); yield return BackroomsNavMesh.UpdateNavMesh(BackroomsNavMesh.navMeshData); } public override void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } [ClientRpc] private void TwinkleRandomLightsClientRpc() { //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.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(81342453u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 81342453u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; CellBehaviour[,] cells = Cells; foreach (CellBehaviour cellBehaviour in cells) { if (cellBehaviour.hasLightSource) { float num = Random.Range(0f, 100f); if (num < 40f) { cellBehaviour.TwinkleLight(lightTwinkleLightCurve, Random.Range(1f, ((Keyframe)(ref lightTwinkleLightCurve.keys[^1])).time)); } } } } private CellVariantInfo[,] BuildVariantLayout() { int width = generator.width; int height = generator.height; CellVariantInfo[,] array = new CellVariantInfo[width, height]; List source = CurrentTheme.CellsVariants.Where((CellVariantInfo v) => !v.mustSpawnAtLeastOnce).ToList(); for (int num = 0; num < width; num++) { for (int num2 = 0; num2 < height; num2++) { List list = source.Where((CellVariantInfo v) => v.maxAmount == -1 || _variantUsageCount[v] < v.maxAmount).ToList(); if (list.Count > 0) { array[num, num2] = SelectWeightedRandom(list); continue; } CellVariantInfo cellVariantInfo = CurrentTheme.CellsVariants[0]; _variantUsageCount[cellVariantInfo]++; array[num, num2] = cellVariantInfo; } } List list2 = CurrentTheme.CellsVariants.Where((CellVariantInfo v) => v.mustSpawnAtLeastOnce && v.maxAmount != 0).ToList(); if (list2.Count > 0) { HashSet<(int, int)> hashSet = new HashSet<(int, int)>(); int num3 = width * height; foreach (CellVariantInfo item2 in list2) { if (hashSet.Count >= num3) { Logger.LogWarning((object)("No free cells left to place required variant '" + ((Object)item2).name + "'.")); break; } (int, int) item; do { item = (Random.Range(0, width), Random.Range(0, height)); } while (hashSet.Contains(item)); hashSet.Add(item); CellVariantInfo key = array[item.Item1, item.Item2]; _variantUsageCount[key]--; array[item.Item1, item.Item2] = item2; _variantUsageCount[item2]++; } } return array; } private CellVariantInfo SelectWeightedRandom(List variants) { float num = variants.Sum((CellVariantInfo v) => v.weight); float num2 = Random.Range(0f, num); float num3 = 0f; foreach (CellVariantInfo variant in variants) { num3 += variant.weight; if (num2 <= num3) { _variantUsageCount[variant]++; return variant; } } CellVariantInfo cellVariantInfo = variants[variants.Count - 1]; _variantUsageCount[cellVariantInfo]++; return cellVariantInfo; } public void StartPlayingAmbientAudios() { if (Object.op_Implicit((Object)(object)ambientNoiseSource) && Object.op_Implicit((Object)(object)CurrentTheme.AmbientNoise)) { ambientNoiseSource.clip = CurrentTheme.AmbientNoise; ambientNoiseSource.Play(); ambientNoiseSource.loop = true; } if (Object.op_Implicit((Object)(object)ambientMusicSource) && CurrentTheme.AmbientMusics.Count > 0) { AmbientMusicInfo weightedRandom = MyCollections.GetWeightedRandom((IList)CurrentTheme.AmbientMusics, (Func)((AmbientMusicInfo md) => (!md.isStreamSafe && LocalConfig.Singleton.StreamerMode.Value) ? 0f : 1f)); ambientMusicSource.clip = weightedRandom.soundtrack; ambientMusicSource.Play(); } } public void StopPlayingAmbientAudios() { if (Object.op_Implicit((Object)(object)ambientNoiseSource)) { ambientNoiseSource.Stop(); } if (Object.op_Implicit((Object)(object)ambientMusicSource)) { ambientMusicSource.Stop(); } } protected override void __initializeVariables() { if (IsGenerated == null) { throw new Exception("Backrooms.IsGenerated cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)IsGenerated).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)IsGenerated, "IsGenerated"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)IsGenerated); if (PlayersInBackrooms == null) { throw new Exception("Backrooms.PlayersInBackrooms cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)PlayersInBackrooms).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PlayersInBackrooms, "PlayersInBackrooms"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)PlayersInBackrooms); ((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 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(585044176u, new RpcReceiveHandler(__rpc_handler_585044176), "RequestTeleportServerRpc"); ((NetworkBehaviour)this).__registerRpc(3050734134u, new RpcReceiveHandler(__rpc_handler_3050734134), "TeleportPlayerClientRpc"); ((NetworkBehaviour)this).__registerRpc(356275655u, new RpcReceiveHandler(__rpc_handler_356275655), "SetupBackroomsClientRpc"); ((NetworkBehaviour)this).__registerRpc(81342453u, new RpcReceiveHandler(__rpc_handler_81342453), "TwinkleRandomLightsClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_585044176(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); bool dropItems = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref dropItems, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).RequestTeleportServerRpc(playerClientId, dropItems); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3050734134(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); bool dropItems = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref dropItems, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).TeleportPlayerClientRpc(playerClientId, position, dropItems); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_356275655(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int width = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref width); int length = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref length); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).SetupBackroomsClientRpc(width, length); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_81342453(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; ((Backrooms)(object)target).TwinkleRandomLightsClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "Backrooms"; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace LC-Backrooms-Renewed.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }