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 SlashBack v1.0.1
SlashBack.dll
Decompiled 5 days agousing System; using System.Diagnostics; 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 UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SlashBack")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("Slash Back")] [assembly: AssemblyTitle("SlashBack")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 SlashBack { [BepInPlugin("SlashBack", "Slash Back", "1.0.1")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void <Postfix>b__0_0(ConsoleEventArgs args) { //IL_0014: 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) if (Instance.startTeleport) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).name.Equals("main")) { args.Context.AddString("You are not in the world."); return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (!playerProfile.HaveDeathPoint()) { args.Context.AddString("You haven't died yet!"); } else if (Instance.isCooldown) { args.Context.AddString("You have already used this command."); args.Context.AddString($"There is a cooldown of {Mathf.Round(Instance.cooldownTimer)}s before you can use it again."); } else if (Instance.isExpired) { args.Context.AddString("You haven't died in a while."); } else { Instance.Start(); } } } public static void Postfix() { //IL_0034: 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) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0014: 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) if (!Instance.startTeleport) { Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).name.Equals("main")) { args.Context.AddString("You are not in the world."); } else { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (!playerProfile.HaveDeathPoint()) { args.Context.AddString("You haven't died yet!"); } else if (Instance.isCooldown) { args.Context.AddString("You have already used this command."); args.Context.AddString($"There is a cooldown of {Mathf.Round(Instance.cooldownTimer)}s before you can use it again."); } else if (Instance.isExpired) { args.Context.AddString("You haven't died in a while."); } else { Instance.Start(); } } } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("back", "return to the death position", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(Player), "Load")] public class Patch2 { public static void Postfix(Player __instance) { if (__instance.m_timeSinceDeath <= Instance.cooldown && !Instance.isCooldown) { Instance.isExpired = false; Instance.Say($"<color=#f7e694>Use /back return to the death position.\nExpires in {Mathf.Round(Instance.cooldown - __instance.m_timeSinceDeath)}s</color>"); } } } internal static Plugin Instance; internal static ManualLogSource Logger; internal static Harmony Harmony = new Harmony("SlashBack"); internal bool startTeleport = false; internal float cooldown = 120f; internal float cooldownTimer = 0f; internal bool isCooldown = false; internal float countdown = 5f; internal float countdownTimer = 0f; internal int lastCountdown = 0; internal Vector3 lastPosition = Vector3.zero; internal bool isExpired = true; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Harmony.PatchAll(); Logger.LogInfo((object)"Plugin SlashBack is loaded!"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); Harmony.UnpatchSelf(); Logger.LogInfo((object)"Plugin SlashBack is unloaded!"); } private void FixedUpdate() { //IL_0001: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).name.Equals("main") || (Object)(object)Player.m_localPlayer == (Object)null) { return; } float fixedDeltaTime = Time.fixedDeltaTime; if (cooldownTimer > 0f && !startTeleport) { cooldownTimer -= fixedDeltaTime; isCooldown = true; } if (Player.m_localPlayer.m_timeSinceDeath > cooldown && !isExpired) { Say("/back command has expired"); isExpired = true; } if (cooldownTimer <= 0f && isCooldown) { isCooldown = false; } if (!startTeleport) { return; } if (countdownTimer > 0f && PlayerIsMoving(((Component)Player.m_localPlayer).transform.position)) { Say("Teleport canceled because the player moved."); lastPosition = Vector3.zero; startTeleport = false; return; } if (Mathf.Round(countdownTimer) != (float)lastCountdown) { lastCountdown = (int)Mathf.Round(countdownTimer); string text = $"Teleporting in {lastCountdown}s."; if ((float)lastCountdown == countdown) { Say(text); } else { Chat instance = Chat.instance; if ((Object)(object)instance != (Object)null) { ((Terminal)instance).m_chatBuffer[((Terminal)instance).m_chatBuffer.Count - 1] = text; ((Terminal)instance).UpdateChat(); instance.m_hideTimer = 0f; } } } countdownTimer -= fixedDeltaTime; if (countdownTimer <= 0f) { TeleportToDeahPoint(); cooldownTimer = cooldown - Player.m_localPlayer.m_timeSinceDeath; lastPosition = Vector3.zero; isExpired = true; startTeleport = false; } } internal void Start() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) countdownTimer = countdown; lastCountdown = 0; lastPosition = GetVectorRound(((Component)Player.m_localPlayer).transform.position); startTeleport = true; } private Vector3 GetVectorRound(Vector3 vector) { //IL_0001: 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) //IL_0023: 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_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Round(vector.x * 10f), Mathf.Round(vector.y * 10f), Mathf.Round(vector.z * 10f)) * 0.1f; } private bool PlayerIsMoving(Vector3 vector) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector3 vectorRound = GetVectorRound(vector); ((Vector3)(ref vectorRound))..ctor(vectorRound.x / lastPosition.x, vectorRound.y / lastPosition.y, vectorRound.z / lastPosition.z); if (vectorRound.x != 1f || vectorRound.y != 1f || vectorRound.z != 1f) { return true; } return false; } internal void Say(string text) { Chat instance = Chat.instance; if ((Object)(object)instance != (Object)null) { ((Terminal)instance).AddString(text); instance.m_hideTimer = 0f; } } private void TeleportToDeahPoint() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) //IL_001a: 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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); Player localPlayer = Player.m_localPlayer; Vector3 deathPoint = playerProfile.GetDeathPoint(); deathPoint += Vector3.up * 2f; ((Character)localPlayer).TeleportTo(deathPoint, ((Component)localPlayer).transform.rotation, false); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "SlashBack"; public const string PLUGIN_NAME = "Slash Back"; public const string PLUGIN_VERSION = "1.0.1"; } }