Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BackroomsFixed v0.3.0
BepInEx/plugins/Backrooms/Backrooms.dll
Decompiled 10 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Backrooms.NetcodePatcher; using BepInEx; using BepInEx.Configuration; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.AI.Navigation; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Backrooms")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0")] [assembly: AssemblyProduct("Backrooms")] [assembly: AssemblyTitle("Backrooms")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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; } } } [RequireComponent(typeof(SphereCollider))] public class KillBox : MonoBehaviour { private void OnTriggerEnter(Collider other) { //IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null) { component.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0, default(Vector3), false); } } } public class LightFlickerEffect : MonoBehaviour { [Tooltip("External light to flicker; you can leave this null if you attach script to a light")] public Light light; [Tooltip("Minimum random light intensity")] public float minIntensity; [Tooltip("Maximum random light intensity")] public float maxIntensity = 1f; [Tooltip("How much to smooth out the randomness; lower values = sparks, higher = lantern")] [Range(1f, 50f)] public int smoothing = 5; private Queue<float> smoothQueue; private float lastSum; public void Reset() { smoothQueue.Clear(); lastSum = 0f; } private void Start() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown smoothQueue = new Queue<float>(smoothing); if ((Object)light == (Object)null) { light = ((Component)this).GetComponent<Light>(); } } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown if (!((Object)light == (Object)null)) { while (smoothQueue.Count >= smoothing) { lastSum -= smoothQueue.Dequeue(); } float num = Random.Range(minIntensity, maxIntensity); smoothQueue.Enqueue(num); lastSum += num; light.intensity = lastSum / (float)smoothQueue.Count; } } } public class LookAtPlayer : MonoBehaviour { private void Update() { //IL_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val != (Object)null) { ((Component)this).transform.LookAt(((Component)val).transform.position + Vector3.up); } } } public class SpawnPosition : MonoBehaviour { private void Start() { } private void Update() { } } namespace Backrooms { public class Backrooms : NetworkBehaviour { public static Backrooms Instance; public GameObject Floor; public GameObject Wall; public GameObject Ceiling; public GameObject LightlessCeiling; public GameObject Pillar; public GameObject Room; public static float Offset = -500f; private int Width = 30; private int Height = 30; public List<Vector2> PossibleSpawnPoint; public List<PlayerControllerB> playerInBackrooms; public NetworkVariable<float> SharedOdds = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public DungeonFlow Flow; public GameObject Child; public bool IsReady => PossibleSpawnPoint.Count > 0; public override void OnNetworkSpawn() { if (((NetworkBehaviour)this).IsServer) { SharedOdds.Value = Loader.TeleportationOdds.Value; } } private void Awake() { PossibleSpawnPoint = new List<Vector2>(); playerInBackrooms = new List<PlayerControllerB>(); } private void Start() { Instance = this; } public override void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } ((NetworkBehaviour)this).OnDestroy(); } public void ServerGenerate() { GenerateClientRpc(Random.Range(0, 1000000)); } public void ServerClean() { Smiler[] array = Object.FindObjectsOfType<Smiler>(); for (int i = 0; i < array.Length; i++) { ((Component)array[i]).GetComponent<NetworkObject>().Despawn(true); } playerInBackrooms.Clear(); CleanBackroomsClientRpc(); } [ClientRpc] public void CleanBackroomsClientRpc() { //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) //IL_00da: 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(2180494496u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2180494496u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; foreach (Transform item in ((Component)this).transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } PossibleSpawnPoint.Clear(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { BackroomsHelper component = ((Component)allPlayerScripts[i]).GetComponent<BackroomsHelper>(); component.HasBeenInTheBackrooms = false; component.InBackrooms = false; } } [ServerRpc(RequireOwnership = false)] public void TeleportToBackroomsServerRpc(int client) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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(2541916904u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, client); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2541916904u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (IsReady) { Vector2 spawn = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)]; TeleportToBackroomsClientRpc(client, spawn); } } } [ClientRpc] public void TeleportToBackroomsClientRpc(int client, Vector2 spawn) { //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_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_00ee: 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) 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(2451931559u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, client); ((FastBufferWriter)(ref val)).WriteValueSafe(ref spawn); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2451931559u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[client]; val3.TeleportPlayer(new Vector3(spawn.x, Offset, spawn.y), false, 0f, false, true); val3.isInsideFactory = true; val3.ResetFallGravity(); BackroomsHelper component = ((Component)val3).GetComponent<BackroomsHelper>(); component.HasBeenInTheBackrooms = true; component.InBackrooms = true; if (((NetworkBehaviour)this).IsServer && !playerInBackrooms.Contains(val3)) { playerInBackrooms.Add(val3); } } } [ServerRpc(RequireOwnership = false)] public void TeleportOutOfBackroomsServerRpc(ulong clientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3409688981u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 3409688981u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; TeleportOutOfBackroomsClientRpc((int)clientId); } } } [ClientRpc] public void TeleportOutOfBackroomsClientRpc(int client) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: 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_00ed: 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(1623403188u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, client); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1623403188u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[client]; val3.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[0].position, false, 0f, false, true); val3.isInsideFactory = false; ((Component)val3).GetComponent<BackroomsHelper>().InBackrooms = false; if (((NetworkBehaviour)this).IsServer) { playerInBackrooms.Remove(val3); } } } [ClientRpc] public void GenerateClientRpc(int seed) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0554: 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_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_042e: 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(890432861u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, seed); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 890432861u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; PossibleSpawnPoint.Clear(); playerInBackrooms.Clear(); Random random = new Random(seed); Debug.Log((object)"Generate floor and ceiling"); for (int i = -Width / 2; i < Width / 2; i++) { for (int j = -Height / 2; j < Height / 2; j++) { Object.Instantiate<GameObject>(Floor, new Vector3((float)(i * 6), Offset, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); if (random.Next(100) < 85) { Object.Instantiate<GameObject>(LightlessCeiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); } else { Object.Instantiate<GameObject>(Ceiling, new Vector3((float)(i * 6), Offset + 5f, (float)(j * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); } } } Debug.Log((object)"Generate walls"); for (int k = -Width / 2; k < Width / 2; k++) { Object.Instantiate<GameObject>(Wall, new Vector3((float)(-Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); if (k != 0) { Object.Instantiate<GameObject>(Wall, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); continue; } Debug.Log((object)"Generate room"); Object.Instantiate<GameObject>(Room, new Vector3((float)(Width / 2 * 6 - 3), Offset, (float)(k * 6)), Quaternion.Euler(0f, 90f, 0f), ((Component)this).transform); } Debug.Log((object)"Generate walls 2"); for (int l = -Width / 2; l < Width / 2; l++) { Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(-Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform); Object.Instantiate<GameObject>(Wall, new Vector3((float)(l * 6), Offset, (float)(Height / 2 * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform); } Debug.Log((object)"Generate inside 2"); for (int m = -Width / 2; m < Width / 2; m++) { for (int n = -Height / 2; n < Height / 2; n++) { if (m == 0 && n == 0) { continue; } int num = random.Next(20); if (num < 15) { if (random.Next(10) < 5) { Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6 - 3), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); } else { Object.Instantiate<GameObject>(Wall, new Vector3((float)(m * 6), Offset, (float)(n * 6 - 3)), Quaternion.Euler(-90f, 90f, 0f), ((Component)this).transform); } } else if (num == 16) { Object.Instantiate<GameObject>(Pillar, new Vector3((float)(m * 6), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform); } else { PossibleSpawnPoint.Add(new Vector2((float)(m * 6), (float)(n * 6))); } } } if (((NetworkBehaviour)this).IsServer) { ((Component)this).GetComponent<NavMeshSurface>().BuildNavMesh(); GameObject val3 = Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/smile.prefab"); for (int num2 = 0; num2 < Loader.NumberOfSmilers.Value; num2++) { Vector2 val4 = PossibleSpawnPoint[Random.Range(0, PossibleSpawnPoint.Count)]; Object.Instantiate<GameObject>(val3, new Vector3(val4.x, Offset, val4.y), Quaternion.identity, ((Component)this).transform).GetComponent<NetworkObject>().Spawn(false); } } } protected override void __initializeVariables() { if (SharedOdds == null) { throw new Exception("Backrooms.SharedOdds cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)SharedOdds).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SharedOdds, "SharedOdds"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)SharedOdds); ((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 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2180494496u, new RpcReceiveHandler(__rpc_handler_2180494496), "CleanBackroomsClientRpc"); ((NetworkBehaviour)this).__registerRpc(2541916904u, new RpcReceiveHandler(__rpc_handler_2541916904), "TeleportToBackroomsServerRpc"); ((NetworkBehaviour)this).__registerRpc(2451931559u, new RpcReceiveHandler(__rpc_handler_2451931559), "TeleportToBackroomsClientRpc"); ((NetworkBehaviour)this).__registerRpc(3409688981u, new RpcReceiveHandler(__rpc_handler_3409688981), "TeleportOutOfBackroomsServerRpc"); ((NetworkBehaviour)this).__registerRpc(1623403188u, new RpcReceiveHandler(__rpc_handler_1623403188), "TeleportOutOfBackroomsClientRpc"); ((NetworkBehaviour)this).__registerRpc(890432861u, new RpcReceiveHandler(__rpc_handler_890432861), "GenerateClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2180494496(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).CleanBackroomsClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2541916904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int client = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref client); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).TeleportToBackroomsServerRpc(client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2451931559(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0052: 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 client = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref client); Vector2 spawn = default(Vector2); ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawn); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).TeleportToBackroomsClientRpc(client, spawn); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3409688981(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong clientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref clientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).TeleportOutOfBackroomsServerRpc(clientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1623403188(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int client = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref client); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).TeleportOutOfBackroomsClientRpc(client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_890432861(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int seed = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref seed); target.__rpc_exec_stage = (__RpcExecStage)1; ((Backrooms)(object)target).GenerateClientRpc(seed); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "Backrooms"; } } public class BackroomsHelper : MonoBehaviour { public bool HasBeenInTheBackrooms; public bool InBackrooms; } [HarmonyPatch(typeof(PlayerControllerB), "PlayFootstepSound")] public static class CarpetFootsteps { private static AudioClip[] carpetClips = Array.Empty<AudioClip>(); private static AudioClip[][] savedClips; public static void Load(string pluginDir) { carpetClips = (from i in Enumerable.Range(1, 4) select LoadWav(Path.Combine(pluginDir, "carpet", $"CarpetStep{i}.wav")) into clip where (Object)(object)clip != (Object)null select clip).ToArray(); } private static AudioClip LoadWav(string path) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 if (!File.Exists(path)) { Debug.LogWarning((object)("Backrooms: missing carpet sound " + path)); return null; } UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), (AudioType)20); try { UnityWebRequestAsyncOperation val = audioClip.SendWebRequest(); while (!((AsyncOperation)val).isDone) { } if ((int)audioClip.result != 1) { Debug.LogWarning((object)("Backrooms: could not load " + path + ": " + audioClip.error)); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); ((Object)content).name = Path.GetFileNameWithoutExtension(path); return content; } finally { ((IDisposable)audioClip)?.Dispose(); } } [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance) { if (carpetClips.Length == 0) { return; } BackroomsHelper component = ((Component)__instance).GetComponent<BackroomsHelper>(); if (!((Object)(object)component == (Object)null) && component.InBackrooms) { FootstepSurface[] footstepSurfaces = StartOfRound.Instance.footstepSurfaces; savedClips = new AudioClip[footstepSurfaces.Length][]; for (int i = 0; i < footstepSurfaces.Length; i++) { savedClips[i] = footstepSurfaces[i].clips; footstepSurfaces[i].clips = carpetClips; } } } [HarmonyFinalizer] private static void Finalizer() { if (savedClips != null) { FootstepSurface[] footstepSurfaces = StartOfRound.Instance.footstepSurfaces; for (int i = 0; i < footstepSurfaces.Length && i < savedClips.Length; i++) { footstepSurfaces[i].clips = savedClips[i]; } savedClips = null; } } } public class Exit : MonoBehaviour { private void OnTriggerEnter(Collider other) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)Backrooms.Instance != (Object)null) { Backrooms.Instance.TeleportOutOfBackroomsServerRpc(component.playerClientId); } } } public static class Hook { private static bool TryTeleport(PlayerControllerB player) { Backrooms instance = Backrooms.Instance; if ((Object)(object)instance == (Object)null || !instance.IsReady) { return false; } if (!((NetworkBehaviour)player).IsOwner || player.isPlayerDead || !player.AllowPlayerDeath()) { return false; } if (((Component)player).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms) { return false; } if ((float)Random.Range(0, 100) >= instance.SharedOdds.Value) { return false; } Debug.Log((object)$"Backrooms: teleporting player {player.playerClientId} (odds {instance.SharedOdds.Value}%)"); ((Component)player).GetComponent<BackroomsHelper>().HasBeenInTheBackrooms = true; instance.TeleportToBackroomsServerRpc((int)player.playerClientId); return true; } [HarmonyPatch(typeof(KillLocalPlayer), "KillPlayer")] [HarmonyPrefix] private static bool BeforeKilling(PlayerControllerB playerWhoTriggered) { return !TryTeleport(playerWhoTriggered); } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyPrefix] private static bool BeforeDamage(PlayerControllerB __instance) { return !TryTeleport(__instance); } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void AddComponents(PlayerControllerB __instance) { ((Component)__instance).gameObject.AddComponent<BackroomsHelper>(); } [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPostfix] private static void SpawnBackrooms(RoundManager __instance) { //IL_0030: 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) if (((NetworkBehaviour)__instance).IsServer) { Debug.Log((object)"Spawning backrooms"); Object.Instantiate<GameObject>(Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/backrooms.prefab"), new Vector3(0f, Backrooms.Offset, 0f), Quaternion.identity).GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")] [HarmonyPostfix] public static void DeleteBackrooms(RoundManager __instance) { if (((NetworkBehaviour)__instance).IsServer && (Object)(object)Backrooms.Instance != (Object)null) { Backrooms.Instance.ServerClean(); } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] public static void GenerateBackrooms(RoundManager __instance) { if (((NetworkBehaviour)__instance).IsServer && (Object)(object)Backrooms.Instance != (Object)null) { Backrooms.Instance.ServerGenerate(); } } [HarmonyPatch(typeof(StartOfRound), "WritePlayerNotes")] [HarmonyPostfix] public static void BackroomsPlayerNote(StartOfRound __instance) { for (int i = 0; i < __instance.gameStats.allPlayerStats.Length; i++) { if (__instance.gameStats.allPlayerStats[i].isActivePlayer) { PlayerControllerB val = __instance.allPlayerScripts[i]; BackroomsHelper component = ((Component)val).GetComponent<BackroomsHelper>(); if (!((Object)(object)component == (Object)null) && component.HasBeenInTheBackrooms) { __instance.gameStats.allPlayerStats[i].playerNotes.Add(val.isPlayerDead ? "Should have been more careful in the Backrooms." : "Had a blast in the Backrooms."); } } } } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] public static void NetworkManagerPatch() { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && !NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs.Any((NetworkPrefab pref) => (Object)(object)pref.Prefab != (Object)null && ((Object)pref.Prefab).name == "backrooms")) { Debug.Log((object)"Load prefabs to Network Manager"); string[] array = new string[2] { "assets/backrooms/backrooms.prefab", "assets/backrooms/smile.prefab" }; foreach (string text in array) { NetworkManager.Singleton.AddNetworkPrefab(Loader.AssetBundle.LoadAsset<GameObject>(text)); } } } } [BepInPlugin("Neekhaulas.Backrooms", "Backrooms", "0.3.0")] public class Loader : BaseUnityPlugin { public static AssetBundle AssetBundle { get; private set; } public static ConfigEntry<float> TeleportationOdds { get; private set; } public static ConfigEntry<int> NumberOfSmilers { get; private set; } private void Awake() { TeleportationOdds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Teleportation odds", 3f, "Odds to be teleported (in %) - This settings has to be changed by the host"); NumberOfSmilers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Number of smilers", 1, "Number of smilers to spawn in the Backrooms - This settings has to be changed by the host"); AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "backrooms")); if ((Object)(object)AssetBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not load the 'backrooms' asset bundle next to Backrooms.dll."); return; } Harmony.CreateAndPatchAll(typeof(Hook), (string)null); CarpetFootsteps.Load(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); Harmony.CreateAndPatchAll(typeof(CarpetFootsteps), (string)null); InitializeNetcode(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Backrooms is loaded!"); } private static void InitializeNetcode() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public class Smiler : NetworkBehaviour { private NavMeshAgent NavMeshAgent; private PlayerControllerB Target; private void Start() { NavMeshAgent = ((Component)this).GetComponent<NavMeshAgent>(); } private void Update() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || (Object)(object)Backrooms.Instance == (Object)null || !Backrooms.Instance.IsReady) { return; } if ((Object)(object)Target != (Object)null && Target.isPlayerDead) { Target = null; NavMeshAgent.speed = 2f; } if (!NavMeshAgent.pathPending && NavMeshAgent.remainingDistance <= NavMeshAgent.stoppingDistance) { if (NavMeshAgent.hasPath) { Vector3 velocity = NavMeshAgent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude != 0f) { goto IL_011b; } } if ((Object)(object)Target != (Object)null) { NavMeshAgent.SetDestination(((Component)Target).transform.position); } else { Vector2 val = Backrooms.Instance.PossibleSpawnPoint[Random.Range(0, Backrooms.Instance.PossibleSpawnPoint.Count)]; NavMeshAgent.SetDestination(new Vector3(val.x, Backrooms.Offset, val.y)); } } goto IL_011b; IL_011b: PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (val2.isPlayerControlled && !val2.isPlayerDead) { if (val2.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 15, -1f, -1)) { Target = val2; NavMeshAgent.SetDestination(((Component)val2).transform.position); NavMeshAgent.speed = 7f; break; } if ((IsLitFlashlight(val2.currentlyHeldObjectServer) || IsLitFlashlight(val2.pocketedFlashlight)) && val2.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up, 45f, 100, -1f, -1)) { Target = val2; NavMeshAgent.SetDestination(((Component)val2).transform.position); NavMeshAgent.speed = 7f; } } } } private static bool IsLitFlashlight(GrabbableObject item) { if ((Object)(object)item != (Object)null && ((object)item).GetType() == typeof(FlashlightItem)) { return item.isBeingUsed; } return false; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "Smiler"; } } public class SoundPatch : MonoBehaviour { private void Start() { ((Component)this).gameObject.AddComponent<OccludeAudio>(); ((Component)this).GetComponent<AudioSource>().Play(); } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } } namespace Backrooms.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }