Decompiled source of SprintPlus v1.1.0

BepInEx/plugins/SprintPlus.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;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using SprintPlus.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("SprintPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SprintPlus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("44c2a14c-60c5-4c1a-ab4f-0c0d1b74dddb")]
[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 SprintPlus
{
	[BepInPlugin("Brew.SprintPlus", "Sprint+", "1.1.0")]
	public class SprintBase : BaseUnityPlugin
	{
		private const string modGUID = "Brew.SprintPlus";

		private const string modName = "Sprint+";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("Brew.SprintPlus");

		private static SprintBase Instance;

		internal ManualLogSource mls;

		public static bool infiniteStamina = true;

		public static int sprintSpeed = 33;

		public static int walkSpeed = 10;

		private void Awake()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00cc: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0115: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Brew.SprintPlus");
			mls.LogInfo((object)"SprintPlus has initialised.");
			LethalConfigManager.SetModDescription("A mod that allows you to control how fast you sprint and allows you to sprint infinitely.");
			ConfigEntry<bool> infConfigEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("Sprint Settings", "Infinite Stamina", true, "Determines whether you can infinitely sprint or not.");
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(infConfigEntry);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
			ConfigEntry<int> sprintSpeedEntry = ((BaseUnityPlugin)this).Config.Bind<int>("Sprint Settings", "Sprint Speed", 33, "How fast you sprint.\n10 = walkspeed,\n20 = default sprint,\n33 = mod default");
			ConfigEntry<int> obj2 = sprintSpeedEntry;
			IntSliderOptions val2 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val2).Min = 10;
			((BaseRangeOptions<int>)val2).Max = 50;
			IntSliderConfigItem val3 = new IntSliderConfigItem(obj2, val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			ConfigEntry<int> val4 = ((BaseUnityPlugin)this).Config.Bind<int>("Sprint Settings", "Walkspeed", 10, "How fast you walk\n10 = default walkspeed\n20 = default sprint");
			IntSliderOptions val5 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val5).Min = 0;
			((BaseRangeOptions<int>)val5).Max = 50;
			IntSliderConfigItem val6 = new IntSliderConfigItem(val4, val5);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			infiniteStamina = infConfigEntry.Value;
			sprintSpeed = sprintSpeedEntry.Value;
			walkSpeed = val4.Value;
			infConfigEntry.SettingChanged += delegate
			{
				infiniteStamina = infConfigEntry.Value;
			};
			sprintSpeedEntry.SettingChanged += delegate
			{
				sprintSpeed = sprintSpeedEntry.Value;
			};
			harmony.PatchAll(typeof(SprintBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace SprintPlus.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void updatePatch(ref float ___sprintMultiplier, ref float ___sprintMeter, ref bool ___isSprinting)
		{
			if (SprintBase.infiniteStamina)
			{
				___sprintMeter = 1f;
			}
			if (___isSprinting)
			{
				___sprintMultiplier = SprintBase.sprintSpeed / 10;
			}
			else
			{
				___sprintMultiplier = SprintBase.walkSpeed / 10;
			}
		}
	}
}