Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of REPO SteamNetworking Lib v0.1.2
plugins/RepoSteamNetworking/RepoSteamNetworking.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Timers; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using RepoSteamNetworking.API; using RepoSteamNetworking.API.Asset; using RepoSteamNetworking.API.Unity; using RepoSteamNetworking.API.VersionCompat; using RepoSteamNetworking.Networking; using RepoSteamNetworking.Networking.Attributes; using RepoSteamNetworking.Networking.Data; using RepoSteamNetworking.Networking.NetworkedProperties; using RepoSteamNetworking.Networking.Packets; using RepoSteamNetworking.Networking.Registries; using RepoSteamNetworking.Networking.Serialization; using RepoSteamNetworking.Networking.Unity; using RepoSteamNetworking.Odin.Formatters; using RepoSteamNetworking.Prefab; using RepoSteamNetworking.Prefab.Modifications; using RepoSteamNetworking.Utils; using RepoSteamNetworking.Utils.Tween; using Sirenix.Serialization; using Steamworks; using Steamworks.Data; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI.CoroutineTween; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: RegisterFormatter(typeof(BitFlagsFormatter), 0)] [assembly: RegisterFormatter(typeof(NetworkTransformDeltaFormatter), 0)] [assembly: AssemblyCompany("Rune580")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.2.0")] [assembly: AssemblyInformationalVersion("0.1.2+8219404c10b8c24abe3711d115d7a90bd7ae02e5")] [assembly: AssemblyProduct("RepoSteamNetworking")] [assembly: AssemblyTitle("RepoSteamNetworking")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Rune580/RepoSteamNetworking")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 RepoSteamNetworking { [RSNVersionCompatibility(VersionCompatibility.Any, false)] [BepInPlugin("com.rune580.reposteamnetworking", "Repo Steam Networking", "0.1.2")] public class RepoSteamNetworkingPlugin : BaseUnityPlugin { private void Awake() { Logging.SetLogSource(((BaseUnityPlugin)this).Logger); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.reposteamnetworking"); RegisterPackets(); } private void RegisterPackets() { RepoSteamNetwork.RegisterPacket<HandshakeStartAuthPacket>(); RepoSteamNetwork.RegisterPacket<HandshakeAuthConnectionPacket>(); RepoSteamNetwork.RegisterPacket<HandshakeStatusPacket>(); RepoSteamNetwork.AddCallback<HandshakeStatusPacket>(PacketHandler.OnHandshakeStatusReceived); RepoSteamNetwork.RegisterPacket<ClientModVersionRegistryPacket>(); RepoSteamNetwork.AddCallback<ClientModVersionRegistryPacket>(PacketHandler.OnClientModVersionRegistryReceived); RepoSteamNetwork.RegisterPacket<ServerModVersionRegistryStatusPacket>(); RepoSteamNetwork.AddCallback<ServerModVersionRegistryStatusPacket>(PacketHandler.OnServerModVersionRegistryReceived); RepoSteamNetwork.RegisterPacket<SetConnectionPalettesPacket>(); RepoSteamNetwork.AddCallback<SetConnectionPalettesPacket>(PacketHandler.OnSetConnectionPalettesReceived); RepoSteamNetwork.RegisterPacket<CallRPCPacket>(); RepoSteamNetwork.AddCallback<CallRPCPacket>(PacketHandler.OnCallRPCPacketReceived); RepoSteamNetwork.RegisterPacket<NetworkedPropertiesDataPacket>(); RepoSteamNetwork.AddCallback<NetworkedPropertiesDataPacket>(NetworkedPropertyManager.OnNetworkedPropertiesPacketReceived); RepoSteamNetwork.RegisterPacket<InstantiateNetworkedPrefabPacket>(); RepoSteamNetwork.AddCallback<InstantiateNetworkedPrefabPacket>(PacketHandler.OnInstantiateNetworkedPrefabPacketReceived); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.rune580.reposteamnetworking"; public const string PLUGIN_NAME = "Repo Steam Networking"; public const string PLUGIN_VERSION = "0.1.2"; } } namespace RepoSteamNetworking.Utils { public struct BitFlags { private bool[] _bits; public bool this[int index] { get { return _bits[index]; } set { if (_bits == null) { _bits = new bool[8]; } while (index >= _bits.Length) { Array.Resize(ref _bits, _bits.Length * 2); } _bits[index] = value; } } public BitFlags(byte bits) { _bits = new bool[8]; for (int i = 0; i < _bits.Length; i++) { _bits[i] = (bits & (1 << i)) != 0; } } public BitFlags(ushort bits) { _bits = new bool[16]; for (int i = 0; i < _bits.Length; i++) { _bits[i] = (bits & (1 << i)) != 0; } } public BitFlags(byte[] bytes) { _bits = new bool[bytes.Length * 8]; for (int i = 0; i < _bits.Length; i++) { int num = i / 8; _bits[i] = (bytes[num] & (1 << i - 8 * num)) != 0; } } public void SetFromBytes(byte[] bytes) { _bits = new bool[bytes.Length * 8]; for (int i = 0; i < _bits.Length; i++) { int num = i / 8; _bits[i] = (bytes[num] & (1 << i - 8 * num)) != 0; } } public byte[] AsByteArray() { byte[] array = new byte[_bits.Length / 8]; for (int i = 0; i < _bits.Length; i++) { int num = i / 8; array[num] |= (byte)((_bits[i] ? 1u : 0u) << i); } return array; } } internal static class ComponentUtils { private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; public static IEnumerable<FieldInfo> GetAllSerializedFields(this Component component) { return from type in ((object)component).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy) where type.IsDefined(typeof(SerializeField), inherit: false) || type.IsPublic select type; } public static Component GetOrAddComponent(this GameObject gameObject, string assemblyQualifiedName) { Type type = Type.GetType(assemblyQualifiedName); Component component = gameObject.GetComponent(type); if (Object.op_Implicit((Object)(object)component)) { return component; } return gameObject.AddComponent(type); } public static Component GetOrAddComponent(this Transform transform, string assemblyQualifiedName) { return ((Component)transform).gameObject.GetOrAddComponent(assemblyQualifiedName); } public static void SetFieldValues(this Component component, Dictionary<string, object?> values) { Type type = ((object)component).GetType(); foreach (KeyValuePair<string, object> value3 in values) { value3.Deconstruct(out var key, out var value); string text = key; object value2 = value; FieldInfo field = type.GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); if ((object)field == null) { Logging.Warn("Failed to find field " + text + " on component " + type.Name + "!"); } else { field.SetValue(component, value2); } } } } internal static class Logging { private static ManualLogSource? _logSource; internal static void SetLogSource(ManualLogSource logSource) { _logSource = logSource; } public static void Error(object data) { Error(data.ToString()); } public static void Warn(object data) { Warn(data.ToString()); } public static void Info(object data) { Info(data.ToString()); } public static void Debug(object data) { Debug(data.ToString()); } public static void Error(string msg) { if (_logSource == null) { Debug.LogError((object)("[Repo Steam Networking] [Error] " + msg)); } else { _logSource.LogError((object)msg); } } public static void Warn(string msg) { if (_logSource == null) { Debug.LogWarning((object)("[Repo Steam Networking] [Warning] " + msg)); } else { _logSource.LogWarning((object)msg); } } public static void Info(string msg) { if (_logSource == null) { Debug.Log((object)("[Repo Steam Networking] [Info] " + msg)); } else { _logSource.LogInfo((object)msg); } } public static void Debug(string msg) { if (_logSource == null) { Debug.Log((object)("[Repo Steam Networking] [Debug] " + msg)); } else { _logSource.LogDebug((object)msg); } } public static string DebugFormat(this object obj, bool showTypeName = false, bool newLine = false, int depth = 0) { Type type = obj.GetType(); StringBuilder stringBuilder = new StringBuilder(); if (showTypeName) { stringBuilder.Append(type.Name + " "); } stringBuilder.Append("( "); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo obj2 in properties) { if (newLine) { stringBuilder.AppendLine(); } string name = obj2.Name; object value = obj2.GetValue(obj); if (depth > 0) { try { stringBuilder.Append(value.DebugFormat(showTypeName, newLine, depth - 1)); } catch { stringBuilder.Append($"{name}: {value},"); } } else { stringBuilder.Append($"{name}: {value},"); } if (!newLine) { stringBuilder.Append(" "); } } FieldInfo[] fields = type.GetFields(); foreach (FieldInfo obj4 in fields) { if (newLine) { stringBuilder.AppendLine(); } string name2 = obj4.Name; object value2 = obj4.GetValue(obj); if (depth > 0) { try { stringBuilder.Append(value2.DebugFormat(showTypeName, newLine, depth - 1)); } catch { stringBuilder.Append($"{name2}: {value2},"); } } else { stringBuilder.Append($"{name2}: {value2},"); } if (!newLine) { stringBuilder.Append(" "); } } if (newLine) { stringBuilder.AppendLine(); } stringBuilder.Append(")"); return stringBuilder.ToString(); } public static string DebugFormatArray<T>(this IEnumerable<T> array) { StringBuilder stringBuilder = new StringBuilder(); foreach (T item in array) { stringBuilder.Append($"{item},"); } return stringBuilder.ToString().TrimEnd(','); } } internal class MethodHandler : IEquatable<MethodHandler> { private readonly MethodInfo _method; private readonly object? _target; private MethodHandler(MethodInfo method, object? target = null) { _method = method; _target = target; } public void Invoke(params object[] parameters) { _method.Invoke(_target, parameters); } public static MethodHandler FromAction<T1>(Action<T1> action) { MethodInfo method = action.Method; object target = action.Target; return new MethodHandler(method, target); } public bool Equals(MethodHandler? other) { if ((object)other == null) { return false; } if ((object)this == other) { return true; } if (_method.Name != other._method.Name) { return false; } if (_target != other._target) { return false; } ParameterInfo[] parameters = _method.GetParameters(); ParameterInfo[] parameters2 = other._method.GetParameters(); if (parameters.Length != parameters2.Length) { return false; } for (int i = 0; i < parameters.Length; i++) { if (parameters[i] != parameters2[i]) { return false; } } return true; } public override bool Equals(object? obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (obj.GetType() != GetType()) { return false; } return Equals((MethodHandler)obj); } public override int GetHashCode() { return HashCode.Combine(_method, _target); } public static bool operator ==(MethodHandler? left, MethodHandler? right) { return object.Equals(left, right); } public static bool operator !=(MethodHandler? left, MethodHandler? right) { return !object.Equals(left, right); } } internal static class ReflectionUtils { public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly) { try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type t) => (object)t != null); } } public static BepInPlugin? GetPluginInfoFromAssembly(this Assembly assembly) { return assembly.GetLoadableTypes().SelectMany((Type type) => ((MemberInfo)type).GetCustomAttributes<BepInPlugin>()).FirstOrDefault(); } } internal class RPCMethodHelper { private readonly Dictionary<int, Dictionary<int, MethodInfo>> _methodInfoCache = new Dictionary<int, Dictionary<int, MethodInfo>>(); public void InvokeRPC(object target, string methodName, object[] parameters) { GetMethodInfo(target, methodName, parameters)?.Invoke(target, parameters); } private MethodInfo? GetMethodInfo(object target, string methodName, object[] parameters) { int hashcodeFromTarget = GetHashcodeFromTarget(target); if (!_methodInfoCache.TryGetValue(hashcodeFromTarget, out Dictionary<int, MethodInfo> value)) { value = (_methodInfoCache[hashcodeFromTarget] = new Dictionary<int, MethodInfo>()); } Type[] array = parameters.Select((object parameter) => parameter.GetType()).ToArray(); int hashcodeFromMethod = GetHashcodeFromMethod(methodName, array); if (!value.TryGetValue(hashcodeFromMethod, out var value2)) { value2 = (value[hashcodeFromMethod] = target.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy, null, CallingConventions.Any, array, Array.Empty<ParameterModifier>())); } if ((object)value2 == null) { Logging.Error("Failed to find RPC method " + methodName + " on " + target.GetType().Name + " with parameter types " + array.Select((Type type) => type.FullName).ToArray().DebugFormatArray()); return null; } return value2; } private static int GetHashcodeFromTarget(object target) { Type type = target.GetType(); return (type.Assembly.FullName + type.FullName).GetHashCode(); } private static int GetHashcodeFromMethod(string methodName, Type[] parameterTypes) { string seed = methodName + ","; seed = parameterTypes.Aggregate(seed, (string current, Type parameterType) => current + parameterType.Assembly.FullName + parameterType.FullName + ","); seed = seed.TrimEnd(','); return seed.GetHashCode(); } } internal static class SteamIdUtils { private static readonly Dictionary<ulong, string> CachedSteamIds = new Dictionary<ulong, string>(); public static string GetLobbyName(this SteamId steamId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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 (CachedSteamIds.TryGetValue(SteamId.op_Implicit(steamId), out string value)) { return value; } Lobby currentLobby = RepoSteamNetwork.GetCurrentLobby(); SteamFriends.RequestUserInformation(steamId, true); string[] array = ((Lobby)(ref currentLobby)).Members.Where((Friend friend) => SteamId.op_Implicit(friend.Id) == SteamId.op_Implicit(steamId)).SelectMany((Friend friend) => ((Friend)(ref friend)).NameHistory).ToArray(); if (array.Length == 0) { return $"SteamId: {steamId.Value}"; } string text = array.First(); if (string.IsNullOrEmpty(text)) { return $"SteamId: {steamId.Value}"; } CachedSteamIds[SteamId.op_Implicit(steamId)] = text; return text; } } internal static class SubIdentityHelper { public static void RegisterAllSubIdentities(this GameObject gameObject) { IEnumerable<ISteamNetworkSubIdentity> enumerable = gameObject.GetComponentsInChildren<Component>().OfType<ISteamNetworkSubIdentity>(); RepoSteamNetworkIdentity repoSteamNetworkIdentity = null; foreach (ISteamNetworkSubIdentity item in enumerable) { if (repoSteamNetworkIdentity == null) { repoSteamNetworkIdentity = item.GetNetworkIdentity(); } repoSteamNetworkIdentity.RegisterSubIdentity(item); } } } internal static class TransformUtils { public static string GetPathFromParent(this Transform current, Transform target) { string text = ((Object)current).name; Transform parent = current.parent; while ((Object)(object)parent != (Object)(object)target && Object.op_Implicit((Object)(object)parent)) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } } internal static class VariableDeltaHelper { public static object Add(object left, object right) { //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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) if (!(left is byte b)) { if (!(left is sbyte b2)) { if (!(left is ushort num)) { if (!(left is short num2)) { if (!(left is uint num3)) { if (!(left is int num4)) { if (!(left is ulong num5)) { if (!(left is long num6)) { if (!(left is float num7)) { if (!(left is double num8)) { if (!(left is Vector2 val)) { if (!(left is Vector2Int val2)) { if (!(left is Vector3 val3)) { if (!(left is Vector3Int val4)) { if (!(left is Vector4 val5)) { if (left is Color val6) { return val6 + (Color)right; } throw new ArgumentOutOfRangeException("left", left, null); } return val5 + (Vector4)right; } return val4 + (Vector3Int)right; } return val3 + (Vector3)right; } return val2 + (Vector2Int)right; } return val + (Vector2)right; } return num8 + (double)right; } return num7 + (float)right; } return num6 + (long)right; } return num5 + (ulong)right; } return num4 + (int)right; } return num3 + (uint)right; } return num2 + (short)right; } return num + (ushort)right; } return b2 + (sbyte)right; } return b + (byte)right; } } } namespace RepoSteamNetworking.Utils.Tween { public struct Vector3Tween : ITweenValue { private class Vector3TweenCallback : UnityEvent<Vector3> { } private Vector3TweenCallback? _target; public bool ignoreTimeScale { get; set; } public float duration { get; set; } public Vector3 StartValue { get; set; } public Vector3 TargetValue { get; set; } public void TweenValue(float floatPercentage) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (ValidTarget()) { Vector3 val = Vector3.Lerp(StartValue, TargetValue, floatPercentage); ((UnityEvent<Vector3>)_target).Invoke(val); } } public void AddOnChangedCallback(UnityAction<Vector3> callback) { if (_target == null) { _target = new Vector3TweenCallback(); } ((UnityEvent<Vector3>)_target).AddListener(callback); } public bool ValidTarget() { return _target != null; } } } namespace RepoSteamNetworking.Prefab { internal class PrefabComponentState { public readonly string FullTypeName; public readonly FieldInfo[] SerializableFields; public readonly Dictionary<string, object?> Values = new Dictionary<string, object>(); public uint ComponentIndex; public PrefabComponentState(Component component) { FullTypeName = ((object)component).GetType().AssemblyQualifiedName; List<FieldInfo> list = new List<FieldInfo>(); foreach (FieldInfo allSerializedField in component.GetAllSerializedFields()) { if ((object)allSerializedField != null) { list.Add(allSerializedField); Values[allSerializedField.Name] = allSerializedField.GetValue(component); } } SerializableFields = list.ToArray(); } public bool AreFieldsEqual(PrefabComponentState other) { return GetChangedValues(other).Count == 0; } public Dictionary<string, object?> GetChangedValues(PrefabComponentState other) { Dictionary<string, object> dictionary = new Dictionary<string, object>(); HashSet<string> hashSet = other.Values.Keys.ToHashSet(); foreach (var (text2, obj2) in Values) { if (!other.Values.TryGetValue(text2, out object value)) { dictionary[text2] = null; } else if (obj2 != value) { dictionary[text2] = value; } else if (!hashSet.Remove(text2)) { dictionary[text2] = null; } } foreach (string item in hashSet) { dictionary[item] = other.Values[item]; } return dictionary; } } internal class PrefabGameObjectState { public readonly string PrefabPath; public readonly PrefabComponentState[] Components; public readonly PrefabGameObjectState[] Children; private PrefabState _prefab; private readonly Dictionary<string, int> _pathChildMap = new Dictionary<string, int>(); private readonly Dictionary<string, int> _pathComponentMap = new Dictionary<string, int>(); public string Name => PrefabPath.Split('/', StringSplitOptions.RemoveEmptyEntries).Last(); public string ParentPrefabPath { get { if (!(PrefabPath == Name)) { return PrefabPath.Replace("/" + Name, ""); } return string.Empty; } } public PrefabGameObjectState(string currentPath, GameObject gameObject, PrefabState prefab) { //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown _prefab = prefab; PrefabPath = (string.IsNullOrEmpty(currentPath) ? ((Object)gameObject).name : (currentPath + "/" + ((Object)gameObject).name)); _prefab.AddChildPath(PrefabPath); Component[] components = gameObject.GetComponents<Component>(); Components = new PrefabComponentState[components.Length]; Dictionary<string, uint> dictionary = new Dictionary<string, uint>(); for (int i = 0; i < components.Length; i++) { PrefabComponentState prefabComponentState = new PrefabComponentState(components[i]); if (!dictionary.TryGetValue(prefabComponentState.FullTypeName, out var value)) { value = (dictionary[prefabComponentState.FullTypeName] = 0u); } prefabComponentState.ComponentIndex = value++; dictionary[prefabComponentState.FullTypeName] = value; string text = $"{PrefabPath}:{prefabComponentState.FullTypeName}-{prefabComponentState.ComponentIndex}"; _prefab.AddComponentPath(text); _pathComponentMap[text] = i; Components[i] = prefabComponentState; } List<PrefabGameObjectState> list = new List<PrefabGameObjectState>(); int num2 = 0; foreach (Transform item in gameObject.transform) { Transform val = item; PrefabGameObjectState prefabGameObjectState = new PrefabGameObjectState(PrefabPath, ((Component)val).gameObject, _prefab); list.Add(prefabGameObjectState); _prefab.AddChildPath(prefabGameObjectState.PrefabPath); _pathChildMap[prefabGameObjectState.PrefabPath] = num2++; } Children = list.ToArray(); } public bool TryGetChild(string path, out PrefabGameObjectState child) { child = null; if (!_pathChildMap.TryGetValue(path, out var value)) { return false; } child = Children[value]; return true; } public bool TryGetComponent(string componentPath, out PrefabComponentState component) { component = null; string text = componentPath.Split(':').First(); if (PrefabPath != text) { if (!TryGetChild(text, out PrefabGameObjectState child)) { return false; } return child.TryGetComponent(componentPath, out component); } if (!_pathComponentMap.TryGetValue(componentPath, out var value)) { return false; } component = Components[value]; return true; } } internal class PrefabState { public readonly PrefabGameObjectState Root; private readonly HashSet<string> _childPaths = new HashSet<string>(); private readonly HashSet<string> _componentPaths = new HashSet<string>(); public PrefabState(GameObject gameObject) { Root = new PrefabGameObjectState("", gameObject, this); } public bool TryGetGameObject(string path, out PrefabGameObjectState gameObject) { if (string.IsNullOrEmpty(path) || path == Root.Name) { gameObject = Root; return true; } return Root.TryGetChild(path, out gameObject); } public void AddChildPath(string path) { _childPaths.Add(path); } public void AddComponentPath(string path) { _componentPaths.Add(path); } public bool TryGetComponent(string componentPath, out PrefabComponentState component) { return Root.TryGetComponent(componentPath, out component); } public PrefabModifications GetModifications(PrefabState modifiedPrefab) { HashSet<string> hashSet = new HashSet<string>(modifiedPrefab._childPaths); HashSet<string> hashSet2 = new HashSet<string>(modifiedPrefab._componentPaths); HashSet<string> removedChildPaths = new HashSet<string>(); HashSet<string> removedComponentPaths = new HashSet<string>(); PrefabModifications prefabModifications = new PrefabModifications(); foreach (string childPath3 in _childPaths) { if (removedChildPaths.Any((string removedPath) => childPath3.Contains(removedPath))) { continue; } PrefabGameObjectState gameObject; if (childPath3 == Root.Name) { gameObject = modifiedPrefab.Root; } else if (!modifiedPrefab.TryGetGameObject(childPath3, out gameObject)) { removedChildPaths.Add(childPath3); prefabModifications.AddModification(new GameObjectRemovedModification(childPath3)); continue; } TryGetGameObject(childPath3, out PrefabGameObjectState gameObject2); PrefabComponentState[] components = gameObject2.Components; foreach (PrefabComponentState prefabComponentState in components) { string text = $"{gameObject2.PrefabPath}:{prefabComponentState.FullTypeName}-{prefabComponentState.ComponentIndex}"; if (!gameObject.TryGetComponent(text, out PrefabComponentState component)) { removedComponentPaths.Add(text); prefabModifications.AddModification(new ComponentRemovedModification(text)); continue; } Dictionary<string, object> changedValues = prefabComponentState.GetChangedValues(component); if (changedValues.Count > 0) { hashSet2.Remove(text); prefabModifications.AddModification(new ComponentValuesModification(text, changedValues)); } else { hashSet2.Remove(text); } } foreach (string item in hashSet2.Where((string otherComponentPath) => !removedComponentPaths.Any(otherComponentPath.Contains))) { if (!gameObject.TryGetComponent(item, out PrefabComponentState component2)) { Logging.Error("Failed to find component in Modified Prefab even though path came from said prefab?"); } else { prefabModifications.AddModification(new ComponentAddedModification(item, component2.Values)); } } hashSet.Remove(childPath3); } IOrderedEnumerable<string> orderedEnumerable = from otherChild in hashSet where !removedChildPaths.Any(otherChild.Contains) select otherChild into childPath orderby childPath.Split('/').Length select childPath; HashSet<string> hashSet3 = new HashSet<string>(); foreach (string childPath2 in orderedEnumerable) { if (!hashSet3.Any((string addedPath) => childPath2.Contains(addedPath))) { if (!modifiedPrefab.TryGetGameObject(childPath2, out PrefabGameObjectState gameObject3)) { Logging.Error("Failed to find child in Modified Prefab even though path came from said prefab?"); continue; } prefabModifications.AddModification(new GameObjectAddedModification(gameObject3)); hashSet3.Add(childPath2); } } return prefabModifications; } } } namespace RepoSteamNetworking.Prefab.Modifications { [Serializable] public abstract class BasePrefabModification { internal abstract void Apply(GameObject prefabRoot); } [Serializable] public class ComponentAddedModification : BasePrefabModification { public string ComponentPath; public Dictionary<string, object?> Values; public string FullTypeName => ComponentPath.Split(':').Last().Split('-') .First(); public string PrefabPath => ComponentPath.Split(':').First(); public ComponentAddedModification() { ComponentPath = string.Empty; Values = new Dictionary<string, object>(); } public ComponentAddedModification(string componentPath, Dictionary<string, object?> values) { ComponentPath = componentPath; Values = values; } internal override void Apply(GameObject prefabRoot) { ((PrefabPath == ((Object)prefabRoot).name) ? prefabRoot.transform : prefabRoot.transform.Find(PrefabPath)).GetOrAddComponent(FullTypeName).SetFieldValues(Values); } } [Serializable] public class ComponentRemovedModification : BasePrefabModification { public string ComponentPath; public string FullTypeName => ComponentPath.Split(':').Last().Split('-') .First(); public string PrefabPath => ComponentPath.Split(':').First(); public ComponentRemovedModification() { ComponentPath = string.Empty; } public ComponentRemovedModification(string componentPath) { ComponentPath = componentPath; } internal override void Apply(GameObject prefabRoot) { Object.DestroyImmediate((Object)(object)((PrefabPath == ((Object)prefabRoot).name) ? prefabRoot.transform : prefabRoot.transform.Find(PrefabPath)).GetOrAddComponent(FullTypeName)); } } [Serializable] public class ComponentValuesModification : BasePrefabModification { public string ComponentPath; public Dictionary<string, object?> Values; public string FullTypeName => ComponentPath.Split(':').Last().Split('-') .First(); public string PrefabPath => ComponentPath.Split(':').First(); public ComponentValuesModification() { ComponentPath = string.Empty; Values = new Dictionary<string, object>(); } public ComponentValuesModification(string componentPath, Dictionary<string, object?> values) { ComponentPath = componentPath; Values = values; } internal override void Apply(GameObject prefabRoot) { ((PrefabPath == ((Object)prefabRoot).name) ? prefabRoot.transform : prefabRoot.transform.Find(PrefabPath)).GetOrAddComponent(FullTypeName).SetFieldValues(Values); } } [Serializable] public class GameObjectAddedModification : BasePrefabModification { public string Name; public string ParentPrefabPath; [SerializeField] private BasePrefabModification[] Modifications; public GameObjectAddedModification() { Name = string.Empty; ParentPrefabPath = string.Empty; Modifications = Array.Empty<BasePrefabModification>(); } internal GameObjectAddedModification(PrefabGameObjectState gameObjectState) { Name = gameObjectState.Name; ParentPrefabPath = gameObjectState.ParentPrefabPath; List<BasePrefabModification> list = new List<BasePrefabModification>(); PrefabComponentState[] components = gameObjectState.Components; foreach (PrefabComponentState prefabComponentState in components) { string componentPath = $"{gameObjectState.PrefabPath}:{prefabComponentState.FullTypeName}-{prefabComponentState.ComponentIndex}"; list.Add(new ComponentAddedModification(componentPath, prefabComponentState.Values)); } PrefabGameObjectState[] children = gameObjectState.Children; foreach (PrefabGameObjectState gameObjectState2 in children) { list.Add(new GameObjectAddedModification(gameObjectState2)); } Modifications = list.ToArray(); } internal override void Apply(GameObject prefabRoot) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) Transform val = ((ParentPrefabPath == ((Object)prefabRoot).name) ? prefabRoot.transform : prefabRoot.transform.Find(ParentPrefabPath)); new GameObject(Name).transform.SetParent(((Component)val).transform); BasePrefabModification[] modifications = Modifications; for (int i = 0; i < modifications.Length; i++) { modifications[i].Apply(prefabRoot); } } } [Serializable] public class GameObjectRemovedModification : BasePrefabModification { public string PrefabPath; public GameObjectRemovedModification() { PrefabPath = string.Empty; } public GameObjectRemovedModification(string prefabPath) { PrefabPath = prefabPath; } internal override void Apply(GameObject prefabRoot) { Object.DestroyImmediate((Object)(object)((PrefabPath == ((Object)prefabRoot).name) ? prefabRoot.transform : prefabRoot.transform.Find(PrefabPath))); } } internal class PrefabModifications { private readonly List<BasePrefabModification> _modifications = new List<BasePrefabModification>(); public BasePrefabModification[] AsArray() { return _modifications.ToArray(); } public PrefabModifications() { } public PrefabModifications(BasePrefabModification[] modifications) { _modifications = new List<BasePrefabModification>(modifications); } public void AddModification(BasePrefabModification modification) { _modifications.Add(modification); } public void ApplyModifications(GameObject prefabRoot) { foreach (BasePrefabModification modification in _modifications) { modification.Apply(prefabRoot); } } } } namespace RepoSteamNetworking.Patches { public static class SteamManagerPatches { [HarmonyPatch(typeof(SteamManager), "Awake")] public static class OnAwakePatch { public static void Postfix(SteamManager __instance) { RepoSteamNetworkManager.CreateSingleton(((Component)__instance).gameObject); RepoNetworkingServer.CreateSingleton(((Component)__instance).gameObject); RepoNetworkingClient.CreateSingleton(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(SteamManager), "OnLobbyCreated")] public static class OnLobbyCreatedPatch { public static void Postfix(Lobby _lobby) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) RepoNetworkingServer.Instance.StartSocketServer(_lobby); } } [HarmonyPatch(typeof(SteamManager), "OnLobbyEntered")] public static class OnLobbyEnteredPatch { public static void Postfix(Lobby _lobby) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) RepoNetworkingClient.Instance.ConnectToServer(_lobby); } } [HarmonyPatch(typeof(SteamManager), "LeaveLobby")] public static class OnLeaveLobbyPatch { public static void Prefix(SteamManager __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref __instance.currentLobby)).IsOwnedBy(SteamClient.SteamId)) { RepoNetworkingServer.Instance.StopSocketServer(); } RepoNetworkingClient.Instance.DisconnectFromServer(); } } } } namespace RepoSteamNetworking.Odin.Formatters { public class BitFlagsFormatter : MinimalBaseFormatter<BitFlags> { private static readonly Serializer<byte> ByteSerializer = Serializer.Get<byte>(); public override void Read(ref BitFlags value, IDataReader reader) { byte b = ByteSerializer.ReadValue(reader); byte[] array = new byte[b]; for (int i = 0; i < b; i++) { array[i] = ByteSerializer.ReadValue(reader); } value.SetFromBytes(array); } public override void Write(ref BitFlags value, IDataWriter writer) { byte[] array = value.AsByteArray(); ByteSerializer.WriteValue((byte)array.Length, writer); byte[] array2 = array; foreach (byte b in array2) { ByteSerializer.WriteValue(b, writer); } } } public class NetworkTransformDeltaFormatter : MinimalBaseFormatter<NetworkTransformDelta> { private static readonly Serializer<BitFlags> BitFlagsSerializer = Serializer.Get<BitFlags>(); private static readonly Serializer<float> FloatSerializer = Serializer.Get<float>(); public override void Read(ref NetworkTransformDelta value, IDataReader reader) { BitFlags bitFlags = BitFlagsSerializer.ReadValue(reader); if (bitFlags[0]) { value.PositionX = FloatSerializer.ReadValue(reader); } if (bitFlags[1]) { value.PositionY = FloatSerializer.ReadValue(reader); } if (bitFlags[2]) { value.PositionZ = FloatSerializer.ReadValue(reader); } if (bitFlags[3]) { value.RotationX = FloatSerializer.ReadValue(reader); } if (bitFlags[4]) { value.RotationY = FloatSerializer.ReadValue(reader); } if (bitFlags[5]) { value.RotationZ = FloatSerializer.ReadValue(reader); } if (bitFlags[6]) { value.ScaleX = FloatSerializer.ReadValue(reader); } if (bitFlags[7]) { value.ScaleY = FloatSerializer.ReadValue(reader); } if (bitFlags[8]) { value.ScaleZ = FloatSerializer.ReadValue(reader); } } public override void Write(ref NetworkTransformDelta value, IDataWriter writer) { BitFlags bitFlags = default(BitFlags); bitFlags[0] = value.PositionX.HasValue; bitFlags[1] = value.PositionY.HasValue; bitFlags[2] = value.PositionZ.HasValue; bitFlags[3] = value.RotationX.HasValue; bitFlags[4] = value.RotationY.HasValue; bitFlags[5] = value.RotationZ.HasValue; bitFlags[6] = value.ScaleX.HasValue; bitFlags[7] = value.ScaleY.HasValue; bitFlags[8] = value.ScaleZ.HasValue; BitFlags bitFlags2 = bitFlags; BitFlagsSerializer.WriteValue(bitFlags2, writer); if (value.PositionX.HasValue) { FloatSerializer.WriteValue(value.PositionX.Value, writer); } if (value.PositionY.HasValue) { FloatSerializer.WriteValue(value.PositionY.Value, writer); } if (value.PositionZ.HasValue) { FloatSerializer.WriteValue(value.PositionZ.Value, writer); } if (value.RotationX.HasValue) { FloatSerializer.WriteValue(value.RotationX.Value, writer); } if (value.RotationY.HasValue) { FloatSerializer.WriteValue(value.RotationY.Value, writer); } if (value.RotationZ.HasValue) { FloatSerializer.WriteValue(value.RotationZ.Value, writer); } if (value.ScaleX.HasValue) { FloatSerializer.WriteValue(value.ScaleX.Value, writer); } if (value.ScaleY.HasValue) { FloatSerializer.WriteValue(value.ScaleY.Value, writer); } if (value.ScaleZ.HasValue) { FloatSerializer.WriteValue(value.ScaleZ.Value, writer); } } } } namespace RepoSteamNetworking.Networking { internal static class NetworkAssetDatabase { private struct NetworkAssetBundle { public AssetBundle Bundle { get; set; } public bool Managed { get; set; } } private static readonly Dictionary<AssetBundleReference, NetworkAssetBundle> AssetBundles = new Dictionary<AssetBundleReference, NetworkAssetBundle>(); public static AssetBundleReference RegisterAssetBundle(AssetBundle assetBundle, string modGuid, string bundleName, bool managed) { AssetBundleReference assetBundleReference = (modGuid, bundleName); AssetBundles[assetBundleReference] = new NetworkAssetBundle { Bundle = assetBundle, Managed = managed }; Logging.Info("Registered Networked AssetBundle " + assetBundleReference.ToString() + "!"); return assetBundleReference; } public static T? LoadAsset<T>(PrefabReference prefabRef) where T : Object { if (!AssetBundles.TryGetValue(prefabRef.BundleReference, out var value)) { Logging.Error($"Failed to find AssetBundle with reference: {prefabRef.BundleReference}"); return default(T); } if (value.Managed) { return default(T); } return value.Bundle.LoadAsset<T>(prefabRef.assetPath); } public static AssetBundleRequest? LoadAssetAsync<T>(PrefabReference prefabRef) where T : Object { if (!AssetBundles.TryGetValue(prefabRef.BundleReference, out var value)) { Logging.Error($"Failed to find AssetBundle with reference: {prefabRef.BundleReference}"); return null; } if (value.Managed) { return null; } return value.Bundle.LoadAssetAsync<T>(prefabRef.assetPath); } public static IEnumerable<PrefabReference> GetAllAssets(AssetBundleReference bundleRef) { return from path in AssetBundles[bundleRef].Bundle.GetAllAssetNames() select bundleRef.GetPrefabReference(path); } } public enum NetworkDestination { HostOnly, ClientsOnly, Everyone, PacketTarget, EveryoneExcludingSender } internal static class PacketHandler { public static void OnHandshakeStatusReceived(HandshakeStatusPacket packet) { RepoNetworkingClient.Instance.SetConnectionVerified(packet.Success); if (!packet.Success) { Logging.Error("Failed to verify with server! Either something has gone terribly wrong, or steam is down!"); return; } Logging.Info("Successfully verified connection with server!"); Logging.Info("Sending mod compat registry to server to verify mod list compatibility."); RepoSteamNetwork.SendPacket(VersionCompatRegistry.CreateRegistryPacket(), NetworkDestination.HostOnly); } public static void OnClientModVersionRegistryReceived(ClientModVersionRegistryPacket packet) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) ClientModVersionRegistryPacket packet2 = packet; if (!RepoNetworkingServer.Instance.ServerActive) { Logging.Warn("Client registry was received on an invalid server?!"); return; } ServerModVersionRegistryStatusPacket serverModVersionRegistryStatusPacket = new ServerModVersionRegistryStatusPacket(); string lobbyName = packet2.Header.Sender.GetLobbyName(); foreach (var (text2, version2) in packet2.ModVersions) { if (!VersionCompatRegistry.IsCompatible(text2, version2, out Version serverModVersion, out VersionCompatibility serverCompatibility)) { if ((object)serverModVersion == null) { Logging.Warn("Client " + lobbyName + " has mod " + text2 + " that requires RepoSteamNetworking, but said mod is not present (or failed to register) on Server!"); } else { Logging.Warn($"Client {lobbyName} has mod {text2} with version {version2}, They need to have {serverCompatibility.CreateVersionRequirementString(serverModVersion)}!"); serverModVersionRegistryStatusPacket.AddIncompatible(text2, serverModVersion, serverCompatibility); } } } string[] array = (from guid in VersionCompatRegistry.ModGuids where !packet2.ModVersions.ContainsKey(guid) where !VersionCompatRegistry.IsOptional(guid) select guid).ToArray(); foreach (string text3 in array) { Logging.Warn("Client " + lobbyName + " is missing required mod " + text3 + "!"); if (VersionCompatRegistry.TryGetCompatInfo(text3, out RSNVersionCompatibilityAttribute compatInfo) && VersionCompatRegistry.TryGetVersion(text3, out Version version3)) { serverModVersionRegistryStatusPacket.AddIncompatible(text3, version3, compatInfo.Compatibility); } } if (serverModVersionRegistryStatusPacket.HasIncompatibilities()) { Logging.Warn("Client " + lobbyName + " has a mismatch in mod versions or is missing required mods! There may be issues during play, Please ensure that all players have the same mod list and versions!"); } Logging.Info("Sending mod compat response to client " + lobbyName + "."); serverModVersionRegistryStatusPacket.SetTarget(packet2.Header.Sender); RepoSteamNetwork.SendPacket(serverModVersionRegistryStatusPacket, NetworkDestination.PacketTarget); if (RepoNetworkingServer.Instance.SocketManager.TryGetSteamUserConnection(packet2.Header.Sender, out SteamUserConnection userConnection)) { userConnection.SetValidated(); if (!userConnection.IsLobbyHost) { Logging.Info($"Sending Connection Palettes [ModNetworkGuidRegistry: {ModNetworkGuidRegistry.Palette.Count()} Entries] [BehaviourIdRegistry: {BehaviourIdRegistry.Palette.Count()} Entries] to {userConnection.UserName}"); SetConnectionPalettesPacket packet3 = new SetConnectionPalettesPacket { GuidPalette = ModNetworkGuidRegistry.Palette, BehaviourIdPalette = BehaviourIdRegistry.Palette }; userConnection.SendPacket(packet3); } } } public static void OnServerModVersionRegistryReceived(ServerModVersionRegistryStatusPacket packet) { if (packet.ModIncompatibilities.Length == 0) { Logging.Info("Mod lists are compatible between server and client!"); return; } ServerModVersionRegistryStatusPacket.ServerModRegistryEntry[] modIncompatibilities = packet.ModIncompatibilities; for (int i = 0; i < modIncompatibilities.Length; i++) { ServerModVersionRegistryStatusPacket.ServerModRegistryEntry serverModRegistryEntry = modIncompatibilities[i]; if (!VersionCompatRegistry.TryGetVersion(serverModRegistryEntry.Guid, out Version version)) { Logging.Warn("Server requires a mod that isn't installed (or failed to register)! Mod Id: " + serverModRegistryEntry.Guid + " Version: " + serverModRegistryEntry.Compatibility.CreateVersionRequirementString(serverModRegistryEntry.Version) + "!"); } else { Logging.Warn($"Mod Id: {serverModRegistryEntry.Guid} Version: {version} requires {serverModRegistryEntry.Compatibility.CreateVersionRequirementString(serverModRegistryEntry.Version)}"); } } Logging.Warn("There's a mismatch in mods and or mod versions! You are responsible for any issues you may encounter!"); } public static void OnSetConnectionPalettesReceived(SetConnectionPalettesPacket packet) { RepoSteamNetworkManager.Instance.SetModGuidPalette(packet.GuidPalette); RepoSteamNetworkManager.Instance.SetBehaviourIdPalette(packet.BehaviourIdPalette); } public static void OnCallRPCPacketReceived(CallRPCPacket packet) { RepoSteamNetwork.InvokeRPC(packet.NetworkId, packet.GuidPaletteId, packet.SubId, packet.MethodName, packet.Parameters); } public static void OnInstantiateNetworkedPrefabPacketReceived(InstantiateNetworkedPrefabPacket packet) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (packet.HasTarget) { RepoSteamNetworkManager.Instance.InstantiateNetworkPrefab(packet.NetworkId, packet.Prefab, packet.TargetTransform, packet.Position, packet.Rotation); } else { RepoSteamNetworkManager.Instance.InstantiateNetworkPrefab(packet.NetworkId, packet.Prefab, packet.Position, packet.Rotation); } } } internal class RepoNetworkConnectionManager : ConnectionManager { private Lobby _currentLobby; internal bool Verified; public RepoNetworkConnectionManager() { Logging.Info("Creating new ConnectionManager"); } public override void OnConnectionChanged(ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ConnectionManager)this).OnConnectionChanged(info); } public override void OnConnecting(ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ConnectionManager)this).OnConnecting(info); } public override void OnConnected(ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ConnectionManager)this).OnConnected(info); Logging.Info("Connected to server!"); } public override void OnDisconnected(ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ConnectionManager)this).OnDisconnected(info); Logging.Info("Disconnected from server!"); } public override void OnMessage(IntPtr data, int size, long messageNum, long recvTime, int channel) { ((ConnectionManager)this).OnMessage(data, size, messageNum, recvTime, channel); byte[] array = new byte[size]; Marshal.Copy(data, array, 0, size); if (!Verified) { SocketMessage socketMessage = new SocketMessage(array); NetworkPacket networkPacket = NetworkPacketRegistry.CreatePacket(socketMessage.ReadPacketHeader().PacketId); if (networkPacket is HandshakeStatusPacket) { RepoSteamNetwork.OnClientMessageReceived(array); return; } if (!(networkPacket is HandshakeStartAuthPacket handshakeStartAuthPacket)) { Logging.Warn(string.Format("Expected {0} from Server but got {1} instead!", "HandshakeStartAuthPacket", networkPacket.GetType())); return; } handshakeStartAuthPacket.Deserialize(socketMessage); Logging.Info("Sending handshake to server to verify connection!"); ClientAuthHandshakeOneShot.Run(handshakeStartAuthPacket.ClientKey); } else { RepoSteamNetwork.OnClientMessageReceived(array); } } public void SetLobby(Lobby lobby) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _currentLobby = lobby; } } internal class RepoNetworkSocketManager : SocketManager { private readonly List<SteamUserConnection> _steamUserConnections = new List<SteamUserConnection>(); private readonly Dictionary<uint, int> _connectionIdSteamUserConnectionLut = new Dictionary<uint, int>(); private readonly Dictionary<ulong, int> _steamIdSteamUserConnectionLut = new Dictionary<ulong, int>(); public IReadOnlyCollection<SteamUserConnection> UserConnections => _steamUserConnections; public RepoNetworkSocketManager() { Logging.Info("Creating new SocketManager"); } public override void OnConnecting(Connection connection, ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) ((SocketManager)this).OnConnecting(connection, info); ((Connection)(ref connection)).Accept(); } public override void OnConnected(Connection connection, ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) ((SocketManager)this).OnConnected(connection, info); AddNewSteamUserConnection(connection, info); } private void AddNewSteamUserConnection(Connection connection, ConnectionInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) SteamUserConnection steamUserConnection = new SteamUserConnection(connection, info); ulong value = ((NetIdentity)(ref info.identity)).SteamId.Value; int count = _steamUserConnections.Count; _connectionIdSteamUserConnectionLut[((Connection)(ref connection)).Id] = count; _steamIdSteamUserConnectionLut[value] = count; _steamUserConnections.Add(steamUserConnection); steamUserConnection.StartVerification(); } public bool TryGetSteamUserConnection(uint connectionId, out SteamUserConnection userConnection) { userConnection = null; if (!_connectionIdSteamUserConnectionLut.TryGetValue(connectionId, out var value)) { return false; } userConnection = _steamUserConnections[value]; return (object)userConnection != null; } public bool TryGetSteamUserConnection(SteamId steamId, out SteamUserConnection userConnection) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) userConnection = null; if (!_steamIdSteamUserConnectionLut.TryGetValue(steamId.Value, out var value)) { return false; } userConnection = _steamUserConnections[value]; return (object)userConnection != null; } private void RemoveSteamUserConnection(SteamUserConnection userConnection) { _connectionIdSteamUserConnectionLut.Remove(userConnection.ConnectionId); _steamUserConnections.Remove(userConnection); } public override void OnDisconnected(Connection connection, ConnectionInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((SocketManager)this).OnDisconnected(connection, info); if (!TryGetSteamUserConnection(((Connection)(ref connection)).Id, out SteamUserConnection userConnection)) { Logging.Info($"Connection {((Connection)(ref connection)).Id} has disconnected!"); return; } SteamUserConnection.ConnectionStatus status = userConnection.Status; if (status != SteamUserConnection.ConnectionStatus.Verified && status == SteamUserConnection.ConnectionStatus.VerifiedAndValid) { Logging.Info($"Connection {((Connection)(ref connection)).Id} has disconnected!"); } else { Logging.Info("Client " + userConnection.UserName + " has disconnected!"); } RemoveSteamUserConnection(userConnection); } public override void OnMessage(Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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) ((SocketManager)this).OnMessage(connection, identity, data, size, messageNum, recvTime, channel); byte[] array = new byte[size]; Marshal.Copy(data, array, 0, size); if (!TryGetSteamUserConnection(((Connection)(ref connection)).Id, out SteamUserConnection userConnection)) { Logging.Warn("Received message from unknown connection"); return; } if (userConnection.Status == SteamUserConnection.ConnectionStatus.Unverified) { SocketMessage socketMessage = new SocketMessage(array); PacketHeader packetHeader = socketMessage.ReadPacketHeader(); NetworkPacket networkPacket = NetworkPacketRegistry.CreatePacket(packetHeader.PacketId); if (!(networkPacket is HandshakeAuthConnectionPacket handshakeAuthConnectionPacket) || packetHeader.Destination != 0) { Logging.Warn($"Received {networkPacket.GetType()} packet from an unverified connection {((Connection)(ref connection)).Id}! dropping packet..."); return; } handshakeAuthConnectionPacket.Deserialize(socketMessage); if (userConnection.VerifyAuth(handshakeAuthConnectionPacket)) { userConnection.SetVerified(); SendHandshakeStatus(((NetIdentity)(ref identity)).SteamId, success: true); userConnection.StartModListValidation(); } else { Logging.Warn("Handshake failed!"); SendHandshakeStatus(((NetIdentity)(ref identity)).SteamId, success: false); } return; } if (userConnection.Status != SteamUserConnection.ConnectionStatus.VerifiedAndValid) { NetworkPacket networkPacket2 = NetworkPacketRegistry.CreatePacket(new SocketMessage(array).ReadPacketHeader().PacketId); if (!(networkPacket2 is ClientModVersionRegistryPacket)) { Logging.Warn($"Received {networkPacket2.GetType()} packet from Client {userConnection.UserName}! Expected mod list compatibility packet! dropping packet..."); return; } } RepoSteamNetwork.OnHostReceivedMessage(array, connection, identity); } private void SendHandshakeStatus(SteamId target, bool success) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) HandshakeStatusPacket handshakeStatusPacket = new HandshakeStatusPacket(); handshakeStatusPacket.Success = success; handshakeStatusPacket.SetTarget(target); RepoSteamNetwork.SendPacket(handshakeStatusPacket, NetworkDestination.PacketTarget); } public void Reset() { _connectionIdSteamUserConnectionLut.Clear(); _steamIdSteamUserConnectionLut.Clear(); foreach (SteamUserConnection steamUserConnection in _steamUserConnections) { steamUserConnection.Close(); } _steamUserConnections.Clear(); } } public class SteamUserConnection : IEquatable<SteamUserConnection> { public enum ConnectionStatus { Unverified, Verified, VerifiedAndValid, Closed } private string _clientKey = ""; private Connection _connection; private ConnectionInfo _info; private readonly System.Timers.Timer _timer; [CompilerGenerated] private string <UserName>k__BackingField = ""; public uint ConnectionId => ((Connection)(ref _connection)).Id; public SteamId SteamId { get; private set; } public ConnectionStatus Status { get; private set; } public ConnectionState State => ((ConnectionInfo)(ref _info)).State; public bool IsLobbyHost { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Lobby currentLobby = RepoSteamNetwork.GetCurrentLobby(); return ((Lobby)(ref currentLobby)).IsOwnedBy(SteamId); } } public string UserName { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(<UserName>k__BackingField)) { <UserName>k__BackingField = SteamId.GetLobbyName(); } return <UserName>k__BackingField; } } internal SteamUserConnection(Connection connection, ConnectionInfo info) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0064: Unknown result type (might be due to invalid IL or missing references) _connection = connection; _info = info; _timer = new System.Timers.Timer(10000.0); _timer.AutoReset = false; Status = ConnectionStatus.Unverified; NetIdentity identity = info.identity; if (((NetIdentity)(ref identity)).IsSteamId) { SteamId = ((NetIdentity)(ref identity)).SteamId; } else { Logging.Error("NetIdentity was not a SteamID"); } } internal void StartVerification() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) _clientKey = RepoNetworkingServer.Instance.CreateAuthKey(); SocketMessage socketMessage = new HandshakeStartAuthPacket { ClientKey = _clientKey, Header = { Sender = RepoSteamNetwork.CurrentSteamId } }.Serialize(NetworkDestination.Everyone); ((Connection)(ref _connection)).SendMessage(socketMessage.GetBytes(), (SendType)8, (ushort)0); _timer.Elapsed += OnHandshakeTimeout; _timer.Start(); Logging.Info($"Waiting for Connection {ConnectionId} to verify..."); } internal void StartModListValidation() { _timer.Elapsed += OnValidationTimeout; _timer.Start(); Logging.Info("Waiting for Client " + UserName + " to validate mod list compatibility..."); } internal bool VerifyAuth(HandshakeAuthConnectionPacket packet) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0045: 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_005f: Unknown result type (might be due to invalid IL or missing references) Lobby currentLobby = RepoNetworkingServer.Instance.CurrentLobby; string memberData = ((Lobby)(ref currentLobby)).GetMemberData(((Lobby)(ref currentLobby)).Owner, _clientKey); if (string.IsNullOrWhiteSpace(memberData) || memberData != packet.AuthKey) { return false; } if (SteamId.op_Implicit(((Lobby)(ref currentLobby)).Id) != SteamId.op_Implicit(packet.LobbyId)) { return false; } if (SteamId.op_Implicit(SteamId) == SteamId.op_Implicit(packet.PlayerId)) { return true; } return false; } internal void SetVerified() { Status = ConnectionStatus.Verified; Logging.Info($"Connection {ConnectionId} is now verified as Client {UserName}!"); RepoNetworkingServer.Instance.RemoveAuthKey(_clientKey); _timer.Elapsed -= OnHandshakeTimeout; _timer.Stop(); } internal void SetValidated() { if (Status == ConnectionStatus.Verified) { _timer.Elapsed -= OnValidationTimeout; _timer.Stop(); _timer.Dispose(); Status = ConnectionStatus.VerifiedAndValid; } } private void OnHandshakeTimeout(object sender, ElapsedEventArgs e) { _timer.Elapsed -= OnHandshakeTimeout; _timer.Stop(); Logging.Warn($"Connection {ConnectionId} failed to verify in time, dropping connection..."); RepoNetworkingServer.Instance.RemoveAuthKey(_clientKey); DropConnection(); } private void OnValidationTimeout(object sender, ElapsedEventArgs e) { _timer.Elapsed -= OnValidationTimeout; _timer.Stop(); Logging.Warn("Client " + UserName + " failed to validate mod list compatibility in time, dropping connection..."); DropConnection(); } private void DropConnection() { _timer.Dispose(); Close(); } public void Close() { if (_timer.Enabled) { _timer.Stop(); _timer.Dispose(); } try { ((Connection)(ref _connection)).Close(false, 0, "Closing Connection"); } catch { } Status = ConnectionStatus.Closed; } public Result SendMessage(byte[] data, SendType sendType = 8) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return ((Connection)(ref _connection)).SendMessage(data, sendType, (ushort)0); } public void SendPacket<TPacket>(TPacket packet) where TPacket : NetworkPacket { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) packet.Header.Target = SteamId; RepoSteamNetwork.SendPacket(packet, NetworkDestination.PacketTarget); } public bool Equals(SteamUserConnection? other) { if ((object)other == null) { return false; } if ((object)this == other) { return true; } return ConnectionId.Equals(other.ConnectionId); } public override bool Equals(object? obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (obj.GetType() != GetType()) { return false; } return Equals((SteamUserConnection)obj); } public override int GetHashCode() { return ConnectionId.GetHashCode(); } public static bool operator ==(SteamUserConnection? left, SteamUserConnection? right) { return object.Equals(left, right); } public static bool operator !=(SteamUserConnection? left, SteamUserConnection? right) { return !object.Equals(left, right); } } } namespace RepoSteamNetworking.Networking.Unity { internal class ClientAuthHandshakeOneShot : MonoBehaviour { [CompilerGenerated] private sealed class <SendAuthHandshake>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ClientAuthHandshakeOneShot <>4__this; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SendAuthHandshake>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown int num = <>1__state; ClientAuthHandshakeOneShot clientAuthHandshakeOneShot = <>4__this; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; if (string.IsNullOrEmpty(clientAuthHandshakeOneShot._clientKey)) { Logging.Error("ClientAuthHandshakeOneShot: No client key provided!"); return false; } } Lobby currentLobby = RepoNetworkingClient.Instance.CurrentLobby; if (string.IsNullOrWhiteSpace(((Lobby)(ref currentLobby)).GetMemberData(((Lobby)(ref currentLobby)).Owner, clientAuthHandshakeOneShot._clientKey))) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } HandshakeAuthConnectionPacket handshakeAuthConnectionPacket = new HandshakeAuthConnectionPacket(); handshakeAuthConnectionPacket.SetData(RepoNetworkingClient.Instance.CurrentLobby, clientAuthHandshakeOneShot._clientKey); RepoSteamNetwork.SendPacket(handshakeAuthConnectionPacket, NetworkDestination.HostOnly); Object.Destroy((Object)(object)((Component)clientAuthHandshakeOneShot).gameObject, 1f); 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(); } } private string? _clientKey; private IEnumerator? _coroutine; private void Start() { _coroutine = SendAuthHandshake(); if (_coroutine != null) { ((MonoBehaviour)this).StartCoroutine(_coroutine); } } [IteratorStateMachine(typeof(<SendAuthHandshake>d__3))] private IEnumerator? SendAuthHandshake() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SendAuthHandshake>d__3(0) { <>4__this = this }; } public static void Run(string clientKey) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown GameObject obj = Object.Instantiate<GameObject>(new GameObject("ClientAuthHandshakeOneShot"), ((Component)RepoNetworkingClient.Instance).transform); obj.SetActive(false); obj.AddComponent<ClientAuthHandshakeOneShot>()._clientKey = clientKey; obj.SetActive(true); } } [RequireComponent(typeof(Rigidbody), typeof(NetworkTransform))] [DisallowMultipleComponent] public class NetworkRigidbody : MonoBehaviour { private Rigidbody _rigidbody; private void Awake() { _rigidbody = ((Component)this).GetComponent<Rigidbody>(); if (!Object.op_Implicit((Object)(object)_rigidbody)) { Logging.Warn("No Rigidbody attached!"); } else { SetupRigidbody(); } } private void SetupRigidbody() { if (!RepoSteamNetwork.HasHostAuthority) { _rigidbody.isKinematic = true; } } } [RequireComponent(typeof(Transform))] [DisallowMultipleComponent] [GenerateBehaviourId] public class NetworkTransform : MonoBehaviour, INetworkedPropertyListener, ISteamNetworkSubIdentity { public bool syncPositionX = true; public bool syncPositionY = true; public bool syncPositionZ = true; public bool syncRotationX = true; public bool syncRotationY = true; public bool syncRotationZ = true; public bool syncScaleX = true; public bool syncScaleY = true; public bool syncScaleZ = true; public float positionThreshold = 0.001f; public float rotationThreshold = 0.01f; public float scaleThreshold = 0.01f; public bool doInterpolation; public int ticksPerSecond = 30; private double _timer; private Vector3 _lastValidPosition; private Vector3 _lastValidRotation; private Vector3 _lastValidScale; private readonly TweenRunner<Vector3Tween> _positionTweenRunner = new TweenRunner<Vector3Tween>(); private readonly TweenRunner<Vector3Tween> _rotationTweenRunner = new TweenRunner<Vector3Tween>(); private readonly TweenRunner<Vector3Tween> _scaleTweenRunner = new TweenRunner<Vector3Tween>(); private NetworkTransformDelta _transformDeltaBackingField; private RepoSteamNetworkIdentity _networkIdentity; [NetworkedProperty(CallbackMethodName = "OnReceivedDelta")] public NetworkTransformDelta TransformDelta { get { return _transformDeltaBackingField; } set { if (RepoSteamNetwork.IsServer && !(_transformDeltaBackingField == value)) { _transformDeltaBackingField = value; SendNetworkedPropertyData(_transformDeltaBackingField, 0u, 0); } } } private Vector3 PositionMask => new Vector3((float)(syncPositionX ? 1 : 0), (float)(syncPositionY ? 1 : 0), (float)(syncPositionZ ? 1 : 0)); private Vector3 RotationMask => new Vector3((float)(syncRotationX ? 1 : 0), (float)(syncRotationY ? 1 : 0), (float)(syncRotationZ ? 1 : 0)); private Vector3 ScaleMask => new Vector3((float)(syncScaleX ? 1 : 0), (float)(syncScaleY ? 1 : 0), (float)(syncScaleZ ? 1 : 0)); private double TimePerTick => 1f / (float)ticksPerSecond; public string ModGuid => "com.rune580.reposteamnetworking"; public uint SubId { get; set; } public bool IsValid { get; set; } private void Awake() { //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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002e: Unknown result type (might be due to invalid IL or missing references) _lastValidPosition = ((Component)this).transform.position; _lastValidRotation = ((Component)this).transform.eulerAngles; _lastValidScale = ((Component)this).transform.localScale; _positionTweenRunner.Init((MonoBehaviour)(object)this); _rotationTweenRunner.Init((MonoBehaviour)(object)this); _scaleTweenRunner.Init((MonoBehaviour)(object)this); } private void Update() { if (RepoSteamNetwork.IsServer && !RepoSteamNetwork.IsSinglePlayer) { _timer += Time.deltaTime; if (_timer >= TimePerTick) { TrySyncProperties(); _timer -= TimePerTick; } } } private void TrySyncProperties() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000e: 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_00ab: 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_00b1: 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_00b9: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) Vector3 position = ((Component)this).transform.position; if (VectorsChanged(position, _lastValidPosition, PositionMask, positionThreshold)) { _lastValidPosition = position; if (syncPositionX) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.PositionX = position.x; TransformDelta = transformDelta; } if (syncPositionY) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.PositionY = position.y; TransformDelta = transformDelta; } if (syncPositionZ) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.PositionZ = position.z; TransformDelta = transformDelta; } } Vector3 eulerAngles = ((Component)this).transform.eulerAngles; if (VectorsChanged(eulerAngles, _lastValidRotation, RotationMask, rotationThreshold)) { _lastValidRotation = eulerAngles; if (syncRotationX) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.RotationX = eulerAngles.x; TransformDelta = transformDelta; } if (syncRotationY) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.RotationY = eulerAngles.y; TransformDelta = transformDelta; } if (syncRotationZ) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.RotationZ = eulerAngles.z; TransformDelta = transformDelta; } } Vector3 localScale = ((Component)this).transform.localScale; if (VectorsChanged(localScale, _lastValidScale, ScaleMask, scaleThreshold)) { _lastValidScale = localScale; if (syncScaleX) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.ScaleX = localScale.x; TransformDelta = transformDelta; } if (syncScaleY) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.ScaleY = localScale.y; TransformDelta = transformDelta; } if (syncScaleZ) { NetworkTransformDelta transformDelta = TransformDelta; transformDelta.ScaleZ = localScale.z; TransformDelta = transformDelta; } } } private void OnReceivedDelta(NetworkTransformDelta oldDelta, NetworkTransformDelta delta) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) if (!RepoSteamNetwork.IsServer && !RepoSteamNetwork.IsSinglePlayer) { Vector3 position = ((Component)this).transform.position; if (delta.PositionX.HasValue) { position.x = delta.PositionX.Value; } if (delta.PositionY.HasValue) { position.y = delta.PositionY.Value; } if (delta.PositionZ.HasValue) { position.z = delta.PositionZ.Value; } Vector3 eulerAngles = ((Component)this).transform.eulerAngles; if (delta.RotationX.HasValue) { eulerAngles.x = delta.RotationX.Value; } if (delta.RotationY.HasValue) { eulerAngles.y = delta.RotationY.Value; } if (delta.RotationZ.HasValue) { eulerAngles.z = delta.RotationZ.Value; } Vector3 localScale = ((Component)this).transform.localScale; if (delta.ScaleX.HasValue) { localScale.x = delta.ScaleX.Value; } if (delta.ScaleY.HasValue) { localScale.y = delta.ScaleY.Value; } if (delta.ScaleZ.HasValue) { localScale.z = delta.ScaleZ.Value; } if (doInterpolation) { TweenTransform(position, eulerAngles, localScale); } else { SetTransform(position, eulerAngles, localScale); } } } private void TweenTransform(Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_00f5: 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_00bc: 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_0133: Unknown result type (might be due to invalid IL or missing references) if (position != ((Component)this).transform.position) { Vector3Tween vector3Tween = default(Vector3Tween); vector3Tween.duration = (float)TimePerTick; vector3Tween.ignoreTimeScale = true; vector3Tween.StartValue = ((Component)this).transform.position; vector3Tween.TargetValue = position; Vector3Tween vector3Tween2 = vector3Tween; vector3Tween2.AddOnChangedCallback(TweenCallbackPosition); _positionTweenRunner.StopTween(); _positionTweenRunner.StartTween(vector3Tween2); } if (rotation != ((Component)this).transform.eulerAngles) { Vector3Tween vector3Tween = default(Vector3Tween); vector3Tween.duration = (float)TimePerTick; vector3Tween.ignoreTimeScale = true; vector3Tween.StartValue = ((Component)this).transform.eulerAngles; vector3Tween.TargetValue = rotation; Vector3Tween vector3Tween3 = vector3Tween; vector3Tween3.AddOnChangedCallback(TweenCallbackRotation); _rotationTweenRunner.StopTween(); _rotationTweenRunner.StartTween(vector3Tween3); } if (scale != ((Component)this).transform.localScale) { Vector3Tween vector3Tween = default(Vector3Tween); vector3Tween.duration = (float)TimePerTick; vector3Tween.ignoreTimeScale = true; vector3Tween.StartValue = ((Component)this).transform.localScale; vector3Tween.TargetValue = scale; Vector3Tween vector3Tween4 = vector3Tween; vector3Tween4.AddOnChangedCallback(TweenCallbackScale); _scaleTweenRunner.StopTween(); _scaleTweenRunner.StartTween(vector3Tween4); } } private void SetTransform(Vector3 position, Vector3 rotation, Vector3 scale) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; ((Component)this).transform.eulerAngles = rotation; ((Component)this).transform.localScale = scale; } private void TweenCallbackPosition(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; } private void TweenCallbackRotation(Vector3 rotation) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.eulerAngles = rotation; } private void TweenCallbackScale(Vector3 scale) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localScale = scale; } private static Vector3 MaskVector(Vector3 vector, Vector3 mask) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector.x * mask.x, vector.y * mask.y, vector.z * mask.z); } private static bool VectorsChanged(Vector3 left, Vector3 right, Vector3 mask, float threshold) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(MaskVector(left, mask), MaskVector(right, mask)) > threshold; } private void SendNetworkedPropertyData(object value, uint propId, byte changeKind) { RepoSteamNetworkIdentity networkIdentity = GetNetworkIdentity(); NetworkedPropertyManager.AddNetworkedPropertyDataToQueue(value, networkIdentity.NetworkId, ModGuid, SubId, "RepoSteamNetworking.Networking.Unity.NetworkTransform", propId, changeKind); } public virtual void OnNetworkedPropertiesDataReceived(string targetClass, NetworkedPropertyChange[] props) { if (!(targetClass != "RepoSteamNetworking.Networking.Unity.NetworkTransform")) { for (int i = 0; i < props.Length; i++) { NetworkedPropertyChange networkedPropertyChange = props[i]; SetNetworkedPropertyValue(networkedPropertyChange.PropertyId, networkedPropertyChange.Value); } } } private void SetNetworkedPropertyValue(uint propId, object value) { if (propId == 0) { NetworkTransformDelta oldDelta = (NetworkTransformDelta)value; _transformDeltaBackingField = (NetworkTransformDelta)value; OnReceivedDelta(oldDelta, (NetworkTransformDelta)value); } } public RepoSteamNetworkIdentity GetNetworkIdentity() { if (!Object.op_Implicit((Object)(object)_networkIdentity)) { _networkIdentity = ((Component)this).GetComponentInParent<RepoSteamNetworkIdentity>(true); } return _networkIdentity; } } public class RepoNetworkingClient : MonoBehaviour { private static RepoNetworkingClient? _instance; private bool _clientActive; private RepoNetworkConnectionManager? _connectionManager; public static RepoNetworkingClient Instance => _instance; internal Lobby CurrentLobby { get; private set; } internal bool ClientActive { get { if (_instance != null) { return _clientActive; } return false; } } internal static void CreateSingleton(GameObject parent) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (_instance != null) { Logging.Warn("RepoNetworkingClient already initialized!"); return; } VersionCompatRegistry.InitRegistry(); ModNetworkGuidRegistry.Init(); BehaviourIdRegistry.Init(); Object.Instantiate<GameObject>(new GameObject("RepoNetworkingClient"), parent.transform).AddComponent<RepoNetworkingClient>(); Logging.Info("Created RepoNetworkingClient"); } private void Awake() { _instance = this; Object.DontDestroyOnLoad((Object)(object)this); } private void Update() { if (_clientActive && _connectionManager != null) { ((ConnectionManager)_connectionManager).Receive(32, true); } } public void ConnectToServer(Lobby lobby) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) CurrentLobby = lobby; _connectionManager = SteamNetworkingSockets.ConnectRelay<RepoNetworkConnectionManager>(((Lobby)(ref lobby)).Owner.Id, 0); _clientActive = true; _connectionManager.SetLobby(lobby); } public void DisconnectFromServer() { RepoNetworkConnectionManager? connectionManager = _connectionManager; if (connectionManager != null) { ((ConnectionManager)connectionManager).Close(false, 0, "Closing Connection"); } _clientActive = false; } public void SendSocketMessageToServer(SocketMessage message) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (_connectionManager == null) { Logging.Info("No connection to server, can't send message!"); } else { ((Connection)(ref ((ConnectionManager)_connectionManager).Connection)).SendMessage(message.GetBytes(), (SendType)8, (ushort)0); } } internal void SetConnectionVerified(bool verified) { if (_connectionManager != null) { _connectionManager.Verified = verified; } } } public class RepoNetworkingServer : MonoBehaviour { private static RepoNetworkingServer? _instance; private bool _serverActive; public static RepoNetworkingServer Instance => _instance; internal Lobby CurrentLobby { get; private set; } internal RepoNetworkSocketManager? SocketManager { get; private set; } internal bool ServerActive { get { if (_instance != null) { return _serverActive; } return false; } } internal static void CreateSingleton(GameObject parent) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (_instance != null) { Logging.Warn("RepoNetworkingServer already initialized!"); return; } VersionCompatRegistry.InitRegistry(); ModNetworkGuidRegistry.Init(); BehaviourIdRegistry.Init(); Object.Instantiate<GameObject>(new GameObject("RepoNetworkingServer"), parent.transform).AddComponent<RepoNetworkingServer>(); Logging.Info("Created RepoNetworkingServer"); } private void Awake() { _instance = this; ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)this); } private void Update() { if (_serverActive && SocketManager != null) { ((SocketManager)SocketManager).Receive(32, true); } } public void StartSocketServer(Lobby lobby) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CurrentLobby = lobby; SocketManager = SteamNetworkingSockets.CreateRelaySocket<RepoNetworkSocketManager>(0); _serverActive = true; RepoSteamNetworkManager.Instance.SetModGuidPalette(ModNetworkGuidRegistry.Palette); RepoSteamNetworkManager.Instance.SetBehaviourIdPalette(BehaviourIdRegistry.Palette); } public string CreateAuthKey() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) string text = Guid.NewGuid().ToString(); string text2 = "RSN_" + Guid.NewGuid(); Lobby currentLobby = CurrentLobby; ((Lobby)(ref currentLobby)).SetMemberData(text2, text); return text2; } public void RemoveAuthKey(string clientKey) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Lobby currentLobby = CurrentLobby; ((Lobby)(ref currentLobby)).SetMemberData(clientKey, string.Empty); } public void StopSocketServer() { RepoNetworkSocketManager? socketManager = SocketManager; if (socketManager != null) { ((SocketManager)socketManager).Close(); } SocketManager?.Reset(); _serverActive = false; } public void SendSocketMessageToClients(SocketMessage message, SteamId excludeSteamId = default(SteamId)) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_005a: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (SocketManager == null) { Logging.Info("No server to send messages, can't send message!"); return; } foreach (SteamUserConnection userConnection in SocketManager.UserConnections) { if ((int)userConnection.State == 3 && (!((SteamId)(ref excludeSteamId)).IsValid || SteamId.op_Implicit(userConnection.SteamId) != SteamId.op_Implicit(excludeSteamId))) { userConnection.SendMessage(message.GetBytes(), (SendType)8); } } } public void SendSocketMessageToTarget(SocketMessage message, SteamId target) { //IL_0019: 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: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) SteamUserConnection userConnection; if (SocketManager == null) { Logging.Info("No server to send messages, can't send message!"); } else if (!SocketManager.TryGetSteamUserConnection(target, out userConnection)) { Logging.Info($"No valid connection found for {target}!"); } else if ((int)userConnection.State != 3) { Logging.Info($"Can't send message to unconnected client {target}"); } else { userConnection.SendMessage(message.GetBytes(), (SendType)8); } } } public class RepoSteamNetworkManager : MonoBehaviour { private const float NetworkPropertySyncInterval = 1f / 30f; private static RepoSteamNetworkManager? _instance; private readonly Dictionary<uint, RepoSteamNetworkIdentity> _networkObjects = new Dictionary<uint, RepoSteamNetworkIdentity>(); private ModNetworkGuidPalette _guidPalette = new ModNetworkGuidPalette(); private BehaviourIdPalette _behaviourIdPa