Decompiled source of NoBowSlowdown v1.0.0

NoBowSlowdown.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("NoBowSlowdown")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ReviOS 11 24.06")]
[assembly: AssemblyProduct("NoBowSlowdown")]
[assembly: AssemblyCopyright("Copyright © ReviOS 11 24.06 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4d2a84de-5c06-4906-92b3-c929cfef4e26")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("NoBowSlowdown", "NoBowSlowdown", "1.0")]
public class BowSpeedTest : BaseUnityPlugin
{
	public static ConfigEntry<bool> EnableSpeed;

	public static ConfigEntry<float> SpeedMultiplier;

	public static ConfigEntry<bool> EnableNoStamina;

	public static ConfigEntry<float> DrawSpeedMultiplier;

	private void Awake()
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		EnableSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Bow Movement", "Enable speed", true, "Turn on the speed boost when aiming");
		SpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bow Movement", "Speed multiplier", 1.6f, "Speed multiplier when pulling a bow");
		EnableNoStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Bow", "No stamina drain", true, "Disable endurance consumption during tension");
		DrawSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bow", "Draw speed multiplier", 2f, "Bow tension speed");
		Harmony val = new Harmony("NoBowSlowdown");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"NoBowSlowdown loaded!");
	}
}
[HarmonyPatch(typeof(Player), "InMinorActionSlowdown")]
public static class BowSlowdownPatch
{
	private static void Postfix(ref bool __result)
	{
		__result = false;
	}
}
[HarmonyPatch(typeof(Character), "UpdateWalking")]
public static class BowSpeedPatch
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		foreach (CodeInstruction instruction in instructions)
		{
			yield return instruction;
			int num;
			if (instruction.opcode == OpCodes.Callvirt)
			{
				object operand = instruction.operand;
				if (operand is MethodInfo method)
				{
					num = ((method.Name == "GetJogSpeedFactor") ? 1 : 0);
					goto IL_00de;
				}
			}
			num = 0;
			goto IL_00de;
			IL_00de:
			if (num != 0)
			{
				yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
				yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BowSpeedPatch), "MultiplyBowSpeed", (Type[])null, (Type[])null));
			}
		}
	}

	public static float MultiplyBowSpeed(float speed, Character character)
	{
		Player val = (Player)(object)((character is Player) ? character : null);
		if ((Object)(object)val == (Object)null)
		{
			return speed;
		}
		if (Traverse.Create((object)val).Field("m_attackHold").GetValue<bool>() && BowSpeedTest.EnableSpeed.Value)
		{
			return speed * BowSpeedTest.SpeedMultiplier.Value;
		}
		return speed;
	}
}
[HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")]
public static class NoBowStaminaPatch
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		if (!BowSpeedTest.EnableNoStamina.Value)
		{
			foreach (CodeInstruction instruction2 in instructions)
			{
				yield return instruction2;
			}
			yield break;
		}
		foreach (CodeInstruction instruction in instructions)
		{
			int num;
			if (instruction.opcode == OpCodes.Callvirt)
			{
				object operand = instruction.operand;
				if (operand is MethodInfo method)
				{
					num = ((method.Name == "UseStamina") ? 1 : 0);
					goto IL_0151;
				}
			}
			num = 0;
			goto IL_0151;
			IL_0151:
			if (num != 0)
			{
				yield return new CodeInstruction(OpCodes.Pop, (object)null);
				yield return new CodeInstruction(OpCodes.Pop, (object)null);
			}
			else
			{
				yield return instruction;
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")]
public static class BowDrawSpeedPatch
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		foreach (CodeInstruction instruction in instructions)
		{
			int num;
			if (instruction.opcode == OpCodes.Call)
			{
				object operand = instruction.operand;
				if (operand is MethodInfo method)
				{
					num = ((method.Name == "get_fixedDeltaTime") ? 1 : 0);
					goto IL_00d1;
				}
			}
			num = 0;
			goto IL_00d1;
			IL_00d1:
			if (num != 0)
			{
				yield return instruction;
				yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(BowSpeedTest), "DrawSpeedMultiplier"));
				yield return new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<float>), "Value"));
				yield return new CodeInstruction(OpCodes.Mul, (object)null);
			}
			else
			{
				yield return instruction;
			}
		}
	}
}