Decompiled source of KnuckleAssist v1.0.0

plugins/KnuckleAssist.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

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

[BepInPlugin("com.whiteknuckle.assist", "Knuckle Assist", "1.0.0")]
public class GuidePlugin : BaseUnityPlugin
{
	private struct Step
	{
		public string text;

		public int i0;

		public int i1;

		public bool warn;

		public float len;
	}

	private struct Contact
	{
		public string name;

		public string meta;

		public string glyph;

		public float dist;

		public float dy;

		public bool threat;

		public bool route;

		public Vector3 pos;
	}

	private struct Threat
	{
		public string name;

		public string info;

		public float dist;

		public float rate;

		public float catchIn;

		public bool urgent;

		public Vector3 at;
	}

	private static readonly Color A = Hex(15263457);

	private static readonly Color D = Hex(9341829);

	private static readonly Color A2 = Hex(12434099);

	private static readonly Color TH = Hex(11740702);

	private static readonly Color TT = Hex(13644844);

	private static readonly Color TS = Hex(11556173);

	private static readonly Color INK = Hex(328965);

	private GUIStyle st10;

	private GUIStyle st11;

	private GUIStyle st12;

	private GUIStyle st13;

	private GUIStyle st14;

	private GUIStyle st18;

	private GUIStyle st30;

	private GUIStyle st38;

	private Font hudFont;

	private Font headFont;

	private bool fontPicked;

	private float lastS = -1f;

	private float s = 1f;

	private float ascent;

	private float massGap = 999f;

	private float massRate;

	private float lastY = float.NaN;

	private float lastGap = float.NaN;

	private float lastT;

	private float sectorT0;

	private float entryY;

	private string sectorName = "";

	private int sectorNo;

	private float hpShown = 1f;

	private readonly float[] gripRate = new float[2];

	private readonly float[] gripLast = new float[2] { -1f, -1f };

	private readonly List<(string name, string label)> regionOrder = new List<(string, string)>();

	private string curRegion = "";

	private float regionStartY;

	private float curRegionHeight;

	private readonly Dictionary<string, float> regionHeights = new Dictionary<string, float>();

	private ConfigEntry<KeyCode> keyHud;

	private ConfigEntry<KeyCode> keyPath;

	private ConfigEntry<KeyCode> keyXray;

	private ConfigEntry<KeyCode> keyRescan;

	private bool hudOn = true;

	private bool guideOn = true;

	private bool xrayOn = true;

	internal readonly List<(string name, Vector3 p, bool moving)> threats = new List<(string, Vector3, bool)>();

	private float nextThreatScan;

	internal readonly List<(string t, string msg, bool warn)> events = new List<(string, string, bool)>();

	private readonly HashSet<string> said = new HashSet<string>();

	private int shots;

	private float shotAt = -1f;

	internal string scanLevel;

	private Coroutine scanRun;

	internal string scanStatus = "";

	internal bool scanning;

	internal float scanY = float.NaN;

	internal Bounds scanBounds;

	internal float scanPct;

	internal readonly List<(string k, Vector3 p)> route = new List<(string, Vector3)>();

	internal readonly List<(string k, Vector3 a, Vector3 b, float gap, Vector3? rebar)> gaps = new List<(string, Vector3, Vector3, float, Vector3?)>();

	internal readonly List<(string k, Vector3 p)> items = new List<(string, Vector3)>();

	private readonly Stopwatch sw = new Stopwatch();

	private static readonly Vector3[] dirs = BuildDirs(170);

	private Material lineMat;

	private readonly List<Threat> core = new List<Threat>();

	private readonly Dictionary<int, float> lastDist = new Dictionary<int, float>();

	private readonly Dictionary<int, float> rateOf = new Dictionary<int, float>();

	private float nextCore;

	private float lastCoreT;

	private readonly List<(Vector3 p, float left)> droneWinds = new List<(Vector3, float)>();

	private static readonly FieldInfo fHunterVisible = typeof(DEN_Hunter).GetField("targetVisible", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly FieldInfo fDroneCharge = typeof(DEN_Drone).GetField("chargeTime", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly FieldInfo fPseudoOrigins = typeof(DEN_Pseudopod).GetField("originNodes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

	private static Color Hex(int h)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		return new Color((float)((h >> 16) & 0xFF) / 255f, (float)((h >> 8) & 0xFF) / 255f, (float)(h & 0xFF) / 255f);
	}

	private static Color Al(Color c, float a)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		c.a = a;
		return c;
	}

	private void HudTrack(ENT_Player p, M_Level lv)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		float time = Time.time;
		float num = time - lastT;
		if (num > 0.2f)
		{
			float y = ((Component)p).transform.position.y;
			float num2 = MassGap(p);
			if (!float.IsNaN(lastY))
			{
				ascent = Mathf.Lerp(ascent, (y - lastY) / num, 0.25f);
			}
			if (!float.IsNaN(lastGap) && num2 < 900f && lastGap < 900f)
			{
				massRate = Mathf.Lerp(massRate, (lastGap - num2) / num, 0.25f);
			}
			for (int i = 0; i < 2 && i < p.hands.Length; i++)
			{
				float gripStrength = p.hands[i].gripStrength;
				if (gripLast[i] >= 0f)
				{
					gripRate[i] = Mathf.Lerp(gripRate[i], (gripLast[i] - gripStrength) / num, 0.3f);
				}
				gripLast[i] = gripStrength;
				float num3 = gripStrength / Mathf.Max(0.01f, p.GetCurrentGripStrengthTimer(i));
				if ((int)p.hands[i].interactState != 0 && num3 < 0.3f)
				{
					Event(((i == 0) ? "L" : "R") + "-GRIP UNDER 30% — FIND A LEDGE", warn: true, "grip" + i + sectorName + (int)(time / 20f));
				}
			}
			if (num2 < 15f)
			{
				Event("MASS WITHIN 15 m", warn: true, "mass15" + sectorName + (int)(time / 30f));
			}
			lastY = y;
			lastGap = num2;
			massGap = num2;
			lastT = time;
		}
		string text = (((Object)(object)lv != (Object)null) ? lv.levelName : "");
		if (text != sectorName)
		{
			sectorName = text;
			sectorT0 = time;
			entryY = ((Component)p).transform.position.y;
			if (text.Length > 0)
			{
				sectorNo++;
				Event("ENTERED " + Pretty(text));
			}
			RegionTrack(p, lv);
		}
	}

	private void RegionTrack(ENT_Player p, M_Level lv)
	{
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			List<(string, string)> order = new List<(string, string)>();
			M_Gamemode baseGamemode = CL_GameManager.GetBaseGamemode();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			if ((Object)(object)baseGamemode != (Object)null && baseGamemode.regions != null)
			{
				foreach (M_Region region in baseGamemode.regions)
				{
					if ((Object)(object)region != (Object)null)
					{
						dictionary[Norm(region.regionName)] = region.introText;
						regionHeights[Norm(region.regionName)] = region.regionHeight;
					}
				}
			}
			if ((Object)(object)lv != (Object)null && (Object)(object)lv.region != (Object)null)
			{
				regionHeights[Norm(lv.region.regionName)] = lv.region.regionHeight;
			}
			BranchInfo val = (((Object)(object)WorldLoader.instance != (Object)null) ? WorldLoader.instance.GetCurrentBranch() : null);
			if (val != null && val.GetLevelIds() != null)
			{
				foreach (LevelId levelId in val.GetLevelIds())
				{
					if (levelId != null)
					{
						AddR(levelId.region, dictionary.TryGetValue(Norm(levelId.region), out var value) ? value : null);
					}
				}
			}
			if ((Object)(object)lv != (Object)null && (Object)(object)lv.region != (Object)null)
			{
				AddR(lv.region.regionName, lv.region.introText);
			}
			if ((Object)(object)baseGamemode != (Object)null && baseGamemode.regions != null)
			{
				foreach (M_Region region2 in baseGamemode.regions)
				{
					if ((Object)(object)region2 != (Object)null)
					{
						AddR(region2.regionName, region2.introText);
					}
				}
			}
			regionOrder.Clear();
			regionOrder.AddRange(order);
			string text = (((Object)(object)lv != (Object)null && (Object)(object)lv.region != (Object)null) ? Norm(lv.region.regionName) : curRegion);
			if (text != curRegion)
			{
				curRegion = text;
				regionStartY = ((Component)p).transform.position.y;
				curRegionHeight = (((Object)(object)lv != (Object)null && (Object)(object)lv.region != (Object)null) ? lv.region.regionHeight : 0f);
				if (!string.IsNullOrEmpty(text))
				{
					Event("REGION: " + (lv.region.introText ?? text).ToUpperInvariant());
				}
			}
			void AddR(string name, string label)
			{
				string k = Norm(name);
				if (k.Length > 0 && !order.Any(((string, string) o) => o.Item1 == k))
				{
					order.Add((k, (string.IsNullOrEmpty(label) ? k.Replace('_', ' ') : label).ToUpperInvariant()));
				}
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("region track: " + ex.Message));
		}
		static string Norm(string q)
		{
			return (q ?? "").ToLowerInvariant().Replace("region_", "").Replace("_campaign", "")
				.Replace("campaign_", "")
				.Trim('_');
		}
	}

	private void PickFont()
	{
		fontPicked = true;
		Font[] source = Resources.FindObjectsOfTypeAll<Font>();
		hudFont = ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.ToLower().EndsWith("_gui"))) ?? ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.ToLower().Contains("mono")));
		headFont = ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.ToLower().Contains("ticketing")));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Knuckle Assist font: " + (((Object)(object)hudFont != (Object)null) ? ((Object)hudFont).name : "default")));
	}

	private void Styles()
	{
		s = (float)Screen.height / 1080f;
		if (!fontPicked)
		{
			PickFont();
		}
		if (!(Mathf.Abs(s - lastS) < 0.001f) || st11 == null)
		{
			lastS = s;
			st10 = Mk(10.5f);
			st11 = Mk(11f);
			st12 = Mk(12f);
			st13 = Mk(13f);
			st14 = Mk(14f);
			st18 = Mk(18f);
			st30 = Mk(30f);
			st38 = Mk(38f);
		}
		GUIStyle Mk(float px)
		{
			//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_0028: 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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//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_0054: Expected O, but got Unknown
			//IL_0055: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = Mathf.Max(8, Mathf.RoundToInt(px * s)),
				clipping = (TextClipping)0,
				wordWrap = false,
				padding = new RectOffset(0, 0, 0, 0),
				margin = new RectOffset(0, 0, 0, 0)
			};
			if ((Object)(object)hudFont != (Object)null)
			{
				val.font = hudFont;
			}
			return val;
		}
	}

	private float S(float v)
	{
		return v * s;
	}

	private static void Fill(Rect r, Color c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		if (!(c.a <= 0f))
		{
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}
	}

	private void Box(Rect r, Color c, float t = 1f)
	{
		//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)
		//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_005a: 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_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)
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), c);
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), c);
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c);
		Fill(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), c);
	}

	private void DashBox(Rect r, Color c)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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_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_00d1: 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)
		float num = S(4f);
		for (float num2 = ((Rect)(ref r)).x; num2 < ((Rect)(ref r)).xMax; num2 += num * 2f)
		{
			Fill(new Rect(num2, ((Rect)(ref r)).y, Mathf.Min(num, ((Rect)(ref r)).xMax - num2), 1f), c);
			Fill(new Rect(num2, ((Rect)(ref r)).yMax - 1f, Mathf.Min(num, ((Rect)(ref r)).xMax - num2), 1f), c);
		}
		for (float num3 = ((Rect)(ref r)).y; num3 < ((Rect)(ref r)).yMax; num3 += num * 2f)
		{
			Fill(new Rect(((Rect)(ref r)).x, num3, 1f, Mathf.Min(num, ((Rect)(ref r)).yMax - num3)), c);
			Fill(new Rect(((Rect)(ref r)).xMax - 1f, num3, 1f, Mathf.Min(num, ((Rect)(ref r)).yMax - num3)), c);
		}
	}

	private void Ticks(Rect r, float len, Color c)
	{
		//IL_0030: 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_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_0080: 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_00a9: 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_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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		float num = S(2f);
		float num2 = S(len);
		Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).y - 1f, num2, num), c);
		Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).y - 1f, num, num2), c);
		Fill(new Rect(((Rect)(ref r)).xMax + 1f - num2, ((Rect)(ref r)).y - 1f, num2, num), c);
		Fill(new Rect(((Rect)(ref r)).xMax + 1f - num, ((Rect)(ref r)).y - 1f, num, num2), c);
		Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).yMax + 1f - num, num2, num), c);
		Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).yMax + 1f - num2, num, num2), c);
		Fill(new Rect(((Rect)(ref r)).xMax + 1f - num2, ((Rect)(ref r)).yMax + 1f - num, num2, num), c);
		Fill(new Rect(((Rect)(ref r)).xMax + 1f - num, ((Rect)(ref r)).yMax + 1f - num2, num, num2), c);
	}

	private void Panel(Rect r)
	{
		//IL_0000: 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_0020: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		Fill(r, new Color(0.02f, 0.02f, 0.02f, 0.62f));
		Box(r, Al(A, 0.55f), S(2f));
	}

	private void Rule(float x, float y, float w)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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)
		float num = S(4f);
		for (float num2 = 0f; num2 < w; num2 += num * 2f)
		{
			Fill(new Rect(x + num2, y, Mathf.Min(num, w - num2), 1f), Al(A, 0.5f));
		}
	}

	private void Hatch(Rect r, Color c, float a)
	{
		//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_0009: 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)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		Fill(r, Al(c, a * 0.25f));
		float num = S(6f);
		for (float num2 = 0f - ((Rect)(ref r)).height; num2 < ((Rect)(ref r)).width; num2 += num)
		{
			for (float num3 = 0f; num3 < ((Rect)(ref r)).height; num3 += S(1.5f))
			{
				float num4 = ((Rect)(ref r)).x + num2 + num3;
				if (!(num4 < ((Rect)(ref r)).x) && !(num4 >= ((Rect)(ref r)).xMax))
				{
					Fill(new Rect(num4, ((Rect)(ref r)).yMax - num3 - S(1.5f), S(1.5f), S(1.5f)), Al(c, a));
				}
			}
		}
	}

	private Vector2 Size(string t, GUIStyle st)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return st.CalcSize(new GUIContent(t));
	}

	private float Tx(float x, float y, string t, GUIStyle st, Color c, int align = 0, bool glow = false, Color? back = null)
	{
		//IL_0004: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0052: 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_0076: 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_01a1: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: 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_00c6: Expected O, but got Unknown
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = Size(t, st);
		float num = align switch
		{
			1 => x - val.x / 2f, 
			0 => x, 
			_ => x - val.x, 
		};
		if (back.HasValue)
		{
			Fill(new Rect(num - S(6f), y - S(2f), val.x + S(12f), val.y + S(2f)), back.Value);
		}
		Color color = GUI.color;
		if (glow)
		{
			float num2 = num;
			float unscaledTime = Time.unscaledTime;
			for (int i = 0; i < t.Length; i++)
			{
				string text = t[i].ToString();
				float x2 = st.CalcSize(new GUIContent(text)).x;
				if (t[i] != ' ')
				{
					float num3 = Mathf.Sin(unscaledTime * 5.2f + (float)i * 0.55f) * S(1.6f);
					GUI.color = new Color(0f, 0f, 0f, 0.7f * c.a);
					GUI.Label(new Rect(num2 + 1f, y + num3 + 1f, x2 + 2f, val.y), text, st);
					GUI.color = c;
					GUI.Label(new Rect(num2, y + num3, x2 + 2f, val.y), text, st);
				}
				num2 += x2;
			}
			GUI.color = color;
			return val.x;
		}
		GUI.color = c;
		GUI.Label(new Rect(num, y, val.x + 2f, val.y), t, st);
		GUI.color = color;
		return val.x;
	}

	private static string Pretty(string n)
	{
		if (string.IsNullOrEmpty(n))
		{
			return "-";
		}
		return Regex.Replace(n, "^M\\d+_", "").Replace("Campaign_Interlude_", "INTERLUDE ").Replace('_', ' ')
			.ToUpperInvariant();
	}

	private static (string region, string sub) Region(string n)
	{
		if (string.IsNullOrEmpty(n))
		{
			return (region: "-", sub: "");
		}
		string text = Regex.Replace(n, "^M\\d+_", "");
		if (text.StartsWith("Campaign_Interlude_"))
		{
			return (region: "INTERLUDE", sub: text.Substring(19).Replace('_', ' ').ToUpperInvariant());
		}
		int num = text.IndexOf('_');
		if (num >= 0)
		{
			return (region: text.Substring(0, num).ToUpperInvariant(), sub: text.Substring(num + 1).Replace('_', ' ').ToUpperInvariant());
		}
		return (region: text.ToUpperInvariant(), sub: "");
	}

	private static string Clock(float sec)
	{
		if (sec < 0f || float.IsInfinity(sec) || float.IsNaN(sec))
		{
			return "--:--";
		}
		int num = Mathf.RoundToInt(sec);
		return (num / 60).ToString("00") + ":" + (num % 60).ToString("00");
	}

	private static float Bearing(Vector3 from, Vector3 to)
	{
		//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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = to - from;
		return (Mathf.Atan2(val.x, val.z) * 57.29578f + 360f) % 360f;
	}

	private static string Deg(float b)
	{
		return Mathf.RoundToInt(b % 360f).ToString("000") + "°";
	}

	private static string Dv(float dy)
	{
		return ((dy >= 0f) ? "▲" : "▼") + Mathf.Abs(Mathf.RoundToInt(dy));
	}

	private List<Step> Steps()
	{
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_008d: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
		List<Step> list = new List<Step>();
		int num = 1;
		while (num < route.Count)
		{
			string item = route[num].k;
			if (item == "easy")
			{
				int i = num;
				float num2 = 0f;
				float num3 = 0f;
				float num4 = 0f;
				for (; i < route.Count && route[i].k == "easy"; i++)
				{
					Vector3 val = route[i].p - route[i - 1].p;
					num2 += ((Vector3)(ref val)).magnitude;
					num3 += val.y;
					float num5 = num4;
					Vector2 val2 = new Vector2(val.x, val.z);
					num4 = num5 + ((Vector2)(ref val2)).magnitude;
				}
				list.Add(new Step
				{
					text = ((num3 > num4) ? "CLIMB" : ((num3 < -2f) ? "DROP DOWN" : "TRAVERSE")),
					i0 = num - 1,
					i1 = i - 1,
					len = num2
				});
				num = i;
			}
			else
			{
				float len = Vector3.Distance(route[num - 1].p, route[num].p);
				list.Add(new Step
				{
					text = ((item == "rebar") ? ("REBAR GAP " + len.ToString("0.0") + " m — USE REBAR") : ("JUMP " + len.ToString("0.0") + " m")),
					i0 = num - 1,
					i1 = num,
					warn = (item == "rebar"),
					len = len
				});
				num++;
			}
		}
		if (route.Count > 0)
		{
			list.Add(new Step
			{
				text = "EXIT HATCH → NEXT LEVEL",
				i0 = route.Count - 1,
				i1 = route.Count - 1
			});
		}
		return list;
	}

	private void DrawCenter(ENT_Player p)
	{
		//IL_0037: 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_0046: 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_007c: 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_0091: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_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_0127: 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_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Invalid comparison between Unknown and I4
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0483: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0520: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		if (!hudOn || (Cursor.visible && (int)Cursor.lockState == 0))
		{
			return;
		}
		Styles();
		float num = (float)Screen.width / 2f;
		float num2 = (float)Screen.height / 2f;
		Color c = Al(A, 0.45f);
		float num3 = S(22f);
		float num4 = S(8f);
		float num5 = S(1.4f);
		Fill(new Rect(num - num3, num2 - num3, num4, num5), c);
		Fill(new Rect(num - num3, num2 - num3, num5, num4), c);
		Fill(new Rect(num + num3 - num4, num2 - num3, num4, num5), c);
		Fill(new Rect(num + num3 - num5, num2 - num3, num5, num4), c);
		Fill(new Rect(num - num3, num2 + num3 - num5, num4, num5), c);
		Fill(new Rect(num - num3, num2 + num3 - num4, num5, num4), c);
		Fill(new Rect(num + num3 - num4, num2 + num3 - num5, num4, num5), c);
		Fill(new Rect(num + num3 - num5, num2 + num3 - num4, num5, num4), c);
		for (int i = 0; i < 2 && i < p.hands.Length; i++)
		{
			float gripStrength = p.hands[i].gripStrength;
			float num6 = Mathf.Max(0.01f, p.GetCurrentGripStrengthTimer(i));
			float num7 = Mathf.Clamp01(gripStrength / num6);
			bool flag = (int)p.hands[i].interactState > 0;
			bool flag2 = flag && gripRate[i] > 0.05f;
			Color c2 = ((num7 < 0.3f) ? TH : A);
			float num8 = ((flag || num7 < 0.99f) ? 0.9f : 0.4f);
			int num9 = 10;
			float num10 = S(4f);
			float num11 = S(2f);
			float num12 = ((i == 0) ? (num - S(46f)) : (num + S(40f)));
			float num13 = num2 - (float)num9 * (num10 + num11) / 2f;
			for (int j = 0; j < num9; j++)
			{
				bool flag3 = ((float)(num9 - j) - 0.5f) / (float)num9 <= num7;
				Fill(new Rect(num12, num13 + (float)j * (num10 + num11), S(6f), num10), Al(c2, flag3 ? num8 : (num8 * 0.16f)));
			}
			string t = ((!flag) ? "FREE" : (flag2 ? ("SLIP " + (gripStrength / Mathf.Max(0.05f, gripRate[i])).ToString("0.0") + "s") : "LOCK"));
			float x = ((i == 0) ? (num12 - S(6f)) : (num12 + S(12f)));
			Tx(x, num2 - S(14f), ((i == 0) ? "L " : "R ") + Mathf.RoundToInt(num7 * 100f), st11, Al(c2, num8), (i == 0) ? 2 : 0, glow: true);
			Tx(x, num2 + S(1f), t, st10, Al((num7 < 0.3f) ? TS : D, num8), (i == 0) ? 2 : 0);
		}
		float num14 = Mathf.Clamp01(((GameEntity)p).health / Mathf.Max(0.01f, ((GameEntity)p).maxHealth));
		hpShown = Mathf.MoveTowards(hpShown, num14, Time.unscaledDeltaTime * 0.6f);
		int num15 = 20;
		float num16 = S(110f);
		float num17 = S(2f);
		float num18 = (num16 - num17 * (float)(num15 - 1)) / (float)num15;
		float num19 = num2 + S(40f);
		Color c3 = ((num14 < 0.3f) ? TH : A);
		for (int k = 0; k < num15; k++)
		{
			float num20 = ((float)k + 0.5f) / (float)num15;
			Fill(new Rect(num - num16 / 2f + (float)k * (num18 + num17), num19, num18, S(4f)), (num20 <= num14) ? Al(c3, 0.85f) : ((num20 <= hpShown) ? Al(TH, 0.8f) : Al(A, 0.14f)));
		}
		Tx(num, num19 + S(7f), "HP " + Mathf.RoundToInt(num14 * 100f), st10, Al((num14 < 0.3f) ? TS : D, 0.85f), 1);
	}

	private void DrawHud(ENT_Player p)
	{
		//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_002a: 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_0064: 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_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0622: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_0631: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0822: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0891: Unknown result type (might be due to invalid IL or missing references)
		//IL_0894: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0874: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0512: Unknown result type (might be due to invalid IL or missing references)
		//IL_0569: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_0378: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b65: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a31: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bbf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bdc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c60: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c63: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c7d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0783: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d16: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d48: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d80: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d85: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d8f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e88: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ed5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eda: Unknown result type (might be due to invalid IL or missing references)
		//IL_0446: Unknown result type (might be due to invalid IL or missing references)
		//IL_108f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f70: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f97: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f1b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dfe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e03: Unknown result type (might be due to invalid IL or missing references)
		//IL_10f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_10fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_114a: Unknown result type (might be due to invalid IL or missing references)
		//IL_114c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1156: Unknown result type (might be due to invalid IL or missing references)
		//IL_1161: Unknown result type (might be due to invalid IL or missing references)
		//IL_1163: Unknown result type (might be due to invalid IL or missing references)
		//IL_1175: Unknown result type (might be due to invalid IL or missing references)
		//IL_11a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd2: Unknown result type (might be due to invalid IL or missing references)
		//IL_1018: Unknown result type (might be due to invalid IL or missing references)
		//IL_101d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1078: Unknown result type (might be due to invalid IL or missing references)
		//IL_11d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e18: Unknown result type (might be due to invalid IL or missing references)
		//IL_13a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_1242: Unknown result type (might be due to invalid IL or missing references)
		//IL_1247: Unknown result type (might be due to invalid IL or missing references)
		//IL_1278: Unknown result type (might be due to invalid IL or missing references)
		//IL_129e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e50: Unknown result type (might be due to invalid IL or missing references)
		//IL_1419: Unknown result type (might be due to invalid IL or missing references)
		//IL_141e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1428: Unknown result type (might be due to invalid IL or missing references)
		//IL_144c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1451: Unknown result type (might be due to invalid IL or missing references)
		//IL_145b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1485: Unknown result type (might be due to invalid IL or missing references)
		//IL_148a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1494: Unknown result type (might be due to invalid IL or missing references)
		//IL_14e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_133d: Unknown result type (might be due to invalid IL or missing references)
		Styles();
		float num = Screen.width;
		_ = Screen.height;
		Vector3 position = ((Component)p).transform.position;
		_ = ((Component)p.cam).transform.position;
		M_Level val = CurrentLevel();
		Transform val2 = (((Object)(object)val != (Object)null) ? val.GetLevelExit() : null);
		float num2 = (((Object)(object)val2 != (Object)null) ? (val2.position.y - position.y) : float.NaN);
		int num3 = NearestRouteIndex(position);
		if (route.Count > 1)
		{
			Mathf.Clamp01((float)num3 / (float)(route.Count - 1));
		}
		Steps();
		List<Contact> source = Contacts(p);
		source.Count((Contact c) => c.threat);
		float num4 = S(40f);
		float num5 = S(36f);
		float num6 = S(520f);
		Fill(new Rect(num4 - S(10f), num5 - S(8f), num6 + S(20f), S(90f)), new Color(0.04f, 0.03f, 0.01f, 0.45f));
		Tx(num4, num5, "KNUCKLE//ASSIST", st11, D);
		Tx(num4 + num6, num5, Pretty(sectorName) + "   " + Clock(Time.time - sectorT0), st11, D, 2);
		num5 += S(18f);
		int count = regionOrder.Count;
		int num7 = regionOrder.FindIndex(((string name, string label) q) => q.name == curRegion);
		if (count > 0)
		{
			float value;
			List<float> list = regionOrder.Select(((string name, string label) q) => (!regionHeights.TryGetValue(q.name, out value) || !(value > 0f)) ? 500f : value).ToList();
			float num8 = list.Sum();
			float num9 = S(3f);
			float num10 = num6 - num9 * (float)(count - 1);
			float num11 = num4;
			float num12 = Mathf.Max(0f, position.y - regionStartY);
			float num13 = 0f;
			for (int num14 = 0; num14 < count; num14++)
			{
				float num15 = num10 * list[num14] / num8;
				float num16 = ((num7 < 0) ? 0f : ((num14 < num7) ? 1f : ((num14 == num7) ? Mathf.Clamp01(num12 / list[num14]) : 0f)));
				if (num14 < num7)
				{
					num13 += list[num14];
				}
				Fill(new Rect(num11, num5, num15, S(6f)), Al(A, 0.14f));
				if (num16 > 0f)
				{
					Fill(new Rect(num11, num5, num15 * num16, S(6f)), (num14 == num7) ? A : Al(A, 0.75f));
				}
				if (num14 == num7)
				{
					Fill(new Rect(num11 + num15 * num16 - S(1f), num5 - S(3f), S(2f), S(12f)), TT);
				}
				bool flag = num14 == num7;
				string text = regionOrder[num14].label;
				GUIStyle st = (flag ? st12 : st10);
				if (!flag && Size(text, st).x > num15 - S(4f))
				{
					text = ((text.Length > 3) ? text.Substring(0, 3) : text);
				}
				if (flag || Size(text, st).x <= num15 + S(2f))
				{
					Tx(num11, num5 + S(10f), text, st, flag ? A : Al(D, (num14 < num7) ? 0.9f : 0.5f), 0, flag);
				}
				num11 += num15 + num9;
			}
			num5 += S(30f);
			float num17 = ((num7 >= 0) ? list[num7] : 0f);
			Tx(num4, num5, (num7 >= 0) ? (regionOrder[num7].label + "  " + num12.ToString("0") + " / " + num17.ToString("0") + " m") : "", st11, A2);
			Tx(num4 + num6, num5, "CAMPAIGN " + Mathf.RoundToInt(100f * (num13 + Mathf.Min(num12, num17)) / num8) + "%", st11, A2, 2);
		}
		float x = num / 2f - S(300f);
		float num18 = S(30f);
		float w = S(600f);
		float heading = (((Component)p.cam).transform.eulerAngles.y + 360f) % 360f;
		float span = 120f;
		Fill(new Rect(x + w * 0.1f, num18 + S(22f), w * 0.8f, 1f), Al(A, 0.5f));
		for (int num19 = Mathf.CeilToInt((heading - 60f) / 5f) * 5; (float)num19 <= heading + 60f; num19 += 5)
		{
			int num20 = (num19 % 360 + 360) % 360;
			float num21 = X(num20);
			float num22 = 1f - Mathf.Abs(num21 - (x + w / 2f)) / (w / 2f);
			if (!(num22 <= 0.05f))
			{
				bool flag2 = num20 % 15 == 0;
				Fill(new Rect(num21, num18 + S(22f), 1f, S(flag2 ? 12 : 6)), Al(A, (flag2 ? 0.9f : 0.45f) * num22));
				if (flag2)
				{
					string text2 = num20 switch
					{
						270 => "W", 
						180 => "S", 
						90 => "E", 
						0 => "N", 
						_ => num20.ToString("000"), 
					};
					Tx(num21, num18 + S(38f), text2, st11, Al((text2.Length == 1) ? A : D, num22), 1);
				}
			}
		}
		Vector3? val3 = null;
		float num23 = 0f;
		for (int num24 = num3 + 1; num24 < route.Count; num24++)
		{
			num23 += Vector3.Distance(route[num24 - 1].p, route[num24].p);
			if (num23 > 6f)
			{
				val3 = route[num24].p;
				break;
			}
		}
		if (!val3.HasValue && route.Count > 0)
		{
			val3 = route[route.Count - 1].p;
		}
		string text3 = "";
		if (val3.HasValue)
		{
			float num25 = Bearing(position, val3.Value);
			Fill(new Rect(Mathf.Clamp(X(num25), x, x + w) - S(5f), num18 + S(12f), S(10f), S(10f)), A);
			float num26 = Mathf.DeltaAngle(heading, num25);
			text3 = "ROUTE " + Deg(num25) + " · " + ((Mathf.Abs(num26) < 8f) ? "AHEAD" : (((num26 > 0f) ? "TURN R " : "TURN L ") + Mathf.RoundToInt(Mathf.Abs(num26)) + "°"));
		}
		Contact contact = (from c in source
			where c.threat
			orderby c.dist
			select c).FirstOrDefault();
		if (contact.name != null)
		{
			float num27 = Mathf.Clamp(X(Bearing(position, contact.pos)), x, x + w);
			Fill(new Rect(num27 - S(6f), num18 + S(10f), S(12f), S(3f)), TH);
			Fill(new Rect(num27 - S(4f), num18 + S(13f), S(8f), S(3f)), TH);
			Fill(new Rect(num27 - S(2f), num18 + S(16f), S(4f), S(3f)), TH);
		}
		Rect r = default(Rect);
		((Rect)(ref r))..ctor(x + w / 2f - S(28f), num18 - S(4f), S(56f), S(20f));
		Fill(r, Al(INK, 0.8f));
		Box(r, A);
		Tx(((Rect)(ref r)).center.x, ((Rect)(ref r)).y + S(2f), Deg(heading), st13, A, 1, glow: true);
		float y = num18 + S(58f);
		if (contact.name != null)
		{
			float x2 = Size(text3, st11).x;
			float x3 = Size("▼ " + contact.name + " " + Deg(Bearing(position, contact.pos)), st11).x;
			float num28 = x + w / 2f - (x2 + x3 + S(18f)) / 2f;
			Tx(num28, y, text3, st11, A);
			Tx(num28 + x2 + S(18f), y, "▼ " + contact.name + " " + Deg(Bearing(position, contact.pos)), st11, TT);
		}
		else if (text3.Length > 0)
		{
			Tx(x + w / 2f, y, text3, st11, A, 1);
		}
		float num29 = S(40f);
		float y2 = S(330f);
		float h = S(440f);
		float span2 = 120f;
		float top = position.y + 60f;
		Tx(num29, y2 - S(26f), "VERTICAL · m", st11, D);
		Fill(new Rect(num29 + S(46f), y2, 1f, h), Al(A, 0.55f));
		for (int num30 = Mathf.CeilToInt((top - span2) / 5f) * 5; (float)num30 <= top; num30 += 5)
		{
			bool flag3 = num30 % 20 == 0;
			float num31 = Y(num30);
			Fill(new Rect(num29 + S(flag3 ? 36 : 40), num31, S(flag3 ? 20 : 12), 1f), Al(A, flag3 ? 0.9f : 0.45f));
			if (flag3)
			{
				Tx(num29 + S(30f), num31 - S(7f), num30.ToString(), st11, D, 2);
			}
		}
		if (!float.IsNaN(num2))
		{
			float num32 = Mathf.Clamp(Y(position.y + num2), y2, y2 + h);
			Fill(new Rect(num29 + S(50f), num32, S(8f), 1f), A);
			Tx(num29 + S(62f), num32 - S(7f), ((num2 > 60f) ? "▲ " : "") + "EXIT " + (position.y + num2).ToString("0"), st11, A, 0, glow: true);
		}
		(string, Vector3, Vector3, float, Vector3?)? tuple = NextGap(position);
		if (tuple.HasValue && Mathf.Abs(tuple.Value.Item2.y - position.y) < 60f && Mathf.Abs(Y(tuple.Value.Item2.y) - Y(position.y)) > S(16f))
		{
			float num33 = Y(tuple.Value.Item2.y);
			Box(new Rect(num29 + S(50f), num33 - S(5f), S(10f), S(10f)), A);
			Tx(num29 + S(66f), num33 - S(7f), "NEXT " + tuple.Value.Item2.y.ToString("0"), st11, A2);
		}
		float num34 = Y(position.y);
		for (int num35 = 0; num35 < 9; num35++)
		{
			Fill(new Rect(num29 + S(30f), num34 - S(9f) + S(num35), S(14f) * (1f - (float)Mathf.Abs(num35 - 4) / 4.5f), S(1f)), A);
		}
		Rect r2 = default(Rect);
		((Rect)(ref r2))..ctor(num29 + S(52f), num34 - S(10f), S(62f), S(20f));
		Fill(r2, Al(INK, 0.85f));
		Box(r2, A);
		Tx(((Rect)(ref r2)).center.x, ((Rect)(ref r2)).y + S(2f), position.y.ToString("0.0"), st14, A, 1, glow: true);
		if (massGap < 900f)
		{
			float num36 = Y(position.y - massGap);
			if (num36 < y2 + h)
			{
				Hatch(new Rect(num29 + S(47f), Mathf.Max(num36, y2), S(30f), y2 + h - Mathf.Max(num36, y2)), TH, 0.35f);
				Tx(num29 + S(82f), num36 - S(9f), "MASS " + (position.y - massGap).ToString("0"), st11, TT, 0, glow: true);
				Tx(num29 + S(82f), num36 + S(5f), "▲ " + Mathf.Max(0f, 0f - massRate + ascent).ToString("0.0") + " m/s" + ((massRate > 0.05f) ? ("  CONTACT " + Clock(massGap / massRate)) : ""), st11, TS);
			}
			else
			{
				Tx(num29 + S(50f), y2 + h + S(4f), "▼ MASS " + massGap.ToString("0") + " m BELOW", st11, TT);
			}
			float num37 = num34 + S(12f);
			float num38 = Mathf.Min(num36, y2 + h);
			if (num38 > num37 + S(10f))
			{
				Fill(new Rect(num29 + S(168f), num37, S(8f), 1f), Al(A, 0.6f));
				Fill(new Rect(num29 + S(176f), num37, 1f, num38 - num37), Al(A, 0.6f));
				Fill(new Rect(num29 + S(168f), num38, S(8f), 1f), Al(A, 0.6f));
				Tx(num29 + S(182f), (num37 + num38) / 2f - S(7f), "Δ " + massGap.ToString("0.0"), st11, A2);
			}
		}
		float X(float deg)
		{
			float num39 = Mathf.DeltaAngle(heading, deg);
			return x + w / 2f + num39 / span * w;
		}
		float Y(float alt)
		{
			return y2 + (top - alt) / span2 * h;
		}
	}

	private List<Contact> Contacts(ENT_Player p)
	{
		//IL_000c: 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_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_0081: 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_00a1: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		List<Contact> list = new List<Contact>();
		Vector3 position = ((Component)p).transform.position;
		Vector3 position2 = ((Component)p.cam).transform.position;
		RaycastHit val = default(RaycastHit);
		foreach (IGrouping<string, (string, Vector3)> item in from i in items
			group i by i.k)
		{
			foreach (var it in item)
			{
				float num = Vector3.Distance(position, it.Item2);
				if (num > 60f)
				{
					continue;
				}
				int num2;
				if (Physics.Linecast(position2, it.Item2 + Vector3.up * 0.2f, ref val, -1, (QueryTriggerInteraction)1))
				{
					Vector3 val2 = ((RaycastHit)(ref val)).point - it.Item2;
					num2 = ((((Vector3)(ref val2)).sqrMagnitude > 1f) ? 1 : 0);
				}
				else
				{
					num2 = 0;
				}
				bool flag = (byte)num2 != 0;
				bool flag2 = it.Item1 == "Rebar" && gaps.Any(delegate((string k, Vector3 a, Vector3 b, float gap, Vector3? rebar) x)
				{
					//IL_0027: 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_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)
					if (x.k == "rebar" && x.rebar.HasValue)
					{
						Vector3 val5 = x.rebar.Value - it.Item2;
						return ((Vector3)(ref val5)).sqrMagnitude < 0.1f;
					}
					return false;
				});
				list.Add(new Contact
				{
					name = it.Item1.ToUpperInvariant(),
					glyph = ((it.Item1 == "Rebar") ? "RB" : ((it.Item1 == "Piton") ? "PT" : ((it.Item1 == "Gun") ? "GN" : ((it.Item1 == "Battery") ? "BT" : it.Item1.Substring(0, 2).ToUpperInvariant())))),
					meta = Deg(Bearing(position, it.Item2)) + " · " + (flag2 ? "NEEDED FOR GAP" : (flag ? "BEHIND WALL" : "IN SIGHT")),
					dist = num,
					dy = it.Item2.y - position.y,
					route = flag2,
					pos = it.Item2
				});
			}
		}
		foreach (var threat in threats)
		{
			float dist = Vector3.Distance(position, threat.p);
			list.Add(new Contact
			{
				name = threat.name,
				glyph = "!",
				meta = Deg(Bearing(position, threat.p)) + (threat.moving ? " · MOVING" : " · STILL"),
				dist = dist,
				dy = threat.p.y - position.y,
				threat = true,
				pos = threat.p
			});
		}
		M_Level val3 = CurrentLevel();
		Transform val4 = (((Object)(object)val3 != (Object)null) ? val3.GetLevelExit() : null);
		if ((Object)(object)val4 != (Object)null)
		{
			float dist2 = Vector3.Distance(position, val4.position);
			list.Add(new Contact
			{
				name = "EXIT HATCH",
				glyph = "EX",
				meta = Deg(Bearing(position, val4.position)) + " · TO NEXT LEVEL",
				dist = dist2,
				dy = val4.position.y - position.y,
				route = true,
				pos = val4.position
			});
		}
		return list.OrderBy((Contact c) => c.dist).ToList();
	}

	private (string k, Vector3 a, Vector3 b, float gap, Vector3? rebar)? NextGap(Vector3 me)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		int num = NearestRouteIndex(me);
		foreach (var g in gaps)
		{
			int num2 = route.FindIndex(delegate((string k, Vector3 p) r)
			{
				//IL_0001: 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_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)
				Vector3 val = r.p - g.a;
				return ((Vector3)(ref val)).sqrMagnitude < 0.01f;
			});
			if (num2 < 0 || num2 >= num)
			{
				return g;
			}
		}
		return null;
	}

	private bool ToScreen(ENT_Player p, Vector3 w, out Vector2 sp)
	{
		//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_000e: 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_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_002b: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = p.cam.WorldToScreenPoint(w);
		sp = new Vector2(val.x, (float)Screen.height - val.y);
		if (val.z > 0.2f && sp.x > -50f && sp.x < (float)(Screen.width + 50) && sp.y > -50f)
		{
			return sp.y < (float)(Screen.height + 50);
		}
		return false;
	}

	private void WorldLabels(ENT_Player p)
	{
		//IL_000c: 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_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_004d: 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_00aa: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: 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_00d0: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: 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_0163: 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_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: 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_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_041f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_058a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0606: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_0482: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Unknown result type (might be due to invalid IL or missing references)
		//IL_056f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0677: Unknown result type (might be due to invalid IL or missing references)
		//IL_0685: Unknown result type (might be due to invalid IL or missing references)
		//IL_068c: Unknown result type (might be due to invalid IL or missing references)
		Styles();
		Vector3 position = ((Component)p).transform.position;
		Color value = Al(INK, 0.72f);
		if (guideOn && route.Count > 1)
		{
			List<Step> list = Steps();
			int near = NearestRouteIndex(position);
			int num = list.FindIndex((Step st) => st.i1 >= near);
			if (num >= 0 && num + 1 < list.Count)
			{
				Step step = list[num + 1];
				Vector3 item = route[step.i0].p;
				if (ToScreen(p, item, out var sp))
				{
					Color c = (step.warn ? TT : A);
					Box(new Rect(sp.x - S(8f), sp.y - S(8f), S(16f), S(16f)), Al(c, 0.4f));
					Fill(new Rect(sp.x - S(4f), sp.y - S(4f), S(8f), S(8f)), Al(c, 0.5f));
					Tx(sp.x + S(22f), sp.y - S(7f), (num + 2).ToString("00") + " · " + step.text + " · " + Vector3.Distance(position, item).ToString("0") + " m", st11, c, 0, glow: true, value);
				}
			}
		}
		Rect r = default(Rect);
		foreach (Contact item2 in Contacts(p))
		{
			if (item2.dist > ((item2.name == "EXIT HATCH") ? 200f : 45f) || !ToScreen(p, item2.pos, out var sp2))
			{
				continue;
			}
			float num2 = Mathf.Lerp(1f, 0.6f, Mathf.Clamp01(item2.dist / 45f));
			if (item2.name == "EXIT HATCH")
			{
				float num3 = S(18f);
				for (int num4 = 0; num4 < 18; num4++)
				{
					float num5 = (float)num4 / 18f * num3;
					Fill(new Rect(sp2.x - num5, sp2.y - num3 + num5, S(1.5f), S(1.5f)), A);
					Fill(new Rect(sp2.x + num5, sp2.y - num3 + num5, S(1.5f), S(1.5f)), A);
					Fill(new Rect(sp2.x - num5, sp2.y + num3 - num5, S(1.5f), S(1.5f)), A);
					Fill(new Rect(sp2.x + num5, sp2.y + num3 - num5, S(1.5f), S(1.5f)), A);
				}
				Tx(sp2.x, sp2.y - num3 - S(22f), "EXIT HATCH · " + item2.dist.ToString("0") + " m · " + Dv(item2.dy), st11, A, 1, glow: true, value);
				continue;
			}
			float num6 = S(item2.threat ? 44 : 34);
			((Rect)(ref r))..ctor(sp2.x - num6 / 2f, sp2.y - num6 / 2f, num6, num6);
			if (item2.threat)
			{
				DashBox(r, Al(TH, num2));
				Hatch(new Rect(((Rect)(ref r)).x + S(3f), ((Rect)(ref r)).y + S(3f), ((Rect)(ref r)).width - S(6f), ((Rect)(ref r)).height - S(6f)), TH, 0.3f * num2);
				Tx(sp2.x, ((Rect)(ref r)).yMax + S(6f), "! " + item2.name + " · " + item2.dist.ToString("0") + " m · " + Dv(item2.dy), st11, Al(TT, num2), 1, glow: true, value);
			}
			else
			{
				Box(r, Al(A, 0.25f * num2));
				Ticks(r, 8f, Al(A, num2));
				Tx(sp2.x, sp2.y - S(8f), item2.glyph, st13, Al(A, num2), 1, glow: true);
				Tx(sp2.x, ((Rect)(ref r)).yMax + S(6f), item2.name + " · " + item2.dist.ToString("00") + " m · " + Dv(item2.dy), st11, Al(item2.route ? TT : A, num2), 1, glow: true, value);
			}
		}
	}

	private int NearestRouteIndex(Vector3 me)
	{
		//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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		int result = 0;
		float num = float.MaxValue;
		for (int i = 0; i < route.Count; i++)
		{
			Vector3 val = route[i].p - me;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude < num)
			{
				num = sqrMagnitude;
				result = i;
			}
		}
		return result;
	}

	private void Awake()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		keyHud = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Hud", (KeyCode)282, "Show/hide the HUD panels");
		keyPath = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Path", (KeyCode)283, "Show/hide the route in the world");
		keyXray = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "XRay", (KeyCode)284, "Show/hide item and threat markers through walls");
		keyRescan = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Rescan", (KeyCode)285, "Scan the current level again");
		Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCamPostRender));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Knuckle Assist loaded");
	}

	private void OnDestroy()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCamPostRender));
	}

	internal void Event(string msg, bool warn = false, string once = null)
	{
		if (once == null || said.Add(once))
		{
			events.Insert(0, (DateTime.Now.ToString("HH:mm:ss"), msg, warn));
			if (events.Count > 4)
			{
				events.RemoveAt(events.Count - 1);
			}
		}
	}

	private void Update()
	{
		//IL_0006: 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_0048: 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)
		if (Input.GetKeyDown(keyHud.Value))
		{
			hudOn = !hudOn;
		}
		if (Input.GetKeyDown(keyPath.Value))
		{
			guideOn = !guideOn;
		}
		if (Input.GetKeyDown(keyXray.Value))
		{
			xrayOn = !xrayOn;
		}
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			M_Level val = CurrentLevel();
			if (Input.GetKeyDown(keyRescan.Value) && (Object)(object)val != (Object)null)
			{
				Event("RESCAN REQUESTED");
				StartScan(val);
			}
			if ((Object)(object)val != (Object)null && val.levelName != scanLevel)
			{
				said.Clear();
				StartScan(val);
			}
			HudTrack(player, val);
			if (Time.time > nextThreatScan)
			{
				nextThreatScan = Time.time + 0.5f;
				ScanThreats(player);
			}
			CoreTrack(player);
			TestShots(player);
		}
	}

	private void ScanThreats(ENT_Player p)
	{
		//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_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_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_010a: 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_0120: 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_0148: 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)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		threats.Clear();
		Vector3 position = ((Component)p).transform.position;
		Denizen[] array = Object.FindObjectsByType<Denizen>((FindObjectsSortMode)0);
		foreach (Denizen val in array)
		{
			if ((Object)(object)val == (Object)null || !((Behaviour)val).isActiveAndEnabled || ((GameEntity)val).IsDead())
			{
				continue;
			}
			Vector3 val2 = ((Component)val).transform.position - position;
			if (((Vector3)(ref val2)).sqrMagnitude > 3600f)
			{
				continue;
			}
			string text = Regex.Replace(((object)val).GetType().Name.Replace("DEN_", "").Replace("Denizen", "").Replace("_", " "), "(?<=[a-z])(?=[A-Z])", " ").Trim().ToUpperInvariant();
			if (text.Length == 0)
			{
				text = "DENIZEN";
			}
			if (!text.Contains("DEATHFLOOR") && !text.Contains("ROACH"))
			{
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				List<(string name, Vector3 p, bool moving)> list = threats;
				string item = text;
				Vector3 position2 = ((Component)val).transform.position;
				int item2;
				if ((Object)(object)component != (Object)null)
				{
					val2 = component.linearVelocity;
					item2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.25f) ? 1 : 0);
				}
				else
				{
					item2 = 0;
				}
				list.Add((item, position2, (byte)item2 != 0));
				val2 = ((Component)val).transform.position - position;
				if (((Vector3)(ref val2)).sqrMagnitude < 900f)
				{
					Event(text + " ENTERED 30 m RANGE", warn: true, "thr" + ((Object)val).GetInstanceID());
				}
			}
		}
	}

	private void OnGUI()
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null) && !((GameEntity)player).IsDead())
		{
			DrawCenter(player);
			if (xrayOn)
			{
				WorldLabels(player);
			}
			DrawCoreThreats(player);
			if (hudOn)
			{
				DrawHud(player);
			}
		}
	}

	private void TestShots(ENT_Player p)
	{
		//IL_00bc: 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_00d6: 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_00ff: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		if (shotAt < 0f)
		{
			shotAt = float.MaxValue;
			string[] commandLineArgs = Environment.GetCommandLineArgs();
			foreach (string text in commandLineArgs)
			{
				if (text.StartsWith("-wkguide-shot="))
				{
					shotAt = float.Parse(text.Substring(14), CultureInfo.InvariantCulture);
				}
			}
		}
		if (shots < 3 && !(Time.time < shotAt + (float)shots * 4f))
		{
			if (shots > 0 && route.Count > 4)
			{
				Vector3 val = route[Mathf.Min(route.Count - 1, 8 * shots)].p - ((Component)p.cam).transform.position;
				p.SetPlayerRotation(new Vector3(Mathf.Clamp((0f - Mathf.Asin(((Vector3)(ref val)).normalized.y)) * 57.29578f, -80f, 80f), Mathf.Atan2(val.x, val.z) * 57.29578f, 0f));
			}
			ScreenCapture.CaptureScreenshot(Path.Combine(Paths.GameRootPath, "BepInEx", "wkbot", "wkguide_" + shots + ".png"));
			shots++;
		}
	}

	internal static M_Level CurrentLevel()
	{
		try
		{
			LevelInfo obj = (((Object)(object)WorldLoader.instance != (Object)null) ? WorldLoader.instance.GetCurrentLevel() : null);
			return (obj != null) ? obj.GetLevel() : null;
		}
		catch
		{
			return null;
		}
	}

	internal static float MassGap(ENT_Player p)
	{
		//IL_0025: 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)
		try
		{
			DEN_DeathFloor instance = DEN_DeathFloor.instance;
			if ((Object)(object)instance == (Object)null || !instance.IsActive())
			{
				return 999f;
			}
			return ((Component)p).transform.position.y - ((Component)instance).transform.position.y;
		}
		catch
		{
			return 999f;
		}
	}

	private bool Tired()
	{
		return sw.ElapsedMilliseconds >= 5;
	}

	private static Vector3[] BuildDirs(int n)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		float num = MathF.PI * (3f - Mathf.Sqrt(5f));
		for (int i = 0; i < n; i++)
		{
			float num2 = 1f - (float)i / (float)(n - 1) * 2f;
			if (!(num2 < -0.77f))
			{
				float num3 = Mathf.Sqrt(1f - num2 * num2);
				float num4 = num * (float)i;
				list.Add(new Vector3(Mathf.Cos(num4) * num3, num2, Mathf.Sin(num4) * num3));
			}
		}
		return list.ToArray();
	}

	private static bool IsFakeHold(ENT_Player p, CL_Handhold h)
	{
		if ((Object)(object)p != (Object)null && p.grabAnywhereFakeHandholds != null)
		{
			CL_Handhold[] grabAnywhereFakeHandholds = p.grabAnywhereFakeHandholds;
			for (int i = 0; i < grabAnywhereFakeHandholds.Length; i++)
			{
				if ((Object)(object)grabAnywhereFakeHandholds[i] == (Object)(object)h)
				{
					return true;
				}
			}
		}
		if ((Object)(object)h != (Object)null && ((Object)h).name != null)
		{
			return ((Object)h).name.Contains("Fake_Handhold");
		}
		return false;
	}

	private static CL_Handhold ResolveHold(ENT_Player p, Collider col)
	{
		if ((Object)(object)col == (Object)null)
		{
			return null;
		}
		ObjectTagger val = ((Component)col).GetComponent<ObjectTagger>() ?? ((Component)col).GetComponentInParent<ObjectTagger>();
		if ((Object)(object)val == (Object)null || !val.HasTag("Handhold"))
		{
			return null;
		}
		CL_Handhold componentInParent = ((Component)col).GetComponentInParent<CL_Handhold>();
		if ((Object)(object)componentInParent == (Object)null || !componentInParent.active || !((Component)componentInParent).gameObject.activeInHierarchy || IsFakeHold(p, componentInParent))
		{
			return null;
		}
		return componentInParent;
	}

	private void StartScan(M_Level lv)
	{
		if (scanRun != null)
		{
			((MonoBehaviour)this).StopCoroutine(scanRun);
		}
		scanLevel = lv.levelName;
		scanStatus = "SCAN QUEUED";
		scanning = true;
		scanPct = 0f;
		scanY = float.NaN;
		route.Clear();
		gaps.Clear();
		items.Clear();
		scanRun = ((MonoBehaviour)this).StartCoroutine(ScanLevel(lv));
	}

	private bool Gone(M_Level lv)
	{
		if (!((Object)(object)lv == (Object)null))
		{
			return lv.levelName != scanLevel;
		}
		return true;
	}

	private IEnumerator ScanLevel(M_Level lv)
	{
		yield return (object)new WaitForSeconds(3f);
		if (Gone(lv))
		{
			yield break;
		}
		sw.Restart();
		ENT_Player p = ENT_Player.GetPlayer();
		Transform levelExit = lv.GetLevelExit();
		if ((Object)(object)p == (Object)null || (Object)(object)levelExit == (Object)null)
		{
			scanStatus = "NO EXIT";
			scanning = false;
			yield break;
		}
		Vector3 goalP = levelExit.position;
		Bounds b = new Bounds(((Component)p).transform.position, Vector3.one * 10f);
		bool first = true;
		Collider[] componentsInChildren = ((Component)lv).GetComponentsInChildren<Collider>();
		int num = 0;
		Vector3 val6 = default(Vector3);
		RaycastHit val8 = default(RaycastHit);
		RaycastHit val11 = default(RaycastHit);
		while (true)
		{
			if (num < componentsInChildren.Length)
			{
				Collider val = componentsInChildren[num];
				if (!((Object)(object)val == (Object)null) && !val.isTrigger && val.enabled)
				{
					if (first)
					{
						b = val.bounds;
						first = false;
					}
					else
					{
						((Bounds)(ref b)).Encapsulate(val.bounds);
					}
					if (Tired())
					{
						yield return null;
						sw.Restart();
						if (Gone(lv))
						{
							break;
						}
					}
				}
				num++;
				continue;
			}
			Bounds bb = b;
			((Bounds)(ref bb)).Expand(2f);
			scanBounds = b;
			string[] source = new string[7] { "Rebar", "Piton", "Flare", "Gun", "Battery", "Rope", "Grapple" };
			Item_Object[] array = Object.FindObjectsByType<Item_Object>((FindObjectsSortMode)0);
			foreach (Item_Object val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && val2.itemData != null && ((Component)val2).gameObject.activeInHierarchy && ((Bounds)(ref bb)).Contains(((Component)val2).transform.position))
				{
					string nm = val2.itemData.prefabName + " " + val2.itemData.itemName + " " + ((Object)val2).name;
					string text = source.FirstOrDefault((string value3) => nm.IndexOf(value3, StringComparison.OrdinalIgnoreCase) >= 0);
					if (text != null)
					{
						items.Add(((text == "Flare") ? "Gun" : text, ((Component)val2).transform.position));
					}
				}
			}
			List<Vector3> pos = new List<Vector3>();
			List<bool> isHold = new List<bool>();
			HashSet<Vector3Int> seen = new HashSet<Vector3Int>();
			scanStatus = "FLOORS";
			RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[16];
			float x = ((Bounds)(ref b)).min.x;
			while (true)
			{
				if (x <= ((Bounds)(ref b)).max.x)
				{
					for (float num2 = ((Bounds)(ref b)).min.z; num2 <= ((Bounds)(ref b)).max.z; num2 += 2f)
					{
						int num3 = Physics.RaycastNonAlloc(new Vector3(x, ((Bounds)(ref b)).max.y + 1f, num2), Vector3.down, hits, ((Bounds)(ref b)).size.y + 2f, -1, (QueryTriggerInteraction)1);
						for (int num4 = 0; num4 < num3; num4++)
						{
							if (((RaycastHit)(ref hits[num4])).normal.y > 0.7f && !((Component)((RaycastHit)(ref hits[num4])).collider).transform.IsChildOf(((Component)p).transform))
							{
								Add(((RaycastHit)(ref hits[num4])).point + Vector3.up * 0.2f, hold: false);
							}
						}
					}
					if (Tired())
					{
						yield return null;
						sw.Restart();
						if (Gone(lv))
						{
							break;
						}
					}
					x += 2f;
					continue;
				}
				float reach = Mathf.Min(p.GetInteractDistance(0), p.GetInteractDistance(1)) - 0.05f;
				LayerMask gmask = p.interactMask;
				List<(Collider c, Bounds cb)> cols = new List<(Collider, Bounds)>();
				Dictionary<Vector3Int, List<Collider>> smallGrid = new Dictionary<Vector3Int, List<Collider>>();
				CL_Handhold[] array2 = Object.FindObjectsByType<CL_Handhold>((FindObjectsSortMode)0);
				Bounds bounds2;
				Vector3 val5;
				foreach (CL_Handhold val3 in array2)
				{
					if ((Object)(object)val3 == (Object)null || !val3.active || !((Component)val3).gameObject.activeInHierarchy || (Object)(object)((Component)val3).GetComponentInParent<DEN_Barnacle>() != (Object)null || IsFakeHold(p, val3))
					{
						continue;
					}
					Collider[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren<Collider>();
					foreach (Collider val4 in componentsInChildren2)
					{
						if ((Object)(object)val4 == (Object)null || !val4.enabled)
						{
							continue;
						}
						Bounds bounds = val4.bounds;
						((Bounds)(ref bounds)).Expand(reach * 2f);
						if (!((Bounds)(ref bb)).Intersects(bounds))
						{
							continue;
						}
						cols.Add((val4, bounds));
						bounds2 = val4.bounds;
						val5 = ((Bounds)(ref bounds2)).size;
						if (((Vector3)(ref val5)).magnitude < 2f)
						{
							bounds2 = val4.bounds;
							Vector3Int key = Vector3Int.FloorToInt(((Bounds)(ref bounds2)).center / 2f);
							if (!smallGrid.TryGetValue(key, out var value))
							{
								value = (smallGrid[key] = new List<Collider>());
							}
							value.Add(val4);
						}
					}
				}
				HashSet<Vector3Int> seenCells = new HashSet<Vector3Int>();
				float nextRoute = Time.realtimeSinceStartup + 3f;
				float y0 = Mathf.Floor(((Bounds)(ref b)).min.y);
				float y1 = ((Bounds)(ref b)).max.y;
				for (x = y0; x <= y1; x += 1f)
				{
					scanY = x;
					scanPct = (x - y0) / Mathf.Max(1f, y1 - y0);
					scanStatus = "SCANNING";
					foreach (var item in cols)
					{
						var (c, cb) = item;
						if ((Object)(object)c == (Object)null || x < Mathf.Floor(((Bounds)(ref cb)).min.y) || x > ((Bounds)(ref cb)).max.y)
						{
							continue;
						}
						for (float x2 = Mathf.Floor(((Bounds)(ref cb)).min.x); x2 <= ((Bounds)(ref cb)).max.x; x2 += 1f)
						{
							for (float z = Mathf.Floor(((Bounds)(ref cb)).min.z); z <= ((Bounds)(ref cb)).max.z; z += 1f)
							{
								((Vector3)(ref val6))..ctor(x2, x, z);
								if (!seenCells.Add(Vector3Int.RoundToInt(val6)))
								{
									continue;
								}
								val5 = c.ClosestPointOnBounds(val6) - val6;
								if (((Vector3)(ref val5)).sqrMagnitude > reach * reach || !Physics.CheckSphere(val6, reach, LayerMask.op_Implicit(gmask), (QueryTriggerInteraction)1) || Physics.CheckSphere(val6, 0.35f, -1, (QueryTriggerInteraction)1))
								{
									continue;
								}
								Physics.queriesHitBackfaces = true;
								Vector3[] array3 = dirs;
								foreach (Vector3 val7 in array3)
								{
									if (Physics.Raycast(val6, val7, ref val8, reach, LayerMask.op_Implicit(gmask), (QueryTriggerInteraction)1) && (Object)(object)ResolveHold(p, ((RaycastHit)(ref val8)).collider) != (Object)null)
									{
										Add(((RaycastHit)(ref val8)).point + ((RaycastHit)(ref val8)).normal * 0.15f, hold: true);
									}
								}
								Vector3Int val9 = Vector3Int.FloorToInt(val6 / 2f);
								for (int num6 = -2; num6 <= 2; num6++)
								{
									for (int num7 = -2; num7 <= 2; num7++)
									{
										for (int num8 = -2; num8 <= 2; num8++)
										{
											if (!smallGrid.TryGetValue(val9 + new Vector3Int(num6, num7, num8), out var value2))
											{
												continue;
											}
											foreach (Collider item2 in value2)
											{
												bounds2 = item2.bounds;
												Vector3 val10 = ((Bounds)(ref bounds2)).center - val6;
												float magnitude = ((Vector3)(ref val10)).magnitude;
												if (!(magnitude > reach + 0.3f) && !(magnitude < 0.05f) && Physics.Raycast(val6, val10 / magnitude, ref val11, reach, LayerMask.op_Implicit(gmask), (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val11)).collider == (Object)(object)item2 && (Object)(object)ResolveHold(p, item2) != (Object)null)
												{
													Add(((RaycastHit)(ref val11)).point + ((RaycastHit)(ref val11)).normal * 0.15f, hold: true);
												}
											}
										}
									}
								}
								Physics.queriesHitBackfaces = false;
								if (Tired())
								{
									yield return null;
									sw.Restart();
									if (Gone(lv))
									{
										yield break;
									}
									if (Time.realtimeSinceStartup > nextRoute)
									{
										yield return Plan(p, lv, goalP, new List<Vector3>(pos), new List<bool>(isHold), final: false);
										nextRoute = Time.realtimeSinceStartup + 4f;
									}
								}
							}
						}
					}
				}
				Physics.queriesHitBackfaces = false;
				scanning = false;
				scanY = float.NaN;
				scanPct = 1f;
				Event(Pretty(lv.levelName) + " MAPPED · " + pos.Count + " PTS");
				yield return Plan(p, lv, goalP, pos, isHold, final: true);
				break;
			}
			break;
			void Add(Vector3 q, bool hold)
			{
				//IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if (seen.Add(Vector3Int.RoundToInt(q / 0.75f)))
				{
					pos.Add(q);
					isHold.Add(hold);
				}
			}
			void Add(Vector3 q, bool hold)
			{
				//IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if (seen.Add(Vector3Int.RoundToInt(q / 0.75f)))
				{
					pos.Add(q);
					isHold.Add(hold);
				}
			}
		}
	}

	private IEnumerator Plan(ENT_Player p, M_Level lv, Vector3 goalP, List<Vector3> pos, List<bool> isHold, bool final)
	{
		//IL_001c: 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)
		Dictionary<Vector3Int, List<int>> grid = new Dictionary<Vector3Int, List<int>>();
		for (int i = 0; i < pos.Count; i++)
		{
			Vector3Int key = Vector3Int.FloorToInt(pos[i] / 2f);
			if (!grid.TryGetValue(key, out var value))
			{
				value = (grid[key] = new List<int>());
			}
			value.Add(i);
		}
		int count = pos.Count;
		float[] cost = new float[count];
		int[] prev = new int[count];
		byte[] how = new byte[count];
		for (int j = 0; j < count; j++)
		{
			cost[j] = float.MaxValue;
			prev[j] = -1;
		}
		SortedSet<(float, int)> pq = new SortedSet<(float, int)>();
		Vector3 position = ((Component)p).transform.position;
		Vector3 val;
		for (int k = 0; k < count; k++)
		{
			val = pos[k] - position;
			if (((Vector3)(ref val)).sqrMagnitude < 9f)
			{
				cost[k] = 0f;
				pq.Add((0f, k));
			}
		}
		int goal = -1;
		int best = -1;
		float bestD = float.MaxValue;
		int exp = 0;
		RaycastHit val7 = default(RaycastHit);
		while (pq.Count > 0)
		{
			var (num, num2) = pq.Min;
			pq.Remove(pq.Min);
			if (num > cost[num2])
			{
				continue;
			}
			val = pos[num2] - goalP;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude < bestD)
			{
				bestD = sqrMagnitude;
				best = num2;
			}
			if (sqrMagnitude < 9f)
			{
				goal = num2;
				break;
			}
			Vector3Int val2 = Vector3Int.FloorToInt(pos[num2] / 2f);
			for (int l = -6; l <= 6; l++)
			{
				for (int m = -6; m <= 6; m++)
				{
					for (int n = -4; n <= 3; n++)
					{
						if (!grid.TryGetValue(val2 + new Vector3Int(l, n, m), out var value2))
						{
							continue;
						}
						foreach (int item2 in value2)
						{
							if (item2 == num2)
							{
								continue;
							}
							Vector3 val3 = pos[item2] - pos[num2];
							float magnitude = ((Vector3)(ref val3)).magnitude;
							Vector2 val4 = new Vector2(val3.x, val3.z);
							float magnitude2 = ((Vector2)(ref val4)).magnitude;
							bool flag = isHold[item2];
							bool flag2 = isHold[num2];
							bool num3 = !flag && !flag2 && magnitude2 <= 2.2f && Mathf.Abs(val3.y) <= 0.6f;
							bool flag3 = !flag && val3.y < -0.6f && val3.y > -6f && magnitude2 < 2.5f;
							bool flag4 = flag && magnitude <= 2.4f;
							bool flag5 = flag2 && !flag && magnitude <= 2f && val3.y > -1f;
							bool flag6 = flag || val3.y <= 1f;
							bool flag7 = flag2 && flag && val3.y >= 1f && magnitude2 <= 2f;
							byte b;
							float num4;
							if (num3 || flag3 || flag4 || flag5)
							{
								b = 0;
								num4 = magnitude;
							}
							else if (magnitude <= 4.5f && flag6 && (val3.y < 2.5f || flag7))
							{
								b = 1;
								num4 = 4f + magnitude * 2f;
							}
							else
							{
								if (!(magnitude <= 12f && val3.y < 4f && flag6))
								{
									continue;
								}
								b = 2;
								num4 = 60f + magnitude * 3f;
							}
							float num5 = num + num4;
							if (num5 >= cost[item2])
							{
								continue;
							}
							Vector3 val5 = pos[num2] + Vector3.up * (flag2 ? 0.2f : 0.8f);
							Vector3 val6 = pos[item2] + Vector3.up * (flag ? 0.1f : 0.5f);
							if (Physics.Linecast(val5, val6, ref val7, -1, (QueryTriggerInteraction)1))
							{
								val = ((RaycastHit)(ref val7)).point - pos[item2];
								if (((Vector3)(ref val)).sqrMagnitude > 0.8f)
								{
									continue;
								}
							}
							if (cost[item2] < float.MaxValue)
							{
								pq.Remove((cost[item2], item2));
							}
							cost[item2] = num5;
							prev[item2] = num2;
							how[item2] = b;
							pq.Add((num5, item2));
						}
					}
				}
			}
			int num6 = exp + 1;
			exp = num6;
			if (num6 % 64 == 0 && Tired())
			{
				yield return null;
				sw.Restart();
				if (Gone(lv))
				{
					yield break;
				}
			}
		}
		int num7 = ((goal >= 0) ? goal : best);
		if (num7 < 0)
		{
			if (final)
			{
				scanStatus = "NO ROUTE";
			}
			yield break;
		}
		List<int> list2 = new List<int>();
		for (int num8 = num7; num8 >= 0; num8 = prev[num8])
		{
			list2.Add(num8);
		}
		list2.Reverse();
		route.Clear();
		gaps.Clear();
		string[] array = new string[3] { "easy", "jump", "rebar" };
		for (int num9 = 0; num9 < list2.Count; num9++)
		{
			int num10 = list2[num9];
			route.Add(((num9 == 0) ? "easy" : array[how[num10]], pos[num10]));
			if (num9 <= 0 || how[num10] <= 0)
			{
				continue;
			}
			Vector3 a = pos[list2[num9 - 1]];
			Vector3? item = null;
			if (how[num10] == 2)
			{
				List<(string, Vector3)> list3 = items.Where(((string k, Vector3 p) it) => it.k == "Rebar").OrderBy(delegate((string k, Vector3 p) it)
				{
					//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val8 = it.p - a;
					return ((Vector3)(ref val8)).sqrMagnitude;
				}).ToList();
				if (list3.Count > 0)
				{
					item = list3[0].Item2;
				}
			}
			gaps.Add((array[how[num10]], a, pos[num10], Vector3.Distance(a, pos[num10]), item));
		}
		if (final)
		{
			scanStatus = ((goal >= 0) ? "ROUTE LOCKED" : "PARTIAL ROUTE");
			Event(((goal >= 0) ? "ROUTE LOCKED · " : "PARTIAL ROUTE · ") + gaps.Count(((string k, Vector3 a, Vector3 b, float gap, Vector3? rebar) x) => x.k == "jump") + " JUMPS");
			if (gaps.Any(((string k, Vector3 a, Vector3 b, float gap, Vector3? rebar) x) => x.k == "rebar"))
			{
				Event("REBAR GAP ON ROUTE — GRAB REBAR", warn: true);
			}
		}
	}

	private void OnCamPostRender(Camera cam)
	{
		//IL_005a: 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_006c: Expected O, but got Unknown
		//IL_0104: 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_0118: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: 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_01ec: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: 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_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		if (!guideOn)
		{
			return;
		}
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || (Object)(object)player.cam == (Object)null || (Object)(object)cam != (Object)(object)player.cam)
		{
			return;
		}
		if ((Object)(object)lineMat == (Object)null)
		{
			Shader val = Shader.Find("Hidden/Internal-Colored");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			lineMat = new Material(val)
			{
				hideFlags = (HideFlags)61
			};
			lineMat.SetInt("_ZTest", 8);
			lineMat.SetInt("_ZWrite", 0);
			lineMat.SetInt("_Cull", 0);
		}
		lineMat.SetPass(0);
		GL.PushMatrix();
		GL.Begin(1);
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0.91f, 0.9f, 0.88f, 0.7f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.82f, 0.2f, 0.17f, 0.95f);
		for (int i = 1; i < route.Count; i++)
		{
			Vector3 item = route[i - 1].p;
			Vector3 item2 = route[i].p;
			float num = Vector3.Distance(item, item2);
			if (!(num < 0.01f))
			{
				GL.Color((route[i].k == "rebar") ? val3 : val2);
				for (float num2 = 0f; num2 < num; num2 += 0.5f)
				{
					GL.Vertex(Vector3.Lerp(item, item2, num2 / num));
					GL.Vertex(Vector3.Lerp(item, item2, Mathf.Min(num, num2 + 0.28f) / num));
				}
			}
		}
		foreach (var gap in gaps)
		{
			GL.Color((gap.k == "rebar") ? val3 : val2);
			Tick(gap.a, 0.25f);
			Tick(gap.b, 0.25f);
			if (gap.k == "rebar" && gap.rebar.HasValue)
			{
				GL.Color(new Color(0.82f, 0.2f, 0.17f, 0.5f));
				GL.Vertex(gap.a);
				GL.Vertex(gap.rebar.Value);
			}
		}
		if (scanning && !float.IsNaN(scanY))
		{
			Bounds val4 = scanBounds;
			float num3 = scanY;
			Vector3 val5 = new Vector3(((Bounds)(ref val4)).min.x, num3, ((Bounds)(ref val4)).min.z);
			Vector3 val6 = default(Vector3);
			((Vector3)(ref val6))..ctor(((Bounds)(ref val4)).max.x, num3, ((Bounds)(ref val4)).min.z);
			Vector3 val7 = default(Vector3);
			((Vector3)(ref val7))..ctor(((Bounds)(ref val4)).max.x, num3, ((Bounds)(ref val4)).max.z);
			Vector3 val8 = default(Vector3);
			((Vector3)(ref val8))..ctor(((Bounds)(ref val4)).min.x, num3, ((Bounds)(ref val4)).max.z);
			GL.Color(new Color(0.82f, 0.2f, 0.17f, 0.5f));
			GL.Vertex(val5);
			GL.Vertex(val6);
			GL.Vertex(val6);
			GL.Vertex(val7);
			GL.Vertex(val7);
			GL.Vertex(val8);
			GL.Vertex(val8);
			GL.Vertex(val5);
		}
		GL.End();
		GL.PopMatrix();
	}

	private static void Tick(Vector3 c, float s)
	{
		//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_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_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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type