Decompiled source of DynamicCrosshair v1.0.0

plugins/DynamicCrosshair/DynamicCrosshair.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DynamicCrosshair")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("How to Fish - Dynamic Crosshair")]
[assembly: AssemblyTitle("DynamicCrosshair")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DynamicCrosshair
{
	internal struct AimSolution
	{
		public bool HasCenter;

		public Vector2 CenterScreen;

		public Vector3 CenterWorld;

		public float Distance;

		public bool HasRing;

		public Vector2[] Ring;

		public int RingCount;

		public float MeanRadiusPixels;

		public bool Blocked;
	}
	internal static class AimSolver
	{
		private static Vector2[] _ringBuffer = (Vector2[])(object)new Vector2[64];

		public static AimSolution Solve(AimInput a, PluginConfig cfg)
		{
			//IL_0036: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			AimSolution s = new AimSolution
			{
				Blocked = a.Blocked
			};
			Vector3 val = ((((Vector3)(ref a.Forward)).sqrMagnitude > 0f) ? ((Vector3)(ref a.Forward)).normalized : Vector3.forward);
			float maxRange = Mathf.Max(1f, cfg.MaxRange.Value);
			float travelTime = 0f;
			Vector3 val2 = (s.CenterWorld = (a.Blocked ? a.BlockedPoint : TracePath(a, val, maxRange, cfg, out travelTime)));
			Vector3 val3 = val2 - a.Origin;
			s.Distance = ((Vector3)(ref val3)).magnitude;
			Vector3 val4 = a.Cam.WorldToScreenPoint(val2);
			if (val4.z <= 0f)
			{
				return s;
			}
			s.HasCenter = true;
			s.CenterScreen = new Vector2(val4.x, val4.y);
			if (a.Blocked || a.SpreadDegrees <= 0.001f)
			{
				return s;
			}
			BuildRing(a, val, s.Distance, travelTime, maxRange, cfg, ref s);
			return s;
		}

		private static void BuildRing(AimInput a, Vector3 forward, float distance, float travelTime, float maxRange, PluginConfig cfg, ref AimSolution s)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0043: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Clamp(cfg.Segments.Value, 6, 64);
			EnsureBuffers(num);
			Vector3 val = Vector3.Cross((Mathf.Abs(forward.y) < 0.99f) ? Vector3.up : Vector3.right, forward);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = Vector3.Cross(forward, normalized);
			bool value = cfg.ConformToGeometry.Value;
			int num2 = 0;
			float num3 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num4 = MathF.PI * 2f / (float)num * (float)i;
				val = Quaternion.Euler((normalized * Mathf.Cos(num4) + val2 * Mathf.Sin(num4)) * a.SpreadDegrees) * forward;
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				float travelTime2;
				Vector3 val3 = (value ? TracePath(a, normalized2, maxRange, cfg, out travelTime2) : ((!a.HitScan) ? IntegrateNoCast(a, normalized2, travelTime) : (a.Origin + normalized2 * distance)));
				Vector3 val4 = a.Cam.WorldToScreenPoint(val3);
				if (val4.z <= 0f)
				{
					return;
				}
				_ringBuffer[i] = new Vector2(val4.x, val4.y);
				num3 += Vector2.Distance(_ringBuffer[i], s.CenterScreen);
				num2++;
			}
			if (num2 != num)
			{
				return;
			}
			float num5 = num3 / (float)num;
			if (float.IsNaN(num5) || float.IsInfinity(num5))
			{
				return;
			}
			float scale = cfg.Scale;
			float num6 = Mathf.Clamp(num5, cfg.MinRadiusPixels.Value * scale, cfg.MaxRadiusPixels.Value * scale);
			if (num5 > 0.001f && !Mathf.Approximately(num6, num5))
			{
				float num7 = num6 / num5;
				for (int j = 0; j < num; j++)
				{
					_ringBuffer[j] = s.CenterScreen + (_ringBuffer[j] - s.CenterScreen) * num7;
				}
				num5 = num6;
			}
			s.HasRing = true;
			s.Ring = _ringBuffer;
			s.RingCount = num;
			s.MeanRadiusPixels = num5;
		}

		private static void EnsureBuffers(int segments)
		{
			if (_ringBuffer.Length < segments)
			{
				_ringBuffer = (Vector2[])(object)new Vector2[segments];
			}
		}

		private static Vector3 TracePath(AimInput a, Vector3 dir, float maxRange, PluginConfig cfg, out float travelTime)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			travelTime = 0f;
			if (a.HitScan)
			{
				float num = maxRange;
				if (SphereOrRayCast(a.Origin, a.ProjectileRadius, dir, maxRange, a.HitLayerMask, out var hit))
				{
					num = ((RaycastHit)(ref hit)).distance;
				}
				float num2 = WaterCrossDistance(a, a.Origin, dir);
				if (num2 >= 0f && num2 < num)
				{
					num = num2;
				}
				return a.Origin + dir * num;
			}
			float num3 = ((Time.fixedDeltaTime > 0f) ? Time.fixedDeltaTime : 0.02f);
			int num4 = Mathf.Clamp(cfg.MaxSimulationSteps.Value, 1, 2000);
			float num5 = maxRange * maxRange;
			Vector3 val = a.Origin;
			Vector3 val2 = dir * a.ProjectileSpeed;
			for (int i = 0; i < num4; i++)
			{
				float num6 = ((Vector3)(ref val2)).magnitude * num3;
				if (num6 <= 0.0001f)
				{
					break;
				}
				if (SphereOrRayCast(val, a.ProjectileRadius, ((Vector3)(ref val2)).normalized, num6, a.HitLayerMask, out var hit2))
				{
					travelTime = num3 * ((float)i + Mathf.Clamp01(((RaycastHit)(ref hit2)).distance / num6));
					return ((RaycastHit)(ref hit2)).point;
				}
				Vector3 val3 = val + val2 * num3;
				if (a.HasWater && val3.y < a.WaterHeight && val.y >= a.WaterHeight)
				{
					float num7 = Mathf.Clamp01((val.y - a.WaterHeight) / Mathf.Max(0.0001f, val.y - val3.y));
					travelTime = num3 * ((float)i + num7);
					return Vector3.Lerp(val, val3, num7);
				}
				val = val3;
				val2 += Vector3.down * (a.Gravity * num3);
				travelTime = num3 * (float)(i + 1);
				Vector3 val4 = val - a.Origin;
				if (((Vector3)(ref val4)).sqrMagnitude >= num5)
				{
					break;
				}
			}
			return val;
		}

		private static Vector3 IntegrateNoCast(AimInput a, Vector3 dir, float travelTime)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0043: 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)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_007e: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Time.fixedDeltaTime > 0f) ? Time.fixedDeltaTime : 0.02f);
			Vector3 val = a.Origin;
			Vector3 val2 = dir * a.ProjectileSpeed;
			int num2 = Mathf.FloorToInt(travelTime / num);
			for (int i = 0; i < num2; i++)
			{
				val += val2 * num;
				val2 += Vector3.down * (a.Gravity * num);
			}
			float num3 = travelTime - (float)num2 * num;
			if (num3 > 0f)
			{
				val += val2 * num3;
			}
			return val;
		}

		private static float WaterCrossDistance(AimInput a, Vector3 origin, Vector3 dir)
		{
			//IL_0008: 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)
			//IL_002f: 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 (!a.HasWater || dir.y >= -0.0001f || origin.y <= a.WaterHeight)
			{
				return -1f;
			}
			return (a.WaterHeight - origin.y) / dir.y;
		}

		private static bool SphereOrRayCast(Vector3 origin, float radius, Vector3 dir, float distance, int mask, out RaycastHit hit)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (radius > 0.001f)
			{
				return Physics.SphereCast(origin, radius, dir, ref hit, distance, mask, (QueryTriggerInteraction)1);
			}
			return Physics.Raycast(origin, dir, ref hit, distance, mask, (QueryTriggerInteraction)1);
		}
	}
	internal sealed class CrosshairController : MonoBehaviour
	{
		private PluginConfig _cfg;

		private CrosshairGraphic _graphic;

		private bool _bound;

		private bool _gaveUp;

		private int _retryCountdown;

		private int _retries;

		private bool _hiddenByUser;

		private bool _dumpedWeaponTable;

		private string _debugText = string.Empty;

		private const int RetryInterval = 30;

		private const int MaxRetries = 300;

		private Vector2[] _testRing;

		public static CrosshairController Create(PluginConfig cfg)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("DynamicCrosshairOverlay");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas obj = val.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 30000;
			GameObject val2 = new GameObject("Crosshair");
			val2.transform.SetParent(val.transform, false);
			CrosshairGraphic crosshairGraphic = val2.AddComponent<CrosshairGraphic>();
			RectTransform rectTransform = ((Graphic)crosshairGraphic).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
			CrosshairController crosshairController = val.AddComponent<CrosshairController>();
			crosshairController._cfg = cfg;
			crosshairController._graphic = crosshairGraphic;
			((Behaviour)crosshairGraphic).enabled = false;
			return crosshairController;
		}

		private void LateUpdate()
		{
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (_cfg == null || (Object)(object)_graphic == (Object)null)
			{
				return;
			}
			if (!_cfg.Enabled.Value)
			{
				Hide();
				return;
			}
			if (Hotkey.Pressed(_cfg.ToggleKey.Value))
			{
				_hiddenByUser = !_hiddenByUser;
				Plugin.Log.LogInfo((object)("Crosshair " + (_hiddenByUser ? "hidden" : "shown") + " by hotkey."));
			}
			if (_hiddenByUser)
			{
				Hide();
				return;
			}
			bool flag = EnsureBound();
			if (_cfg.TestPattern.Value)
			{
				ShowTestPattern();
				return;
			}
			if (!flag)
			{
				Hide();
				return;
			}
			if (!GameBinding.TryRead(out var a))
			{
				Hide();
				return;
			}
			if (_cfg.DumpWeaponTable.Value && !_dumpedWeaponTable)
			{
				_dumpedWeaponTable = true;
				GameBinding.DumpWeaponTable();
			}
			if (_cfg.HideWithSniperScope.Value && a.SniperScopeActive)
			{
				Hide();
				return;
			}
			if (_cfg.HideWhileAiming.Value && a.AimPercent > 0.5f)
			{
				Hide();
				return;
			}
			if (a.Blocked && !_cfg.ShowBlockedIndicator.Value)
			{
				a.Blocked = false;
			}
			AimSolution s = AimSolver.Solve(a, _cfg);
			if (!s.HasCenter)
			{
				Hide();
				return;
			}
			ApplyAppearance(s.Blocked);
			((Behaviour)_graphic).enabled = true;
			_graphic.SetState(hasCenter: true, s.CenterScreen, s.Ring, s.RingCount, s.MeanRadiusPixels);
			if (_cfg.ShowDebugText.Value)
			{
				_debugText = BuildDebugText(a, s);
			}
		}

		private void ShowTestPattern()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			//IL_0064: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			if (_testRing == null)
			{
				_testRing = (Vector2[])(object)new Vector2[32];
			}
			for (int i = 0; i < 32; i++)
			{
				float num = MathF.PI / 16f * (float)i;
				_testRing[i] = val + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * 60f;
			}
			ApplyAppearance(blocked: false);
			((Behaviour)_graphic).enabled = true;
			_graphic.SetState(hasCenter: true, val, _testRing, 32, 60f);
			_debugText = "Dynamic Crosshair\nTestPattern is on - this ring is not real aim data.\nbinding     " + GameBinding.Status;
		}

		private void ApplyAppearance(bool blocked)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			float scale = _cfg.Scale;
			_graphic.SpreadStyle = _cfg.Spread.Value;
			_graphic.CenterStyle = _cfg.Center.Value;
			_graphic.RingColor = (blocked ? _cfg.BlockedColor : _cfg.MainColor);
			_graphic.CenterColor = (blocked ? _cfg.BlockedColor : _cfg.CenterColor);
			_graphic.OutlineColor = _cfg.OutlineColor;
			_graphic.Thickness = _cfg.Thickness.Value * scale;
			_graphic.OutlineWidth = _cfg.OutlineWidth.Value * scale;
			_graphic.CenterSize = _cfg.CenterSize.Value * scale;
			_graphic.CenterGap = _cfg.CenterGap.Value * scale;
			_graphic.CenterArmLength = _cfg.CenterArmLength.Value * scale;
			_graphic.TickLength = _cfg.TickLength.Value * scale;
			_graphic.DashCount = _cfg.DashCount.Value;
			_graphic.BracketArcDegrees = _cfg.BracketArcDegrees.Value;
		}

		private bool EnsureBound()
		{
			if (_bound)
			{
				return GameBinding.Ready;
			}
			if (_gaveUp)
			{
				return false;
			}
			if (--_retryCountdown > 0)
			{
				return false;
			}
			_retryCountdown = 30;
			if (Reflect.FindType("Player") == null)
			{
				if (++_retries > 300)
				{
					_gaveUp = true;
					Plugin.Log.LogError((object)"Gave up waiting for the game's script assembly to appear. Dynamic Crosshair will stay inactive for this session.");
				}
				return false;
			}
			_bound = true;
			GameBinding.Initialise();
			Plugin.Log.LogInfo((object)("Binding result: " + GameBinding.Status));
			return GameBinding.Ready;
		}

		private void Hide()
		{
			if (((Behaviour)_graphic).enabled)
			{
				_graphic.ClearState();
				((Behaviour)_graphic).enabled = false;
			}
			_debugText = string.Empty;
		}

		private static string BuildDebugText(AimInput a, AimSolution s)
		{
			return "Dynamic Crosshair\nspread      " + a.SpreadDegrees.ToString("0.###") + " deg cone\npellets     " + a.Pellets + "\ndelivery    " + (a.HitScan ? "hitscan" : ("projectile  speed " + a.ProjectileSpeed.ToString("0.#") + "  gravity " + a.Gravity.ToString("0.##"))) + "\nrange       " + s.Distance.ToString("0.0") + " m\non screen   " + s.MeanRadiusPixels.ToString("0.0") + " px radius\naim         " + (a.AimPercent * 100f).ToString("0") + "%" + (a.SniperScopeActive ? "  (scoped)" : string.Empty) + "\n" + (s.Blocked ? "muzzle      BLOCKED - shot lands at the obstruction\n" : string.Empty) + "binding     " + GameBinding.Status;
		}

		private void OnGUI()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (_cfg != null && _cfg.ShowDebugText.Value && _debugText.Length != 0)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(14f, 14f, 430f, 168f);
				GUI.Box(val, GUIContent.none);
				GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 16f, ((Rect)(ref val)).height - 12f), _debugText);
			}
		}
	}
	internal sealed class CrosshairGraphic : MaskableGraphic
	{
		public SpreadStyle SpreadStyle = SpreadStyle.Ring;

		public CenterStyle CenterStyle = CenterStyle.Plus;

		public Color RingColor = Color.white;

		public Color CenterColor = Color.white;

		public Color OutlineColor = new Color(0f, 0f, 0f, 0.78f);

		public float Thickness = 2f;

		public float OutlineWidth = 1.5f;

		public float CenterSize = 3f;

		public float CenterGap = 3f;

		public float CenterArmLength = 8f;

		public float TickLength = 9f;

		public int DashCount = 12;

		public float BracketArcDegrees = 34f;

		private Vector2[] _ring = (Vector2[])(object)new Vector2[64];

		private int _ringCount;

		private Vector2 _center;

		private bool _hasCenter;

		private bool _hasRing;

		private float _radius;

		private readonly Vector2[] _shape = (Vector2[])(object)new Vector2[24];

		private static readonly Vector2 Uv = Vector2.zero;

		protected override void Awake()
		{
			((UIBehaviour)this).Awake();
			((Graphic)this).raycastTarget = false;
			((Graphic)this).useLegacyMeshGeneration = false;
		}

		public void SetState(bool hasCenter, Vector2 center, Vector2[] ring, int ringCount, float radius)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			_hasCenter = hasCenter;
			_center = center;
			_radius = radius;
			_hasRing = ring != null && ringCount >= 3;
			if (_hasRing)
			{
				if (_ring.Length < ringCount)
				{
					_ring = (Vector2[])(object)new Vector2[ringCount];
				}
				for (int i = 0; i < ringCount; i++)
				{
					_ring[i] = ring[i];
				}
				_ringCount = ringCount;
			}
			else
			{
				_ringCount = 0;
			}
			((Graphic)this).SetVerticesDirty();
		}

		public void ClearState()
		{
			if (_hasCenter || _hasRing)
			{
				_hasCenter = false;
				_hasRing = false;
				_ringCount = 0;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			if (_hasCenter)
			{
				Rect rect = ((Graphic)this).rectTransform.rect;
				Vector2 min = ((Rect)(ref rect)).min;
				if (OutlineWidth > 0.01f && OutlineColor.a > 0.001f)
				{
					EmitPass(vh, min, OutlineColor, OutlineColor, OutlineWidth);
				}
				EmitPass(vh, min, RingColor, CenterColor, 0f);
			}
		}

		private void EmitPass(VertexHelper vh, Vector2 offset, Color ringColor, Color centerColor, float grow)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			float thickness = Thickness + grow * 2f;
			if (_hasRing)
			{
				switch (SpreadStyle)
				{
				case SpreadStyle.Ring:
					EmitRingBand(vh, offset, ringColor, thickness, 0, _ringCount, closed: true);
					break;
				case SpreadStyle.DashedRing:
					EmitDashedRing(vh, offset, ringColor, thickness);
					break;
				case SpreadStyle.Brackets:
					EmitBrackets(vh, offset, ringColor, thickness);
					break;
				case SpreadStyle.Ticks:
					EmitTicks(vh, offset, ringColor, thickness, grow);
					break;
				}
			}
			EmitCenter(vh, offset, centerColor, thickness, grow, !_hasRing);
		}

		private void EmitCenter(VertexHelper vh, Vector2 offset, Color color, float thickness, float grow, bool forceVisible)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0049: 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_006a: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			CenterStyle centerStyle = CenterStyle;
			if (centerStyle == CenterStyle.None && forceVisible)
			{
				centerStyle = CenterStyle.Dot;
			}
			Vector2 center = _center + offset;
			float num = CenterSize + grow;
			switch (centerStyle)
			{
			case CenterStyle.Dot:
				EmitDisc(vh, center, num, color);
				break;
			case CenterStyle.HollowDot:
				BuildCircle(num + Thickness * 0.5f, 16);
				EmitShapeBand(vh, offset, color, thickness, 16);
				break;
			case CenterStyle.Diamond:
				BuildDiamond((num + Thickness * 0.5f) * 1.5f);
				EmitShapeBand(vh, offset, color, thickness, 4);
				break;
			case CenterStyle.Plus:
				EmitArms(vh, center, color, thickness, grow, diagonal: false);
				break;
			case CenterStyle.Cross:
				EmitArms(vh, center, color, thickness, grow, diagonal: true);
				break;
			case CenterStyle.None:
				break;
			}
		}

		private void EmitArms(VertexHelper vh, Vector2 center, Color color, float thickness, float grow, bool diagonal)
		{
			//IL_003a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_005f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_008f: 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_009b: 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)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0f, CenterGap - grow);
			float num2 = CenterGap + CenterArmLength + grow;
			Vector2 val = (Vector2)(diagonal ? new Vector2(0.70710677f, 0.70710677f) : Vector2.up);
			Vector2 val2 = (Vector2)(diagonal ? new Vector2(0.70710677f, -0.70710677f) : Vector2.right);
			EmitQuad(vh, center + val * num, center + val * num2, thickness, color);
			EmitQuad(vh, center - val * num, center - val * num2, thickness, color);
			EmitQuad(vh, center + val2 * num, center + val2 * num2, thickness, color);
			EmitQuad(vh, center - val2 * num, center - val2 * num2, thickness, color);
		}

		private void BuildCircle(float radius, int points)
		{
			//IL_0018: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			for (int i = 0; i < points; i++)
			{
				float num = MathF.PI * 2f / (float)points * (float)i;
				_shape[i] = _center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius;
			}
		}

		private void BuildDiamond(float radius)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			_shape[0] = _center + Vector2.up * radius;
			_shape[1] = _center + Vector2.right * radius;
			_shape[2] = _center + Vector2.down * radius;
			_shape[3] = _center + Vector2.left * radius;
		}

		private void EmitShapeBand(VertexHelper vh, Vector2 offset, Color color, float thickness, int count)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			EmitBand(vh, offset, color, thickness, _shape, count, 0, count, closed: true);
		}

		private void EmitRingBand(VertexHelper vh, Vector2 offset, Color color, float thickness, int start, int count, bool closed)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			EmitBand(vh, offset, color, thickness, _ring, _ringCount, start, count, closed);
		}

		private void EmitDashedRing(VertexHelper vh, Vector2 offset, Color color, float thickness)
		{
			//IL_0037: 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)
			int ringCount = _ringCount;
			int num = Mathf.Clamp(DashCount, 2, ringCount / 2);
			float num2 = (float)ringCount / (float)num;
			int count = Mathf.Max(2, Mathf.RoundToInt(num2 * 0.55f));
			for (int i = 0; i < num; i++)
			{
				EmitRingBand(vh, offset, color, thickness, Mathf.RoundToInt((float)i * num2), count, closed: false);
			}
		}

		private void EmitBrackets(VertexHelper vh, Vector2 offset, Color color, float thickness)
		{
			//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)
			int ringCount = _ringCount;
			int num = Mathf.Max(1, Mathf.RoundToInt(BracketArcDegrees / 720f * (float)ringCount));
			for (int i = 0; i < 4; i++)
			{
				int num2 = Mathf.RoundToInt((float)(i * ringCount) / 4f);
				EmitRingBand(vh, offset, color, thickness, num2 - num, num * 2 + 1, closed: false);
			}
		}

		private void EmitTicks(VertexHelper vh, Vector2 offset, Color color, float thickness, float grow)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00b5: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = _center + offset;
			float num = Mathf.Max(0f, _radius - grow);
			float num2 = _radius + TickLength + grow;
			EmitQuad(vh, val + Vector2.up * num, val + Vector2.up * num2, thickness, color);
			EmitQuad(vh, val + Vector2.down * num, val + Vector2.down * num2, thickness, color);
			EmitQuad(vh, val + Vector2.left * num, val + Vector2.left * num2, thickness, color);
			EmitQuad(vh, val + Vector2.right * num, val + Vector2.right * num2, thickness, color);
		}

		private void EmitBand(VertexHelper vh, Vector2 offset, Color color, float thickness, Vector2[] points, int total, int start, int count, bool closed)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (total < 3 || count < 2)
			{
				return;
			}
			float num = thickness * 0.5f;
			int currentVertCount = vh.currentVertCount;
			Color32 val = Color32.op_Implicit(color);
			for (int i = 0; i < count; i++)
			{
				int num2 = Wrap(start + i, total);
				Vector2 val2 = points[num2];
				Vector2 val3 = val2 - _center;
				Vector2 val4;
				if (((Vector2)(ref val3)).sqrMagnitude > 1E-06f)
				{
					val4 = val3 / ((Vector2)(ref val3)).magnitude;
				}
				else
				{
					Vector2 val5 = points[Wrap(start + i + 1, total)] - val2;
					Vector2 val6;
					if (!(((Vector2)(ref val5)).sqrMagnitude > 1E-06f))
					{
						val6 = Vector2.up;
					}
					else
					{
						Vector2 val7 = new Vector2(0f - val5.y, val5.x);
						val6 = ((Vector2)(ref val7)).normalized;
					}
					val4 = val6;
				}
				Vector2 val8 = val2 + offset;
				vh.AddVert(Vector2.op_Implicit(val8 - val4 * num), val, Vector4.op_Implicit(Uv));
				vh.AddVert(Vector2.op_Implicit(val8 + val4 * num), val, Vector4.op_Implicit(Uv));
			}
			int num3 = (closed ? count : (count - 1));
			for (int j = 0; j < num3; j++)
			{
				int num4 = currentVertCount + j * 2;
				int num5 = currentVertCount + (j + 1) % count * 2;
				vh.AddTriangle(num4, num4 + 1, num5 + 1);
				vh.AddTriangle(num4, num5 + 1, num5);
			}
		}

		private static int Wrap(int index, int total)
		{
			return (index % total + total) % total;
		}

		private static void EmitQuad(VertexHelper vh, Vector2 from, Vector2 to, float thickness, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//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_002d: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0090: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = to - from;
			if (!(((Vector2)(ref val)).sqrMagnitude < 1E-06f))
			{
				Vector2 val2 = new Vector2(0f - val.y, val.x);
				Vector2 val3 = ((Vector2)(ref val2)).normalized * (thickness * 0.5f);
				int currentVertCount = vh.currentVertCount;
				Color32 val4 = Color32.op_Implicit(color);
				vh.AddVert(Vector2.op_Implicit(from - val3), val4, Vector4.op_Implicit(Uv));
				vh.AddVert(Vector2.op_Implicit(from + val3), val4, Vector4.op_Implicit(Uv));
				vh.AddVert(Vector2.op_Implicit(to + val3), val4, Vector4.op_Implicit(Uv));
				vh.AddVert(Vector2.op_Implicit(to - val3), val4, Vector4.op_Implicit(Uv));
				vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
				vh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
			}
		}

		private static void EmitDisc(VertexHelper vh, Vector2 center, float radius, Color color)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005e: 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)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (!(radius <= 0.01f))
			{
				int currentVertCount = vh.currentVertCount;
				Color32 val = Color32.op_Implicit(color);
				vh.AddVert(Vector2.op_Implicit(center), val, Vector4.op_Implicit(Uv));
				for (int i = 0; i < 14; i++)
				{
					float num = MathF.PI / 7f * (float)i;
					vh.AddVert(Vector2.op_Implicit(center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius), val, Vector4.op_Implicit(Uv));
				}
				for (int j = 0; j < 14; j++)
				{
					vh.AddTriangle(currentVertCount, currentVertCount + 1 + j, currentVertCount + 1 + (j + 1) % 14);
				}
			}
		}
	}
	internal struct AimInput
	{
		public Camera Cam;

		public Vector3 Origin;

		public Vector3 Forward;

		public float SpreadDegrees;

		public int Pellets;

		public float ProjectileSpeed;

		public float Gravity;

		public bool HitScan;

		public float ProjectileRadius;

		public int HitLayerMask;

		public bool Blocked;

		public Vector3 BlockedPoint;

		public bool HasWater;

		public float WaterHeight;

		public float AimPercent;

		public bool SniperScopeActive;
	}
	internal static class GameBinding
	{
		private static Type _tPlayer;

		private static Type _tPlayerHolding;

		private static Type _tItem;

		private static Type _tWeapon;

		private static Type _tAttachments;

		private static Type _tWeaponInfo;

		private static Type _tGameInfo;

		private static Type _tProjectileManager;

		private static Type _tWaterManager;

		private static Type _tPlayerCamera;

		private static Member _mLocalPlayer;

		private static Member _mLocalPlayerEnabled;

		private static Member _mCurCamera;

		private static Member _mPmInstance;

		private static Member _mWaterHeight;

		private static Member _mLevelLayer;

		private static Member _mPlayerLayer;

		private static Member _mItemLayer;

		private static Member _mNpcLayer;

		private static Member _mProjectileHitLayer;

		private static Member _mBlockInputs;

		private static Member _mHolding;

		private static Member _mCamObject;

		private static Member _mPlayerCameraRef;

		private static Member _mCameraCam;

		private static Member _mHeldItem;

		private static Member _mItemWeapon;

		private static Member _mModelForwardLength;

		private static Member _mSpread;

		private static Member _mProjSpeed;

		private static Member _mPelletCount;

		private static Member _mWeaponInfo;

		private static Member _mAimPercent;

		private static Member _mAttachments;

		private static Member _mFirePoint;

		private static Member _mUseSniperUi;

		private static Member _mProjectileTypeId;

		private static Member _mProjectileGravity;

		private static Member _mProjectileTypes;

		private static MethodInfo _miGetProjectileType;

		private static Member _mIsHitScan;

		private static Member _mWidthRadius;

		private static Member _mIdToSpawnable;

		private static Member _mItemId;

		private static int _cachedClipMask = -1;

		private static int _cachedHitMask = -1;

		private static int _consecutiveErrors;

		private const int ErrorBudget = 30;

		public static bool Ready { get; private set; }

		public static string Status { get; private set; } = "not initialised";

		public static bool Initialise()
		{
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			_tPlayer = Reflect.FindType("Player");
			_tPlayerHolding = Reflect.FindType("PlayerHolding");
			_tItem = Reflect.FindType("Item");
			_tWeapon = Reflect.FindType("Weapon");
			_tAttachments = Reflect.FindType("Attachments");
			_tWeaponInfo = Reflect.FindType("WeaponInfo");
			_tGameInfo = Reflect.FindType("GameInfo");
			_tProjectileManager = Reflect.FindType("ProjectileManager");
			_tWaterManager = Reflect.FindType("WaterManager");
			_tPlayerCamera = Reflect.FindType("PlayerCamera");
			if (_tPlayer == null)
			{
				list.Add("type Player");
			}
			if (_tWeapon == null)
			{
				list.Add("type Weapon");
			}
			if (_tAttachments == null)
			{
				list.Add("type Attachments");
			}
			_mLocalPlayer = Reflect.Bind(_tPlayer, true, _tPlayer, "localplayer", "LocalPlayer", "_localPlayer");
			if (_mLocalPlayer == null)
			{
				list.Add("Player.LocalPlayer");
			}
			_mHolding = Reflect.Bind(_tPlayer, false, _tPlayerHolding, "holding", "Holding", "_holding");
			if (_mHolding == null)
			{
				list.Add("Player.Holding");
			}
			_mHeldItem = Reflect.Bind(_tPlayerHolding, false, _tItem, "helditem", "HeldItem", "_heldItem");
			if (_mHeldItem == null)
			{
				list.Add("PlayerHolding.HeldItem");
			}
			_mItemWeapon = Reflect.Bind(_tItem, false, _tWeapon, "weapon", "Weapon", "_weapon");
			if (_mItemWeapon == null)
			{
				list.Add("Item.Weapon");
			}
			_mSpread = Reflect.Bind(_tWeapon, false, typeof(float), "spread", "_spread", "Spread", "_bulletSpread");
			if (_mSpread == null)
			{
				list.Add("Weapon._spread");
			}
			_mAttachments = Reflect.Bind(_tWeapon, false, _tAttachments, "attachment", "Attachments", "_attachments");
			if (_mAttachments == null)
			{
				list.Add("Weapon.Attachments");
			}
			_mFirePoint = Reflect.Bind(_tAttachments, false, typeof(Transform), "firepoint", "FirePoint", "_firePoint", "MuzzlePoint");
			if (_mFirePoint == null)
			{
				list.Add("Attachments.FirePoint");
			}
			_mCurCamera = Reflect.Bind(_tGameInfo, true, typeof(Camera), "curcamera", "CurCamera", "CurrentCamera", "MainCamera");
			_mPlayerCameraRef = Reflect.Bind(_tPlayer, false, _tPlayerCamera, null, "Camera", "_camera");
			_mCameraCam = Reflect.Bind(_tPlayerCamera, false, typeof(Camera), "cam", "Cam", "_cam", "Camera");
			if (_mCurCamera == null && (_mPlayerCameraRef == null || _mCameraCam == null))
			{
				list.Add("a camera source (GameInfo.CurCamera or Player.Camera.Cam)");
			}
			_mLocalPlayerEnabled = Reflect.Bind(_tPlayer, true, typeof(bool), null, "LocalPlayerEnabled");
			_mBlockInputs = Reflect.Bind(_tPlayer, false, typeof(bool), null, "BlockInputs");
			if (_mLocalPlayerEnabled == null)
			{
				list2.Add("Player.LocalPlayerEnabled (crosshair may show in menus)");
			}
			if (_mBlockInputs == null)
			{
				list2.Add("Player.BlockInputs (crosshair may show while UI is open)");
			}
			_mProjSpeed = Reflect.Bind(_tWeapon, false, typeof(float), "projspeed", "_projSpeed", "ProjSpeed", "_projectileSpeed");
			_mPelletCount = Reflect.Bind(_tWeapon, false, typeof(int), "projectilecount", "_projectileCountPerShot", "ProjectileCountPerShot");
			_mWeaponInfo = Reflect.Bind(_tWeapon, false, _tWeaponInfo, "weaponinfo", "_weaponInfo", "WeaponInfo");
			_mProjectileTypeId = Reflect.Bind(_tWeaponInfo, false, typeof(byte), "projectiletype", "ProjectileType", "_projectileType");
			_mProjectileGravity = Reflect.Bind(_tWeaponInfo, false, typeof(float), "gravity", "ProjectileGravity", "_projectileGravity");
			if (_mProjSpeed == null)
			{
				list2.Add("Weapon._projSpeed (assuming hitscan)");
			}
			if (_mProjectileGravity == null)
			{
				list2.Add("WeaponInfo.ProjectileGravity (no bullet drop)");
			}
			_mPmInstance = Reflect.Bind(_tProjectileManager, true, _tProjectileManager, null, "Instance", "_instance");
			_mProjectileTypes = Reflect.Bind(_tProjectileManager, false, null, null, "_types", "types", "_projectileTypes");
			_miGetProjectileType = Reflect.BindMethod(_tProjectileManager, "GetType", typeof(byte));
			Type owner = Reflect.FindType("ProjectileType");
			_mIsHitScan = Reflect.Bind(owner, false, typeof(bool), "hitscan", "IsHitScan", "HitScan");
			_mWidthRadius = Reflect.Bind(owner, false, typeof(float), "radius", "WidthRadius", "Radius");
			if (_mIsHitScan == null)
			{
				list2.Add("ProjectileType.IsHitScan (assuming hitscan)");
			}
			_mAimPercent = Reflect.Bind(_tWeapon, false, typeof(float), "aimpercent", "_aimPercent", "AimPercent");
			_mUseSniperUi = Reflect.Bind(_tAttachments, false, typeof(bool), "sniperui", "UseSniperUi", "UseSniperUI");
			_mModelForwardLength = Reflect.Bind(_tItem, false, typeof(float), "modelforward", "_modelForwardLength", "ModelForwardLength");
			_mCamObject = Reflect.Bind(_tPlayer, false, typeof(Transform), "camobject", "CamObject", "_camObject");
			_mLevelLayer = Reflect.Bind(_tGameInfo, true, typeof(LayerMask), null, "LevelLayer");
			_mPlayerLayer = Reflect.Bind(_tGameInfo, true, typeof(LayerMask), null, "PlayerLayer");
			_mItemLayer = Reflect.Bind(_tGameInfo, true, typeof(LayerMask), null, "ItemLayer");
			_mNpcLayer = Reflect.Bind(_tGameInfo, true, typeof(LayerMask), null, "NpcLayer");
			_mProjectileHitLayer = Reflect.Bind(_tGameInfo, true, typeof(LayerMask), null, "ProjectileHitLayer");
			if (_mProjectileHitLayer == null)
			{
				list2.Add("GameInfo.ProjectileHitLayer (falling back to default raycast layers)");
			}
			if (_mCamObject == null)
			{
				list2.Add("Player.CamObject (no muzzle-blocked detection)");
			}
			_mWaterHeight = Reflect.Bind(_tWaterManager, true, typeof(float), null, "WaterHeight");
			_mIdToSpawnable = Reflect.Bind(_tGameInfo, true, null, null, "_idToSpawnable", "IdToSpawnable");
			_mItemId = Reflect.Bind(_tItem, false, typeof(byte), null, "ID", "_id");
			Ready = list.Count == 0;
			if (Ready)
			{
				Status = ((list2.Count == 0) ? "bound cleanly" : ("bound with " + list2.Count + " reduced feature(s)"));
			}
			else
			{
				Status = "could not bind: " + string.Join(", ", list.ToArray());
			}
			LogReport(list, list2);
			return Ready;
		}

		private static void LogReport(List<string> missing, List<string> degraded)
		{
			if (!Ready)
			{
				Plugin.Log.LogError((object)("Dynamic Crosshair is disabled - the game's code no longer matches what this version expects. Missing: " + string.Join(", ", missing.ToArray())));
				Plugin.Log.LogError((object)"This usually means How to Fish has been updated. Check for a mod update, or report this log line so the binding can be refreshed.");
				return;
			}
			foreach (string item in degraded)
			{
				Plugin.Log.LogWarning((object)("Reduced feature - could not find " + item));
			}
			if (!Plugin.Cfg.LogBindingDetails.Value)
			{
				return;
			}
			Member[] array = new Member[23]
			{
				_mLocalPlayer, _mHolding, _mHeldItem, _mItemWeapon, _mSpread, _mAttachments, _mFirePoint, _mCurCamera, _mProjSpeed, _mPelletCount,
				_mWeaponInfo, _mProjectileTypeId, _mProjectileGravity, _mIsHitScan, _mWidthRadius, _mAimPercent, _mUseSniperUi, _mModelForwardLength, _mCamObject, _mLocalPlayerEnabled,
				_mBlockInputs, _mProjectileHitLayer, _mWaterHeight
			};
			foreach (Member member in array)
			{
				if (member != null)
				{
					if (member.ExactName)
					{
						Plugin.Log.LogInfo((object)("  bound " + member.Path));
					}
					else
					{
						Plugin.Log.LogWarning((object)("  bound " + member.Path + " by keyword search - the game was probably updated. Values may be wrong; please verify."));
					}
				}
			}
		}

		public static bool TryRead(out AimInput a)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			a = default(AimInput);
			if (!Ready)
			{
				return false;
			}
			try
			{
				if (_mLocalPlayerEnabled != null && !_mLocalPlayerEnabled.GetBool(null))
				{
					return false;
				}
				object obj = _mLocalPlayer.Get(null);
				if ((Object)obj == (Object)null)
				{
					return false;
				}
				if (_mBlockInputs != null && _mBlockInputs.GetBool(obj))
				{
					return false;
				}
				object obj2 = _mHolding.Get(obj);
				if ((Object)obj2 == (Object)null)
				{
					return false;
				}
				object obj3 = _mHeldItem.Get(obj2);
				if ((Object)obj3 == (Object)null)
				{
					return false;
				}
				object obj4 = _mItemWeapon.Get(obj3);
				if ((Object)obj4 == (Object)null)
				{
					return false;
				}
				object obj5 = _mAttachments.Get(obj4);
				if ((Object)obj5 == (Object)null)
				{
					return false;
				}
				object obj6 = _mFirePoint.Get(obj5);
				Transform val = (Transform)((obj6 is Transform) ? obj6 : null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				Camera val2 = ResolveCamera(obj);
				if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).isActiveAndEnabled)
				{
					return false;
				}
				a.Cam = val2;
				a.SpreadDegrees = Mathf.Max(0f, _mSpread.GetFloat(obj4));
				a.Pellets = ((_mPelletCount == null) ? 1 : Mathf.Max(1, _mPelletCount.GetInt(obj4)));
				a.ProjectileSpeed = ((_mProjSpeed != null) ? _mProjSpeed.GetFloat(obj4) : 0f);
				a.AimPercent = ((_mAimPercent != null) ? _mAimPercent.GetFloat(obj4) : 0f);
				bool flag = _mUseSniperUi != null && _mUseSniperUi.GetBool(obj5);
				a.SniperScopeActive = flag && a.AimPercent > 0.9f;
				Transform transform = ((Component)val2).transform;
				if (a.SniperScopeActive && _mModelForwardLength != null)
				{
					float num = _mModelForwardLength.GetFloat(obj3);
					a.Origin = transform.position + transform.forward * num;
					a.Forward = transform.forward;
				}
				else
				{
					a.Origin = val.position;
					a.Forward = val.forward;
				}
				ReadProjectileProfile(obj4, ref a);
				a.HitLayerMask = ResolveHitMask();
				ReadWater(ref a);
				ReadMuzzleBlocked(obj, val, ref a);
				_consecutiveErrors = 0;
				return true;
			}
			catch (Exception ex)
			{
				_consecutiveErrors++;
				if (_consecutiveErrors == 1 || _consecutiveErrors == 30)
				{
					Plugin.Log.LogError((object)("Failed to read aim state: " + ex.Message));
				}
				if (_consecutiveErrors >= 30)
				{
					Ready = false;
					Status = "disabled after repeated read errors";
					Plugin.Log.LogError((object)("Dynamic Crosshair is switching itself off after " + 30 + " consecutive read failures, so it cannot spam your log or hurt your frame rate."));
				}
				return false;
			}
		}

		public static void DumpWeaponTable()
		{
			if (_mIdToSpawnable == null || _tWeapon == null)
			{
				Plugin.Log.LogWarning((object)"Cannot dump the item table - GameInfo's spawnable list was not found.");
				return;
			}
			IDictionary dictionary;
			try
			{
				dictionary = _mIdToSpawnable.Get(null) as IDictionary;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Cannot dump the item table: " + ex.Message));
				return;
			}
			if (dictionary == null || dictionary.Count == 0)
			{
				Plugin.Log.LogWarning((object)"The spawnable item table is empty - try again once a world is loaded.");
				return;
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			foreach (DictionaryEntry item in dictionary)
			{
				object? value = item.Value;
				Component val = (Component)((value is Component) ? value : null);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				int num = Convert.ToInt32(item.Key);
				string name = ((Object)val).name;
				Component weapon = null;
				try
				{
					weapon = val.GetComponent(_tWeapon);
				}
				catch
				{
				}
				if ((Object)(object)weapon == (Object)null)
				{
					list2.Add(num + " " + name);
					continue;
				}
				list.Add(string.Format("  id {0,-4} {1,-22} spread {2,-7} pellets {3,-4} speed {4,-7} gravity {5,-7} {6}", num, Truncate(name, 22), Safe(() => _mSpread.GetFloat(weapon).ToString("0.###")), (_mPelletCount != null) ? Safe(() => _mPelletCount.GetInt(weapon).ToString()) : "?", (_mProjSpeed != null) ? Safe(() => _mProjSpeed.GetFloat(weapon).ToString("0.#")) : "?", DescribeGravity(weapon), DescribeDelivery(weapon)));
			}
			list.Sort();
			list2.Sort();
			Plugin.Log.LogInfo((object)("=== weapons (" + list.Count + ") ==="));
			foreach (string item2 in list)
			{
				Plugin.Log.LogInfo((object)item2);
			}
			Plugin.Log.LogInfo((object)("=== other items (" + list2.Count + ") ==="));
			Plugin.Log.LogInfo((object)("  " + string.Join(", ", list2.ToArray())));
		}

		private static string DescribeGravity(Component weapon)
		{
			if (_mWeaponInfo == null || _mProjectileGravity == null)
			{
				return "?";
			}
			return Safe(delegate
			{
				object obj = _mWeaponInfo.Get(weapon);
				return (obj != null) ? _mProjectileGravity.GetFloat(obj).ToString("0.##") : "?";
			});
		}

		private static string DescribeDelivery(Component weapon)
		{
			if (_mWeaponInfo == null || _mProjectileTypeId == null)
			{
				return "";
			}
			return Safe(delegate
			{
				object obj = _mWeaponInfo.Get(weapon);
				if (obj == null)
				{
					return "";
				}
				byte id = (byte)_mProjectileTypeId.GetInt(obj);
				object obj2 = ResolveProjectileType(id);
				if (obj2 == null || _mIsHitScan == null)
				{
					return "projType " + id;
				}
				return (!_mIsHitScan.GetBool(obj2)) ? "travels" : "hitscan";
			});
		}

		private static string Safe(Func<string> read)
		{
			try
			{
				return read();
			}
			catch
			{
				return "?";
			}
		}

		private static string Truncate(string text, int max)
		{
			if (text.Length > max)
			{
				return text.Substring(0, max);
			}
			return text;
		}

		private static Camera ResolveCamera(object player)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			if (_mCurCamera != null)
			{
				object obj = _mCurCamera.Get(null);
				Camera val = (Camera)((obj is Camera) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			if (_mPlayerCameraRef != null && _mCameraCam != null)
			{
				object obj2 = _mPlayerCameraRef.Get(player);
				if ((Object)obj2 != (Object)null)
				{
					object obj3 = _mCameraCam.Get(obj2);
					return (Camera)((obj3 is Camera) ? obj3 : null);
				}
			}
			return Camera.main;
		}

		private static void ReadProjectileProfile(object weapon, ref AimInput a)
		{
			a.HitScan = true;
			a.ProjectileRadius = 0f;
			a.Gravity = 0f;
			if (_mWeaponInfo == null)
			{
				return;
			}
			object obj = _mWeaponInfo.Get(weapon);
			if (obj == null)
			{
				return;
			}
			if (_mProjectileGravity != null)
			{
				a.Gravity = _mProjectileGravity.GetFloat(obj);
			}
			if (_mProjectileTypeId == null)
			{
				return;
			}
			object obj2 = ResolveProjectileType((byte)_mProjectileTypeId.GetInt(obj));
			if (obj2 != null)
			{
				if (_mIsHitScan != null)
				{
					a.HitScan = _mIsHitScan.GetBool(obj2);
				}
				if (_mWidthRadius != null)
				{
					a.ProjectileRadius = Mathf.Max(0f, _mWidthRadius.GetFloat(obj2));
				}
				if (a.ProjectileSpeed <= 0.01f)
				{
					a.HitScan = true;
				}
			}
		}

		private static object ResolveProjectileType(byte id)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (_mPmInstance == null)
			{
				return null;
			}
			object obj = _mPmInstance.Get(null);
			if ((Object)obj == (Object)null)
			{
				return null;
			}
			if (_mProjectileTypes != null && _mProjectileTypes.Get(obj) is Array array && id < array.Length)
			{
				return array.GetValue(id);
			}
			if (_miGetProjectileType != null)
			{
				return _miGetProjectileType.Invoke(obj, new object[1] { id });
			}
			return null;
		}

		private static void ReadWater(ref AimInput a)
		{
			if (_mWaterHeight == null)
			{
				return;
			}
			try
			{
				a.WaterHeight = _mWaterHeight.GetFloat(null);
				a.HasWater = true;
			}
			catch
			{
				a.HasWater = false;
			}
		}

		private static void ReadMuzzleBlocked(object player, Transform firePoint, ref AimInput a)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (_mCamObject == null)
			{
				return;
			}
			object obj = _mCamObject.Get(player);
			Transform val = (Transform)((obj is Transform) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			int num = ResolveClipMask();
			if (num != 0)
			{
				Vector3 position = val.position;
				Vector3 val2 = firePoint.position + firePoint.forward * 0.1f - position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				RaycastHit val3 = default(RaycastHit);
				if (!(magnitude <= 0.0001f) && Physics.Raycast(position, val2, ref val3, magnitude, num))
				{
					a.Blocked = true;
					a.BlockedPoint = ((RaycastHit)(ref val3)).point;
				}
			}
		}

		private static int ResolveClipMask()
		{
			if (_cachedClipMask >= 0)
			{
				return _cachedClipMask;
			}
			try
			{
				int num = MaskOf(_mLevelLayer) | MaskOf(_mPlayerLayer) | MaskOf(_mItemLayer) | MaskOf(_mNpcLayer);
				if (num != 0)
				{
					_cachedClipMask = num;
				}
				return num;
			}
			catch
			{
				return 0;
			}
		}

		private static int ResolveHitMask()
		{
			if (_cachedHitMask >= 0)
			{
				return _cachedHitMask;
			}
			try
			{
				int num = MaskOf(_mProjectileHitLayer);
				if (num != 0)
				{
					_cachedHitMask = num;
					return num;
				}
			}
			catch
			{
			}
			return -5;
		}

		private static int MaskOf(Member member)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (member == null)
			{
				return 0;
			}
			object obj = member.Get(null);
			if (obj is LayerMask val)
			{
				return ((LayerMask)(ref val)).value;
			}
			return Convert.ToInt32(obj);
		}
	}
	internal static class Hotkey
	{
		private static bool _resolved;

		private static bool _legacyBroken;

		private static MethodInfo _keyboardCurrent;

		private static MethodInfo _keyIndexer;

		private static MethodInfo _wasPressedThisFrame;

		private static Type _keyEnumType;

		private static string _parsedFrom;

		private static object _newInputKey;

		private static KeyCode _legacyKey;

		private static bool _keyValid;

		private static readonly object[] IndexArgs = new object[1];

		public static bool Pressed(string keyName)
		{
			if (string.IsNullOrEmpty(keyName))
			{
				return false;
			}
			if (!_resolved)
			{
				Resolve();
			}
			if (keyName != _parsedFrom)
			{
				ParseKey(keyName);
			}
			if (!_keyValid)
			{
				return false;
			}
			if (_newInputKey != null && ReadNewInput())
			{
				return true;
			}
			return ReadLegacyInput();
		}

		private static bool ReadNewInput()
		{
			try
			{
				object obj = _keyboardCurrent.Invoke(null, null);
				if (obj == null)
				{
					return false;
				}
				IndexArgs[0] = _newInputKey;
				object obj2 = _keyIndexer.Invoke(obj, IndexArgs);
				if (obj2 == null)
				{
					return false;
				}
				return (bool)_wasPressedThisFrame.Invoke(obj2, null);
			}
			catch
			{
				_newInputKey = null;
				return false;
			}
		}

		private static bool ReadLegacyInput()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (_legacyBroken || (int)_legacyKey == 0)
			{
				return false;
			}
			try
			{
				return Input.GetKeyDown(_legacyKey);
			}
			catch
			{
				_legacyBroken = true;
				return false;
			}
		}

		private static void Resolve()
		{
			_resolved = true;
			try
			{
				Type type = Reflect.FindType("UnityEngine.InputSystem.Keyboard");
				_keyEnumType = Reflect.FindType("UnityEngine.InputSystem.Key");
				if (type == null || _keyEnumType == null)
				{
					return;
				}
				PropertyInfo propertyInfo = type.GetProperty("current", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
				if (propertyInfo == null)
				{
					try
					{
						propertyInfo = type.GetProperty("current", BindingFlags.Static | BindingFlags.Public);
					}
					catch (AmbiguousMatchException)
					{
						propertyInfo = null;
					}
				}
				_keyboardCurrent = ((propertyInfo != null) ? propertyInfo.GetGetMethod() : null);
				_keyIndexer = type.GetMethod("get_Item", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { _keyEnumType }, null);
				Type type2 = Reflect.FindType("UnityEngine.InputSystem.Controls.ButtonControl");
				PropertyInfo propertyInfo2 = ((type2 != null) ? type2.GetProperty("wasPressedThisFrame", BindingFlags.Instance | BindingFlags.Public) : null);
				_wasPressedThisFrame = ((propertyInfo2 != null) ? propertyInfo2.GetGetMethod() : null);
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogWarning((object)("Could not attach to the Input System package: " + ex2.Message));
			}
		}

		private static void ParseKey(string keyName)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			_parsedFrom = keyName;
			_newInputKey = null;
			_legacyKey = (KeyCode)0;
			_keyValid = false;
			string text = keyName.Trim();
			if (text.Length == 0)
			{
				return;
			}
			if (_keyEnumType != null && _keyboardCurrent != null && _keyIndexer != null && _wasPressedThisFrame != null)
			{
				try
				{
					_newInputKey = Enum.Parse(_keyEnumType, text, ignoreCase: true);
				}
				catch
				{
					_newInputKey = null;
				}
			}
			try
			{
				_legacyKey = (KeyCode)Enum.Parse(typeof(KeyCode), text, ignoreCase: true);
			}
			catch
			{
				_legacyKey = (KeyCode)0;
			}
			_keyValid = _newInputKey != null || (int)_legacyKey > 0;
			if (!_keyValid)
			{
				Plugin.Log.LogWarning((object)("ToggleKey '" + keyName + "' is not a key name I recognise. Try F8, H, Backquote or any other Input System Key value."));
			}
		}
	}
	[BepInPlugin("howtofish.dynamiccrosshair", "Dynamic Crosshair", "1.0.0")]
	[BepInProcess("How to Fish.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "howtofish.dynamiccrosshair";

		public const string PluginName = "Dynamic Crosshair";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static PluginConfig Cfg;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Cfg = new PluginConfig(((BaseUnityPlugin)this).Config);
			if (!Cfg.Enabled.Value)
			{
				Log.LogInfo((object)"Dynamic Crosshair is switched off in its config file; nothing will be created.");
				return;
			}
			CrosshairController.Create(Cfg);
			Log.LogInfo((object)("Dynamic Crosshair 1.0.0 ready. Toggle key: " + (string.IsNullOrEmpty(Cfg.ToggleKey.Value) ? "none" : Cfg.ToggleKey.Value)));
		}
	}
	internal enum SpreadStyle
	{
		None,
		Ring,
		DashedRing,
		Ticks,
		Brackets
	}
	internal enum CenterStyle
	{
		None,
		Dot,
		HollowDot,
		Plus,
		Cross,
		Diamond
	}
	internal sealed class PluginConfig
	{
		public readonly ConfigEntry<bool> Enabled;

		public readonly ConfigEntry<string> ToggleKey;

		public readonly ConfigEntry<SpreadStyle> Spread;

		public readonly ConfigEntry<CenterStyle> Center;

		public readonly ConfigEntry<bool> ScaleWithResolution;

		public readonly ConfigEntry<float> ReferenceHeight;

		public readonly ConfigEntry<string> ColorHex;

		public readonly ConfigEntry<string> CenterColorHex;

		public readonly ConfigEntry<string> BlockedColorHex;

		public readonly ConfigEntry<string> OutlineColorHex;

		public readonly ConfigEntry<float> Thickness;

		public readonly ConfigEntry<float> OutlineWidth;

		public readonly ConfigEntry<int> Segments;

		public readonly ConfigEntry<float> CenterSize;

		public readonly ConfigEntry<float> CenterGap;

		public readonly ConfigEntry<float> CenterArmLength;

		public readonly ConfigEntry<float> TickLength;

		public readonly ConfigEntry<int> DashCount;

		public readonly ConfigEntry<float> BracketArcDegrees;

		public readonly ConfigEntry<float> MinRadiusPixels;

		public readonly ConfigEntry<float> MaxRadiusPixels;

		public readonly ConfigEntry<bool> HideWhileAiming;

		public readonly ConfigEntry<bool> HideWithSniperScope;

		public readonly ConfigEntry<bool> ShowBlockedIndicator;

		public readonly ConfigEntry<bool> ConformToGeometry;

		public readonly ConfigEntry<int> MaxSimulationSteps;

		public readonly ConfigEntry<float> MaxRange;

		public readonly ConfigEntry<bool> ShowDebugText;

		public readonly ConfigEntry<bool> LogBindingDetails;

		public readonly ConfigEntry<bool> DumpWeaponTable;

		public readonly ConfigEntry<bool> TestPattern;

		private string _cachedMain;

		private string _cachedCenter;

		private string _cachedBlocked;

		private string _cachedOutline;

		private Color _main;

		private Color _center;

		private Color _blocked;

		private Color _outline;

		private const string SchemaVersion = "1";

		public float Scale
		{
			get
			{
				if (!ScaleWithResolution.Value)
				{
					return 1f;
				}
				float num = Mathf.Max(1f, ReferenceHeight.Value);
				return Mathf.Clamp(((Screen.height > 0) ? ((float)Screen.height) : num) / num, 0.5f, 4f);
			}
		}

		public Color MainColor => Resolve(ColorHex.Value, ref _cachedMain, ref _main, new Color(0.36f, 1f, 0.78f, 1f));

		public Color CenterColor => Resolve(CenterColorHex.Value, ref _cachedCenter, ref _center, Color.white);

		public Color BlockedColor => Resolve(BlockedColorHex.Value, ref _cachedBlocked, ref _blocked, new Color(1f, 0.25f, 0.25f, 1f));

		public Color OutlineColor => Resolve(OutlineColorHex.Value, ref _cachedOutline, ref _outline, new Color(0f, 0f, 0f, 0.78f));

		public PluginConfig(ConfigFile file)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Expected O, but got Unknown
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Expected O, but got Unknown
			ConfigEntry<string> val = file.Bind<string>("General", "ConfigSchema", "1", "Internal - do not edit. Identifies which version of the mod wrote this file.");
			Enabled = file.Bind<bool>("General", "Enabled", true, "Master switch. Turning this off hides the crosshair and stops all per-frame work.");
			ToggleKey = file.Bind<string>("General", "ToggleKey", "F8", "Key that shows/hides the crosshair in game. Use a key name such as F8, H or Backquote. Leave empty to disable the shortcut.");
			Spread = file.Bind<SpreadStyle>("Appearance", "SpreadStyle", SpreadStyle.Ring, "How to draw the spread cone boundary.\nNone       - do not draw it\nRing       - continuous outline\nDashedRing - broken outline, reads better over busy scenery\nTicks      - four marks standing outward on the boundary\nBrackets   - four short arcs, like brackets around the target");
			Center = file.Bind<CenterStyle>("Appearance", "CenterStyle", CenterStyle.Plus, "How to mark the exact point of aim.\nNone      - do not mark it\nDot       - filled disc\nHollowDot - small open circle, readable on light and dark backgrounds\nPlus      - four arms with a centre gap, never covers what you are shooting\nCross     - four diagonal arms with a centre gap\nDiamond   - small open diamond");
			ScaleWithResolution = file.Bind<bool>("Appearance", "ScaleWithResolution", true, "Scale every thickness and size below by your screen height, so the crosshair looks the same on 1080p and 4K. Turn off to treat the numbers as exact pixels.");
			ReferenceHeight = file.Bind<float>("Appearance", "ReferenceHeight", 1080f, new ConfigDescription("Screen height the sizes below are authored against, used only when ScaleWithResolution is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(480f, 2160f), Array.Empty<object>()));
			Thickness = file.Bind<float>("Appearance", "Thickness", 2f, new ConfigDescription("Line thickness of the spread outline.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 16f), Array.Empty<object>()));
			OutlineWidth = file.Bind<float>("Appearance", "OutlineWidth", 1.5f, new ConfigDescription("Width of the dark edge drawn behind everything, per side. This is what keeps the crosshair visible against bright sand and sky. 0 disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f), Array.Empty<object>()));
			CenterSize = file.Bind<float>("Appearance", "CenterSize", 3f, new ConfigDescription("Radius of the centre marker, for Dot, HollowDot and Diamond.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 24f), Array.Empty<object>()));
			CenterGap = file.Bind<float>("Appearance", "CenterGap", 3f, new ConfigDescription("Empty space in the middle of the Plus and Cross styles, so the marker never hides your target.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 24f), Array.Empty<object>()));
			CenterArmLength = file.Bind<float>("Appearance", "CenterArmLength", 8f, new ConfigDescription("Length of each arm of the Plus and Cross styles.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 48f), Array.Empty<object>()));
			TickLength = file.Bind<float>("Appearance", "TickLength", 9f, new ConfigDescription("Length of each mark in the Ticks style.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 48f), Array.Empty<object>()));
			Segments = file.Bind<int>("Appearance", "Segments", 40, new ConfigDescription("Points used to trace the spread outline. Higher is smoother and slightly more expensive.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 64), Array.Empty<object>()));
			DashCount = file.Bind<int>("Appearance", "DashCount", 12, new ConfigDescription("Number of dashes in the DashedRing style.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 32), Array.Empty<object>()));
			BracketArcDegrees = file.Bind<float>("Appearance", "BracketArcDegrees", 34f, new ConfigDescription("How much of the boundary each arc covers in the Brackets style.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 89f), Array.Empty<object>()));
			MinRadiusPixels = file.Bind<float>("Appearance", "MinRadiusPixels", 3f, new ConfigDescription("Smallest the outline is allowed to get, so a very tight cone stays readable. Weapons with no spread at all show only the centre marker, since drawing a ring there would imply spread that does not exist.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>()));
			MaxRadiusPixels = file.Bind<float>("Appearance", "MaxRadiusPixels", 900f, new ConfigDescription("Safety clamp on outline size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 4000f), Array.Empty<object>()));
			ColorHex = file.Bind<string>("Colours", "Color", "5CFFC8FF", "Spread outline colour, as RRGGBBAA hex. The last two digits are opacity.");
			CenterColorHex = file.Bind<string>("Colours", "CenterColor", "FFFFFFFF", "Centre marker colour, as RRGGBBAA hex. Keeping this different from the outline colour makes the exact point of aim much easier to pick out.");
			BlockedColorHex = file.Bind<string>("Colours", "BlockedColor", "FF4040FF", "Colour used when the barrel is pressed into something, so the shot will hit that obstruction instead of leaving the muzzle.");
			OutlineColorHex = file.Bind<string>("Colours", "OutlineColor", "000000C8", "Colour of the dark edge drawn behind the crosshair. Set alpha to 00 to remove it.");
			HideWhileAiming = file.Bind<bool>("Behaviour", "HideWhileAiming", false, "Hide the crosshair once you are aiming down the weapon's own sights.");
			HideWithSniperScope = file.Bind<bool>("Behaviour", "HideWithSniperScope", true, "Hide the crosshair while a full screen scope overlay is up, where it would only add clutter.");
			ShowBlockedIndicator = file.Bind<bool>("Behaviour", "ShowBlockedIndicator", true, "Recolour the crosshair when the muzzle is clipping into geometry. The game resolves those shots at the obstruction, which is easy to miss otherwise.");
			ConformToGeometry = file.Bind<bool>("Behaviour", "ConformToGeometry", false, "Trace every point of the outline against the world so the spread wraps around corners and angled surfaces. Looks better, costs one cast per segment per frame.");
			MaxSimulationSteps = file.Bind<int>("Behaviour", "MaxSimulationSteps", 250, new ConfigDescription("Physics ticks simulated for weapons whose projectiles travel and drop. Lower if a bow or harpoon costs you frames.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 2000), Array.Empty<object>()));
			MaxRange = file.Bind<float>("Behaviour", "MaxRange", 400f, new ConfigDescription("How far to follow a shot before giving up and drawing the crosshair at that distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 2000f), Array.Empty<object>()));
			ShowDebugText = file.Bind<bool>("Diagnostics", "ShowDebugText", false, "Show the live spread, pellet count and range on screen. Handy for confirming the crosshair matches the weapon you are holding.");
			LogBindingDetails = file.Bind<bool>("Diagnostics", "LogBindingDetails", true, "List every game field the mod attached to at startup. Leave this on: it is the fastest way to see what a game update changed.");
			DumpWeaponTable = file.Bind<bool>("Diagnostics", "DumpWeaponTable", false, "Once in game, write every weapon's id, spread, pellet count, projectile speed and gravity to the log, plus the id of every other item. Useful for checking the crosshair against weapons you are not holding, and for reading the save format.");
			TestPattern = file.Bind<bool>("Diagnostics", "TestPattern", false, "Draw a fixed ring in the middle of the screen, everywhere including the main menu. If you see nothing in game, turn this on: a visible ring means the overlay works and the problem is reading the weapon, no ring means the overlay itself is being blocked.");
			if (val.Value != "1")
			{
				Plugin.Log.LogWarning((object)("This config file was written by a different version of Dynamic Crosshair. Settings that have since been renamed keep their old values, and removed ones are left in the file and ignored. If the crosshair does not look like the new defaults, delete " + file.ConfigFilePath + " and restart to regenerate it."));
				val.Value = "1";
			}
		}

		private static Color Resolve(string text, ref string cacheKey, ref Color cacheValue, Color fallback)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (text == cacheKey)
			{
				return cacheValue;
			}
			cacheKey = text;
			cacheValue = Parse(text, fallback);
			return cacheValue;
		}

		private static Color Parse(string text, Color fallback)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return fallback;
			}
			string text2 = text.Trim();
			if (text2[0] != '#')
			{
				text2 = "#" + text2;
			}
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString