Decompiled source of Vitals v1.0.2

Mods/Vitals.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppTMPro;
using LabFusion.Entities;
using LabFusion.Network;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Vitals;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Vitals", "1.0.0", "HP / weight / speed HUD, face cams, inner voice", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Vitals")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Vitals")]
[assembly: AssemblyTitle("Vitals")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Vitals
{
	internal static class K
	{
		public static Instance Log;

		public static string ModName = "Mod";

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

		public static string Dir => Path.Combine(MelonEnvironment.UserDataDirectory, ModName);

		public static Transform Head => Player.Head;

		public static void Warn(string key, string msg)
		{
			float unscaledTime = Time.unscaledTime;
			if (!_warned.TryGetValue(key, out var value) || !(unscaledTime - value < 20f))
			{
				_warned[key] = unscaledTime;
				if (Log != null)
				{
					Log.Warning(key + ": " + msg);
				}
			}
		}

		public static float Rand(float a, float b)
		{
			return Random.Range(a, b);
		}

		public static int RandInt(int a, int bExclusive)
		{
			return Random.Range(a, bExclusive);
		}

		public static T Pick<T>(IList<T> list)
		{
			if (list.Count != 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			return default(T);
		}

		public static Color Hsv(float h, float s, float v)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return Color.HSVToRGB(Mathf.Repeat(h, 1f), s, v);
		}

		public static Color WithA(Color c, float a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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)
			return new Color(c.r, c.g, c.b, a);
		}

		public static Quaternion Face(Vector3 eye, Vector3 pos, float roll)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//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_0037: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pos - eye;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.forward;
			}
			return Quaternion.LookRotation(val, Vector3.up) * Quaternion.Euler(0f, 0f, roll);
		}

		public static void Axes(Vector3 eye, Vector3 center, out Vector3 right, out Vector3 up)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 val = center - eye;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.forward;
			}
			((Vector3)(ref val)).Normalize();
			right = Vector3.Cross(Vector3.up, val);
			if (((Vector3)(ref right)).sqrMagnitude < 0.0001f)
			{
				right = Vector3.right;
			}
			((Vector3)(ref right)).Normalize();
			up = Vector3.Cross(val, right);
		}

		public static string OpenFolderHint()
		{
			return Dir;
		}

		public static void OpenFolder()
		{
			try
			{
				Directory.CreateDirectory(Dir);
				Process.Start(new ProcessStartInfo
				{
					FileName = Dir,
					UseShellExecute = true
				});
			}
			catch (Exception ex)
			{
				Log.Msg("Could not open the folder (" + ex.Message + "). It is here: " + Dir);
			}
		}

		public static Dictionary<string, List<string>> ReadSections(string path, string firstSection)
		{
			Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
			string key = firstSection;
			dictionary[key] = new List<string>();
			string[] array = File.ReadAllLines(path);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0 || text[0] == '#')
				{
					continue;
				}
				if (text[0] == '[' && text[text.Length - 1] == ']')
				{
					key = text.Substring(1, text.Length - 2).Trim().ToLowerInvariant();
					if (!dictionary.ContainsKey(key))
					{
						dictionary[key] = new List<string>();
					}
				}
				else
				{
					dictionary[key].Add(text);
				}
			}
			return dictionary;
		}

		public static void WriteIfMissing(string path, string content)
		{
			try
			{
				Directory.CreateDirectory(Path.GetDirectoryName(path));
				if (!File.Exists(path))
				{
					File.WriteAllText(path, content);
				}
			}
			catch (Exception ex)
			{
				Warn("write " + path, ex.Message);
			}
		}
	}
	internal static class R
	{
		private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly Dictionary<string, MemberInfo> _cache = new Dictionary<string, MemberInfo>();

		private static MemberInfo Find(Type t, string name)
		{
			string key = t.FullName + "." + name;
			if (_cache.TryGetValue(key, out var value))
			{
				return value;
			}
			value = (MemberInfo)(((object)t.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) ?? ((object)t.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)));
			_cache[key] = value;
			return value;
		}

		public static object Get(object o, string name)
		{
			if (o == null)
			{
				return null;
			}
			try
			{
				MemberInfo memberInfo = Find(o.GetType(), name);
				PropertyInfo propertyInfo = memberInfo as PropertyInfo;
				if (propertyInfo != null)
				{
					return propertyInfo.GetValue(o);
				}
				FieldInfo fieldInfo = memberInfo as FieldInfo;
				return (fieldInfo != null) ? fieldInfo.GetValue(o) : null;
			}
			catch (Exception)
			{
				return null;
			}
		}

		public static bool Set(object o, string name, object value)
		{
			if (o == null)
			{
				return false;
			}
			try
			{
				MemberInfo memberInfo = Find(o.GetType(), name);
				PropertyInfo propertyInfo = memberInfo as PropertyInfo;
				if (propertyInfo != null && propertyInfo.CanWrite)
				{
					propertyInfo.SetValue(o, Convert.ChangeType(value, propertyInfo.PropertyType, CultureInfo.InvariantCulture));
					return true;
				}
				FieldInfo fieldInfo = memberInfo as FieldInfo;
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(o, Convert.ChangeType(value, fieldInfo.FieldType, CultureInfo.InvariantCulture));
					return true;
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		public static object Call(object o, string name, params object[] args)
		{
			if (o == null)
			{
				return null;
			}
			try
			{
				MethodInfo[] methods = o.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.Name == name && methodInfo.GetParameters().Length == args.Length)
					{
						return methodInfo.Invoke(o, args);
					}
				}
			}
			catch (Exception)
			{
			}
			return null;
		}

		public static float Float(object o, string name, float fallback)
		{
			object obj = Get(o, name);
			if (obj is float)
			{
				return (float)obj;
			}
			if (obj is double)
			{
				return (float)(double)obj;
			}
			if (obj is int)
			{
				return (int)obj;
			}
			return fallback;
		}
	}
	internal static class Vit
	{
		private static object Health()
		{
			RigManager rigManager = Player.RigManager;
			if (!((Object)(object)rigManager == (Object)null))
			{
				return R.Get(rigManager, "health");
			}
			return null;
		}

		public static float Cur()
		{
			object obj = Health();
			if (obj != null)
			{
				return R.Float(obj, "curr_Health", -1f);
			}
			return -1f;
		}

		public static float Max()
		{
			object obj = Health();
			float num = ((obj == null) ? 100f : R.Float(obj, "max_Health", 100f));
			if (!(num <= 0.01f))
			{
				return num;
			}
			return 100f;
		}

		public static void SetCur(float v)
		{
			object obj = Health();
			if (obj != null)
			{
				R.Set(obj, "curr_Health", v);
			}
		}

		public static void SetMax(float v)
		{
			object obj = Health();
			if (obj != null)
			{
				R.Set(obj, "max_Health", v);
			}
		}

		public static float Frac()
		{
			float num = Cur();
			if (!(num < 0f))
			{
				return Mathf.Clamp01(num / Max());
			}
			return 1f;
		}
	}
	internal static class Watch
	{
		private static float _prev = -1f;

		private static float _levelAt;

		private static string _scene = "";

		private static int _lastFrame = -1;

		public static bool IsDead { get; private set; }

		public static int Lives { get; private set; }

		public static float LifeStart { get; private set; }

		public static float SinceLevel { get; private set; }

		public static event Action<float> Damaged;

		public static event Action Died;

		public static event Action Respawned;

		public static event Action LevelChanged;

		public static void Update(float now)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (_lastFrame == Time.frameCount)
			{
				return;
			}
			_lastFrame = Time.frameCount;
			float num = Vit.Cur();
			if (num >= 0f)
			{
				if (_prev >= 0f && num < _prev - 0.001f && Watch.Damaged != null)
				{
					Watch.Damaged(_prev - num);
				}
				if (!IsDead && num <= 0.0001f && _prev > 0.0001f)
				{
					IsDead = true;
					if (Watch.Died != null)
					{
						Watch.Died();
					}
				}
				else if (IsDead && num > 0.01f)
				{
					IsDead = false;
					Lives++;
					LifeStart = now;
					if (Watch.Respawned != null)
					{
						Watch.Respawned();
					}
				}
				_prev = num;
			}
			string text = "";
			try
			{
				Scene activeScene = SceneManager.GetActiveScene();
				text = ((Scene)(ref activeScene)).name;
			}
			catch (Exception)
			{
			}
			if (text != _scene)
			{
				bool num2 = _scene.Length == 0;
				_scene = text;
				_levelAt = now;
				if (!num2 && Watch.LevelChanged != null)
				{
					Watch.LevelChanged();
				}
			}
			SinceLevel = now - _levelAt;
		}
	}
	internal static class A
	{
		private static readonly Dictionary<string, Texture2D> _cache = new Dictionary<string, Texture2D>();

		private static Texture2D _white;

		public static Texture2D White
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_white == (Object)null)
				{
					_white = new Texture2D(2, 2, (TextureFormat)4, false);
					for (int i = 0; i < 2; i++)
					{
						for (int j = 0; j < 2; j++)
						{
							_white.SetPixel(i, j, Color.white);
						}
					}
					_white.Apply(false);
				}
				return _white;
			}
		}

		private static byte[] Bytes(string file)
		{
			try
			{
				string path = Path.Combine(K.Dir, "Images", file);
				if (File.Exists(path))
				{
					return File.ReadAllBytes(path);
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				foreach (string text in manifestResourceNames)
				{
					if (!text.EndsWith("." + file, StringComparison.OrdinalIgnoreCase) && !string.Equals(text, file, StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					return memoryStream.ToArray();
				}
			}
			catch (Exception ex)
			{
				K.Warn("art " + file, ex.Message);
			}
			return null;
		}

		public static Texture2D Tex(string name, bool repeat = false)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if (_cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			byte[] array = Bytes(name + ".png");
			if (array == null)
			{
				_cache[name] = null;
				return null;
			}
			value = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(value, new Il2CppStructArray<byte>(array)))
			{
				_cache[name] = null;
				return null;
			}
			((Texture)value).filterMode = (FilterMode)1;
			((Texture)value).wrapMode = (TextureWrapMode)(!repeat);
			_cache[name] = value;
			return value;
		}

		public static string Text(string file, bool writeOut = true)
		{
			try
			{
				string path = Path.Combine(K.Dir, file);
				if (File.Exists(path))
				{
					return File.ReadAllText(path);
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				foreach (string text in manifestResourceNames)
				{
					if (!text.EndsWith("." + file, StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					using StreamReader streamReader = new StreamReader(stream);
					string text2 = streamReader.ReadToEnd();
					if (writeOut)
					{
						K.WriteIfMissing(path, text2);
					}
					return text2;
				}
			}
			catch (Exception ex)
			{
				K.Warn("text " + file, ex.Message);
			}
			return "";
		}

		public static string TextPath(string file)
		{
			Text(file);
			return Path.Combine(K.Dir, file);
		}

		public static Texture2D FromFile(string path)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			try
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, new Il2CppStructArray<byte>(File.ReadAllBytes(path))))
				{
					return null;
				}
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				return val;
			}
			catch (Exception ex)
			{
				K.Warn("png " + path, ex.Message);
				return null;
			}
		}

		public static List<Texture2D> Folder(string sub)
		{
			List<Texture2D> list = new List<Texture2D>();
			try
			{
				string path = Path.Combine(K.Dir, sub);
				Directory.CreateDirectory(path);
				string[] files = Directory.GetFiles(path, "*.png");
				for (int i = 0; i < files.Length; i++)
				{
					Texture2D val = FromFile(files[i]);
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
				}
			}
			catch (Exception ex)
			{
				K.Warn("folder " + sub, ex.Message);
			}
			return list;
		}

		public static Texture2D PixelTex(string name, bool repeat = false)
		{
			Texture2D val = Tex(name, repeat);
			if ((Object)(object)val != (Object)null)
			{
				((Texture)val).filterMode = (FilterMode)0;
			}
			return val;
		}
	}
	internal sealed class ImgPool
	{
		private readonly bool _local;

		private readonly bool _through;

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

		private readonly List<MeshRenderer> _r = new List<MeshRenderer>();

		private readonly List<MeshFilter> _f = new List<MeshFilter>();

		private readonly List<int> _mesh = new List<int>();

		private int _u;

		private int _pu;

		public ImgPool(bool local, bool through)
		{
			_local = local;
			_through = through;
		}

		public void Begin()
		{
			_u = 0;
		}

		public void End()
		{
			for (int i = _u; i < _pu && i < _g.Count; i++)
			{
				if ((Object)(object)_g[i] != (Object)null)
				{
					_g[i].SetActive(false);
				}
			}
			_pu = _u;
		}

		public void Hide()
		{
			_u = 0;
			End();
		}

		public void Draw(Texture tex, Vector3 pos, Quaternion rot, float w, float h, Color c, int tx = 1, int ty = 1, int order = 0)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tex == (Object)null)
			{
				tex = (Texture)(object)A.White;
			}
			Material val = Gfx.Mat(_through);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			int num = _u++;
			if (num >= _g.Count || (Object)(object)_g[num] == (Object)null || (Object)(object)_r[num] == (Object)null || (Object)(object)_f[num] == (Object)null)
			{
				GameObject val2 = new GameObject("kit_img");
				((Object)val2).hideFlags = (HideFlags)61;
				val2.transform.SetParent(_local ? Gfx.HudRoot : Gfx.WorldRoot, false);
				MeshFilter val3 = val2.AddComponent<MeshFilter>();
				MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
				((Renderer)val4).sharedMaterial = val;
				((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val4).receiveShadows = false;
				if (num < _g.Count)
				{
					_g[num] = val2;
					_f[num] = val3;
					_r[num] = val4;
					_mesh[num] = -1;
				}
				else
				{
					_g.Add(val2);
					_f.Add(val3);
					_r.Add(val4);
					_mesh.Add(-1);
				}
			}
			int num2 = tx * 1000 + ty;
			if (_mesh[num] != num2)
			{
				_f[num].sharedMesh = Gfx.Quad(tx, ty);
				_mesh[num] = num2;
			}
			Transform transform = _g[num].transform;
			if (_local)
			{
				transform.localPosition = pos;
				transform.localRotation = rot;
			}
			else
			{
				transform.SetPositionAndRotation(pos, rot);
			}
			transform.localScale = new Vector3(w, h, 1f);
			Gfx.Mpb.SetTexture("_MainTex", tex);
			Gfx.Mpb.SetColor("_Color", c);
			Gfx.Mpb.SetColor("_RendererColor", c);
			((Renderer)_r[num]).SetPropertyBlock(Gfx.Mpb);
			((Renderer)_r[num]).sortingOrder = order;
			if (!_g[num].activeSelf)
			{
				_g[num].SetActive(true);
			}
		}
	}
	internal sealed class TextPool
	{
		private sealed class Slot
		{
			public GameObject G;

			public TextMeshPro T;

			public string Last;

			public float Spacing = 999f;

			public int Ver = -1;

			public Material Mat;
		}

		private readonly bool _local;

		private readonly bool _through;

		private readonly List<Slot> _s = new List<Slot>();

		private int _u;

		private int _pu;

		public TextPool(bool local, bool through)
		{
			_local = local;
			_through = through;
		}

		public void Begin()
		{
			_u = 0;
		}

		public void End()
		{
			for (int i = _u; i < _pu && i < _s.Count; i++)
			{
				if ((Object)(object)_s[i].G != (Object)null)
				{
					_s[i].G.SetActive(false);
				}
			}
			_pu = _u;
		}

		public void Hide()
		{
			_u = 0;
			End();
		}

		public void ApplyDepth()
		{
			foreach (Slot item in _s)
			{
				Depth(item);
			}
		}

		private void Depth(Slot s)
		{
			try
			{
				if (!((Object)(object)s.Mat == (Object)null))
				{
					int num = (_through ? 8 : 4);
					if (s.Mat.HasProperty("_ZTestMode"))
					{
						s.Mat.SetInt("_ZTestMode", num);
					}
					s.Mat.renderQueue = (_through ? 4000 : 3500);
				}
			}
			catch (Exception)
			{
			}
		}

		public void Draw(string text, Vector3 pos, Quaternion rot, float height, Color c, float spacing = 0f, FontStyles style = (FontStyles)1, string font = null, bool left = false, int order = 0)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			int num = _u++;
			if (num >= _s.Count || _s[num] == null || (Object)(object)_s[num].G == (Object)null || (Object)(object)_s[num].T == (Object)null)
			{
				GameObject val = new GameObject("kit_text");
				((Object)val).hideFlags = (HideFlags)61;
				val.transform.SetParent(_local ? Gfx.HudRoot : Gfx.WorldRoot, false);
				TextMeshPro val2 = val.AddComponent<TextMeshPro>();
				((TMP_Text)val2).enableWordWrapping = false;
				((TMP_Text)val2).richText = true;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val2).fontSize = 1f;
				((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(40f, 4f);
				Slot slot = new Slot
				{
					G = val,
					T = val2
				};
				try
				{
					slot.Mat = ((TMP_Text)val2).fontMaterial;
				}
				catch (Exception)
				{
				}
				Depth(slot);
				if (num < _s.Count)
				{
					_s[num] = slot;
				}
				else
				{
					_s.Add(slot);
				}
			}
			Slot slot2 = _s[num];
			TMP_FontAsset val3 = Gfx.Font(font);
			int num2 = Gfx.FontVersion(font);
			if ((Object)(object)val3 != (Object)null && slot2.Ver != num2)
			{
				((TMP_Text)slot2.T).font = val3;
				slot2.Ver = num2;
			}
			if (slot2.Last != text)
			{
				((TMP_Text)slot2.T).text = text;
				slot2.Last = text;
			}
			if (Mathf.Abs(slot2.Spacing - spacing) > 0.01f)
			{
				((TMP_Text)slot2.T).characterSpacing = spacing;
				slot2.Spacing = spacing;
			}
			((TMP_Text)slot2.T).fontStyle = style;
			slot2.T.sortingOrder = order;
			((Graphic)slot2.T).color = c;
			((TMP_Text)slot2.T).alignment = (TextAlignmentOptions)(left ? 513 : 514);
			((TMP_Text)slot2.T).rectTransform.pivot = (left ? new Vector2(0f, 0.5f) : new Vector2(0.5f, 0.5f));
			Transform transform = slot2.G.transform;
			if (_local)
			{
				transform.localPosition = pos;
				transform.localRotation = rot;
			}
			else
			{
				transform.SetPositionAndRotation(pos, rot);
			}
			transform.localScale = Vector3.one * (height / Gfx.Unit(val3));
			if (!slot2.G.activeSelf)
			{
				slot2.G.SetActive(true);
			}
		}
	}
	internal static class Gfx
	{
		public static float HudDist = 1f;

		public static readonly MaterialPropertyBlock Mpb = new MaterialPropertyBlock();

		public static readonly ImgPool Hud = new ImgPool(local: true, through: true);

		public static readonly ImgPool World = new ImgPool(local: false, through: false);

		public static readonly ImgPool WorldThru = new ImgPool(local: false, through: true);

		public static readonly TextPool HudTxt = new TextPool(local: true, through: true);

		public static readonly TextPool WorldTxt = new TextPool(local: false, through: false);

		public static readonly TextPool WorldTxtThru = new TextPool(local: false, through: true);

		private static GameObject _hudRoot;

		private static GameObject _worldRoot;

		private static Material _matThru;

		private static Material _matDepth;

		private static Material _lineMat;

		private static bool _matsTried;

		private static readonly Dictionary<int, Mesh> _quads = new Dictionary<int, Mesh>();

		private static readonly List<LineRenderer> _lines = new List<LineRenderer>();

		private static int _lu;

		private static int _plu;

		private static readonly Vector3[] _ring = (Vector3[])(object)new Vector3[40];

		private static readonly Vector3[] _rect = (Vector3[])(object)new Vector3[5];

		private static readonly Dictionary<string, TMP_FontAsset> _fonts = new Dictionary<string, TMP_FontAsset>();

		private static List<TMP_FontAsset> _allFonts;

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

		private static int _fontVer;

		public static Transform HudRoot => Roots()[0];

		public static Transform WorldRoot => Roots()[1];

		private static Transform[] Roots()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_hudRoot == (Object)null)
			{
				_hudRoot = new GameObject("kit_hud");
				((Object)_hudRoot).hideFlags = (HideFlags)61;
			}
			if ((Object)(object)_worldRoot == (Object)null)
			{
				_worldRoot = new GameObject("kit_world");
				((Object)_worldRoot).hideFlags = (HideFlags)61;
			}
			Transform val = null;
			try
			{
				val = Player.Head;
			}
			catch (Exception)
			{
			}
			if ((Object)(object)val != (Object)null && (Object)(object)_hudRoot.transform.parent != (Object)(object)val)
			{
				_hudRoot.transform.SetParent(val, false);
				_hudRoot.transform.localPosition = Vector3.zero;
				_hudRoot.transform.localRotation = Quaternion.identity;
			}
			return (Transform[])(object)new Transform[2] { _hudRoot.transform, _worldRoot.transform };
		}

		public static void Begin()
		{
			Roots();
			Hud.Begin();
			World.Begin();
			WorldThru.Begin();
			HudTxt.Begin();
			WorldTxt.Begin();
			WorldTxtThru.Begin();
			_lu = 0;
		}

		public static void End()
		{
			Hud.End();
			World.End();
			WorldThru.End();
			HudTxt.End();
			WorldTxt.End();
			WorldTxtThru.End();
			for (int i = _lu; i < _plu && i < _lines.Count; i++)
			{
				if ((Object)(object)_lines[i] != (Object)null)
				{
					((Renderer)_lines[i]).enabled = false;
				}
			}
			_plu = _lu;
		}

		public static void HideAll()
		{
			Hud.Hide();
			World.Hide();
			WorldThru.Hide();
			HudTxt.Hide();
			WorldTxt.Hide();
			WorldTxtThru.Hide();
			for (int i = 0; i < _lines.Count; i++)
			{
				if ((Object)(object)_lines[i] != (Object)null)
				{
					((Renderer)_lines[i]).enabled = false;
				}
			}
			_lu = 0;
			_plu = 0;
		}

		public static Material Mat(bool through)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			if (!_matsTried)
			{
				_matsTried = true;
				Shader val = Shader.Find("UI/Default");
				if ((Object)(object)val == (Object)null)
				{
					val = Shader.Find("Sprites/Default");
				}
				Shader val2 = Shader.Find("Sprites/Default");
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val;
				}
				if ((Object)(object)val != (Object)null)
				{
					_matThru = new Material(val);
					((Object)_matThru).hideFlags = (HideFlags)61;
					_matThru.renderQueue = 4000;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					_matDepth = new Material(val2);
					((Object)_matDepth).hideFlags = (HideFlags)61;
					_matDepth.renderQueue = 3500;
				}
				if ((Object)(object)val == (Object)null)
				{
					K.Log.Warning("No sprite shader found - images will not draw.");
				}
			}
			if (!through)
			{
				return _matDepth;
			}
			return _matThru;
		}

		public static Mesh Quad(int tx, int ty)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//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_005d: 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_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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			int key = tx * 1000 + ty;
			if (_quads.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new Mesh();
			value.vertices = new Il2CppStructArray<Vector3>((Vector3[])(object)new Vector3[4]
			{
				new Vector3(-0.5f, -0.5f, 0f),
				new Vector3(0.5f, -0.5f, 0f),
				new Vector3(0.5f, 0.5f, 0f),
				new Vector3(-0.5f, 0.5f, 0f)
			});
			value.uv = new Il2CppStructArray<Vector2>((Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2((float)tx, 0f),
				new Vector2((float)tx, (float)ty),
				new Vector2(0f, (float)ty)
			});
			value.colors = new Il2CppStructArray<Color>((Color[])(object)new Color[4]
			{
				Color.white,
				Color.white,
				Color.white,
				Color.white
			});
			value.triangles = new Il2CppStructArray<int>(new int[6] { 0, 2, 1, 0, 3, 2 });
			value.RecalculateBounds();
			_quads[key] = value;
			return value;
		}

		private static void LoadFonts()
		{
			if (_allFonts != null)
			{
				return;
			}
			_allFonts = new List<TMP_FontAsset>();
			try
			{
				Il2CppArrayBase<TMP_FontAsset> val = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				HashSet<string> hashSet = new HashSet<string>();
				for (int i = 0; i < val.Length; i++)
				{
					TMP_FontAsset val2 = val[i];
					if (!((Object)(object)val2 == (Object)null) && hashSet.Add(((Object)val2).name))
					{
						_allFonts.Add(val2);
					}
				}
				_allFonts.Sort((TMP_FontAsset a, TMP_FontAsset b) => string.Compare(((Object)a).name, ((Object)b).name, StringComparison.OrdinalIgnoreCase));
			}
			catch (Exception ex)
			{
				K.Warn("fonts", ex.Message);
			}
		}

		public static List<string> FontNames()
		{
			LoadFonts();
			List<string> list = new List<string>();
			foreach (TMP_FontAsset allFont in _allFonts)
			{
				list.Add(((Object)allFont).name);
			}
			return list;
		}

		public static TMP_FontAsset Font(string name)
		{
			LoadFonts();
			if (_allFonts.Count == 0)
			{
				return null;
			}
			if (!string.IsNullOrEmpty(name))
			{
				foreach (TMP_FontAsset allFont in _allFonts)
				{
					if (((Object)allFont).name == name)
					{
						return allFont;
					}
				}
			}
			return _allFonts[0];
		}

		public static int FontVersion(string name)
		{
			return _fontVer;
		}

		public static void FontChanged()
		{
			_fontVer++;
			_unit.Clear();
		}

		public static float Unit(TMP_FontAsset f)
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			string key = (((Object)(object)f == (Object)null) ? "" : ((Object)f).name);
			if (_unit.TryGetValue(key, out var value))
			{
				return value;
			}
			value = 0.1f;
			try
			{
				GameObject val = new GameObject("kit_probe")
				{
					hideFlags = (HideFlags)61
				};
				TextMeshPro val2 = val.AddComponent<TextMeshPro>();
				if ((Object)(object)f != (Object)null)
				{
					((TMP_Text)val2).font = f;
				}
				((TMP_Text)val2).fontSize = 1f;
				float y = ((TMP_Text)val2).GetPreferredValues("Ag").y;
				if (y > 0.0001f)
				{
					value = y;
				}
				Object.Destroy((Object)val);
			}
			catch (Exception)
			{
			}
			_unit[key] = value;
			return value;
		}

		public static Vector3 HudPos(float az, float el, float dist)
		{
			//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_0012: 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)
			return Quaternion.Euler(0f - el, az, 0f) * Vector3.forward * dist;
		}

		public static void HudImg(Texture tex, float az, float el, float sizeDeg, Color c, float roll = 0f, float aspect = 1f, int order = 0)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = HudPos(az, el, HudDist);
			float num = HudDist * Mathf.Tan(sizeDeg * ((float)Math.PI / 180f));
			Hud.Draw(tex, val, Quaternion.LookRotation(val, Vector3.up) * Quaternion.Euler(0f, 0f, roll), num * aspect, num, c, 1, 1, order);
		}

		public static void HudText(string text, float az, float el, float heightDeg, Color c, float spacing = 0f, string font = null, FontStyles style = (FontStyles)1, float roll = 0f, bool left = false, int order = 0)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = HudPos(az, el, HudDist);
			float height = HudDist * Mathf.Tan(heightDeg * ((float)Math.PI / 180f));
			HudTxt.Draw(text, val, Quaternion.LookRotation(val, Vector3.up) * Quaternion.Euler(0f, 0f, roll), height, c, spacing, style, font, left, order);
		}

		public static void HudFill(Texture2D tex, Color c, int tx = 1, int ty = 1, float scale = 1f)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.35f;
			float num2 = 1.6f * scale;
			Hud.Draw((Texture)(object)tex, new Vector3(0f, 0f, num), Quaternion.identity, num2, num2, c, tx, ty);
		}

		private static LineRenderer NextLine(bool through)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			if ((Object)(object)_lineMat == (Object)null)
			{
				Shader val = Shader.Find("Hidden/Internal-Colored");
				if ((Object)(object)val == (Object)null)
				{
					val = Shader.Find("Sprites/Default");
				}
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				_lineMat = new Material(val);
				((Object)_lineMat).hideFlags = (HideFlags)61;
				if (_lineMat.HasProperty("_ZTest"))
				{
					_lineMat.SetInt("_ZTest", 8);
				}
				if (_lineMat.HasProperty("_ZWrite"))
				{
					_lineMat.SetInt("_ZWrite", 0);
				}
				if (_lineMat.HasProperty("_Cull"))
				{
					_lineMat.SetInt("_Cull", 0);
				}
				if (_lineMat.HasProperty("_SrcBlend"))
				{
					_lineMat.SetInt("_SrcBlend", 5);
				}
				if (_lineMat.HasProperty("_DstBlend"))
				{
					_lineMat.SetInt("_DstBlend", 10);
				}
				_lineMat.renderQueue = 4000;
			}
			if (_lu < _lines.Count && (Object)(object)_lines[_lu] != (Object)null)
			{
				return _lines[_lu++];
			}
			GameObject val2 = new GameObject("kit_line")
			{
				hideFlags = (HideFlags)61
			};
			val2.transform.SetParent(WorldRoot, false);
			LineRenderer val3 = val2.AddComponent<LineRenderer>();
			val3.useWorldSpace = true;
			((Renderer)val3).sharedMaterial = _lineMat;
			val3.numCapVertices = 2;
			val3.numCornerVertices = 2;
			((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val3).receiveShadows = false;
			val3.alignment = (LineAlignment)0;
			if (_lu < _lines.Count)
			{
				_lines[_lu] = val3;
			}
			else
			{
				_lines.Add(val3);
			}
			_lu++;
			return val3;
		}

		public static void Line(Vector3 a, Vector3 b, Color c, float w)
		{
			//IL_001a: 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)
			LineRenderer val = NextLine(through: true);
			if (!((Object)(object)val == (Object)null))
			{
				val.positionCount = 2;
				val.SetPosition(0, a);
				val.SetPosition(1, b);
				val.startColor = c;
				val.endColor = c;
				val.startWidth = w;
				val.endWidth = w;
				((Renderer)val).enabled = true;
			}
		}

		public static void Poly(Vector3[] pts, int count, Color c, float w)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (count < 2)
			{
				return;
			}
			LineRenderer val = NextLine(through: true);
			if (!((Object)(object)val == (Object)null))
			{
				val.positionCount = count;
				for (int i = 0; i < count; i++)
				{
					val.SetPosition(i, pts[i]);
				}
				val.startColor = c;
				val.endColor = c;
				val.startWidth = w;
				val.endWidth = w;
				((Renderer)val).enabled = true;
			}
		}

		public static void Rect(Vector3 center, Vector3 right, Vector3 up, float hw, float hh, Color c, float w)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			_rect[0] = center - right * hw - up * hh;
			_rect[1] = center + right * hw - up * hh;
			_rect[2] = center + right * hw + up * hh;
			_rect[3] = center - right * hw + up * hh;
			_rect[4] = _rect[0];
			Poly(_rect, 5, c, w);
		}

		public static void Ring(Vector3 center, Vector3 a, Vector3 b, float ra, float rb, Color c, float w)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005c: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i <= 28; i++)
			{
				float num = (float)i / 28f * (float)Math.PI * 2f;
				_ring[i] = center + a * (Mathf.Cos(num) * ra) + b * (Mathf.Sin(num) * rb);
			}
			Poly(_ring, 29, c, w);
		}

		public static float LineW(float dist, float thickness)
		{
			return Mathf.Clamp(thickness * 0.0016f * dist, 0.004f, 0.25f);
		}

		public static float TextH(float dist, float scale)
		{
			return Mathf.Clamp(dist * 0.04f * scale, 0.07f, 1.8f);
		}
	}
	internal static class Snd
	{
		private static readonly Dictionary<string, AudioClip> _c = new Dictionary<string, AudioClip>();

		private static readonly Random _rnd = new Random(4242);

		private static AudioSource _ui;

		private static readonly Dictionary<string, AudioSource> _loops = new Dictionary<string, AudioSource>();

		public const int Rate = 44100;

		private static float N()
		{
			return (float)(_rnd.NextDouble() * 2.0 - 1.0);
		}

		private static AudioClip Build(string key, float[] data)
		{
			AudioClip val = AudioClip.Create(key, data.Length, 1, 44100, false);
			val.SetData(new Il2CppStructArray<float>(data), 0);
			_c[key] = val;
			return val;
		}

		private static float Env(int i, int n, float attack, float release)
		{
			float num = (float)i / 44100f;
			float num2 = (float)(n - i) / 44100f;
			return Mathf.Clamp01(num / Mathf.Max(0.0005f, attack)) * Mathf.Clamp01(num2 / Mathf.Max(0.0005f, release));
		}

		public static AudioClip Get(string name)
		{
			if (_c.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			float[] array;
			switch (name)
			{
			case "beep":
			{
				int num = 5292;
				array = new float[num];
				for (int l = 0; l < num; l++)
				{
					array[l] = Mathf.Sin((float)Math.PI * 2200f * (float)l / 44100f) * 0.45f * Env(l, num, 0.004f, 0.04f);
				}
				break;
			}
			case "blip":
			{
				int num = 3087;
				array = new float[num];
				for (int num27 = 0; num27 < num; num27++)
				{
					array[num27] = Mathf.Sin((float)Math.PI * 3400f * (float)num27 / 44100f) * 0.4f * Env(num27, num, 0.002f, 0.03f);
				}
				break;
			}
			case "chime":
			{
				int num = 39690;
				array = new float[num];
				for (int num38 = 0; num38 < num; num38++)
				{
					float num39 = (float)num38 / 44100f;
					array[num38] = (Mathf.Sin((float)Math.PI * 1760f * num39) + 0.5f * Mathf.Sin((float)Math.PI * 2640f * num39)) * 0.25f * Mathf.Exp((0f - num39) * 4f);
				}
				break;
			}
			case "thud":
			{
				int num = 15435;
				array = new float[num];
				for (int num16 = 0; num16 < num; num16++)
				{
					float num17 = (float)num16 / 44100f;
					array[num16] = Mathf.Sin((float)Math.PI * 2f * (70f - num17 * 60f) * num17) * 0.9f * Mathf.Exp((0f - num17) * 14f);
				}
				break;
			}
			case "footstep":
			{
				int num = 9702;
				array = new float[num];
				float num43 = 0f;
				for (int num44 = 0; num44 < num; num44++)
				{
					float num45 = (float)num44 / 44100f;
					num43 += (N() - num43) * 0.07f;
					array[num44] = (num43 * 3.2f + Mathf.Sin((float)Math.PI * 110f * num45) * 0.5f) * 0.55f * Mathf.Exp((0f - num45) * 20f);
				}
				break;
			}
			case "heartbeat":
			{
				int num = 39690;
				array = new float[num];
				for (int num30 = 0; num30 < num; num30++)
				{
					float num31 = (float)num30 / 44100f;
					float num32 = Mathf.Sin((float)Math.PI * 104f * num31) * Mathf.Exp((0f - num31) * 22f);
					float num33 = num31 - 0.26f;
					float num34 = ((num33 > 0f) ? (Mathf.Sin((float)Math.PI * 92f * num33) * Mathf.Exp((0f - num33) * 26f) * 0.75f) : 0f);
					array[num30] = (num32 + num34) * 0.9f;
				}
				break;
			}
			case "breath":
			{
				int num = 105840;
				array = new float[num];
				float num22 = 0f;
				for (int num23 = 0; num23 < num; num23++)
				{
					float num24 = (float)num23 / (float)num;
					num22 += (N() - num22) * 0.18f;
					array[num23] = num22 * 0.5f * Mathf.Sin((float)Math.PI * num24) * Mathf.Sin((float)Math.PI * num24);
				}
				break;
			}
			case "whisper":
			{
				int num = 97020;
				array = new float[num];
				float num8 = 0f;
				float num9 = 0f;
				for (int n = 0; n < num; n++)
				{
					float num10 = (float)n / 44100f;
					float num11 = N();
					num8 += (num11 - num8) * 0.35f;
					num9 += (num8 - num9) * 0.5f;
					float num12 = Mathf.Clamp01(Mathf.Sin(num10 * 9f) * 1.6f) * Mathf.Clamp01(Mathf.Sin(num10 * 2.3f + 1f) + 0.4f);
					array[n] = (num8 - num9) * 2.2f * num12 * Env(n, num, 0.3f, 0.6f) * 0.8f;
				}
				break;
			}
			case "static":
			{
				int num = 22050;
				array = new float[num];
				for (int j = 0; j < num; j++)
				{
					array[j] = N() * 0.35f * Env(j, num, 0.01f, 0.1f);
				}
				break;
			}
			case "thunder":
			{
				int num = 154350;
				array = new float[num];
				float num40 = 0f;
				for (int num41 = 0; num41 < num; num41++)
				{
					float num42 = (float)num41 / 44100f;
					num40 += (N() - num40) * 0.012f;
					array[num41] = num40 * 14f * Mathf.Exp((0f - num42) * 1.1f) * (0.6f + 0.4f * Mathf.Sin(num42 * 13f));
				}
				break;
			}
			case "creak":
			{
				int num = 48510;
				array = new float[num];
				float num35 = 0f;
				for (int num36 = 0; num36 < num; num36++)
				{
					float num37 = (float)num36 / 44100f;
					num35 += (180f + 80f * Mathf.Sin(num37 * 7f) + 120f * num37) / 44100f;
					array[num36] = (Mathf.Repeat(num35, 1f) * 2f - 1f) * 0.25f * Env(num36, num, 0.15f, 0.4f) * (0.5f + 0.5f * Mathf.Sin(num37 * 31f));
				}
				break;
			}
			case "drone":
			{
				int num = 264600;
				array = new float[num];
				for (int num28 = 0; num28 < num; num28++)
				{
					float num29 = (float)num28 / 44100f;
					array[num28] = (Mathf.Sin((float)Math.PI * 110f * num29) + 0.6f * Mathf.Sin(517.7345f * num29 + 1f) + 0.4f * Mathf.Sin((float)Math.PI * 221f * num29)) * 0.2f * (0.8f + 0.2f * Mathf.Sin(num29 * (float)Math.PI * 2f / 3f));
				}
				break;
			}
			case "hum":
			{
				int num = 88200;
				array = new float[num];
				for (int num25 = 0; num25 < num; num25++)
				{
					float num26 = (float)num25 / 44100f;
					array[num25] = (Mathf.Sin((float)Math.PI * 240f * num26) * 0.5f + Mathf.Sin((float)Math.PI * 480f * num26) * 0.25f) * 0.18f;
				}
				break;
			}
			case "wind":
			{
				int num = 352800;
				array = new float[num];
				float num18 = 0f;
				for (int num19 = 0; num19 < num; num19++)
				{
					float num20 = (float)num19 / 44100f;
					num18 += (N() - num18) * (0.02f + 0.012f * Mathf.Sin(num20 * 0.8f));
					float num21 = (float)Mathf.Min(num19, num - num19) / 22050f;
					array[num19] = num18 * 6f * (0.55f + 0.45f * Mathf.Sin(num20 * 0.9f + 1f)) * Mathf.Clamp01(num21) * 0.5f;
				}
				break;
			}
			case "rain":
			{
				int num = 176400;
				array = new float[num];
				float num13 = 0f;
				for (int num14 = 0; num14 < num; num14++)
				{
					float num15 = N();
					array[num14] = (num15 - num13) * 0.28f * Mathf.Clamp01((float)Mathf.Min(num14, num - num14) / 13230.001f);
					num13 = num15;
				}
				break;
			}
			case "crickets":
			{
				int num = 176400;
				array = new float[num];
				for (int m = 0; m < num; m++)
				{
					float num6 = (float)m / 44100f;
					float num7 = Mathf.Clamp01(Mathf.Sin(num6 * 2f * (float)Math.PI * 14f) * 3f) * Mathf.Clamp01(Mathf.Sin(num6 * 2f * (float)Math.PI * 1.1f) * 3f);
					array[m] = Mathf.Sin((float)Math.PI * 8600f * num6) * 0.07f * num7 * Mathf.Clamp01((float)Mathf.Min(m, num - m) / 8820f);
				}
				break;
			}
			case "sting":
			{
				int num = 61740;
				array = new float[num];
				for (int k = 0; k < num; k++)
				{
					float num4 = (float)k / 44100f;
					float num5 = 900f + 1400f * Mathf.Exp((0f - num4) * 3f);
					array[k] = (Mathf.Sin((float)Math.PI * 2f * num5 * num4) * 0.35f + N() * 0.25f) * Mathf.Exp((0f - num4) * 2.4f);
				}
				break;
			}
			case "scare":
			{
				int num = 70560;
				array = new float[num];
				float num2 = 0f;
				for (int i = 0; i < num; i++)
				{
					float num3 = (float)i / 44100f;
					num2 += (N() - num2) * 0.5f;
					array[i] = (num2 * 0.9f + Mathf.Sin((float)Math.PI * 380f * num3) * 0.5f + Mathf.Sin((float)Math.PI * 394f * num3) * 0.5f) * 0.55f * Mathf.Exp((0f - num3) * 1.8f);
				}
				break;
			}
			default:
				return null;
			}
			return Build(name, array);
		}

		public static AudioClip FromWav(string path)
		{
			try
			{
				byte[] array = File.ReadAllBytes(path);
				int i = 12;
				int num = 1;
				int num2 = 16;
				int num3 = 44100;
				int num4 = -1;
				int num5 = 0;
				int num6;
				for (; i + 8 <= array.Length; i += 8 + num6 + (num6 & 1))
				{
					string text = Encoding.ASCII.GetString(array, i, 4);
					num6 = BitConverter.ToInt32(array, i + 4);
					if (text == "fmt ")
					{
						num = BitConverter.ToInt16(array, i + 10);
						num3 = BitConverter.ToInt32(array, i + 12);
						num2 = BitConverter.ToInt16(array, i + 22);
					}
					else if (text == "data")
					{
						num4 = i + 8;
						num5 = Math.Min(num6, array.Length - num4);
						break;
					}
				}
				if (num4 < 0 || num2 != 16)
				{
					return null;
				}
				int num7 = num5 / (2 * num);
				float[] array2 = new float[num7];
				for (int j = 0; j < num7; j++)
				{
					float num8 = 0f;
					for (int k = 0; k < num; k++)
					{
						num8 += (float)BitConverter.ToInt16(array, num4 + (j * num + k) * 2) / 32768f;
					}
					array2[j] = num8 / (float)num;
				}
				AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num7, 1, num3, false);
				obj.SetData(new Il2CppStructArray<float>(array2), 0);
				return obj;
			}
			catch (Exception ex)
			{
				K.Warn("wav " + path, ex.Message);
				return null;
			}
		}

		public static List<AudioClip> Folder(string folder)
		{
			List<AudioClip> list = new List<AudioClip>();
			try
			{
				string path = Path.Combine(K.Dir, folder);
				Directory.CreateDirectory(path);
				string[] files = Directory.GetFiles(path, "*.wav");
				for (int i = 0; i < files.Length; i++)
				{
					AudioClip val = FromWav(files[i]);
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
				}
			}
			catch (Exception ex)
			{
				K.Warn("folder " + folder, ex.Message);
			}
			return list;
		}

		public static void At(string name, Vector3 pos, float vol = 1f)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				AudioClip val = Get(name);
				if ((Object)(object)val != (Object)null)
				{
					AudioSource.PlayClipAtPoint(val, pos, Mathf.Clamp01(vol));
				}
			}
			catch (Exception)
			{
			}
		}

		public static void At(AudioClip c, Vector3 pos, float vol = 1f)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)c != (Object)null)
				{
					AudioSource.PlayClipAtPoint(c, pos, Mathf.Clamp01(vol));
				}
			}
			catch (Exception)
			{
			}
		}

		private static AudioSource Ui()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_ui == (Object)null)
			{
				_ui = new GameObject("kit_audio")
				{
					hideFlags = (HideFlags)61
				}.AddComponent<AudioSource>();
				_ui.spatialBlend = 0f;
				_ui.playOnAwake = false;
			}
			Transform head = Player.Head;
			if ((Object)(object)head != (Object)null && (Object)(object)((Component)_ui).transform.parent != (Object)(object)head)
			{
				((Component)_ui).transform.SetParent(head, false);
			}
			return _ui;
		}

		public static void Flat(string name, float vol = 1f)
		{
			try
			{
				AudioClip val = Get(name);
				if ((Object)(object)val != (Object)null)
				{
					Ui().PlayOneShot(val, Mathf.Clamp01(vol));
				}
			}
			catch (Exception)
			{
			}
		}

		public static void Flat(AudioClip c, float vol = 1f)
		{
			try
			{
				if ((Object)(object)c != (Object)null)
				{
					Ui().PlayOneShot(c, Mathf.Clamp01(vol));
				}
			}
			catch (Exception)
			{
			}
		}

		public static void Loop(string name, float vol)
		{
			//IL_0038: 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)
			try
			{
				if (!_loops.TryGetValue(name, out var value) || (Object)(object)value == (Object)null)
				{
					AudioClip val = Get(name);
					if ((Object)(object)val == (Object)null)
					{
						return;
					}
					value = new GameObject("kit_loop_" + name)
					{
						hideFlags = (HideFlags)61
					}.AddComponent<AudioSource>();
					value.clip = val;
					value.loop = true;
					value.spatialBlend = 0f;
					value.playOnAwake = false;
					_loops[name] = value;
				}
				Transform head = Player.Head;
				if ((Object)(object)head != (Object)null && (Object)(object)((Component)value).transform.parent != (Object)(object)head)
				{
					((Component)value).transform.SetParent(head, false);
				}
				value.volume = Mathf.Clamp01(vol);
				if (vol > 0.001f && !value.isPlaying)
				{
					value.Play();
				}
				else if (vol <= 0.001f && value.isPlaying)
				{
					value.Pause();
				}
			}
			catch (Exception)
			{
			}
		}

		public static void StopLoops()
		{
			foreach (AudioSource value in _loops.Values)
			{
				try
				{
					if ((Object)(object)value != (Object)null && value.isPlaying)
					{
						value.Pause();
					}
				}
				catch (Exception)
				{
				}
			}
		}
	}
	internal enum Btn
	{
		None,
		A,
		B,
		Stick,
		Trigger,
		Grip,
		Menu
	}
	internal static class Pad
	{
		private static readonly string[][] Names = new string[7][]
		{
			new string[0],
			new string[1] { "GetAButton" },
			new string[1] { "GetBButton" },
			new string[1] { "GetThumbStick" },
			new string[2] { "GetPrimaryInteractionButton", "GetTrigger" },
			new string[2] { "GetSecondaryInteractionButton", "GetGrip" },
			new string[2] { "GetMenuButton", "GetMenuTap" }
		};

		private static readonly Dictionary<string, MethodInfo> _m = new Dictionary<string, MethodInfo>();

		private static readonly Dictionary<int, bool> _prev = new Dictionary<int, bool>();

		private static readonly Dictionary<int, bool> _down = new Dictionary<int, bool>();

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

		private static bool _reported;

		private static object Ctrl(bool right)
		{
			if (!right)
			{
				return Player.LeftController;
			}
			return Player.RightController;
		}

		private static bool ReadOne(object ctrl, string name)
		{
			if (ctrl == null)
			{
				return false;
			}
			string key = ctrl.GetType().FullName + "." + name;
			if (!_m.TryGetValue(key, out var value))
			{
				value = ctrl.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				_m[key] = value;
			}
			if (value == null)
			{
				return false;
			}
			try
			{
				object obj = value.Invoke(ctrl, null);
				if (!(obj is bool result))
				{
					if (obj is float)
					{
						return (float)obj > 0.6f;
					}
					return false;
				}
				return result;
			}
			catch (Exception)
			{
				return false;
			}
		}

		public static bool Held(bool right, Btn b)
		{
			if (b == Btn.None)
			{
				return false;
			}
			object obj = Ctrl(right);
			string[] array = Names[(int)b];
			foreach (string name in array)
			{
				if (ReadOne(obj, name))
				{
					return true;
				}
			}
			if (!_reported && obj != null && Names[(int)b].Length != 0)
			{
				bool flag = false;
				array = Names[(int)b];
				foreach (string name2 in array)
				{
					if (obj.GetType().GetMethod(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null)
					{
						flag = true;
					}
				}
				if (!flag)
				{
					_reported = true;
					K.Log.Warning("Controller button '" + b.ToString() + "' was not found on " + obj.GetType().Name + " - use the menu's 'Log controller buttons' and send me the list.");
				}
			}
			return false;
		}

		public static bool Down(bool right, Btn b)
		{
			int key = (int)((right ? 1u : 0u) << 8) | (int)b;
			int frameCount = Time.frameCount;
			if (_frame.TryGetValue(key, out var value) && value == frameCount)
			{
				return _down[key];
			}
			bool flag = Held(right, b);
			_prev.TryGetValue(key, out var value2);
			_prev[key] = flag;
			_frame[key] = frameCount;
			_down[key] = flag && !value2;
			return _down[key];
		}

		public static Vector2 Stick(bool right)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object obj = Ctrl(right);
				if (obj == null)
				{
					return Vector2.zero;
				}
				MethodInfo method = obj.GetType().GetMethod("GetThumbStickAxis", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (method == null)
				{
					return Vector2.zero;
				}
				object obj2 = method.Invoke(obj, null);
				return (Vector2)((obj2 is Vector2) ? ((Vector2)obj2) : Vector2.zero);
			}
			catch (Exception)
			{
				return Vector2.zero;
			}
		}

		public static void Dump()
		{
			bool[] array = new bool[2] { false, true };
			foreach (bool flag in array)
			{
				object obj = Ctrl(flag);
				if (obj == null)
				{
					K.Log.Msg((flag ? "right" : "left") + " controller: none");
					continue;
				}
				K.Log.Msg("---- " + (flag ? "right" : "left") + " controller: " + obj.GetType().FullName);
				MethodInfo[] methods = obj.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					string name = methodInfo.Name;
					if (name.StartsWith("Get") && methodInfo.GetParameters().Length == 0 && (name.IndexOf("Button", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Axis", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Stick", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Grip", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Trigger", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Menu", StringComparison.OrdinalIgnoreCase) >= 0))
					{
						string text = "?";
						try
						{
							text = Convert.ToString(methodInfo.Invoke(obj, null), CultureInfo.InvariantCulture);
						}
						catch (Exception)
						{
						}
						K.Log.Msg("  " + name + " = " + text);
					}
				}
			}
		}
	}
	internal static class M
	{
		public static Page Root(string name, Color c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Page.Root.CreatePage(name, c, 0, true);
		}

		public static Page Sub(Page p, string name, Color c)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return p.CreatePage(name, c, 0, true);
		}

		public static FloatElement F(Page p, string name, MelonPreferences_Entry<float> e, float inc, float min, float max)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return p.CreateFloat(name, Color.white, e.Value, inc, min, max, (Action<float>)delegate(float v)
			{
				e.Value = v;
				MelonPreferences.Save();
			});
		}

		public static IntElement I(Page p, string name, MelonPreferences_Entry<int> e, int inc, int min, int max)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return p.CreateInt(name, Color.white, e.Value, inc, min, max, (Action<int>)delegate(int v)
			{
				e.Value = v;
				MelonPreferences.Save();
			});
		}

		public static BoolElement B(Page p, string name, MelonPreferences_Entry<bool> e, Action<bool> also = null)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return p.CreateBool(name, Color.white, e.Value, (Action<bool>)delegate(bool v)
			{
				e.Value = v;
				MelonPreferences.Save();
				if (also != null)
				{
					also(v);
				}
			});
		}

		public static EnumElement E<T>(Page p, string name, MelonPreferences_Entry<int> e, Action<int> also = null) where T : struct, IConvertible
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return p.CreateEnum(name, Color.white, (Enum)Enum.ToObject(typeof(T), e.Value), (Action<Enum>)delegate(Enum v)
			{
				e.Value = Convert.ToInt32(v);
				MelonPreferences.Save();
				if (also != null)
				{
					also(e.Value);
				}
			});
		}

		public static FunctionElement Fn(Page p, string name, Color c, Action a)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return p.CreateFunction(name, c, a);
		}
	}
	internal static class N
	{
		public static void Send(string title, string message, Color c, float seconds = 3f, NotificationType type = (NotificationType)0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			try
			{
				Notifier.Send(new Notification
				{
					Title = new NotificationText(title, c, true),
					Message = new NotificationText(message, Color.white, true),
					ShowTitleOnPopup = true,
					PopupLength = Mathf.Max(1f, seconds),
					Type = type
				});
			}
			catch (Exception ex)
			{
				K.Warn("notify", ex.Message);
			}
		}
	}
	public enum Place
	{
		Off,
		Hud,
		LeftWrist,
		RightWrist,
		HudAndLeftWrist,
		HudAndRightWrist
	}
	public enum Corner
	{
		BottomLeft,
		BottomRight,
		TopLeft,
		TopRight,
		BottomCenter,
		TopCenter
	}
	public enum SkinSel
	{
		Denoised,
		Fantasy,
		Candy,
		Pixel,
		Heretic,
		Terminal
	}
	public enum PaletteSel
	{
		Planetarium,
		Fortuna,
		GreatBarrierReef,
		Bonfire,
		GreenTea,
		Daybreak,
		ChallengerDeep,
		Bonk,
		Mojave
	}
	public enum FaceStyle
	{
		Auto,
		Color,
		Pixel,
		ThresholdYellow,
		Outline,
		Terminal,
		Dither
	}
	public enum SelfSource
	{
		Camera,
		Cartoon
	}
	public class Mod : MelonMod
	{
		private class SkinDef
		{
			public string Id;

			public Color Frame;

			public Color Text;

			public Color[] Fill;

			public bool Seg;

			public bool UsePal;

			public int Segs;
		}

		private class Face
		{
			public string Key;

			public string Name;

			public Transform Head;

			public bool Self;

			public bool Empty;

			public Texture2D Tex;

			public float Last = -99f;

			public float Dist;

			public int Res;
		}

		private sealed class Surf
		{
			public bool Wrist;

			public Vector3 O;

			public Quaternion Rot;

			public float M;

			public float S;

			public float Az;

			public float El;

			public void Img(Texture t, float x, float y, float w, float h, Color c, int order)
			{
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: 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_0067: 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)
				if (!((Object)(object)t == (Object)null))
				{
					if (Wrist)
					{
						Vector3 val = Rot * Vector3.right;
						Vector3 val2 = Rot * Vector3.up;
						Gfx.WorldThru.Draw(t, O + val * (x * M) + val2 * (y * M), Rot, w * M, h * M, c, 1, 1, order);
					}
					else
					{
						Gfx.HudImg(t, Az + x * S, El + y * S, S * h, c, 0f, w / Mathf.Max(0.0001f, h), order);
					}
				}
			}

			public void Txt(string s, float x, float y, float h, Color c, int order, bool left = false, FontStyles st = (FontStyles)1)
			{
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				if (!string.IsNullOrEmpty(s))
				{
					if (Wrist)
					{
						Vector3 val = Rot * Vector3.right;
						Vector3 val2 = Rot * Vector3.up;
						Gfx.WorldTxtThru.Draw(s, O + val * (x * M) + val2 * (y * M), Rot, h * M, c, 0f, st, null, left, order);
					}
					else
					{
						Gfx.HudText(s, Az + x * S, El + y * S, S * h, c, 0f, null, st, 0f, left, order);
					}
				}
			}
		}

		private static MelonPreferences_Entry<bool> On;

		private static MelonPreferences_Entry<bool> ShowHp;

		private static MelonPreferences_Entry<bool> ShowWt;

		private static MelonPreferences_Entry<bool> ShowSp;

		private static MelonPreferences_Entry<bool> KmH;

		private static MelonPreferences_Entry<bool> WtDetail;

		private static MelonPreferences_Entry<bool> FSelf;

		private static MelonPreferences_Entry<bool> FFusion;

		private static MelonPreferences_Entry<bool> FNames;

		private static MelonPreferences_Entry<bool> FDist;

		private static MelonPreferences_Entry<bool> TOn;

		private static MelonPreferences_Entry<bool> TUseful;

		private static MelonPreferences_Entry<bool> TNpc;

		private static MelonPreferences_Entry<bool> TPlayers;

		private static MelonPreferences_Entry<bool> TDark;

		private static MelonPreferences_Entry<bool> ForceDark;

		private static MelonPreferences_Entry<bool> TNotify;

		private static MelonPreferences_Entry<int> VPlace;

		private static MelonPreferences_Entry<int> VCorner;

		private static MelonPreferences_Entry<int> SkinPref;

		private static MelonPreferences_Entry<int> PalPref;

		private static MelonPreferences_Entry<int> FPlace;

		private static MelonPreferences_Entry<int> FCorner;

		private static MelonPreferences_Entry<int> FMax;

		private static MelonPreferences_Entry<int> FStyle;

		private static MelonPreferences_Entry<int> FResIdx;

		private static MelonPreferences_Entry<int> FCols;

		private static MelonPreferences_Entry<int> FSelfSrc;

		private static MelonPreferences_Entry<float> VSize;

		private static MelonPreferences_Entry<float> VWrist;

		private static MelonPreferences_Entry<float> VOpac;

		private static MelonPreferences_Entry<float> VOffX;

		private static MelonPreferences_Entry<float> VOffY;

		private static MelonPreferences_Entry<float> CapKg;

		private static MelonPreferences_Entry<float> MaxSpd;

		private static MelonPreferences_Entry<float> HudDist;

		private static MelonPreferences_Entry<float> FSize;

		private static MelonPreferences_Entry<float> FWrist;

		private static MelonPreferences_Entry<float> FOpac;

		private static MelonPreferences_Entry<float> FFps;

		private static MelonPreferences_Entry<float> FRange;

		private static MelonPreferences_Entry<float> FOffX;

		private static MelonPreferences_Entry<float> FOffY;

		private static MelonPreferences_Entry<float> TSize;

		private static MelonPreferences_Entry<float> TY;

		private static MelonPreferences_Entry<float> TSpeed;

		private static MelonPreferences_Entry<float> TCool;

		private static MelonPreferences_Entry<float> TDarkLevel;

		private static MelonPreferences_Entry<float> ItemRadius;

		private static MelonPreferences_Entry<float> NpcRadius;

		private static MelonPreferences_Entry<float> PlayerRadius;

		private static readonly SkinDef[] Skins = new SkinDef[6]
		{
			new SkinDef
			{
				Id = "den",
				Frame = Color.white,
				Text = Color.white,
				Fill = (Color[])(object)new Color[3]
				{
					Color.white,
					Color.white,
					Color.white
				}
			},
			new SkinDef
			{
				Id = "fan",
				Frame = Color.white,
				Text = C(255, 235, 170),
				Fill = (Color[])(object)new Color[3]
				{
					C(215, 40, 50),
					C(235, 165, 40),
					C(60, 205, 195)
				}
			},
			new SkinDef
			{
				Id = "can",
				Frame = Color.white,
				Text = Color.white,
				UsePal = true
			},
			new SkinDef
			{
				Id = "pix",
				Frame = Color.white,
				Text = C(205, 220, 245),
				UsePal = true,
				Seg = true,
				Segs = 16
			},
			new SkinDef
			{
				Id = "her",
				Frame = Color.white,
				Text = C(232, 232, 232),
				Fill = (Color[])(object)new Color[3]
				{
					C(222, 62, 40),
					C(236, 150, 40),
					C(170, 176, 186)
				}
			},
			new SkinDef
			{
				Id = "ter",
				Frame = C(90, 255, 110),
				Text = C(110, 255, 130),
				Fill = (Color[])(object)new Color[3]
				{
					C(90, 255, 110),
					C(90, 255, 110),
					C(90, 255, 110)
				}
			}
		};

		private static readonly Color[][] Pals = new Color[9][]
		{
			(Color[])(object)new Color[5]
			{
				C(240, 232, 205),
				C(180, 200, 200),
				C(110, 150, 175),
				C(70, 110, 150),
				C(40, 70, 100)
			},
			(Color[])(object)new Color[5]
			{
				C(245, 215, 160),
				C(200, 170, 240),
				C(140, 110, 220),
				C(80, 60, 160),
				C(40, 30, 100)
			},
			(Color[])(object)new Color[5]
			{
				C(60, 180, 170),
				C(245, 200, 90),
				C(240, 130, 70),
				C(190, 70, 110),
				C(100, 40, 100)
			},
			(Color[])(object)new Color[5]
			{
				C(225, 100, 60),
				C(235, 130, 60),
				C(240, 160, 70),
				C(245, 190, 80),
				C(250, 215, 100)
			},
			(Color[])(object)new Color[5]
			{
				C(205, 215, 175),
				C(170, 180, 150),
				C(140, 140, 120),
				C(110, 100, 90),
				C(90, 80, 70)
			},
			(Color[])(object)new Color[5]
			{
				C(245, 225, 190),
				C(240, 200, 200),
				C(220, 170, 210),
				C(190, 140, 200),
				C(150, 110, 170)
			},
			(Color[])(object)new Color[5]
			{
				C(190, 230, 170),
				C(110, 200, 160),
				C(50, 150, 140),
				C(30, 100, 110),
				C(20, 50, 70)
			},
			(Color[])(object)new Color[5]
			{
				C(130, 10, 20),
				C(220, 60, 30),
				C(240, 140, 40),
				C(250, 200, 60),
				C(255, 245, 230)
			},
			(Color[])(object)new Color[5]
			{
				C(80, 70, 40),
				C(150, 110, 70),
				C(200, 150, 100),
				C(230, 190, 140),
				C(210, 120, 70)
			}
		};

		private const float W0 = 0.06f;

		private const float W1 = 0.26f;

		private const float W2 = 0.94f;

		private const float W3 = 0.74f;

		private static readonly Dictionary<string, Face> _faces = new Dictionary<string, Face>();

		private static readonly List<Face> _faceList = new List<Face>();

		private static Camera _cam;

		private static RenderTexture _rt;

		private static Texture2D _readTex;

		private static int _camRes;

		private static float _lastCap;

		private static float _speed;

		private static float _kg;

		private static float _heldL;

		private static float _heldR;

		private static float _slotKg;

		private static float _nextWeight;

		private static float _nextSlots;

		private static float _warnedRender;

		private static string _nameL = "";

		private static string _nameR = "";

		private static string _slotNames = "";

		private static Vector3 _lastHead;

		private static bool _hasLast;

		private static string _myName = "YOU";

		private static readonly List<Component> _slots = new List<Component>();

		private static Type _tSlot;

		private static Type _tBrain;

		private static bool _typesTried;

		private static Dictionary<string, List<string>> _th = new Dictionary<string, List<string>>();

		private static List<string> _useful = new List<string>();

		private static List<string> _hostile = new List<string>();

		private static List<string> _friendly = new List<string>();

		private static string _cur = "";

		private static string _full = "";

		private static float _typed;

		private static float _bornAt;

		private static float _holdUntil;

		private static float _lastThought;

		private static float _fear;

		private static float _bright = 1f;

		private static float _nextScan;

		private static float _nextMeasure;

		private static float _lastLine = -1f;

		private static float _darkSince = -1f;

		private static float _lastDarkSay;

		private static float _nextTypeTick;

		private static Color _curCol = Color.white;

		private static int _lastIdx = -1;

		private static bool _wasFearful;

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

		private static Light[] _lights = (Light[])(object)new Light[0];

		private static float _nextLights;

		private static string _why = "";

		private static int _nearHostile;

		private static int _nearFriendly;

		private static int _nearItems;

		private static Color C(int r, int g, int b)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)r / 255f, (float)g / 255f, (float)b / 255f, 1f);
		}

		public override void OnInitializeMelon()
		{
			K.Log = ((MelonBase)this).LoggerInstance;
			K.ModName = "Vitals";
			MelonPreferences_Category obj = MelonPreferences.CreateCategory("Vitals");
			On = obj.CreateEntry<bool>("On", true, "Vitals on", (string)null, false, false, (ValueValidator)null, (string)null);
			HudDist = obj.CreateEntry<float>("HudDist", 1f, "HUD distance (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			VPlace = obj.CreateEntry<int>("VPlace", 4, "Panel: where", (string)null, false, false, (ValueValidator)null, (string)null);
			VCorner = obj.CreateEntry<int>("VCorner", 0, "Panel: HUD corner", (string)null, false, false, (ValueValidator)null, (string)null);
			SkinPref = obj.CreateEntry<int>("Skin", 0, "Skin", (string)null, false, false, (ValueValidator)null, (string)null);
			PalPref = obj.CreateEntry<int>("Palette", 0, "Palette (Candy / Pixel)", (string)null, false, false, (ValueValidator)null, (string)null);
			VSize = obj.CreateEntry<float>("VSize", 11f, "Panel size on the HUD (degrees)", (string)null, false, false, (ValueValidator)null, (string)null);
			VWrist = obj.CreateEntry<float>("VWrist", 0.15f, "Panel size on the wrist (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			VOpac = obj.CreateEntry<float>("VOpac", 0.95f, "Panel opacity", (string)null, false, false, (ValueValidator)null, (string)null);
			VOffX = obj.CreateEntry<float>("VOffX", 0f, "Panel nudge left/right (deg)", (string)null, false, false, (ValueValidator)null, (string)null);
			VOffY = obj.CreateEntry<float>("VOffY", 0f, "Panel nudge up/down (deg)", (string)null, false, false, (ValueValidator)null, (string)null);
			ShowHp = obj.CreateEntry<bool>("ShowHp", true, "Health bar", (string)null, false, false, (ValueValidator)null, (string)null);
			ShowWt = obj.CreateEntry<bool>("ShowWt", true, "Weight bar", (string)null, false, false, (ValueValidator)null, (string)null);
			ShowSp = obj.CreateEntry<bool>("ShowSp", true, "Speed bar", (string)null, false, false, (ValueValidator)null, (string)null);
			KmH = obj.CreateEntry<bool>("KmH", false, "Speed in km/h", (string)null, false, false, (ValueValidator)null, (string)null);
			MaxSpd = obj.CreateEntry<float>("MaxSpd", 10f, "Speed that fills the bar (m/s)", (string)null, false, false, (ValueValidator)null, (string)null);
			CapKg = obj.CreateEntry<float>("CapKg", 30f, "Carry limit that fills the weight bar (kg)", (string)null, false, false, (ValueValidator)null, (string)null);
			WtDetail = obj.CreateEntry<bool>("WtDetail", true, "Show what you are carrying", (string)null, false, false, (ValueValidator)null, (string)null);
			FPlace = obj.CreateEntry<int>("FPlace", 4, "Faces: where", (string)null, false, false, (ValueValidator)null, (string)null);
			FCorner = obj.CreateEntry<int>("FCorner", 2, "Faces: HUD corner", (string)null, false, false, (ValueValidator)null, (string)null);
			FSelf = obj.CreateEntry<bool>("FSelf", true, "Show my own face", (string)null, false, false, (ValueValidator)null, (string)null);
			FFusion = obj.CreateEntry<bool>("FFusion", true, "Show Fusion players' faces", (string)null, false, false, (ValueValidator)null, (string)null);
			FMax = obj.CreateEntry<int>("FMax", 6, "Most faces shown", (string)null, false, false, (ValueValidator)null, (string)null);
			FStyle = obj.CreateEntry<int>("FStyle", 0, "Face style", (string)null, false, false, (ValueValidator)null, (string)null);
			FResIdx = obj.CreateEntry<int>("FRes", 1, "Face resolution (0=64 1=96 2=128)", (string)null, false, false, (ValueValidator)null, (string)null);
			FFps = obj.CreateEntry<float>("FFps", 10f, "Face updates per second (all faces together)", (string)null, false, false, (ValueValidator)null, (string)null);
			FCols = obj.CreateEntry<int>("FCols", 3, "Faces per row", (string)null, false, false, (ValueValidator)null, (string)null);
			FSize = obj.CreateEntry<float>("FSize", 6f, "Face size on the HUD (degrees)", (string)null, false, false, (ValueValidator)null, (string)null);
			FWrist = obj.CreateEntry<float>("FWrist", 0.06f, "Face size on the wrist (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			FOpac = obj.CreateEntry<float>("FOpac", 0.95f, "Face opacity", (string)null, false, false, (ValueValidator)null, (string)null);
			FRange = obj.CreateEntry<float>("FRange", 0f, "Only players closer than (m, 0 = any)", (string)null, false, false, (ValueValidator)null, (string)null);
			FNames = obj.CreateEntry<bool>("FNames", true, "Usernames above faces", (string)null, false, false, (ValueValidator)null, (string)null);
			FDist = obj.CreateEntry<bool>("FDist", true, "Distance under faces", (string)null, false, false, (ValueValidator)null, (string)null);
			FSelfSrc = obj.CreateEntry<int>("FSelfSrc", 0, "My face comes from", (string)null, false, false, (ValueValidator)null, (string)null);
			FOffX = obj.CreateEntry<float>("FOffX", 0f, "Faces nudge left/right (deg)", (string)null, false, false, (ValueValidator)null, (string)null);
			FOffY = obj.CreateEntry<float>("FOffY", 0f, "Faces nudge up/down (deg)", (string)null, false, false, (ValueValidator)null, (string)null);
			TOn = obj.CreateEntry<bool>("TOn", true, "Thoughts", (string)null, false, false, (ValueValidator)null, (string)null);
			TSize = obj.CreateEntry<float>("TSize", 1.4f, "Thought text size (degrees)", (string)null, false, false, (ValueValidator)null, (string)null);
			TY = obj.CreateEntry<float>("TY", -13f, "Thought height (degrees, negative = below centre)", (string)null, false, false, (ValueValidator)null, (string)null);
			TSpeed = obj.CreateEntry<float>("TSpeed", 22f, "Typing speed (letters per second)", (string)null, false, false, (ValueValidator)null, (string)null);
			TCool = obj.CreateEntry<float>("TCool", 9f, "Minimum seconds between thoughts", (string)null, false, false, (ValueValidator)null, (string)null);
			TUseful = obj.CreateEntry<bool>("TUseful", true, "Thoughts about useful objects", (string)null, false, false, (ValueValidator)null, (string)null);
			TNpc = obj.CreateEntry<bool>("TNpc", true, "Thoughts about NPCs", (string)null, false, false, (ValueValidator)null, (string)null);
			TPlayers = obj.CreateEntry<bool>("TPlayers", true, "Thoughts about other players", (string)null, false, false, (ValueValidator)null, (string)null);
			TDark = obj.CreateEntry<bool>("TDark", true, "Fear in the dark", (string)null, false, false, (ValueValidator)null, (string)null);
			TNotify = obj.CreateEntry<bool>("TNotify", false, "Also send thoughts as notifications", (string)null, false, false, (ValueValidator)null, (string)null);
			TDarkLevel = obj.CreateEntry<float>("TDarkLevel", 0.18f, "How dark is 'dark'", (string)null, false, false, (ValueValidator)null, (string)null);
			ItemRadius = obj.CreateEntry<float>("ItemRadius", 7f, "Useful object range (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			NpcRadius = obj.CreateEntry<float>("NpcRadius", 14f, "NPC range (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			PlayerRadius = obj.CreateEntry<float>("PlayerRadius", 12f, "Player range (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			ForceDark = obj.CreateEntry<bool>("ForceDark", false, "TEST: always dark", (string)null, false, false, (ValueValidator)null, (string)null);
			LoadThoughts();
			Watch.LevelChanged += delegate
			{
				_seen.Clear();
				_fear = 0f;
				_cur = "";
				_darkSince = -1f;
				_lights = (Light[])(object)new Light[0];
				_nextLights = 0f;
			};
			BuildMenu();
			((MelonBase)this).LoggerInstance.Msg("Vitals ready (BoneMenu > Vitals)");
		}

		private static void LoadThoughts()
		{
			try
			{
				_th = K.ReadSections(A.TextPath("thoughts.txt"), "idle");
				Dictionary<string, List<string>> dictionary = K.ReadSections(A.TextPath("items.txt"), "useful");
				_useful = (dictionary.ContainsKey("useful") ? Lower(dictionary["useful"]) : new List<string>());
				Dictionary<string, List<string>> dictionary2 = K.ReadSections(A.TextPath("npcs.txt"), "hostile");
				_hostile = (dictionary2.ContainsKey("hostile") ? Lower(dictionary2["hostile"]) : new List<string>());
				_friendly = (dictionary2.ContainsKey("friendly") ? Lower(dictionary2["friendly"]) : new List<string>());
				string[] array = A.Text("myname.txt").Split('\n');
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i].Trim();
					if (text.Length > 0 && text[0] != '#')
					{
						_myName = text;
						break;
					}
				}
			}
			catch (Exception ex)
			{
				K.Warn("thoughts", ex.Message);
			}
		}

		private static List<string> Lower(List<string> l)
		{
			List<string> list = new List<string>();
			foreach (string item in l)
			{
				list.Add(item.ToLowerInvariant());
			}
			return list;
		}

		private static void BuildMenu()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			Page p = M.Root("Vitals", new Color(0.5f, 1f, 0.7f));
			M.B(p, "Vitals on", On);
			Page p2 = M.Sub(p, "Vitals panel (HP / weight / speed)", new Color(1f, 0.5f, 0.5f));
			M.E<Place>(p2, "Where it shows", VPlace);
			M.E<Corner>(p2, "HUD corner", VCorner);
			M.E<SkinSel>(p2, "Skin", SkinPref);
			M.E<PaletteSel>(p2, "Palette (Candy / Pixel)", PalPref);
			M.B(p2, "Health bar", ShowHp);
			M.B(p2, "Weight bar", ShowWt);
			M.B(p2, "Speed bar", ShowSp);
			M.B(p2, "Show what you are carrying", WtDetail);
			M.F(p2, "Carry limit (kg)", CapKg, 2.5f, 2.5f, 200f);
			M.F(p2, "Speed that fills the bar (m/s)", MaxSpd, 1f, 3f, 30f);
			M.B(p2, "Speed in km/h", KmH);
			M.F(p2, "Size on HUD (deg)", VSize, 0.5f, 4f, 30f);
			M.F(p2, "Size on wrist (m)", VWrist, 0.01f, 0.05f, 0.4f);
			M.F(p2, "Opacity", VOpac, 0.05f, 0.2f, 1f);
			M.F(p2, "Nudge left/right (deg)", VOffX, 1f, -30f, 30f);
			M.F(p2, "Nudge up/down (deg)", VOffY, 1f, -30f, 30f);
			Page p3 = M.Sub(p, "Faces (avatar screenshots)", new Color(0.5f, 0.8f, 1f));
			M.E<Place>(p3, "Where they show", FPlace);
			M.E<Corner>(p3, "HUD corner", FCorner);
			M.B(p3, "Show my own face", FSelf);
			M.E<SelfSource>(p3, "My face comes from", FSelfSrc);
			M.B(p3, "Show Fusion players' faces", FFusion);
			M.I(p3, "Most faces shown", FMax, 1, 1, 12);
			M.I(p3, "Faces per row", FCols, 1, 1, 6);
			M.E<FaceStyle>(p3, "Style", FStyle);
			M.I(p3, "Resolution (0=64 1=96 2=128)", FResIdx, 1, 0, 2);
			M.F(p3, "Updates per second", FFps, 1f, 2f, 40f);
			M.B(p3, "Usernames above faces", FNames);
			M.B(p3, "Distance under faces", FDist);
			M.F(p3, "Only players closer than (m, 0 = any)", FRange, 5f, 0f, 300f);
			M.F(p3, "Size on HUD (deg)", FSize, 0.5f, 2f, 20f);
			M.F(p3, "Size on wrist (m)", FWrist, 0.005f, 0.02f, 0.2f);
			M.F(p3, "Opacity", FOpac, 0.05f, 0.2f, 1f);
			M.F(p3, "Nudge left/right (deg)", FOffX, 1f, -30f, 30f);
			M.F(p3, "Nudge up/down (deg)", FOffY, 1f, -30f, 30f);
			Page p4 = M.Sub(p, "Thoughts", new Color(0.8f, 0.7f, 1f));
			M.B(p4, "Thoughts on", TOn);
			M.B(p4, "Useful objects nearby", TUseful);
			M.B(p4, "NPCs (danger / peace)", TNpc);
			M.B(p4, "Other players", TPlayers);
			M.B(p4, "Fear in the dark", TDark);
			M.F(p4, "How dark is 'dark'", TDarkLevel, 0.01f, 0.02f, 0.8f);
			M.F(p4, "Typing speed", TSpeed, 2f, 4f, 60f);
			M.F(p4, "Seconds between thoughts", TCool, 1f, 2f, 60f);
			M.F(p4, "Text size", TSize, 0.1f, 0.6f, 4f);
			M.F(p4, "Text height", TY, 1f, -30f, 20f);
			M.F(p4, "Useful object range (m)", ItemRadius, 1f, 2f, 25f);
			M.F(p4, "NPC range (m)", NpcRadius, 1f, 3f, 40f);
			M.F(p4, "Player range (m)", PlayerRadius, 1f, 3f, 60f);
			M.B(p4, "Also send as notifications", TNotify);
			M.B(p4, "TEST: always dark", ForceDark);
			M.Fn(p4, "Open thoughts / items / npcs files", Color.yellow, delegate
			{
				A.TextPath("thoughts.txt");
				A.TextPath("items.txt");
				A.TextPath("npcs.txt");
				A.TextPath("myname.txt");
				K.OpenFolder();
			});
			M.Fn(p4, "Reload the files", Color.gray, LoadThoughts);
			M.Fn(p4, "Test: think something scary", Color.red, delegate
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				_fear = Mathf.Max(_fear, 0.8f);
				Say("scared", force: true, Color.white, scared: true);
			});
			Page p5 = M.Sub(p, "Debug", Color.gray);
			M.F(p5, "HUD distance (m)", HudDist, 0.1f, 0.5f, 3f);
			M.Fn(p5, "Log what I am carrying", Color.white, LogCarry);
			M.Fn(p5, "Log what is nearby (NPC names)", Color.white, LogNearby);
			M.Fn(p5, "Log the light sensor", Color.white, LogLight);
		}

		private static string Fmt(float v, string f)
		{
			return v.ToString(f, CultureInfo.InvariantCulture);
		}

		private static Rigidbody Pelvis()
		{
			try
			{
				PhysicsRig physicsRig = Player.PhysicsRig;
				return ((Object)(object)physicsRig == (Object)null) ? null : physicsRig.torso.rbPelvis;
			}
			catch (Exception)
			{
				return null;
			}
		}

		private static bool IsMine(Transform t)
		{
			try
			{
				Transform val = (((Object)(object)Player.RigManager == (Object)null) ? null : ((Component)Player.RigManager).transform);
				return (Object)(object)val != (Object)null && t.IsChildOf(val);
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static void FindTypes()
		{
			if (_typesTried)
			{
				return;
			}
			_typesTried = true;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				string name = assembly.GetName().Name;
				if (!name.StartsWith("Il2Cpp") && !(name == "Assembly-CSharp"))
				{
					continue;
				}
				Type[] types;
				try
				{
					types = assembly.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					types = ex.Types;
				}
				catch (Exception)
				{
					continue;
				}
				Type[] array = types;
				foreach (Type type in array)
				{
					if (!(type == null))
					{
						if (_tSlot == null && type.Name == "InventorySlotReceiver")
						{
							_tSlot = type;
						}
						if (_tBrain == null && type.Name == "AIBrain")
						{
							_tBrain = type;
						}
					}
				}
				if (_tSlot != null && _tBrain != null)
				{
					break;
				}
			}
		}

		private static void UpdateSpeed(Transform head, float dt)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			float num = -1f;
			Rigidbody val = Pelvis();
			Vector3 val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = val.velocity;
				num = ((Vector3)(ref val2)).magnitude;
			}
			else if (_hasLast)
			{
				val2 = head.position - _lastHead;
				num = ((Vector3)(ref val2)).magnitude / dt;
			}
			_lastHead = head.position;
			_hasLast = true;
			if (num >= 0f)
			{
				_speed = Mathf.Lerp(_speed, num, 1f - Mathf.Exp(-8f * dt));
			}
		}

		private static string Clean(string n)
		{
			if (n == null)
			{
				return "";
			}
			int num = n.IndexOf('(');
			if (num > 0)
			{
				n = n.Substring(0, num);
			}
			num = n.IndexOf('[');
			if (num > 0)
			{
				n = n.Substring(0, num);
			}
			n = n.Trim();
			if (n.Length <= 14)
			{
				return n;
			}
			return n.Substring(0, 14);
		}

		private static float HeldMass(object hand, out string name)
		{
			name = "";
			if (hand == null)
			{
				return 0f;
			}
			try
			{
				object obj = R.Get(hand, "m_CurrentAttachedGO");
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if ((Object)(object)val == (Object)null)
				{
					MethodInfo method = typeof(Player).GetMethod("GetObjectInHand", BindingFlags.Static | BindingFlags.Public);
					if (method != null)
					{
						object? obj2 = method.Invoke(null, new object[1] { hand });
						val = (GameObject)((obj2 is GameObject) ? obj2 : null);
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					return 0f;
				}
				Rigidbody val2 = val.GetComponentInParent<Rigidbody>();
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val.GetComponentInChildren<Rigidbody>();
				}
				if ((Object)(object)val2 == (Object)null || IsMine(((Component)val2).transform))
				{
					return 0f;
				}
				name = Clean(((Object)((Component)val2).gameObject).name);
				return val2.mass;
			}
			catch (Exception)
			{
				return 0f;
			}
		}

		private static float SlotMass(out string names)
		{
			names = "";
			float num = 0f;
			try
			{
				FindTypes();
				float unscaledTime = Time.unscaledTime;
				if (_tSlot != null && unscaledTime >= _nextSlots)
				{
					_nextSlots = unscaledTime + 3f;
					_slots.Clear();
					Il2CppReferenceArray<Component> componentsInChildren = ((C