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 LethalSleep v0.1.1
LethalSleep.dll
Decompiled a year 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.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalSleep.NetcodePatcher; using LethalSleep.Resources; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LethalSleep")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalSleep")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("DF90D888-BF76-42FA-A222-388AA13A161B")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace LethalSleep { public static class BedWorker { public const int INTERACT_LAYER = 9; public static readonly Vector3[] SleepingPositions = (Vector3[])(object)new Vector3[4] { new Vector3(-2.069098f, -0.7690924f, -0.5f), new Vector3(-2.069098f, -0.7690924f, 0.5f), new Vector3(-2.069098f, -0.7690924f, 1.5f), new Vector3(-2.069098f, -0.7690924f, 2.5f) }; public static readonly Vector3[] WakeUpPositions = (Vector3[])(object)new Vector3[4] { new Vector3(-0.4752663f, 1.189903f, -0.09496737f), new Vector3(0.488894f, 1.189903f, -0.09496737f), new Vector3(0.488894f, -1.074116f, -0.09496817f), new Vector3(-0.4752663f, -1.074116f, -0.09496817f) }; private static InteractTrigger _sleepTrigger; private static PlaceableShipObject _bed; public static readonly Dictionary<int, int> SleepingPlayers = new Dictionary<int, int>(); public static readonly List<Transform> SleepingSlots = new List<Transform>(); public static readonly Dictionary<int, Vector3> WakePlayerPos = new Dictionary<int, Vector3>(); private static int _currentSlot; public static void ConfigureBed(GameObject bed) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007f: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) PluginLogger.Debug("Configuring bed"); GameObject gameObject = ((Component)bed.transform.GetChild(0)).gameObject; gameObject.tag = "InteractTrigger"; gameObject.layer = 9; ((Renderer)gameObject.GetComponent<MeshRenderer>()).enabled = false; _bed = bed.GetComponentInChildren<PlaceableShipObject>(); int num = 0; Vector3[] sleepingPositions = SleepingPositions; foreach (Vector3 localPosition in sleepingPositions) { GameObject val = new GameObject("SleepingSlot " + num); val.transform.SetParent(bed.transform); val.transform.localPosition = localPosition; val.transform.localRotation = Quaternion.Euler(0f, 180f, 90f); SleepingSlots.Add(val.transform); num++; } InteractTrigger trigger = gameObject.AddComponent<InteractTrigger>(); SetupTrigger(trigger); } private static void SetupTrigger(InteractTrigger trigger) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown if ((Object)(object)trigger == (Object)null) { PluginLogger.Error("InteractTrigger is null"); return; } trigger.holdingInteractEvent = new InteractEventFloat(); trigger.onInteract = new InteractEvent(); trigger.onInteractEarly = new InteractEvent(); trigger.onInteractEarlyOtherClients = new InteractEvent(); trigger.onStopInteract = new InteractEvent(); trigger.onCancelAnimation = new InteractEvent(); trigger.hoverTip = "Sleep"; trigger.hoverIcon = Assets.SleepIcon; trigger.disabledHoverTip = "Not enough space to sleep"; trigger.interactable = true; trigger.oneHandedItemAllowed = true; trigger.twoHandedItemAllowed = false; trigger.holdInteraction = true; trigger.timeToHold = 0.5f; trigger.timeToHoldSpeedMultiplier = 1f; trigger.hidePlayerItem = true; ((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)OnPlayerInteract); _sleepTrigger = trigger; } public static void Update() { _bed.inUse = SleepingPlayers.Count > 0; _sleepTrigger.interactable = EnoughSpaceToSleep(); if (SleepingPlayers.Count >= SleepingPositions.Length) { return; } for (int i = 0; i < SleepingSlots.Count; i++) { if (!SleepingPlayers.ContainsValue(i)) { _sleepTrigger.playerPositionNode = SleepingSlots[i]; _currentSlot = i; break; } } } public static Vector3 GetWakeUpPosition(int playerId) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007a: Unknown result type (might be due to invalid IL or missing references) if (!WakePlayerPos.ContainsKey(playerId)) { return StartOfRound.Instance.playerSpawnPositions[0].position; } Vector3 val = WakePlayerPos[playerId] + new Vector3(0f, 0f, 2f); Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds; return (!((Bounds)(ref bounds)).Contains(val)) ? StartOfRound.Instance.playerSpawnPositions[0].position : val; } public static bool EnoughSpaceToSleep() { return SleepingPlayers.Count < SleepingPositions.Length; } private static void OnPlayerInteract(PlayerControllerB player) { if (!EnoughSpaceToSleep()) { Update(); } else { Networker.Instance.PlayerSleepServerRpc((int)player.playerClientId); } } public static void Sleep(PlayerControllerB player) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DisabledByError) { SleepingPlayers.Add((int)player.playerClientId, _currentSlot); if (!WakePlayerPos.ContainsKey((int)player.playerClientId)) { WakePlayerPos.Add((int)player.playerClientId, ((Component)player).transform.position); } player.inSpecialInteractAnimation = true; player.disableSyncInAnimation = true; Update(); } } public static void WakeUp(PlayerControllerB player) { //IL_0053: 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_006a: 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) if (SleepingPlayers.ContainsKey((int)player.playerClientId)) { SleepingPlayers.Remove((int)player.playerClientId); } player.inSpecialInteractAnimation = false; player.disableSyncInAnimation = false; ((Component)player).transform.SetParent(player.playersManager.elevatorTransform); ((Component)player).transform.localPosition = Vector3.zero; Vector3 wakeUpPosition = GetWakeUpPosition((int)player.playerClientId); WakePlayerPos.Remove((int)player.playerClientId); ((Component)player).transform.position = wakeUpPosition; Update(); } } [HarmonyPatch] public class Networker : NetworkBehaviour { public static Networker Instance; [ServerRpc(RequireOwnership = false)] public void PlayerSleepServerRpc(int playerId) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1658776184u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1658776184u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { PlayerSleepClientRpc(playerId); } } } [ClientRpc] public void PlayerSleepClientRpc(int playerId) { //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) 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(3940410982u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3940410982u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId]; if (!val3.isPlayerDead && val3.isPlayerControlled) { BedWorker.Sleep(val3); } } } [ServerRpc(RequireOwnership = false)] public void PlayerWakeUpServerRpc(int playerId) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1962355180u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1962355180u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { PlayerWakeUpClientRpc(playerId); } } } [ClientRpc] public void PlayerWakeUpClientRpc(int playerId) { //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) 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(2037218156u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2037218156u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId]; if (!val3.isPlayerDead && val3.isPlayerControlled) { BedWorker.WakeUp(val3); } } } public override void OnNetworkSpawn() { if ((Object)(object)NetworkManager.Singleton != (Object)null && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)) { Networker instance = Instance; if (instance != null) { ((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true); } } Instance = this; ((NetworkBehaviour)this).OnNetworkSpawn(); } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void SpawnNetHandler() { //IL_0028: 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) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { GameObject val = Object.Instantiate<GameObject>(Assets.NetworkPrefab, Vector3.zero, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void Init() { Assets.NetworkPrefab.AddComponent<Networker>(); NetworkManager.Singleton.AddNetworkPrefab(Assets.NetworkPrefab); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_Networker() { //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 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(1658776184u, new RpcReceiveHandler(__rpc_handler_1658776184)); NetworkManager.__rpc_func_table.Add(3940410982u, new RpcReceiveHandler(__rpc_handler_3940410982)); NetworkManager.__rpc_func_table.Add(1962355180u, new RpcReceiveHandler(__rpc_handler_1962355180)); NetworkManager.__rpc_func_table.Add(2037218156u, new RpcReceiveHandler(__rpc_handler_2037218156)); } private static void __rpc_handler_1658776184(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 playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)1; ((Networker)(object)target).PlayerSleepServerRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3940410982(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 playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)2; ((Networker)(object)target).PlayerSleepClientRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1962355180(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 playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)1; ((Networker)(object)target).PlayerWakeUpServerRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2037218156(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 playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)2; ((Networker)(object)target).PlayerWakeUpClientRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "Networker"; } } [BepInPlugin("LethalSleep", "Lethal Sleep", "0.1.0")] public class Plugin : BaseUnityPlugin { internal static bool DisabledByError; public ManualLogSource logger; private Harmony _harmony; internal static Plugin Instance { get; private set; } private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { Instance = this; logger = Logger.CreateLogSource("LethalSleep"); _harmony = new Harmony("LethalSleep"); Assets.Load(); _harmony.PatchAll(); NetcodePatcher(); if (!DisabledByError) { logger.LogInfo((object)"LethalSleep loaded successfully"); } } } private static void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } public static class PluginConstants { public const string GUID = "LethalSleep"; public const string NAME = "Lethal Sleep"; public const string VERSION = "0.1.0"; } internal static class PluginLogger { internal static void Info(object o) { Plugin.Instance.logger.LogInfo(o); } internal static void Warn(object o) { Plugin.Instance.logger.LogWarning(o); } internal static void Error(object o) { Plugin.Instance.logger.LogError(o); } internal static void Debug(object o) { Plugin.Instance.logger.LogDebug(o); } } } namespace LethalSleep.Resources { internal static class Assets { public static AssetBundle Bundle; public static Sprite SleepIcon; public static GameObject NetworkPrefab; public static void Load() { Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LethalSleep.Resources.sleepbundle"); if (manifestResourceStream == null) { PluginLogger.Error("Cannot load the asset bundle"); Plugin.DisabledByError = true; return; } Bundle = AssetBundle.LoadFromStream(manifestResourceStream); if ((Object)(object)Bundle == (Object)null) { PluginLogger.Error("Cannot load the asset bundle"); Plugin.DisabledByError = true; } else { SleepIcon = Bundle.LoadAsset<Sprite>("Assets/LCSleep/noun-sleep-2216308.png"); NetworkPrefab = Bundle.LoadAsset<GameObject>("Assets/LCSleep/NetPrefab.prefab"); } } } } namespace LethalSleep.Patches { [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatch { [HarmonyPatch("Interact_performed")] [HarmonyPostfix] internal static void InteractPerformedPatch(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && BedWorker.SleepingPlayers.ContainsKey((int)__instance.playerClientId)) { Networker.Instance.PlayerWakeUpServerRpc((int)__instance.playerClientId); } } [HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")] [HarmonyPrefix] internal static bool SetTipPatch(PlayerControllerB __instance) { if (!BedWorker.SleepingPlayers.ContainsKey((int)__instance.playerClientId)) { return true; } ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = "Wake up : [E]"; return false; } [HarmonyPatch("Update")] [HarmonyPostfix] internal static void UpdatePatch(PlayerControllerB __instance, ref float ___targetYRot) { //IL_0078: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if (!BedWorker.SleepingPlayers.ContainsKey((int)__instance.playerClientId)) { return; } if (!__instance.isPlayerControlled) { BedWorker.SleepingPlayers.Remove((int)__instance.playerClientId); return; } Transform val = BedWorker.SleepingSlots[BedWorker.SleepingPlayers[(int)__instance.playerClientId]]; ((Component)__instance).transform.SetParent(val); ((Component)__instance).transform.localPosition = Vector3.Lerp(((Component)__instance).transform.localPosition, Vector3.zero, Time.deltaTime * 10f); if (!((NetworkBehaviour)__instance).IsOwner) { ((Component)__instance).transform.localEulerAngles = new Vector3(((Component)val).transform.localEulerAngles.x, Mathf.LerpAngle(((Component)__instance).transform.localEulerAngles.y, ___targetYRot, Time.deltaTime * 10f), ((Component)val).transform.localEulerAngles.z - 90f); } } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { private static GameObject TryGetBed() { AutoParentToShip[] array = (from obj in Object.FindObjectsOfType<AutoParentToShip>() where ((Object)obj).name == "Bunkbeds" select obj).ToArray(); if (array.Length == 1) { return ((Component)array[0]).gameObject; } PluginLogger.Error("Can't find bed object or found multiples : plugin will not enable"); Plugin.DisabledByError = true; return null; } [HarmonyPatch("Start")] [HarmonyPostfix] internal static void StartPostfix() { if (!Plugin.DisabledByError) { GameObject val = TryGetBed(); if (!((Object)(object)val == (Object)null)) { BedWorker.ConfigureBed(val); } } } [HarmonyPatch("OnPlayerDC")] [HarmonyPostfix] internal static void OnPlayerDCPatch(int playerObjectNumber, ulong clientId) { if (BedWorker.SleepingPlayers.ContainsKey(playerObjectNumber)) { BedWorker.SleepingPlayers.Remove(playerObjectNumber); } } } } namespace LethalSleep.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }