Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RumisLethalNetworkHandler v1.0.1
Rumi's Lethal Network Handler.dll
Decompiled 11 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Rumi.LCNetworks.API; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Rumi's Lethal Network Handler")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e8a1c986769d8fa7c133688ed8da89a57c15f560")] [assembly: AssemblyProduct("Rumi's Lethal Network Handler")] [assembly: AssemblyTitle("Rumi's Lethal Network Handler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Rumi.LCNetworks { internal static class Debug { public static void Log(object data) { ManualLogSource? logger = LCNHPlugin.logger; if (logger != null) { logger.LogInfo(data); } } public static void LogWarning(object data) { ManualLogSource? logger = LCNHPlugin.logger; if (logger != null) { logger.LogWarning(data); } } public static void LogError(object data) { ManualLogSource? logger = LCNHPlugin.logger; if (logger != null) { logger.LogError(data); } } } public static class LCNHNetworkPatches { private static readonly List<(NetworkObject networkObject, string name)> networkObjects = new List<(NetworkObject, string)>(); public static void Patch() { Debug.Log("GameNetworkManager Patch..."); try { LCNHPlugin.harmony.PatchAll(typeof(LCNHNetworkPatches)); Debug.Log("GameNetworkManager Patched!"); } catch (Exception data) { Debug.LogError(data); Debug.Log("GameNetworkManager Patch Fail!"); } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void GameNetworkManager_Start_Postfix() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown for (int i = 0; i < ReflectionManager.networks.Count; i++) { Type type = ReflectionManager.networks[i]; try { GameObject val = new GameObject("LCNA Network Handler"); NetworkObject val2 = val.AddComponent<NetworkObject>(); LCNHNetworkBehaviour lCNHNetworkBehaviour = (LCNHNetworkBehaviour)(object)val.AddComponent(type); ((Object)val).name = lCNHNetworkBehaviour.name; ((Object)val.gameObject).hideFlags = (HideFlags)61; val2.GlobalObjectIdHash = lCNHNetworkBehaviour.globalIdHash; val2.SynchronizeTransform = false; val2.AutoObjectParentSync = false; NetworkManager.Singleton.AddNetworkPrefab(val); networkObjects.Add((val2, lCNHNetworkBehaviour.name)); } catch (Exception data) { Debug.LogError(data); } } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void StartOfRound_Awake_Postfix() { if (networkObjects == null || (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)) { return; } for (int i = 0; i < networkObjects.Count; i++) { try { (NetworkObject networkObject, string name) tuple = networkObjects[i]; NetworkObject item = tuple.networkObject; string item2 = tuple.name; NetworkObject obj = Object.Instantiate<NetworkObject>(item); ((Object)obj).name = item2; obj.Spawn(false); } catch (Exception data) { Debug.LogError(data); } } } } [BepInPlugin("Rumi.LCNetworkHandler", "LCNetworkHandler", "1.0.1")] public sealed class LCNHPlugin : BaseUnityPlugin { public const string modGuid = "Rumi.LCNetworkHandler"; public const string modName = "LCNetworkHandler"; public const string modVersion = "1.0.1"; internal static ManualLogSource? logger { get; private set; } = null; internal static Harmony harmony { get; } = new Harmony("Rumi.LCNetworkHandler"); private void Awake() { logger = ((BaseUnityPlugin)this).Logger; Debug.Log("Start loading plugin..."); LCNHNetworkPatches.Patch(); Debug.Log("Plugin LCNetworkHandler is loaded!"); } public static void NetcodePatcher() { Type[] types = Assembly.GetCallingAssembly().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); } } } } } internal static class ReflectionManager { public static IReadOnlyList<Assembly> assemblys { get; } public static IReadOnlyList<Type> types { get; } public static IReadOnlyList<Type> networks { get; } static ReflectionManager() { assemblys = Array.Empty<Assembly>(); types = Array.Empty<Type>(); networks = Array.Empty<Type>(); assemblys = AppDomain.CurrentDomain.GetAssemblies(); types = assemblys.SelectMany(delegate(Assembly x) { try { return x.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type x) => x != null).ToArray(); } }).ToArray(); networks = types.Where(delegate(Type x) { try { return !x.IsAbstract && typeof(LCNHNetworkBehaviour).IsAssignableFrom(x); } catch { return false; } }).ToArray(); } } } namespace Rumi.LCNetworks.API { public abstract class LCNHNetworkBehaviour : NetworkBehaviour { public abstract string name { get; } public abstract uint globalIdHash { get; } } public abstract class LCNHNetworkBehaviour<T> : LCNHNetworkBehaviour where T : LCNHNetworkBehaviour<T> { public static T? instance { get; private set; } public override void OnNetworkSpawn() { if (((NetworkBehaviour)this).IsServer && (Object)(object)instance != (Object)null) { ((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true); } instance = (T)this; } public override void OnNetworkDespawn() { instance = null; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }