Decompiled source of FasterPunch v1.0.6

plugins/Faster Punch/FasterPunch.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FasterPunch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FasterPunch")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("92548e93-e4ba-42d0-9122-7eac57741ec9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FasterPunch;

[BepInPlugin("ironfarm.uk.muda", "Faster Punch", "1.0.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static BoolValueChangeEventDelegate <>9__0_0;

		public static BoolValueChangeEventDelegate <>9__0_1;

		public static BoolValueChangeEventDelegate <>9__0_2;

		internal void <Start>b__0_0(BoolValueChangeEvent e)
		{
			((ConfigField)ConfigManager.PunchDelay).interactable = e.value;
			((ConfigField)ConfigManager.PunchDelay).hidden = !e.value;
		}

		internal void <Start>b__0_1(BoolValueChangeEvent e)
		{
			((ConfigField)ConfigManager.WhipThrowSpeed).interactable = e.value;
			((ConfigField)ConfigManager.WhipThrowSpeed).hidden = !e.value;
			((ConfigField)ConfigManager.WhipPullSpeed).interactable = e.value;
			((ConfigField)ConfigManager.WhipPullSpeed).hidden = !e.value;
		}

		internal void <Start>b__0_2(BoolValueChangeEvent e)
		{
			((ConfigField)ConfigManager.DamageUpType).interactable = e.value;
			((ConfigField)ConfigManager.DamageUpType).hidden = !e.value;
			((ConfigField)ConfigManager.ParryDamageAmount).interactable = e.value;
			((ConfigField)ConfigManager.ParryDamageAmount).hidden = !e.value;
		}
	}

	public void Start()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Expected O, but got Unknown
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Expected O, but got Unknown
		ConfigManager.config = PluginConfigurator.Create("Faster Punch", "ironfarm.uk.muda");
		ConfigManager.StandardEnabled = new BoolField(ConfigManager.config.rootPanel, "Fast Feedbacker", "field.standardenabled", true, true);
		ConfigManager.PunchDelay = new FloatField(ConfigManager.config.rootPanel, "Feedbacker Punch Delay", "field.punchDelay", 0f, 0f, 1f, true, true);
		BoolField standardEnabled = ConfigManager.StandardEnabled;
		object obj = <>c.<>9__0_0;
		if (obj == null)
		{
			BoolValueChangeEventDelegate val = delegate(BoolValueChangeEvent e)
			{
				((ConfigField)ConfigManager.PunchDelay).interactable = e.value;
				((ConfigField)ConfigManager.PunchDelay).hidden = !e.value;
			};
			<>c.<>9__0_0 = val;
			obj = (object)val;
		}
		standardEnabled.onValueChange += (BoolValueChangeEventDelegate)obj;
		ConfigManager.StandardEnabled.TriggerValueChangeEvent();
		ConfigManager.HeavyEnabled = new BoolField(ConfigManager.config.rootPanel, "Fast Knuckleblaster", "field.heavyenabled", true, true);
		ConfigManager.HookEnabled = new BoolField(ConfigManager.config.rootPanel, "Fast Whiplash", "field.hookenabled", true, true);
		ConfigManager.WhipThrowSpeed = new FloatField(ConfigManager.config.rootPanel, "Whiplash Throw Speed", "field.whipthrowspeed", 750f, 250f, 1500f, true, true);
		ConfigManager.WhipPullSpeed = new FloatField(ConfigManager.config.rootPanel, "Whiplash Pulling Speed", "field.whipcarryspeed", 120f, 60f, 540f, true, true);
		BoolField hookEnabled = ConfigManager.HookEnabled;
		object obj2 = <>c.<>9__0_1;
		if (obj2 == null)
		{
			BoolValueChangeEventDelegate val2 = delegate(BoolValueChangeEvent e)
			{
				((ConfigField)ConfigManager.WhipThrowSpeed).interactable = e.value;
				((ConfigField)ConfigManager.WhipThrowSpeed).hidden = !e.value;
				((ConfigField)ConfigManager.WhipPullSpeed).interactable = e.value;
				((ConfigField)ConfigManager.WhipPullSpeed).hidden = !e.value;
			};
			<>c.<>9__0_1 = val2;
			obj2 = (object)val2;
		}
		hookEnabled.onValueChange += (BoolValueChangeEventDelegate)obj2;
		ConfigManager.HookEnabled.TriggerValueChangeEvent();
		ConfigManager.ParryUpDamage = new BoolField(ConfigManager.config.rootPanel, "Parry Adds Damage", "field.parryupdamage", true, true);
		ConfigManager.DamageUpType = new EnumField<ConfigManager.IncreaseType>(ConfigManager.config.rootPanel, "Parry Damage Increase Type", "field.uptype", ConfigManager.IncreaseType.Additive);
		ConfigManager.ParryDamageAmount = new FloatField(ConfigManager.config.rootPanel, "Parry Damage Amount", "field.parrydamageamount", 1f, 1f, 100f, true, true);
		BoolField parryUpDamage = ConfigManager.ParryUpDamage;
		object obj3 = <>c.<>9__0_2;
		if (obj3 == null)
		{
			BoolValueChangeEventDelegate val3 = delegate(BoolValueChangeEvent e)
			{
				((ConfigField)ConfigManager.DamageUpType).interactable = e.value;
				((ConfigField)ConfigManager.DamageUpType).hidden = !e.value;
				((ConfigField)ConfigManager.ParryDamageAmount).interactable = e.value;
				((ConfigField)ConfigManager.ParryDamageAmount).hidden = !e.value;
			};
			<>c.<>9__0_2 = val3;
			obj3 = (object)val3;
		}
		parryUpDamage.onValueChange += (BoolValueChangeEventDelegate)obj3;
		ConfigManager.ParryUpDamage.TriggerValueChangeEvent();
		string text = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data"), "icon.png");
		ConfigManager.config.SetIconWithURL("file://" + text);
		new Harmony("ironfarm.uk.muda").PatchAll(typeof(PatchyMcPatchFace));
	}
}
public static class ConfigManager
{
	public enum IncreaseType
	{
		Additive,
		Multiplicitive
	}

