Decompiled source of Expanded Aim Assist v0.5.6

plugins/GatekeeperAimAssist.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Doozy.Runtime.UIManager.Components;
using Gatekeeper.CameraScripts;
using Gatekeeper.CameraScripts.HUD.Aim;
using Gatekeeper.Char_Scripts.Aegis.Skills.SplinterStuff;
using Gatekeeper.Char_Scripts.General;
using Gatekeeper.Char_Scripts.General.Network;
using Gatekeeper.Char_Scripts.General.Skills;
using Gatekeeper.Char_Scripts.Mediator.CraniumScatterStuff;
using Gatekeeper.Enemy.Base;
using Gatekeeper.General.Events.Characters;
using Gatekeeper.General.Events.Network;
using Gatekeeper.Interfaces;
using Gatekeeper.MainMenuScripts.MainMenu.SettingsPanel;
using Gatekeeper.MainMenuScripts.MainMenu.SettingsPanel.KeyBindingSettings;
using Gatekeeper.MainMenuScripts.MainMenu.SettingsPanel.Lines;
using Gatekeeper.Other;
using GatekeeperAimAssist.Core;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GatekeeperAimAssist")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.6.0")]
[assembly: AssemblyInformationalVersion("0.5.6")]
[assembly: AssemblyProduct("GatekeeperAimAssist")]
[assembly: AssemblyTitle("GatekeeperAimAssist")]
[assembly: AssemblyVersion("0.5.6.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace GatekeeperAimAssist
{
	[BepInPlugin("com.prom.gatekeeper.aimassist", "Gatekeeper Aim Assist", "0.5.6")]
	[BepInProcess("Gatekeeper.exe")]
	public sealed class Plugin : BasePlugin
	{
		private sealed class ManualUpdatePatchState : IDisposable
		{
			private AimAssistRuntimeScope? _aimAssistScope;

			private IDisposable? _heldTargetDistanceScope;

			public ManualUpdatePatchState(AimAssistRuntimeScope aimAssistScope, IDisposable? heldTargetDistanceScope)
			{
				_aimAssistScope = aimAssistScope;
				_heldTargetDistanceScope = heldTargetDistanceScope;
			}

			public void Dispose()
			{
				Interlocked.Exchange(ref _aimAssistScope, null)?.Dispose();
				Interlocked.Exchange(ref _heldTargetDistanceScope, null)?.Dispose();
			}
		}

		private sealed class MeleeCharacterExclusionScope : IDisposable
		{
			private AimAssistInfo? _info;

			private Il2CppStructArray<CharacterType>? _original;

			public MeleeCharacterExclusionScope(AimAssistInfo info, Il2CppStructArray<CharacterType> original, Il2CppStructArray<CharacterType> filtered)
			{
				_info = info;
				_original = original;
				info._ExcludeCharacters_k__BackingField = filtered;
			}

			public void Dispose()
			{
				AimAssistInfo val = Interlocked.Exchange(ref _info, null);
				Il2CppStructArray<CharacterType> val2 = Interlocked.Exchange(ref _original, null);
				if (val != null && val2 != null)
				{
					val._ExcludeCharacters_k__BackingField = val2;
				}
			}
		}

		public const string PluginGuid = "com.prom.gatekeeper.aimassist";

		public const string PluginName = "Gatekeeper Aim Assist";

		public const string PluginVersion = "0.5.6";

		private static ManualLogSource PluginLog;

		private static GatekeeperRuntimeBindings Bindings;

		private static ConfigEntry<bool> Enabled;

		private static ConfigEntry<bool> EnableForMouseKeyboard;

		private static ConfigEntry<bool> EnableForMeleeCharacters;

		private static ConfigEntry<bool> EnableAimDiagnostics;

		private static ConfigEntry<bool> EnableMouseRetentionDiagnostics;

		private static ConfigEntry<bool> EnableInputScaledAssist;

		private static ConfigEntry<bool> EnableProjectileOriginCorrection;

		private static ConfigEntry<float> GamepadAimRange;

		private static ConfigEntry<float> CursorSphereRadius;

		private static ConfigEntry<float> CursorFollowSpeed;

		private static ConfigEntry<float> CursorBreakRadius;

		private static ConfigEntry<float> MouseFullAssistBelow;

		private static ConfigEntry<float> MouseZeroAssistAt;

		private static ConfigEntry<float> MouseHeldTargetBreakRadiusPixels;

		private static ConfigEntry<float> ControllerFullAssistBelow;

		private static ConfigEntry<float> ControllerZeroAssistAt;

		private static ConfigEntry<float> FrontSphereOffsetX;

		private static ConfigEntry<float> FrontSphereOffsetY;

		private static ConfigEntry<float> FrontSphereOffsetZ;

		private static ConfigEntry<float> FrontSphereRadius;

		private static ConfigEntry<float> FrontCursorAngleThreshold;

		private static KeyboardMouseAimAssistSetting KeyboardMouseSetting;

		private static int KbmOverrideLogged;

		private static bool MouseRetentionDiagnosticsActive;

		public override void Load()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0725: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0331: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Expected O, but got Unknown
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_039b: Expected O, but got Unknown
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Expected O, but got Unknown
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Expected O, but got Unknown
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Expected O, but got Unknown
			//IL_054a: Expected O, but got Unknown
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Expected O, but got Unknown
			//IL_059e: Expected O, but got Unknown
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Expected O, but got Unknown
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Expected O, but got Unknown
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Expected O, but got Unknown
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Expected O, but got Unknown
			PluginLog = ((BasePlugin)this).Log;
			BindConfiguration();
			KeyboardMouseSetting = new KeyboardMouseAimAssistSetting(() => EnableForMouseKeyboard.Value, delegate(bool value)
			{
				EnableForMouseKeyboard.Value = value;
				((BasePlugin)this).Config.Save();
			});
			KeyboardMouseSettingsMenu.Initialize(KeyboardMouseSetting, ((BasePlugin)this).Log);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Gatekeeper Aim Assist");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.5.6");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" starting (Enabled=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(Enabled.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", MouseKeyboard=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(EnableForMouseKeyboard.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
			}
			log.LogInfo(val);
			if (!Enabled.Value)
			{
				ManualLogSource log2 = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Gatekeeper Aim Assist");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is disabled by configuration; no patch applied.");
				}
				log2.LogInfo(val);
				return;
			}
			Harmony val2 = null;
			try
			{
				Bindings = GatekeeperRuntimeBindings.Resolve((Func<string, Type?>)AccessTools.TypeByName);
				MethodInfo methodInfo = RequireUniqueManualUpdate(Bindings.ControllerType);
				MethodInfo methodInfo2 = RequireInstanceMethod(Bindings.ControllerType, "CalculateDistance", typeof(Transform));
				MethodInfo methodInfo3 = RequireInstanceMethod(Bindings.ControllerType, "OwnerHandleCharacterAppeared", typeof(EventClientCharacterAppeared));
				MethodInfo methodInfo4 = RequireStaticBooleanGetter(Bindings.InputManagerType, "CurrentDeviceIsJoystick");
				Type declaringType = RequireType("Gatekeeper.MainMenuScripts.MainMenu.SettingsPanel.KeyBindingSettings.GamepadSettingsController");
				Type declaringType2 = RequireType("Gatekeeper.MainMenuScripts.MainMenu.SettingsPanel.KeyBindingSettings.KeyboardSettingsController");
				val2 = new Harmony("com.prom.gatekeeper.aimassist");
				bool flag2 = EnableProjectileOriginCorrection.Value || EnableAimDiagnostics.Value;
				MethodInfo methodInfo5 = (flag2 ? RequireInstanceMethod(typeof(SkillAimLogic), "GetSkillDirection", typeof(Vector3)) : null);
				MethodInfo methodInfo6 = (flag2 ? RequireInstanceMethod(typeof(CharProjectileSpawner), "ClientSpawnLocalProjectileInternal", typeof(NetworkProjectileSpawnData).MakeByRefType(), typeof(float)) : null);
				if (EnableAimDiagnostics.Value)
				{
					AimDiagnostics.Initialize(PluginLog);
					ManualLogSource log3 = ((BasePlugin)this).Log;
					val = new BepInExInfoLogInterpolatedStringHandler(51, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AIM_DIAG_HOOK resolved role=skill-direction method=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescribeMethod(methodInfo5));
					}
					log3.LogInfo(val);
					ManualLogSource log4 = ((BasePlugin)this).Log;
					val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AIM_DIAG_HOOK resolved role=local-spawn method=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescribeMethod(methodInfo6));
					}
					log4.LogInfo(val);
				}
				val2.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "CurrentDeviceIsJoystickPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val2.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ManualUpdatePrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ManualUpdateFinalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null);
				val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "CalculateDistancePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val2.Patch((MethodBase)methodInfo3, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OwnerHandleCharacterAppearedPrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OwnerHandleCharacterAppearedFinalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null);
				val2.Patch((MethodBase)RequireInstanceMethod(declaringType, "Awake"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "GamepadSettingsAwakePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val2.Patch((MethodBase)RequireInstanceMethod(declaringType2, "OnEnable"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "KeyboardSettingsOnEnablePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val2.Patch((MethodBase)RequireInstanceMethod(declaringType2, "KeyboardResetToDefault"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "KeyboardResetToDefaultPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				if (flag2)
				{
					MethodInfo methodInfo7 = RequirePatchMethod("GetSkillDirectionPostfix");
					HarmonyMethod val3 = ((!EnableAimDiagnostics.Value) ? ((HarmonyMethod)null) : new HarmonyMethod(RequirePatchMethod("GetSkillDirectionDiagnosticEntryPrefix")));
					val2.Patch((MethodBase)methodInfo5, val3, new HarmonyMethod(methodInfo7), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				if (EnableProjectileOriginCorrection.Value)
				{
					val2.Patch((MethodBase)RequireInstanceMethod(typeof(CharPlaneRay), "LookDirection"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "CharPlaneRayLookDirectionPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				if (flag2)
				{
					MethodInfo methodInfo8 = RequirePatchMethod("ClientSpawnLocalProjectileInternalPrefix");
					val2.Patch((MethodBase)methodInfo6, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					val2.Patch((MethodBase)RequireInstanceMethod(typeof(SplinterController), "ClientSpawnProjectile", typeof(Transform)), new HarmonyMethod(AccessTools.Method(typeof(Plugin), "SplinterClientSpawnProjectilePrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ProjectileConsumerFinalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null);
					val2.Patch((MethodBase)RequireInstanceMethod(typeof(MediatorCraniumScatterController), "ClientSpawnProjectile"), new HarmonyMethod(AccessTools.Method(typeof(Plugin), "MediatorClientSpawnProjectilePrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ProjectileConsumerFinalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null);
				}
				if (EnableAimDiagnostics.Value)
				{
					val2.Patch((MethodBase)RequireInstanceMethod(typeof(AimController), "LateUpdate"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "AimControllerLateUpdatePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					val2.Patch((MethodBase)RequireInstanceMethod(typeof(SkillAimLogic), "GetCursorRaycastHit"), (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "GetCursorRaycastHitPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					VerifyDiagnosticPatch(methodInfo5, RequirePatchMethod("GetSkillDirectionDiagnosticEntryPrefix"), prefix: true);
					VerifyDiagnosticPatch(methodInfo5, RequirePatchMethod("GetSkillDirectionPostfix"), prefix: false);
					VerifyDiagnosticPatch(methodInfo6, RequirePatchMethod("ClientSpawnLocalProjectileInternalPrefix"), prefix: true);
					((BasePlugin)this).Log.LogInfo((object)"Aim diagnostics are enabled. At each requested point, fire/place the ability, then press F8 once in order: center, top-left, top-right, bottom-left, bottom-right.");
					((BasePlugin)this).Log.LogInfo((object)"Close-range shared-path diagnostics log AIM_CLOSE records automatically for each GetSkillDirection call and matching local projectile spawn; no aim values are changed by logging.");
				}
				if (EnableMouseRetentionDiagnostics.Value)
				{
					TryEnableMouseRetentionDiagnostics(methodInfo);
				}
				ManualLogSource log5 = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(212, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Patched ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Bindings.ControllerType.FullName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".ManualUpdate(), scoped ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Bindings.InputManagerType.FullName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".CurrentDeviceIsJoystick, and attached the keyboard/mouse settings toggle. ProjectileOriginCorrection=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(EnableProjectileOriginCorrection.Value);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Existing target validity, LOS, exclusions and selection order are preserved.");
				}
				log5.LogInfo(val);
			}
			catch (Exception ex)
			{
				if (val2 != null)
				{
					val2.UnpatchSelf();
				}
				ManualLogSource log6 = ((BasePlugin)this).Log;
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(47, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("Gatekeeper Aim Assist");
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" failed closed; no aim-assist patch is active: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
				}
				log6.LogError(val4);
			}
		}

		private static void TryEnableMouseRetentionDiagnostics(MethodInfo manualUpdate)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			Harmony val = null;
			MouseRetentionDiagnosticsActive = false;
			try
			{
				MethodInfo methodInfo = RequireInstanceMethod(Bindings.ControllerType, "CalculateDistance", typeof(Transform));
				MethodInfo methodInfo2 = RequirePatchMethod("Complete", typeof(MouseRetentionDiagnostics));
				MethodInfo methodInfo3 = RequirePatchMethod("RecordCalculateDistance", typeof(MouseRetentionDiagnostics));
				val = new Harmony("com.prom.gatekeeper.aimassist.retention-diagnostic");
				val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val.Patch((MethodBase)manualUpdate, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MouseRetentionDiagnostics.Initialize(PluginLog);
				MouseRetentionDiagnosticsActive = true;
				LogDiagnosticPatch(methodInfo, methodInfo3);
				LogDiagnosticPatch(manualUpdate, methodInfo2);
			}
			catch (Exception ex)
			{
				if (val != null)
				{
					val.UnpatchSelf();
				}
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(91, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Mouse-retention diagnostics are unavailable; the working aim-assist patches remain active: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val2);
			}
		}

		private void BindConfiguration()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Expected O, but got Unknown
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Expected O, but got Unknown
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Expected O, but got Unknown
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Expected O, but got Unknown
			Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch. Restart the game after changing this value.");
			EnableForMouseKeyboard = ((BasePlugin)this).Config.Bind<bool>("General", "EnableForMouseKeyboard", true, "Temporarily opens the game's own aim-assist gate while mouse or keyboard is the current input device.");
			EnableForMeleeCharacters = ((BasePlugin)this).Config.Bind<bool>("General", "EnableForMeleeCharacters", true, "Enable the game's existing crosshair lock and pull for Nidum, Bastion, Void Model, and Maverick. Their attacks are unchanged.");
			EnableAimDiagnostics = ((BasePlugin)this).Config.Bind<bool>("Diagnostics", "EnableAimDiagnostics", false, "Passive diagnostic capture. Press F8 once at each instructed test point. No aim or gameplay values are changed.");
			EnableMouseRetentionDiagnostics = ((BasePlugin)this).Config.Bind<bool>("Diagnostics", "EnableMouseRetentionDiagnostics", false, "Temporary passive target-retention capture. Press F9 to start and stop; no aim values are changed.");
			EnableInputScaledAssist = ((BasePlugin)this).Config.Bind<bool>("Input Scaling", "EnableInputScaledAssist", true, "Reduce only the game's cursor-follow pull while the player is actively aiming.");
			MouseFullAssistBelow = ((BasePlugin)this).Config.Bind<float>("Input Scaling", "MouseFullAssistBelow", 0.05f, new ConfigDescription("Full assist at or below this mouse speed in screen-heights per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			MouseZeroAssistAt = ((BasePlugin)this).Config.Bind<float>("Input Scaling", "MouseZeroAssistAt", 0.75f, new ConfigDescription("Zero cursor-follow pull at or above this mouse speed in screen-heights per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			MouseHeldTargetBreakRadiusPixels = ((BasePlugin)this).Config.Bind<float>("Input Scaling", "MouseHeldTargetBreakRadiusPixels", 400f, new ConfigDescription("Mouse-only held-target break radius in screen pixels during strong input. Controller behavior is unchanged.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10000f), Array.Empty<object>()));
			ControllerFullAssistBelow = ((BasePlugin)this).Config.Bind<float>("Input Scaling", "ControllerFullAssistBelow", 0.15f, new ConfigDescription("Full assist at or below this processed right-stick magnitude.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ControllerZeroAssistAt = ((BasePlugin)this).Config.Bind<float>("Input Scaling", "ControllerZeroAssistAt", 0.85f, new ConfigDescription("Zero cursor-follow pull at or above this processed right-stick magnitude.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EnableProjectileOriginCorrection = ((BasePlugin)this).Config.Bind<bool>("Projectile Correction", "EnableProjectileOriginCorrection", true, "Correct cursor parallax for the five cursor-aimed ranged primaries. Target-lock aim and the native near-centre fail-safe are unchanged.");
			GamepadAimRange = ((BasePlugin)this).Config.Bind<float>("Acquisition", "GamepadAimRange", 2200f, new ConfigDescription("Screen-space cursor acquisition diameter. The game internally uses half this value as its pixel radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10000f), Array.Empty<object>()));
			CursorSphereRadius = ((BasePlugin)this).Config.Bind<float>("Acquisition", "CursorSphereRadius", 12f, new ConfigDescription("Radius of the game's cursor ray sphere-cast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			FrontSphereOffsetX = ((BasePlugin)this).Config.Bind<float>("Acquisition", "FrontSphereOffsetX", 0f, new ConfigDescription("World-space X component of the game's forward-search sphere offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			FrontSphereOffsetY = ((BasePlugin)this).Config.Bind<float>("Acquisition", "FrontSphereOffsetY", 0f, new ConfigDescription("World-space Y component of the game's forward-search sphere offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			FrontSphereOffsetZ = ((BasePlugin)this).Config.Bind<float>("Acquisition", "FrontSphereOffsetZ", 8f, new ConfigDescription("World-space Z component of the game's forward-search sphere offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			FrontSphereRadius = ((BasePlugin)this).Config.Bind<float>("Acquisition", "FrontSphereRadius", 30f, new ConfigDescription("Radius of the game's forward target-search sphere.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			FrontCursorAngleThreshold = ((BasePlugin)this).Config.Bind<float>("Acquisition", "FrontCursorAngleThreshold", 180f, new ConfigDescription("Maximum screen-space cursor angle that permits the forward-search fallback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>()));
			CursorFollowSpeed = ((BasePlugin)this).Config.Bind<float>("Tracking", "CursorFollowSpeed", 10f, new ConfigDescription("The game's target tracking speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			CursorBreakRadius = ((BasePlugin)this).Config.Bind<float>("Tracking", "CursorBreakRadius", 0.98f, new ConfigDescription("Multiplier used by the game's current-target break threshold.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

		private static MethodInfo RequireUniqueManualUpdate(Type controllerType)
		{
			MethodInfo methodInfo = null;
			MethodInfo[] methods = controllerType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo2 in methods)
			{
				if (!(methodInfo2.Name != "ManualUpdate") && methodInfo2.GetParameters().Length == 0)
				{
					if ((object)methodInfo != null)
					{
						throw new AmbiguousMatchException("More than one parameterless ManualUpdate method was found.");
					}
					methodInfo = methodInfo2;
				}
			}
			return methodInfo ?? throw new MissingMethodException(controllerType.FullName, "ManualUpdate()");
		}

		private static MethodInfo RequireStaticBooleanGetter(Type declaringType, string propertyName)
		{
			MethodInfo methodInfo = (declaringType.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingMemberException(declaringType.FullName, propertyName)).GetGetMethod(nonPublic: true) ?? throw new MissingMethodException(declaringType.FullName, "get_" + propertyName + "()");
			if (methodInfo.ReturnType != typeof(bool) || methodInfo.GetParameters().Length != 0)
			{
				throw new InvalidOperationException(declaringType.FullName + "." + propertyName + " is not a parameterless boolean getter.");
			}
			return methodInfo;
		}

		private static Type RequireType(string typeName)
		{
			return AccessTools.TypeByName(typeName) ?? throw new TypeLoadException(typeName);
		}

		private static MethodInfo RequireInstanceMethod(Type declaringType, string methodName)
		{
			return AccessTools.Method(declaringType, methodName, Type.EmptyTypes, (Type[])null) ?? throw new MissingMethodException(declaringType.FullName, methodName + "()");
		}

		private static MethodInfo RequireInstanceMethod(Type declaringType, string methodName, params Type[] parameterTypes)
		{
			return AccessTools.Method(declaringType, methodName, parameterTypes, (Type[])null) ?? throw new MissingMethodException(declaringType.FullName, methodName + "(" + string.Join(", ", parameterTypes.Select((Type type) => type.Name)) + ")");
		}

		private static MethodInfo RequirePatchMethod(string methodName)
		{
			return AccessTools.Method(typeof(Plugin), methodName, (Type[])null, (Type[])null) ?? throw new MissingMethodException(typeof(Plugin).FullName, methodName);
		}

		private static MethodInfo RequirePatchMethod(string methodName, Type declaringType)
		{
			return AccessTools.Method(declaringType, methodName, (Type[])null, (Type[])null) ?? throw new MissingMethodException(declaringType.FullName, methodName);
		}

		private static void LogDiagnosticPatch(MethodBase original, MethodInfo patchMethod)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			bool flag = Harmony.GetPatchInfo(original)?.Postfixes.Any((Patch patch) => patch.owner == "com.prom.gatekeeper.aimassist.retention-diagnostic" && patch.PatchMethod == patchMethod) ?? false;
			ManualLogSource pluginLog = PluginLog;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 3, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AIM_MOUSE_RETENTION_HOOK attach=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag ? "success" : "failure");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" target=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescribeMethod(original));
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patch=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescribeMethod(patchMethod));
			}
			pluginLog.LogInfo(val);
			if (!flag)
			{
				throw new InvalidOperationException("Retention diagnostic postfix did not attach to " + DescribeMethod(original) + ".");
			}
		}

		private static string DescribeMethod(MethodBase method)
		{
			string value = string.Join(",", from parameter in method.GetParameters()
				select parameter.ParameterType.FullName + " " + parameter.Name);
			string value2 = ((method is MethodInfo methodInfo) ? methodInfo.ReturnType.FullName : "void");
			return $"{method.Module.Assembly.GetName().Name}!{method.DeclaringType?.FullName}.{method.Name}({value})->{value2} token=0x{method.MetadataToken:X8} mvid={method.Module.ModuleVersionId}";
		}

		private static void VerifyDiagnosticPatch(MethodBase original, MethodInfo patchMethod, bool prefix)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			Patches val = Harmony.GetPatchInfo(original) ?? throw new InvalidOperationException("Harmony returned no patch registry entry for " + DescribeMethod(original) + ".");
			bool flag = (prefix ? val.Prefixes : val.Postfixes).Any((Patch patch) => patch.owner == "com.prom.gatekeeper.aimassist" && patch.PatchMethod == patchMethod);
			ManualLogSource pluginLog = PluginLog;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(42, 4, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AIM_DIAG_HOOK attach=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag ? "success" : "failure");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" kind=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(prefix ? "prefix" : "postfix");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" target=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DescribeMethod(original));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" patch=");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DescribeMethod(patchMethod));
			}
			pluginLog.LogInfo(val2);
			if (!flag)
			{
				throw new InvalidOperationException($"Required diagnostic {(prefix ? "prefix" : "postfix")} did not attach to {DescribeMethod(original)}.");
			}
		}

		private static void GamepadSettingsAwakePostfix(GamepadSettingsController __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			try
			{
				KeyboardMouseSettingsMenu.CaptureTemplate(__instance);
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(57, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not capture the native Aim Assist toggle template: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void KeyboardSettingsOnEnablePostfix(KeyboardSettingsController __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			try
			{
				KeyboardMouseSettingsMenu.Attach(__instance);
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(82, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not add the keyboard/mouse Aim Assist toggle; other settings are unchanged: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void KeyboardResetToDefaultPostfix()
		{
			KeyboardMouseSettingsMenu.ResetToDefault();
		}

		private static void AimControllerLateUpdatePostfix(AimController __instance)
		{
			AimDiagnostics.CaptureOnHotkey(__instance);
		}

		private static void GetCursorRaycastHitPostfix(ref RaycastHit __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			AimDiagnostics.RecordAbilityPlacement(__result);
		}

		private static void GetSkillDirectionDiagnosticEntryPrefix(SkillAimLogic __instance, Vector3 origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			try
			{
				AimDiagnostics.RecordGetSkillDirectionEntry(__instance, origin);
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AIM_CLOSE phase=get-skill-entry-error error=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void ClientSpawnLocalProjectileInternalPrefix(CharProjectileSpawner __instance, ref NetworkProjectileSpawnData spawnData)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (EnableAimDiagnostics.Value)
				{
					AimDiagnostics.RecordProjectile($"CharProjectileSpawner:{spawnData.ItemID}", spawnData.SpawnPosition, spawnData.SpawnDirection, ((Object)__instance).GetInstanceID());
				}
				if (EnableProjectileOriginCorrection.Value && ProjectileOriginCorrection.TryGetFrame(ProjectileCorrectionPath.MediatorCraniumScatter, out ProjectileCorrectionFrame frame) && (object)frame != null && frame.ExpectedConsumerInstanceId == ((Object)__instance).GetInstanceID() && !frame.SkillAimLogic._aimOnEnemy && ProjectileOriginCorrection.TryCorrect(frame.CharManager, spawnData.SpawnPosition, spawnData.SpawnDirection, out var correctedDirection))
				{
					spawnData.SpawnDirection = correctedDirection;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(56, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Projectile-origin correction skipped for a local spawn: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void SplinterClientSpawnProjectilePrefix(SplinterController __instance, Transform originTransform, out IDisposable? __state)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			try
			{
				if (Object.op_Implicit((Object)(object)originTransform) && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)((SkillController)__instance).CharManager) && Object.op_Implicit((Object)(object)((SkillController)__instance).CharManager.PlaneRay))
				{
					if (EnableProjectileOriginCorrection.Value && !((SkillController)__instance).SkillAimLogic._aimOnEnemy)
					{
						__state = ProjectileOriginCorrection.Enter(new ProjectileCorrectionFrame(ProjectileCorrectionPath.AegisSplinter, ((SkillController)__instance).CharManager, ((SkillController)__instance).SkillAimLogic, originTransform.position, ((Object)((SkillController)__instance).CharManager.PlaneRay).GetInstanceID()));
					}
					if (EnableAimDiagnostics.Value)
					{
						AimDiagnostics.RecordProjectile("Aegis:Splinter", originTransform.position, ((SkillController)__instance).CharManager.PlaneRay.LookDirection());
					}
				}
			}
			catch (Exception ex)
			{
				__state?.Dispose();
				__state = null;
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Aegis projectile-origin correction scope was not entered: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void MediatorClientSpawnProjectilePrefix(MediatorCraniumScatterController __instance, out IDisposable? __state)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			try
			{
				if (EnableProjectileOriginCorrection.Value && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)((SkillController)__instance).CharManager) && Object.op_Implicit((Object)(object)((SkillController)__instance).SkillAimLogic) && !((SkillController)__instance).SkillAimLogic._aimOnEnemy && Object.op_Implicit((Object)(object)((SkillController)__instance).CharManager.ProjectileSpawner))
				{
					__state = ProjectileOriginCorrection.Enter(new ProjectileCorrectionFrame(ProjectileCorrectionPath.MediatorCraniumScatter, ((SkillController)__instance).CharManager, ((SkillController)__instance).SkillAimLogic, Vector3.zero, ((Object)((SkillController)__instance).CharManager.ProjectileSpawner).GetInstanceID()));
				}
			}
			catch (Exception ex)
			{
				__state?.Dispose();
				__state = null;
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Mediator projectile-origin correction scope was not entered: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static Exception? ProjectileConsumerFinalizer(Exception? __exception, IDisposable? __state)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				__state?.Dispose();
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not exit a projectile-origin correction scope: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogError(val);
			}
			return __exception;
		}

		private static void GetSkillDirectionPostfix(SkillAimLogic __instance, Vector3 origin, ref Vector3 __result)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_001b: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.charManager))
				{
					return;
				}
				Vector3 nativeDirection = __result;
				bool aimOnEnemy = __instance._aimOnEnemy;
				bool flag = ProjectileOriginCorrection.IsDisplacedFromRoot(__instance.charManager, origin);
				ProjectileAimEvaluation? evaluation = null;
				bool correctionApplied = false;
				if (EnableProjectileOriginCorrection.Value && !aimOnEnemy && flag && ProjectileOriginCorrection.TryEvaluate(__instance.charManager, origin, nativeDirection, out var evaluation2))
				{
					evaluation = evaluation2;
					if (evaluation2.Result.Decision == ProjectileAimDecision.Corrected)
					{
						__result = ProjectileOriginCorrection.ToUnity(evaluation2.Result.Direction);
						correctionApplied = true;
					}
				}
				if (EnableAimDiagnostics.Value)
				{
					AimDiagnostics.RecordSharedCorrection(__instance.charManager, origin, nativeDirection, __result, aimOnEnemy, flag, correctionApplied, evaluation);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag2 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Shared projectile-origin correction skipped: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void CharPlaneRayLookDirectionPostfix(CharPlaneRay __instance, ref Vector3 __result)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (EnableProjectileOriginCorrection.Value && Object.op_Implicit((Object)(object)__instance) && ProjectileOriginCorrection.TryGetFrame(ProjectileCorrectionPath.AegisSplinter, out ProjectileCorrectionFrame frame) && (object)frame != null && frame.ExpectedConsumerInstanceId == ((Object)__instance).GetInstanceID() && !frame.SkillAimLogic._aimOnEnemy && ProjectileOriginCorrection.TryCorrect(frame.CharManager, frame.AegisOrigin, __result, out var correctedDirection))
				{
					__result = correctedDirection;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Aegis projectile-origin correction skipped: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val);
			}
		}

		private static void ManualUpdatePrefix(AimAssistController __instance, out ManualUpdatePatchState? __state)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			__state = null;
			IDisposable disposable = null;
			AimAssistRuntimeScope aimAssistRuntimeScope = null;
			try
			{
				if (!Enabled.Value)
				{
					return;
				}
				InputKind currentInputKind = Bindings.CurrentInputKind;
				float num = CurrentMouseVelocity(currentInputKind);
				AimAssistTuning tuning = ConfiguredTuning();
				float assistScale = 1f;
				if (EnableInputScaledAssist.Value)
				{
					assistScale = CurrentAssistScale(__instance, currentInputKind, num);
					tuning = InputScaledAimAssist.ApplyScale(tuning, assistScale);
				}
				if (MouseRetentionDiagnosticsActive)
				{
					MouseRetentionDiagnostics.Begin(__instance, currentInputKind, assistScale, tuning.GamepadAimRange, tuning.CursorBreakRadius);
				}
				if (EnableInputScaledAssist.Value)
				{
					disposable = BeginHeldTargetMouseDistance(__instance, currentInputKind, num, tuning.GamepadAimRange * 0.5f * tuning.CursorBreakRadius, out var heldTransformId, out var overrideArmed);
					if (MouseRetentionDiagnosticsActive)
					{
						MouseRetentionDiagnostics.RecordOverrideArm(heldTransformId, num, overrideArmed);
					}
				}
				aimAssistRuntimeScope = AimAssistRuntimeScope.Begin(Bindings.CreateState(__instance), EnableForMouseKeyboard.Value, currentInputKind, tuning);
				__state = new ManualUpdatePatchState(aimAssistRuntimeScope, disposable);
				aimAssistRuntimeScope = null;
				disposable = null;
			}
			catch (Exception ex)
			{
				aimAssistRuntimeScope?.Dispose();
				disposable?.Dispose();
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(74, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not apply the temporary aim-assist scope; this update is unchanged: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogError(val);
			}
		}

		private static Exception? ManualUpdateFinalizer(Exception? __exception, ManualUpdatePatchState? __state)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				__state?.Dispose();
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not restore temporary aim-assist values: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogError(val);
			}
			return __exception;
		}

		private static void CalculateDistancePostfix(AimAssistController __instance, Transform enemy, ref float __result)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0024: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)__instance._mainCamera))
				{
					float nativeBeforeOverride = __result;
					Vector3 val = __instance._mainCamera.WorldToScreenPoint(enemy.position);
					__result = HeldTargetMouseDistance.SelectSquaredDistance(((Il2CppObjectBase)enemy).Pointer.ToInt64(), val.x, val.y, __result);
					if (MouseRetentionDiagnosticsActive)
					{
						MouseRetentionDiagnostics.RecordOverrideEvaluation(((Il2CppObjectBase)enemy).Pointer.ToInt64(), val, nativeBeforeOverride, __result);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(87, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Physical-mouse held-target distance was not substituted; native distance is preserved: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val2);
			}
		}

		private static void CurrentDeviceIsJoystickPostfix(ref bool __result)
		{
			if (AimAssistRuntimeScope.ForceJoystickGateForCurrentThread)
			{
				__result = true;
				if (Interlocked.Exchange(ref KbmOverrideLogged, 1) == 0)
				{
					PluginLog.LogInfo((object)"Keyboard/mouse aim-assist path activated: the joystick-only guard is overridden only inside AimAssistController.ManualUpdate().");
				}
			}
		}

		private static void OwnerHandleCharacterAppearedPrefix(AimAssistController __instance, EventClientCharacterAppeared @event, out IDisposable? __state)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected I4, but got Unknown
			__state = null;
			try
			{
				if (!Enabled.Value || !EnableForMeleeCharacters.Value || @event == null)
				{
					return;
				}
				int characterType = (int)((BaseEventClient)@event).CharacterType;
				AimAssistInfo info = __instance.info;
				Il2CppStructArray<CharacterType> val = ((info != null) ? info._ExcludeCharacters_k__BackingField : null);
				if (info == null || val == null)
				{
					return;
				}
				int[] array = ((IEnumerable<CharacterType>)val).Select((CharacterType value) => (int)value).ToArray();
				int[] array2 = MeleeAimAssistPolicy.FilterNativeExclusions(EnableForMeleeCharacters.Value, characterType, (IReadOnlyCollection<int>)(object)array);
				if (array2.Length != array.Length)
				{
					Il2CppStructArray<CharacterType> val2 = new Il2CppStructArray<CharacterType>((long)array2.Length);
					for (int num = 0; num < array2.Length; num++)
					{
						((Il2CppArrayBase<CharacterType>)(object)val2)[num] = (CharacterType)array2[num];
					}
					__state = new MeleeCharacterExclusionScope(info, val, val2);
				}
			}
			catch (Exception ex)
			{
				__state?.Dispose();
				__state = null;
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(84, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Melee aim-assist appearance scope was not entered; native exclusions are unchanged: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogWarning(val3);
			}
		}

		private static Exception? OwnerHandleCharacterAppearedFinalizer(Exception? __exception, IDisposable? __state)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				__state?.Dispose();
			}
			catch (Exception ex)
			{
				ManualLogSource pluginLog = PluginLog;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not exit the melee aim-assist appearance scope: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				pluginLog.LogError(val);
			}
			return __exception;
		}

		private static AimAssistTuning ConfiguredTuning()
		{
			return new AimAssistTuning(GamepadAimRange.Value, CursorSphereRadius.Value, CursorFollowSpeed.Value, CursorBreakRadius.Value, FrontSphereOffsetX.Value, FrontSphereOffsetY.Value, FrontSphereOffsetZ.Value, FrontSphereRadius.Value, FrontCursorAngleThreshold.Value);
		}

		private static float CurrentMouseVelocity(InputKind inputKind)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if ((uint)(inputKind - 1) > 1u)
			{
				return 0f;
			}
			Mouse current = Mouse.current;
			Vector2 val = ((current != null) ? ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue() : Vector2.zero);
			return InputScaledAimAssist.ScreenHeightsPerSecond(val.x, val.y, Time.unscaledDeltaTime, Screen.height);
		}

		private static float CurrentAssistScale(AimAssistController controller, InputKind inputKind, float mouseMagnitude)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float controllerMagnitude = 0f;
			if (inputKind == InputKind.Joystick)
			{
				Vector2 rightStickVector = controller.aimController.RightStickVector;
				controllerMagnitude = ((Vector2)(ref rightStickVector)).magnitude;
			}
			return InputScaledAimAssist.ForInputKind(inputKind, mouseMagnitude, controllerMagnitude, MouseFullAssistBelow.Value, MouseZeroAssistAt.Value, ControllerFullAssistBelow.Value, ControllerZeroAssistAt.Value);
		}

		private static IDisposable? BeginHeldTargetMouseDistance(AimAssistController controller, InputKind inputKind, float mouseVelocity, float nativeBreakRadiusPixels, out long heldTransformId, out bool overrideArmed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			heldTransformId = 0L;
			overrideArmed = false;
			Mouse current = Mouse.current;
			IEnemy enemy = controller._enemy;
			if (current == null || enemy == null)
			{
				return null;
			}
			BodyParts bodyParts = new ICharacter(((Il2CppObjectBase)enemy).Pointer).BodyParts;
			if (bodyParts == null)
			{
				return null;
			}
			Transform centerPoint = bodyParts.CenterPoint;
			if (!Object.op_Implicit((Object)(object)centerPoint))
			{
				return null;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
			heldTransformId = ((Il2CppObjectBase)centerPoint).Pointer.ToInt64();
			bool flag = (uint)(inputKind - 1) <= 1u;
			overrideArmed = flag && float.IsFinite(mouseVelocity) && float.IsFinite(MouseZeroAssistAt.Value) && float.IsFinite(nativeBreakRadiusPixels) && nativeBreakRadiusPixels > 0f && float.IsFinite(MouseHeldTargetBreakRadiusPixels.Value) && MouseHeldTargetBreakRadiusPixels.Value > 0f && float.IsFinite(val.x) && float.IsFinite(val.y) && mouseVelocity >= MouseZeroAssistAt.Value;
			return HeldTargetMouseDistance.BeginForNativeRetentionPointPixels(inputKind, mouseVelocity, MouseZeroAssistAt.Value, nativeBreakRadiusPixels, MouseHeldTargetBreakRadiusPixels.Value, heldTransformId, val.x, val.y);
		}
	}
	internal sealed class GatekeeperRuntimeBindings
	{
		private const string ControllerTypeName = "Gatekeeper.CameraScripts.HUD.Aim.AimAssistController";

		private const string SaveManagerTypeName = "Gatekeeper.General.SaveLoad.SaveLoadManager";

		private const string InputManagerTypeName = "Gatekeeper.General.InputSystem.GameplayInputManager";

		private readonly ReflectionMemberAccessor _controllerInfo;

		private readonly ReflectionMemberAccessor _dataSave;

		private readonly ReflectionMemberAccessor _currentInputDevice;

		public Type ControllerType { get; }

		public Type InputManagerType { get; }

		public InputKind CurrentInputKind => InputKindMapper.FromGameValue(Convert.ToInt32(_currentInputDevice.Get(null)));

		public GatekeeperRuntimeBindings(Type controllerType, Type saveManagerType, Type inputManagerType)
		{
			ControllerType = controllerType;
			InputManagerType = inputManagerType;
			_controllerInfo = ReflectionMemberAccessor.Required(controllerType, "info", "Info");
			_dataSave = ReflectionMemberAccessor.Required(saveManagerType, "DataSave");
			_currentInputDevice = ReflectionMemberAccessor.Required(inputManagerType, "CurrentInputDeviceType");
		}

		public static GatekeeperRuntimeBindings Resolve(Func<string, Type?> typeResolver)
		{
			return new GatekeeperRuntimeBindings(typeResolver("Gatekeeper.CameraScripts.HUD.Aim.AimAssistController") ?? throw new TypeLoadException("Gatekeeper.CameraScripts.HUD.Aim.AimAssistController"), typeResolver("Gatekeeper.General.SaveLoad.SaveLoadManager") ?? throw new TypeLoadException("Gatekeeper.General.SaveLoad.SaveLoadManager"), typeResolver("Gatekeeper.General.InputSystem.GameplayInputManager") ?? throw new TypeLoadException("Gatekeeper.General.InputSystem.GameplayInputManager"));
		}

		public GatekeeperRuntimeState CreateState(object controller)
		{
			object? dataSave = _dataSave.Get(null) ?? throw new InvalidOperationException("SaveLoadManager.DataSave is null.");
			object info = _controllerInfo.Get(controller) ?? throw new InvalidOperationException("AimAssistController.info is null.");
			return new GatekeeperRuntimeState(dataSave, info);
		}
	}
	internal sealed class GatekeeperRuntimeState : IAimAssistRuntimeState
	{
		private sealed class VectorMembers
		{
			private readonly ReflectionMemberAccessor _x;

			private readonly ReflectionMemberAccessor _y;

			private readonly ReflectionMemberAccessor _z;

			public VectorMembers(Type vectorType)
			{
				_x = ReflectionMemberAccessor.Required(vectorType, "x");
				_y = ReflectionMemberAccessor.Required(vectorType, "y");
				_z = ReflectionMemberAccessor.Required(vectorType, "z");
			}

			public float ReadX(object vector)
			{
				return Convert.ToSingle(_x.Get(vector));
			}

			public float ReadY(object vector)
			{
				return Convert.ToSingle(_y.Get(vector));
			}

			public float ReadZ(object vector)
			{
				return Convert.ToSingle(_z.Get(vector));
			}

			public void Write(object vector, float x, float y, float z)
			{
				_x.Set(vector, x);
				_y.Set(vector, y);
				_z.Set(vector, z);
			}
		}

		private readonly object _dataSave;

		private readonly object _info;

		private readonly ReflectionMemberAccessor _aimAssistEnabled;

		private readonly ReflectionMemberAccessor _gamepadAimRange;

		private readonly ReflectionMemberAccessor _cursorSphereRadius;

		private readonly ReflectionMemberAccessor _cursorFollowSpeed;

		private readonly ReflectionMemberAccessor _cursorBreakRadius;

		private readonly ReflectionMemberAccessor _frontSphereOffset;

		private readonly ReflectionMemberAccessor _frontSphereRadius;

		private readonly ReflectionMemberAccessor _frontCursorAngleThreshold;

		public bool AimAssistEnabled
		{
			get
			{
				return Convert.ToBoolean(_aimAssistEnabled.Get(_dataSave));
			}
			set
			{
				_aimAssistEnabled.Set(_dataSave, value);
			}
		}

		public AimAssistTuning Tuning
		{
			get
			{
				object obj = _frontSphereOffset.Get(_info) ?? throw new InvalidOperationException("AimAssistInfo.FrontSphereOffset is null.");
				VectorMembers vectorMembers = new VectorMembers(obj.GetType());
				return new AimAssistTuning(ReadFloat(_gamepadAimRange, _dataSave), ReadFloat(_cursorSphereRadius, _info), ReadFloat(_cursorFollowSpeed, _info), ReadFloat(_cursorBreakRadius, _info), vectorMembers.ReadX(obj), vectorMembers.ReadY(obj), vectorMembers.ReadZ(obj), ReadFloat(_frontSphereRadius, _info), ReadFloat(_frontCursorAngleThreshold, _info));
			}
			set
			{
				_gamepadAimRange.Set(_dataSave, value.GamepadAimRange);
				_cursorSphereRadius.Set(_info, value.CursorSphereRadius);
				_cursorFollowSpeed.Set(_info, value.CursorFollowSpeed);
				_cursorBreakRadius.Set(_info, value.CursorBreakRadius);
				object obj = _frontSphereOffset.Get(_info) ?? throw new InvalidOperationException("AimAssistInfo.FrontSphereOffset is null.");
				new VectorMembers(obj.GetType()).Write(obj, value.FrontSphereOffsetX, value.FrontSphereOffsetY, value.FrontSphereOffsetZ);
				_frontSphereOffset.Set(_info, obj);
				_frontSphereRadius.Set(_info, value.FrontSphereRadius);
				_frontCursorAngleThreshold.Set(_info, value.FrontCursorAngleThreshold);
			}
		}

		public GatekeeperRuntimeState(object dataSave, object info)
		{
			_dataSave = dataSave;
			_info = info;
			_aimAssistEnabled = ReflectionMemberAccessor.Required(dataSave.GetType(), "IsGamepadAimAssistOn");
			_gamepadAimRange = ReflectionMemberAccessor.Required(dataSave.GetType(), "GamepadAimRange");
			_cursorSphereRadius = InfoMember("CursorSphereRadius");
			_cursorFollowSpeed = InfoMember("CursorFollowSpeed");
			_cursorBreakRadius = InfoMember("CursorBreakRadius");
			_frontSphereOffset = InfoMember("FrontSphereOffset");
			_frontSphereRadius = InfoMember("FrontSphereRadius");
			_frontCursorAngleThreshold = InfoMember("FrontCursorAngleThreshold");
		}

		private ReflectionMemberAccessor InfoMember(string propertyName)
		{
			return ReflectionMemberAccessor.Required(_info.GetType(), propertyName, "<" + propertyName + ">k__BackingField");
		}

		private static float ReadFloat(ReflectionMemberAccessor member, object instance)
		{
			return Convert.ToSingle(member.Get(instance));
		}
	}
	internal static class KeyboardMouseSettingsMenu
	{
		private const string CloneName = "GatekeeperAimAssist.KeyboardMouseToggle";

		private static ToggleSettingsLine? _template;

		private static ToggleSettingsLine? _toggleLine;

		private static Action<bool>? _toggleChanged;

		private static KeyboardMouseAimAssistSetting? _setting;

		private static ManualLogSource? _log;

		public static void Initialize(KeyboardMouseAimAssistSetting setting, ManualLogSource log)
		{
			_setting = setting;
			_log = log;
		}

		public static void CaptureTemplate(GamepadSettingsController controller)
		{
			if (!Object.op_Implicit((Object)(object)_template))
			{
				_template = controller.aimAssistToggle;
			}
		}

		public static void Attach(KeyboardSettingsController controller)
		{
			if (Object.op_Implicit((Object)(object)_toggleLine))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)_template))
			{
				foreach (GamepadSettingsController item in Resources.FindObjectsOfTypeAll<GamepadSettingsController>())
				{
					CaptureTemplate(item);
					if (Object.op_Implicit((Object)(object)_template))
					{
						break;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)_template))
			{
				throw new InvalidOperationException("The controller Aim Assist toggle template is not available yet.");
			}
			if (_setting == null)
			{
				throw new InvalidOperationException("The keyboard/mouse setting is not initialized.");
			}
			BaseSettingsLine val = KeyboardMouseMenuPlacement.FirstBinding((IEnumerable<BaseSettingsLine>)((Component)controller).GetComponentsInChildren<BaseSettingsLine>(true));
			Transform parent = ((Component)val).transform.parent;
			ToggleSettingsLine val2 = Object.Instantiate<ToggleSettingsLine>(_template, parent, false);
			((Object)((Component)val2).gameObject).name = "GatekeeperAimAssist.KeyboardMouseToggle";
			((Component)val2).transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex());
			Transform val3 = ((Component)val2).transform.Find("Text (TMP)");
			TMP_Text obj = (Object.op_Implicit((Object)(object)val3) ? ((Component)val3).GetComponent<TMP_Text>() : null);
			if (!Object.op_Implicit((Object)(object)obj))
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
				throw new InvalidOperationException("The cloned Aim Assist row has no Text (TMP) caption.");
			}
			obj.text = "AIM ASSIST";
			((UISelectable)val2.Toggle).isOn = _setting.Value;
			_toggleChanged = DelegateSupport.ConvertDelegate<Action<bool>>((Delegate)new Action<bool>(OnToggleChanged));
			val2.OnToggleValueChanged += _toggleChanged;
			_toggleLine = val2;
			ManualLogSource? log = _log;
			if (log != null)
			{
				log.LogInfo((object)"Added a labelled Aim Assist row before the first keyboard binding.");
			}
		}

		public static void ResetToDefault()
		{
			if (_setting == null)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)_toggleLine))
			{
				ToggleSettingsLine toggleLine = _toggleLine;
				if (!((UISelectable)toggleLine.Toggle).isOn)
				{
					((UISelectable)toggleLine.Toggle).isOn = true;
				}
				else
				{
					_setting.ResetToDefault();
				}
			}
			else
			{
				_setting.ResetToDefault();
			}
		}

		private static void OnToggleChanged(bool value)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			_setting?.Change(value);
			ManualLogSource log = _log;
			if (log != null)
			{
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(61, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Keyboard/mouse aim assist changed to ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value ? "On" : "Off");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from the settings menu.");
				}
				log.LogInfo(val);
			}
		}
	}
	internal static class AimDiagnostics
	{
		private readonly record struct ProjectileObservation(string Source, Vector3 Position, Vector3 Direction, int Frame);

		private readonly record struct PlacementObservation(Vector3 Point, string Collider, int Frame);

		private readonly record struct SharedCorrectionObservation(int Sample, int Frame, int SpawnerInstanceId, Vector3 Origin, Vector3 FinalDirection);

		private static ManualLogSource Log = null;

		private static DiagnosticCaptureSequence Sequence = new DiagnosticCaptureSequence();

		private static ProjectileObservation? LastProjectile;

		private static PlacementObservation? LastPlacement;

		private static int SampleNumber;

		private static int CloseRangeSampleNumber;

		private static int GetSkillDirectionEntryCount;

		private static int LocalSpawnEntryCount;

		private static bool CompletionLogged;

		[ThreadStatic]
		private static SharedCorrectionObservation? LastSharedCorrection;

		public static void Initialize(ManualLogSource log)
		{
			Log = log;
			Sequence = new DiagnosticCaptureSequence();
			LastProjectile = null;
			LastPlacement = null;
			SampleNumber = 0;
			CloseRangeSampleNumber = 0;
			GetSkillDirectionEntryCount = 0;
			LocalSpawnEntryCount = 0;
			CompletionLogged = false;
			LastSharedCorrection = null;
		}

		public static void RecordProjectile(string source, Vector3 position, Vector3 direction, int spawnerInstanceId = -1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			LastProjectile = new ProjectileObservation(source, position, direction, Time.frameCount);
			List<KeyValuePair<string, string>> fields = new List<KeyValuePair<string, string>>();
			Add(fields, "phase", "spawn-entry");
			Add(fields, "count", Interlocked.Increment(ref LocalSpawnEntryCount));
			Add(fields, "frame", Time.frameCount);
			Add(fields, "source", source);
			Add(fields, "spawner", spawnerInstanceId);
			Add(fields, "spawnPosition", V3(position));
			Add(fields, "spawnDirection", V3(direction));
			Log.LogInfo((object)DiagnosticRecordFormatter.FormatEvent("AIM_CLOSE", fields));
			SharedCorrectionObservation? lastSharedCorrection = LastSharedCorrection;
			if (lastSharedCorrection.HasValue)
			{
				SharedCorrectionObservation valueOrDefault = lastSharedCorrection.GetValueOrDefault();
				if (valueOrDefault.SpawnerInstanceId == spawnerInstanceId)
				{
					Vector3 value = position - valueOrDefault.Origin;
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(valueOrDefault.FinalDirection.x, 0f, valueOrDefault.FinalDirection.z);
					Vector3 val2 = default(Vector3);
					((Vector3)(ref val2))..ctor(direction.x, 0f, direction.z);
					float value2 = ((((Vector3)(ref val)).sqrMagnitude > 1E-08f && ((Vector3)(ref val2)).sqrMagnitude > 1E-08f) ? Vector3.Dot(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized) : float.NaN);
					List<KeyValuePair<string, string>> fields2 = new List<KeyValuePair<string, string>>();
					Add(fields2, "phase", "spawn");
					Add(fields2, "sample", valueOrDefault.Sample);
					Add(fields2, "frame", Time.frameCount);
					Add(fields2, "ageFrames", Time.frameCount - valueOrDefault.Frame);
					Add(fields2, "source", source);
					Add(fields2, "spawner", spawnerInstanceId);
					Add(fields2, "sharedOrigin", V3(valueOrDefault.Origin));
					Add(fields2, "spawnPosition", V3(position));
					Add(fields2, "originDelta", V3(value));
					Add(fields2, "originDeltaLength", N(((Vector3)(ref value)).magnitude));
					Add(fields2, "sharedFinal", V3(valueOrDefault.FinalDirection));
					Add(fields2, "spawnDirection", V3(direction));
					Add(fields2, "directionDot", N(value2));
					Log.LogInfo((object)DiagnosticRecordFormatter.FormatEvent("AIM_CLOSE", fields2));
				}
			}
		}

		public static void RecordGetSkillDirectionEntry(SkillAimLogic? instance, Vector3 origin)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<string, string>> fields = new List<KeyValuePair<string, string>>();
			Add(fields, "phase", "get-skill-entry");
			Add(fields, "count", Interlocked.Increment(ref GetSkillDirectionEntryCount));
			Add(fields, "frame", Time.frameCount);
			Add(fields, "instance", Object.op_Implicit((Object)(object)instance) ? ((Object)instance).GetInstanceID() : (-1));
			Add(fields, "origin", V3(origin));
			Log.LogInfo((object)DiagnosticRecordFormatter.FormatEvent("AIM_CLOSE", fields));
		}

		public static void RecordSharedCorrection(CharManager manager, Vector3 origin, Vector3 nativeDirection, Vector3 finalDirection, bool targetLock, bool originDisplaced, bool correctionApplied, ProjectileAimEvaluation? evaluation)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			int num = Interlocked.Increment(ref CloseRangeSampleNumber);
			int frameCount = Time.frameCount;
			int num2 = ((Object.op_Implicit((Object)(object)manager) && Object.op_Implicit((Object)(object)manager.ProjectileSpawner)) ? ((Object)manager.ProjectileSpawner).GetInstanceID() : (-1));
			LastSharedCorrection = new SharedCorrectionObservation(num, frameCount, num2, origin, finalDirection);
			List<KeyValuePair<string, string>> fields = new List<KeyValuePair<string, string>>();
			Mouse current = Mouse.current;
			Vector2 value = ((current != null) ? ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue() : Vector2.zero);
			Vector3 value2 = ((Object.op_Implicit((Object)(object)manager) && Object.op_Implicit((Object)(object)manager.CachedTransform)) ? manager.CachedTransform.position : Vector3.zero);
			Vector3 val = ((Object.op_Implicit((Object)(object)manager) && Object.op_Implicit((Object)(object)manager.CameraManager)) ? manager.CameraManager.GetAimPosition : Vector3.zero);
			Add(fields, "phase", "shared");
			Add(fields, "sample", num);
			Add(fields, "frame", frameCount);
			Add(fields, "character", Object.op_Implicit((Object)(object)manager) ? ((object)manager.CharacterType/*cast due to .constrained prefix*/).ToString() : "null");
			Add(fields, "spawner", num2);
			Add(fields, "rawMouse", V2(value));
			Add(fields, "aimScreen", V3(val));
			Add(fields, "screen", $"{Screen.width}x{Screen.height}");
			if (Object.op_Implicit((Object)(object)manager) && Object.op_Implicit((Object)(object)manager.CameraManager) && Object.op_Implicit((Object)(object)manager.CameraManager.MainCamera))
			{
				Ray val2 = manager.CameraManager.MainCamera.ScreenPointToRay(val);
				Add(fields, "screenRayOrigin", V3(((Ray)(ref val2)).origin));
				Add(fields, "screenRayDirection", V3(((Ray)(ref val2)).direction));
			}
			Add(fields, "root", V3(value2));
			Add(fields, "origin", V3(origin));
			Add(fields, "native", V3(nativeDirection));
			Add(fields, "targetLock", B(targetLock));
			Add(fields, "originDisplaced", B(originDisplaced));
			if (evaluation.HasValue)
			{
				ProjectileAimEvaluation valueOrDefault = evaluation.GetValueOrDefault();
				Add(fields, "candidate", V3(valueOrDefault.CandidateDirection));
				Add(fields, "nativeCandidateDot", N(valueOrDefault.NativeCandidateDot));
				Add(fields, "rootPlaneT", N(valueOrDefault.RootPlaneRayDistance));
				Add(fields, "rootPlanePoint", V3(valueOrDefault.RootPlanePoint));
				Add(fields, "rootPlaneRange", N(valueOrDefault.RootPlaneDistance));
				Add(fields, "deadZone", N(valueOrDefault.DeadZone));
				Add(fields, "translatedPlaneT", N(valueOrDefault.TranslatedPlaneRayDistance));
				Add(fields, "translatedPlanePoint", V3(valueOrDefault.TranslatedPlanePoint));
				Add(fields, "gateNonFinite", B(valueOrDefault.NonFiniteGate));
				Add(fields, "gateParallel", B(valueOrDefault.ParallelRayGate));
				Add(fields, "gateBehind", B(valueOrDefault.BehindCameraGate));
				Add(fields, "gateDeadZone", B(valueOrDefault.InsideDeadZoneGate));
				Add(fields, "gateDegenerate", B(valueOrDefault.DegenerateDirectionGate));
				Add(fields, "gateReversal", B(valueOrDefault.ReversalGate));
				Add(fields, "decision", valueOrDefault.Result.Decision.ToString());
			}
			else
			{
				Add(fields, "candidate", "not-evaluated");
				Add(fields, "decision", targetLock ? "TargetLock" : "OriginOrRuntimeGate");
			}
			Add(fields, "applied", B(correctionApplied));
			Add(fields, "final", V3(finalDirection));
			Log.LogInfo((object)DiagnosticRecordFormatter.FormatEvent("AIM_CLOSE", fields));
		}

		public static void RecordAbilityPlacement(RaycastHit hit)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Collider collider = ((RaycastHit)(ref hit)).collider;
			LastPlacement = new PlacementObservation(((RaycastHit)(ref hit)).point, Object.op_Implicit((Object)(object)collider) ? $"{((Object)collider).GetInstanceID()}:{((Object)collider).name}" : "none", Time.frameCount);
		}

		public static void CaptureOnHotkey(AimController aimController)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			try
			{
				Keyboard current = Keyboard.current;
				if (current == null || !((ButtonControl)current.f8Key).wasPressedThisFrame || !Sequence.TryTakeNext(Time.frameCount, out string label))
				{
					return;
				}
				if (label == null)
				{
					if (!CompletionLogged)
					{
						CompletionLogged = true;
						Log.LogInfo((object)"AIM_DIAG complete=1 requestedSamples=5");
					}
				}
				else
				{
					Log.LogInfo((object)BuildRecord(++SampleNumber, label, aimController));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AIM_DIAG captureFailed=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SingleLine(ex.ToString()));
				}
				log.LogWarning(val);
			}
		}

		private static string BuildRecord(int sampleNumber, string label, AimController aimController)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<string, string>> fields = new List<KeyValuePair<string, string>>();
			Mouse current = Mouse.current;
			Vector2 val = ((current != null) ? ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue() : Vector2.zero);
			RectTransform aimTransform = aimController.AimTransform;
			Vector3 val2 = (Object.op_Implicit((Object)(object)aimTransform) ? ((Transform)aimTransform).position : Vector3.zero);
			CharManager charManager = aimController._charManager;
			CameraManager val3 = (Object.op_Implicit((Object)(object)charManager) ? charManager.CameraManager : null);
			Camera main = Camera.main;
			Camera mainCamera = aimController._mainCamera;
			Camera val4 = (Object.op_Implicit((Object)(object)val3) ? val3.MainCamera : null);
			Canvas val5 = (Object.op_Implicit((Object)(object)aimTransform) ? ((Component)aimTransform).GetComponentInParent<Canvas>() : null);
			Camera val6 = ((Object.op_Implicit((Object)(object)val5) && (int)val5.renderMode != 0) ? val5.worldCamera : null);
			Add(fields, "frame", Time.frameCount);
			Add(fields, "rawMouse", V2(val));
			Add(fields, "legacyMouse", V3(Input.mousePosition));
			Add(fields, "screen", $"{Screen.width}x{Screen.height}");
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 3);
			Resolution currentResolution = Screen.currentResolution;
			defaultInterpolatedStringHandler.AppendFormatted(((Resolution)(ref currentResolution)).width);
			defaultInterpolatedStringHandler.AppendLiteral("x");
			currentResolution = Screen.currentResolution;
			defaultInterpolatedStringHandler.AppendFormatted(((Resolution)(ref currentResolution)).height);
			defaultInterpolatedStringHandler.AppendLiteral("@");
			currentResolution = Screen.currentResolution;
			defaultInterpolatedStringHandler.AppendFormatted<RefreshRate>(((Resolution)(ref currentResolution)).refreshRateRatio);
			Add(fields, "currentResolution", defaultInterpolatedStringHandler.ToStringAndClear());
			Add(fields, "safeArea", Rect(Screen.safeArea));
			Add(fields, "display", (Display.main == null) ? "null" : $"system={Display.main.systemWidth}x{Display.main.systemHeight},render={Display.main.renderingWidth}x{Display.main.renderingHeight}");
			Add(fields, "reticlePos", V3(val2));
			Add(fields, "reticleAnchored", Object.op_Implicit((Object)(object)aimTransform) ? V2(aimTransform.anchoredPosition) : "null");
			Add(fields, "reticlePivot", Object.op_Implicit((Object)(object)aimTransform) ? V2(aimTransform.pivot) : "null");
			Add(fields, "reticleAnchors", Object.op_Implicit((Object)(object)aimTransform) ? (V2(aimTransform.anchorMin) + ".." + V2(aimTransform.anchorMax)) : "null");
			Add(fields, "reticleSize", Object.op_Implicit((Object)(object)aimTransform) ? V2(aimTransform.sizeDelta) : "null");
			Add(fields, "reticleScale", Object.op_Implicit((Object)(object)aimTransform) ? V3(((Transform)aimTransform).lossyScale) : "null");
			Add(fields, "canvas", ObjectId((Object?)(object)val5));
			Add(fields, "canvasMode", Object.op_Implicit((Object)(object)val5) ? ((object)val5.renderMode/*cast due to .constrained prefix*/).ToString() : "null");
			Add(fields, "canvasScale", Object.op_Implicit((Object)(object)val5) ? N(val5.scaleFactor) : "null");
			Add(fields, "canvasCamera", ObjectId((Object?)(object)val6));
			Add(fields, "reticleToScreen", Object.op_Implicit((Object)(object)aimTransform) ? V2(RectTransformUtility.WorldToScreenPoint(val6, val2)) : "null");
			AddCanvasConversion(fields, val5, val6, val);
			Add(fields, "Camera.main", CameraData(main));
			Add(fields, "AimController.camera", CameraData(mainCamera));
			Add(fields, "CameraManager.MainCamera", CameraData(val4));
			Add(fields, "cameraIdentity", $"main==aim:{Same((Object?)(object)main, (Object?)(object)mainCamera)},main==manager:{Same((Object?)(object)main, (Object?)(object)val4)},aim==manager:{Same((Object?)(object)mainCamera, (Object?)(object)val4)}");
			Vector3 val7 = ((Object.op_Implicit((Object)(object)charManager) && Object.op_Implicit((Object)(object)charManager.CachedTransform)) ? charManager.CachedTransform.position : Vector3.zero);
			Add(fields, "character", Object.op_Implicit((Object)(object)charManager) ? $"{charManager.CharacterType}:{ObjectId((Object?)(object)charManager)}" : "null");
			Add(fields, "root", Object.op_Implicit((Object)(object)charManager) ? V3(val7) : "null");
			if (Object.op_Implicit((Object)(object)val4))
			{
				Ray val8 = val4.ScreenPointToRay(val2);
				Ray value = val4.ScreenPointToRay(Vector2.op_Implicit(val));
				Add(fields, "reticleRay", Ray(val8));
				Add(fields, "rawRay", Ray(value));
				Add(fields, "rayDelta", V3(((Ray)(ref value)).direction - ((Ray)(ref val8)).direction));
				AddWorldHit(fields, val3, val8);
				AddTrajectory(fields, val4, charManager, val7);
			}
			else
			{
				Add(fields, "reticleRay", "no-camera");
				Add(fields, "worldHit", "no-camera");
			}
			if (Object.op_Implicit((Object)(object)charManager) && Object.op_Implicit((Object)(object)charManager.PlaneRay))
			{
				Add(fields, "planeMousePoint", V3(charManager.PlaneRay.MousePoint()));
				Add(fields, "rootLookDirection", V3(charManager.PlaneRay.LookDirection()));
			}
			ProjectileObservation? lastProjectile = LastProjectile;
			if (lastProjectile.HasValue)
			{
				ProjectileObservation valueOrDefault = lastProjectile.GetValueOrDefault();
				Add(fields, "projectileSource", valueOrDefault.Source);
				Add(fields, "muzzle", V3(valueOrDefault.Position));
				Add(fields, "projectileDirection", V3(valueOrDefault.Direction));
				Add(fields, "projectileAgeFrames", Time.frameCount - valueOrDefault.Frame);
			}
			else
			{
				Add(fields, "projectileSource", "none");
				Add(fields, "muzzle", "none");
				Add(fields, "projectileDirection", "none");
			}
			PlacementObservation? lastPlacement = LastPlacement;
			if (lastPlacement.HasValue)
			{
				PlacementObservation valueOrDefault2 = lastPlacement.GetValueOrDefault();
				Add(fields, "abilityPlacement", V3(valueOrDefault2.Point));
				Add(fields, "abilityCollider", valueOrDefault2.Collider);
				Add(fields, "abilityAgeFrames", Time.frameCount - valueOrDefault2.Frame);
			}
			else
			{
				Add(fields, "abilityPlacement", "none");
			}
			return DiagnosticRecordFormatter.Format(sampleNumber, label, fields);
		}

		private static void AddCanvasConversion(ICollection<KeyValuePair<string, string>> fields, Canvas? canvas, Camera? canvasCamera, Vector2 rawMouse)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)canvas))
			{
				Add(fields, "rawToCanvasLocal", "no-canvas");
				return;
			}
			RectTransform component = ((Component)((Component)canvas).transform).GetComponent<RectTransform>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Add(fields, "rawToCanvasLocal", "no-rect");
				return;
			}
			Vector2 value = default(Vector2);
			bool flag = RectTransformUtility.ScreenPointToLocalPointInRectangle(component, rawMouse, canvasCamera, ref value);
			Add(fields, "rawToCanvasLocal", flag ? V2(value) : "failed");
			Add(fields, "canvasPixelRect", Rect(canvas.pixelRect));
		}

		private static void AddWorldHit(ICollection<KeyValuePair<string, string>> fields, CameraManager? cameraManager, Ray ray)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)cameraManager))
			{
				Add(fields, "worldHit", "no-manager");
				return;
			}
			float mouseHitDistance = cameraManager.mouseHitDistance;
			LayerMask mouseHitMask = cameraManager.mouseHitMask;
			RaycastHit val = default(RaycastHit);
			bool flag = Physics.Raycast(ray, ref val, mouseHitDistance, ((LayerMask)(ref mouseHitMask)).value);
			Add(fields, "worldHit", flag ? V3(((RaycastHit)(ref val)).point) : "none");
			Add(fields, "worldCollider", (flag && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider)) ? $"{((Object)((RaycastHit)(ref val)).collider).GetInstanceID()}:{((Object)((RaycastHit)(ref val)).collider).name}" : "none");
		}

		private static void AddTrajectory(ICollection<KeyValuePair<string, string>> fields, Camera camera, CharManager? charManager, Vector3 rootPosition)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_0119: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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)
			ProjectileObservation? lastProjectile = LastProjectile;
			if (!lastProjectile.HasValue)
			{
				return;
			}
			ProjectileObservation projectile = lastProjectile.GetValueOrDefault();
			Vector3 direction = projectile.Direction;
			Vector3 direction2 = ((Vector3)(ref direction)).normalized;
			Add(fields, "trajectoryScreen", string.Join