Decompiled source of BarberSpeed v1.0.1

BarberSpeed.dll

Decompiled 4 months 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 HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoMoreCheatCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMoreCheatCompany")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fa45ba87-70ba-4d08-bcb5-fa8bb4d4232e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ClaySurgeonSpeedup;

[BepInPlugin("BarberSpeed", "BarberKillerMachine", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("BarberSpeed");

	private static ManualLogSource logger;

	public static ConfigEntry<float> SpeedMultiplier;

	private void Awake()
	{
		logger = ((BaseUnityPlugin)this).Logger;
		SpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SpeedMultiplier", 3f, "Multiplier for Barber's speed (default: 3)");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Plugin {0} is loaded! Speed multiplier set to {1}.", "BarberSpeed", SpeedMultiplier.Value));
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "BarberSpeed";

	public const string PLUGIN_NAME = "BarberKillerMachine";

	public const string PLUGIN_VERSION = "1.0.0";
}
[HarmonyPatch(typeof(ClaySurgeonAI))]
public static class ClaySurgeonAIPatch
{
	private static FieldInfo jumpTimerField;

	static ClaySurgeonAIPatch()
	{
		jumpTimerField = typeof(ClaySurgeonAI).GetField("jumpTimer", BindingFlags.Instance | BindingFlags.NonPublic);
	}

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	public static void StartPostfix(ClaySurgeonAI __instance)
	{
		__instance.jumpSpeed *= Plugin.SpeedMultiplier.Value;
		__instance.jumpTime /= Plugin.SpeedMultiplier.Value;
		__instance.startingInterval /= Plugin.SpeedMultiplier.Value;
		__instance.endingInterval /= Plugin.SpeedMultiplier.Value;
	}

	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	public static void UpdatePostfix(ClaySurgeonAI __instance)
	{
		if (__instance.isJumping)
		{
			((EnemyAI)__instance).agent.speed = __instance.jumpSpeed * Plugin.SpeedMultiplier.Value;
		}
	}

	[HarmonyPatch("DanceBeat")]
	[HarmonyPrefix]
	public static void DanceBeatPrefix(ClaySurgeonAI __instance)
	{
		if (__instance.isJumping && jumpTimerField != null)
		{
			float num = (float)jumpTimerField.GetValue(__instance);
			jumpTimerField.SetValue(__instance, num / Plugin.SpeedMultiplier.Value);
		}
	}

	[HarmonyPatch("HourChanged")]
	[HarmonyPostfix]
	public static void HourChangedPostfix(ClaySurgeonAI __instance)
	{
		__instance.currentInterval /= Plugin.SpeedMultiplier.Value;
	}
}