	public static PluginConfigurator config;

	public static FloatField PunchDelay;

	public static FloatField WhipThrowSpeed;

	public static FloatField WhipPullSpeed;

	public static BoolField StandardEnabled;

	public static BoolField HeavyEnabled;

	public static BoolField HookEnabled;

	public static BoolField ParryUpDamage;

	public static EnumField<IncreaseType> DamageUpType;

	public static FloatField ParryDamageAmount;

	public static bool CheatCheck()
	{
		return StandardEnabled.value | HeavyEnabled.value | HookEnabled.value | ParryUpDamage.value;
	}
}
public class PatchyMcPatchFace
{
	public static bool tp = false;

	public static float tpDist = 5f;

	public static float punchWait = 0f;

	public static bool punchReady = true;

	[HarmonyPatch(typeof(Punch), "Update")]
	[HarmonyPrefix]
	public static void SpeedPunch(Punch __instance)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Invalid comparison between Unknown and I4
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		if ((!ConfigManager.StandardEnabled.value && !ConfigManager.HeavyEnabled.value) || __instance.shopping || GameStateManager.Instance.PlayerInputLocked)
		{
			return;
		}
		__instance.cooldownCost = 0f;
		if ((int)__instance.type == 0 && ConfigManager.StandardEnabled.value)
		{
			if (punchWait > ConfigManager.PunchDelay.value)
			{
				punchReady = true;
			}
			else
			{
				punchWait += Time.deltaTime;
			}
			FistActions fist = MonoSingleton<InputManager>.Instance.InputSource.Actions.Fist;
			if ((((FistActions)(ref fist)).PunchFeedbacker.IsPressed() || MonoSingleton<InputManager>.Instance.InputSource.Punch.IsPressed) && punchReady)
			{
				__instance.PunchStart();
				punchWait -= ConfigManager.PunchDelay.value;
				punchReady = false;
			}
			__instance.ReadyToPunch();
			__instance.cooldownCost = 0f;
		}
		if ((int)__instance.type == 1 && ConfigManager.HeavyEnabled.value)
		{
			__instance.ReadyToPunch();
			__instance.cooldownCost = 0f;
		}
	}

	[HarmonyPatch(typeof(Punch), "ParryProjectile")]
	[HarmonyPostfix]
	public static void ParryAddDamage(Punch __instance, Projectile proj)
	{
		if (ConfigManager.ParryUpDamage.value)
		{
			if (ConfigManager.DamageUpType.value == ConfigManager.IncreaseType.Additive)
			{
				proj.damage += ConfigManager.ParryDamageAmount.value;
			}
			else
			{
				proj.damage *= ConfigManager.ParryDamageAmount.value;
			}
		}
	}

	[HarmonyPatch(typeof(HookArm), "Update")]
	[HarmonyPrefix]
	public static void SpeedHook(HookArm __instance)
	{
		if (ConfigManager.HookEnabled.value)
		{
			__instance.cooldown = 0f;
			__instance.throwWarp = 0f;
		}
	}

	[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
	[HarmonyPrefix]
	public static void SpeedHook_FixedUpdate_Prefix(HookArm __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if ((int)__instance.state == 0 && __instance.returning)
		{
			__instance.hookPoint = __instance.hand.position;
		}
	}

	[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
	[HarmonyPostfix]
	public static void SpeedHook_FixedUpdate_Postfix(HookArm __instance)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Invalid comparison between Unknown and I4
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		if (!ConfigManager.HookEnabled.value)
		{
			return;
		}
		if ((int)__instance.state == 1)
		{
			__instance.hookPoint += __instance.throwDirection * (ConfigManager.WhipThrowSpeed.value - 250f) * Time.fixedDeltaTime;
		}
		if ((int)__instance.state == 3)
		{
			Vector3 val;
			if (__instance.lightTarget)
			{
				if ((Object)(object)__instance.enemyGroundCheck != (Object)null)
				{
					if (tp)
					{
						val = ((Component)MonoSingleton<NewMovement>.Instance).transform.position - __instance.hookPoint;
						if (((Vector3)(ref val)).magnitude > tpDist + 2f)
						{
							Rigidbody enemyRigidbody = __instance.enemyRigidbody;
							Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
							val = ((Component)MonoSingleton<NewMovement>.Instance).transform.position - __instance.hookPoint;
							enemyRigidbody.position = position - ((Vector3)(ref val)).normalized * (tpDist + 2.5f);
							tp = false;
						}
					}
					Rigidbody enemyRigidbody2 = __instance.enemyRigidbody;
					val = ((Component)MonoSingleton<NewMovement>.Instance).transform.position - __instance.hookPoint;
					enemyRigidbody2.velocity = ((Vector3)(ref val)).normalized * ConfigManager.WhipPullSpeed.value;
					return;
				}
				if (tp)
				{
					val = ((Component)MonoSingleton<CameraController>.Instance).transform.position - __instance.hookPoint;
					if (((Vector3)(ref val)).magnitude > tpDist + 2f)
					{
						Rigidbody enemyRigidbody3 = __instance.enemyRigidbody;
						Vector3 position2 = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
						val = ((Component)MonoSingleton<CameraController>.Instance).transform.position - __instance.hookPoint;
						enemyRigidbody3.position = position2 - ((Vector3)(ref val)).normalized * (tpDist + 2.5f);
						tp = false;
					}
				}
				Rigidbody enemyRigidbody4 = __instance.enemyRigidbody;
				val = ((Component)MonoSingleton<CameraController>.Instance).transform.position - __instance.hookPoint;
				enemyRigidbody4.velocity = ((Vector3)(ref val)).normalized * ConfigManager.WhipPullSpeed.value;
			}
			else
			{
				if (MonoSingleton<NewMovement>.Instance.boost && !MonoSingleton<NewMovement>.Instance.sliding)
				{
					return;
				}
				if (tp)
				{
					val = __instance.hookPoint - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
					if (((Vector3)(ref val)).magnitude > tpDist)
					{
						Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
						Vector3 hookPoint = __instance.hookPoint;
						val = __instance.hookPoint - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
						rb.position = hookPoint - ((Vector3)(ref val)).normalized * tpDist;
						tp = false;
					}
				}
				__instance.caughtEid = null;
				if (!MonoSingleton<NewMovement>.Instance.boost || MonoSingleton<NewMovement>.Instance.sliding)
				{
					Rigidbody rb2 = MonoSingleton<NewMovement>.Instance.rb;
					val = __instance.hookPoint - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
					rb2.velocity = ((Vector3)(ref val)).normalized * ConfigManager.WhipPullSpeed.value;
				}
			}
		}
		else
		{
			tp = true;
		}
	}

	[HarmonyPatch(typeof(LeaderboardController), "SubmitCyberGrindScore")]
	[HarmonyPrefix]
	public static bool no(LeaderboardController __instance)
	{
		return false;
	}

	[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
	[HarmonyPrefix]
	public static bool nope(LeaderboardController __instance)
	{
		return false;
	}

	[HarmonyPatch(typeof(LeaderboardController), "SubmitFishSize")]
	[HarmonyPrefix]
	public static bool notevenfish(LeaderboardController __instance)
	{
		return false;
	}
}
public class PluginInfo
{
	public const string Name = "Faster Punch";

	public const string GUID = "ironfarm.uk.muda";

	public const string Version = "1.0.6";
}