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 NoAggroNoStaminaCost v0.1.0
plugins\NoAggroNoStaminaCost.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NoAggroNoStaminaCost")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NoAggroNoStaminaCost")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] namespace NoAggroNoStaminaCost; internal static class AggroState { private static float _lastAggroTime = float.NegativeInfinity; public static void NotifyAggro() { _lastAggroTime = Time.time; } public static bool IsRecent(float gracePeriod) { return Time.time - _lastAggroTime <= gracePeriod; } } [BepInPlugin("orax.NoAggroNoStaminaCost", "NoAggroNoStaminaCost", "0.1.0")] public class NoAggroNoStaminaCost : BaseUnityPlugin { public const string PluginGuid = "orax.NoAggroNoStaminaCost"; public const string PluginName = "NoAggroNoStaminaCost"; public const string PluginVersion = "0.1.0"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> CombatGracePeriod; private Harmony _harmony; private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "While enabled, the local player's stamina no longer drains as long as no enemy has aggro on them."); CombatGracePeriod = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CombatGracePeriod", 1f, new ConfigDescription("Delay (in seconds) after losing aggro before stamina becomes unlimited again. Prevents rapid flickering when a monster loses and quickly regains aggro.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); _harmony = new Harmony("orax.NoAggroNoStaminaCost"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"NoAggroNoStaminaCost 0.1.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal class Patch { [HarmonyPatch(typeof(Player), "RPC_OnTargeted")] internal static class Player_RPC_OnTargeted_TrackAggro { private static void Postfix(Player __instance, bool alerted) { if (alerted && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { AggroState.NotifyAggro(); } } } [HarmonyPatch(typeof(Player), "UseStamina")] internal static class Player_UseStamina_NoDrainOutOfCombat { private static bool Prefix(Player __instance) { if (!NoAggroNoStaminaCost.Enabled.Value) { return true; } if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (AggroState.IsRecent(NoAggroNoStaminaCost.CombatGracePeriod.Value)) { return true; } return false; } } }