using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI.NetcodePatcher;
using LethalNetworkAPI.Networking;
using LethalNetworkAPI.Serializable;
using Microsoft.CodeAnalysis;
using OdinSerializer;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RegisterFormatter(typeof(NetworkBehaviourReferenceFormatter), 0)]
[assembly: RegisterFormatter(typeof(NetworkObjectReferenceFormatter), 0)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Xilophor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Easily create networked mods.")]
[assembly: AssemblyFileVersion("2.1.7.0")]
[assembly: AssemblyInformationalVersion("2.1.7+c8257aeddc1f0bf628a1d632f63c6b6b4df68b85")]
[assembly: AssemblyProduct("LethalNetworkAPI")]
[assembly: AssemblyTitle("LethalNetworkAPI")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Xilophor/LethalNetworkAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 LethalNetworkAPI
{
public sealed class LethalClientEvent : LNetworkEvent
{
public event Action? OnReceived;
public event Action<ulong>? OnReceivedFromClient;
public LethalClientEvent(string identifier, Action? onReceived = null, Action<ulong>? onReceivedFromClient = null)
: base(identifier)
{
NetworkHandler.OnClientEvent += ReceiveClientEvent;
NetworkHandler.OnSyncedClientEvent += ReceiveSyncedClientEvent;
OnReceived += onReceived;
OnReceivedFromClient += onReceivedFromClient;
}
public void InvokeServer()
{
//IL_0019: 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)
if (!IsNetworkHandlerNull())
{
NetworkHandler.Instance.EventServerRpc(Identifier);
}
}
public void InvokeAllClients(bool includeLocalClient = true, bool waitForServerResponse = false)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull())
{
NetworkHandler.Instance.EventServerRpc(Identifier, toOtherClients: true, includeLocalClient && waitForServerResponse);
if (includeLocalClient && !waitForServerResponse)
{
this.OnReceivedFromClient?.Invoke(NetworkManager.Singleton.LocalClientId);
}
}
}
public void InvokeAllClientsSynced()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0031: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull())
{
NetworkTime localTime = NetworkManager.Singleton.LocalTime;
double time = ((NetworkTime)(ref localTime)).Time;
NetworkHandler.Instance.SyncedEventServerRpc(Identifier, time);
ReceiveClientEvent(Identifier, NetworkManager.Singleton.LocalClientId);
}
}
private void ReceiveClientEvent(string identifier, ulong originatorClientId)
{
if (!(identifier != Identifier))
{
if (originatorClientId == 99999)
{
this.OnReceived?.Invoke();
}
else
{
this.OnReceivedFromClient?.Invoke(originatorClientId);
}
}
}
private void ReceiveSyncedClientEvent(string identifier, double time, ulong originatorClientId)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (!(identifier != Identifier) && !((Object)(object)NetworkHandler.Instance == (Object)null))
{
NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
double num = time - ((NetworkTime)(ref serverTime)).Time;
((MonoBehaviour)NetworkHandler.Instance).StartCoroutine(WaitAndInvokeEvent((float)num, originatorClientId));
}
}
private IEnumerator WaitAndInvokeEvent(float timeToWait, ulong originatorClientId)
{
if (timeToWait > 0f)
{
yield return (object)new WaitForSeconds(timeToWait);
}
ReceiveClientEvent(Identifier, originatorClientId);
}
}
public sealed class LethalServerEvent : LNetworkEvent
{
public event Action<ulong>? OnReceived;
public LethalServerEvent(string identifier, Action<ulong>? onReceived = null)
: base(identifier)
{
NetworkHandler.OnServerEvent += ReceiveServerEvent;
NetworkHandler.OnSyncedServerEvent += ReceiveSyncedServerEvent;
OnReceived += onReceived;
}
public void InvokeClient(ulong clientId)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParams(clientId));
}
}
public void InvokeClients(IEnumerable<ulong> clientIds)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParams(clientIds));
}
}
public void InvokeAllClients(bool receiveOnHost = true)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
if (receiveOnHost)
{
NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL);
}
else
{
NetworkHandler.Instance.EventClientRpc(Identifier, 99999uL, GenerateClientParamsExceptHost());
}
}
}
private void ReceiveServerEvent(string identifier, ulong originClientId)
{
if (!(identifier != Identifier))
{
this.OnReceived?.Invoke(originClientId);
}
}
private void ReceiveSyncedServerEvent(string identifier, double time, ulong originatorClientId)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (!(identifier != Identifier) && !IsNetworkHandlerNull())
{
NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
double num = time - ((NetworkTime)(ref serverTime)).Time;
NetworkHandler.Instance.SyncedEventClientRpc(identifier, time, originatorClientId, GenerateClientParamsExcept(originatorClientId));
((MonoBehaviour)NetworkHandler.Instance).StartCoroutine(WaitAndInvokeEvent((float)num, originatorClientId));
}
}
private IEnumerator WaitAndInvokeEvent(float timeToWait, ulong clientId)
{
if (timeToWait > 0f)
{
yield return (object)new WaitForSeconds(timeToWait);
}
this.OnReceived?.Invoke(clientId);
}
}
public abstract class LNetworkEvent : LethalNetwork
{
protected LNetworkEvent(string identifier)
: base("evt." + identifier, "Event")
{
}
}
public abstract class LethalNetwork
{
internal readonly string Identifier;
private readonly string _networkType;
protected LethalNetwork(string identifier, string networkType, int frameIndex = 3)
{
try
{
MethodBase method = new StackTrace().GetFrame(frameIndex).GetMethod();
Assembly assembly = method.ReflectedType.Assembly;
Type type2 = AccessTools.GetTypesFromAssembly(assembly).First((Type type) => type.GetCustomAttributes(typeof(BepInPlugin), inherit: false).Any());
Identifier = MetadataHelper.GetMetadata(type2).GUID + "." + identifier;
_networkType = networkType;
}
catch (Exception arg)
{
LethalNetworkAPIPlugin.Logger.LogError((object)$"Unable to find plugin info for calling mod for {_networkType.ToLower()} with identifier \"{Identifier}\". Are you using BepInEx? \n Stacktrace: {arg}");
}
}
protected bool IsNetworkHandlerNull(bool log = true)
{
if ((Object)(object)NetworkHandler.Instance != (Object)null)
{
return false;
}
if (log)
{
LethalNetworkAPIPlugin.Logger.LogError((object)string.Format("Unable to invoke the {1} with identifier \"{0}\". Is the player in a lobby?", _networkType.ToLower(), Identifier));
}
return true;
}
protected bool IsHostOrServer(bool log = true)
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
return true;
}
if (log)
{
LethalNetworkAPIPlugin.Logger.LogError((object)$"The client {NetworkManager.Singleton.LocalClientId} cannot use server methods. {_networkType} Identifier: \"{Identifier}\"");
}
return false;
}
private bool DoClientsExist(IEnumerable<ulong> clientIds, bool log = true)
{
if (clientIds.Any())
{
return true;
}
if (log)
{
LethalNetworkAPIPlugin.Logger.LogError((object)$"None of the specified clients {clientIds} are connected. {_networkType} Identifier: \"{Identifier}\"");
}
return false;
}
private ClientRpcParams GenerateClientParams(IEnumerable<ulong> clientIds, bool allExcept)
{
//IL_00d0: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
ulong[] enumerable = (clientIds as ulong[]) ?? clientIds.ToArray();
NativeArray<ulong> val = default(NativeArray<ulong>);
if (!enumerable.Any() && allExcept)
{
val..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != 0).ToArray(), (Allocator)4);
}
else if (allExcept)
{
val..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => enumerable.All((ulong j) => i != j)).ToArray(), (Allocator)4);
}
else
{
val..ctor(enumerable.Where((ulong i) => NetworkManager.Singleton.ConnectedClientsIds.Contains(i)).ToArray(), (Allocator)4);
}
if (!DoClientsExist((IEnumerable<ulong>)(object)val))
{
return default(ClientRpcParams);
}
ClientRpcParams result = default(ClientRpcParams);
result.Send = new ClientRpcSendParams
{
TargetClientIdsNativeArray = val
};
return result;
}
protected ClientRpcParams GenerateClientParams(IEnumerable<ulong> clientIds)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return GenerateClientParams(clientIds, allExcept: false);
}
protected ClientRpcParams GenerateClientParams(ulong clientId)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return GenerateClientParams(new <>z__ReadOnlyArray<ulong>(new ulong[1] { clientId }), allExcept: false);
}
protected ClientRpcParams GenerateClientParamsExcept(IEnumerable<ulong> clientIds)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return GenerateClientParams(clientIds, allExcept: true);
}
protected ClientRpcParams GenerateClientParamsExcept(ulong clientId)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return GenerateClientParams(new <>z__ReadOnlyArray<ulong>(new ulong[1] { clientId }), allExcept: true);
}
protected ClientRpcParams GenerateClientParamsExceptHost()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return GenerateClientParams(Array.Empty<ulong>(), allExcept: true);
}
}
[BepInPlugin("LethalNetworkAPI", "LethalNetworkAPI", "2.1.7")]
public class LethalNetworkAPIPlugin : BaseUnityPlugin
{
public static LethalNetworkAPIPlugin Instance;
private static Harmony _harmony;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("LethalNetworkAPI");
NetcodePatcher();
_harmony.PatchAll(typeof(NetworkObjectManager));
Logger.LogInfo((object)"LethalNetworkAPI v2.1.7 has Loaded.");
}
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 LethalNetworkExtensions
{
public static PlayerControllerB? GetPlayerController(this ulong clientId)
{
return StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.ClientPlayerList[clientId]];
}
[Obsolete("GetPlayerFromId is deprecated, please use GetPlayerController instead.")]
public static PlayerControllerB? GetPlayerFromId(this ulong clientId)
{
return clientId.GetPlayerController();
}
public static ulong GetClientId(this PlayerControllerB player)
{
return player.actualClientId;
}
public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this NetworkBehaviour networkBehaviour, string identifier, bool serverOwned = false)
{
return ((Component)networkBehaviour).gameObject.NetworkVariable<TData>(identifier, serverOwned);
}
public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this NetworkObject networkObject, string identifier, bool serverOwned = false)
{
return ((Component)networkObject).gameObject.NetworkVariable<TData>(identifier, serverOwned);
}
public static LethalNetworkVariable<TData>? GetNetworkVariable<TData>(this GameObject gameObject, string identifier, bool serverOwned = false)
{
return gameObject.NetworkVariable<TData>(identifier, serverOwned);
}
private static LethalNetworkVariable<TData>? NetworkVariable<TData>(this GameObject gameObject, string identifier, bool serverOwned)
{
string identifier2 = identifier;
NetworkObject networkObjectComp = default(NetworkObject);
if (!gameObject.TryGetComponent<NetworkObject>(ref networkObjectComp))
{
LethalNetworkAPIPlugin.Logger.LogError((object)$"Unable to find the network object component. Are you adding variable \"{identifier2}\" to a network object?");
return null;
}
LethalNetworkVariable<TData> lethalNetworkVariable = (LethalNetworkVariable<TData>)NetworkHandler.Instance.ObjectNetworkVariableList.FirstOrDefault((ILethalNetVar i) => ((LethalNetworkVariable<TData>)i).Identifier == $"{identifier2}.{networkObjectComp.GlobalObjectIdHash}");
if (lethalNetworkVariable != null)
{
return lethalNetworkVariable;
}
lethalNetworkVariable = new LethalNetworkVariable<TData>($"{identifier2}.{networkObjectComp.GlobalObjectIdHash}", networkObjectComp, serverOwned, 3);
NetworkHandler.Instance.ObjectNetworkVariableList.Add(lethalNetworkVariable);
return lethalNetworkVariable;
}
}
public sealed class LethalClientMessage<TData> : LNetworkMessage
{
public event Action<TData>? OnReceived;
public event Action<TData, ulong>? OnReceivedFromClient;
public LethalClientMessage(string identifier, Action<TData>? onReceived = null, Action<TData, ulong>? onReceivedFromClient = null)
: base(identifier)
{
NetworkHandler.OnClientMessage += ReceiveMessage;
OnReceived += onReceived;
OnReceivedFromClient += onReceivedFromClient;
}
public void SendServer(TData data)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull())
{
NetworkHandler.Instance.MessageServerRpc(Identifier, LethalNetworkSerializer.Serialize(data));
}
}
public void SendAllClients(TData data, bool includeLocalClient = true, bool waitForServerResponse = false)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull())
{
NetworkHandler.Instance.MessageServerRpc(Identifier, LethalNetworkSerializer.Serialize(data), toOtherClients: true, includeLocalClient && waitForServerResponse);
if (includeLocalClient && !waitForServerResponse)
{
this.OnReceivedFromClient?.Invoke(data, NetworkManager.Singleton.LocalClientId);
}
}
}
private void ReceiveMessage(string identifier, byte[] data, ulong originatorClient)
{
if (!(identifier != Identifier))
{
if (originatorClient == 99999)
{
this.OnReceived?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data));
}
else
{
this.OnReceivedFromClient?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data), originatorClient);
}
}
}
}
public class LethalServerMessage<TData> : LNetworkMessage
{
public event Action<TData, ulong>? OnReceived;
public LethalServerMessage(string identifier, Action<TData, ulong>? onReceived = null)
: base(identifier)
{
NetworkHandler.OnServerMessage += ReceiveServerMessage;
OnReceived += onReceived;
}
public void SendClient(TData data, ulong clientId)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParams(clientId));
}
}
public void SendClients(TData data, IEnumerable<ulong> clientIds)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParams(clientIds));
}
}
public void SendAllClients(TData data, bool receiveOnHost = true)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
if (receiveOnHost)
{
NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL);
}
else
{
NetworkHandler.Instance.MessageClientRpc(Identifier, LethalNetworkSerializer.Serialize(data), 99999uL, GenerateClientParamsExceptHost());
}
}
}
private void ReceiveServerMessage(string identifier, byte[] data, ulong originClientId)
{
if (!(identifier != Identifier))
{
this.OnReceived?.Invoke(LethalNetworkSerializer.Deserialize<TData>(data), originClientId);
}
}
}
public abstract class LNetworkMessage : LethalNetwork
{
protected LNetworkMessage(string identifier)
: base("msg." + identifier, "Message")
{
}
}
internal static class TextDefinitions
{
internal const string NotInLobbyMessage = "Unable to send the {0} with identifier \"{1}\" and data {{{2}}}. Is the player in a lobby?";
internal const string UnableToFindGuid = "Unable to find plugin info for calling mod for {0} with identifier \"{1}\". Are you using BepInEx? \n Stacktrace: {2}";
internal const string NotServerInfo = "The client {0} cannot use server methods. {1} Identifier: \"{2}\"";
internal const string NotInLobbyEvent = "Unable to invoke the {1} with identifier \"{0}\". Is the player in a lobby?";
internal const string NetworkHandlerDoesNotExist = "The NetworkHandler does not exist. This shouldn't occur!";
internal const string TargetClientNotConnected = "The specified client {0} is not connected. {1} Identifier: \"{2}\"";
internal const string TargetClientsNotConnected = "None of the specified clients {0} are connected. {1} Identifier: \"{2}\"";
internal const string UnableToLocateNetworkObjectComponent = "Unable to find the network object component. Are you adding variable \"{0}\" to a network object?";
}
internal interface ILethalNetVar
{
}
public sealed class LethalNetworkVariable<TData> : LethalNetwork, ILethalNetVar
{
private readonly bool _public;
private readonly NetworkObject? _ownerObject;
private bool _isDirty;
private TData _value;
public TData Value
{
get
{
return _value;
}
set
{
if (IsOwner && (value != null || _value != null) && (value == null || !value.Equals(_value)))
{
_value = value;
_isDirty = true;
this.OnValueChanged?.Invoke(_value);
}
}
}
private bool IsOwner
{
get
{
if (_public)
{
return true;
}
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return true;
}
if (_ownerObject == null && NetworkManager.Singleton.IsServer)
{
return true;
}
if (_ownerObject != null)
{
return _ownerObject.OwnerClientId == NetworkManager.Singleton.LocalClientId;
}
return false;
}
}
public event Action<TData>? OnValueChanged;
public LethalNetworkVariable(string identifier)
: this(identifier, (NetworkObject?)null, serverOwned: true, 2)
{
}
internal LethalNetworkVariable(string identifier, NetworkObject? owner, bool serverOwned, int frameIndex)
: base(identifier, "Variable", frameIndex + 1)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
_ownerObject = ((!serverOwned) ? owner : null);
NetworkHandler.OnVariableUpdate += ReceiveUpdate;
NetworkHandler.NetworkTick += OnNetworkTick;
NetworkHandler.NetworkSpawn += delegate
{
if (!IsNetworkHandlerNull() && IsHostOrServer(log: false))
{
NetworkHandler.OnPlayerJoin += OnPlayerJoin;
NetworkHandler.NetworkDespawn += ClearSubscriptions;
}
};
NetworkHandler.GetVariableValue += delegate(string id, ulong clientId)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (!(id != Identifier) && !IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.UpdateVariableClientRpc(Identifier, LethalNetworkSerializer.Serialize(_value), GenerateClientParams(clientId));
}
};
if (typeof(LethalNetworkVariable<TData>).GetCustomAttributes(typeof(PublicNetworkVariableAttribute), inherit: true).Any())
{
_public = true;
}
if (!IsNetworkHandlerNull(log: false))
{
if (IsHostOrServer())
{
NetworkHandler.OnPlayerJoin += OnPlayerJoin;
}
else
{
NetworkHandler.Instance.GetVariableValueServerRpc(Identifier);
}
}
}
private void OnPlayerJoin(ulong clientId)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetworkHandlerNull() && IsHostOrServer())
{
NetworkHandler.Instance.UpdateVariableClientRpc(Identifier, LethalNetworkSerializer.Serialize(_value), GenerateClientParams(clientId));
}
}
private void ClearSubscriptions()
{
NetworkHandler.OnPlayerJoin -= OnPlayerJoin;
NetworkHandler.NetworkDespawn -= ClearSubscriptions;
}
private void SendUpdate()
{
//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)
if (!IsNetworkHandlerNull() && IsOwner)
{
NetworkHandler.Instance.UpdateVariableServerRpc(Identifier, LethalNetworkSerializer.Serialize(_value));
}
}
private void ReceiveUpdate(string identifier, byte[] data)
{
if (!(identifier != Identifier))
{
TData val = LethalNetworkSerializer.Deserialize<TData>(data);
if (val != null)
{
_value = val;
this.OnValueChanged?.Invoke(val);
}
}
}
private void OnNetworkTick()
{
if (_isDirty && _value != null)
{
SendUpdate();
_isDirty = false;
}
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class PublicNetworkVariableAttribute : Attribute
{
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "LethalNetworkAPI";
public const string PLUGIN_NAME = "LethalNetworkAPI";
public const string PLUGIN_VERSION = "2.1.7";
}
}
namespace LethalNetworkAPI.Serializable
{
internal static class LethalNetworkSerializer
{
internal static byte[] Serialize<T>(T value)
{
//IL_003e: 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_005e: Unknown result type (might be due to invalid IL or missing references)
if (value == null)
{
return Array.Empty<byte>();
}
object obj = value;
GameObject val = (GameObject)((obj is GameObject) ? obj : null);
if (val != null)
{
return SerializationUtility.SerializeValue<NetworkObjectReference>(NetworkObjectReference.op_Implicit(val), (DataFormat)0, (SerializationContext)null);
}
object obj2 = value;
NetworkObject val2 = (NetworkObject)((obj2 is NetworkObject) ? obj2 : null);
if (val2 != null)
{
return SerializationUtility.SerializeValue<NetworkObjectReference>(NetworkObjectReference.op_Implicit(val2), (DataFormat)0, (SerializationContext)null);
}
object obj3 = value;
NetworkBehaviour val3 = (NetworkBehaviour)((obj3 is NetworkBehaviour) ? obj3 : null);
if (val3 != null)
{
return SerializationUtility.SerializeValue<NetworkBehaviourReference>(NetworkBehaviourReference.op_Implicit(val3), (DataFormat)0, (SerializationContext)null);
}
return SerializationUtility.SerializeValue<T>(value, (DataFormat)0, (SerializationContext)null);
}
internal static T Deserialize<T>(byte[] data)
{
//IL_0042: 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_006c: Unknown result type (might be due to invalid IL or missing references)
if (data.Length == 0)
{
return default(T);
}
T val = default(T);
if (!(val is GameObject))
{
if (!(val is NetworkObject))
{
if (val is NetworkBehaviour)
{
return (T)(object)NetworkBehaviourReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkBehaviourReference>(data, (DataFormat)0, (DeserializationContext)null));
}
return SerializationUtility.DeserializeValue<T>(data, (DataFormat)0, (DeserializationContext)null);
}
return (T)(object)NetworkObjectReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkObjectReference>(data, (DataFormat)0, (DeserializationContext)null));
}
return (T)(object)NetworkObjectReference.op_Implicit(SerializationUtility.DeserializeValue<NetworkObjectReference>(data, (DataFormat)0, (DeserializationContext)null));
}
}
public class NetworkBehaviourReferenceFormatter : MinimalBaseFormatter<NetworkBehaviourReference>
{
private static readonly Serializer<ushort> UInt16Serializer = Serializer.Get<ushort>();
private static readonly Serializer<NetworkObjectReference> NetworkObjectReferenceSerializer = Serializer.Get<NetworkObjectReference>();
protected override void Read(ref NetworkBehaviourReference value, IDataReader reader)
{
//IL_0007: 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)
value.m_NetworkObjectReference = NetworkObjectReferenceSerializer.ReadValue(reader);
value.m_NetworkBehaviourId = UInt16Serializer.ReadValue(reader);
}
protected override void Write(ref NetworkBehaviourReference value, IDataWriter writer)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
NetworkObjectReferenceSerializer.WriteValue(value.m_NetworkObjectReference, writer);
UInt16Serializer.WriteValue(value.m_NetworkBehaviourId, writer);
}
}
internal class NetworkObjectReferenceFormatter : MinimalBaseFormatter<NetworkObjectReference>
{
private static readonly Serializer<ulong> UInt64Serializer = Serializer.Get<ulong>();
protected override void Read(ref NetworkObjectReference value, IDataReader reader)
{
((NetworkObjectReference)(ref value)).NetworkObjectId = UInt64Serializer.ReadValue(reader);
}
protected override void Write(ref NetworkObjectReference value, IDataWriter writer)
{
UInt64Serializer.WriteValue(((NetworkObjectReference)(ref value)).NetworkObjectId, writer);
}
}
}
namespace LethalNetworkAPI.Networking
{
internal class NetworkHandler : NetworkBehaviour
{
internal readonly List<ILethalNetVar> ObjectNetworkVariableList = new List<ILethalNetVar>();
internal static NetworkHandler? Instance { get; private set; }
internal static event Action? NetworkSpawn;
internal static event Action? NetworkDespawn;
internal static event Action? NetworkTick;
internal static event Action<ulong>? OnPlayerJoin;
internal static event Action<string, byte[], ulong>? OnServerMessage;
internal static event Action<string, byte[], ulong>? OnClientMessage;
internal static event Action<string, byte[]>? OnVariableUpdate;
internal static event Action<string, ulong>? GetVariableValue;
internal static event Action<string, ulong>? OnServerEvent;
internal static event Action<string, ulong>? OnClientEvent;
internal static event Action<string, double, ulong>? OnSyncedServerEvent;
internal static event Action<string, double, ulong>? OnSyncedClientEvent;
public override void OnNetworkSpawn()
{
if ((Object)(object)Instance != (Object)null)
{
Object.Destroy((Object)(object)this);
return;
}
Instance = this;
NetworkHandler.NetworkSpawn?.Invoke();
((NetworkBehaviour)this).NetworkManager.NetworkTickSystem.Tick += NetworkHandler.NetworkTick;
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnectedCallback;
}
internal void Clean()
{
NetworkHandler.NetworkDespawn?.Invoke();
NetworkHandler.OnPlayerJoin = null;
NetworkHandler.NetworkDespawn = null;
Instance = null;
}
private void OnClientConnectedCallback(ulong client)
{
NetworkHandler.OnPlayerJoin?.Invoke(client);
}
[ServerRpc(RequireOwnership = false)]
internal void MessageServerRpc(string identifier, byte[] data, bool toOtherClients = false, bool sendToOriginator = false, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3629803754u, serverRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
bool flag2 = data != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
if (flag2)
{
((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
}
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val, 3629803754u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
ServerRpcParams serverRpcParams2 = serverRpcParams;
if (!toOtherClients)
{
NetworkHandler.OnServerMessage?.Invoke(identifier, data, serverRpcParams2.Receive.SenderClientId);
}
else if (!sendToOriginator)
{
NativeArray<ulong> val2 = default(NativeArray<ulong>);
val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
if (((IEnumerable<ulong>)(object)val2).Any())
{
MessageClientRpc(identifier, data, serverRpcParams2.Receive.SenderClientId, new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIdsNativeArray = val2
}
});
}
}
else
{
MessageClientRpc(identifier, data, serverRpcParams2.Receive.SenderClientId);
}
}
[ClientRpc]
internal void MessageClientRpc(string identifier, byte[] data, ulong originatorClient = 99999uL, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: 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))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3740138170u, clientRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
bool flag2 = data != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
if (flag2)
{
((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
}
BytePacker.WriteValueBitPacked(val, originatorClient);
((NetworkBehaviour)this).__endSendClientRpc(ref val, 3740138170u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkHandler.OnClientMessage?.Invoke(identifier, data, originatorClient);
clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
}
}
[ServerRpc(RequireOwnership = false)]
internal void EventServerRpc(string identifier, bool toOtherClients = false, bool sendToOriginator = false, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1959733556u, serverRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val, 1959733556u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
ServerRpcParams serverRpcParams2 = serverRpcParams;
if (!toOtherClients)
{
NetworkHandler.OnServerEvent?.Invoke(identifier, serverRpcParams2.Receive.SenderClientId);
}
else if (!sendToOriginator)
{
NativeArray<ulong> val2 = default(NativeArray<ulong>);
val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
if (((IEnumerable<ulong>)(object)val2).Any())
{
EventClientRpc(identifier, serverRpcParams2.Receive.SenderClientId, new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIdsNativeArray = val2
}
});
}
}
else
{
EventClientRpc(identifier, serverRpcParams2.Receive.SenderClientId);
}
}
[ClientRpc]
internal void EventClientRpc(string identifier, ulong originatorClient = 99999uL, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(53735464u, clientRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
BytePacker.WriteValueBitPacked(val, originatorClient);
((NetworkBehaviour)this).__endSendClientRpc(ref val, 53735464u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkHandler.OnClientEvent?.Invoke(identifier, originatorClient);
clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
}
}
[ServerRpc(RequireOwnership = false)]
internal void SyncedEventServerRpc(string identifier, double time, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_00c1: 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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2669215490u, serverRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref time, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val, 2669215490u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
NetworkHandler.OnSyncedServerEvent?.Invoke(identifier, time, serverRpcParams.Receive.SenderClientId);
}
}
[ClientRpc]
internal void SyncedEventClientRpc(string identifier, double time, ulong originatorClient, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: 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_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: 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))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(899832842u, clientRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref time, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val, originatorClient);
((NetworkBehaviour)this).__endSendClientRpc(ref val, 899832842u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkHandler.OnSyncedClientEvent?.Invoke(identifier, time, originatorClient);
clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
}
}
[ServerRpc(RequireOwnership = false)]
internal void UpdateVariableServerRpc(string identifier, byte[] data, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1359429614u, serverRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
bool flag2 = data != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
if (flag2)
{
((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
}
((NetworkBehaviour)this).__endSendServerRpc(ref val, 1359429614u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
ServerRpcParams serverRpcParams2 = serverRpcParams;
if (serverRpcParams2.Receive.SenderClientId != 0L)
{
NetworkHandler.OnVariableUpdate?.Invoke(identifier, data);
}
NativeArray<ulong> val2 = default(NativeArray<ulong>);
val2..ctor(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong i) => i != serverRpcParams2.Receive.SenderClientId).ToArray(), (Allocator)4);
if (((IEnumerable<ulong>)(object)val2).Any())
{
UpdateVariableClientRpc(identifier, data, new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIdsNativeArray = val2
}
});
}
}
}
[ClientRpc]
internal void UpdateVariableClientRpc(string identifier, byte[] data, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: 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))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1641402893u, clientRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
bool flag2 = data != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
if (flag2)
{
((FastBufferWriter)(ref val)).WriteValueSafe<byte>(data, default(ForPrimitives));
}
((NetworkBehaviour)this).__endSendClientRpc(ref val, 1641402893u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
NetworkHandler.OnVariableUpdate?.Invoke(identifier, data);
clientRpcParams.Send.TargetClientIdsNativeArray?.Dispose();
}
}
[ServerRpc(RequireOwnership = false)]
internal void GetVariableValueServerRpc(string identifier, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2442151635u, serverRpcParams, (RpcDelivery)0);
bool flag = identifier != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(identifier, false);
}
((NetworkBehaviour)this).__endSendServerRpc(ref val, 2442151635u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
NetworkHandler.GetVariableValue?.Invoke(identifier, serverRpcParams.Receive.SenderClientId);
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_NetworkHandler()
{
//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
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3629803754u, new RpcReceiveHandler(__rpc_handler_3629803754));
NetworkManager.__rpc_func_table.Add(3740138170u, new RpcReceiveHandler(__rpc_handler_3740138170));
NetworkManager.__rpc_func_table.Add(1959733556u, new RpcReceiveHandler(__rpc_handler_1959733556));
NetworkManager.__rpc_func_table.Add(53735464u, new RpcReceiveHandler(__rpc_handler_53735464));
NetworkManager.__rpc_func_table.Add(2669215490u, new RpcReceiveHandler(__rpc_handler_2669215490));
NetworkManager.__rpc_func_table.Add(899832842u, new RpcReceiveHandler(__rpc_handler_899832842));
NetworkManager.__rpc_func_table.Add(1359429614u, new RpcReceiveHandler(__rpc_handler_1359429614));
NetworkManager.__rpc_func_table.Add(1641402893u, new RpcReceiveHandler(__rpc_handler_1641402893));
NetworkManager.__rpc_func_table.Add(2442151635u, new RpcReceiveHandler(__rpc_handler_2442151635));
}
private static void __rpc_handler_3629803754(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
byte[] data = null;
if (flag2)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
}
bool toOtherClients = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
bool sendToOriginator = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((NetworkHandler)(object)target).MessageServerRpc(identifier, data, toOtherClients, sendToOriginator, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3740138170(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
byte[] data = null;
if (flag2)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
}
ulong originatorClient = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((NetworkHandler)(object)target).MessageClientRpc(identifier, data, originatorClient, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1959733556(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
bool toOtherClients = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toOtherClients, default(ForPrimitives));
bool sendToOriginator = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sendToOriginator, default(ForPrimitives));
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((NetworkHandler)(object)target).EventServerRpc(identifier, toOtherClients, sendToOriginator, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_53735464(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_008b: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
ulong originatorClient = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((NetworkHandler)(object)target).EventClientRpc(identifier, originatorClient, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2669215490(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_0086: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
double time = default(double);
((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref time, default(ForPrimitives));
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((NetworkHandler)(object)target).SyncedEventServerRpc(identifier, time, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_899832842(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0076: 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_0084: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
double time = default(double);
((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref time, default(ForPrimitives));
ulong originatorClient = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref originatorClient);
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((NetworkHandler)(object)target).SyncedEventClientRpc(identifier, time, originatorClient, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1359429614(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
byte[] data = null;
if (flag2)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
}
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((NetworkHandler)(object)target).UpdateVariableServerRpc(identifier, data, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1641402893(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
byte[] data = null;
if (flag2)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref data, default(ForPrimitives));
}
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((NetworkHandler)(object)target).UpdateVariableClientRpc(identifier, data, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2442151635(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_006b: 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)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string identifier = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref identifier, false);
}
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((NetworkHandler)(object)target).GetVariableValueServerRpc(identifier, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string? __getTypeName()
{
return "NetworkHandler";
}
}
[HarmonyPatch]
[HarmonyPriority(800)]
[HarmonyWrapSafe]
internal class NetworkObjectManager
{
private static GameObject _networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
private static void Init()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (!((Object)(object)_networkPrefab != (Object)null))
{
GameObject val = new GameObject("NetworkAPIContainer")
{
hideFlags = (HideFlags)61
};
val.SetActive(false);
_networkPrefab = MakePrefab<NetworkHandler>("LethalNetworkAPI.Handler", val, 889887688u);
}
}
private static GameObject MakePrefab<T>(string name, GameObject parent, uint overrideGuid = 0u) where T : NetworkBehaviour
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
GameObject val = new GameObject(name);
val.transform.SetParent(parent.transform);
val.AddComponent<NetworkObject>();
val.AddComponent<T>();
((Object)val).hideFlags = (HideFlags)61;
if (overrideGuid != 0)
{
val.GetComponent<NetworkObject>().GlobalObjectIdHash = overrideGuid;
}
else
{
uint globalObjectIdHash = BitConverter.ToUInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetExecutingAssembly().GetName().Name + name)), 0);
val.GetComponent<NetworkObject>().GlobalObjectIdHash = globalObjectIdHash;
}
NetworkManager.Singleton.AddNetworkPrefab(val);
return val;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPriority(800)]
private static void SpawnNetworkHandler()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(_networkPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "OnDisable")]
private static void OnDisconnect()
{
NetworkHandler.Instance.Clean();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
namespace LethalNetworkAPI.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}