Decompiled source of StaminaBuff v1.1.0

BepInEx/plugins/StaminaBuff/StaminaBuff.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StaminaBuff")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StaminaBuff")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7e6a1842-b241-4cde-9472-49fbd9291012")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StaminaBuff;

[BepInPlugin("catgocri.StaminaBuff", "Stamina Buff", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch]
	private class Patches
	{
		private static float val = staminaRegainRate.Value;

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		private static void StaminaPatch(ref float ___sprintMeter, ref bool ___isSprinting)
		{
			if (!___isSprinting)
			{
				___sprintMeter += val;
			}
		}
	}

	private const string pluginGUID = "catgocri.StaminaBuff";

	private const string pluginNAME = "Stamina Buff";

	private const string pluginVERSION = "1.1.0";

	private readonly Harmony _harmony = new Harmony("catgocri.StaminaBuff");

	public static ConfigEntry<float> staminaRegainRate;

	internal static ManualLogSource Logger { get; private set; }

	private void Awake()
	{
		_harmony.PatchAll();
		Logger = ((BaseUnityPlugin)this).Logger;
		Logger.LogInfo((object)"Plugin Stamina Buff is loaded!");
		staminaRegainRate = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina Regain Rate", "staminaRegainRate", 0.005f, "The amount of stamina readded per frame of not sprinting.");
	}
}