Decompiled source of RicochetAssist v1.0.0

plugins/RicochetAssist.dll

Decompiled a month 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.Decorators;
using PluginConfig.API.Fields;
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("RicochetAssist")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RicochetAssist")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("128f5857-fe39-43b0-9bb9-71d258a32957")]
[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 RicochetAssist;

[BepInPlugin("ironfarm.uk.ricomorty", "RicochetAssist", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	private Harmony harm;

	public void Start()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		Debug.Log((object)"We did dang dun it reddit");
		harm = new Harmony("ironfarm.uk.ricomorty");
		harm.PatchAll(typeof(RicochetMorty));
		ConfigManager.Setup();
	}
}
public static class ConfigManager
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static BoolValueChangeEventDelegate <>9__9_0;

		public static BoolValueChangeEventDelegate <>9__9_1;

		public static FloatValueChangeEventDelegate <>9__9_2;

		public static BoolValueChangeEventDelegate <>9__9_3;

		public static FloatValueChangeEventDelegate <>9__9_4;

		public static IntValueChangeEventDelegate <>9__9_5;

		public static BoolValueChangeEventDelegate <>9__9_6;

		public static IntValueChangeEventDelegate <>9__9_7;

		internal void <Setup>b__9_0(BoolValueChangeEvent e)
		{
			RicochetMorty.shouldVanillaAimAssist = e.value;
		}

		internal void <Setup>b__9_1(BoolValueChangeEvent e)
		{
			((ConfigField)RicochetFOV).hidden = !e.value;
			((ConfigField)TargetCoins).hidden = !e.value;
			RicochetMorty.shouldAimAssist = e.value;
		}

		internal void <Setup>b__9_2(FloatValueChangeEvent e)
		{
			RicochetMorty.ricFOV = e.value;
		}

		internal void <Setup>b__9_3(BoolValueChangeEvent e)
		{
			RicochetMorty.shouldTargetCoin = e.value;
		}

		internal void <Setup>b__9_4(FloatValueChangeEvent e)
		{
			RicochetMorty.ricTimer = e.value;
		}

		internal void <Setup>b__9_5(IntValueChangeEvent e)
		{
			RicochetMorty.ricBounceAmount = e.value;
		}

		internal void <Setup>b__9_6(BoolValueChangeEvent e)
		{
			((ConfigField)RailcannonExtraRicochet).hidden = !e.value;
			RicochetMorty.shouldRailBounce = e.value;
		}

		internal void <Setup>b__9_7(IntValueChangeEvent e)
		{
			RicochetMorty.railBounceAmount = e.value;
		}
	}

	public static PluginConfigurator config;

	public static BoolField AimAssistEnabled;

	public static BoolField VanillaAimAssistEnabled;

	public static FloatField RicochetFOV;

	public static BoolField TargetCoins;

	public static FloatField RicochetTimer;

	public static IntField SharpshooterExtraRicochet;

	public static BoolField RailcannonRicochetEnable;

	public static IntField RailcannonExtraRicochet;

	public static void Setup()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Expected O, but got Unknown
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Expected O, but got Unknown
		//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_01b1: Expected O, but got Unknown
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Expected O, but got Unknown
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Expected O, but got Unknown
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Expected O, but got Unknown
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Expected O, but got Unknown
		config = PluginConfigurator.Create("RicochetAssist", "ironfarm.uk.ricomorty");
		new ConfigHeader(config.rootPanel, "<color=red>Does not confict with modded aim assist</color>", 15);
		VanillaAimAssistEnabled = new BoolField(config.rootPanel, "Enable Vanilla Aim Assist", "bool.vanillaaimassist", false);
		AimAssistEnabled = new BoolField(config.rootPanel, "Enable Aim Assist", "bool.aimassist", true);
		RicochetFOV = new FloatField(config.rootPanel, "Ricochet FOV", "float.ricochetfov", 180f, 0f, 360f);
		TargetCoins = new BoolField(config.rootPanel, "Target Coins", "bool.targetcoins", true);
		new ConfigHeader(config.rootPanel, "<color=red>At 0, shots will ricochet while paused!</color>", 15);
		RicochetTimer = new FloatField(config.rootPanel, "Ricochet Timer", "float.ricochettimer", 0.1f, 0f, 100f);
		SharpshooterExtraRicochet = new IntField(config.rootPanel, "Extra Sharpshooter Ricochet", "int.sharpshooterextraricochet", 5, 0, 100000000);
		RailcannonRicochetEnable = new BoolField(config.rootPanel, "Enable Railcannon Ricochet", "bool.railcannonricochet", false);
		RailcannonExtraRicochet = new IntField(config.rootPanel, "Extra Railcannon Ricochet", "int.railcannonextraricochet", 5, 0, 100000000);
		BoolField vanillaAimAssistEnabled = VanillaAimAssistEnabled;
		object obj = <>c.<>9__9_0;
		if (obj == null)
		{
			BoolValueChangeEventDelegate val = delegate(BoolValueChangeEvent e)
			{
				RicochetMorty.shouldVanillaAimAssist = e.value;
			};
			<>c.<>9__9_0 = val;
			obj = (object)val;
		}
		vanillaAimAssistEnabled.onValueChange += (BoolValueChangeEventDelegate)obj;
		BoolField aimAssistEnabled = AimAssistEnabled;
		object obj2 = <>c.<>9__9_1;
		if (obj2 == null)
		{
			BoolValueChangeEventDelegate val2 = delegate(BoolValueChangeEvent e)
			{
				((ConfigField)RicochetFOV).hidden = !e.value;
				((ConfigField)TargetCoins).hidden = !e.value;
				RicochetMorty.shouldAimAssist = e.value;
			};
			<>c.<>9__9_1 = val2;
			obj2 = (object)val2;
		}
		aimAssistEnabled.onValueChange += (BoolValueChangeEventDelegate)obj2;
		FloatField ricochetFOV = RicochetFOV;
		object obj3 = <>c.<>9__9_2;
		if (obj3 == null)
		{
			FloatValueChangeEventDelegate val3 = delegate(FloatValueChangeEvent e)
			{
				RicochetMorty.ricFOV = e.value;
			};
			<>c.<>9__9_2 = val3;
			obj3 = (object)val3;
		}
		ricochetFOV.onValueChange += (FloatValueChangeEventDelegate)obj3;
		BoolField targetCoins = TargetCoins;
		object obj4 = <>c.<>9__9_3;
		if (obj4 == null)
		{
			BoolValueChangeEventDelegate val4 = delegate(BoolValueChangeEvent e)
			{
				RicochetMorty.shouldTargetCoin = e.value;
			};
			<>c.<>9__9_3 = val4;
			obj4 = (object)val4;
		}
		targetCoins.onValueChange += (BoolValueChangeEventDelegate)obj4;
		FloatField ricochetTimer = RicochetTimer;
		object obj5 = <>c.<>9__9_4;
		if (obj5 == null)
		{
			FloatValueChangeEventDelegate val5 = delegate(FloatValueChangeEvent e)
			{
				RicochetMorty.ricTimer = e.value;
			};
			<>c.<>9__9_4 = val5;
			obj5 = (object)val5;
		}
		ricochetTimer.onValueChange += (FloatValueChangeEventDelegate)obj5;
		IntField sharpshooterExtraRicochet = SharpshooterExtraRicochet;
		object obj6 = <>c.<>9__9_5;
		if (obj6 == null)
		{
			IntValueChangeEventDelegate val6 = delegate(IntValueChangeEvent e)
			{
				RicochetMorty.ricBounceAmount = e.value;
			};
			<>c.<>9__9_5 = val6;
			obj6 = (object)val6;
		}
		sharpshooterExtraRicochet.onValueChange += (IntValueChangeEventDelegate)obj6;
		BoolField railcannonRicochetEnable = RailcannonRicochetEnable;
		object obj7 = <>c.<>9__9_6;
		if (obj7 == null)
		{
			BoolValueChangeEventDelegate val7 = delegate(BoolValueChangeEvent e)
			{
				((ConfigField)RailcannonExtraRicochet).hidden = !e.value;
				RicochetMorty.shouldRailBounce = e.value;
			};
			<>c.<>9__9_6 = val7;
			obj7 = (object)val7;
		}
		railcannonRicochetEnable.onValueChange += (BoolValueChangeEventDelegate)obj7;
		IntField railcannonExtraRicochet = RailcannonExtraRicochet;
		object obj8 = <>c.<>9__9_7;
		if (obj8 == null)
		{
			IntValueChangeEventDelegate val8 = delegate(IntValueChangeEvent e)
			{
				RicochetMorty.railBounceAmount = e.value;
			};
			<>c.<>9__9_7 = val8;
			obj8 = (object)val8;
		}
		railcannonExtraRicochet.onValueChange += (IntValueChangeEventDelegate)obj8;
		VanillaAimAssistEnabled.TriggerValueChangeEvent();
		AimAssistEnabled.TriggerValueChangeEvent();
		RicochetFOV.TriggerValueChangeEvent();
		TargetCoins.TriggerValueChangeEvent();
		RicochetTimer.TriggerValueChangeEvent();
		SharpshooterExtraRicochet.TriggerValueChangeEvent();
		RailcannonRicochetEnable.TriggerValueChangeEvent();
		RailcannonExtraRicochet.TriggerValueChangeEvent();
		string path = Utils.ModDir();
		string text = Path.Combine(Path.Combine(path, "Data"), "icon.png");
		config.SetIconWithURL("file://" + text);
	}
}
public static class Utils
{
	public static bool WithinFOV(Vector3 main, Vector3 target, float fov)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Acos(Vector3.Dot(((Vector3)(ref main)).normalized, ((Vector3)(ref target)).normalized));
		float num2 = fov / 2f % 360f * ((float)Math.PI / 180f);
		return num <= num2 || num >= (float)Math.PI * 2f - num2;
	}

	public static string ModDir()
	{
		return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
	}
}
internal class PluginInfo
{
	public const string Name = "RicochetAssist";

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

