using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
internal class <Module>
{
static <Module>()
{
}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
private struct MonoScriptData
{
public byte[] FilePathsData;
public byte[] TypesData;
public int TotalTypes;
public int TotalFiles;
public bool IsEditorOnly;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static MonoScriptData Get()
{
MonoScriptData result = default(MonoScriptData);
result.FilePathsData = new byte[166]
{
0, 0, 0, 1, 0, 0, 0, 24, 92, 65,
115, 115, 101, 116, 115, 92, 65, 114, 101, 89,
111, 117, 87, 97, 116, 99, 104, 101, 100, 46,
99, 115, 0, 0, 0, 1, 0, 0, 0, 29,
92, 65, 115, 115, 101, 116, 115, 92, 66, 97,
99, 107, 114, 111, 111, 109, 115, 71, 101, 110,
101, 114, 97, 116, 111, 114, 46, 99, 115, 0,
0, 0, 1, 0, 0, 0, 15, 92, 65, 115,
115, 101, 116, 115, 92, 69, 120, 105, 116, 46,
99, 115, 0, 0, 0, 1, 0, 0, 0, 15,
92, 65, 115, 115, 101, 116, 115, 92, 72, 111,
111, 107, 46, 99, 115, 0, 0, 0, 1, 0,
0, 0, 17, 92, 65, 115, 115, 101, 116, 115,
92, 76, 111, 97, 100, 101, 114, 46, 99, 115,
0, 0, 0, 1, 0, 0, 0, 18, 92, 65,
115, 115, 101, 116, 115, 92, 83, 107, 105, 98,
105, 100, 105, 46, 99, 115
};
result.TypesData = new byte[142]
{
0, 0, 0, 0, 23, 66, 97, 99, 107, 114,
111, 111, 109, 115, 124, 65, 114, 101, 89, 111,
117, 87, 97, 116, 99, 104, 101, 100, 0, 0,
0, 0, 28, 66, 97, 99, 107, 114, 111, 111,
109, 115, 124, 66, 97, 99, 107, 114, 111, 111,
109, 115, 71, 101, 110, 101, 114, 97, 116, 111,
114, 0, 0, 0, 0, 14, 66, 97, 99, 107,
114, 111, 111, 109, 115, 124, 69, 120, 105, 116,
0, 0, 0, 0, 14, 66, 97, 99, 107, 114,
111, 111, 109, 115, 124, 72, 111, 111, 107, 0,
0, 0, 0, 16, 66, 97, 99, 107, 114, 111,
111, 109, 115, 124, 76, 111, 97, 100, 101, 114,
0, 0, 0, 0, 17, 66, 97, 99, 107, 114,
111, 111, 109, 115, 124, 83, 107, 105, 98, 105,
100, 105
};
result.TotalFiles = 6;
result.TotalTypes = 6;
result.IsEditorOnly = false;
return result;
}
}
namespace Backrooms;
public class AreYouWatched : MonoBehaviour
{
private float _timer;
private float _timeToCheck = 5f;
private bool _isWatched;
private PlayerControllerB _controller;
private int _index;
public bool HasBeenInTheBackrooms;
private void Start()
{
_controller = ((Component)this).GetComponent<PlayerControllerB>();
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
if (((Object)StartOfRound.Instance.allPlayerScripts[i]).GetInstanceID() == ((Object)_controller).GetInstanceID())
{
_index = i;
break;
}
}
}
private void Update()
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
if (_controller.isPlayerDead || !_controller.isPlayerControlled || !_isWatched || HasBeenInTheBackrooms)
{
return;
}
_timer += Time.deltaTime;
if (_timer > _timeToCheck)
{
Debug.Log((object)"Check");
if (_isWatched && Random.Range(0f, 100f) < Loader.TeleportationOdds.Value)
{
Debug.Log((object)"Teleport");
BackroomsGenerator.Instance.TeleportToBackroomsClientRpc(_index, new Vector3(0f, BackroomsGenerator.Offset, 0f));
HasBeenInTheBackrooms = true;
}
_isWatched = false;
_timer = 0f;
_timeToCheck = Random.Range(8f, 15f);
}
}
public void StartBeingWatched()
{
_isWatched = true;
}
}
public class BackroomsGenerator : NetworkBehaviour
{
public static BackroomsGenerator Instance;
public GameObject Floor;
public GameObject Wall;
public GameObject Ceiling;
public GameObject LightlessCeiling;
public GameObject Pillar;
public GameObject Room;
public static float Offset = -60f;
private int Width = 30;
private int Height = 30;
private void Awake()
{
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);
}
}
}
}
private void Start()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
}
private IEnumerator Teleport()
{
yield return (object)new WaitForSeconds(10f);
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled)
{
TeleportToBackroomsClientRpc(i, new Vector3(0f, Offset, 0f));
}
}
}
public void ServerGenerate()
{
int seed = Random.Range(0, 1000000);
GenerateClientRpc(seed);
}
public void ServerClean()
{
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_00cf: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2398337161u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2398337161u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
foreach (Transform item in ((Component)this).transform)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
}
[ClientRpc]
public void TeleportToBackroomsClientRpc(int client, Vector3 position)
{
//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_00e2: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2635639541u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, client);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2635639541u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
PlayerControllerB obj = StartOfRound.Instance.allPlayerScripts[client];
obj.TeleportPlayer(position, false, 0f, false, true);
obj.isInsideFactory = true;
}
}
}
[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_010a: 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_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: 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_040a: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4262673211u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, seed);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4262673211u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
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) < 96)
{
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);
}
}
if (num == 16)
{
Object.Instantiate<GameObject>(Pillar, new Vector3((float)(m * 6), Offset, (float)(n * 6)), Quaternion.Euler(-90f, 0f, 0f), ((Component)this).transform);
}
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_BackroomsGenerator()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2398337161u, new RpcReceiveHandler(__rpc_handler_2398337161));
NetworkManager.__rpc_func_table.Add(2635639541u, new RpcReceiveHandler(__rpc_handler_2635639541));
NetworkManager.__rpc_func_table.Add(4262673211u, new RpcReceiveHandler(__rpc_handler_4262673211));
}
private static void __rpc_handler_2398337161(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)2;
((BackroomsGenerator)(object)target).CleanBackroomsClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2635639541(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);
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
target.__rpc_exec_stage = (__RpcExecStage)2;
((BackroomsGenerator)(object)target).TeleportToBackroomsClientRpc(client, position);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4262673211(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)2;
((BackroomsGenerator)(object)target).GenerateClientRpc(seed);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "BackroomsGenerator";
}
}
public class Exit : MonoBehaviour
{
private void Start()
{
}
public void TeleportAway()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
GameNetworkManager.Instance.localPlayerController.TeleportPlayer(Vector3.zero, false, 0f, false, true);
}
private void OnTriggerEnter(Collider other)
{
//IL_0029: 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.isInsideFactory = false;
component.TeleportPlayer(Object.FindObjectOfType<StartOfRound>().playerSpawnPositions[0].position, false, 0f, false, true);
}
}
}
public static class Hook
{
[HarmonyPatch(typeof(PlayerControllerB), "Start")]
[HarmonyPostfix]
private static void AddComponents(PlayerControllerB __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
((Component)__instance).gameObject.AddComponent<AreYouWatched>();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
[HarmonyPostfix]
private static void CheckIfPlayerIsInVision(PlayerControllerB __instance)
{
//IL_004a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer || __instance.isPlayerDead || !__instance.isInsideFactory)
{
return;
}
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
if (!((Object)(object)val == (Object)null) && ((Object)val).GetInstanceID() != ((Object)__instance).GetInstanceID() && __instance.HasLineOfSightToPosition(((Component)val).transform.position + Vector3.up, 60f, 60, -1f))
{
((Component)val).GetComponent<AreYouWatched>().StartBeingWatched();
}
}
}
[HarmonyPatch(typeof(RoundManager), "Start")]
[HarmonyPostfix]
private static void SpawnBackrooms(RoundManager __instance)
{
//IL_0031: 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)
if (((NetworkBehaviour)__instance).IsServer)
{
Debug.Log((object)"Spawning backrooms");
Object.Instantiate<GameObject>(Loader.AssetBundle.LoadAsset<GameObject>("assets/backrooms/backrooms.prefab"), new Vector3(0f, -50f, 0f), Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPatch(typeof(RoundManager), "UnloadSceneObjectsEarly")]
[HarmonyPrefix]
public static void DeleteBackrooms(RoundManager __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
BackroomsGenerator.Instance.ServerClean();
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
((Component)StartOfRound.Instance.allPlayerScripts[i]).GetComponent<AreYouWatched>().HasBeenInTheBackrooms = false;
}
}
}
[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
[HarmonyPostfix]
public static void GenerateBackrooms(RoundManager __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
BackroomsGenerator.Instance.ServerGenerate();
}
}
}
[BepInPlugin("Neekhaulas.Backrooms", "Backrooms", "0.0.6")]
public class Loader : BaseUnityPlugin
{
public static AssetBundle AssetBundle { get; private set; }
public static ConfigEntry<float> TeleportationOdds { 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");
AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "backrooms"));
string[] array = new string[1] { "assets/backrooms/backrooms.prefab" };
foreach (string text in array)
{
NetworkPrefabs.RegisterNetworkPrefab(AssetBundle.LoadAsset<GameObject>(text));
}
Harmony.CreateAndPatchAll(typeof(Hook), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Backrooms is loaded!");
}
}
public class Skibidi : MonoBehaviour
{
public static Skibidi instance;
private void Start()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
((Component)this).gameObject.AddComponent<OccludeAudio>();
((Component)instance).GetComponent<AudioSource>().Play();
}
public static void StartMusic()
{
((Component)instance).GetComponent<AudioSource>().Play();
}
}