Decompiled source of LongerSprinting v1.2.3

LongerSprinting.dll

Decompiled 8 months ago
using 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LongerSprinting")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Longer Sprinting allows you to sprint for longer in Content Warning.")]
[assembly: AssemblyFileVersion("1.2.3.0")]
[assembly: AssemblyInformationalVersion("1.2.3")]
[assembly: AssemblyProduct("LongerSprinting")]
[assembly: AssemblyTitle("LongerSprinting")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.3.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LongerSprinting
{
	[HarmonyPatch(typeof(PlayerController))]
	internal class PlayerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static bool Prefix(PlayerController __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<Player>() == (Object)(object)Player.localPlayer)
			{
				__instance.maxStamina = LongerSprint.MaxStamina.Value;
				__instance.staminaRegRate = LongerSprint.StaminaRegenRate.Value;
				__instance.sprintMultiplier = LongerSprint.SprintMultiplyer.Value;
				__instance.movementForce = LongerSprint.BaseMovementSpeed.Value;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void UpdatePostFix(PlayerController __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<Player>() == (Object)(object)Player.localPlayer)
			{
				if (!Player.localPlayer.data.isSprinting)
				{
					Player.localPlayer.data.currentStamina = Math.Clamp(__instance.staminaRegRate * Time.deltaTime + Player.localPlayer.data.currentStamina, 0f, __instance.maxStamina);
				}
				if (LongerSprint.IsInfinite.Value)
				{
					Player.localPlayer.data.currentStamina = __instance.maxStamina;
				}
			}
		}
	}
	[ContentWarningPlugin("LongerSprinting", "1.2.3", false)]
	[BepInPlugin("LongerSprinting", "LongerSprinting", "1.2.3")]
	public class LongerSprint : BaseUnityPlugin
	{
		internal static ConfigEntry<float>? MaxStamina { get; private set; }

		internal static ConfigEntry<float>? StaminaRegenRate { get; private set; }

		internal static ConfigEntry<bool>? IsInfinite { get; private set; }

		internal static ConfigEntry<float>? SprintMultiplyer { get; private set; }

		internal static ConfigEntry<float>? BaseMovementSpeed { get; private set; }

		public static ManualLogSource logger { get; private set; }

		private void Awake()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			MaxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxStamina", 20f, "The maximum amount of stamina you have in game, The default without the mod is 10.");
			StaminaRegenRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StaminaRegenRate", 2f, "How quickly you regenerate stamina. This is added on the base stamina regen so if you wanted to not regenerate any extra stamina you may set this to 0");
			SprintMultiplyer = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SprintMultiplyer", 2.3f, "How fast you sprint.");
			BaseMovementSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BaseMovementSpeed", 17f, "How Fast you walk.");
			IsInfinite = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsInfinite", false, "Are you able to sprint forever?");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LongerSprinting is loaded! v1.0.3");
			Harmony val = new Harmony("sprintLonger");
			val.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LongerSprinting";

		public const string PLUGIN_NAME = "LongerSprinting";

		public const string PLUGIN_VERSION = "1.2.3";
	}
}