Decompiled source of 3x Speed Modifier v1.0.0

plugins/3xSpeedMod.dll

Decompiled 6 months 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 UnityEngine;
using _3xSpeedMod.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("3xSpeedMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("3xSpeedMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("194e03da-bfcb-4155-abb2-33bc4774f28b")]
[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 _3xSpeedMod
{
	[BepInPlugin("minecart.3xSpeed", "3x Speed", "1.0.0.0")]
	public class SpeedModBase : BaseUnityPlugin
	{
		private const string modGUID = "minecart.3xSpeed";

		private const string modName = "3x Speed";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("minecart.3xSpeed");

		private static SpeedModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("minecart.3xSpeed");
			mls.LogInfo((object)"Speed Mod Loaded!");
			harmony.PatchAll(typeof(SpeedModBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace _3xSpeedMod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void PatchUpdate(ref float ___sprintMultiplier, ref bool ___isSprinting)
		{
			if (___isSprinting)
			{
				___sprintMultiplier = Mathf.Lerp(___sprintMultiplier, 6.75f, Time.deltaTime * 1f);
			}
			else
			{
				___sprintMultiplier = Mathf.Lerp(___sprintMultiplier, 1f, 10f * Time.deltaTime);
			}
		}
	}
}