Decompiled source of UnseenHandTargeting v1.0.3

plugins/UnseenHandTargeting/UnseenHandTargeting.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Seeker;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.EntityStates.Seeker;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UnseenHandTargeting")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a87a5ba690b6f53bbb5204bdb9850e5d70a9a699")]
[assembly: AssemblyProduct("UnseenHandTargeting")]
[assembly: AssemblyTitle("UnseenHandTargeting")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UnseenHandTargeting
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("UnseenHandTargeting");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "UnseenHandTargeting".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.UnseenHandTargeting", "UnseenHandTargeting", "1.0.3")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Nuxlar.UnseenHandTargeting";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "UnseenHandTargeting";

		public const string PluginVersion = "1.0.3";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			UnseenHand.UpdateAreaIndicator += new hook_UpdateAreaIndicator(EnhanceAim);
		}

		private void EnhanceAim(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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)self.areaIndicatorInstance))
			{
				return;
			}
			bool num = self.goodPlacement;
			self.goodPlacement = false;
			self.areaIndicatorInstance.SetActive(true);
			float maxDistance = UnseenHand.maxDistance;
			float num2 = 0f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(CameraRigController.ModifyAimRayIfApplicable(((BaseState)self).GetAimRay(), ((EntityState)self).gameObject, ref num2), ref val, maxDistance + num2, LayerMask.op_Implicit(CommonMasks.bullet)))
			{
				Vector3 position = RaycastToFloor(((RaycastHit)(ref val)).point);
				self.areaIndicatorInstance.transform.position = position;
				self.goodPlacement = true;
			}
			int num3 = (self.goodPlacement ? 1 : 0);
			if ((num ? 1 : 0) != num3 || 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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, 200f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return position;
			}
			return ((RaycastHit)(ref val)).point;
		}
	}
}