	public const string Version = "1.0.0";
}
public static class RicochetMorty
{
	private static int ricochetCount = 0;

	private static int damCount = 0;

	public static float ricFOV = 180f;

	public static float ricTimer = 0.1f;

	public static bool shouldAimAssist = true;

	public static bool shouldVanillaAimAssist = false;

	public static bool shouldRailBounce = false;

	public static bool shouldTargetCoin = true;

	public static int railBounceAmount = 5;

	public static int ricBounceAmount = 5;

	private static bool eidCheck(EnemyIdentifier eid)
	{
		return (Object)(object)eid != (Object)null && !eid.dead && Object.op_Implicit((Object)(object)((Component)eid).gameObject) && !eid.blessed;
	}

	[HarmonyPatch(typeof(RevolverBeam), "RicochetAimAssist")]
	[HarmonyPrefix]
	public static bool TargetedHarassmentCampaign(RevolverBeam __instance)
	{
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: 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_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
		if (!shouldAimAssist)
		{
			return shouldVanillaAimAssist;
		}
		float num = float.PositiveInfinity;
		GameObject val = null;
		Transform val2 = null;
		EnemyIdentifier val3 = null;
		if (MonoSingleton<CoinList>.Instance.revolverCoinsList.Count > 0 && shouldTargetCoin)
		{
			RaycastHit val5 = default(RaycastHit);
			foreach (Coin revolverCoins in MonoSingleton<CoinList>.Instance.revolverCoinsList)
			{
				if (!((Object)(object)revolverCoins != (Object)null) || (revolverCoins.shot && !revolverCoins.shotByEnemy))
				{
					continue;
				}
				Vector3 val4 = ((Component)revolverCoins).transform.position - ((Component)__instance).transform.position;
				if (Utils.WithinFOV(((Component)__instance).transform.forward, val4, ricFOV))
				{
					float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
					if (sqrMagnitude < num && !Physics.Raycast(((Component)__instance).transform.position, val4, ref val5, Vector3.Distance(((Component)__instance).transform.position, ((Component)revolverCoins).transform.position) - 0.5f, LayerMask.op_Implicit(revolverCoins.lmask)))
					{
						val = ((Component)revolverCoins).gameObject;
						num = sqrMagnitude;
					}
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			num = float.PositiveInfinity;
			GameObject[] array = GameObject.FindGameObjectsWithTag("Enemy");
			RaycastHit val7 = default(RaycastHit);
			foreach (GameObject val6 in array)
			{
				Vector3 target = val6.transform.position - ((Component)__instance).transform.position;
				float sqrMagnitude2 = ((Vector3)(ref target)).sqrMagnitude;
				if (!(sqrMagnitude2 < num) || !Utils.WithinFOV(((Component)__instance).transform.forward, target, ricFOV))
				{
					continue;
				}
				val3 = val6.GetComponent<EnemyIdentifier>();
				if ((Object)(object)val3 != (Object)null && !val3.dead && Object.op_Implicit((Object)(object)((Component)val3).gameObject) && !val3.blessed)
				{
					if ((Object)(object)val3.weakPoint != (Object)null && val3.weakPoint.activeInHierarchy)
					{
						val2 = val3.weakPoint.transform;
					}
					else
					{
						EnemyIdentifierIdentifier componentInChildren = ((Component)val3).GetComponentInChildren<EnemyIdentifierIdentifier>();
						val2 = ((!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)componentInChildren.eid) || !((Object)(object)componentInChildren.eid == (Object)(object)val3)) ? ((Component)val3).transform : ((Component)componentInChildren).transform);
					}
					if (!Physics.Raycast(((Component)__instance).transform.position, val2.position - ((Component)__instance).transform.position, ref val7, Vector3.Distance(((Component)__instance).transform.position, val2.position) - 0.5f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1))))
					{
						val = ((Component)val2).gameObject;
						num = sqrMagnitude2;
					}
					else
					{
						val3 = null;
					}
				}
				else
				{
					val3 = null;
				}
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			((Component)__instance).gameObject.transform.LookAt(val.transform.position);
		}
		return shouldVanillaAimAssist;
	}

	[HarmonyPatch(typeof(RevolverBeam), "Start")]
	[HarmonyPrefix]
	public static bool RicochetForAll(RevolverBeam __instance)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Invalid comparison between Unknown and I4
		if ((Object)(object)__instance != (Object)null && !__instance.aimAssist)
		{
			if ((int)__instance.beamType == 1 && shouldRailBounce)
			{
				__instance.ricochetAmount += railBounceAmount;
				return true;
			}
			if (__instance.canHitProjectiles)
			{
				__instance.ricochetAmount += ricBounceAmount;
				return true;
			}
		}
		return true;
	}

	[HarmonyPatch(typeof(RevolverBeam), "PiercingShotCheck")]
	[HarmonyPrefix]
	public static void RicochetPreCheck(RevolverBeam __instance)
	{
		if ((Object)(object)MonoSingleton<DelayedActivationManager>.instance != (Object)null)
		{
			damCount = MonoSingleton<DelayedActivationManager>.instance.toActivate.Count;
		}
	}

	[HarmonyPatch(typeof(RevolverBeam), "PiercingShotCheck")]
	[HarmonyPostfix]
	public static void RicochetPostCheck(RevolverBeam __instance)
	{
		if (!((Object)(object)MonoSingleton<DelayedActivationManager>.instance != (Object)null) || damCount >= MonoSingleton<DelayedActivationManager>.instance.toActivate.Count)
		{
			return;
		}
		DelayedActivationManager instance = MonoSingleton<DelayedActivationManager>.instance;
		RevolverBeam val = default(RevolverBeam);
		for (int num = instance.toActivate.Count - 1; num >= 0; num--)
		{
			if (instance.toActivate[num].TryGetComponent<RevolverBeam>(ref val) && val.ricochetAmount == __instance.ricochetAmount)
			{
				instance.activateCountdowns[num] = ricTimer;
				break;
			}
		}
	}

	[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;
	}
}