Decompiled source of CommandControlledFastFeets v2.1.0

TurboFeets.dll

Decompiled 5 months ago
using System;
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 TerminalApi;
using TerminalApi.Classes;
using TurboFeets.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("TurboFeets")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TurboFeets")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("31c22072-a437-4602-8b4b-e659cf28bdb5")]
[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 TurboFeets
{
	[BepInPlugin("LxsDev.TurboFeets", "Turbo Feets", "1.0.0")]
	public class TurboFeetsBase : BaseUnityPlugin
	{
		private const string modGUID = "LxsDev.TurboFeets";

		private const string modName = "Turbo Feets";

		private const string modVersion = "1.0.0";

		public readonly Harmony harmony = new Harmony("LxsDev.TurboFeets");

		private static TurboFeetsBase Instance;

		public static float speed = 18f;

		internal ManualLogSource Mlog;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Mlog = Logger.CreateLogSource(" LxsDev.TurboFeets");
			try
			{
				TerminalApi.AddCommand("feetspeed+1", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Increased by 1 \n NewSpeed: " + speed));
						speed += 1f;
						return "Feet Speed Increased by 1\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				TerminalApi.AddCommand("feetspeed-1", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Decreased by 1 \n NewSpeed: " + speed));
						speed -= 1f;
						if ((double)speed < 0.5)
						{
							speed = 0.5f;
						}
						return "Feet Speed Decreased by 1\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				TerminalApi.AddCommand("feetspeed+10", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Increased by 10 \n NewSpeed: " + speed));
						speed += 10f;
						return "Feet Speed Increased by 10\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				TerminalApi.AddCommand("feetspeed-10", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Decreased by 10 \n NewSpeed: " + speed));
						speed -= 10f;
						if ((double)speed < 0.5)
						{
							speed = 0.5f;
						}
						return "Feet Speed Decreased by 10\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				TerminalApi.AddCommand("feetspeed+100", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Increased by 100 \n NewSpeed: " + speed));
						speed += 100f;
						return "Feet Speed Increased by 100\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				TerminalApi.AddCommand("feetspeed-100", new CommandInfo
				{
					DisplayTextSupplier = delegate
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Speed Decreased by 100 \n NewSpeed: " + speed));
						speed -= 100f;
						if ((double)speed < 0.5)
						{
							speed = 0.5f;
						}
						return "Feet Speed Decreased by 100\n NewSpeed: " + speed + "\n\n";
					},
					Category = "Other"
				}, (string)null, true);
				Mlog.LogInfo((object)"Time to go fast...Katchow");
			}
			catch (Exception ex)
			{
				Mlog.LogError((object)("Error adding commands: " + ex.Message));
			}
			harmony.PatchAll(typeof(TurboFeetsBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace TurboFeets.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		public static float speed = TurboFeetsBase.speed;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchedUpdate(ref float ___sprintMeter, ref float ___movementSpeed, ref bool ___isSprinting)
		{
			speed = TurboFeetsBase.speed;
			___movementSpeed = speed;
			___sprintMeter = 1f;
			___isSprinting = true;
		}
	}
}