Decompiled source of Faster Player v1.0.1

PlayerSpeedEditor.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 PlayerSpeedEditor.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("FasterPlayer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FasterPlayer")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a56ca837-234f-4487-9563-7cf5995da1dc")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PlayerSpeedEditor
{
	[BepInPlugin("SpiralMods.PlayerSpeedEditor", "PlayerSpeedEditor", "1.0.1")]
	public class PlayerSpeedEditorBase : BaseUnityPlugin
	{
		private const string modGUID = "SpiralMods.PlayerSpeedEditor";

		private const string modName = "PlayerSpeedEditor";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("SpiralMods.PlayerSpeedEditor");

		private static PlayerSpeedEditorBase Instance;

		internal ManualLogSource mls;

		public static ConfigEntry<float> movementSpeedMultiplier;

		public static ConfigEntry<float> sprintMultiplierMultiplier;

		public static ConfigEntry<float> jumpForceMultiplier;

		public static ConfigEntry<bool> ModEnabled;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SpiralMods.PlayerSpeedEditor");
			mls.LogInfo((object)"PlayerSpeedEditorhas loaded (ModVersion: 1.0.1, ModGUID: SpiralMods.PlayerSpeedEditor)!");
			SetBindings();
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}

		private void SetBindings()
		{
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings (Restart Required)", "Disable Mod", false, "If true, the mod will be disabled!");
			movementSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings (Restart Required)", "Speed Multiplier", 2f, "This number signifies the multiplier of how fast the player moves!");
			sprintMultiplierMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings (Restart Required)", "Sprint Multiplier", 2f, "This number signifies the multiplier of how long the player's sprint lasts!");
			jumpForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings (Restart Required)", "Jump Multiplier", 2f, "This number signifies the multiplier of how high the player jumps!");
		}
	}
}
namespace PlayerSpeedEditor.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate(ref float ___movementSpeed, ref float ___sprintMultiplier, ref float ___jumpForce)
		{
			if (PlayerSpeedEditorBase.ModEnabled.Value)
			{
				___movementSpeed = 0.5f * PlayerSpeedEditorBase.movementSpeedMultiplier.Value;
				___sprintMultiplier = 1f * PlayerSpeedEditorBase.sprintMultiplierMultiplier.Value;
				___jumpForce = 5f * PlayerSpeedEditorBase.jumpForceMultiplier.Value;
			}
		}
	}
}