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 RespawnPatched v1.2.5
plugins/Respawn/Respawn.dll
Decompiled an hour agousing System; 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.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Respawn")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.5.0")] [assembly: AssemblyInformationalVersion("1.2.5+bf7f5cce526ee01b9f9b59345531bf7bcb5f9adb")] [assembly: AssemblyProduct("Respawn")] [assembly: AssemblyTitle("Respawn")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 RespawnMod { [BepInPlugin("ShaderLaze.Respawn", "Respawn", "1.2.5")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "ShaderLaze.Respawn"; public const string PluginName = "Respawn"; public const string PluginVersion = "1.2.5"; internal static ManualLogSource Log; internal static ConfigEntry<bool> RespawnAtDeathPosition; internal static ConfigEntry<int> RespawnHealAmount; internal static ConfigEntry<KeyCode> ActivationKey; private void Awake() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; RespawnAtDeathPosition = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "RespawnAtDeathPosition", false, "Respawn players where they died (true) or at the truck spawn point (false)."); RespawnHealAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "RespawnHealAmount", 19, "HP restored on respawn, on top of the 1 HP the game's revive gives."); ActivationKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "ActivationKey", (KeyCode)282, "Key that respawns all dead players."); GameObject val = new GameObject("RespawnUpdater") { hideFlags = (HideFlags)61 }; val.AddComponent<RespawnUpdater>(); Object.DontDestroyOnLoad((Object)val); Log.LogInfo((object)string.Format("{0} {1} loaded. Activation key: {2}", "Respawn", "1.2.5", ActivationKey.Value)); } } public class RespawnUpdater : MonoBehaviour { private static readonly Vector3 ParkedHeadPosition = new Vector3(0f, 3000f, 0f); private static readonly MethodInfo? SpawnMethod = (from m in (from m in typeof(PlayerAvatar).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "Spawn" select m).Where(delegate(MethodInfo m) { ParameterInfo[] parameters = m.GetParameters(); return parameters.Length >= 2 && parameters[0].ParameterType == typeof(Vector3) && parameters[1].ParameterType == typeof(Quaternion) && parameters.Skip(2).All((ParameterInfo x) => x.HasDefaultValue); }) orderby m.GetParameters().Length select m).FirstOrDefault(); private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(Plugin.ActivationKey.Value)) { RespawnAllDeadPlayers(); } } private static void RespawnAllDeadPlayers() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList == null) { return; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogInfo((object)"Only the host can respawn players."); return; } int num = 0; PlayerAvatar[] array = GameDirector.instance.PlayerList.ToArray(); foreach (PlayerAvatar val in array) { if (!((Object)(object)val == (Object)null) && val.deadSet && !((Object)(object)val.playerDeathHead == (Object)null) && !(((Component)val.playerDeathHead).transform.position == ParkedHeadPosition) && RespawnPlayer(val)) { num++; } } Plugin.Log.LogInfo((object)$"Respawned {num} dead player(s)."); } private static bool Spawn(PlayerAvatar player, Vector3 position, Quaternion rotation) { //IL_0034: 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) if (SpawnMethod == null) { Plugin.Log.LogError((object)"PlayerAvatar.Spawn(Vector3, Quaternion, ...) not found; the game changed again."); return false; } ParameterInfo[] parameters = SpawnMethod.GetParameters(); object[] array = new object[parameters.Length]; array[0] = position; array[1] = rotation; for (int i = 2; i < parameters.Length; i++) { array[i] = parameters[i].DefaultValue; } SpawnMethod.Invoke(player, array); return true; } private static bool RespawnPlayer(PlayerAvatar player) { //IL_004a: 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) if (Plugin.RespawnAtDeathPosition.Value) { player.Revive(false); } else { SpawnPoint[] array = Object.FindObjectsOfType<SpawnPoint>(); if (array.Length == 0) { Plugin.Log.LogWarning((object)"No spawn points found."); return false; } Transform transform = ((Component)array[Random.Range(0, array.Length)]).transform; player.Revive(false); if (!Spawn(player, transform.position, transform.rotation)) { return false; } } int value = Plugin.RespawnHealAmount.Value; if (value > 0) { player.playerHealth.HealOther(value, true); } Plugin.Log.LogInfo((object)("Respawned player: " + player.playerName)); return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Respawn"; public const string PLUGIN_NAME = "Respawn"; public const string PLUGIN_VERSION = "1.2.5"; } }