Decompiled source of Empress ToolKit v0.8.1

EmpressToolKit.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+31d33a1e262fb9cd936a8fd3f583fdd7bc996e5a")]
[assembly: AssemblyProduct("EmpressToolKit")]
[assembly: AssemblyTitle("EmpressToolKit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.EmpressToolKit
{
	public sealed class EmpressFPSOverlay : MonoBehaviour
	{
		private static EmpressFPSOverlay _instance;

		private bool _active;

		private float _acc;

		private int _frames;

		private float _fps;

		public bool Active => _active;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressFPSOverlay Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_FPSOverlay");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressFPSOverlay>();
			_instance._active = true;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				try
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			_active = !_active;
			((Component)this).gameObject.SetActive(_active);
		}

		private void Update()
		{
			_acc += Time.deltaTime;
			_frames++;
			if (_acc >= 0.5f)
			{
				_fps = (float)_frames / _acc;
				_acc = 0f;
				_frames = 0;
			}
		}

		private void OnGUI()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (_active)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(12f, 12f, 300f, 24f);
				GUI.Label(val, $"FPS {_fps:F1}");
			}
		}
	}
	public static class EmpressGame
	{
		public static PlayerController LocalPlayerController()
		{
			PlayerController[] array = Object.FindObjectsOfType<PlayerController>(true);
			PlayerController val = null;
			PlayerController[] array2 = array;
			foreach (PlayerController val2 in array2)
			{
				PhotonView component = ((Component)val2).GetComponent<PhotonView>();
				if (!PhotonNetwork.InRoom || (Object)(object)component == (Object)null || component.IsMine)
				{
					val = val2;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val) && array.Length != 0)
			{
				val = array[0];
			}
			return val;
		}

		public static LevelGenerator LevelGen()
		{
			return LevelGenerator.Instance;
		}

		public static bool IsMasterOrSingle()
		{
			return SemiFunc.IsMasterClientOrSingleplayer();
		}

		public static Vector3 TruckWorldPos(out bool ok)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			ok = false;
			LevelGenerator instance = LevelGenerator.Instance;
			if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.LevelPathTruck))
			{
				ok = true;
				return ((Component)instance.LevelPathTruck).transform.position;
			}
			return Vector3.zero;
		}
	}
	public sealed class EmpressLevelGizmos : MonoBehaviour
	{
		private static EmpressLevelGizmos _instance;

		private GameObject _root;

		private readonly List<GameObject> _lines = new List<GameObject>();

		private readonly List<GameObject> _markers = new List<GameObject>();

		private static Material _cachedLineMat;

		public bool Active => Object.op_Implicit((Object)(object)_root) && _root.activeSelf;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressLevelGizmos Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_LevelGizmos");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressLevelGizmos>();
			_instance._root = val;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if (Object.op_Implicit((Object)(object)_instance) && Object.op_Implicit((Object)(object)_instance._root))
			{
				try
				{
					Object.Destroy((Object)(object)_instance._root);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			if (!Active)
			{
				_root.SetActive(true);
				Rebuild();
			}
			else
			{
				_root.SetActive(false);
				Clear();
			}
		}

		public void Rebuild()
		{
			//IL_00e7: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_032f: 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_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: 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_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			Clear();
			LevelGenerator instance = LevelGenerator.Instance;
			List<LevelPoint> list = ((Object.op_Implicit((Object)(object)instance) && instance.LevelPathPoints != null && instance.LevelPathPoints.Count > 0) ? instance.LevelPathPoints : Object.FindObjectsOfType<LevelPoint>(true).ToList());
			if (list == null || list.Count == 0)
			{
				return;
			}
			foreach (LevelPoint item2 in list)
			{
				if (Object.op_Implicit((Object)(object)item2) && Object.op_Implicit((Object)(object)((Component)item2).transform))
				{
					GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
					((Object)val).name = "LP:" + ((Object)item2).name;
					val.layer = 0;
					val.transform.SetParent(_root.transform, false);
					val.transform.position = ((Component)item2).transform.position + Vector3.up * 0.1f;
					val.transform.localScale = Vector3.one * 0.35f;
					Collider component = val.GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
					Renderer component2 = val.GetComponent<Renderer>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.shadowCastingMode = (ShadowCastingMode)0;
						component2.receiveShadows = false;
					}
					_markers.Add(val);
				}
			}
			HashSet<ulong> hashSet = new HashSet<ulong>();
			foreach (LevelPoint item3 in list)
			{
				if (!Object.op_Implicit((Object)(object)item3))
				{
					continue;
				}
				List<LevelPoint> connectedPoints = item3.ConnectedPoints;
				if (connectedPoints == null)
				{
					continue;
				}
				Vector3 val2 = ((Component)item3).transform.position + Vector3.up * 0.05f;
				foreach (LevelPoint item4 in connectedPoints)
				{
					if (Object.op_Implicit((Object)(object)item4))
					{
						ulong num = (ulong)((Object)item3).GetInstanceID();
						ulong num2 = (ulong)((Object)item4).GetInstanceID();
						ulong item = ((num < num2) ? ((num << 32) | num2) : ((num2 << 32) | num));
						if (hashSet.Add(item))
						{
							GameObject val3 = new GameObject("Path:" + ((Object)item3).name + "->" + ((Object)item4).name);
							val3.transform.SetParent(_root.transform, false);
							LineRenderer val4 = val3.AddComponent<LineRenderer>();
							val4.useWorldSpace = true;
							val4.positionCount = 2;
							val4.startWidth = 0.05f;
							val4.endWidth = 0.05f;
							val4.numCapVertices = 4;
							val4.numCornerVertices = 2;
							((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
							((Renderer)val4).receiveShadows = false;
							((Renderer)val4).material = GetDefaultLineMaterial();
							val4.startColor = new Color(0.85f, 0.85f, 0.85f, 0.9f);
							val4.endColor = new Color(0.85f, 0.85f, 0.85f, 0.9f);
							val4.SetPosition(0, val2);
							val4.SetPosition(1, ((Component)item4).transform.position + Vector3.up * 0.05f);
							_lines.Add(val3);
						}
					}
				}
			}
		}

		private void Clear()
		{
			foreach (GameObject marker in _markers)
			{
				if (Object.op_Implicit((Object)(object)marker))
				{
					Object.Destroy((Object)(object)marker);
				}
			}
			foreach (GameObject line in _lines)
			{
				if (Object.op_Implicit((Object)(object)line))
				{
					Object.Destroy((Object)(object)line);
				}
			}
			_markers.Clear();
			_lines.Clear();
		}

		private static Material GetDefaultLineMaterial()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_cachedLineMat))
			{
				return _cachedLineMat;
			}
			Shader val = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			}
			_cachedLineMat = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(Shader.Find("Sprites/Default")));
			((Object)_cachedLineMat).hideFlags = (HideFlags)61;
			return _cachedLineMat;
		}
	}
	public sealed class EmpressMeshBoundsOverlay : MonoBehaviour
	{
		private static EmpressMeshBoundsOverlay _instance;

		private GameObject _root;

		private readonly List<GameObject> _boxes = new List<GameObject>();

		private static Material _cachedLineMat;

		public bool Active => Object.op_Implicit((Object)(object)_root) && _root.activeSelf;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressMeshBoundsOverlay Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_MeshBounds_ROOT");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressMeshBoundsOverlay>();
			_instance._root = val;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if (Object.op_Implicit((Object)(object)_instance) && Object.op_Implicit((Object)(object)_instance._root))
			{
				try
				{
					Object.Destroy((Object)(object)_instance._root);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			if (!Active)
			{
				_root.SetActive(true);
				Rebuild();
			}
			else
			{
				_root.SetActive(false);
				Clear();
			}
		}

		public void Rebuild()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Clear();
			MeshRenderer[] array = Object.FindObjectsOfType<MeshRenderer>(true);
			Material defaultLineMaterial = GetDefaultLineMaterial();
			MeshRenderer[] array2 = array;
			foreach (MeshRenderer val in array2)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Renderer)val).enabled)
				{
					Bounds bounds = ((Renderer)val).bounds;
					DrawBounds(bounds, defaultLineMaterial);
				}
			}
		}

		private void Clear()
		{
			foreach (GameObject box in _boxes)
			{
				if (Object.op_Implicit((Object)(object)box))
				{
					Object.Destroy((Object)(object)box);
				}
			}
			_boxes.Clear();
		}

		private static Material GetDefaultLineMaterial()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_cachedLineMat))
			{
				return _cachedLineMat;
			}
			Shader val = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			}
			_cachedLineMat = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(Shader.Find("Sprites/Default")));
			((Object)_cachedLineMat).hideFlags = (HideFlags)61;
			return _cachedLineMat;
		}

		private void DrawBounds(Bounds b, Material mat)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0122: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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)
			//IL_0158: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			Material mat2 = mat;
			Vector3 center = ((Bounds)(ref b)).center;
			Vector3 extents = ((Bounds)(ref b)).extents;
			Vector3 val = center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z);
			Vector3 val2 = center + new Vector3(0f - extents.x, 0f - extents.y, extents.z);
			Vector3 val3 = center + new Vector3(0f - extents.x, extents.y, 0f - extents.z);
			Vector3 val4 = center + new Vector3(0f - extents.x, extents.y, extents.z);
			Vector3 val5 = center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z);
			Vector3 val6 = center + new Vector3(extents.x, 0f - extents.y, extents.z);
			Vector3 val7 = center + new Vector3(extents.x, extents.y, 0f - extents.z);
			Vector3 val8 = center + new Vector3(extents.x, extents.y, extents.z);
			Edge(val, val2);
			Edge(val2, val4);
			Edge(val4, val3);
			Edge(val3, val);
			Edge(val5, val6);
			Edge(val6, val8);
			Edge(val8, val7);
			Edge(val7, val5);
			Edge(val, val5);
			Edge(val2, val6);
			Edge(val4, val8);
			Edge(val3, val7);
			void Edge(Vector3 a, Vector3 b2)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				GameObject val9 = new GameObject("BoundsEdge");
				val9.transform.SetParent(_root.transform, false);
				LineRenderer val10 = val9.AddComponent<LineRenderer>();
				val10.useWorldSpace = true;
				val10.positionCount = 2;
				val10.startWidth = 0.02f;
				val10.endWidth = 0.02f;
				((Renderer)val10).material = mat2;
				((Renderer)val10).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val10).receiveShadows = false;
				val10.startColor = new Color(0.2f, 0.9f, 0.9f, 0.9f);
				val10.endColor = new Color(0.2f, 0.9f, 0.9f, 0.9f);
				val10.SetPosition(0, a);
				val10.SetPosition(1, b2);
				_boxes.Add(val9);
			}
		}
	}
	public sealed class EmpressNavMeshOverlay : MonoBehaviour
	{
		private static EmpressNavMeshOverlay _instance;

		private GameObject _root;

		private readonly List<GameObject> _lines = new List<GameObject>();

		private static Material _cachedLineMat;

		public bool Active => Object.op_Implicit((Object)(object)_root) && _root.activeSelf;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressNavMeshOverlay Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_LevelNavMesh_ROOT");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressNavMeshOverlay>();
			_instance._root = val;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if ((Object)(object)_instance != (Object)null && (Object)(object)_instance._root != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)_instance._root);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			if (!Active)
			{
				_root.SetActive(true);
				Rebuild();
			}
			else
			{
				_root.SetActive(false);
				Clear();
			}
		}

		public void Rebuild()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_001f: 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_00e9: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			Clear();
			NavMeshTriangulation val = NavMesh.CalculateTriangulation();
			if (val.vertices != null && val.vertices.Length != 0 && val.indices != null && val.indices.Length != 0)
			{
				HashSet<ulong> seen = new HashSet<ulong>();
				Material defaultLineMaterial = GetDefaultLineMaterial();
				for (int i = 0; i < val.indices.Length; i += 3)
				{
					int num = val.indices[i];
					int num2 = val.indices[i + 1];
					int num3 = val.indices[i + 2];
					DrawEdge(val.vertices[num], val.vertices[num2], seen, defaultLineMaterial);
					DrawEdge(val.vertices[num2], val.vertices[num3], seen, defaultLineMaterial);
					DrawEdge(val.vertices[num3], val.vertices[num], seen, defaultLineMaterial);
				}
			}
		}

		private void Clear()
		{
			foreach (GameObject line in _lines)
			{
				if (Object.op_Implicit((Object)(object)line))
				{
					Object.Destroy((Object)(object)line);
				}
			}
			_lines.Clear();
		}

		private static Material GetDefaultLineMaterial()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_cachedLineMat))
			{
				return _cachedLineMat;
			}
			Shader val = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
			}
			_cachedLineMat = (Object.op_Implicit((Object)(object)val) ? new Material(val) : new Material(Shader.Find("Sprites/Default")));
			((Object)_cachedLineMat).hideFlags = (HideFlags)61;
			return _cachedLineMat;
		}

		private void DrawEdge(Vector3 a, Vector3 b, HashSet<ulong> seen, Material mat)
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_00ac: 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_00d9: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			ulong item = HashEdge(a, b);
			if (seen.Add(item))
			{
				GameObject val = new GameObject("NavEdge");
				val.transform.SetParent(_root.transform, false);
				LineRenderer val2 = val.AddComponent<LineRenderer>();
				val2.useWorldSpace = true;
				val2.positionCount = 2;
				val2.startWidth = 0.025f;
				val2.endWidth = 0.025f;
				val2.numCapVertices = 2;
				val2.numCornerVertices = 2;
				((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val2).receiveShadows = false;
				((Renderer)val2).material = mat;
				val2.startColor = new Color(0.3f, 0.9f, 0.3f, 0.9f);
				val2.endColor = new Color(0.3f, 0.9f, 0.3f, 0.9f);
				val2.SetPosition(0, a + Vector3.up * 0.02f);
				val2.SetPosition(1, b + Vector3.up * 0.02f);
				_lines.Add(val);
			}
		}

		private static ulong HashEdge(Vector3 a, Vector3 b)
		{
			//IL_0001: 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)
			ulong num = HashVec(a);
			ulong num2 = HashVec(b);
			return (num < num2) ? ((num << 32) | num2) : ((num2 << 32) | num);
		}

		private static ulong HashVec(Vector3 v)
		{
			//IL_0002: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			uint num = (uint)Mathf.RoundToInt(v.x * 1000f);
			uint num2 = (uint)Mathf.RoundToInt(v.y * 1000f);
			uint num3 = (uint)Mathf.RoundToInt(v.z * 1000f);
			ulong num4 = num;
			num4 = (num4 * 397) ^ num2;
			return (num4 * 397) ^ num3;
		}
	}
	public sealed class EmpressPlayerOverlay : MonoBehaviour
	{
		private static EmpressPlayerOverlay _instance;

		private bool _active;

		public bool Active => _active;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressPlayerOverlay Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_PlayerOverlay");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressPlayerOverlay>();
			_instance._active = true;
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				try
				{
					Object.Destroy((Object)(object)((Component)_instance).gameObject);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			_active = !_active;
			((Component)this).gameObject.SetActive(_active);
		}

		private void OnGUI()
		{
			//IL_003b: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (_active)
			{
				PlayerController val = EmpressGame.LocalPlayerController();
				string text;
				if (Object.op_Implicit((Object)(object)val))
				{
					Transform transform = ((Component)val).transform;
					text = $"Pos {transform.position}  RotY {transform.eulerAngles.y:F1}\r\nEnergy {val.EnergyCurrent:F1}/{val.EnergyStart:F1}\r\nSprint {val.sprinting}\r\nCrouch {val.Crouching}";
				}
				else
				{
					text = "No local player";
				}
				GUI.Label(new Rect(12f, 36f, 800f, 80f), text);
			}
		}
	}
	[BepInPlugin("Empress.EmpressToolKit", "EmpressToolKit", "1.1.0")]
	public sealed class EmpressToolKit : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(CameraAim), "Update")]
		private static class Patch_CameraAim_Update
		{
			private static bool Prefix()
			{
				return !Object.op_Implicit((Object)(object)Instance) || !Instance._uiVisible;
			}
		}

		[CompilerGenerated]
		private sealed class <InitializeCanvasDelayed>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EmpressToolKit <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitializeCanvasDelayed>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.BuildCanvas();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private ConfigEntry<KeyCode> _toggleKey = null;

		private ConfigEntry<float> _scrollSpeed = null;

		private ConfigEntry<float> _uiScale = null;

		private ConfigEntry<Vector2> _uiPosition = null;

		private GameObject _canvasRoot = null;

		private Canvas _canvas = null;

		private GameObject _panelRoot = null;

		private ScrollRect _scrollRect = null;

		private Transform _contentContainer = null;

		private TextMeshProUGUI _statusText = null;

		private TextMeshProUGUI _countText = null;

		private int _tabIndex;

		private CursorLockMode _prevLock;

		private bool _prevVisible;

		private bool _uiVisible;

		private readonly Color _bg = new Color(0.02f, 0.02f, 0.02f, 0.95f);

		private readonly Color _bg2 = new Color(0.07f, 0.07f, 0.07f, 0.98f);

		private readonly Color _fg = new Color(0.9f, 0.9f, 0.9f, 1f);

		private readonly Color _mutedCol = new Color(0.6f, 0.6f, 0.65f, 0.8f);

		private readonly Color _accentBase = new Color(0.1f, 1f, 0.4f, 1f);

		private readonly Color _accentHover = new Color(0.3f, 1f, 0.6f, 1f);

		private readonly Color _accentDisabled = new Color(0.05f, 0.3f, 0.15f, 0.6f);

		internal static EmpressToolKit Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony Harmony { get; private set; } = null;


		private void Awake()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			Harmony.PatchAll();
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "ToggleKey", (KeyCode)277, "");
			_scrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ScrollSpeed", 35f, "");
			_uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "UIScale", 1f, "");
			_uiPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("UI", "UIPosition", new Vector2(0f, 0f), "");
			((MonoBehaviour)this).StartCoroutine(InitializeCanvasDelayed());
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} ready");
		}

		[IteratorStateMachine(typeof(<InitializeCanvasDelayed>d__35))]
		private IEnumerator InitializeCanvasDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeCanvasDelayed>d__35(0)
			{
				<>4__this = this
			};
		}

		private void OnDestroy()
		{
			try
			{
				Harmony harmony = Harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			if (_uiVisible)
			{
				RestoreCursor();
			}
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				Object.Destroy((Object)(object)_canvasRoot);
			}
			EmpressLevelGizmos.DestroyIfExists();
			EmpressNavMeshOverlay.DestroyIfExists();
			EmpressMeshBoundsOverlay.DestroyIfExists();
			EmpressFPSOverlay.DestroyIfExists();
			EmpressPlayerOverlay.DestroyIfExists();
			EmpressWaypointsOverlay.DestroyIfExists();
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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)
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_uiVisible = !_uiVisible;
				if (_uiVisible)
				{
					TakeCursor();
					ShowCanvas();
				}
				else
				{
					RestoreCursor();
					HideCanvas();
				}
			}
			if (_uiVisible)
			{
				KeepCursorFree();
			}
			if (Object.op_Implicit((Object)(object)_scrollRect) && Mathf.Abs(_scrollRect.scrollSensitivity - _scrollSpeed.Value) > 0.001f)
			{
				_scrollRect.scrollSensitivity = _scrollSpeed.Value;
			}
			if (Object.op_Implicit((Object)(object)_panelRoot))
			{
				RectTransform component = _panelRoot.GetComponent<RectTransform>();
				((Transform)component).localScale = new Vector3(_uiScale.Value, _uiScale.Value, 1f);
				component.anchoredPosition = _uiPosition.Value;
			}
		}

		private void BuildCanvas()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Expected O, but got Unknown
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: 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_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Expected O, but got Unknown
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_079d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0818: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0846: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: 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_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_0927: Unknown result type (might be due to invalid IL or missing references)
			//IL_093e: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			//IL_099e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adf: Unknown result type (might be due to invalid IL or missing references)
			_canvasRoot = new GameObject("EmpressToolKitCanvas");
			Object.DontDestroyOnLoad((Object)(object)_canvasRoot);
			_canvasRoot.layer = LayerMask.NameToLayer("UI");
			_canvas = _canvasRoot.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.sortingOrder = 32767;
			_canvas.overrideSorting = true;
			CanvasScaler val = _canvasRoot.AddComponent<CanvasScaler>();
			val.uiScaleMode = (ScaleMode)1;
			val.referenceResolution = new Vector2(1920f, 1080f);
			val.matchWidthOrHeight = 1f;
			_canvasRoot.AddComponent<GraphicRaycaster>();
			if ((Object)(object)EventSystem.current == (Object)null)
			{
				GameObject val2 = new GameObject("EventSystem_EMPRESS");
				Object.DontDestroyOnLoad((Object)(object)val2);
				val2.AddComponent<EventSystem>();
				val2.AddComponent<StandaloneInputModule>();
			}
			_panelRoot = CreateUIElement("Panel", _canvasRoot.transform);
			RectTransform component = _panelRoot.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(640f, 720f);
			component.anchoredPosition = _uiPosition.Value;
			Image val3 = _panelRoot.AddComponent<Image>();
			((Graphic)val3).color = _bg;
			Outline val4 = _panelRoot.AddComponent<Outline>();
			((Shadow)val4).effectColor = new Color(0.1f, 0.5f, 0.1f, 0.5f);
			((Shadow)val4).effectDistance = new Vector2(2f, -2f);
			GameObject val5 = CreateUIElement("Header", _panelRoot.transform);
			RectTransform component2 = val5.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0.5f, 1f);
			component2.sizeDelta = new Vector2(-28f, 60f);
			component2.anchoredPosition = new Vector2(0f, -14f);
			HorizontalLayoutGroup val6 = val5.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val6).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val6).spacing = 10f;
			GameObject val7 = CreateUIElement("Title", val5.transform);
			LayoutElement val8 = val7.AddComponent<LayoutElement>();
			val8.flexibleWidth = 1f;
			val8.minWidth = 200f;
			TextMeshProUGUI val9 = val7.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val9).text = "<b>EMPRESS TOOLKIT</b> <color=#00FF66>- Debug";
			((TMP_Text)val9).fontSize = 20f;
			((TMP_Text)val9).fontStyle = (FontStyles)1;
			((Graphic)val9).color = _fg;
			((TMP_Text)val9).alignment = (TextAlignmentOptions)4097;
			GameObject val10 = CreateButton("CloseBtn", val5.transform, "X");
			LayoutElement val11 = val10.AddComponent<LayoutElement>();
			val11.preferredWidth = 40f;
			val11.preferredHeight = 26f;
			Button component3 = val10.GetComponent<Button>();
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				_uiVisible = false;
				RestoreCursor();
				HideCanvas();
			});
			DrawDivider(_panelRoot.transform, -80f);
			GameObject tabBar = CreateUIElement("TabBar", _panelRoot.transform);
			RectTransform component4 = tabBar.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 1f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.pivot = new Vector2(0.5f, 1f);
			component4.sizeDelta = new Vector2(-28f, 40f);
			component4.anchoredPosition = new Vector2(0f, -88f);
			HorizontalLayoutGroup val12 = tabBar.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val12).spacing = 10f;
			((HorizontalOrVerticalLayoutGroup)val12).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val12).childForceExpandHeight = true;
			string[] array = new string[4] { "LEVELS \ud83d\uddfa", "PLAYER \ud83d\udc64", "NETWORK ☁", "PERF ⏱" };
			for (int i = 0; i < array.Length; i++)
			{
				int index = i;
				GameObject val13 = CreateButton($"Tab{index}", tabBar.transform, array[i]);
				Image component5 = val13.GetComponent<Image>();
				((Graphic)component5).color = _bg2;
				Button component6 = val13.GetComponent<Button>();
				((Selectable)component6).transition = (Transition)1;
				ColorBlock colors = default(ColorBlock);
				((ColorBlock)(ref colors)).normalColor = Color.white;
				((ColorBlock)(ref colors)).highlightedColor = _accentHover;
				((ColorBlock)(ref colors)).pressedColor = _accentBase;
				((ColorBlock)(ref colors)).selectedColor = _accentBase;
				((ColorBlock)(ref colors)).disabledColor = _accentDisabled;
				((ColorBlock)(ref colors)).colorMultiplier = 1f;
				((ColorBlock)(ref colors)).fadeDuration = 0.1f;
				((Selectable)component6).colors = colors;
				((UnityEvent)component6.onClick).AddListener((UnityAction)delegate
				{
					_tabIndex = index;
					RenderCurrentTab();
					UpdateTabVisuals(tabBar);
				});
			}
			DrawDivider(_panelRoot.transform, -136f);
			GameObject val14 = CreateUIElement("Status", _panelRoot.transform);
			RectTransform component7 = val14.GetComponent<RectTransform>();
			component7.anchorMin = new Vector2(0f, 1f);
			component7.anchorMax = new Vector2(1f, 1f);
			component7.pivot = new Vector2(0.5f, 1f);
			component7.sizeDelta = new Vector2(-28f, 30f);
			component7.anchoredPosition = new Vector2(0f, -200f);
			_statusText = val14.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_statusText).fontSize = 11f;
			((Graphic)_statusText).color = new Color(0.95f, 0.75f, 0.3f, 1f);
			((TMP_Text)_statusText).alignment = (TextAlignmentOptions)514;
			GameObject val15 = CreateUIElement("ScrollView", _panelRoot.transform);
			RectTransform component8 = val15.GetComponent<RectTransform>();
			component8.anchorMin = new Vector2(0f, 0f);
			component8.anchorMax = new Vector2(1f, 1f);
			component8.offsetMin = new Vector2(14f, 50f);
			component8.offsetMax = new Vector2(-34f, -276f);
			_scrollRect = val15.AddComponent<ScrollRect>();
			_scrollRect.horizontal = false;
			_scrollRect.vertical = true;
			_scrollRect.scrollSensitivity = _scrollSpeed.Value;
			_scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			GameObject val16 = CreateUIElement("Viewport", val15.transform);
			RectTransform component9 = val16.GetComponent<RectTransform>();
			component9.anchorMin = Vector2.zero;
			component9.anchorMax = Vector2.one;
			component9.sizeDelta = Vector2.zero;
			val16.AddComponent<RectMask2D>();
			_scrollRect.viewport = component9;
			GameObject val17 = CreateUIElement("Content", val16.transform);
			RectTransform component10 = val17.GetComponent<RectTransform>();
			component10.anchorMin = new Vector2(0f, 1f);
			component10.anchorMax = new Vector2(1f, 1f);
			component10.pivot = new Vector2(0.5f, 1f);
			component10.sizeDelta = new Vector2(0f, 500f);
			VerticalLayoutGroup val18 = val17.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val18).spacing = 6f;
			((HorizontalOrVerticalLayoutGroup)val18).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val18).childForceExpandHeight = false;
			val17.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_scrollRect.content = component10;
			_contentContainer = val17.transform;
			GameObject val19 = CreateUIElement("Scrollbar", val15.transform);
			RectTransform component11 = val19.GetComponent<RectTransform>();
			component11.anchorMin = new Vector2(1f, 0f);
			component11.anchorMax = new Vector2(1f, 1f);
			component11.pivot = new Vector2(1f, 1f);
			component11.sizeDelta = new Vector2(20f, 0f);
			component11.anchoredPosition = new Vector2(0f, 0f);
			Image val20 = val19.AddComponent<Image>();
			((Graphic)val20).color = _bg2;
			Scrollbar val21 = val19.AddComponent<Scrollbar>();
			val21.direction = (Direction)2;
			GameObject val22 = CreateUIElement("Sliding Area", val19.transform);
			RectTransform component12 = val22.GetComponent<RectTransform>();
			component12.anchorMin = Vector2.zero;
			component12.anchorMax = Vector2.one;
			component12.sizeDelta = new Vector2(-10f, -10f);
			GameObject val23 = CreateUIElement("Handle", val22.transform);
			RectTransform component13 = val23.GetComponent<RectTransform>();
			component13.anchorMin = Vector2.zero;
			component13.anchorMax = Vector2.one;
			component13.sizeDelta = Vector2.zero;
			Image val24 = val23.AddComponent<Image>();
			((Graphic)val24).color = _accentBase;
			((Selectable)val21).targetGraphic = (Graphic)(object)val24;
			val21.handleRect = component13;
			_scrollRect.verticalScrollbar = val21;
			GameObject val25 = CreateUIElement("Count", _panelRoot.transform);
			RectTransform component14 = val25.GetComponent<RectTransform>();
			component14.anchorMin = new Vector2(0f, 0f);
			component14.anchorMax = new Vector2(1f, 0f);
			component14.pivot = new Vector2(0.5f, 0f);
			component14.sizeDelta = new Vector2(-28f, 30f);
			component14.anchoredPosition = new Vector2(0f, 12f);
			_countText = val25.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_countText).fontSize = 12f;
			((Graphic)_countText).color = _mutedCol;
			((TMP_Text)_countText).alignment = (TextAlignmentOptions)514;
			_canvasRoot.SetActive(false);
			UpdateTabVisuals(tabBar);
			RenderCurrentTab();
		}

		private void ShowCanvas()
		{
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				_canvasRoot.SetActive(true);
			}
			RenderCurrentTab();
		}

		private void HideCanvas()
		{
			if (Object.op_Implicit((Object)(object)_canvasRoot))
			{
				_canvasRoot.SetActive(false);
			}
		}

		private void UpdateTabVisuals(GameObject tabBar)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)tabBar))
			{
				return;
			}
			for (int i = 0; i < tabBar.transform.childCount; i++)
			{
				Transform child = tabBar.transform.GetChild(i);
				Image component = ((Component)child).GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Graphic)component).color = (Color)((_tabIndex == i) ? new Color(0.02f, 0.1f, 0.05f, 1f) : _bg2);
				}
			}
		}

		private void RenderCurrentTab()
		{
			if (!((Object)(object)_contentContainer == (Object)null))
			{
				for (int num = _contentContainer.childCount - 1; num >= 0; num--)
				{
					Object.DestroyImmediate((Object)(object)((Component)_contentContainer.GetChild(num)).gameObject);
				}
				if (_tabIndex == 0)
				{
					RenderLevelsTab();
				}
				else if (_tabIndex == 1)
				{
					RenderPlayerTab();
				}
				else if (_tabIndex == 2)
				{
					RenderNetworkTab();
				}
				else if (_tabIndex == 3)
				{
					RenderPerfTab();
				}
			}
		}

		private void TakeCursor()
		{
			//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)
			_prevLock = Cursor.lockState;
			_prevVisible = Cursor.visible;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}

		private void RestoreCursor()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Cursor.lockState = _prevLock;
			Cursor.visible = _prevVisible;
		}

		private void KeepCursorFree()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Cursor.lockState > 0)
			{
				Cursor.lockState = (CursorLockMode)0;
			}
			if (!Cursor.visible)
			{
				Cursor.visible = true;
			}
		}

		private void DrawDivider(Transform parent, float yPos)
		{
			//IL_0020: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			GameObject val = CreateUIElement("Divider", parent);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.sizeDelta = new Vector2(-28f, 1f);
			component.anchoredPosition = new Vector2(0f, yPos);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.1f, 0.8f, 0.4f, 0.2f);
		}

		private void RenderLevelsTab()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = "Level tools";
			}
			TextMeshProUGUI val = CreateTMP(_contentContainer, "<b>LEVELS</b>", 16f, _fg, (TextAlignmentOptions)4097);
			((Component)val).gameObject.AddComponent<LayoutElement>().minHeight = 32f;
			GameObject val2 = CreateRow(_contentContainer);
			Button val3 = CreateActionButton(val2.transform, "Next Level ▶", TryAdvanceLevel);
			((Selectable)val3).interactable = SemiFunc.IsMasterClientOrSingleplayer();
			if (!((Selectable)val3).interactable)
			{
				Image component = ((Component)val3).GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Graphic)component).color = _accentDisabled;
				}
			}
			GameObject val4 = CreateRow(_contentContainer);
			string text = (EmpressLevelGizmos.ExistsAndActive ? "Hide Points/Paths ⦿" : "Show Points/Paths ⦿");
			Button gizBtn = CreateActionButton(val4.transform, text, delegate
			{
			});
			((UnityEventBase)gizBtn.onClick).RemoveAllListeners();
			((UnityEvent)gizBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressLevelGizmos empressLevelGizmos = EmpressLevelGizmos.Ensure();
				empressLevelGizmos.Toggle();
				TextMeshProUGUI componentInChildren4 = ((Component)gizBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren4))
				{
					((TMP_Text)componentInChildren4).text = (empressLevelGizmos.Active ? "Hide Points/Paths ⦿" : "Show Points/Paths ⦿");
				}
			});
			GameObject val5 = CreateRow(_contentContainer);
			string text2 = (EmpressNavMeshOverlay.ExistsAndActive ? "Hide NavMesh △" : "Show NavMesh △");
			Button navBtn = CreateActionButton(val5.transform, text2, delegate
			{
			});
			((UnityEventBase)navBtn.onClick).RemoveAllListeners();
			((UnityEvent)navBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressNavMeshOverlay empressNavMeshOverlay = EmpressNavMeshOverlay.Ensure();
				empressNavMeshOverlay.Toggle();
				TextMeshProUGUI componentInChildren3 = ((Component)navBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren3))
				{
					((TMP_Text)componentInChildren3).text = (empressNavMeshOverlay.Active ? "Hide NavMesh △" : "Show NavMesh △");
				}
			});
			GameObject val6 = CreateRow(_contentContainer);
			string text3 = (EmpressMeshBoundsOverlay.ExistsAndActive ? "Hide Mesh Bounds ▭" : "Show Mesh Bounds ▭");
			Button meshBtn = CreateActionButton(val6.transform, text3, delegate
			{
			});
			((UnityEventBase)meshBtn.onClick).RemoveAllListeners();
			((UnityEvent)meshBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressMeshBoundsOverlay empressMeshBoundsOverlay = EmpressMeshBoundsOverlay.Ensure();
				empressMeshBoundsOverlay.Toggle();
				TextMeshProUGUI componentInChildren2 = ((Component)meshBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren2))
				{
					((TMP_Text)componentInChildren2).text = (empressMeshBoundsOverlay.Active ? "Hide Mesh Bounds ▭" : "Show Mesh Bounds ▭");
				}
			});
			GameObject val7 = CreateRow(_contentContainer);
			string text4 = (EmpressWaypointsOverlay.ExistsAndActive ? "Hide Waypoints \ud83d\udccd" : "Show Waypoints \ud83d\udccd");
			Button wpToggleBtn = CreateActionButton(val7.transform, text4, delegate
			{
			});
			((UnityEventBase)wpToggleBtn.onClick).RemoveAllListeners();
			((UnityEvent)wpToggleBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressWaypointsOverlay empressWaypointsOverlay = EmpressWaypointsOverlay.Ensure();
				empressWaypointsOverlay.Toggle();
				TextMeshProUGUI componentInChildren = ((Component)wpToggleBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((TMP_Text)componentInChildren).text = (empressWaypointsOverlay.Active ? "Hide Waypoints \ud83d\udccd" : "Show Waypoints \ud83d\udccd");
				}
			});
			GameObject val8 = CreateRow(_contentContainer);
			CreateActionButton(val8.transform, "Add Waypoint (Player)", delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				PlayerController val10 = EmpressGame.LocalPlayerController();
				if (Object.op_Implicit((Object)(object)val10))
				{
					EmpressWaypointsOverlay.Ensure().AddWaypoint(((Component)val10).transform.position, "Player");
				}
			});
			CreateActionButton(val8.transform, "Mark Truck", delegate
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				bool ok;
				Vector3 pos = EmpressGame.TruckWorldPos(out ok);
				if (ok)
				{
					EmpressWaypointsOverlay.Ensure().AddWaypoint(pos, "Truck");
				}
			});
			GameObject val9 = CreateRow(_contentContainer);
			CreateActionButton(val9.transform, "Clear Waypoints", delegate
			{
				EmpressWaypointsOverlay.Ensure().ClearWaypoints();
			});
			((TMP_Text)_countText).text = "Level gizmos & waypoints";
		}

		private void RenderPlayerTab()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = "Local player debug";
			}
			TextMeshProUGUI val = CreateTMP(_contentContainer, "<b>PLAYER</b>", 16f, _fg, (TextAlignmentOptions)4097);
			((Component)val).gameObject.AddComponent<LayoutElement>().minHeight = 32f;
			PlayerController val2 = EmpressGame.LocalPlayerController();
			GameObject val3 = CreateRow(_contentContainer);
			Button val4 = CreateToggleButton(val3.transform, Object.op_Implicit((Object)(object)val2) && val2.DebugEnergy, "Debug Energy", delegate(bool state)
			{
				PlayerController val13 = EmpressGame.LocalPlayerController();
				if (Object.op_Implicit((Object)(object)val13))
				{
					val13.DebugEnergy = state;
				}
			});
			Button val5 = CreateToggleButton(val3.transform, Object.op_Implicit((Object)(object)val2) && val2.DebugNoTumble, "No Tumble", delegate(bool state)
			{
				PlayerController val12 = EmpressGame.LocalPlayerController();
				if (Object.op_Implicit((Object)(object)val12))
				{
					val12.DebugNoTumble = state;
				}
			});
			GameObject val6 = CreateRow(_contentContainer);
			CreateActionButton(val6.transform, "Refill Energy", delegate
			{
				PlayerController val11 = EmpressGame.LocalPlayerController();
				if (Object.op_Implicit((Object)(object)val11))
				{
					val11.EnergyCurrent = val11.EnergyStart;
				}
			});
			GameObject val7 = CreateRow(_contentContainer);
			CreateActionButton(val7.transform, "Teleport to Truck", TeleportToTruckSafe);
			GameObject val8 = CreateRow(_contentContainer);
			string text = (EmpressPlayerOverlay.ExistsAndActive ? "Hide HUD ℹ" : "Show HUD ℹ");
			Button hudBtn = CreateActionButton(val8.transform, text, delegate
			{
			});
			((UnityEventBase)hudBtn.onClick).RemoveAllListeners();
			((UnityEvent)hudBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressPlayerOverlay empressPlayerOverlay = EmpressPlayerOverlay.Ensure();
				empressPlayerOverlay.Toggle();
				TextMeshProUGUI componentInChildren = ((Component)hudBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((TMP_Text)componentInChildren).text = (empressPlayerOverlay.Active ? "Hide HUD ℹ" : "Show HUD ℹ");
				}
			});
			GameObject val9 = CreateRow(_contentContainer);
			(float min, float max, float current) fovRangeAndCurrent = GetFovRangeAndCurrent();
			float item = fovRangeAndCurrent.min;
			float item2 = fovRangeAndCurrent.max;
			float item3 = fovRangeAndCurrent.current;
			Slider val10 = CreateSlider(val9.transform, item, item2, item3, "FOV", delegate(float v)
			{
				AdjustFOVAbsolute(v);
			}, (float v) => v.ToString("F0"));
			((TMP_Text)_countText).text = (Object.op_Implicit((Object)(object)val2) ? $"Energy {Mathf.RoundToInt(val2.EnergyCurrent)}/{Mathf.RoundToInt(val2.EnergyStart)}" : "No local player");
		}

		private void RenderNetworkTab()
		{
			//IL_0033: 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)
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = "Photon";
			}
			TextMeshProUGUI val = CreateTMP(_contentContainer, "<b>NETWORK</b>", 16f, _fg, (TextAlignmentOptions)4097);
			((Component)val).gameObject.AddComponent<LayoutElement>().minHeight = 32f;
			TextMeshProUGUI val2 = CreateTMP(_contentContainer, NetworkInfoString(), 14f, _fg, (TextAlignmentOptions)4097);
			GameObject val3 = CreateRow(_contentContainer);
			CreateActionButton(val3.transform, "Refresh", delegate
			{
				RenderCurrentTab();
			});
			((TMP_Text)_countText).text = "Room info";
		}

		private void RenderPerfTab()
		{
			//IL_003b: 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_00e1: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_statusText))
			{
				((TMP_Text)_statusText).text = "Performance";
			}
			TextMeshProUGUI val = CreateTMP(_contentContainer, "<b>PERF</b>", 16f, _fg, (TextAlignmentOptions)4097);
			((Component)val).gameObject.AddComponent<LayoutElement>().minHeight = 32f;
			GameObject val2 = CreateRow(_contentContainer);
			string text = (EmpressFPSOverlay.ExistsAndActive ? "Hide FPS ⏱" : "Show FPS ⏱");
			Button fpsBtn = CreateActionButton(val2.transform, text, delegate
			{
			});
			((UnityEventBase)fpsBtn.onClick).RemoveAllListeners();
			((UnityEvent)fpsBtn.onClick).AddListener((UnityAction)delegate
			{
				EmpressFPSOverlay empressFPSOverlay = EmpressFPSOverlay.Ensure();
				empressFPSOverlay.Toggle();
				TextMeshProUGUI componentInChildren = ((Component)fpsBtn).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((TMP_Text)componentInChildren).text = (empressFPSOverlay.Active ? "Hide FPS ⏱" : "Show FPS ⏱");
				}
			});
			GameObject val3 = CreateRow(_contentContainer);
			int num = ((Application.targetFrameRate > 0) ? Application.targetFrameRate : 0);
			Slider val4 = CreateSlider(val3.transform, 0f, 240f, num, "Target FPS", delegate(float v)
			{
				Application.targetFrameRate = ((v <= 0.5f) ? (-1) : Mathf.RoundToInt(v));
			}, (float v) => (v <= 0.5f) ? "Unlimited" : Mathf.RoundToInt(v).ToString());
			val4.wholeNumbers = true;
			GameObject val5 = CreateRow(_contentContainer);
			CreateToggleButton(val5.transform, Application.runInBackground, "Run In Background", delegate(bool state)
			{
				Application.runInBackground = state;
			});
			((TMP_Text)_countText).text = $"FPS {Mathf.RoundToInt(1f / Mathf.Max(Time.deltaTime, 0.0001f))}";
		}

		private void TryAdvanceLevel()
		{
			RunManager instance = RunManager.instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				instance.ChangeLevel(true, false, (ChangeLevelType)0);
			}
		}

		private string NetworkInfoString()
		{
			bool inRoom = PhotonNetwork.InRoom;
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			int num = (inRoom ? PhotonNetwork.CurrentRoom.PlayerCount : 0);
			int num2 = (inRoom ? PhotonNetwork.CurrentRoom.MaxPlayers : 0);
			string text = (inRoom ? PhotonNetwork.CurrentRoom.Name : "None");
			int ping = PhotonNetwork.GetPing();
			return $"InRoom: {inRoom}\r\nMaster: {isMasterClient}\r\nPlayers: {num}/{num2}\r\nRoom: {text}\r\nPing: {ping} ms";
		}

		private (float min, float max, float current) GetFovRangeAndCurrent()
		{
			CameraZoom instance = CameraZoom.Instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				float item = ((instance.cams != null && instance.cams.Count > 0) ? instance.cams[0].fieldOfView : instance.playerZoomDefault);
				return (instance.MinimumZoom, instance.MaximumZoom, item);
			}
			if (Object.op_Implicit((Object)(object)Camera.main))
			{
				return (5f, 170f, Camera.main.fieldOfView);
			}
			return (5f, 170f, 60f);
		}

		private void AdjustFOVAbsolute(float target)
		{
			CameraZoom instance = CameraZoom.Instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				target = Mathf.Clamp(target, instance.MinimumZoom, instance.MaximumZoom);
				instance.OverrideZoomSet(target, 0f, 0f, 0f, ((Component)this).gameObject, 999);
			}
			else if (Object.op_Implicit((Object)(object)Camera.main))
			{
				Camera.main.fieldOfView = Mathf.Clamp(target, 5f, 170f);
			}
		}

		private void TeleportToTruckSafe()
		{
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			PlayerController val = EmpressGame.LocalPlayerController();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			bool ok;
			Vector3 val2 = EmpressGame.TruckWorldPos(out ok);
			if (ok)
			{
				Vector3 val3 = val2 + Vector3.up * 0.2f;
				NavMeshHit val4 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val3, ref val4, 3f, -1))
				{
					val3 = ((NavMeshHit)(ref val4)).position + Vector3.up * 0.1f;
				}
				CharacterController component = ((Component)val).GetComponent<CharacterController>();
				if (Object.op_Implicit((Object)(object)component) && ((Collider)component).enabled)
				{
					((Collider)component).enabled = false;
					((Component)val).transform.position = val3;
					val.Velocity = Vector3.zero;
					((Collider)component).enabled = true;
				}
				else
				{
					((Component)val).transform.position = val3;
					val.Velocity = Vector3.zero;
				}
			}
		}

		private GameObject CreateUIElement(string name, Transform parent)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			return val;
		}

		private GameObject CreateButton(string name, Transform parent, string text)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIElement(name, parent);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = _bg2;
			Button val3 = val.AddComponent<Button>();
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			TextMeshProUGUI val4 = CreateTMP("Text", val.transform, text, 13f, _fg, (TextAlignmentOptions)514);
			RectTransform component = ((Component)val4).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			return val;
		}

		private TextMeshProUGUI CreateTMP(string name, Transform parent, string text, float size, Color color, TextAlignmentOptions align)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIElement(name, parent);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = size;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			return val2;
		}

		private TextMeshProUGUI CreateTMP(Transform parent, string text, float size, Color color, TextAlignmentOptions align)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return CreateTMP("Text", parent, text, size, color, align);
		}

		private GameObject CreateRow(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Row");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(0f, 40f);
			HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 8f;
			return val;
		}

		private Button CreateActionButton(Transform parent, string text, Action onClick)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_010b: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			Action onClick2 = onClick;
			GameObject val = new GameObject("Btn");
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = _accentBase;
			Button val3 = val.AddComponent<Button>();
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			((Selectable)val3).transition = (Transition)1;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = _accentHover;
			((ColorBlock)(ref colors)).pressedColor = new Color(0f, 0.6f, 0.2f, 1f);
			((ColorBlock)(ref colors)).selectedColor = _accentBase;
			((ColorBlock)(ref colors)).disabledColor = _accentDisabled;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)val3).colors = colors;
			LayoutElement val4 = val.AddComponent<LayoutElement>();
			val4.preferredHeight = 28f;
			TextMeshProUGUI val5 = CreateTMP(val.transform, text, 13f, new Color(0.05f, 0.08f, 0.05f, 1f), (TextAlignmentOptions)514);
			RectTransform component = ((Component)val5).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
			{
				onClick2();
			});
			return val3;
		}

		private Button CreateToggleButton(Transform parent, bool initial, string label, Action<bool> onChange)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			string label2 = label;
			Action<bool> onChange2 = onChange;
			GameObject val = new GameObject("ToggleBtn");
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = (initial ? _accentBase : _bg2);
			Button btn = val.AddComponent<Button>();
			((Selectable)btn).transition = (Transition)1;
			Button obj = btn;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((ColorBlock)(ref colors)).highlightedColor = _accentHover;
			((ColorBlock)(ref colors)).pressedColor = new Color(0f, 0.6f, 0.2f, 1f);
			((ColorBlock)(ref colors)).selectedColor = _accentBase;
			((ColorBlock)(ref colors)).disabledColor = _accentDisabled;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((Selectable)obj).colors = colors;
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			val3.preferredHeight = 28f;
			Color color = (Color)(initial ? new Color(0.05f, 0.08f, 0.05f, 1f) : Color.white);
			TextMeshProUGUI tmp = CreateTMP(val.transform, initial ? (label2 + " ✔") : (label2 + " ✖"), 13f, color, (TextAlignmentOptions)514);
			RectTransform component = ((Component)tmp).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			bool state = initial;
			((UnityEvent)btn.onClick).AddListener((UnityAction)delegate
			{
				//IL_00ac: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				state = !state;
				((TMP_Text)tmp).text = (state ? (label2 + " ✔") : (label2 + " ✖"));
				Image component2 = ((Component)btn).GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					((Graphic)component2).color = (state ? _accentBase : _bg2);
				}
				((Graphic)tmp).color = (Color)(state ? new Color(0.05f, 0.08f, 0.05f, 1f) : Color.white);
				onChange2(state);
			});
			return btn;
		}

		private Slider CreateSlider(Transform parent, float min, float max, float value, string labelPrefix, Action<float> onChange, Func<float, string> formatter)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			string labelPrefix2 = labelPrefix;
			Func<float, string> formatter2 = formatter;
			Action<float> onChange2 = onChange;
			GameObject val = new GameObject("SliderRoot");
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.flexibleWidth = 1f;
			val2.preferredHeight = 32f;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = _bg2;
			GameObject val4 = CreateUIElement("Slider", val.transform);
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.02f, 0.2f);
			component.anchorMax = new Vector2(0.98f, 0.8f);
			component.sizeDelta = Vector2.zero;
			Slider val5 = val4.AddComponent<Slider>();
			val5.minValue = min;
			val5.maxValue = max;
			val5.value = Mathf.Clamp(value, min, max);
			GameObject val6 = CreateUIElement("Background", val4.transform);
			RectTransform component2 = val6.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0.25f);
			component2.anchorMax = new Vector2(1f, 0.75f);
			component2.sizeDelta = Vector2.zero;
			Image val7 = val6.AddComponent<Image>();
			((Graphic)val7).color = new Color(0.12f, 0.12f, 0.12f, 1f);
			GameObject val8 = CreateUIElement("Fill Area", val4.transform);
			RectTransform component3 = val8.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.offsetMin = new Vector2(10f, 0f);
			component3.offsetMax = new Vector2(-10f, 0f);
			GameObject val9 = CreateUIElement("Fill", val8.transform);
			RectTransform component4 = val9.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0.25f);
			component4.anchorMax = new Vector2(1f, 0.75f);
			component4.sizeDelta = Vector2.zero;
			Image val10 = val9.AddComponent<Image>();
			((Graphic)val10).color = _accentBase;
			GameObject val11 = CreateUIElement("Handle Slide Area", val4.transform);
			RectTransform component5 = val11.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0f, 0f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.sizeDelta = Vector2.zero;
			GameObject val12 = CreateUIElement("Handle", val11.transform);
			RectTransform component6 = val12.GetComponent<RectTransform>();
			component6.sizeDelta = new Vector2(16f, 24f);
			Image val13 = val12.AddComponent<Image>();
			((Graphic)val13).color = _accentHover;
			val5.fillRect = component4;
			((Selectable)val5).targetGraphic = (Graphic)(object)val13;
			val5.handleRect = component6;
			val5.direction = (Direction)0;
			TextMeshProUGUI label = CreateTMP(val.transform, labelPrefix2 + ": " + formatter2(val5.value), 12f, new Color(0.05f, 0.08f, 0.05f, 1f), (TextAlignmentOptions)514);
			((Graphic)label).raycastTarget = false;
			RectTransform component7 = ((Component)label).GetComponent<RectTransform>();
			component7.anchorMin = new Vector2(0f, 0f);
			component7.anchorMax = new Vector2(1f, 1f);
			component7.sizeDelta = Vector2.zero;
			((UnityEvent<float>)(object)val5.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
			{
				((TMP_Text)label).text = labelPrefix2 + ": " + formatter2(v);
				onChange2(v);
			});
			return val5;
		}
	}
	public sealed class EmpressWaypointsOverlay : MonoBehaviour
	{
		private static EmpressWaypointsOverlay _instance;

		private GameObject _root;

		private readonly List<GameObject> _wps = new List<GameObject>();

		private static Material _cached;

		public bool Active => Object.op_Implicit((Object)(object)_root) && _root.activeSelf;

		public static bool ExistsAndActive => Object.op_Implicit((Object)(object)_instance) && _instance.Active;

		public static EmpressWaypointsOverlay Ensure()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance;
			}
			GameObject val = new GameObject("Empress_Waypoints_ROOT");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			_instance = val.AddComponent<EmpressWaypointsOverlay>();
			_instance._root = val;
			_instance._root.SetActive(true);
			return _instance;
		}

		public static void DestroyIfExists()
		{
			if (Object.op_Implicit((Object)(object)_instance) && Object.op_Implicit((Object)(object)_instance._root))
			{
				try
				{
					Object.Destroy((Object)(object)_instance._root);
				}
				catch
				{
				}
			}
			_instance = null;
		}

		public void Toggle()
		{
			if (!Active)
			{
				_root.SetActive(true);
			}
			else
			{
				_root.SetActive(false);
			}
		}

		public void ClearWaypoints()
		{
			foreach (GameObject wp in _wps)
			{
				if (Object.op_Implicit((Object)(object)wp))
				{
					Object.Destroy((Object)(object)wp);
				}
			}
			_wps.Clear();
		}

		public void AddWaypoint(Vector3 pos, string label)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_015e: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WP:" + label);
			val.transform.SetParent(_root.transform, false);
			val.transform.position = pos;
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val2).name = "Marker";
			val2.transform.SetParent(val.transform, false);
			val2.transform.localScale = new Vector3(0.2f, 0.5f, 0.2f);
			val2.transform.position = pos + Vector3.up * 0.5f;
			Collider component = val2.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = val2.GetComponent<Renderer>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.shadowCastingMode = (ShadowCastingMode)0;
				component2.receiveShadows = false;
				component2.material = GetMat(new Color(0.1f, 1f, 0.4f, 0.85f));
			}
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)val3).name = "Flag";
			val3.transform.SetParent(val.transform, false);
			val3.transform.localScale = new Vector3(0.35f, 0.2f, 1f);
			val3.transform.position = pos + Vector3.up * 1.1f;
			Transform transform = val3.transform;
			Vector3 val4;
			if (!Object.op_Implicit((Object)(object)Camera.main))
			{
				val4 = Vector3.forward;
			}
			else
			{
				Vector3 val5 = ((Component)Camera.main).transform.position - val3.transform.position;
				val4 = ((Vector3)(ref val5)).normalized;
			}
			transform.rotation = Quaternion.LookRotation(val4) * Quaternion.Euler(0f, 180f, 0f);
			Collider component3 = val3.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				Object.Destroy((Object)(object)component3);
			}
			Renderer component4 = val3.GetComponent<Renderer>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				component4.shadowCastingMode = (ShadowCastingMode)0;
				component4.receiveShadows = false;
				component4.material = GetMat(new Color(0.3f, 1f, 0.6f, 0.85f));
			}
			_wps.Add(val);
		}

		private static Material GetMat(Color c)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			if ((Object)(object)_cached == (Object)null)
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
				}
				_cached = new Material(val)
				{
					hideFlags = (HideFlags)61
				};
			}
			_cached.color = c;
			return _cached;
		}
	}
}