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 DoorSync v1.4.0
DoorSync.dll
Decompiled 5 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; [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("DoorSync")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0")] [assembly: AssemblyProduct("DoorSync")] [assembly: AssemblyTitle("DoorSync")] [assembly: AssemblyVersion("1.4.0.0")] [module: RefSafetyRules(11)] 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; } } } namespace DoorSync { internal static class AnimSync { private struct AnimMsg { public string Path; public Vector3 Position; public bool IsTriggerType; public bool SetBool; public bool PlaySecondary; public int PlayerWhoTriggered; public void Write(FastBufferWriter w) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0041: 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_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references) ((FastBufferWriter)(ref w)).WriteValueSafe(Path, false); ((FastBufferWriter)(ref w)).WriteValueSafe(ref Position); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref IsTriggerType, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref SetBool, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref PlaySecondary, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref PlayerWhoTriggered, default(ForPrimitives)); } public static AnimMsg Read(FastBufferReader r) { //IL_0030: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0064: 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_007b: Unknown result type (might be due to invalid IL or missing references) AnimMsg result = default(AnimMsg); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Path, false); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Position); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref result.IsTriggerType, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref result.SetBool, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref result.PlaySecondary, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.PlayerWhoTriggered, default(ForPrimitives)); return result; } } [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnToServer; public static HandleNamedMessageDelegate <1>__OnToClients; } private const string ToServer = "DoorSync_AnimToServer"; private const string ToClients = "DoorSync_AnimToClients"; private static readonly FieldInfo LocalPlayerTriggered = AccessTools.Field(typeof(AnimatedObjectTrigger), "localPlayerTriggered"); private static readonly MethodInfo PlayAudio = AccessTools.Method(typeof(AnimatedObjectTrigger), "PlayAudio", (Type[])null, (Type[])null); private static readonly MethodInfo SetParticle = AccessTools.Method(typeof(AnimatedObjectTrigger), "SetParticleBasedOnBoolean", (Type[])null, (Type[])null); private static bool _registered; [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Start")] private static void Register() { //IL_0033: 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) //IL_003e: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null) { CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; object obj = <>O.<0>__OnToServer; if (obj == null) { HandleNamedMessageDelegate val = OnToServer; <>O.<0>__OnToServer = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("DoorSync_AnimToServer", (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnToClients; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnToClients; <>O.<1>__OnToClients = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("DoorSync_AnimToClients", (HandleNamedMessageDelegate)obj2); _registered = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] private static void Unregister() { if (_registered) { _registered = false; NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null) { singleton.CustomMessagingManager.UnregisterNamedMessageHandler("DoorSync_AnimToServer"); singleton.CustomMessagingManager.UnregisterNamedMessageHandler("DoorSync_AnimToClients"); } } } [HarmonyPrefix] [HarmonyPriority(0)] [HarmonyPatch(typeof(AnimatedObjectTrigger), "UpdateAnimServerRpc")] private static bool InterceptBool(AnimatedObjectTrigger __instance, bool setBool, bool playSecondaryAudios, int playerWhoTriggered) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).IsSpawned) { return true; } Send(new AnimMsg { Path = PathKey(((Component)__instance).transform), Position = ((Component)__instance).transform.position, IsTriggerType = false, SetBool = setBool, PlaySecondary = playSecondaryAudios, PlayerWhoTriggered = playerWhoTriggered }); return false; } [HarmonyPrefix] [HarmonyPriority(0)] [HarmonyPatch(typeof(AnimatedObjectTrigger), "UpdateAnimTriggerServerRpc")] private static bool InterceptTrigger(AnimatedObjectTrigger __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).IsSpawned) { return true; } Send(new AnimMsg { Path = PathKey(((Component)__instance).transform), Position = ((Component)__instance).transform.position, IsTriggerType = true, PlayerWhoTriggered = -1 }); return false; } private unsafe static void Send(AnimMsg msg) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { return; } if (singleton.IsServer) { ServerHandle(msg, singleton); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, 4096); try { msg.Write(val); singleton.CustomMessagingManager.SendNamedMessage("DoorSync_AnimToServer", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnToServer(ulong sender, FastBufferReader reader) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } AnimMsg msg; try { msg = AnimMsg.Read(reader); } catch (Exception ex) { Plugin.Log.LogError((object)$"Bad object message from {sender}: {ex.Message}"); return; } StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null)) { if (msg.PlayerWhoTriggered != -1 && (!instance.ClientPlayerList.TryGetValue(sender, out var value) || value != msg.PlayerWhoTriggered)) { Plugin.Log.LogWarning((object)$"Ignored object message from client {sender}: claims player {msg.PlayerWhoTriggered}"); } else { ServerHandle(msg, singleton); } } } private unsafe static void ServerHandle(AnimMsg msg, NetworkManager nm) { //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) AnimatedObjectTrigger val = Find(msg); if ((Object)(object)val != (Object)null) { Apply(val, msg); } List<ulong> list = new List<ulong>(); foreach (ulong connectedClientsId in nm.ConnectedClientsIds) { if (connectedClientsId != 0L) { list.Add(connectedClientsId); } } if (list.Count == 0) { return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(128, (Allocator)2, 4096); try { msg.Write(val2); nm.CustomMessagingManager.SendNamedMessage("DoorSync_AnimToClients", (IReadOnlyList<ulong>)list, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnToClients(ulong sender, FastBufferReader reader) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AnimMsg msg; try { msg = AnimMsg.Read(reader); } catch (Exception ex) { Plugin.Log.LogError((object)("Bad object message: " + ex.Message)); return; } AnimatedObjectTrigger val = Find(msg); if ((Object)(object)val != (Object)null) { Apply(val, msg); } } private static void Apply(AnimatedObjectTrigger t, AnimMsg msg) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; try { if (msg.IsTriggerType) { ((UnityEvent<bool>)(object)t.onTriggerBool)?.Invoke(false); if (LocalPlayerTriggered != null && (bool)LocalPlayerTriggered.GetValue(t)) { LocalPlayerTriggered.SetValue(t, false); return; } if ((Object)(object)t.triggerAnimator != (Object)null) { t.triggerAnimator.SetTrigger(t.animationString); } PlayAudio?.Invoke(t, new object[2] { false, false }); } else { if ((Object)(object)val == (Object)null || (msg.PlayerWhoTriggered != -1 && (int)val.playerClientId == msg.PlayerWhoTriggered)) { return; } if (t.isBool) { if ((Object)(object)t.triggerAnimatorB != (Object)null) { t.triggerAnimatorB.SetBool("on", msg.SetBool); } t.boolValue = msg.SetBool; if ((Object)(object)t.triggerAnimator != (Object)null) { t.triggerAnimator.SetBool(t.animationString, msg.SetBool); } ((UnityEvent<bool>)(object)t.onTriggerBool)?.Invoke(t.boolValue); } else if ((Object)(object)t.triggerAnimator != (Object)null) { t.triggerAnimator.SetTrigger(t.animationString); } SetParticle?.Invoke(t, null); PlayAudio?.Invoke(t, new object[2] { msg.SetBool, msg.PlaySecondary }); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not apply object state to '" + msg.Path + "': " + ex.Message)); } } private static string PathKey(Transform t) { StringBuilder stringBuilder = new StringBuilder(); while ((Object)(object)t != (Object)null) { stringBuilder.Insert(0, ((Object)(object)t.parent != (Object)null) ? $"/{((Object)t).name}#{t.GetSiblingIndex()}" : ((Object)t).name); t = t.parent; } return stringBuilder.ToString(); } private static AnimatedObjectTrigger Find(AnimMsg msg) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) AnimatedObjectTrigger val = null; float num = float.MaxValue; AnimatedObjectTrigger[] array = Object.FindObjectsOfType<AnimatedObjectTrigger>(); foreach (AnimatedObjectTrigger val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((NetworkBehaviour)val2).IsSpawned) { if (PathKey(((Component)val2).transform) == msg.Path) { return val2; } Vector3 val3 = ((Component)val2).transform.position - msg.Position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val2; } } } if ((Object)(object)val != (Object)null && num < 4f) { Plugin.Log.LogWarning((object)("No object matched path '" + msg.Path + "'; using nearest by position")); return val; } Plugin.Log.LogWarning((object)("Could not find object '" + msg.Path + "' on this client")); return null; } } [BepInPlugin("zandromic.doorsync", "DoorSync", "1.4.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "zandromic.doorsync"; public const string Name = "DoorSync"; public const string Version = "1.4.0"; internal const string ToServerMsg = "DoorSync_ToServer"; internal const string ToClientsMsg = "DoorSync_ToClients"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("zandromic.doorsync"); val.PatchAll(typeof(Patches)); val.PatchAll(typeof(AnimSync)); Log.LogInfo((object)"DoorSync 1.4.0 loaded"); } } internal struct DoorUse { public int EntranceId; public bool IsEntranceToBuilding; public Vector3 Position; public int PlayerObj; public void Write(FastBufferWriter w) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0043: 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) ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref EntranceId, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref IsEntranceToBuilding, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe(ref Position); ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref PlayerObj, default(ForPrimitives)); } public static DoorUse Read(FastBufferReader r) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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: 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_0055: Unknown result type (might be due to invalid IL or missing references) DoorUse result = default(DoorUse); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.EntranceId, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref result.IsEntranceToBuilding, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Position); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref result.PlayerObj, default(ForPrimitives)); return result; } public override string ToString() { return string.Format("door id {0} ({1}) player {2}", EntranceId, IsEntranceToBuilding ? "outside" : "inside", PlayerObj); } } internal static class Patches { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnToServer; public static HandleNamedMessageDelegate <1>__OnToClients; } private const int MsgSize = 64; private static readonly MethodInfo SetAudioPresetMethod = AccessTools.Method(typeof(EntranceTeleport), "SetAudioPreset", (Type[])null, (Type[])null); private static bool _registered; [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Start")] private static void RegisterHandlers() { //IL_0033: 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) //IL_003e: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null) { CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; object obj = <>O.<0>__OnToServer; if (obj == null) { HandleNamedMessageDelegate val = OnToServer; <>O.<0>__OnToServer = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("DoorSync_ToServer", (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnToClients; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnToClients; <>O.<1>__OnToClients = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("DoorSync_ToClients", (HandleNamedMessageDelegate)obj2); _registered = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] private static void UnregisterHandlers() { if (_registered) { _registered = false; NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null) { singleton.CustomMessagingManager.UnregisterNamedMessageHandler("DoorSync_ToServer"); singleton.CustomMessagingManager.UnregisterNamedMessageHandler("DoorSync_ToClients"); } } } [HarmonyPrefix] [HarmonyPriority(800)] [HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")] private static void PruneDestroyedOutsideNodes(RoundManager __instance) { PruneNow(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")] private static void PruneNextFrame(RoundManager __instance) { ((MonoBehaviour)__instance).StartCoroutine(PruneAfterFrame(__instance)); } private static IEnumerator PruneAfterFrame(RoundManager rm) { yield return null; if ((Object)(object)rm != (Object)null) { PruneNow(rm); } } private static void PruneNow(RoundManager __instance) { GameObject[] outsideAINodes = __instance.outsideAINodes; if (outsideAINodes == null || outsideAINodes.Length == 0) { return; } int num = 0; GameObject[] array = outsideAINodes; for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { num++; } } if (num == outsideAINodes.Length) { return; } GameObject[] array2 = (GameObject[])(object)new GameObject[num]; int num2 = 0; array = outsideAINodes; foreach (GameObject val in array) { if ((Object)(object)val != (Object)null) { array2[num2++] = val; } } __instance.outsideAINodes = array2; Plugin.Log.LogInfo((object)$"Removed {outsideAINodes.Length - num} destroyed outside AI node(s) from RoundManager.outsideAINodes"); } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "DisplayTip")] private static bool FilterLethalPerformanceTip(string prefsKey) { if (prefsKey != "LP_ETBAD") { return true; } int num = 0; EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); foreach (EntranceTeleport val in array) { if (!((Object)(object)val == (Object)null) && !((NetworkBehaviour)val).IsSpawned) { num++; bool flag; try { flag = val.FindExitPoint() && (Object)(object)val.exitPoint != (Object)null; } catch { flag = false; } if (!flag) { Plugin.Log.LogWarning((object)$"Door '{((Object)val).name}' (id {val.entranceId}) has no exit - showing LethalPerformance warning"); return true; } } } if (num == 0) { return true; } Plugin.Log.LogInfo((object)$"Suppressed LethalPerformance 'Entrance teleport mismatch' tip: all {num} non-networked door(s) connect"); return false; } [HarmonyPrefix] [HarmonyPriority(0)] [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerServerRpc")] private unsafe static bool InterceptUnspawnedDoor(EntranceTeleport __instance, int playerObj) { //IL_0055: 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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).IsSpawned) { return true; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { return false; } DoorUse use = new DoorUse { EntranceId = __instance.entranceId, IsEntranceToBuilding = __instance.isEntranceToBuilding, Position = ((Component)__instance).transform.position, PlayerObj = playerObj }; if (singleton.IsServer) { SendToClients(use, singleton); } else { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { use.Write(val); singleton.CustomMessagingManager.SendNamedMessage("DoorSync_ToServer", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } return false; } private static void OnToServer(ulong sender, FastBufferReader reader) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } DoorUse use; try { use = DoorUse.Read(reader); } catch (Exception ex) { Plugin.Log.LogError((object)$"Bad door message from {sender}: {ex.Message}"); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || use.PlayerObj < 0 || use.PlayerObj >= instance.allPlayerScripts.Length) { return; } if (!instance.ClientPlayerList.TryGetValue(sender, out var value) || value != use.PlayerObj) { Plugin.Log.LogWarning((object)$"Ignored door message from client {sender}: claims player {use.PlayerObj}"); return; } EntranceTeleport val = FindDoor(use); if ((Object)(object)val != (Object)null) { ApplyDoorUse(val, use); } SendToClients(use, singleton); } private unsafe static void SendToClients(DoorUse use, NetworkManager nm) { //IL_004f: 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) List<ulong> list = new List<ulong>(); foreach (ulong connectedClientsId in nm.ConnectedClientsIds) { if (connectedClientsId != 0L) { list.Add(connectedClientsId); } } if (list.Count == 0) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { use.Write(val); nm.CustomMessagingManager.SendNamedMessage("DoorSync_ToClients", (IReadOnlyList<ulong>)list, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnToClients(ulong sender, FastBufferReader reader) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) DoorUse use; try { use = DoorUse.Read(reader); } catch (Exception ex) { Plugin.Log.LogError((object)("Bad door message: " + ex.Message)); return; } EntranceTeleport val = FindDoor(use); if ((Object)(object)val != (Object)null) { ApplyDoorUse(val, use); } } private static EntranceTeleport FindDoor(DoorUse use) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport val = null; EntranceTeleport val2 = null; float num = float.MaxValue; EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); foreach (EntranceTeleport val3 in array) { if (!((Object)(object)val3 == (Object)null) && val3.isEntranceToBuilding == use.IsEntranceToBuilding) { if (val3.entranceId == use.EntranceId && !((NetworkBehaviour)val3).IsSpawned) { val = val3; } Vector3 val4 = ((Component)val3).transform.position - use.Position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val2 = val3; } } } if ((Object)(object)val != (Object)null) { return val; } if ((Object)(object)val2 != (Object)null && num < 25f) { Plugin.Log.LogWarning((object)$"No door matched {use}; using nearest door by position"); return val2; } Plugin.Log.LogWarning((object)$"Could not find {use} on this client"); return null; } private static void ApplyDoorUse(EntranceTeleport door, DoorUse use) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || use.PlayerObj < 0 || use.PlayerObj >= instance.allPlayerScripts.Length) { return; } PlayerControllerB val = instance.allPlayerScripts[use.PlayerObj]; PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)val2) { return; } if (!door.FindExitPoint() || (Object)(object)door.exitPoint == (Object)null) { Plugin.Log.LogWarning((object)$"{use}: door has no exit on this client"); return; } val.TeleportPlayer(door.exitPoint.position, true, door.exitPoint.eulerAngles.y, false, true); val.isInElevator = false; val.isInHangarShipRoom = false; try { door.PlayAudioAtTeleportPositions(); } catch (Exception ex) { Plugin.Log.LogDebug((object)("Door audio skipped: " + ex.Message)); } val.isInsideFactory = door.isEntranceToBuilding; GrabbableObject[] itemSlots = val.ItemSlots; foreach (GrabbableObject val3 in itemSlots) { if ((Object)(object)val3 != (Object)null) { val3.isInFactory = door.isEntranceToBuilding; } } if ((Object)(object)val2 != (Object)null && val2.isPlayerDead && (Object)(object)val == (Object)(object)val2.spectatedPlayerScript && SetAudioPresetMethod != null) { try { SetAudioPresetMethod.Invoke(door, new object[1] { use.PlayerObj }); } catch (Exception ex2) { Plugin.Log.LogDebug((object)("Spectator reverb skipped: " + ex2.Message)); } } door.timeAtLastUse = Time.realtimeSinceStartup; } } }