Decompiled source of LethalNetSync v1.3.0

LethalNetSync.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[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("LethalNetSync")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("LethalNetSync")]
[assembly: AssemblyTitle("LethalNetSync")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 LethalNetSync
{
	[BepInPlugin("com.nadre.lethalnetsync", "LethalNetSync", "1.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		internal class StartOfRoundPatch
		{
			[HarmonyPostfix]
			private static void Postfix_Start()
			{
				NetworkBridge.OnRoundStart();
				if ((Object)(object)NetworkManager.Singleton != (Object)null && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					((MonoBehaviour)StartOfRound.Instance).StartCoroutine(PeriodicSyncLoop());
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
		internal class EndOfRoundPatch
		{
			[HarmonyPostfix]
			private static void Postfix_EndOfGame()
			{
				NetworkBridge.OnRoundEnd();
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
		internal class PlayerConnectedPatch
		{
			[CompilerGenerated]
			private sealed class <DelayedWelcomeSync>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public ulong clientId;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <DelayedWelcomeSync>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						LoggerInstance.LogInfo((object)$"[NetSync] Nouveau joueur {clientId} — envoi sync initiale des objets.");
						NetworkBridge.BroadcastAllPositionsToClient(clientId);
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			[HarmonyPostfix]
			private static void Postfix_OnPlayerConnectedClientRpc(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed, bool isChallenge)
			{
				if (!((Object)(object)NetworkManager.Singleton == (Object)null) && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					((MonoBehaviour)StartOfRound.Instance).StartCoroutine(DelayedWelcomeSync(clientId));
				}
			}

			[IteratorStateMachine(typeof(<DelayedWelcomeSync>d__1))]
			private static IEnumerator DelayedWelcomeSync(ulong clientId)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <DelayedWelcomeSync>d__1(0)
				{
					clientId = clientId
				};
			}
		}

		[CompilerGenerated]
		private sealed class <PeriodicSyncLoop>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PeriodicSyncLoop>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					try
					{
						NetworkBridge.BroadcastItemPositions();
					}
					catch
					{
					}
				}
				else
				{
					<>1__state = -1;
				}
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public const string ModGUID = "com.nadre.lethalnetsync";

		public const string ModName = "LethalNetSync";

		public const string ModVersion = "1.3.0";

		private readonly Harmony harmony = new Harmony("com.nadre.lethalnetsync");

		internal static Plugin Instance;

		internal static ManualLogSource LoggerInstance;

		private void Awake()
		{
			Instance = this;
			LoggerInstance = ((BaseUnityPlugin)this).Logger;
			LoggerInstance.LogInfo((object)"LethalNetSync v1.3.0 en cours de chargement...");
			harmony.PatchAll(typeof(Plugin).Assembly);
			LoggerInstance.LogInfo((object)"LethalNetSync v1.3.0 chargé avec succès.");
		}

		[IteratorStateMachine(typeof(<PeriodicSyncLoop>d__10))]
		private static IEnumerator PeriodicSyncLoop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PeriodicSyncLoop>d__10(0);
		}
	}
	public class DeathSyncController
	{
		[HarmonyPatch(typeof(DeadBodyInfo))]
		public class DeadBodyInfoPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void Postfix_Start(DeadBodyInfo __instance)
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				try
				{
					Logger.LogInfo((object)"[DeathSync] Initialisation physique du ragdoll joueur.");
					Animator[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Animator>(true);
					foreach (Animator val in componentsInChildren)
					{
						if ((Object)(object)val != (Object)null)
						{
							((Behaviour)val).enabled = false;
						}
					}
					if (__instance.bodyParts == null)
					{
						return;
					}
					Rigidbody[] bodyParts = __instance.bodyParts;
					foreach (Rigidbody val2 in bodyParts)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							val2.isKinematic = false;
							val2.useGravity = true;
							val2.AddForce(Random.insideUnitSphere * 0.2f, (ForceMode)1);
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Erreur sync ragdoll : " + ex.Message));
				}
			}
		}

		[HarmonyPatch(typeof(EnemyAI))]
		public class EnemyAIDeathPatch
		{
			[HarmonyPatch("KillEnemy")]
			[HarmonyPostfix]
			private static void Postfix_KillEnemy(EnemyAI __instance, bool destroy = false)
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null || destroy)
				{
					return;
				}
				try
				{
					Logger.LogInfo((object)string.Format("[DeathSync] Mort de '{0}' (ID:{1}).", __instance.enemyType?.enemyName ?? "Ennemi", ((NetworkBehaviour)__instance).NetworkObjectId));
					if ((Object)(object)__instance.agent != (Object)null)
					{
						((Behaviour)__instance.agent).enabled = false;
						__instance.agent.speed = 0f;
						__instance.agent.velocity = Vector3.zero;
					}
					Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>(true);
					foreach (Collider val in componentsInChildren)
					{
						if (!((Object)(object)val == (Object)null) && val.isTrigger && !((Object)(object)((Component)val).GetComponentInParent<ScanNodeProperties>() != (Object)null) && !((Object)((Component)val).gameObject).name.ToLower().Contains("scannode"))
						{
							val.enabled = false;
						}
					}
					if ((Object)(object)__instance.creatureAnimator != (Object)null)
					{
						__instance.creatureAnimator.SetBool("Sprinting", false);
						__instance.creatureAnimator.SetBool("Crouching", false);
						__instance.creatureAnimator.SetTrigger("dead");
						__instance.creatureAnimator.SetBool("isDead", true);
					}
					Rigidbody[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Rigidbody>(true);
					foreach (Rigidbody val2 in componentsInChildren2)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							val2.isKinematic = false;
							val2.useGravity = true;
						}
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Erreur sync mort ennemi : " + ex.Message));
				}
			}
		}

		private static readonly ManualLogSource Logger = Logger.CreateLogSource("LethalNetSync.DeathSyncController");
	}
	public class NetworkOptimizer
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		public class StartOfRoundPatch
		{
			[HarmonyPostfix]
			private static void Postfix_Start()
			{
				try
				{
					if (!((Object)(object)NetworkManager.Singleton == (Object)null))
					{
						string arg = (NetworkManager.Singleton.IsHost ? "Hôte" : (NetworkManager.Singleton.IsServer ? "Serveur Dédié" : "Client"));
						Logger.LogInfo((object)$"[NetSync] Réseau actif — Mode: {arg} | TickRate: {NetworkManager.Singleton.NetworkConfig.TickRate} Hz");
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Erreur optimisation réseau : " + ex.Message));
				}
			}
		}

		[HarmonyPatch(typeof(HangarShipDoor), "SetDoorClosed")]
		public class HangarDoorClosePatch
		{
			[HarmonyPostfix]
			private static void Postfix_SetDoorClosed()
			{
				if (!((Object)(object)NetworkManager.Singleton == (Object)null) && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					NetworkBridge.BroadcastDoorState(isClosed: true);
				}
			}
		}

		[HarmonyPatch(typeof(HangarShipDoor), "SetDoorOpen")]
		public class HangarDoorOpenPatch
		{
			[HarmonyPostfix]
			private static void Postfix_SetDoorOpen()
			{
				if (!((Object)(object)NetworkManager.Singleton == (Object)null) && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					NetworkBridge.BroadcastDoorState(isClosed: false);
				}
			}
		}

		private static readonly ManualLogSource Logger = Logger.CreateLogSource("LethalNetSync.NetworkOptimizer");
	}
	public static class NetworkBridge
	{
		[HarmonyPatch(typeof(GrabbableObject))]
		public class GrabbableObjectSyncPatch
		{
			[CompilerGenerated]
			private sealed class <SyncItemAfterLanding>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public GrabbableObject item;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <SyncItemAfterLanding>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						if ((Object)(object)item != (Object)null && !item.isHeld && !item.isHeldByEnemy && (Object)(object)item.parentObject == (Object)null)
						{
							BroadcastSingleItemPosition(item);
						}
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			[HarmonyPatch("DiscardItem")]
			[HarmonyPostfix]
			private static void Postfix_DiscardItem(GrabbableObject __instance)
			{
				if (!((Object)(object)NetworkManager.Singleton == (Object)null) && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
				{
					((MonoBehaviour)__instance).StartCoroutine(SyncItemAfterLanding(__instance));
				}
			}

			[IteratorStateMachine(typeof(<SyncItemAfterLanding>d__1))]
			private static IEnumerator SyncItemAfterLanding(GrabbableObject item)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <SyncItemAfterLanding>d__1(0)
				{
					item = item
				};
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnReceiveItemPosition;

			public static HandleNamedMessageDelegate <1>__OnReceiveDoorState;
		}

		private static readonly ManualLogSource Logger = Logger.CreateLogSource("LethalNetSync.Bridge");

		private const string MSG_ITEM_POS = "LethalNetSync_ItemPos";

		private const string MSG_DOOR_STATE = "LethalNetSync_DoorState";

		private static readonly Dictionary<ulong, (Vector3 pos, Quaternion rot)> _lastSentPositions = new Dictionary<ulong, (Vector3, Quaternion)>();

		private const float DELTA_THRESHOLD = 0.05f;

		public static void OnRoundStart()
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				Logger.LogWarning((object)"[Bridge] NetworkManager non disponible lors de l'initialisation du round.");
				return;
			}
			_lastSentPositions.Clear();
			string text = (NetworkManager.Singleton.IsHost ? "Hôte" : (NetworkManager.Singleton.IsServer ? "Serveur" : "Client"));
			Logger.LogInfo((object)("[Bridge] Démarrage — Mode: " + text + " | Enregistrement des protocoles réseau..."));
			RegisterNamedMessageHandlers();
		}

		public static void OnRoundEnd()
		{
			_lastSentPositions.Clear();
			Logger.LogInfo((object)"[Bridge] Cache delta nettoyé en fin de round.");
		}

		public static void RegisterNamedMessageHandlers()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//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_0083: Expected O, but got Unknown
			if ((Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.CustomMessagingManager == null)
			{
				Logger.LogWarning((object)"[Bridge] CustomMessagingManager indisponible.");
				return;
			}
			try
			{
				CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
				object obj = <>O.<0>__OnReceiveItemPosition;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnReceiveItemPosition;
					<>O.<0>__OnReceiveItemPosition = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("LethalNetSync_ItemPos", (HandleNamedMessageDelegate)obj);
				CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
				object obj2 = <>O.<1>__OnReceiveDoorState;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val2 = OnReceiveDoorState;
					<>O.<1>__OnReceiveDoorState = val2;
					obj2 = (object)val2;
				}
				customMessagingManager2.RegisterNamedMessageHandler("LethalNetSync_DoorState", (HandleNamedMessageDelegate)obj2);
				Logger.LogInfo((object)"[Bridge] ✅ Protocoles de sync objets + portes enregistrés.");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("[Bridge] Erreur lors de l'enregistrement des protocoles : " + ex.Message));
			}
		}

		private static void OnReceiveItemPosition(ulong senderId, FastBufferReader reader)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ulong key = default(ulong);
				((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives));
				Vector3 val = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref val);
				Quaternion rotation = default(Quaternion);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation);
				if ((Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.SpawnManager == null || (NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsClient) || !NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(key, out var value) || (Object)(object)value == (Object)null)
				{
					return;
				}
				GrabbableObject component = ((Component)value).GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null && !component.isHeld && !component.isHeldByEnemy && (Object)(object)component.parentObject == (Object)null && Vector3.Distance(((Component)component).transform.position, val) > 0.05f)
				{
					((Component)component).transform.position = val;
					((Component)component).transform.rotation = rotation;
					Rigidbody component2 = ((Component)component).GetComponent<Rigidbody>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.velocity = Vector3.zero;
						component2.angularVelocity = Vector3.zero;
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("[Bridge] Erreur décodage position item : " + ex.Message));
			}
		}

		private static void OnReceiveDoorState(ulong senderId, FastBufferReader reader)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				if (!((Object)(object)NetworkManager.Singleton != (Object)null) || !NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsClient)
				{
					HangarShipDoor val = Object.FindObjectOfType<HangarShipDoor>();
					if ((Object)(object)val != (Object)null && val.doorPower <= 0f && flag)
					{
						val.SetDoorClosed();
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("[Bridge] Erreur décodage état porte : " + ex.Message));
			}
		}

		public static void BroadcastItemPositions()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || NetworkManager.Singleton.CustomMessagingManager == null)
			{
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			if (array == null)
			{
				return;
			}
			int num = 0;
			GrabbableObject[] array2 = array;
			FastBufferWriter val2 = default(FastBufferWriter);
			foreach (GrabbableObject val in array2)
			{
				if ((Object)(object)val == (Object)null || val.isHeld || val.isHeldByEnemy || (Object)(object)val.parentObject != (Object)null || !((NetworkBehaviour)val).IsSpawned)
				{
					continue;
				}
				Vector3 position = ((Component)val).transform.position;
				Quaternion rotation = ((Component)val).transform.rotation;
				ulong networkObjectId = ((NetworkBehaviour)val).NetworkObjectId;
				if (_lastSentPositions.TryGetValue(networkObjectId, out (Vector3, Quaternion) value) && Vector3.Distance(value.Item1, position) < 0.05f)
				{
					continue;
				}
				try
				{
					((FastBufferWriter)(ref val2))..ctor(36, (Allocator)2, -1);
					FastBufferWriter val3 = val2;
					try
					{
						((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
						((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
						((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
						NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("LethalNetSync_ItemPos", val2, (NetworkDelivery)1);
					}
					finally
					{
						((IDisposable)(FastBufferWriter)(ref val3)).Dispose();
					}
					_lastSentPositions[networkObjectId] = (position, rotation);
					num++;
				}
				catch
				{
				}
			}
			if (num > 0)
			{
				Logger.LogInfo((object)$"[Bridge] Delta sync : {num} objet(s) mis à jour.");
			}
		}

		public static void BroadcastSingleItemPosition(GrabbableObject item)
		{
			//IL_0045: 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_0054: 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_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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)
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || NetworkManager.Singleton.CustomMessagingManager == null || (Object)(object)item == (Object)null || !((NetworkBehaviour)item).IsSpawned)
			{
				return;
			}
			try
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(36, (Allocator)2, -1);
				FastBufferWriter val2 = val;
				try
				{
					ulong networkObjectId = ((NetworkBehaviour)item).NetworkObjectId;
					((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
					Vector3 position = ((Component)item).transform.position;
					((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
					Quaternion rotation = ((Component)item).transform.rotation;
					((FastBufferWriter)(ref val)).WriteValueSafe(ref rotation);
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("LethalNetSync_ItemPos", val, (NetworkDelivery)2);
				}
				finally
				{
					((IDisposable)(FastBufferWriter)(ref val2)).Dispose();
				}
				_lastSentPositions[((NetworkBehaviour)item).NetworkObjectId] = (((Component)item).transform.position, ((Component)item).transform.rotation);
			}
			catch
			{
			}
		}

		public static void BroadcastAllPositionsToClient(ulong clientId)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || NetworkManager.Singleton.CustomMessagingManager == null)
			{
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			if (array == null)
			{
				return;
			}
			int num = 0;
			GrabbableObject[] array2 = array;
			FastBufferWriter val2 = default(FastBufferWriter);
			foreach (GrabbableObject val in array2)
			{
				if ((Object)(object)val == (Object)null || val.isHeld || val.isHeldByEnemy || (Object)(object)val.parentObject != (Object)null || !((NetworkBehaviour)val).IsSpawned)
				{
					continue;
				}
				try
				{
					((FastBufferWriter)(ref val2))..ctor(36, (Allocator)2, -1);
					FastBufferWriter val3 = val2;
					try
					{
						ulong networkObjectId = ((NetworkBehaviour)val).NetworkObjectId;
						((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives));
						Vector3 position = ((Component)val).transform.position;
						((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
						Quaternion rotation = ((Component)val).transform.rotation;
						((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
						NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("LethalNetSync_ItemPos", clientId, val2, (NetworkDelivery)2);
					}
					finally
					{
						((IDisposable)(FastBufferWriter)(ref val3)).Dispose();
					}
					num++;
				}
				catch
				{
				}
			}
			Logger.LogInfo((object)$"[Bridge] Sync initiale envoyée à client {clientId} : {num} objet(s).");
		}

		public static void BroadcastDoorState(bool isClosed)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			//IL_0040: 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)
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || NetworkManager.Singleton.CustomMessagingManager == null)
			{
				return;
			}
			try
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1);
				FastBufferWriter val2 = val;
				try
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isClosed, default(ForPrimitives));
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("LethalNetSync_DoorState", val, (NetworkDelivery)2);
				}
				finally
				{
					((IDisposable)(FastBufferWriter)(ref val2)).Dispose();
				}
				Logger.LogInfo((object)("[Bridge] État porte diffusé : " + (isClosed ? "Fermée" : "Ouverte") + "."));
			}
			catch
			{
			}
		}
	}
}