Decompiled source of EnforcerPlateFix v1.0.0

plugins\EnforcerPlateFix.dll

Decompiled 11 hours ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace EnforcerPlateFix;

[BepInPlugin("com.YourName.EnforcerPlateFix", "EnforcerPlateFix", "1.1.5")]
public class EnforcerPlateFixPlugin : BaseUnityPlugin
{
	public void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.YourName.EnforcerPlateFix");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(PressurePlateController), "SetSwitch")]
public class PressurePlatePatch
{
	public static void Prefix(PressurePlateController __instance, ref bool switchIsDown)
	{
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		if (switchIsDown || !__instance.enableOverlapSphere)
		{
			return;
		}
		bool flag = false;
		foreach (HoldoutZoneController instances in InstanceTracker.GetInstancesList<HoldoutZoneController>())
		{
			if (!((Object)(object)instances != (Object)null))
			{
				continue;
			}
			string text = ((Object)((Component)instances).gameObject).name.ToUpper();
			string text2 = ((Object)((Component)instances).transform.root).name.ToUpper();
			if (text.Contains("ENFORCER") || text2.Contains("ENFORCER") || text.Contains("RALLY") || text2.Contains("RALLY") || text.Contains("BEACON") || text2.Contains("BEACON"))
			{
				Vector3 position = ((Component)__instance).transform.position;
				Vector3 position2 = ((Component)instances).transform.position;
				float num = Vector2.Distance(new Vector2(position.x, position.z), new Vector2(position2.x, position2.z));
				float num2 = Mathf.Abs(position.y - position2.y);
				if (num <= __instance.overlapSphereRadius && num2 <= 1.5f)
				{
					flag = true;
					break;
				}
			}
		}
		if (!flag)
		{
			Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, __instance.overlapSphereRadius, -1, (QueryTriggerInteraction)2);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null)
				{
					continue;
				}
				string text = ((Object)((Component)val).gameObject).name.ToUpper();
				string text2 = ((Object)((Component)val).transform.root).name.ToUpper();
				if (text.Contains("RALLY") || text2.Contains("RALLY") || text.Contains("BEACON") || text2.Contains("BEACON"))
				{
					flag = true;
					break;
				}
				Deployable componentInParent = ((Component)val).GetComponentInParent<Deployable>();
				if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.ownerMaster != (Object)null))
				{
					continue;
				}
				CharacterBody body = componentInParent.ownerMaster.GetBody();
				if ((Object)(object)body != (Object)null)
				{
					string text3 = ((((Object)body).name != null) ? ((Object)body).name.ToUpper() : "");
					string text4 = ((body.baseNameToken != null) ? body.baseNameToken.ToUpper() : "");
					if ((text3.Contains("ENFORCER") || text4.Contains("ENFORCER")) && (text.Contains("RALLY") || text2.Contains("RALLY") || text.Contains("BEACON") || text2.Contains("BEACON")))
					{
						flag = true;
						break;
					}
				}
			}
		}
		if (flag)
		{
			switchIsDown = true;
		}
	}
}