Decompiled source of FasterSprint v1.0.1

FasterSprint.dll

Decompiled 2 years 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FasterSprint")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FasterSprint")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e6dfe476-de21-4f2b-883d-b2e3b72f52f1")]
[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 FasterSprint
{
	[BepInPlugin("FasterSprint", "FasterSprint", "0.0.1")]
	public class FasterSprintBase : BaseUnityPlugin
	{
		public static ManualLogSource mls = Logger.CreateLogSource("FasterSprint");

		private static FasterSprintBase Instance;

		private static ConfigEntry<float> ConfigSpeedMultiplier;

		public static float SpeedMultiplier;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			BindConfig();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "FasterSprint");
			SetValues();
			mls.LogInfo((object)"Plugin has awoken");
		}

		private void BindConfig()
		{
			ConfigSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Speed Multiplier", 1f, "How much faster should the player run? Setting this to 2 will make the player run twice as fast.");
		}

		private void SetValues()
		{
			SpeedMultiplier = ConfigSpeedMultiplier.Value;
		}
	}
	public class PluginInfo
	{
		public const string PLUGIN_GUID = "FasterSprint";

		public const string PLUGIN_NAME = "FasterSprint";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace FasterSprint.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal class PlayerControllerBPatches
	{
		private static void Postfix(ref PlayerControllerB __instance)
		{
			if (__instance.isSprinting)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerControllerB), "sprintMultiplier");
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(__instance, FasterSprintBase.SpeedMultiplier);
				}
				else
				{
					FasterSprintBase.mls.LogError((object)"Could not find the 'sprintMultiplier' field in PlayerControllerB. <- Unsuccessful search for 'sprintMultiplier' field.");
				}
			}
		}
	}
}