Decompiled source of UnseenHandTargeting v1.0.2

UnseenHandTargeting.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.Seeker;
using On.EntityStates.Seeker;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UnseenHandTargeting")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UnseenHandTargeting")]
[assembly: AssemblyTitle("UnseenHandTargeting")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UnseenHandTargeting;

[BepInPlugin("com.Nuxlar.UnseenHandTargeting", "UnseenHandTargeting", "1.0.2")]
public class UnseenHandTargeting : BaseUnityPlugin
{
	public void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		UnseenHand.UpdateAreaIndicator += (hook_UpdateAreaIndicator)delegate(orig_UpdateAreaIndicator orig, UnseenHand self)
		{
			//IL_0037: 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_004e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			bool goodPlacement = self.goodPlacement;
			self.goodPlacement = false;
			self.areaIndicatorInstance.SetActive(true);
			if (Object.op_Implicit((Object)(object)self.areaIndicatorInstance))
			{
				float maxDistance = UnseenHand.maxDistance;
				float num = 0f;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(CameraRigController.ModifyAimRayIfApplicable(((BaseState)self).GetAimRay(), ((EntityState)self).gameObject, ref num), ref val, maxDistance + num, LayerMask.op_Implicit(CommonMasks.bullet)))
				{
					Vector3? val2 = RaycastToFloor(((RaycastHit)(ref val)).point);
					if (val2.HasValue)
					{
						self.areaIndicatorInstance.transform.position = val2.Value;
						self.goodPlacement = true;
					}
					else if (Physics.Raycast(CameraRigController.ModifyAimRayIfApplicable(((BaseState)self).GetAimRay(), ((EntityState)self).gameObject, ref num), ref val, maxDistance + num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
					{
						self.areaIndicatorInstance.transform.position = ((RaycastHit)(ref val)).point;
						self.goodPlacement = (double)Vector3.Angle(Vector3.up, ((RaycastHit)(ref val)).normal) < (double)UnseenHand.maxSlopeAngle;
					}
				}
				else if (Physics.Raycast(CameraRigController.ModifyAimRayIfApplicable(((BaseState)self).GetAimRay(), ((EntityState)self).gameObject, ref num), ref val, maxDistance + num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
				{
					self.areaIndicatorInstance.transform.position = ((RaycastHit)(ref val)).point;
					self.goodPlacement = (double)Vector3.Angle(Vector3.up, ((RaycastHit)(ref val)).normal) < (double)UnseenHand.maxSlopeAngle;
				}
				if (goodPlacement != self.goodPlacement || self.crosshairOverrideRequest == null)
				{
					OverrideRequest crosshairOverrideRequest = self.crosshairOverrideRequest;
					if (crosshairOverrideRequest != null)
					{
						crosshairOverrideRequest.Dispose();
					}
					self.crosshairOverrideRequest = CrosshairUtils.RequestOverrideForBody(((EntityState)self).characterBody, self.goodPlacement ? UnseenHand.goodCrosshairPrefab : UnseenHand.badCrosshairPrefab, (OverridePriority)1);
				}
			}
			self.areaIndicatorInstance.SetActive(self.goodPlacement);
		};
	}

	private Vector3? RaycastToFloor(Vector3 position)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (!Physics.Raycast(new Ray(position, Vector3.down), ref val, 100f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
		{
			return null;
		}
		return ((RaycastHit)(ref val)).point;
	}
}