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 DeathLink v1.0.4
LC_DeathLink.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LC_DeathLink.Patches; using StaticNetcodeLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LC_DeathLink")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LC_DeathLink")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3a3dd9b0-59fb-43a8-9627-399356537d2e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace LC_DeathLink { [BepInPlugin("Jack.DeathLink", "DeathLink", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DeathLinkBase : BaseUnityPlugin { private const string modGUID = "Jack.DeathLink"; private const string modName = "DeathLink"; private const string modVersion = "1.0.4"; private readonly Harmony harmony = new Harmony("Jack.DeathLink"); private static DeathLinkBase Instance; internal static ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Jack.DeathLink"); mls.LogInfo((object)"Successfully loaded DeathLink ver. 1.0.4"); harmony.PatchAll(typeof(DeathLinkBase)); harmony.PatchAll(typeof(DeathPatch)); } } } namespace LC_DeathLink.Patches { internal class DeathPatch { internal static ManualLogSource Logger = Logger.CreateLogSource("DeathLink"); internal static List<PlayerControllerB> playersToKill = new List<PlayerControllerB>(); [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyPrefix] private static void LandShipPatch() { Networking.FillListClientRpc(); Networking.FillListServerRpc(); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPrefix] private static void KillPostfix(PlayerControllerB __instance) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) List<PlayerControllerB> list = new List<PlayerControllerB>(playersToKill); Logger.LogInfo((object)("Number of players to kill = " + list.Count)); if (list.Count == 0) { Logger.LogError((object)"No players to kill"); } foreach (PlayerControllerB item in list) { playersToKill.Remove(item); if (!item.isPlayerDead && item.isHostPlayerObject) { DeathLinkBase.mls.LogError((object)("Called kill method on host: " + item.playerUsername)); Networking.KillServerRpc(item.playerClientId, item.causeOfDeath); } else if (!item.isPlayerDead && ((NetworkBehaviour)item).IsClient) { DeathLinkBase.mls.LogError((object)("Called kill method on client: " + item.playerUsername)); Networking.KillClientRpc(item.playerClientId, item.causeOfDeath); } } } } [StaticNetcode] internal class Networking : MonoBehaviour { internal static int animationToUse; [ClientRpc] public static void KillClientRpc(ulong playerId, CauseOfDeath causeOfDeath) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; PlayerControllerB val; if (playerId > (ulong)instance.allPlayerScripts.Length) { val = null; } val = instance.allPlayerScripts[playerId]; if ((Object)(object)val != (Object)null) { val.KillPlayer(Vector3.zero, true, causeOfDeath, 1, Vector3.zero); } } [ClientRpc] public static void FillListClientRpc() { DeathPatch.playersToKill = new List<PlayerControllerB>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (val.isPlayerControlled) { DeathPatch.playersToKill.Add(val); } } } [ServerRpc] public static void KillServerRpc(ulong playerId, CauseOfDeath causeOfDeath) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; PlayerControllerB val; if (playerId > (ulong)instance.allPlayerScripts.Length) { val = null; } val = instance.allPlayerScripts[playerId]; if ((Object)(object)val != (Object)null) { val.KillPlayer(Vector3.zero, true, causeOfDeath, 1, Vector3.zero); } } [ServerRpc] public static void FillListServerRpc() { DeathPatch.playersToKill = new List<PlayerControllerB>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (val.isPlayerControlled) { DeathPatch.playersToKill.Add(val); } } } } internal class Override { [HarmonyPatch(typeof(PlayerControllerB), "AllowPlayerDeath")] [HarmonyPrefix] private static bool AllowPlayerDeathPatch() { return true; } } }