Decompiled source of LCStaminafix v1.0.1

Plugins/LCStaminaFix.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCStaminaFix.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LCStaminaFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCStaminaFix")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c3e2aa72-10af-489d-bb40-07f4b7fc5bd8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCStaminaFix
{
	[BepInPlugin("sunsetos.lcstaminafix", "lcstaminafix", "1.0.1")]
	public class LCStaminaFix : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "sunsetos.lcstaminafix";

		public const string PLUGIN_NAME = "lcstaminafix";

		public const string PLUGIN_VERSION = "1.0.1";

		private readonly Harmony harmony = new Harmony("sunsetos.lcstaminafix");

		private static LCStaminaFix Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("sunsetos.lcstaminafix");
			mls.LogInfo((object)"sunsetos.lcstaminafix is here");
			harmony.PatchAll(typeof(StaminaFix));
			harmony.PatchAll(typeof(LCStaminaFix));
		}
	}
}
namespace LCStaminaFix.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class StaminaFix
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Postfix(ref float ___sprintMeter, ref bool ___isSprinting, ref bool ___isWalking, ref float ___sprintTime)
		{
			if (!___isSprinting && !___isWalking)
			{
				___sprintMeter = Mathf.Clamp(___sprintMeter + 0.08f * Time.deltaTime - Time.deltaTime / (___sprintTime + 4f), 0f, 1f);
			}
			else if (!___isSprinting & ___isWalking)
			{
				___sprintMeter = Mathf.Clamp(___sprintMeter + 0.07f * Time.deltaTime - Time.deltaTime / (___sprintTime + 9f), 0f, 1f);
			}
		}
	}
}