Please disclose if your mod was created primarily 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 LC API V50 v3.4.14
LC_API_V50.dll
Decompiled 5 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LC_API.BundleAPI; using LC_API.ClientAPI; using LC_API.Comp; using LC_API.Data; using LC_API.Exceptions; using LC_API.Extensions; using LC_API.GameInterfaceAPI; using LC_API.GameInterfaceAPI.Events; using LC_API.GameInterfaceAPI.Events.Cache; using LC_API.GameInterfaceAPI.Events.EventArgs.Player; using LC_API.GameInterfaceAPI.Events.Handlers; using LC_API.GameInterfaceAPI.Features; using LC_API.ManualPatches; using LC_API.Networking; using LC_API.ServerAPI; using LC_API_V50.NetcodePatcher; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("2018")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Utilities for plugin devs")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0-alpha.0.116+3c4ba20bf35071adfcaf9f1fc1aabf1ecccbe094")] [assembly: AssemblyProduct("Lethal Company API")] [assembly: AssemblyTitle("LC_API_V50")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 LC_API { internal static class CheatDatabase { private const string SIG_REQ_GUID = "LC_API_ReqGUID"; private const string SIG_SEND_MODS = "LC_APISendMods"; private static Dictionary<string, PluginInfo> PluginsLoaded = new Dictionary<string, PluginInfo>(); public static void RunLocalCheatDetector() { PluginsLoaded = Chainloader.PluginInfos; using Dictionary<string, PluginInfo>.ValueCollection.Enumerator enumerator = PluginsLoaded.Values.GetEnumerator(); while (enumerator.MoveNext()) { switch (enumerator.Current.Metadata.GUID) { case "mikes.lethalcompany.mikestweaks": case "mom.llama.enhancer": case "Posiedon.GameMaster": case "LethalCompanyScalingMaster": case "verity.amberalert": ModdedServer.SetServerModdedOnly(); break; } } } public static void OtherPlayerCheatDetector() { Plugin.Log.LogWarning((object)"Asking all other players for their mod list."); LC_API.GameInterfaceAPI.Features.Player localPlayer = LC_API.GameInterfaceAPI.Features.Player.LocalPlayer; MenuManager menuManager = LC_APIManager.MenuManager; object obj; if (menuManager == null) { obj = null; } else { TextMeshProUGUI versionNumberText = menuManager.versionNumberText; obj = ((versionNumberText != null) ? ((TMP_Text)versionNumberText).GetParsedText() : null); } if (obj == null) { obj = "unknown"; } localPlayer.QueueTip("Mod List:", "Asking all other players for installed mods, the game version is " + (string?)obj + "."); LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.QueueTip("Mod List:", "Check the logs for more detailed results.\n<size=13>(Note that if someone doesnt show up on the list, they may not have LC_API installed)</size>"); Network.Broadcast("LC_API_ReqGUID"); } [NetworkMessage("LC_APISendMods", false)] internal static void ReceivedModListHandler(ulong senderId, List<string> mods) { string text = (LC_API.GameInterfaceAPI.Features.Player.Get(senderId)?.Username ?? "unidentified player") + " responded with these mods:\n" + string.Join("\n", mods); LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.QueueTip("Mod List:", text); Plugin.Log.LogWarning((object)text); } [NetworkMessage("LC_API_ReqGUID", false)] internal static void ReceivedModListHandler(ulong senderId) { List<string> list = new List<string>(); foreach (PluginInfo value in PluginsLoaded.Values) { list.Add(value.Metadata.GUID); } Network.Broadcast("LC_APISendMods", list); } } [BepInPlugin("LC_API_V50", "Lethal Company API", "3.4.14")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<bool> configOverrideModServer; private ConfigEntry<bool> configLegacyAssetLoading; private ConfigEntry<bool> configDisableBundleLoader; internal static ConfigEntry<bool> configVanillaSupport; internal static Harmony Harmony; internal static Plugin Instance { get; private set; } public static bool Initialized { get; private set; } private void Awake() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown Instance = this; configOverrideModServer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Force modded server browser", false, "Should the API force you into the modded server browser?"); configLegacyAssetLoading = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Legacy asset bundle loading", false, "Should the BundleLoader use legacy asset loading? Turning this on may help with loading assets from older plugins."); configDisableBundleLoader = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable BundleLoader", false, "Should the BundleLoader be turned off? Enable this if you are having problems with mods that load assets using a different method from LC_API's BundleLoader."); configVanillaSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("Compatibility", "Vanilla Compatibility", false, "Allows you to join vanilla servers, but disables many networking-related things and could cause mods to not work properly."); CommandHandler.commandPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Prefix", "/", "Command prefix"); Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogWarning((object)"\n.____ _________ _____ __________ .___ \r\n| | \\_ ___ \\ / _ \\ \\______ \\| | \r\n| | / \\ \\/ / /_\\ \\ | ___/| | \r\n| |___\\ \\____ / | \\| | | | \r\n|_______ \\\\______ /______\\____|__ /|____| |___| \r\n \\/ \\//_____/ \\/ \r\n "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Starting up."); if (configOverrideModServer.Value) { ModdedServer.SetServerModdedOnly(); } if (configVanillaSupport.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API is starting with VANILLA SUPPORT ENABLED."); } Harmony = new Harmony("ModAPI"); MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null); AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(ServerPatch), "CacheMenuManager", (Type[])null, (Type[])null); AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "SubmitChat_performed", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(CommandHandler.SubmitChatPatch), "Transpiler", (Type[])null, (Type[])null); MethodInfo methodInfo7 = AccessTools.Method(typeof(GameNetworkManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo8 = AccessTools.Method(typeof(ServerPatch), "GameNetworkManagerAwake", (Type[])null, (Type[])null); MethodInfo methodInfo9 = AccessTools.Method(typeof(NetworkManager), "StartClient", (Type[])null, (Type[])null); MethodInfo methodInfo10 = AccessTools.Method(typeof(NetworkManager), "StartHost", (Type[])null, (Type[])null); MethodInfo methodInfo11 = AccessTools.Method(typeof(NetworkManager), "Shutdown", (Type[])null, (Type[])null); MethodInfo methodInfo12 = AccessTools.Method(typeof(RegisterPatch), "Postfix", (Type[])null, (Type[])null); MethodInfo methodInfo13 = AccessTools.Method(typeof(UnregisterPatch), "Postfix", (Type[])null, (Type[])null); Harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo7, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo9, (HarmonyMethod)null, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo10, (HarmonyMethod)null, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.Patch((MethodBase)methodInfo11, (HarmonyMethod)null, new HarmonyMethod(methodInfo13), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Network.Init(); Events.Patch(Harmony); } internal void Start() { Initialize(); } internal void OnDestroy() { Initialize(); } internal void Initialize() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!Initialized) { Initialized = true; if (!configDisableBundleLoader.Value) { BundleLoader.Load(configLegacyAssetLoading.Value); } GameObject val = new GameObject("API"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<LC_APIManager>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Started!"); CheatDatabase.RunLocalCheatDetector(); } } internal static void PatchMethodManual(MethodInfo method, MethodInfo patch, Harmony harmony) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony.Patch((MethodBase)method, new HarmonyMethod(patch), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static class Utils { public static string ReplaceWithCase(this string input, string toReplace, string replacement) { Dictionary<string, string> map = new Dictionary<string, string> { { toReplace, replacement } }; return input.ReplaceWithCase(map); } public static string ReplaceWithCase(this string input, Dictionary<string, string> map) { string text = input; foreach (KeyValuePair<string, string> item in map) { string key = item.Key; string value = item.Value; text = Regex.Replace(text, key, delegate(Match match) { string value2 = match.Value; char[] array = value2.ToCharArray(); string[] source = value2.Split(new char[1] { ' ' }); bool flag = char.IsUpper(array[0]); bool flag2 = source.All((string w) => char.IsUpper(w[0]) || !char.IsLetter(w[0])); if (array.All((char c) => char.IsUpper(c) || !char.IsLetter(c))) { return value.ToUpper(); } if (flag2) { return Regex.Replace(value, "\\b\\w", (Match charMatch) => charMatch.Value.ToUpper()); } char[] array2 = value.ToCharArray(); array2[0] = (flag ? char.ToUpper(array2[0]) : char.ToLower(array2[0])); return new string(array2); }, RegexOptions.IgnoreCase); } return text; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LC_API_V50"; public const string PLUGIN_NAME = "Lethal Company API"; public const string PLUGIN_VERSION = "3.4.14"; } } namespace LC_API.ServerAPI { public static class ModdedServer { private static bool moddedOnly; [Obsolete("Use SetServerModdedOnly() instead. This will be removed/private in a future update.")] public static bool setModdedOnly; public static int GameVersion { get; internal set; } public static bool ModdedOnly => moddedOnly; public static void SetServerModdedOnly() { moddedOnly = true; Plugin.Log.LogMessage((object)"A plugin has set your game to only allow you to play with other people who have mods!"); } public static void OnSceneLoaded() { if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && ModdedOnly) { GameNetworkManager instance = GameNetworkManager.Instance; instance.gameVersionNum += 16440; setModdedOnly = true; } } } [Obsolete("ServerAPI.Networking is obsolete and will be removed in future versions. Use LC_API.Networking.Network.")] public static class Networking { private sealed class Data<T> { public readonly string Signature; public readonly T Value; public Data(string signature, T value) { Signature = signature; Value = value; } } private const string StringMessageRegistrationName = "LCAPI_NET_LEGACY_STRING"; private const string ListStringMessageRegistrationName = "LCAPI_NET_LEGACY_LISTSTRING"; private const string IntMessageRegistrationName = "LCAPI_NET_LEGACY_INT"; private const string FloatMessageRegistrationName = "LCAPI_NET_LEGACY_FLOAT"; private const string Vector3MessageRegistrationName = "LCAPI_NET_LEGACY_VECTOR3"; private const string SyncVarMessageRegistrationName = "LCAPI_NET_LEGACY_SYNCVAR_SET"; public static Action<string, string> GetString = delegate { }; public static Action<List<string>, string> GetListString = delegate { }; public static Action<int, string> GetInt = delegate { }; public static Action<float, string> GetFloat = delegate { }; public static Action<Vector3, string> GetVector3 = delegate { }; private static Dictionary<string, string> syncStringVars = new Dictionary<string, string>(); public static void Broadcast(string data, string signature) { if (data.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); } else { Network.Broadcast("LCAPI_NET_LEGACY_STRING", new Data<string>(signature, data)); } } public static void Broadcast(List<string> data, string signature) { string text = ""; foreach (string datum in data) { if (datum.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } if (datum.Contains("\n")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( NewLine )"); return; } text = text + datum + "\n"; } Network.Broadcast("LCAPI_NET_LEGACY_LISTSTRING", new Data<string>(signature, text)); } public static void Broadcast(int data, string signature) { Network.Broadcast("LCAPI_NET_LEGACY_INT", new Data<int>(signature, data)); } public static void Broadcast(float data, string signature) { Network.Broadcast("LCAPI_NET_LEGACY_FLOAT", new Data<float>(signature, data)); } public static void Broadcast(Vector3 data, string signature) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Network.Broadcast("LCAPI_NET_LEGACY_VECTOR3", new Data<Vector3>(signature, data)); } public static void RegisterSyncVariable(string name) { if (!syncStringVars.ContainsKey(name)) { syncStringVars.Add(name, ""); } else { Plugin.Log.LogError((object)("Cannot register Sync Variable! A Sync Variable has already been registered with name " + name)); } } public static void SetSyncVariable(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; Broadcast(new List<string> { name, value }, "LCAPI_NET_LEGACY_SYNCVAR_SET"); } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } private static void SetSyncVariableB(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } internal static void LCAPI_NET_SYNCVAR_SET(List<string> list, string arg2) { if (arg2 == "LCAPI_NET_LEGACY_SYNCVAR_SET") { SetSyncVariableB(list[0], list[1]); } } public static string GetSyncVariable(string name) { if (syncStringVars.ContainsKey(name)) { return syncStringVars[name]; } Plugin.Log.LogError((object)("Cannot get the value of Sync Variable " + name + " as it is not registered!")); return ""; } internal static void InitializeLegacyNetworking() { GetListString = (Action<List<string>, string>)Delegate.Combine(GetListString, new Action<List<string>, string>(LCAPI_NET_SYNCVAR_SET)); Network.RegisterMessage("LCAPI_NET_LEGACY_STRING", relayToSelf: false, delegate(ulong senderId, Data<string> data) { GetString(data.Value, data.Signature); }); Network.RegisterMessage("LCAPI_NET_LEGACY_LISTSTRING", relayToSelf: false, delegate(ulong senderId, Data<string> data) { GetListString(data.Value.Split(new char[1] { '\n' }).ToList(), data.Signature); }); Network.RegisterMessage("LCAPI_NET_LEGACY_INT", relayToSelf: false, delegate(ulong senderId, Data<int> data) { GetInt(data.Value, data.Signature); }); Network.RegisterMessage("LCAPI_NET_LEGACY_FLOAT", relayToSelf: false, delegate(ulong senderId, Data<float> data) { GetFloat(data.Value, data.Signature); }); Network.RegisterMessage("LCAPI_NET_LEGACY_VECTOR3", relayToSelf: false, delegate(ulong senderId, Data<Vector3> data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) GetVector3(data.Value, data.Signature); }); } } } namespace LC_API.Networking { public static class Network { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__35_2; public static Events.CustomEventHandler <>9__35_0; public static Events.CustomEventHandler <>9__35_1; internal void <Init>b__35_0() { //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_004c: Expected O, but got Unknown StartedNetworking = true; if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>9__35_2; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderClientId, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) byte[] bytes = default(byte[]); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref bytes, default(ForPrimitives)); NetworkMessageWrapper networkMessageWrapper = bytes.ToObject<NetworkMessageWrapper>(); networkMessageWrapper.Sender = senderClientId; byte[] array = networkMessageWrapper.ToBytes(); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(FastBufferWriter.GetWriteSize<byte>(array, -1, 0), (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(array, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(networkMessageWrapper.UniqueName, val2, (NetworkDelivery)4); } finally { ((IDisposable)(FastBufferWriter)(ref val2)).Dispose(); } }; <>9__35_2 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("LC_API_RELAY_MESSAGE", (HandleNamedMessageDelegate)obj); } RegisterAllMessages(); } internal void <Init>b__35_2(ulong senderClientId, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) byte[] bytes = default(byte[]); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref bytes, default(ForPrimitives)); NetworkMessageWrapper networkMessageWrapper = bytes.ToObject<NetworkMessageWrapper>(); networkMessageWrapper.Sender = senderClientId; byte[] array = networkMessageWrapper.ToBytes(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize<byte>(array, -1, 0), (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(array, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(networkMessageWrapper.UniqueName, val, (NetworkDelivery)4); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } internal void <Init>b__35_1() { StartedNetworking = false; if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("LC_API_RELAY_MESSAGE"); } UnregisterAllMessages(); } } internal const string MESSAGE_RELAY_UNIQUE_NAME = "LC_API_RELAY_MESSAGE"; private static MethodInfo _registerInfo = null; private static MethodInfo _registerInfoGeneric = null; internal static Dictionary<string, NetworkMessageFinalizerBase> NetworkMessageFinalizers { get; } = new Dictionary<string, NetworkMessageFinalizerBase>(); internal static bool StartedNetworking { get; set; } = false; internal static MethodInfo RegisterInfo { get { if (_registerInfo == null) { MethodInfo[] methods = typeof(Network).GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == "RegisterMessage" && !methodInfo.IsGenericMethod) { _registerInfo = methodInfo; break; } } } return _registerInfo; } } internal static MethodInfo RegisterInfoGeneric { get { if (_registerInfoGeneric == null) { MethodInfo[] methods = typeof(Network).GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == "RegisterMessage" && methodInfo.IsGenericMethod) { _registerInfoGeneric = methodInfo; break; } } } return _registerInfoGeneric; } } public static event Events.CustomEventHandler RegisterNetworkMessages; internal static event Events.CustomEventHandler UnregisterNetworkMessages; internal static byte[] ToBytes(this object @object) { if (@object == null) { return null; } return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(@object)); } internal static T ToObject<T>(this byte[] bytes) where T : class { return JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(bytes)); } internal static void OnRegisterNetworkMessages() { Network.RegisterNetworkMessages.InvokeSafely(); } internal static void OnUnregisterNetworkMessages() { Network.UnregisterNetworkMessages.InvokeSafely(); } internal static void RegisterAllMessages() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown foreach (NetworkMessageFinalizerBase value in NetworkMessageFinalizers.Values) { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(value.UniqueName, new HandleNamedMessageDelegate(value.Read)); } } internal static void UnregisterAllMessages() { foreach (string key in NetworkMessageFinalizers.Keys) { UnregisterMessage(key, andRemoveHandler: false); } } public static void RegisterAll() { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(new StackTrace().GetFrame(1).GetMethod().ReflectedType.Assembly); for (int i = 0; i < typesFromAssembly.Length; i++) { RegisterAll(typesFromAssembly[i]); } } public static void RegisterAll(Type type) { if (!type.IsClass) { return; } NetworkMessage customAttribute = type.GetCustomAttribute<NetworkMessage>(); if (customAttribute != null) { if (type.BaseType.Name == "NetworkMessageHandler`1") { Type type2 = type.BaseType.GetGenericArguments()[0]; RegisterInfoGeneric.MakeGenericMethod(type2).Invoke(null, new object[3] { customAttribute.UniqueName, customAttribute.RelayToSelf, type.GetMethod("Handler").CreateDelegate(typeof(Action<, >).MakeGenericType(typeof(ulong), type2), Activator.CreateInstance(type)) }); } else if (type.BaseType.Name == "NetworkMessageHandler") { RegisterInfo.Invoke(null, new object[3] { customAttribute.UniqueName, customAttribute.RelayToSelf, type.GetMethod("Handler").CreateDelegate(typeof(Action<>).MakeGenericType(typeof(ulong)), Activator.CreateInstance(type)) }); } return; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { customAttribute = methodInfo.GetCustomAttribute<NetworkMessage>(); if (customAttribute != null) { if (!methodInfo.IsStatic) { throw new Exception("Detected NetworkMessage attribute on non-static method. All NetworkMessages on methods must be static."); } if (methodInfo.GetParameters().Length == 1) { RegisterInfo.Invoke(null, new object[3] { customAttribute.UniqueName, customAttribute.RelayToSelf, methodInfo.CreateDelegate(typeof(Action<>).MakeGenericType(typeof(ulong))) }); } else { Type parameterType = methodInfo.GetParameters()[1].ParameterType; RegisterInfoGeneric.MakeGenericMethod(parameterType).Invoke(null, new object[3] { customAttribute.UniqueName, customAttribute.RelayToSelf, methodInfo.CreateDelegate(typeof(Action<, >).MakeGenericType(typeof(ulong), parameterType)) }); } } } } public static void UnregisterAll(bool andRemoveHandler = true) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(new StackTrace().GetFrame(1).GetMethod().ReflectedType.Assembly); for (int i = 0; i < typesFromAssembly.Length; i++) { UnregisterAll(typesFromAssembly[i], andRemoveHandler); } } public static void UnregisterAll(Type type, bool andRemoveHandler = true) { if (!type.IsClass) { return; } NetworkMessage customAttribute = type.GetCustomAttribute<NetworkMessage>(); if (customAttribute != null) { UnregisterMessage(customAttribute.UniqueName, andRemoveHandler); return; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); for (int i = 0; i < methods.Length; i++) { customAttribute = methods[i].GetCustomAttribute<NetworkMessage>(); if (customAttribute != null) { UnregisterMessage(customAttribute.UniqueName, andRemoveHandler); } } } public static void RegisterMessage<T>(string uniqueName, bool relayToSelf, Action<ulong, T> onReceived) where T : class { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (NetworkMessageFinalizers.ContainsKey(uniqueName)) { throw new Exception(uniqueName + " already registered"); } NetworkMessageFinalizer<T> networkMessageFinalizer = new NetworkMessageFinalizer<T>(uniqueName, relayToSelf, onReceived); NetworkMessageFinalizers.Add(uniqueName, networkMessageFinalizer); if (StartedNetworking) { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(uniqueName, new HandleNamedMessageDelegate(networkMessageFinalizer.Read)); } } public static void RegisterMessage(string uniqueName, bool relayToSelf, Action<ulong> onReceived) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (NetworkMessageFinalizers.ContainsKey(uniqueName)) { throw new Exception(uniqueName + " already registered"); } NetworkMessageFinalizer networkMessageFinalizer = new NetworkMessageFinalizer(uniqueName, relayToSelf, onReceived); NetworkMessageFinalizers.Add(uniqueName, networkMessageFinalizer); if (StartedNetworking) { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(uniqueName, new HandleNamedMessageDelegate(networkMessageFinalizer.Read)); } } public static void UnregisterMessage(string uniqueName, bool andRemoveHandler = true) { if ((!andRemoveHandler && NetworkMessageFinalizers.ContainsKey(uniqueName)) || (andRemoveHandler && NetworkMessageFinalizers.Remove(uniqueName))) { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(uniqueName); } } public static void Broadcast<T>(string uniqueName, T @object) where T : class { if (NetworkMessageFinalizers.TryGetValue(uniqueName, out var value)) { if (!(value is NetworkMessageFinalizer<T> networkMessageFinalizer)) { throw new Exception("Network handler for " + uniqueName + " was not broadcast with the right type!"); } networkMessageFinalizer.Send(@object); } } public static void Broadcast(string uniqueName) { if (NetworkMessageFinalizers.TryGetValue(uniqueName, out var value)) { if (!(value is NetworkMessageFinalizer networkMessageFinalizer)) { throw new Exception("Network handler for " + uniqueName + " was not broadcast with the right type!"); } networkMessageFinalizer.Send(); } } internal static void Init() { RegisterNetworkMessages += delegate { //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_004c: Expected O, but got Unknown StartedNetworking = true; if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__35_2; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderClientId, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) byte[] bytes = default(byte[]); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref bytes, default(ForPrimitives)); NetworkMessageWrapper networkMessageWrapper = bytes.ToObject<NetworkMessageWrapper>(); networkMessageWrapper.Sender = senderClientId; byte[] array = networkMessageWrapper.ToBytes(); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(FastBufferWriter.GetWriteSize<byte>(array, -1, 0), (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(array, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(networkMessageWrapper.UniqueName, val2, (NetworkDelivery)4); } finally { ((IDisposable)(FastBufferWriter)(ref val2)).Dispose(); } }; <>c.<>9__35_2 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("LC_API_RELAY_MESSAGE", (HandleNamedMessageDelegate)obj); } RegisterAllMessages(); }; UnregisterNetworkMessages += delegate { StartedNetworking = false; if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("LC_API_RELAY_MESSAGE"); } UnregisterAllMessages(); }; SetupNetworking(); RegisterAll(); LC_API.ServerAPI.Networking.InitializeLegacyNetworking(); } internal static void SetupNetworking() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public class NetworkMessage : Attribute { public string UniqueName { get; } public bool RelayToSelf { get; } public NetworkMessage(string uniqueName, bool relayToSelf = false) { UniqueName = uniqueName; RelayToSelf = relayToSelf; } } public abstract class NetworkMessageHandler<T> where T : class { public abstract void Handler(ulong sender, T message); } public abstract class NetworkMessageHandler { public abstract void Handler(ulong sender); } internal abstract class NetworkMessageFinalizerBase { internal abstract string UniqueName { get; } internal abstract bool RelayToSelf { get; } public abstract void Read(ulong sender, FastBufferReader reader); } internal class NetworkMessageFinalizer : NetworkMessageFinalizerBase { [CompilerGenerated] private sealed class <ReadLater>d__13 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NetworkMessageFinalizer <>4__this; public ulong fakeSender; public FastBufferReader reader; private int <timesWaited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReadLater>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; NetworkMessageFinalizer networkMessageFinalizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timesWaited>5__2 = 0; break; case 1: <>1__state = -1; <timesWaited>5__2++; if (<timesWaited>5__2 % 20 == 0) { Plugin.Log.LogWarning((object)$"Waiting to read network message. Waiting on host?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null} Waiting on local player?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null}"); } if (<timesWaited>5__2 >= 100) { Plugin.Log.LogError((object)"Dropping network message"); <>2__current = null; <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } networkMessageFinalizer.Read(fakeSender, reader); 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(); } } [CompilerGenerated] private sealed class <SendLater>d__12 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NetworkMessageFinalizer <>4__this; private int <timesWaited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SendLater>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown int num = <>1__state; NetworkMessageFinalizer networkMessageFinalizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timesWaited>5__2 = 0; break; case 1: <>1__state = -1; <timesWaited>5__2++; if (<timesWaited>5__2 % 20 == 0) { Plugin.Log.LogWarning((object)$"Waiting to send network message. Waiting on host?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null} Waiting on local player?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null}"); } if (<timesWaited>5__2 >= 100) { Plugin.Log.LogError((object)"Dropping network message"); <>2__current = null; <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } networkMessageFinalizer.Send(); 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(); } } internal override string UniqueName { get; } internal override bool RelayToSelf { get; } internal Action<ulong> OnReceived { get; } public NetworkMessageFinalizer(string uniqueName, bool relayToSelf, Action<ulong> onReceived) { UniqueName = uniqueName; RelayToSelf = relayToSelf; OnReceived = onReceived; } public void Send() { //IL_005d: 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_0091: 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) if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { ((MonoBehaviour)NetworkManager.Singleton).StartCoroutine(SendLater()); return; } byte[] array = new NetworkMessageWrapper(UniqueName, LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.ClientId).ToBytes(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize<byte>(array, -1, 0), (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(array, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(UniqueName, val, (NetworkDelivery)4); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("LC_API_RELAY_MESSAGE", LC_API.GameInterfaceAPI.Features.Player.HostPlayer.ClientId, val, (NetworkDelivery)4); } } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public override void Read(ulong fakeSender, FastBufferReader reader) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { ((MonoBehaviour)NetworkManager.Singleton).StartCoroutine(ReadLater(fakeSender, reader)); return; } byte[] bytes = default(byte[]); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref bytes, default(ForPrimitives)); NetworkMessageWrapper networkMessageWrapper = bytes.ToObject<NetworkMessageWrapper>(); if (RelayToSelf || LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.ClientId != networkMessageWrapper.Sender) { OnReceived(networkMessageWrapper.Sender); } } [IteratorStateMachine(typeof(<SendLater>d__12))] private IEnumerator SendLater() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SendLater>d__12(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<ReadLater>d__13))] private IEnumerator ReadLater(ulong fakeSender, FastBufferReader reader) { //IL_0015: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReadLater>d__13(0) { <>4__this = this, fakeSender = fakeSender, reader = reader }; } } internal class NetworkMessageFinalizer<T> : NetworkMessageFinalizerBase where T : class { [CompilerGenerated] private sealed class <ReadLater>d__13 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NetworkMessageFinalizer<T> <>4__this; public ulong fakeSender; public FastBufferReader reader; private int <timesWaited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReadLater>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; NetworkMessageFinalizer<T> networkMessageFinalizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timesWaited>5__2 = 0; break; case 1: <>1__state = -1; <timesWaited>5__2++; if (<timesWaited>5__2 % 20 == 0) { Plugin.Log.LogWarning((object)$"Waiting to read network message. Waiting on host?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null} Waiting on local player?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null}"); } if (<timesWaited>5__2 >= 100) { Plugin.Log.LogError((object)"Dropping network message"); <>2__current = null; <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } networkMessageFinalizer.Read(fakeSender, reader); 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(); } } [CompilerGenerated] private sealed class <SendLater>d__12 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public NetworkMessageFinalizer<T> <>4__this; public T obj; private int <timesWaited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SendLater>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown int num = <>1__state; NetworkMessageFinalizer<T> networkMessageFinalizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timesWaited>5__2 = 0; break; case 1: <>1__state = -1; <timesWaited>5__2++; if (<timesWaited>5__2 % 20 == 0) { Plugin.Log.LogWarning((object)$"Waiting to send network message. Waiting on host?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null} Waiting on local player?: {(Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null}"); } if (<timesWaited>5__2 >= 100) { Plugin.Log.LogError((object)"Dropping network message"); <>2__current = null; <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } networkMessageFinalizer.Send(obj); 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(); } } internal override string UniqueName { get; } internal override bool RelayToSelf { get; } internal Action<ulong, T> OnReceived { get; } public NetworkMessageFinalizer(string uniqueName, bool relayToSelf, Action<ulong, T> onReceived) { UniqueName = uniqueName; RelayToSelf = relayToSelf; OnReceived = onReceived; } public void Send(T obj) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { ((MonoBehaviour)NetworkManager.Singleton).StartCoroutine(SendLater(obj)); return; } byte[] array = new NetworkMessageWrapper(UniqueName, LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.ClientId, obj.ToBytes()).ToBytes(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize<byte>(array, -1, 0), (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(array, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(UniqueName, val, (NetworkDelivery)4); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("LC_API_RELAY_MESSAGE", LC_API.GameInterfaceAPI.Features.Player.HostPlayer.ClientId, val, (NetworkDelivery)4); } } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public override void Read(ulong fakeSender, FastBufferReader reader) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) if ((Object)(object)LC_API.GameInterfaceAPI.Features.Player.LocalPlayer == (Object)null || (Object)(object)LC_API.GameInterfaceAPI.Features.Player.HostPlayer == (Object)null) { ((MonoBehaviour)NetworkManager.Singleton).StartCoroutine(ReadLater(fakeSender, reader)); return; } byte[] bytes = default(byte[]); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref bytes, default(ForPrimitives)); NetworkMessageWrapper networkMessageWrapper = bytes.ToObject<NetworkMessageWrapper>(); if (RelayToSelf || LC_API.GameInterfaceAPI.Features.Player.LocalPlayer.ClientId != networkMessageWrapper.Sender) { OnReceived(networkMessageWrapper.Sender, networkMessageWrapper.Message.ToObject<T>()); } } [IteratorStateMachine(typeof(NetworkMessageFinalizer<>.<SendLater>d__12))] private IEnumerator SendLater(T obj) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SendLater>d__12(0) { <>4__this = this, obj = obj }; } [IteratorStateMachine(typeof(NetworkMessageFinalizer<>.<ReadLater>d__13))] private IEnumerator ReadLater(ulong fakeSender, FastBufferReader reader) { //IL_0015: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReadLater>d__13(0) { <>4__this = this, fakeSender = fakeSender, reader = reader }; } } internal class NetworkMessageWrapper { public string UniqueName { get; set; } public ulong Sender { get; set; } public byte[] Message { get; set; } internal NetworkMessageWrapper(string uniqueName, ulong sender) { UniqueName = uniqueName; Sender = sender; } internal NetworkMessageWrapper(string uniqueName, ulong sender, byte[] message) { UniqueName = uniqueName; Sender = sender; Message = message; } internal NetworkMessageWrapper() { } } internal static class RegisterPatch { internal static void Postfix() { Network.OnRegisterNetworkMessages(); } } internal static class UnregisterPatch { internal static void Postfix() { Network.OnUnregisterNetworkMessages(); } } } namespace LC_API.Networking.Serializers { public struct Vector2S { private Vector2? v2; public float x { get; set; } public float y { get; set; } [JsonIgnore] public Vector2 vector2 { get { //IL_002f: 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) if (!v2.HasValue) { v2 = new Vector2(x, y); } return v2.Value; } } public Vector2S(float x, float y) { v2 = null; this.x = x; this.y = y; } public static implicit operator Vector2(Vector2S vector2S) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return vector2S.vector2; } public static implicit operator Vector2S(Vector2 vector2) { //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) return new Vector2S(vector2.x, vector2.y); } } public struct Vector2IntS { private Vector2Int? v2; public int x { get; set; } public int y { get; set; } [JsonIgnore] public Vector2Int vector2 { get { //IL_002f: 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) if (!v2.HasValue) { v2 = new Vector2Int(x, y); } return v2.Value; } } public Vector2IntS(int x, int y) { v2 = null; this.x = x; this.y = y; } public static implicit operator Vector2Int(Vector2IntS vector2S) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return vector2S.vector2; } public static implicit operator Vector2IntS(Vector2Int vector2) { return new Vector2IntS(((Vector2Int)(ref vector2)).x, ((Vector2Int)(ref vector2)).y); } } public struct Vector3S { private Vector3? v3; public float x { get; set; } public float y { get; set; } public float z { get; set; } [JsonIgnore] public Vector3 vector3 { get { //IL_0035: 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) if (!v3.HasValue) { v3 = new Vector3(x, y, z); } return v3.Value; } } public Vector3S(float x, float y, float z) { v3 = null; this.x = x; this.y = y; this.z = z; } public static implicit operator Vector3(Vector3S vector3S) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return vector3S.vector3; } public static implicit operator Vector3S(Vector3 vector3) { //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_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector3S(vector3.x, vector3.y, vector3.z); } } public struct Vector3IntS { private Vector3Int? v3; public int x { get; set; } public int y { get; set; } public int z { get; set; } [JsonIgnore] public Vector3Int vector3 { get { //IL_0035: 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) if (!v3.HasValue) { v3 = new Vector3Int(x, y, z); } return v3.Value; } } public Vector3IntS(int x, int y, int z) { v3 = null; this.x = x; this.y = y; this.z = z; } public static implicit operator Vector3Int(Vector3IntS vector3S) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return vector3S.vector3; } public static implicit operator Vector3IntS(Vector3Int vector3) { return new Vector3IntS(((Vector3Int)(ref vector3)).x, ((Vector3Int)(ref vector3)).y, ((Vector3Int)(ref vector3)).z); } } public struct Vector4S { private Vector4? v4; public float x { get; set; } public float y { get; set; } public float z { get; set; } public float w { get; set; } [JsonIgnore] public Vector4 Vector4 { get { //IL_003b: 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 (!v4.HasValue) { v4 = new Vector4(x, y, z, w); } return v4.Value; } } public Vector4S(float x, float y, float z, float w) { v4 = null; this.x = x; this.y = y; this.z = z; this.w = w; } public static implicit operator Vector4(Vector4S vector4S) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return vector4S.Vector4; } public static implicit operator Vector4S(Vector4 vector4) { //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_000c: 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) return new Vector4S(vector4.x, vector4.y, vector4.z, vector4.w); } } public struct QuaternionS { private Quaternion? q; public float x { get; set; } public float y { get; set; } public float z { get; set; } public float w { get; set; } [JsonIgnore] public Quaternion Quaternion { get { //IL_003b: 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 (!q.HasValue) { q = new Quaternion(x, y, z, w); } return q.Value; } } public QuaternionS(float x, float y, float z, float w) { q = null; this.x = x; this.y = y; this.z = z; this.w = w; } public static implicit operator Quaternion(QuaternionS quaternionS) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return quaternionS.Quaternion; } public static implicit operator QuaternionS(Quaternion quaternion) { //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_000c: 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) return new QuaternionS(quaternion.x, quaternion.y, quaternion.z, quaternion.w); } } public struct ColorS { private Color? c; public float r { get; set; } public float g { get; set; } public float b { get; set; } public float a { get; set; } [JsonIgnore] public Color Color { get { //IL_003b: 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 (!c.HasValue) { c = new Color(r, g, b, a); } return c.Value; } } public ColorS(float r, float g, float b, float a) { c = null; this.r = r; this.g = g; this.b = b; this.a = a; } public static implicit operator Color(ColorS colorS) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return colorS.Color; } public static implicit operator ColorS(Color color) { //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_000c: 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) return new ColorS(color.r, color.g, color.b, color.a); } } public struct Color32S { private Color32? c; public byte r { get; set; } public byte g { get; set; } public byte b { get; set; } public byte a { get; set; } [JsonIgnore] public Color32 Color { get { //IL_003b: 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 (!c.HasValue) { c = new Color32(r, g, b, a); } return c.Value; } } public Color32S(byte r, byte g, byte b, byte a) { c = null; this.r = r; this.g = g; this.b = b; this.a = a; } public static implicit operator Color32(Color32S colorS) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return colorS.Color; } public static implicit operator Color32S(Color32 color) { //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_000c: 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) return new Color32S(color.r, color.g, color.b, color.a); } } public struct RayS { private Ray? r; public Vector3S origin { get; set; } public Vector3S direction { get; set; } [JsonIgnore] public Ray Ray { get { //IL_0039: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!r.HasValue) { r = new Ray((Vector3)origin, (Vector3)direction); } return r.Value; } } public RayS(Vector3 origin, Vector3 direction) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) r = null; this.origin = origin; this.direction = direction; } public static implicit operator Ray(RayS rayS) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return rayS.Ray; } public static implicit operator RayS(Ray ray) { //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) return new RayS(((Ray)(ref ray)).origin, ((Ray)(ref ray)).direction); } } public struct Ray2DS { private Ray2D? r; public Vector2S origin { get; set; } public Vector2S direction { get; set; } [JsonIgnore] public Ray2D Ray { get { //IL_0039: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!r.HasValue) { r = new Ray2D((Vector2)origin, (Vector2)direction); } return r.Value; } } public Ray2DS(Vector2 origin, Vector2 direction) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) r = null; this.origin = origin; this.direction = direction; } public static implicit operator Ray2D(Ray2DS ray2DS) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ray2DS.Ray; } public static implicit operator Ray2DS(Ray2D ray2D) { //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) return new Ray2DS(((Ray2D)(ref ray2D)).origin, ((Ray2D)(ref ray2D)).direction); } } } namespace LC_API.ManualPatches { internal static class ServerPatch { internal static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 1) { Debug.LogError((object)$"Lobby could not be created! {result}", (Object)(object)__instance); } __instance.lobbyHostSettings.lobbyName = "[MODDED]" + __instance.lobbyHostSettings.lobbyName.ToString(); Plugin.Log.LogMessage((object)"server pre-setup success"); return true; } internal static bool CacheMenuManager(MenuManager __instance) { LC_APIManager.MenuManager = __instance; return true; } internal static bool ChatCommands(HUDManager __instance, CallbackContext context) { if (__instance.chatTextField.text.ToLower().Contains("/modcheck")) { CheatDatabase.OtherPlayerCheatDetector(); return false; } return true; } internal static void GameNetworkManagerAwake(GameNetworkManager __instance) { if ((Object)(object)GameNetworkManager.Instance == (Object)null) { ModdedServer.GameVersion = __instance.gameVersionNum; } } } } namespace LC_API.GameInterfaceAPI { public static class GameState { private static readonly Action NothingAction = delegate { }; public static int AlivePlayerCount { get; private set; } public static ShipState ShipState { get; private set; } public static event Action PlayerDied; public static event Action LandOnMoon; public static event Action WentIntoOrbit; public static event Action ShipStartedLeaving; internal static void GSUpdate() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { if (StartOfRound.Instance.shipHasLanded && ShipState != ShipState.OnMoon) { ShipState = ShipState.OnMoon; GameState.LandOnMoon.InvokeActionSafe(); } if (StartOfRound.Instance.inShipPhase && ShipState != 0) { ShipState = ShipState.InOrbit; GameState.WentIntoOrbit.InvokeActionSafe(); } if (StartOfRound.Instance.shipIsLeaving && ShipState != ShipState.LeavingMoon) { ShipState = ShipState.LeavingMoon; GameState.ShipStartedLeaving.InvokeActionSafe(); } if (AlivePlayerCount < StartOfRound.Instance.livingPlayers) { GameState.PlayerDied.InvokeActionSafe(); } AlivePlayerCount = StartOfRound.Instance.livingPlayers; } } static GameState() { GameState.PlayerDied = NothingAction; GameState.LandOnMoon = NothingAction; GameState.WentIntoOrbit = NothingAction; GameState.ShipStartedLeaving = NothingAction; } } [Obsolete("Use Player::QueueTip instead.")] public class GameTips { private static List<string> tipHeaders = new List<string>(); private static List<string> tipBodys = new List<string>(); private static float lastMessageTime; public static void ShowTip(string header, string body) { tipHeaders.Add(header); tipBodys.Add(body); } public static void UpdateInternal() { lastMessageTime -= Time.deltaTime; if ((tipHeaders.Count > 0) & (lastMessageTime < 0f)) { lastMessageTime = 5f; if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(tipHeaders[0], tipBodys[0], false, false, "LC_Tip1"); } tipHeaders.RemoveAt(0); tipBodys.RemoveAt(0); } } } } namespace LC_API.GameInterfaceAPI.Features { public class Item : NetworkBehaviour { private bool hasNewProps; internal static GameObject ItemNetworkPrefab { get; set; } public static Dictionary<GrabbableObject, Item> Dictionary { get; } = new Dictionary<GrabbableObject, Item>(); public static IReadOnlyCollection<Item> List => Dictionary.Values; public GrabbableObject GrabbableObject { get; private set; } public Item ItemProperties => GrabbableObject.itemProperties; public ScanNodeProperties ScanNodeProperties { get; set; } public bool IsHeld => GrabbableObject.isHeld; public bool IsTwoHanded => ItemProperties.twoHanded; public Player Holder { get { if (!IsHeld) { return null; } if (!Player.Dictionary.TryGetValue(GrabbableObject.playerHeldBy, out var value)) { return null; } return value; } } public string Name { get { return ItemProperties.itemName; } set { if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to set item name on client."); } string oldName = ItemProperties.itemName.ToLower(); CloneProperties(); ItemProperties.itemName = value; OverrideTooltips(oldName, value.ToLower()); ScanNodeProperties.headerText = value; SetGrabbableNameClientRpc(value); } } public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((Component)GrabbableObject).transform.position; } set { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to set item position on client."); } GrabbableObject.startFallingPosition = value; GrabbableObject.targetFloorPosition = value; ((Component)GrabbableObject).transform.position = value; SetItemPositionClientRpc(value); } } public Quaternion Rotation { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((Component)GrabbableObject).transform.rotation; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((Component)GrabbableObject).transform.rotation = value; } } public Vector3 Scale { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((Component)GrabbableObject).transform.localScale; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((Component)GrabbableObject).transform.localScale = value; } } public bool IsScrap { get { return ItemProperties.isScrap; } set { if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to set item name on client."); } CloneProperties(); ItemProperties.isScrap = value; SetIsScrapClientRpc(value); } } public int ScrapValue { get { return GrabbableObject.scrapValue; } set { if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to set scrap value on client."); } GrabbableObject.SetScrapValue(value); SetScrapValueClientRpc(value); } } [ClientRpc] private void SetGrabbableNameClientRpc(string name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(851295176u, val, (RpcDelivery)0); bool flag = name != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(name, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 851295176u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; string oldName = ItemProperties.itemName.ToLower(); CloneProperties(); ItemProperties.itemName = name; OverrideTooltips(oldName, name.ToLower()); ScanNodeProperties.headerText = name; } } private void OverrideTooltips(string oldName, string newName) { for (int i = 0; i < ItemProperties.toolTips.Length; i++) { ItemProperties.toolTips[i] = ItemProperties.toolTips[i].ReplaceWithCase(oldName, newName); } if (IsHeld && (Object)(object)Holder == (Object)(object)Player.LocalPlayer) { GrabbableObject.SetControlTipsForItem(); } } [ClientRpc] private void SetItemPositionClientRpc(Vector3 pos) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2488421240u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2488421240u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; GrabbableObject.startFallingPosition = pos; GrabbableObject.targetFloorPosition = pos; ((Component)GrabbableObject).transform.position = pos; } } } public void SetAndSyncRotation(Quaternion rotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to sync item rotation from client."); } SetItemRotationClientRpc(rotation); } [ClientRpc] private void SetItemRotationClientRpc(Quaternion rotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1294664755u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1294664755u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Rotation = rotation; } } } public void SetAndSyncScale(Vector3 scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to sync item scale from client."); } SetItemScaleClientRpc(scale); } [ClientRpc] private void SetItemScaleClientRpc(Vector3 scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(580391759u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref scale); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 580391759u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Scale = scale; } } } [ClientRpc] private void SetIsScrapClientRpc(bool isScrap) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3947257550u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isScrap, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3947257550u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; CloneProperties(); ItemProperties.isScrap = isScrap; } } } [ClientRpc] private void SetScrapValueClientRpc(int scrapValue) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(841518948u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, scrapValue); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 841518948u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; GrabbableObject.SetScrapValue(scrapValue); } } } public void RemoveFromHolder(Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion)) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to remove item from player on client."); } if (IsHeld) { ((NetworkBehaviour)this).NetworkObject.RemoveOwnership(); Holder.Inventory.RemoveItem(this); RemoveFromHolderClientRpc(); Position = position; Rotation = rotation; } } [ClientRpc] private void RemoveFromHolderClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2848836392u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2848836392u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (IsHeld) { Holder.Inventory.RemoveItem(this); } } } public void EnablePhysics(bool enable) { GrabbableObject.EnablePhysics(enable); } public void EnableMeshes(bool enable) { GrabbableObject.EnableItemMeshes(enable); } public void FallToGround(bool randomizePosition = false) { //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) GrabbableObject.FallToGround(randomizePosition, false, default(Vector3)); } public bool PocketItem() { if (!IsHeld || (Object)(object)Holder.HeldItem != (Object)(object)this || IsTwoHanded) { return false; } GrabbableObject.PocketItem(); return true; } public bool GiveTo(Player player, bool switchTo = true) { if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to give item to player on client."); } return player.Inventory.TryAddItem(this, switchTo); } public void InitializeScrap() { if (RoundManager.Instance.AnomalyRandom != null) { InitializeScrap((int)((float)RoundManager.Instance.AnomalyRandom.Next(ItemProperties.minValue, ItemProperties.maxValue) * RoundManager.Instance.scrapValueMultiplier)); } else { InitializeScrap((int)((float)Random.Range(ItemProperties.minValue, ItemProperties.maxValue) * RoundManager.Instance.scrapValueMultiplier)); } } public void InitializeScrap(int scrapValue) { if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to initialize scrap on client."); } ScrapValue = scrapValue; InitializeScrapClientRpc(); } [ClientRpc] private void InitializeScrapClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1025089875u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1025089875u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; MeshFilter val3 = default(MeshFilter); if (((Component)GrabbableObject).gameObject.TryGetComponent<MeshFilter>(ref val3) && ItemProperties.meshVariants != null && ItemProperties.meshVariants.Length != 0) { if (RoundManager.Instance.ScrapValuesRandom != null) { val3.mesh = ItemProperties.meshVariants[RoundManager.Instance.ScrapValuesRandom.Next(ItemProperties.meshVariants.Length)]; } else { val3.mesh = ItemProperties.meshVariants[0]; } } MeshRenderer val4 = default(MeshRenderer); if (((Component)GrabbableObject).gameObject.TryGetComponent<MeshRenderer>(ref val4) && ItemProperties.materialVariants != null && ItemProperties.materialVariants.Length != 0) { if (RoundManager.Instance.ScrapValuesRandom != null) { ((Renderer)val4).sharedMaterial = ItemProperties.materialVariants[RoundManager.Instance.ScrapValuesRandom.Next(ItemProperties.materialVariants.Length)]; } else { ((Renderer)val4).sharedMaterial = ItemProperties.materialVariants[0]; } } } public static Item CreateAndSpawnItem(string itemName, bool andInitialize = true, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion)) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to create and spawn item on client."); } string name = itemName.ToLower(); GameObject val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemName.ToLower().Contains(name)))?.spawnPrefab; if ((Object)(object)val != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(val, position, rotation); obj.GetComponent<NetworkObject>().Spawn(false); Item component = obj.GetComponent<Item>(); if (component.IsScrap && andInitialize) { component.InitializeScrap(); } return component; } return null; } public static Item CreateAndGiveItem(string itemName, Player player, bool andInitialize = true, bool switchTo = true) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsHost) { throw new NoAuthorityException("Tried to create and give item on client."); } string name = itemName.ToLower(); GameObject val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemName.ToLower().Contains(name)))?.spawnPrefab; if ((Object)(object)val != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(val, Vector3.zero, default(Quaternion)); obj.GetComponent<NetworkObject>().Spawn(false); Item component = obj.GetComponent<Item>(); if (component.IsScrap && andInitialize) { component.InitializeScrap(); } component.GiveTo(player, switchTo); return component; } return null; } private void Awake() { GrabbableObject = ((Component)this).GetComponent<GrabbableObject>(); ScanNodeProperties = ((Component)GrabbableObject).gameObject.GetComponentInChildren<ScanNodeProperties>(); Dictionary.Add(GrabbableObject, this); } private void CloneProperties() { Item itemProperties = Object.Instantiate<Item>(ItemProperties); if (hasNewProps) { Object.Destroy((Object)(object)ItemProperties); } GrabbableObject.itemProperties = itemProperties; hasNewProps = true; } public override void OnDestroy() { Dictionary.Remove(GrabbableObject); ((NetworkBehaviour)this).OnDestroy(); } public static Item GetOrAdd(GrabbableObject grabbableObject) { if (Dictionary.TryGetValue(grabbableObject, out var value)) { return value; } return ((Component)grabbableObject).gameObject.AddComponent<Item>(); } public static Item Get(GrabbableObject grabbableObject) { if (Dictionary.TryGetValue(grabbableObject, out var value)) { return value; } return null; } public static bool TryGet(GrabbableObject grabbableObject, out Item item) { return Dictionary.TryGetValue(grabbableObject, out item); } public static Item Get(ulong netId) { return List.FirstOrDefault((Item i) => ((NetworkBehaviour)i).NetworkObjectId == netId); } public static bool TryGet(ulong netId, out Item item) { item = Get(netId); return (Object)(object)item != (Object)null; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(851295176u, new RpcReceiveHandler(__rpc_handler_851295176), "SetGrabbableNameClientRpc"); ((NetworkBehaviour)this).__registerRpc(2488421240u, new RpcReceiveHandler(__rpc_handler_2488421240), "SetItemPositionClientRpc"); ((NetworkBehaviour)this).__registerRpc(1294664755u, new RpcReceiveHandler(__rpc_handler_1294664755), "SetItemRotationClientRpc"); ((NetworkBehaviour)this).__registerRpc(580391759u, new RpcReceiveHandler(__rpc_handler_580391759), "SetItemScaleClientRpc"); ((NetworkBehaviour)this).__registerRpc(3947257550u, new RpcReceiveHandler(__rpc_handler_3947257550), "SetIsScrapClientRpc"); ((NetworkBehaviour)this).__registerRpc(841518948u, new RpcReceiveHandler(__rpc_handler_841518948), "SetScrapValueClientRpc"); ((NetworkBehaviour)this).__registerRpc(2848836392u, new RpcReceiveHandler(__rpc_handler_2848836392), "RemoveFromHolderClientRpc"); ((NetworkBehaviour)this).__registerRpc(1025089875u, new RpcReceiveHandler(__rpc_handler_1025089875), "InitializeScrapClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_851295176(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string grabbableNameClientRpc = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref grabbableNameClientRpc, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((Item)(object)target).SetGrabbableNameClientRpc(grabbableNameClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2488421240(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 itemPositionClientRpc = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemPositionClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((Item)(object)target).SetItemPositionClientRpc(itemPositionClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1294664755(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Quaternion itemRotationClientRpc = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemRotationClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((Item)(object)target).SetItemRotationClientRpc(itemRotationClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_580391759(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 itemScaleClientRpc = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemScaleClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((Item)(object)target).SetItemScaleCl