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 QuickRespawn v1.0.0
QuickRespawn.dll
Decompiled 12 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace QuickRespawn; [BepInPlugin("com.burks.quickrespawn", "Quick Respawn", "1.0.0")] public class QuickRespawnPlugin : BaseUnityPlugin { public const string GUID = "com.burks.quickrespawn"; public const string NAME = "Quick Respawn"; public const string VERSION = "1.0.0"; public static ManualLogSource Log; public static ConfigEntry<float> DeathDelay; public static ConfigEntry<float> LoadWait; public static ConfigEntry<float> QuickDeathCooldown; public static ConfigEntry<float> HoldSeconds; public static ConfigEntry<bool> QuickDeathOn; public static ConfigEntry<bool> NotNearEnemies; public static ConfigEntry<KeyCode> QuickDeathKey; private bool _cmd; private float _confirmUntil = -1f; private float _readyAt; private float _holdStart = -1f; private void Awake() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; DeathDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Respawn", "DeathScreenSeconds", 3f, "Seconds on the death screen before respawning starts (the game's own is 10)."); LoadWait = ((BaseUnityPlugin)this).Config.Bind<float>("Respawn", "MinimumLoadSeconds", 2f, "Shortest time the respawn waits for the area around your bed to load (the game's own is 8). It always waits until the area is actually ready."); QuickDeathOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick death", "Enabled", true, "Allow killing your own character with the 'quickdeath' console command (typed twice to confirm) or the key below."); QuickDeathKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Quick death", "Key", (KeyCode)0, "Optional key; hold it down to die."); HoldSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Quick death", "HoldSeconds", 2f, "How long the key must be held."); QuickDeathCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Quick death", "CooldownSeconds", 600f, "Time between quick deaths, so it is not a free trip home every minute."); NotNearEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick death", "NotWhileEnemiesAware", false, "Refuse while enemies are aware of you (stops using it to escape a losing fight)."); if ((int)SystemInfo.graphicsDeviceType != 4) { new Harmony("com.burks.quickrespawn").PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Quick Respawn 1.0.0 loaded."); } } private void Update() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { _holdStart = -1f; return; } if (!_cmd) { _cmd = true; try { new ConsoleCommand("quickdeath", "kill your own character (type it twice to confirm)", (ConsoleEvent)delegate(ConsoleEventArgs a) { Command(a.Context); }, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not add the 'quickdeath' command: " + ex.Message)); } } KeyCode value = QuickDeathKey.Value; if ((int)value == 0 || Console.IsVisible() || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())) { _holdStart = -1f; } else if (Input.GetKey(value)) { if (_holdStart < 0f) { _holdStart = Time.unscaledTime; Tell(null, "Keep holding to die..."); } else if (Time.unscaledTime - _holdStart >= Mathf.Max(0.2f, HoldSeconds.Value)) { _holdStart = float.MaxValue; Die(null); } } else { _holdStart = -1f; } } private void Command(Terminal ctx) { if (Time.unscaledTime > _confirmUntil) { _confirmUntil = Time.unscaledTime + 5f; Tell(ctx, "Type 'quickdeath' again within 5 seconds to die."); } else { _confirmUntil = -1f; Die(ctx); } } private void Die(Terminal ctx) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } if (!QuickDeathOn.Value) { Tell(ctx, "Quick death is switched off."); return; } float num = _readyAt - Time.unscaledTime; if (num > 0f) { Tell(ctx, "Quick death is ready again in " + Mathf.CeilToInt(num) + " s."); return; } if (NotNearEnemies.Value && (localPlayer.IsTargeted() || localPlayer.IsSensed())) { Tell(ctx, "Not while enemies are aware of you."); return; } if (((Character)localPlayer).IsTeleporting() || ((Character)localPlayer).InBed()) { Tell(ctx, "You can't do that right now."); return; } _readyAt = Time.unscaledTime + Mathf.Max(0f, QuickDeathCooldown.Value); HitData val = new HitData(); val.m_damage.m_damage = 10000000f; val.m_point = ((Character)localPlayer).GetCenterPoint(); val.m_hitType = (HitType)14; ((Character)localPlayer).Damage(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Quick death used."); } public static void Tell(Terminal ctx, string text) { if ((Object)(object)ctx != (Object)null) { ctx.AddString(text); } if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true); } } } [HarmonyPatch] public static class Patches { [HarmonyPatch(typeof(Game), "RequestRespawn")] [HarmonyPrefix] public static void RequestRespawn_Prefix(Game __instance, ref float delay, bool afterDeath) { if (afterDeath) { float num = Mathf.Clamp(QuickRespawnPlugin.DeathDelay.Value, 0.5f, 10f); if (delay > num) { delay = num; } __instance.m_fadeTimeDeath = Mathf.Min(9.5f, Mathf.Max(0.5f, num - 0.25f)); } } [HarmonyPatch(typeof(Game), "Start")] [HarmonyPostfix] public static void Start_Postfix(Game __instance) { float num = Mathf.Clamp(QuickRespawnPlugin.LoadWait.Value, 0.5f, 8f); if (__instance.m_respawnLoadDuration > num) { __instance.m_respawnLoadDuration = num; } } }