Decompiled source of smolMods v1.0.10

BepInEx/plugins/smolMods.Crosshair.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Mirror;
using Rewired;
using RewiredConsts;
using SmolMods.Core;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("smolMods.Crosshair")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2421764d6013a8ab70ae955dcea0dc3cec55a021")]
[assembly: AssemblyProduct("smolMods.Crosshair")]
[assembly: AssemblyTitle("smolMods.Crosshair")]
[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 SmolMods.Crosshair
{
	[HarmonyPatch]
	internal static class ArmsUpFeature
	{
		private static ModRowDef _row;

		private static float _seconds = 5f;

		private const float VanillaSeconds = 5f;

		private static readonly bool[] _wasStickied = new bool[3];

		private static readonly bool[] _suppressed = new bool[3];

		private static bool _loggedFailure;

		internal static void Register()
		{
			_row = ModSettingsApi.AddSliderRow(100, "Arms up stick time", "settings_mod_armsUpStickTime", 50, 0, 50, (Action<int>)delegate(int v)
			{
				_seconds = (float)v / 10f;
			}, (Func<int, string>)((int v) => (v > 0) ? ((v < 50) ? $"{(float)v / 10f:0.0}s" : "Hold") : "Toggle"), false, 1, true, (Func<int, Color?>)null, false);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerGestures), "Update")]
		private static void GesturesUpdate_Postfix(PlayerGestures __instance)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_0037: 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_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_004a: 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_0070: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				float seconds = _seconds;
				if (seconds >= 5f)
				{
					return;
				}
				PlayerCharacter playerCharacter = __instance.playerCharacter;
				if (!((Object)(object)playerCharacter == (Object)null) && ((NetworkBehaviour)playerCharacter).isLocalPlayer)
				{
					float deltaTime = Time.deltaTime;
					PlayerActionState s = __instance.sharedArmWavingState;
					if (Drive(ref s, 0, seconds, deltaTime))
					{
						__instance.sharedArmWavingState = s;
					}
					s = __instance.leftArmWavingState;
					if (Drive(ref s, 1, seconds, deltaTime))
					{
						__instance.leftArmWavingState = s;
					}
					s = __instance.rightArmWavingState;
					if (Drive(ref s, 2, seconds, deltaTime))
					{
						__instance.rightArmWavingState = s;
					}
				}
			}
			catch (Exception ex)
			{
				if (_loggedFailure)
				{
					return;
				}
				_loggedFailure = true;
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Arms up stick patch failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val);
				}
			}
		}

		private static bool Drive(ref PlayerActionState s, int idx, float t, float dt)
		{
			if (_wasStickied[idx] && !s.isStickiedOn && s.isHeld)
			{
				_suppressed[idx] = true;
			}
			_wasStickied[idx] = s.isStickiedOn;
			if (!s.isHeld)
			{
				_suppressed[idx] = false;
				return false;
			}
			if (_suppressed[idx] || s.isStickiedOn)
			{
				return false;
			}
			if (t <= 0.05f)
			{
				s.timeHeld = 5f;
				s.isStickiedOn = true;
				_wasStickied[idx] = true;
				return true;
			}
			float num = dt * (5f / t - 1f);
			if (num <= 0f)
			{
				return false;
			}
			s.timeHeld = Mathf.Min(s.timeHeld + num, 5f);
			return true;
		}
	}
	internal static class CrosshairPreviewPanel
	{
		internal const float PreviewBaseFontSize = 72f;

		private static readonly List<TMP_Text> Previews = new List<TMP_Text>();

		internal static TMP_FontAsset PreviewFont;

		internal static void Register()
		{
			ModSettingsApi.AddPanel(100, (Action<ModPanelContext>)Build);
			ModSettingsApi.AddMenuTicker((Action)UpdatePreview);
		}

		private static void Build(ModPanelContext ctx)
		{
			//IL_003b: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0069: 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_008e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject noteGo = ctx.NoteGo;
				GameObject val = Object.Instantiate<GameObject>(noteGo, noteGo.transform.parent);
				((Object)val).name = "ModsCrosshairPreview";
				RectTransform component = noteGo.GetComponent<RectTransform>();
				RectTransform component2 = val.GetComponent<RectTransform>();
				Vector2 val2 = ctx.NextSlot(new Vector2(380f, 200f), 0f, (float?)150f);
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					component2.sizeDelta = new Vector2(Mathf.Max(component.sizeDelta.x, 380f), 200f);
					component2.anchoredPosition = component.anchoredPosition + val2;
				}
				TMP_Text val3 = val.GetComponent<TMP_Text>() ?? val.GetComponentInChildren<TMP_Text>(true);
				if (!((Object)(object)val3 == (Object)null))
				{
					val3.text = "( · )";
					val3.fontSize = 72f;
					val3.alignment = (TextAlignmentOptions)514;
					val3.enableWordWrapping = false;
					val3.overflowMode = (TextOverflowModes)0;
					val3.fontStyle = (FontStyles)0;
					PreviewFont = val3.font;
					Previews.Add(val3);
					ModSettingsApi.RegisterPreviewGraphic((Graphic)(object)val3);
					ctx.RegisterPanel(val);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Crosshair preview creation failed: ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val4);
				}
			}
		}

		private static void UpdatePreview()
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			for (int num = Previews.Count - 1; num >= 0; num--)
			{
				TMP_Text val = Previews[num];
				if ((Object)(object)val == (Object)null)
				{
					Previews.RemoveAt(num);
				}
				else if (((Component)val).gameObject.activeInHierarchy)
				{
					try
					{
						float num2 = Mathf.Clamp((float)CrosshairSizeFeature.CurrentPercent / 100f, 0f, 2f);
						int currentMode = CrosshairSizeFeature.CurrentMode;
						if (currentMode == 4 || num2 <= 0.001f)
						{
							val.text = "no crosshair";
							val.fontSize = 32.399998f;
						}
						else
						{
							bool flag = currentMode == 2 || currentMode == 3;
							val.text = (flag ? "+" : "( + )");
							val.fontSize = 72f * num2 * (flag ? 0.75f : 1f);
						}
						val.transform.localScale = Vector3.one;
					}
					catch
					{
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class CrosshairSizeFeature
	{
		private static ModRowDef _row;

		private static ModRowDef _modeRow;

		internal const int ModeFull = 0;

		internal const int ModeSlick = 1;

		internal const int ModeSSmol = 2;

		internal const int ModeSmall = 3;

		internal const int ModeOff = 4;

		private static readonly Dictionary<int, Vector3> BaseScales = new Dictionary<int, Vector3>();

		private static TextMeshProUGUI _slickText;

		private const float SlickBaseFontSize = 72f;

		private static Image _windupBar;

		private const float WindupMaxWidth = 220f;

		private const float WindupHeight = 6f;

		private static int _modeMirror = 0;

		private static float _factorMirror = 1f;

		private static SettingsHanger _vanillaHanger;

		private static bool _vanillaSynced;

		private static bool _glyphShown;

		private static string _glyphText;

		private static float _glyphSize;

		private static bool _barShown;

		private static RectTransform _windupBarRt;

		private static float _lastBarW = -1f;

		private const string GlyphFullNormal = "( + )";

		private const string GlyphFullHold = "( x )";

		private const string GlyphSmallNormal = "+";

		private const string GlyphSmallHold = "x";

		private static bool SlickEnabled
		{
			get
			{
				if (_modeMirror != 1)
				{
					return _modeMirror == 2;
				}
				return true;
			}
		}

		internal static int CurrentPercent
		{
			get
			{
				ModRowDef row = _row;
				if (row == null)
				{
					return 100;
				}
				return row.Value;
			}
		}

		internal static int CurrentMode => _modeMirror;

		private static float Factor => _factorMirror;

		internal static void Register()
		{
			_row = ModSettingsApi.AddSliderRow(100, "Crosshair size", "settings_mod_crosshairSize", 100, 0, 200, (Action<int>)delegate(int v)
			{
				_factorMirror = (float)v / 100f;
				Apply();
			}, (Func<int, string>)((int v) => $"{v}%"), true, 5, false, (Func<int, Color?>)null, false);
			int num = 0;
			try
			{
				if (PlayerPrefs.GetInt("settings_mod_crosshairStyle", 0) == 1)
				{
					num = 1;
				}
			}
			catch
			{
			}
			_modeRow = ModSettingsApi.AddArrayRow(100, "Crosshair", "settings_mod_crosshairMode", num, new int[5] { 0, 1, 2, 3, 4 }, (Func<int, string>)ModeLabel, (Action<int>)delegate(int v)
			{
				_modeMirror = v;
				PushVanillaValue(v);
				Apply();
			}, (Func<int, Color?>)null, true, false);
			ModSettingsApi.ReplaceVanillaCrosshairRow();
			CrosshairPreviewPanel.Register();
			ModSettingsApi.AddTicker((Action)TickSlick);
		}

		internal static string ModeLabel(int v)
		{
			return v switch
			{
				1 => "Slick", 
				2 => "SSmol", 
				3 => "Small", 
				4 => "Off", 
				_ => "Full", 
			};
		}

		private static void PushVanillaValue(int mode)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			_vanillaSynced = false;
			try
			{
				SettingsHanger val = _vanillaHanger;
				if (val == null)
				{
					val = (_vanillaHanger = SettingsWardrobe.crosshairHanger);
				}
				if (val == null)
				{
					return;
				}
				int num = mode switch
				{
					4 => 2, 
					3 => 1, 
					_ => 0, 
				};
				if (val.value != num)
				{
					val.value = num;
					val.Save();
					try
					{
						SettingsWardrobe instance = SettingsWardrobe.instance;
						if (instance != null)
						{
							instance.ApplyCrosshair(num);
						}
					}
					catch
					{
					}
					try
					{
						Crosshair.OnSettingsChange();
					}
					catch
					{
					}
				}
				_vanillaSynced = true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Vanilla crosshair write-through failed: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Crosshair), "OnSettingsChange")]
		private static void OnSettingsChange_Postfix()
		{
			Apply();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Crosshair), "SetCrosshairMode")]
		private static void SetCrosshairMode_Postfix()
		{
			Apply();
		}

		internal static void Apply()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			try
			{
				Crosshair val;
				try
				{
					val = Crosshair.instance;
				}
				catch
				{
					val = null;
				}
				if (val != null)
				{
					bool slickEnabled = SlickEnabled;
					float factor = ((slickEnabled || _modeMirror == 4) ? 0f : Factor);
					ScaleTransform(val.crosshairNormal, factor);
					ScaleTransform(val.crosshairHolding, factor);
					ScaleTransform((Transform)(object)val.crosshairWindup, factor);
					ScaleTransform(val.wings, factor);
					UpdateSlick(val, slickEnabled);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Crosshair scale apply failed: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}

		private static void UpdateSlick(Crosshair crosshair, bool slick)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			try
			{
				if (!slick)
				{
					if (_glyphShown && (Object)(object)_slickText != (Object)null)
					{
						((Component)_slickText).gameObject.SetActive(false);
						_glyphShown = false;
					}
				}
				else if (!((Object)(object)_slickText == (Object)null) || CreateSlick(crosshair))
				{
					RefreshSlickVisual(crosshair);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Slick crosshair update failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val);
				}
				_slickText = null;
				_glyphShown = false;
				_glyphText = null;
			}
		}

		private static TMP_FontAsset FindSlickFont()
		{
			if ((Object)(object)CrosshairPreviewPanel.PreviewFont != (Object)null)
			{
				return CrosshairPreviewPanel.PreviewFont;
			}
			try
			{
				Il2CppReferenceArray<Object> obj = Resources.FindObjectsOfTypeAll(Il2CppType.Of<TMP_FontAsset>());
				TMP_FontAsset val = null;
				foreach (Object item in (Il2CppArrayBase<Object>)(object)obj)
				{
					TMP_FontAsset val2 = ((Il2CppObjectBase)item).TryCast<TMP_FontAsset>();
					if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name != null && ((Object)val2).name.Contains("Courier"))
					{
						if (((Object)val2).name.IndexOf("Italic", StringComparison.OrdinalIgnoreCase) < 0)
						{
							return val2;
						}
						if ((Object)(object)val == (Object)null)
						{
							val = val2;
						}
					}
				}
				return val;
			}
			catch
			{
			}
			return null;
		}

		private static bool IsCarrying()
		{
			try
			{
				PlayerCharacter val = PlayerPalette.FindLocalPlayer();
				return (Object)(object)val != (Object)null && val.hands != null && val.hands.isHoldingSomething;
			}
			catch
			{
				return false;
			}
		}

		internal static void TickSlick()
		{
			try
			{
				if (!_vanillaSynced)
				{
					PushVanillaValue(_modeMirror);
				}
				if (!SlickEnabled)
				{
					if (_glyphShown)
					{
						if ((Object)(object)_slickText != (Object)null)
						{
							((Component)_slickText).gameObject.SetActive(false);
						}
						_glyphShown = false;
					}
					if (_barShown)
					{
						if ((Object)(object)_windupBar != (Object)null)
						{
							((Component)_windupBar).gameObject.SetActive(false);
						}
						_barShown = false;
					}
				}
				else
				{
					Crosshair val;
					try
					{
						val = Crosshair.instance;
					}
					catch
					{
						val = null;
					}
					if (val != null && (!((Object)(object)_slickText == (Object)null) || CreateSlick(val)))
					{
						RefreshSlickVisual(val);
						TickWindupBar(val);
					}
				}
			}
			catch
			{
				_slickText = null;
				_windupBar = null;
				_windupBarRt = null;
				_glyphShown = false;
				_glyphText = null;
				_barShown = false;
			}
		}

		private static void TickWindupBar(Crosshair ch)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_windupBar == (Object)null)
			{
				return;
			}
			if ((int)ch.crosshairMode != 2)
			{
				if (_barShown)
				{
					((Component)_windupBar).gameObject.SetActive(false);
					_barShown = false;
				}
				return;
			}
			if (!_barShown)
			{
				((Component)_windupBar).gameObject.SetActive(true);
				_barShown = true;
			}
			float num = Mathf.Clamp01(ch.windupPower);
			float num2 = Mathf.Clamp(Factor, 0.5f, 2f);
			float num3 = 220f * num2 * num;
			if ((Object)(object)_windupBarRt != (Object)null && Mathf.Abs(num3 - _lastBarW) > 0.25f)
			{
				_windupBarRt.sizeDelta = new Vector2(num3, 6f * num2);
				_lastBarW = num3;
			}
		}

		private static void RefreshSlickVisual(Crosshair crosshair)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			bool flag = _modeMirror == 2;
			float factor = Factor;
			bool flag2 = factor > 0.001f;
			if (_glyphShown != flag2)
			{
				((Component)_slickText).gameObject.SetActive(flag2);
				_glyphShown = flag2;
			}
			if (flag2)
			{
				bool flag3 = (crosshair != null && (int)crosshair.crosshairMode == 1) || IsCarrying();
				string text = ((!flag) ? (flag3 ? "( x )" : "( + )") : (flag3 ? "x" : "+"));
				if ((object)text != _glyphText)
				{
					((TMP_Text)_slickText).text = text;
					_glyphText = text;
				}
				float num = 72f * factor * (flag ? 0.75f : 1f);
				if (Mathf.Abs(num - _glyphSize) > 0.01f)
				{
					((TMP_Text)_slickText).fontSize = num;
					_glyphSize = num;
				}
			}
		}

		private static bool CreateSlick(Crosshair crosshair)
		{
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_005b: 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_0073: 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_0146: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Transform crosshairNormal = crosshair.crosshairNormal;
				if ((Object)(object)crosshairNormal == (Object)null || (Object)(object)crosshairNormal.parent == (Object)null)
				{
					return false;
				}
				GameObject val = new GameObject("crosshair_slick");
				val.transform.SetParent(crosshairNormal.parent, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				RectTransform component = ((Component)crosshairNormal).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					val2.anchorMin = component.anchorMin;
					val2.anchorMax = component.anchorMax;
					val2.pivot = component.pivot;
					val2.anchoredPosition = component.anchoredPosition;
				}
				val2.sizeDelta = new Vector2(400f, 160f);
				_slickText = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_slickText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_slickText).enableWordWrapping = false;
				((TMP_Text)_slickText).overflowMode = (TextOverflowModes)0;
				((Graphic)_slickText).raycastTarget = false;
				((TMP_Text)_slickText).text = "( + )";
				((TMP_Text)_slickText).fontSize = 72f;
				((TMP_Text)_slickText).fontStyle = (FontStyles)0;
				TMP_FontAsset val3 = FindSlickFont();
				if ((Object)(object)val3 != (Object)null)
				{
					((TMP_Text)_slickText).font = val3;
				}
				_glyphShown = true;
				_glyphText = null;
				_glyphSize = 72f;
				_barShown = false;
				_lastBarW = -1f;
				GameObject val4 = new GameObject("crosshair_slick_windup");
				val4.transform.SetParent(crosshairNormal.parent, false);
				RectTransform val5 = val4.AddComponent<RectTransform>();
				val5.anchorMin = val2.anchorMin;
				val5.anchorMax = val2.anchorMax;
				val5.pivot = new Vector2(0.5f, 0.5f);
				val5.anchoredPosition = val2.anchoredPosition + new Vector2(0f, -46f);
				val5.sizeDelta = new Vector2(0f, 6f);
				_windupBar = val4.AddComponent<Image>();
				((Graphic)_windupBar).raycastTarget = false;
				_windupBarRt = val5;
				val4.SetActive(false);
				ModSettingsApi.RegisterPreviewGraphic((Graphic)(object)_slickText);
				ModSettingsApi.RegisterPreviewGraphic((Graphic)(object)_windupBar);
				ManualLogSource logger = Plugin.Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"Slick crosshair created");
				}
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				if (logger2 != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Slick crosshair creation failed: ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(ex.Message);
					}
					logger2.LogWarning(val6);
				}
				_slickText = null;
				return false;
			}
		}

		private static void ScaleTransform(Transform t, float factor)
		{
			//IL_0034: 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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			if (!((Object)(object)t == (Object)null))
			{
				int instanceID = ((Object)t).GetInstanceID();
				if (!BaseScales.TryGetValue(instanceID, out var value))
				{
					value = t.localScale;
					BaseScales[instanceID] = value;
				}
				t.localScale = value * factor;
			}
		}
	}
	[HarmonyPatch]
	internal static class EspFeature
	{
		private const int MotionOverlayType = 15;

		internal const int ModeNubKey = 4;

		internal const int ModeItems = 5;

		internal const int ModePlayerNames = 6;

		internal const int ModePlayer = 7;

		internal const int ModeShowAll = 8;

		internal const int ModeShowAllImportant = 9;

		private const int VanillaCount = 4;

		private static bool _injected;

		private static float _nextGate;

		private static readonly Color EspRed = new Color(0.85f, 0.15f, 0.08f);

		private static readonly Dictionary<int, Color> BaseLabelColour = new Dictionary<int, Color>();

		private static readonly Dictionary<int, string> BaseRowTitle = new Dictionary<int, string>();

		internal static void Register()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ClassInjector.RegisterTypeInIl2Cpp<EspOverlay>();
				GameObject val = new GameObject("SmolModsEsp");
				Object.DontDestroyOnLoad((Object)val);
				((Object)val).hideFlags = (HideFlags)61;
				val.AddComponent<EspOverlay>();
				_injected = true;
			}
			catch
			{
			}
			ModSettingsApi.AddTicker((Action)GateMotionOverlay);
		}

		private static void GateMotionOverlay()
		{
			if (!_injected || Time.unscaledTime < _nextGate)
			{
				return;
			}
			_nextGate = Time.unscaledTime + 0.5f;
			try
			{
				SettingsHanger motionOverlayHanger = SettingsWardrobe.motionOverlayHanger;
				if (motionOverlayHanger == null || motionOverlayHanger.possibleValues == null)
				{
					return;
				}
				bool flag = CrosshairSizeFeature.CurrentMode == 2;
				List<int> possibleValues = motionOverlayHanger.possibleValues;
				bool flag2 = possibleValues.Count > 4;
				if (flag && !flag2)
				{
					possibleValues.Add(4);
					possibleValues.Add(5);
					possibleValues.Add(6);
					possibleValues.Add(7);
					possibleValues.Add(8);
					possibleValues.Add(9);
				}
				else if (!flag && flag2)
				{
					while (possibleValues.Count > 4)
					{
						possibleValues.RemoveAt(possibleValues.Count - 1);
					}
					if (motionOverlayHanger.value >= 4)
					{
						motionOverlayHanger.value = 0;
						motionOverlayHanger.Save();
					}
				}
			}
			catch (Exception)
			{
			}
		}

		internal static int ActiveMode()
		{
			try
			{
				if (CrosshairSizeFeature.CurrentMode != 2)
				{
					return -1;
				}
				SettingsHanger motionOverlayHanger = SettingsWardrobe.motionOverlayHanger;
				if (motionOverlayHanger == null)
				{
					return -1;
				}
				int value = motionOverlayHanger.value;
				return (value >= 4) ? value : (-1);
			}
			catch
			{
				return -1;
			}
		}

		[HarmonyPatch(typeof(SettingsHelper), "GetArrayLabelValue")]
		[HarmonyPostfix]
		private static void Label_Postfix(SettingsType settingsType, int value, ref DisplayType displayType, ref string __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)settingsType == 15 && value >= 4)
			{
				__result = value switch
				{
					4 => "Nub/Key/Pack", 
					5 => "All Items", 
					6 => "Player Names", 
					7 => "Player", 
					8 => "Show All", 
					9 => "Show All Important", 
					_ => __result, 
				};
				displayType = (DisplayType)1;
			}
		}

		[HarmonyPatch(typeof(SettingsRow), "Refresh")]
		[HarmonyPostfix]
		private static void Row_Postfix(SettingsRow __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_005e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((int)__instance.settingsType != 15 || (Object)(object)__instance.arrayLabel == (Object)null)
				{
					return;
				}
				TMP_Text val = __instance.arrayLabel.textElement ?? ((Component)__instance.arrayLabel).GetComponent<TMP_Text>();
				if (!((Object)(object)val == (Object)null))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (!BaseLabelColour.ContainsKey(instanceID))
					{
						BaseLabelColour[instanceID] = ((Graphic)val).color;
					}
					SettingsHanger motionOverlayHanger = SettingsWardrobe.motionOverlayHanger;
					bool flag = motionOverlayHanger != null && motionOverlayHanger.value >= 4;
					((Graphic)val).color = (flag ? EspRed : BaseLabelColour[instanceID]);
					RetitleRow(__instance, flag);
				}
			}
			catch
			{
			}
		}

		private static void RetitleRow(SettingsRow row, bool ours)
		{
			try
			{
				LocalizedText title = row.title;
				if ((Object)(object)title == (Object)null)
				{
					return;
				}
				TMP_Text val = title.textElement ?? ((Component)title).GetComponent<TMP_Text>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (!BaseRowTitle.ContainsKey(instanceID))
				{
					string text = val.text;
					if (text == "Debug Esp")
					{
						return;
					}
					BaseRowTitle[instanceID] = text;
				}
				string text2 = (ours ? "Debug Esp" : BaseRowTitle[instanceID]);
				if (val.text != text2)
				{
					val.text = text2;
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(WorldMenuManager), "ApplyMotionOverlaySetting")]
		[HarmonyPrefix]
		private static bool ApplyOverlay_Prefix(WorldMenuManager __instance)
		{
			try
			{
				SettingsHanger motionOverlayHanger = SettingsWardrobe.motionOverlayHanger;
				if (motionOverlayHanger == null || motionOverlayHanger.value < 4)
				{
					return true;
				}
				if ((Object)(object)__instance.motionOverlayCross != (Object)null)
				{
					((Component)__instance.motionOverlayCross).gameObject.SetActive(false);
				}
				if ((Object)(object)__instance.motionOverlayDots != (Object)null)
				{
					((Component)__instance.motionOverlayDots).gameObject.SetActive(false);
				}
				if ((Object)(object)__instance.motionOverlayFrame != (Object)null)
				{
					((Component)__instance.motionOverlayFrame).gameObject.SetActive(false);
				}
				return false;
			}
			catch
			{
				return true;
			}
		}
	}
	[HarmonyPatch]
	internal static class EspTouch
	{
		internal sealed class Entry
		{
			public Prop prop;

			public float time;
		}

		internal static readonly Dictionary<IntPtr, Entry> Touched = new Dictionary<IntPtr, Entry>();

		internal static void Stamp(Prop prop)
		{
			try
			{
				if (!((Object)(object)prop == (Object)null))
				{
					IntPtr pointer = ((Il2CppObjectBase)prop).Pointer;
					if (Touched.TryGetValue(pointer, out var value))
					{
						value.time = Time.unscaledTime;
						value.prop = prop;
					}
					else
					{
						Touched[pointer] = new Entry
						{
							prop = prop,
							time = Time.unscaledTime
						};
					}
				}
			}
			catch
			{
			}
		}

		internal static void Purge(float maxAge)
		{
			if (Touched.Count == 0)
			{
				return;
			}
			float num = Time.unscaledTime - maxAge;
			List<IntPtr> list = null;
			foreach (KeyValuePair<IntPtr, Entry> item in Touched)
			{
				if (item.Value.time < num)
				{
					(list ?? (list = new List<IntPtr>())).Add(item.Key);
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (IntPtr item2 in list)
			{
				Touched.Remove(item2);
			}
		}

		internal static void Clear()
		{
			Touched.Clear();
		}

		[HarmonyPatch(typeof(PlayerNetworking), "OnSetHeld")]
		[HarmonyPostfix]
		private static void OnSetHeld_Postfix(PlayerHeldInformation __0, PlayerHeldInformation __1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			try
			{
				if ((int)__0.heldType == 1)
				{
					Stamp(__0.GetProp());
				}
			}
			catch
			{
			}
			try
			{
				if ((int)__1.heldType == 1)
				{
					Stamp(__1.GetProp());
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(Prop), "SetHeld")]
		[HarmonyPostfix]
		private static void SetHeld_Postfix(Prop __instance)
		{
			Stamp(__instance);
		}

		[HarmonyPatch(typeof(Prop), "SetDropped", new Type[] { typeof(PlayerCharacter) })]
		[HarmonyPostfix]
		private static void SetDropped1_Postfix(Prop __instance)
		{
			Stamp(__instance);
		}

		[HarmonyPatch(typeof(Prop), "SetDropped", new Type[]
		{
			typeof(PlayerCharacter),
			typeof(Vector3),
			typeof(Vector3)
		})]
		[HarmonyPostfix]
		private static void SetDropped2_Postfix(Prop __instance)
		{
			Stamp(__instance);
		}

		[HarmonyPatch(typeof(Prop), "OnChangePropHome")]
		[HarmonyPostfix]
		private static void OnChangePropHome_Postfix(Prop __instance)
		{
			Stamp(__instance);
		}

		[HarmonyPatch(typeof(PropHome), "SetPinned")]
		[HarmonyPostfix]
		private static void SetPinned_Postfix(Prop __0)
		{
			Stamp(__0);
		}

		[HarmonyPatch(typeof(PropHome), "SetUnpinned")]
		[HarmonyPostfix]
		private static void SetUnpinned_Postfix(Prop __0)
		{
			Stamp(__0);
		}
	}
	public class EspOverlay : MonoBehaviour
	{
		private sealed class ItemState
		{
			public Prop prop;

			public Transform kernal;

			public Vector3 lastPos;

			public float lastMoved = -9999f;

			public float alpha;

			public int kind;

			public int carry;
		}

		private sealed class NameInfo
		{
			public string name;

			public bool isHost;

			public ulong netId;

			public float refreshAt;

			public int distShown = -1;

			public string distText = "";
		}

		private GUIStyle _marker;

		private GUIStyle _name;

		private GUIStyle _tag;

		private const float NubWorldSize = 0.55f;

		private const float KeyWorldSize = 0.5f;

		private const float ItemWorldSize = 0.4f;

		private const float PlayerWorldHeight = 1.7f;

		private const float RecentSeconds = 300f;

		private const float IdleCutoff = 10f;

		private const float MoveEpsilon = 0.08f;

		private const int MinMarker = 8;

		private const int MaxMarker = 90;

		private const float DoubleTapWindow = 0.35f;

		private const float FadeSpeed = 2.2f;

		private const float IdleTeardownSeconds = 10f;

		private const int NameFar = 9;

		private const int NameMid = 11;

		private const int NameClose = 15;

		private static readonly Color NubMoved = new Color(0.9f, 0.11f, 0.05f);

		private static readonly Color NubIdle = Color.white;

		private static readonly Color KeyYellow = new Color(1f, 0.85f, 0.1f);

		private static readonly Color PackBlue = new Color(0.157f, 0.427f, 0.596f);

		private bool _stuck;

		private float _master;

		private float _lastTapDown = -9f;

		private float _idleSince = -1f;

		private const int KindItem = 0;

		private const int KindNub = 1;

		private const int KindKey = 2;

		private const int KindContainer = 3;

		private const int CarryLoose = 0;

		private const int CarryHeld = 1;

		private const int CarryBackpack = 2;

		private const int CarrySeated = 3;

		private const int CarryBelt = 4;

		private const int CarryWorn = 5;

		private readonly Dictionary<IntPtr, ItemState> _items = new Dictionary<IntPtr, ItemState>();

		private readonly Dictionary<IntPtr, int> _kindCache = new Dictionary<IntPtr, int>();

		private readonly HashSet<IntPtr> _heldSet = new HashSet<IntPtr>();

		private readonly HashSet<IntPtr> _localHeldSet = new HashSet<IntPtr>();

		private readonly List<IntPtr> _forget = new List<IntPtr>();

		private float _nextRescan;

		private float _nextSample;

		private IntPtr _lastLocalPtr;

		private const float SeatedFadeSeconds = 45f;

		private const float ItemForgetDistance = 50f;

		private const float TorsoVsHeadRadius = 0.8f;

		private const float BumVsHeadRadius = 1.35f;

		private const float BellyLerp = 0.6f;

		private const int BodyMaxMarker = 500;

		private readonly Dictionary<IntPtr, NameInfo> _names = new Dictionary<IntPtr, NameInfo>();

		private ulong _hostNetId;

		private float _nextHostScan;

		public EspOverlay(IntPtr ptr)
			: base(ptr)
		{
		}

		private void PickGlyphs()
		{
		}

		private void Update()
		{
			try
			{
				HandleToggle();
				bool key = Input.GetKey((KeyCode)9);
				float num = ((_stuck || key) ? 1f : 0f);
				_master = Mathf.MoveTowards(_master, num, 2.2f * Time.unscaledDeltaTime);
				if (!_stuck && !key && _master <= 0.001f)
				{
					if (_idleSince < 0f)
					{
						_idleSince = Time.unscaledTime;
					}
					else if (_items.Count > 0 && Time.unscaledTime - _idleSince > 10f)
					{
						_items.Clear();
						_kindCache.Clear();
						_names.Clear();
						_heldSet.Clear();
						EspTouch.Purge(300f);
						_nextRescan = 0f;
					}
				}
				else
				{
					_idleSince = -1f;
					if (Time.unscaledTime >= _nextRescan)
					{
						_nextRescan = Time.unscaledTime + 2f;
						Rescan();
					}
					if (Time.unscaledTime >= _nextSample)
					{
						_nextSample = Time.unscaledTime + 0.25f;
						SampleItems();
					}
				}
			}
			catch
			{
			}
		}

		private void HandleToggle()
		{
			if (Input.GetKeyDown((KeyCode)9))
			{
				float unscaledTime = Time.unscaledTime;
				if (_stuck)
				{
					_stuck = false;
				}
				else if (unscaledTime - _lastTapDown <= 0.35f)
				{
					_stuck = true;
				}
				_lastTapDown = unscaledTime;
			}
		}

		private void Rescan()
		{
			IntPtr intPtr = IntPtr.Zero;
			try
			{
				PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
				if ((Object)(object)localPlayerCharacter != (Object)null)
				{
					intPtr = ((Il2CppObjectBase)localPlayerCharacter).Pointer;
				}
			}
			catch
			{
			}
			if (intPtr != _lastLocalPtr)
			{
				_lastLocalPtr = intPtr;
				_items.Clear();
				_kindCache.Clear();
				_names.Clear();
				_heldSet.Clear();
				EspTouch.Clear();
			}
			EspTouch.Purge(300f);
			HashSet<IntPtr> hashSet = new HashSet<IntPtr>();
			List<Prop> allProps = Prop.allProps;
			if (allProps != null)
			{
				for (int i = 0; i < allProps.Count; i++)
				{
					Prop val = allProps[i];
					if (!((Object)(object)val == (Object)null))
					{
						IntPtr pointer = ((Il2CppObjectBase)val).Pointer;
						if (!_kindCache.TryGetValue(pointer, out var value))
						{
							value = Classify(val);
							_kindCache[pointer] = value;
						}
						if (value != 0)
						{
							hashSet.Add(pointer);
							Track(pointer, val, value);
						}
					}
				}
			}
			foreach (KeyValuePair<IntPtr, EspTouch.Entry> item in EspTouch.Touched)
			{
				Prop prop = item.Value.prop;
				if (!((Object)(object)prop == (Object)null))
				{
					IntPtr key = item.Key;
					if (!_kindCache.TryGetValue(key, out var value2))
					{
						value2 = Classify(prop);
						_kindCache[key] = value2;
					}
					hashSet.Add(key);
					ItemState itemState = Track(key, prop, value2);
					if (itemState != null && item.Value.time > itemState.lastMoved)
					{
						itemState.lastMoved = item.Value.time;
					}
				}
			}
			if (_items.Count <= hashSet.Count)
			{
				return;
			}
			List<IntPtr> list = null;
			foreach (KeyValuePair<IntPtr, ItemState> item2 in _items)
			{
				if (!hashSet.Contains(item2.Key))
				{
					(list ?? (list = new List<IntPtr>())).Add(item2.Key);
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (IntPtr item3 in list)
			{
				_items.Remove(item3);
			}
		}

		private ItemState Track(IntPtr key, Prop p, int kind)
		{
			//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)
			if (_items.TryGetValue(key, out var value))
			{
				value.prop = p;
				return value;
			}
			Transform kernal;
			try
			{
				kernal = p.kernal;
			}
			catch
			{
				return null;
			}
			if ((Object)(object)kernal == (Object)null)
			{
				return null;
			}
			value = new ItemState
			{
				prop = p,
				kernal = kernal,
				lastPos = kernal.position,
				kind = kind
			};
			_items[key] = value;
			return value;
		}

		private static int Classify(Prop p)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			try
			{
				if ((Object)(object)((Component)p).GetComponent<RewardGourd>() != (Object)null)
				{
					return 1;
				}
			}
			catch
			{
			}
			try
			{
				List<PropGroup> propGroups = p.propGroups;
				if (propGroups != null)
				{
					for (int i = 0; i < propGroups.Count; i++)
					{
						switch ((int)propGroups[i])
						{
						case 32:
						case 35:
						case 36:
						case 37:
						case 38:
							return 2;
						case 24:
						case 30:
							return 3;
						}
					}
				}
			}
			catch
			{
			}
			return 0;
		}

		private void SampleItems()
		{
			//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)
			//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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			_heldSet.Clear();
			_localHeldSet.Clear();
			try
			{
				List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
				if (allPlayerCharacters != null)
				{
					for (int i = 0; i < allPlayerCharacters.Count; i++)
					{
						PlayerCharacter val = allPlayerCharacters[i];
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						try
						{
							PlayerHands hands = val.hands;
							Prop val2 = ((hands != null) ? hands.heldProp : null);
							if ((Object)(object)val2 != (Object)null)
							{
								IntPtr pointer = ((Il2CppObjectBase)val2).Pointer;
								_heldSet.Add(pointer);
								if (((NetworkBehaviour)val).isLocalPlayer)
								{
									_localHeldSet.Add(pointer);
								}
							}
						}
						catch
						{
						}
					}
				}
			}
			catch
			{
			}
			foreach (KeyValuePair<IntPtr, ItemState> item in _items)
			{
				ItemState value = item.Value;
				if (!((Object)(object)value.kernal == (Object)null))
				{
					Vector3 position;
					try
					{
						position = value.kernal.position;
					}
					catch
					{
						continue;
					}
					Vector3 val3 = position - value.lastPos;
					if (((Vector3)(ref val3)).sqrMagnitude > 0.0064f)
					{
						value.lastMoved = Time.unscaledTime;
					}
					value.lastPos = position;
					value.carry = CarryOf(item.Key, value);
				}
			}
		}

		private int CarryOf(IntPtr key, ItemState st)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected I4, but got Unknown
			if (_heldSet.Contains(key))
			{
				return 1;
			}
			try
			{
				PropHome currentHome = st.prop.currentHome;
				if ((Object)(object)currentHome == (Object)null)
				{
					return 0;
				}
				int num = (int)currentHome.saveableHomeName;
				if (st.kind == 1 && num >= 100 && num <= 177)
				{
					return 3;
				}
				if (st.kind == 2 && num >= 210 && num <= 225)
				{
					return 3;
				}
				PlayerCharacter parentCharacter = currentHome.parentCharacter;
				if ((Object)(object)parentCharacter != (Object)null)
				{
					return IsWearSlot(currentHome, parentCharacter) ? 5 : 2;
				}
				Prop parentProp = currentHome.parentProp;
				if ((Object)(object)parentProp != (Object)null)
				{
					PropHome currentHome2 = parentProp.currentHome;
					if ((Object)(object)currentHome2 != (Object)null)
					{
						PlayerCharacter parentCharacter2 = currentHome2.parentCharacter;
						if ((Object)(object)parentCharacter2 != (Object)null)
						{
							return IsHolsterSlot(currentHome2, parentCharacter2) ? 4 : 2;
						}
					}
				}
			}
			catch
			{
			}
			return 0;
		}

		private static bool IsWearSlot(PropHome home, PlayerCharacter owner)
		{
			try
			{
				PlayerRegistry registry = owner.registry;
				if (registry == null)
				{
					return false;
				}
				IntPtr pointer = ((Il2CppObjectBase)home).Pointer;
				PropHome backpackPocket = registry.backpackPocket;
				if ((Object)(object)backpackPocket != (Object)null && ((Il2CppObjectBase)backpackPocket).Pointer == pointer)
				{
					return true;
				}
				PropHome holsterPocket = registry.holsterPocket;
				if ((Object)(object)holsterPocket != (Object)null && ((Il2CppObjectBase)holsterPocket).Pointer == pointer)
				{
					return true;
				}
				PropHome blindfoldPocket = registry.blindfoldPocket;
				if ((Object)(object)blindfoldPocket != (Object)null && ((Il2CppObjectBase)blindfoldPocket).Pointer == pointer)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		private static bool IsHolsterSlot(PropHome home, PlayerCharacter owner)
		{
			try
			{
				PlayerRegistry registry = owner.registry;
				PropHome val = ((registry != null) ? registry.holsterPocket : null);
				return (Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)home).Pointer;
			}
			catch
			{
			}
			return false;
		}

		private void OnGUI()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_006b: 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_007c: Expected O, but got Unknown
			//IL_007d: 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_0095: Expected O, but got Unknown
			//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_00a7: Expected O, but got Unknown
			//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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if (_master <= 0.001f)
			{
				return;
			}
			if (EspFeature.ActiveMode() < 0 && !_stuck)
			{
				_stuck = false;
			}
			if (Event.current == null || (int)Event.current.type != 7)
			{
				return;
			}
			int num = EspFeature.ActiveMode();
			if (num < 0 && _master <= 0.001f)
			{
				return;
			}
			Camera val = ResolveCamera();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (_marker == null)
			{
				_marker = new GUIStyle
				{
					alignment = (TextAnchor)4
				};
				_name = new GUIStyle
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				_tag = new GUIStyle
				{
					alignment = (TextAnchor)4
				};
				PickGlyphs();
			}
			float pxPerMetreAt;
			Vector3 position;
			try
			{
				pxPerMetreAt = (float)Screen.height / (2f * Mathf.Tan(val.fieldOfView * 0.5f * ((float)Math.PI / 180f)));
				position = ((Component)val).transform.position;
			}
			catch
			{
				return;
			}
			bool flag = num < 0 || num == 7 || num == 8 || num == 9;
			bool flag2 = num == 6;
			bool flag3 = num < 0 || num == 4 || num == 8 || num == 9;
			bool flag4 = num < 0 || num == 5 || num == 8;
			try
			{
				if (flag || flag2)
				{
					RefreshHost();
					DrawPlayers(val, pxPerMetreAt, position, flag2);
					if (!flag2)
					{
						DrawCorpses(val, pxPerMetreAt, position);
					}
				}
				if (flag3 || flag4)
				{
					DrawItems(val, pxPerMetreAt, position, flag3, flag4);
				}
			}
			catch
			{
			}
		}

		private static Camera ResolveCamera()
		{
			try
			{
				WorldManager instance = WorldManager.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerCameraReferences != (Object)null && (Object)(object)instance.playerCameraReferences.playerCamera != (Object)null)
				{
					return instance.playerCameraReferences.playerCamera;
				}
			}
			catch
			{
			}
			try
			{
				return Camera.main;
			}
			catch
			{
				return null;
			}
		}

		private static float EyeDistance(Vector3 eye, Vector3 world)
		{
			//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)
			return Vector3.Distance(eye, world);
		}

		private void DrawPlayers(Camera cam, float pxPerMetreAt1, Vector3 eyePos, bool namesOnly)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
			if (allPlayerCharacters == null)
			{
				return;
			}
			PlayerCharacter val = null;
			try
			{
				val = WorldManager.localPlayerCharacter;
			}
			catch
			{
			}
			for (int i = 0; i < allPlayerCharacters.Count; i++)
			{
				PlayerCharacter val2 = allPlayerCharacters[i];
				if (!((Object)(object)val2 == (Object)null) && (!((Object)(object)val != (Object)null) || !(((Il2CppObjectBase)val2).Pointer == ((Il2CppObjectBase)val).Pointer)))
				{
					DrawBodyParts(cam, val2, eyePos, pxPerMetreAt1, namesOnly);
				}
			}
		}

		private void DrawCorpses(Camera cam, float pxPerMetreAt1, Vector3 eyePos)
		{
			//IL_011d: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0076: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00a3: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00ef: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			List<Corpse> allCorpses;
			try
			{
				allCorpses = Corpse.allCorpses;
			}
			catch
			{
				return;
			}
			if (allCorpses == null)
			{
				return;
			}
			for (int i = 0; i < allCorpses.Count; i++)
			{
				Corpse val = allCorpses[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Transform val2 = null;
				try
				{
					if ((Object)(object)val.prop != (Object)null)
					{
						val2 = val.prop.kernal;
					}
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = ((Component)val).transform;
					}
				}
				catch
				{
					continue;
				}
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Vector3 position = val2.position;
				Vector3 val3 = cam.WorldToScreenPoint(position);
				if (!(val3.z <= 0.01f))
				{
					Color head = Color.white;
					Color torso = Color.white;
					Color legs = Color.white;
					try
					{
						head = (Color)(((??)PlayerPalette.PaletteDisplayColor(val.headColorIndex)) ?? Color.white);
						torso = (Color)(((??)PlayerPalette.PaletteDisplayColor(val.torsoColorIndex)) ?? Color.white);
						legs = (Color)(((??)PlayerPalette.PaletteDisplayColor(val.legsColorIndex)) ?? Color.white);
					}
					catch
					{
					}
					DrawBody(val3, EyeDistance(eyePos, position), pxPerMetreAt1, head, torso, legs, "x", null, _master);
				}
			}
		}

		private void DrawBodyParts(Camera cam, PlayerCharacter pc, Vector3 eyePos, float pxPerMetreAt1, bool namesOnly)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!BodyAnchors(pc, out var head, out var torso, out var bum, out var headRadius))
			{
				return;
			}
			if (namesOnly)
			{
				Vector3 val = cam.WorldToScreenPoint(head);
				if (!(val.z <= 0.01f))
				{
					float num = EyeDistance(eyePos, head);
					int num2 = Mathf.Clamp(Mathf.RoundToInt(2f * headRadius * pxPerMetreAt1 / Mathf.Max(num, 0.05f) / 0.72f), 8, 500);
					int num3 = ((num < 25f) ? 15 : ((num > 80f) ? 9 : 11));
					DrawNameRow(pc, val.x, (float)Screen.height - val.y - (float)num2 * 0.36f - (float)num3, num3, num);
				}
				return;
			}
			DrawBallRing(cam, eyePos, pxPerMetreAt1, bum, headRadius * 1.35f, PartColor(pc, (LookPart)2), out var x, out var y);
			DrawBallRing(cam, eyePos, pxPerMetreAt1, torso, headRadius * 0.8f, PartColor(pc, (LookPart)1), out y, out x);
			float x2;
			float y2;
			int num4 = DrawBallRing(cam, eyePos, pxPerMetreAt1, head, headRadius, PartColor(pc, (LookPart)0), out x2, out y2);
			if (num4 > 0)
			{
				string text = EyeGlyph(pc);
				if (!string.IsNullOrEmpty(text))
				{
					Glyph(_marker, x2, y2, text, Color.white, Mathf.Max(3, Mathf.RoundToInt((float)num4 * 0.5f)), _master);
				}
				float num5 = EyeDistance(eyePos, head);
				int num6 = ((num5 < 25f) ? 15 : ((num5 > 80f) ? 9 : 11));
				DrawNameRow(pc, x2, y2 - (float)num4 * 0.36f - (float)num6, num6, num5);
			}
		}

		private int DrawBallRing(Camera cam, Vector3 eyePos, float pxPerMetreAt1, Vector3 world, float radius, Color colour, out float x, out float y)
		{
			//IL_0011: 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_0019: 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_0029: 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_006f: 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)
			x = 0f;
			y = 0f;
			Vector3 val = cam.WorldToScreenPoint(world);
			if (val.z <= 0.01f)
			{
				return 0;
			}
			float num = EyeDistance(eyePos, world);
			int num2 = Mathf.Clamp(Mathf.RoundToInt(2f * radius * pxPerMetreAt1 / Mathf.Max(num, 0.05f) / 0.72f), 8, 500);
			x = val.x;
			y = (float)Screen.height - val.y;
			Glyph(_marker, x, y, "○", colour, num2, _master);
			return num2;
		}

		private static bool BodyAnchors(PlayerCharacter pc, out Vector3 head, out Vector3 torso, out Vector3 bum, out float headRadius)
		{
			//IL_0003: 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_0009: 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)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//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_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			head = (torso = (bum = Vector3.zero));
			headRadius = 0f;
			Transform val = null;
			Transform val2 = null;
			try
			{
				PlayerRegistry registry = pc.registry;
				val = ((registry != null) ? registry.headBone : null);
			}
			catch
			{
			}
			try
			{
				FootstepSound footstepSound = pc.footstepSound;
				val2 = ((footstepSound != null) ? footstepSound.Bum : null);
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return false;
			}
			head = val.position;
			bum = val2.position;
			bool flag = false;
			try
			{
				PlayerArms arms = pc.arms;
				object obj3;
				if (arms == null)
				{
					obj3 = null;
				}
				else
				{
					LimbSpline leftArmLimbSpline = arms.leftArmLimbSpline;
					obj3 = ((leftArmLimbSpline != null) ? leftArmLimbSpline.startTransform : null);
				}
				Transform val3 = (Transform)obj3;
				object obj4;
				if (arms == null)
				{
					obj4 = null;
				}
				else
				{
					LimbSpline rightArmLimbSpline = arms.rightArmLimbSpline;
					obj4 = ((rightArmLimbSpline != null) ? rightArmLimbSpline.startTransform : null);
				}
				Transform val4 = (Transform)obj4;
				if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
				{
					torso = (val3.position + val4.position) * 0.5f;
					flag = true;
				}
			}
			catch
			{
			}
			if (!flag)
			{
				torso = Vector3.Lerp(head, bum, 0.5f);
			}
			try
			{
				PlayerRegistry registry2 = pc.registry;
				object obj6;
				if (registry2 == null)
				{
					obj6 = null;
				}
				else
				{
					LimbSpline leftLegLimbSpline = registry2.leftLegLimbSpline;
					obj6 = ((leftLegLimbSpline != null) ? leftLegLimbSpline.startTransform : null);
				}
				Transform val5 = (Transform)obj6;
				object obj7;
				if (registry2 == null)
				{
					obj7 = null;
				}
				else
				{
					LimbSpline rightLegLimbSpline = registry2.rightLegLimbSpline;
					obj7 = ((rightLegLimbSpline != null) ? rightLegLimbSpline.startTransform : null);
				}
				Transform val6 = (Transform)obj7;
				if ((Object)(object)val5 != (Object)null && (Object)(object)val6 != (Object)null)
				{
					bum = Vector3.Lerp(torso, (val5.position + val6.position) * 0.5f, 0.6f);
				}
			}
			catch
			{
			}
			try
			{
				MeshFilter headMeshFilter = pc.registry.headMeshFilter;
				Mesh val7 = (((Object)(object)headMeshFilter != (Object)null) ? headMeshFilter.sharedMesh : null);
				if ((Object)(object)val7 != (Object)null)
				{
					Bounds bounds = val7.bounds;
					Vector3 extents = ((Bounds)(ref bounds)).extents;
					Vector3 lossyScale = ((Component)headMeshFilter).transform.lossyScale;
					headRadius = Mathf.Max(extents.x * Mathf.Abs(lossyScale.x), Mathf.Max(extents.y * Mathf.Abs(lossyScale.y), extents.z * Mathf.Abs(lossyScale.z)));
				}
			}
			catch
			{
			}
			if (headRadius <= 0.001f)
			{
				headRadius = Vector3.Distance(head, bum) * 0.35f;
			}
			return true;
		}

		private void DrawBody(Vector3 sp, float dist, float pxPerMetreAt1, Color head, Color torso, Color legs, string faceGlyph, string name, float alpha)
		{
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp(1.7f * pxPerMetreAt1 / Mathf.Max(dist, 0.05f), 24f, 270f) / 3f), 8, 90);
			float num2 = (float)num * 0.72f;
			float x = sp.x;
			float num3 = (float)Screen.height - sp.y;
			float num4 = num3 - num2;
			float y = num3 + num2;
			Glyph(_marker, x, num4, "○", head, num, alpha);
			Glyph(_marker, x, num3, "○", torso, num, alpha);
			Glyph(_marker, x, y, "○", legs, num, alpha);
			if (!string.IsNullOrEmpty(faceGlyph))
			{
				Glyph(_marker, x, num4, faceGlyph, Color.white, Mathf.Max(3, Mathf.RoundToInt((float)num * 0.62f)), alpha);
			}
			if (!string.IsNullOrEmpty(name))
			{
				int num5 = ((dist < 25f) ? 15 : ((dist > 80f) ? 9 : 11));
				Glyph(_name, x, num4 - num2 - (float)num5, name, Color.white, num5, alpha);
			}
		}

		private void DrawItems(Camera cam, float pxPerMetreAt1, Vector3 eyePos, bool nubKeys, bool items)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0090: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: 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_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			float unscaledTime = Time.unscaledTime;
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			_forget.Clear();
			foreach (KeyValuePair<IntPtr, ItemState> item in _items)
			{
				ItemState value = item.Value;
				if (!((value.kind == 0) ? items : (nubKeys || items)) || (Object)(object)value.kernal == (Object)null || value.carry == 5)
				{
					continue;
				}
				Vector3 position;
				try
				{
					position = value.kernal.position;
				}
				catch
				{
					continue;
				}
				Vector3 val = cam.WorldToScreenPoint(position);
				bool flag = val.z > 0.01f;
				float num = EyeDistance(eyePos, position);
				if (value.kind == 0 && num > 50f)
				{
					_forget.Add(item.Key);
					continue;
				}
				float num2 = unscaledTime - value.lastMoved;
				bool flag2 = num2 < 300f;
				bool flag3 = flag && !_localHeldSet.Contains(item.Key) && (flag2 || (value.kind != 0 && num <= 10f));
				value.alpha = Mathf.MoveTowards(value.alpha, flag3 ? 1f : 0f, 2.2f * unscaledDeltaTime);
				if (value.alpha <= 0.01f || !flag)
				{
					continue;
				}
				float num3 = 1f;
				float num4 = 1f;
				Color color;
				float num5;
				string text;
				switch (value.kind)
				{
				case 1:
					color = NubMoved;
					num5 = 0.55f;
					switch (value.carry)
					{
					case 3:
					{
						text = "○";
						float num9 = Mathf.Clamp01(num2 / 45f);
						color = Color.Lerp(NubMoved, NubIdle, num9);
						break;
					}
					case 1:
					case 2:
					case 4:
						text = "○";
						num3 = 0.7f;
						break;
					default:
						if (flag2)
						{
							float num7 = Mathf.Clamp01(num2 / 300f);
							float num8 = num7 * num7 * num7;
							color = Color.Lerp(NubMoved, NubIdle, num8);
							text = "⦿";
						}
						else
						{
							text = "○";
						}
						break;
					}
					break;
				case 2:
					text = "⦿";
					color = KeyYellow;
					num5 = 0.5f;
					break;
				case 3:
					text = "⦿";
					color = PackBlue;
					num5 = 0.5f;
					break;
				default:
				{
					text = ((value.carry == 1) ? "●" : "○");
					if (value.carry != 1)
					{
						num3 = 0.65f;
					}
					color = Color.white;
					num5 = 0.4f;
					float num6 = Mathf.Clamp01(num2 / 300f);
					num4 = 1f - num6 * num6 * num6;
					break;
				}
				}
				int fontSize = Mathf.Clamp(Mathf.RoundToInt(num5 * num3 * pxPerMetreAt1 / Mathf.Max(num, 0.05f)), 8, 90);
				Glyph(_marker, val.x, (float)Screen.height - val.y, text, color, fontSize, _master * value.alpha * num4);
			}
			foreach (IntPtr item2 in _forget)
			{
				_items.Remove(item2);
				EspTouch.Touched.Remove(item2);
			}
		}

		private Color PartColor(PlayerCharacter pc, LookPart part)
		{
			//IL_000e: 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_0025: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (pc.looks != null)
				{
					Color? val = PlayerPalette.PaletteDisplayColor(pc.looks.GetLookId(part));
					if (val.HasValue)
					{
						return val.Value;
					}
				}
			}
			catch
			{
			}
			return Color.white;
		}

		private void RefreshHost()
		{
			if (Time.unscaledTime < _nextHostScan)
			{
				return;
			}
			_nextHostScan = Time.unscaledTime + 5f;
			ulong num = ulong.MaxValue;
			try
			{
				List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
				if (allPlayerCharacters == null)
				{
					return;
				}
				for (int i = 0; i < allPlayerCharacters.Count; i++)
				{
					PlayerCharacter val = allPlayerCharacters[i];
					if (!((Object)(object)val == (Object)null))
					{
						ulong num2 = 0uL;
						try
						{
							num2 = ((NetworkBehaviour)val).netId;
						}
						catch
						{
						}
						if (num2 != 0L && num2 < num)
						{
							num = num2;
						}
					}
				}
			}
			catch
			{
			}
			_hostNetId = ((num == ulong.MaxValue) ? 0 : num);
		}

		private NameInfo InfoFor(PlayerCharacter pc)
		{
			IntPtr pointer = ((Il2CppObjectBase)pc).Pointer;
			if (!_names.TryGetValue(pointer, out var value))
			{
				value = new NameInfo();
				_names[pointer] = value;
			}
			if (Time.unscaledTime < value.refreshAt)
			{
				return value;
			}
			value.refreshAt = Time.unscaledTime + 5f;
			try
			{
				value.netId = ((NetworkBehaviour)pc).netId;
			}
			catch
			{
			}
			value.isHost = _hostNetId != 0L && value.netId == _hostNetId;
			string text = SteamNickname(pc);
			if (string.IsNullOrEmpty(text))
			{
				text = PlayerName(pc);
			}
			value.name = text;
			return value;
		}

		private void DrawNameRow(PlayerCharacter pc, float x, float y, int nameSize, float dist)
		{
			//IL_0030: 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_0070: Expected O, but got Unknown
			//IL_006b: 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_00d2: Expected O, but got Unknown
			//IL_00cd: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			NameInfo nameInfo;
			try
			{
				nameInfo = InfoFor(pc);
			}
			catch
			{
				return;
			}
			if (nameInfo != null && !string.IsNullOrEmpty(nameInfo.name))
			{
				Glyph(_name, x, y, nameInfo.name, Color.white, nameSize, _master);
				int fontSize = Mathf.Max(4, nameSize / 2);
				_name.fontSize = nameSize;
				float num = _name.CalcSize(new GUIContent(nameInfo.name)).x * 0.5f;
				int num2 = Mathf.RoundToInt(dist);
				if (num2 != nameInfo.distShown)
				{
					nameInfo.distShown = num2;
					nameInfo.distText = "⌞" + num2 + "m⌝";
				}
				_tag.fontSize = fontSize;
				float num3 = _tag.CalcSize(new GUIContent(nameInfo.distText)).x * 0.5f;
				Glyph(_tag, x + num + 4f + num3, y, nameInfo.distText, Color.white, fontSize, _master);
				if (nameInfo.isHost)
				{
					float num4 = _tag.CalcSize(new GUIContent("⌞Host⌝")).x * 0.5f;
					Glyph(_tag, x - num - 4f - num4, y, "⌞Host⌝", Color.white, fontSize, _master);
				}
			}
		}

		private static string SteamNickname(PlayerCharacter pc)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerNetworking playerNetworking = pc.playerNetworking;
				if ((Object)(object)playerNetworking == (Object)null)
				{
					return null;
				}
				if ((int)playerNetworking.platform != 2)
				{
					return null;
				}
				ulong userPlatformId = playerNetworking.userPlatformId;
				if (userPlatformId < 76561197960265728L || userPlatformId >= 76561202255233024L)
				{
					return null;
				}
				CSteamID val = default(CSteamID);
				((CSteamID)(ref val))..ctor(userPlatformId);
				string playerNickname = SteamFriends.GetPlayerNickname(val);
				if (!string.IsNullOrEmpty(playerNickname))
				{
					return playerNickname;
				}
				try
				{
					SteamFriends.RequestUserInformation(val, true);
				}
				catch
				{
				}
				string friendPersonaName = SteamFriends.GetFriendPersonaName(val);
				return (string.IsNullOrEmpty(friendPersonaName) || friendPersonaName == "[unknown]") ? null : friendPersonaName;
			}
			catch
			{
				return null;
			}
		}

		private static string PlayerName(PlayerCharacter pc)
		{
			try
			{
				PlayerNetworking playerNetworking = pc.playerNetworking;
				if ((Object)(object)playerNetworking == (Object)null)
				{
					return null;
				}
				string text = null;
				try
				{
					text = playerNetworking.moderationNameSanitized;
				}
				catch
				{
				}
				if (string.IsNullOrEmpty(text))
				{
					try
					{
						text = playerNetworking.moderationName;
					}
					catch
					{
					}
				}
				if (string.IsNullOrEmpty(text))
				{
					try
					{
						text = playerNetworking.username;
					}
					catch
					{
					}
				}
				if (string.IsNullOrEmpty(text))
				{
					return null;
				}
				bool flag = true;
				string text2 = text;
				foreach (char c in text2)
				{
					if (c < '0' || c > '9')
					{
						flag = false;
						break;
					}
				}
				return flag ? null : text;
			}
			catch
			{
				return null;
			}
		}

		private static string EyeGlyph(PlayerCharacter pc)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected I4, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			try
			{
				PlayerEyes playerEyes = pc.playerEyes;
				if (playerEyes == null)
				{
					return null;
				}
				int num = (int)playerEyes.moodLeft;
				int num2 = (int)playerEyes.moodRight;
				if (num == 0 && num2 != 0)
				{
					num = num2;
				}
				return num switch
				{
					0 => "o", 
					1 => "-", 
					2 => "*", 
					3 => "u", 
					4 => "<", 
					5 => "O", 
					6 => "x", 
					7 => "·", 
					8 => "■", 
					9 => "◎", 
					10 => "@", 
					_ => null, 
				};
			}
			catch
			{
				return null;
			}
		}

		private void Glyph(GUIStyle style, float x, float y, string text, Color color, int fontSize, float alpha)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!(alpha <= 0.01f))
			{
				float num = (float)fontSize + 6f;
				float num2 = Mathf.Max(num, 180f);
				Rect val = new Rect(x - num2, y - num, num2 * 2f, num * 2f);
				style.fontSize = fontSize;
				style.normal.textColor = new Color(color.r, color.g, color.b, color.a * alpha);
				GUI.Label(val, text, style);
			}
		}
	}
	[BepInPlugin("com.smolmods.crosshair", "smolMods.Crosshair", "1.0.10")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public const string PluginGuid = "com.smolmods.crosshair";

		public const string PluginName = "smolMods.Crosshair";

		public const string PluginVersion = "1.0.10";

		internal static ManualLogSource Logger;

		public override void Load()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			CrosshairSizeFeature.Register();
			ArmsUpFeature.Register();
			StickyButtonsFeature.Register();
			RunIsWalkFeature.Register();
			EspFeature.Register();
			Harmony val = new Harmony("com.smolmods.crosshair");
			val.PatchAll(typeof(Plugin).Assembly);
			int num = 0;
			foreach (MethodBase patchedMethod in val.GetPatchedMethods())
			{
				_ = patchedMethod;
				num++;
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(27, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("smolMods.Crosshair");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.10");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" methods patched.");
			}
			log.LogInfo(val2);
		}
	}
	[HarmonyPatch]
	internal static class RunIsWalkFeature
	{
		private static bool _enabled;

		private static int _sprintAction = -1;

		internal static void Register()
		{
			ModSettingsApi.AddArrayRow(100, "Run is Walk", "settings_mod_runIsWalk", 0, new int[2] { 0, 1 }, (Func<int, string>)((int v) => (v != 1) ? "Off" : "On"), (Action<int>)delegate(int v)
			{
				_enabled = v == 1;
			}, (Func<int, Color?>)null, false, true);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerSprinter), "LocalUpdate")]
		private static void LocalUpdate_Postfix(PlayerSprinter __instance)
		{
			if (!_enabled)
			{
				return;
			}
			try
			{
				PlayerCharacter pc = __instance.pc;
				if ((Object)(object)pc == (Object)null || !((NetworkBehaviour)pc).isLocalPlayer)
				{
					return;
				}
				Player inputPlayer = pc.inputPlayer;
				if (inputPlayer != null)
				{
					if (_sprintAction < 0)
					{
						_sprintAction = Action.sprint;
					}
					bool button = inputPlayer.GetButton(_sprintAction);
					__instance.isSprinting = !button;
					__instance.sprintIsToggledOn = false;
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch]
	internal static class StickyButtonsFeature
	{
		private static ModRowDef _row;

		private static bool _enabled;

		private const int UseAction = 17;

		private static bool _latched;

		private static bool _readingRaw;

		private static bool _prevRawHeld;

		private static bool _sawClickWhileLatched;

		private static int _forceUpFrames;

		private static IntPtr _inputPlayerPtr = IntPtr.Zero;

		private static bool _loggedActive;

		internal static void Register()
		{
			_row = ModSettingsApi.AddArrayRow(100, "Sticky buttons", "settings_mod_stickyButtons", 0, new int[2] { 0, 1 }, (Func<int, string>)((int v) => (v != 1) ? "Off" : "On"), (Action<int>)delegate(int v)
			{
				_enabled = v == 1;
				if (!_enabled && _latched)
				{
					Unlatch(synthesizeRelease: true);
				}
			}, (Func<int, Color?>)null, false, true);
			ModSettingsApi.AddTicker((Action)Tick);
			ModSettingsApi.AddTicker((Action)LateTick);
		}

		private static void Unlatch(bool synthesizeRelease)
		{
			_latched = false;
			_sawClickWhileLatched = false;
			if (synthesizeRelease)
			{
				_forceUpFrames = 2;
			}
		}

		private static void Tick()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			try
			{
				if (!_enabled && !_latched && _forceUpFrames == 0)
				{
					return;
				}
				PlayerCharacter val = PlayerPalette.FindLocalPlayer();
				if ((Object)(object)val == (Object)null)
				{
					if (_latched)
					{
						Unlatch(synthesizeRelease: false);
					}
					_inputPlayerPtr = IntPtr.Zero;
					return;
				}
				Player inputPlayer = val.inputPlayer;
				if (inputPlayer == null)
				{
					return;
				}
				_inputPlayerPtr = ((Il2CppObjectBase)inputPlayer).Pointer;
				bool button;
				try
				{
					_readingRaw = true;
					button = inputPlayer.GetButton(17);
				}
				finally
				{
					_readingRaw = false;
				}
				bool flag = _prevRawHeld && !button;
				bool flag2 = !_prevRawHeld && button;
				_prevRawHeld = button;
				if (!_latched)
				{
					if (!(_enabled && flag) || val.decisions == null || !((Object)(object)val.decisions.heldDownSwitch != (Object)null))
					{
						return;
					}
					_latched = true;
					_sawClickWhileLatched = false;
					if (!_loggedActive)
					{
						_loggedActive = true;
						ManualLogSource logger = Plugin.Logger;
						if (logger != null)
						{
							logger.LogInfo((object)"Sticky buttons: latch engaged (input forcing active)");
						}
					}
				}
				else if (val.decisions == null || (Object)(object)val.decisions.heldDownSwitch == (Object)null)
				{
					Unlatch(synthesizeRelease: false);
				}
				else
				{
					if (flag2)
					{
						_sawClickWhileLatched = true;
					}
					if (_sawClickWhileLatched && flag)
					{
						Unlatch(synthesizeRelease: true);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				if (logger2 != null)
				{
					bool flag3 = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag3);
					if (flag3)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Sticky buttons tick failed: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger2.LogWarning(val2);
				}
				Unlatch(synthesizeRelease: false);
			}
		}

		private static bool IsLocalUse(Player player, int actionId)
		{
			if (!_readingRaw && actionId == 17 && _inputPlayerPtr != IntPtr.Zero)
			{
				return ((Il2CppObjectBase)player).Pointer == _inputPlayerPtr;
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButton", new Type[] { typeof(int) })]
		private static void GetButton_Postfix(Player __instance, int actionId, ref bool __result)
		{
			if (_latched && IsLocalUse(__instance, actionId))
			{
				__result = true;
			}
			else if (_forceUpFrames > 0 && IsLocalUse(__instance, actionId))
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButtonDown", new Type[] { typeof(int) })]
		private static void GetButtonDown_Postfix(Player __instance, int actionId, ref bool __result)
		{
			if (_latched && IsLocalUse(__instance, actionId))
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "GetButtonUp", new Type[] { typeof(int) })]
		private static void GetButtonUp_Postfix(Player __instance, int actionId, ref bool __result)
		{
			if (_latched && IsLocalUse(__instance, actionId))
			{
				__result = false;
			}
			else if (_forceUpFrames > 0 && IsLocalUse(__instance, actionId))
			{
				__result = true;
			}
		}

		internal static void LateTick()
		{
			if (_forceUpFrames > 0)
			{
				_forceUpFrames--;
			}
		}
	}
}