Decompiled source of LethalCaptions v1.0.0

LethalCaptions.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCVitals;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LCVitals
{
	internal static class V
	{
		public static Color Orange = new Color(1f, 0.39f, 0.02f, 1f);

		public static Color OrangeDim = new Color(0.72f, 0.28f, 0.02f, 1f);

		public static readonly Color Red = new Color(1f, 0.17f, 0.12f, 1f);

		public static readonly Color Scrap = new Color(0.4f, 1f, 0.38f, 1f);

		public static readonly Color Blue = new Color(0.38f, 0.72f, 1f, 1f);

		public static readonly Color Gold = new Color(1f, 0.8f, 0.25f, 1f);

		public static readonly Color Grey = new Color(0.52f, 0.5f, 0.48f, 1f);

		public static readonly Color Ink = new Color(0.03f, 0.012f, 0f, 1f);

		public static float S = 1f;

		private static GUIStyle text;

		private static Font font;

		private static Texture2D scan;

		private static Texture2D silOutline;

		private static Texture2D silFill;

		private static Texture iconOut;

		private static Texture iconRed;

		private static Rect iconOutUV;

		private static Rect iconRedUV;

		private static bool gameIcon;

		private static bool gameFont;

		private static bool gameColor;

		private static int tries;

		private static float nextTry;

		private static readonly GUIContent tmp = new GUIContent();

		public static GUIStyle Style => text;

		public static Font Font => font;

		public static void Begin(float scale)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			S = (float)Screen.height / 1080f * scale;
			if (text == null)
			{
				text = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					wordWrap = false,
					clipping = (TextClipping)0,
					richText = false
				};
				scan = MakeScan();
				MakeSilhouette(out silOutline, out silFill);
			}
			if ((!gameIcon || !gameFont || !gameColor) && tries < 6 && Time.unscaledTime >= nextTry)
			{
				nextTry = Time.unscaledTime + 5f;
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					tries++;
					Borrow();
				}
			}
		}

		private static void Borrow()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_005c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			try
			{
				HUDManager instance = HUDManager.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				if (!gameColor && (Object)(object)instance.weightCounter != (Object)null)
				{
					Color color = ((Graphic)instance.weightCounter).color;
					if (color.r + color.g + color.b > 0.3f)
					{
						Orange = new Color(color.r, color.g, color.b, 1f);
						OrangeDim = new Color(color.r * 0.72f, color.g * 0.72f, color.b * 0.72f, 1f);
						gameColor = true;
					}
				}
				if (!gameFont)
				{
					Font val = null;
					if ((Object)(object)instance.weightCounter != (Object)null && (Object)(object)((TMP_Text)instance.weightCounter).font != (Object)null)
					{
						val = ((TMP_Text)instance.weightCounter).font.sourceFontFile;
					}
					if ((Object)(object)val == (Object)null)
					{
						Font[] array = Resources.FindObjectsOfTypeAll<Font>();
						foreach (Font val2 in array)
						{
							if ((Object)(object)val2 != (Object)null && ((Object)val2).name.IndexOf("3270", StringComparison.OrdinalIgnoreCase) >= 0)
							{
								val = val2;
								break;
							}
						}
					}
					if ((Object)(object)val != (Object)null)
					{
						font = val;
						text.font = val;
						gameFont = true;
					}
				}
				if (gameIcon || !((Object)(object)instance.selfRedCanvasGroup != (Object)null))
				{
					return;
				}
				Image component = ((Component)instance.selfRedCanvasGroup).GetComponent<Image>();
				Image val3 = null;
				Transform parent = ((Component)instance.selfRedCanvasGroup).transform.parent;
				if ((Object)(object)parent != (Object)null)
				{
					val3 = ((Component)parent).GetComponent<Image>();
					if ((Object)(object)val3 == (Object)null)
					{
						foreach (Transform item in parent)
						{
							Transform val4 = item;
							if (!((Object)(object)val4 == (Object)(object)((Component)instance.selfRedCanvasGroup).transform))
							{
								Image component2 = ((Component)val4).GetComponent<Image>();
								if ((Object)(object)component2 != (Object)null && (Object)(object)component2.sprite != (Object)null)
								{
									val3 = component2;
									break;
								}
							}
						}
					}
				}
				if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val3.sprite != (Object)null)
				{
					iconRed = (Texture)(object)component.sprite.texture;
					iconRedUV = UV(component.sprite);
					iconOut = (Texture)(object)val3.sprite.texture;
					iconOutUV = UV(val3.sprite);
					gameIcon = (Object)(object)iconRed != (Object)null && (Object)(object)iconOut != (Object)null;
				}
			}
			catch
			{
			}
		}

		private static Rect UV(Sprite s)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Rect textureRect = s.textureRect;
			float num = ((Texture)s.texture).width;
			float num2 = ((Texture)s.texture).height;
			return new Rect(((Rect)(ref textureRect)).x / num, ((Rect)(ref textureRect)).y / num2, ((Rect)(ref textureRect)).width / num, ((Rect)(ref textureRect)).height / num2);
		}

		public static void Fill(Rect r, Color c)
		{
			//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)
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
		}

		public static void Text(Rect r, string s, float size, Color c, TextAnchor a)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(s))
			{
				text.fontSize = FontPx(size);
				text.alignment = a;
				float num = Mathf.Max(1f, Mathf.Round(S * 1.2f));
				GUI.color = new Color(Ink.r, Ink.g, Ink.b, c.a * 0.9f);
				GUI.Label(new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y + num, ((Rect)(ref r)).width, ((Rect)(ref r)).height), s, text);
				GUI.Label(new Rect(((Rect)(ref r)).x - num * 0.5f, ((Rect)(ref r)).y - num * 0.5f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), s, text);
				GUI.color = c;
				GUI.Label(r, s, text);
			}
		}

		private static int FontPx(float size)
		{
			return Mathf.Max(10, Mathf.RoundToInt(Mathf.Max(size, 12f) * S));
		}

		public static float Width(string s, float size)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			text.fontSize = FontPx(size);
			tmp.text = s;
			return text.CalcSize(tmp).x;
		}

		public static void Panel(Rect r, float alpha)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: 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_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			Fill(r, new Color(0.02f, 0.008f, 0f, alpha));
			GUI.color = new Color(Orange.r, Orange.g, Orange.b, 0.06f);
			GUI.DrawTextureWithTexCoords(r, (Texture)(object)scan, new Rect(0f, 0f, 1f, ((Rect)(ref r)).height / Mathf.Max(1f, 3f * S)), true);
			Color c = default(Color);
			((Color)(ref c))..ctor(Orange.r, Orange.g, Orange.b, 0.35f);
			float num = Mathf.Max(1f, S);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, num), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - num, ((Rect)(ref r)).width, num), c);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), c);
			Fill(new Rect(((Rect)(ref r)).xMax - num, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), c);
			float num2 = Mathf.Min(12f * S, Mathf.Min(((Rect)(ref r)).width, ((Rect)(ref r)).height) * 0.3f);
			float num3 = Mathf.Max(2f, 2f * S);
			Color orange = Orange;
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num2, num3), orange);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num3, num2), orange);
			Fill(new Rect(((Rect)(ref r)).xMax - num2, ((Rect)(ref r)).y, num2, num3), orange);
			Fill(new Rect(((Rect)(ref r)).xMax - num3, ((Rect)(ref r)).y, num3, num2), orange);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - num3, num2, num3), orange);
			Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - num2, num3, num2), orange);
			Fill(new Rect(((Rect)(ref r)).xMax - num2, ((Rect)(ref r)).yMax - num3, num2, num3), orange);
			Fill(new Rect(((Rect)(ref r)).xMax - num3, ((Rect)(ref r)).yMax - num2, num3, num2), orange);
		}

		public static void Bar(Rect r, float frac, Color c, int segments)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			frac = Mathf.Clamp01(frac);
			if (segments <= 0)
			{
				Fill(r, new Color(c.r, c.g, c.b, 0.15f));
				Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * frac, ((Rect)(ref r)).height), c);
				return;
			}
			float num = Mathf.Max(1f, 2f * S);
			float num2 = (((Rect)(ref r)).width - num * (float)(segments - 1)) / (float)segments;
			float num3 = frac * (float)segments;
			Rect r2 = default(Rect);
			for (int i = 0; i < segments; i++)
			{
				float num4 = Mathf.Clamp01(num3 - (float)i);
				((Rect)(ref r2))..ctor(((Rect)(ref r)).x + (float)i * (num2 + num), ((Rect)(ref r)).y, num2, ((Rect)(ref r)).height);
				Fill(r2, new Color(c.r, c.g, c.b, 0.14f));
				if (num4 > 0f)
				{
					Fill(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width * num4, ((Rect)(ref r2)).height), c);
				}
			}
		}

		public static void Icon(Rect r, float damage01, bool dead, Color tint)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Color color = (dead ? Grey : tint);
			if (gameIcon)
			{
				GUI.color = color;
				GUI.DrawTextureWithTexCoords(r, iconOut, iconOutUV, true);
				if (!dead && damage01 > 0.01f)
				{
					GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(damage01));
					GUI.DrawTextureWithTexCoords(r, iconRed, iconRedUV, true);
				}
			}
			else
			{
				GUI.color = color;
				GUI.DrawTexture(r, (Texture)(object)silOutline, (ScaleMode)2, true);
				if (!dead && damage01 > 0.01f)
				{
					GUI.color = new Color(Red.r, Red.g, Red.b, Mathf.Clamp01(damage01));
					GUI.DrawTexture(r, (Texture)(object)silFill, (ScaleMode)2, true);
				}
			}
			if (dead)
			{
				GUI.color = Red;
				Text(r, "X", ((Rect)(ref r)).height * 0.7f / Mathf.Max(0.01f, S), Red, (TextAnchor)4);
			}
		}

		public static void Toast(string s, float yFrac, Color c)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			float num = Width(s, 17f) + 36f * S;
			float num2 = 30f * S;
			Rect r = new Rect(((float)Screen.width - num) / 2f, (float)Screen.height * yFrac, num, num2);
			Panel(r, 0.6f);
			Text(r, s, 17f, c, (TextAnchor)4);
		}

		public static void End()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.white;
		}

		private static Texture2D MakeScan()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0020: Expected O, but got Unknown
			//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_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_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)
			Texture2D val = new Texture2D(1, 3, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)0,
				hideFlags = (HideFlags)61
			};
			val.SetPixels((Color[])(object)new Color[3]
			{
				new Color(1f, 1f, 1f, 1f),
				new Color(1f, 1f, 1f, 0f),
				new Color(1f, 1f, 1f, 0f)
			});
			val.Apply(false, true);
			return val;
		}

		private static void MakeSilhouette(out Texture2D outline, out Texture2D fill)
		{
			//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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			outline = new Texture2D(48, 96, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				wrapMode = (TextureWrapMode)1
			};
			fill = new Texture2D(48, 96, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				wrapMode = (TextureWrapMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[4608];
			Color32[] array2 = (Color32[])(object)new Color32[4608];
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 48; j++)
				{
					float x = (float)j + 0.5f;
					float y = 96f - ((float)i + 0.5f);
					float num = Body(x, y);
					byte b = (byte)(Mathf.Clamp01(0.5f - num) * 255f);
					byte b2 = (byte)(Mathf.Clamp01(1.6f - Mathf.Abs(num + 1.2f)) * 255f);
					array2[i * 48 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
					array[i * 48 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.Max((int)b2, b / 6));
				}
			}
			outline.SetPixels32(array);
			outline.Apply(false, true);
			fill.SetPixels32(array2);
			fill.Apply(false, true);
		}

		private static float Body(float x, float y)
		{
			return Mathf.Min(Mathf.Min(Mathf.Min(Mathf.Min(Mathf.Min(Circle(x, y, 24f, 12f, 8.5f), Box(x, y, 24f, 38f, 11f, 16f, 5f)), Capsule(x, y, 14f, 26f, 8f, 52f, 3.6f)), Capsule(x, y, 34f, 26f, 40f, 52f, 3.6f)), Capsule(x, y, 19f, 54f, 18f, 90f, 4.5f)), Capsule(x, y, 29f, 54f, 30f, 90f, 4.5f));
		}

		private static float Circle(float x, float y, float cx, float cy, float r)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = new Vector2(x - cx, y - cy);
			return ((Vector2)(ref val)).magnitude - r;
		}

		private static float Box(float x, float y, float cx, float cy, float hx, float hy, float rad)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(x - cx) - (hx - rad);
			float num2 = Mathf.Abs(y - cy) - (hy - rad);
			Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f));
			return ((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f) - rad;
		}

		private static float Capsule(float x, float y, float ax, float ay, float bx, float by, float r)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = new Vector2(x - ax, y - ay);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(bx - ax, by - ay);
			float num = Mathf.Clamp01(Vector2.Dot(val, val2) / ((Vector2)(ref val2)).sqrMagnitude);
			Vector2 val3 = val - val2 * num;
			return ((Vector2)(ref val3)).magnitude - r;
		}
	}
	internal static class Num
	{
		private static readonly string[] small = new string[1001];

		public static string Of(int v)
		{
			if (v >= 0 && v <= 1000)
			{
				return small[v] ?? (small[v] = v.ToString());
			}
			return v.ToString();
		}
	}
	internal sealed class Cached
	{
		private long key = long.MinValue;

		public string Value = "";

		public bool Stale(long k)
		{
			if (k == key)
			{
				return false;
			}
			key = k;
			return true;
		}

		public void Reset()
		{
			key = long.MinValue;
		}
	}
}
namespace LethalCaptions
{
	[BepInPlugin("local.lethalcaptions", "LethalCaptions", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "local.lethalcaptions";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> On;

		internal static ConfigEntry<bool> Enemies;

		internal static ConfigEntry<bool> Footsteps;

		internal static ConfigEntry<bool> Doors;

		internal static ConfigEntry<bool> Traps;

		internal static ConfigEntry<bool> Ship;

		internal static ConfigEntry<bool> Teammates;

		internal static ConfigEntry<bool> Items;

		internal static ConfigEntry<bool> Weather;

		internal static ConfigEntry<bool> Other;

		internal static ConfigEntry<bool> OwnSounds;

		internal static ConfigEntry<float> MaxDistance;

		internal static ConfigEntry<float> MinLoudness;

		internal static ConfigEntry<float> WallMuffle;

		internal static ConfigEntry<float> TeammateDeathRange;

		internal static ConfigEntry<float> TextSize;

		internal static ConfigEntry<float> Scale;

		internal static ConfigEntry<float> Seconds;

		internal static ConfigEntry<float> OffsetX;

		internal static ConfigEntry<float> OffsetY;

		internal static ConfigEntry<int> MaxLines;

		internal static ConfigEntry<string> Corner;

		internal static ConfigEntry<bool> CrosshairArrows;

		internal static ConfigEntry<bool> ShowMuffled;

		private void Awake()
		{
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			On = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show captions for sounds.");
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxDistance", 60f, "Never caption sounds farther away than this many meters, even if they'd still be faintly audible.");
			MinLoudness = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinLoudness", 0.03f, "How loud a sound must be where you stand to get a caption (0-1, after the game's own falloff with distance). Lower = fainter sounds too.");
			WallMuffle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WallMuffle", 0.55f, "Sounds behind a wall count as this much quieter (0-1). They're marked MUFFLED.");
			OwnSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CaptionYourOwnSounds", false, "Also caption sounds you make yourself (your own items). Warnings like a jetpack about to blow are always shown.");
			Enemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Enemies", true, "Monster screeches, growls, attacks and other noises.");
			Footsteps = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "EnemyFootsteps", true, "Monster footsteps and movement.");
			Doors = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Doors", true, "Doors, locks, the facility entrance, ship doors, elevators.");
			Traps = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Traps", true, "Turrets, landmines, spike traps, steam pipes, bridges.");
			Ship = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "ShipAndAlerts", true, "Ship horn, take-off and landing, the leave warning, system alerts.");
			Teammates = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Teammates", true, "A teammate dying near you.");
			Items = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Items", true, "Gunshots, flashbangs, horns, boomboxes, jetpack warnings, the Cruiser.");
			Weather = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Weather", true, "Lightning (and the static crackle before a strike), thunder, meteors.");
			Other = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Other", false, "Everything else the mod can name (item drops, small props, ambience). Can be busy.");
			TeammateDeathRange = ((BaseUnityPlugin)this).Config.Bind<float>("Categories", "TeammateDeathRange", 30f, "A teammate's death is captioned only within this many meters (about how far you'd hear it).");
			Corner = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "Corner", "BottomRight", new ConfigDescription("Where the caption box sits.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[5] { "BottomRight", "BottomLeft", "TopRight", "TopLeft", "BottomCenter" }), Array.Empty<object>()));
			OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "OffsetX", 24f, "Distance from the side of the screen (1080p pixels).");
			OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "OffsetY", 170f, "Distance from the top/bottom of the screen (1080p pixels).");
			TextSize = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "TextSize", 16f, "Caption text size (1080p pixels).");
			Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Scale", 1f, "Overall size of the caption box.");
			MaxLines = ((BaseUnityPlugin)this).Config.Bind<int>("Display", "MaxLines", 6, "Most captions shown at once (the loudest/newest win).");
			Seconds = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Seconds", 3f, "How long a caption stays after its sound ends.");
			CrosshairArrows = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "CrosshairArrows", true, "Also show a small arrow around the crosshair pointing at dangerous sounds (attacks, traps, screams).");
			ShowMuffled = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "MarkMuffled", true, "Mark sounds coming through a wall as MUFFLED.");
			new Harmony("local.lethalcaptions").PatchAll(typeof(Plugin).Assembly);
			GameObject val = new GameObject("LethalCaptions");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<Captions>();
			Log.LogInfo((object)"LethalCaptions loaded");
		}

		internal static bool CatOn(Cat c)
		{
			return c switch
			{
				Cat.Enemies => Enemies.Value, 
				Cat.Footsteps => Footsteps.Value, 
				Cat.Doors => Doors.Value, 
				Cat.Traps => Traps.Value, 
				Cat.Ship => Ship.Value, 
				Cat.Teammates => Teammates.Value, 
				Cat.Items => Items.Value, 
				Cat.Weather => Weather.Value, 
				_ => Other.Value, 
			};
		}
	}
	[HarmonyPatch(typeof(AudioSource))]
	internal static class AudioPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("PlayOneShot", new Type[]
		{
			typeof(AudioClip),
			typeof(float)
		})]
		private static void OneShot(AudioSource __instance, AudioClip __0, float __1)
		{
			if (!Plugin.On.Value || (Object)(object)__0 == (Object)null)
			{
				return;
			}
			try
			{
				Captions.Heard(__instance, __0, __1, isPlay: false);
			}
			catch (Exception e)
			{
				Captions.Fail(e);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Play", new Type[] { })]
		private static void Play(AudioSource __instance)
		{
			if (!Plugin.On.Value)
			{
				return;
			}
			try
			{
				AudioClip clip = __instance.clip;
				if ((Object)(object)clip != (Object)null)
				{
					Captions.Heard(__instance, clip, 1f, isPlay: true);
				}
			}
			catch (Exception e)
			{
				Captions.Fail(e);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("PlayDelayed", new Type[] { typeof(float) })]
		private static void PlayDelayed(AudioSource __instance)
		{
			if (!Plugin.On.Value)
			{
				return;
			}
			try
			{
				AudioClip clip = __instance.clip;
				if ((Object)(object)clip != (Object)null)
				{
					Captions.Heard(__instance, clip, 1f, isPlay: true);
				}
			}
			catch (Exception e)
			{
				Captions.Fail(e);
			}
		}
	}
	internal enum Cat
	{
		Enemies,
		Footsteps,
		Doors,
		Traps,
		Ship,
		Teammates,
		Items,
		Weather,
		Other
	}
	internal sealed class Info
	{
		public string Text;

		public Cat Cat;

		public bool Danger;

		public bool Self;

		public Info(string t, Cat c, bool d, bool s)
		{
			Text = t;
			Cat = c;
			Danger = d;
			Self = s;
		}
	}
	internal static class Sounds
	{
		private sealed class Owner
		{
			public EnemyAI Enemy;

			public GrabbableObject Item;

			public PlayerControllerB Player;

			public readonly List<MonoBehaviour> Comps = new List<MonoBehaviour>();

			public string SrcField;

			public bool HasDoorLock;
		}

		private static readonly Dictionary<string, Info> table;

		private static readonly Dictionary<int, Owner> owners;

		private static readonly Dictionary<long, Info> cache;

		private static readonly Dictionary<int, string> globalClips;

		private static readonly Dictionary<int, Info> lastForClip;

		private static readonly Dictionary<Type, FieldInfo[]> clipFields;

		private static readonly Dictionary<Type, FieldInfo[]> srcFields;

		private static readonly Info None;

		private static Object globalsFor;

		private static readonly Dictionary<string, string> enemyNames;

		static Sounds()
		{
			table = new Dictionary<string, Info>(StringComparer.Ordinal);
			owners = new Dictionary<int, Owner>();
			cache = new Dictionary<long, Info>();
			globalClips = new Dictionary<int, string>();
			lastForClip = new Dictionary<int, Info>();
			clipFields = new Dictionary<Type, FieldInfo[]>();
			srcFields = new Dictionary<Type, FieldInfo[]>();
			None = new Info(null, Cat.Other, d: false, s: false);
			enemyNames = new Dictionary<string, string>
			{
				{ "FlowermanAI", "Bracken" },
				{ "CrawlerAI", "Thumper" },
				{ "SpringManAI", "Coil-head" },
				{ "MouthDogAI", "Eyeless Dog" },
				{ "CentipedeAI", "Snare Flea" },
				{ "HoarderBugAI", "Hoarding Bug" },
				{ "JesterAI", "Jester" },
				{ "NutcrackerEnemyAI", "Nutcracker" },
				{ "PufferAI", "Spore Lizard" },
				{ "SandSpiderAI", "Bunker Spider" },
				{ "BaboonBirdAI", "Baboon Hawk" },
				{ "SandWormAI", "Earth Leviathan" },
				{ "ForestGiantAI", "Forest Giant" },
				{ "RadMechAI", "Old Bird" },
				{ "ButlerEnemyAI", "Butler" },
				{ "ButlerBeesEnemyAI", "Mask Hornets" },
				{ "ClaySurgeonAI", "Barber" },
				{ "BushWolfEnemy", "Kidnapper Fox" },
				{ "CaveDwellerAI", "Maneater" },
				{ "DressGirlAI", "Ghost Girl" },
				{ "MaskedPlayerEnemy", "Masked" },
				{ "BlobAI", "Hygrodere" },
				{ "FlowerSnakeEnemy", "Tulip Snake" },
				{ "RedLocustBees", "Circuit Bees" },
				{ "DocileLocustBeesAI", "Locusts" },
				{ "DoublewingAI", "Manticoil" },
				{ "GiantKiwiAI", "Giant Sapsucker" },
				{ "LassoManAI", "Lasso Man" }
			};
			E("FlowermanAI.crackNeckSFX", "Bracken snaps a neck", danger: true);
			E("FlowermanAI.@creatureAngerVoice", "Bracken growls angrily", danger: true);
			E("JesterAI.popGoesTheWeaselTheme", "Jester winding up!", danger: true);
			E("JesterAI.popUpSFX", "Jester pops out", danger: true);
			E("JesterAI.screamingSFX", "Jester screaming", danger: true);
			E("JesterAI.killPlayerSFX", "Jester attacks", danger: true);
			E("CrawlerAI.shortRoar", "Thumper roars", danger: true);
			E("CrawlerAI.longRoarSFX", "Thumper roars", danger: true);
			E("CrawlerAI.hitWallSFX", "Thumper slams a wall", danger: true);
			E("CrawlerAI.bitePlayerSFX", "Thumper bites", danger: true);
			E("CrawlerAI.eatPlayerSFX", "Thumper eating", danger: true);
			F("SpringManAI.springNoises", "Coil-head moving");
			E("SpringManAI.enterCooldownSFX", "Coil-head winds down", danger: false);
			E("MouthDogAI.screamSFX", "Eyeless Dog howls", danger: true);
			E("MouthDogAI.breathingSFX", "Eyeless Dog breathing", danger: false);
			E("MouthDogAI.killPlayerSFX", "Eyeless Dog attacks", danger: true);
			E("ForestGiantAI.giantCry", "Forest Giant cries out", danger: false);
			E("ForestGiantAI.giantFall", "Forest Giant falls", danger: false);
			E("ForestGiantAI.@giantBurningAudio", "Forest Giant burning", danger: false);
			E("NutcrackerEnemyAI.aimSFX", "Nutcracker aiming", danger: true);
			E("NutcrackerEnemyAI.kickSFX", "Nutcracker kicks", danger: true);
			E("NutcrackerEnemyAI.torsoFinishTurningClips", "Nutcracker turning", danger: false);
			E("NutcrackerEnemyAI.@torsoTurnAudio", "Nutcracker turning", danger: false);
			E("CentipedeAI.fallShriek", "Snare Flea drops!", danger: true);
			E("CentipedeAI.shriekClips", "Snare Flea shrieks", danger: true);
			E("CentipedeAI.hitGroundSFX", "Snare Flea lands", danger: true);
			E("CentipedeAI.clingToPlayer3D", "Snare Flea clinging to someone", danger: true);
			E("HoarderBugAI.chitterSFX", "Hoarding Bug chitters", danger: false);
			E("HoarderBugAI.angryScreechSFX", "Hoarding Bug screeches", danger: true);
			E("HoarderBugAI.angryVoiceSFX", "Hoarding Bug angry", danger: true);
			E("HoarderBugAI.bugFlySFX", "Hoarding Bug flying", danger: false);
			E("HoarderBugAI.hitPlayerSFX", "Hoarding Bug attacks", danger: true);
			E("BaboonBirdAI.cawScreamSFX", "Baboon Hawk screams", danger: true);
			E("BaboonBirdAI.cawLaughSFX", "Baboon Hawk caws", danger: false);
			E("BaboonBirdAI.@aggressionAudio", "Baboon Hawk threatening", danger: true);
			F("SandSpiderAI.footstepSFX", "Bunker Spider footsteps");
			E("SandSpiderAI.attackSFX", "Bunker Spider attacks", danger: true);
			E("SandSpiderAI.spoolPlayerSFX", "Bunker Spider wrapping someone", danger: true);
			E("SandSpiderAI.hangPlayerSFX", "Bunker Spider hanging someone", danger: true);
			E("SandSpiderAI.hitWebSFX", "Spider web touched", danger: false);
			E("SandSpiderAI.breakWebSFX", "Spider web breaks", danger: false);
			E("SandWormAI.groundRumbleSFX", "Ground rumbling!", danger: true);
			E("SandWormAI.ambientRumbleSFX", "Distant rumbling", danger: false);
			E("SandWormAI.emergeFromGroundSFX", "Earth Leviathan bursts out", danger: true);
			E("SandWormAI.roarSFX", "Earth Leviathan roars", danger: true);
			E("SandWormAI.hitGroundSFX", "Earth Leviathan crashes down", danger: true);
			E("BlobAI.agitatedSFX", "Hygrodere agitated", danger: true);
			E("BlobAI.jiggleSFX", "Hygrodere squelching", danger: false);
			E("BlobAI.idleSFX", "Hygrodere squelching", danger: false);
			E("BlobAI.killPlayerSFX", "Hygrodere attacks", danger: true);
			E("PufferAI.frightenSFX", "Spore Lizard hisses", danger: false);
			E("PufferAI.puff", "Spore Lizard puffs spores", danger: false);
			E("PufferAI.rattleTail", "Spore Lizard rattles its tail", danger: true);
			E("PufferAI.angry", "Spore Lizard angry", danger: true);
			E("PufferAI.stomp", "Spore Lizard stomps", danger: true);
			E("PufferAI.bitePlayerSFX", "Spore Lizard bites", danger: true);
			E("PufferAI.nervousMumbling", "Spore Lizard mumbling", danger: false);
			F("PufferAI.footstepsSFX", "Spore Lizard footsteps");
			E("DressGirlAI.appearStaringSFX", "Something is watching you", danger: true);
			F("DressGirlAI.skipWalkSFX", "Skipping footsteps");
			E("DressGirlAI.breathingSFX", "Breathing", danger: false);
			E("DressGirlAI.@heartbeatMusic", "Heartbeat", danger: true);
			E("RadMechAI.shootGunSFX", "Old Bird firing", danger: true);
			E("RadMechAI.largeExplosionSFX", "Explosion", danger: true);
			E("RadMechAI.@LocalLRADAudio", "Old Bird blaring", danger: true);
			E("RadMechAI.@LocalLRADAudio2", "Old Bird blaring", danger: true);
			E("RadMechAI.@blowtorchAudio", "Old Bird blowtorch", danger: true);
			E("RadMechAI.@chargeForwardAudio", "Old Bird charging", danger: true);
			E("RadMechAI.@flyingDistantAudio", "Old Bird flying", danger: false);
			E("RadMechAI.@spotlightOnAudio", "Old Bird spotlight", danger: false);
			E("ButlerEnemyAI.broomSweepSFX", "Butler sweeping", danger: false);
			F("ButlerEnemyAI.footsteps", "Butler footsteps");
			E("ButlerEnemyAI.@murderMusicAudio", "Butler attacking!", danger: true);
			E("ButlerEnemyAI.@popAudio", "Butler pops", danger: true);
			E("ButlerEnemyAI.@popAudioFar", "Butler pops", danger: true);
			E("ButlerBeesEnemyAI.@buzzing", "Mask Hornets buzzing", danger: true);
			E("ClaySurgeonAI.snipScissors", "Barber's scissors snip", danger: true);
			E("ClaySurgeonAI.snareDrum", "Drum beat", danger: false);
			E("ClaySurgeonAI.paradeClips", "Marching drums", danger: false);
			E("BushWolfEnemy.snarlSFX", "Kidnapper Fox snarls", danger: true);
			E("BushWolfEnemy.growlSFX", "Kidnapper Fox growls", danger: true);
			E("BushWolfEnemy.shootTongueSFX", "Kidnapper Fox tongue lash", danger: true);
			E("BushWolfEnemy.tongueShootSFX", "Kidnapper Fox tongue lash", danger: true);
			E("BushWolfEnemy.killSFX", "Kidnapper Fox attacks", danger: true);
			E("BushWolfEnemy.callsClose", "Kidnapper Fox calls", danger: false);
			E("BushWolfEnemy.callsFar", "Kidnapper Fox calls (far)", danger: false);
			E("CaveDwellerAI.fakeCrySFX", "Baby crying", danger: false);
			E("CaveDwellerAI.scaredBabyVoiceSFX", "Baby crying", danger: false);
			E("CaveDwellerAI.@babyCryingAudio", "Baby crying", danger: false);
			E("CaveDwellerAI.growlSFX", "Maneater growls", danger: true);
			E("CaveDwellerAI.transformationSFX", "Maneater transforming!", danger: true);
			E("CaveDwellerAI.@screamAudio", "Maneater screams", danger: true);
			E("CaveDwellerAI.biteSFX", "Maneater bites", danger: true);
			F("CaveDwellerAI.@walkingAudio", "Maneater footsteps");
			E("RedLocustBees.@beesAngry", "Bees swarming angrily", danger: true);
			E("RedLocustBees.@beesDefensive", "Bees buzzing loudly", danger: true);
			E("RedLocustBees.@beesIdle", "Bees buzzing", danger: false);
			E("RedLocustBees.@beeZapAudio", "Bees zapping", danger: true);
			E("DoublewingAI.birdScreechSFX", "Manticoil screeches", danger: false);
			E("GiantKiwiAI.screamSFX", "Giant Sapsucker screams", danger: true);
			E("GiantKiwiAI.attackSFX", "Giant Sapsucker attacks", danger: true);
			E("GiantKiwiAI.squawkSFX", "Giant Sapsucker squawks", danger: false);
			E("GiantKiwiAI.peckTreeSFX", "Pecking", danger: false);
			E("GiantKiwiAI.breakAndEnter", "Something smashed in", danger: true);
			F("GiantKiwiAI.footstepSFX", "Giant Sapsucker footsteps");
			F("GiantKiwiAI.footstepBassSFX", "Giant Sapsucker footsteps");
			F("MaskedPlayerEnemy.@movementAudio", "Masked footsteps");
			E("FlowerSnakeEnemy.@flappingAudio", "Tulip Snake flapping", danger: false);
			E("EnemyVent.ventCrawlSFX", "Something crawling out of a vent", danger: true);
			E("EnemyType.overrideVentSFX", "Something crawling out of a vent", danger: true);
			A("DoorLock.pickingLockSFX", "Lock being picked", Cat.Doors, danger: false);
			A("DoorLock.unlockSFX", "Door unlocked", Cat.Doors, danger: false);
			A("SoundManager.steelDoorOpenSFX", "Steel door opens", Cat.Doors, danger: false);
			A("SoundManager.steelDoorCloseSFX", "Steel door closes", Cat.Doors, danger: false);
			A("SoundManager.woodDoorOpenSFX", "Door opens", Cat.Doors, danger: false);
			A("SoundManager.woodDoorCloseSFX", "Door closes", Cat.Doors, danger: false);
			A("StartOfRound.shutDoorMetal", "Door closes", Cat.Doors, danger: false);
			A("StartOfRound.shutDoorWooden", "Door closes", Cat.Doors, danger: false);
			A("StartOfRound.creakOpenDoorMetal", "Door opens", Cat.Doors, danger: false);
			A("StartOfRound.creakOpenDoorWooden", "Door opens", Cat.Doors, danger: false);
			A("EntranceTeleport.doorAudios", "Entrance door", Cat.Doors, danger: false);
			A("StartOfRound.@shipDoorAudioSource", "Ship doors", Cat.Doors, danger: false);
			A("StartOfRound.openingHangarDoorAudio", "Ship doors opening", Cat.Doors, danger: false);
			A("MineshaftElevatorController.elevatorStartUpSFX", "Elevator going up", Cat.Doors, danger: false);
			A("MineshaftElevatorController.elevatorStartDownSFX", "Elevator going down", Cat.Doors, danger: false);
			A("MineshaftElevatorController.elevatorTravelSFX", "Elevator moving", Cat.Doors, danger: false);
			A("MineshaftElevatorController.elevatorFinishUpSFX", "Elevator arrives", Cat.Doors, danger: false);
			A("MineshaftElevatorController.elevatorFinishDownSFX", "Elevator arrives", Cat.Doors, danger: false);
			A("DepositItemsDesk.doorOpenSFX", "Company door opens", Cat.Doors, danger: false);
			A("DepositItemsDesk.doorShutSFX", "Company door shuts", Cat.Doors, danger: false);
			A("Turret.detectPlayerSFX", "Turret spots someone", Cat.Traps, danger: true);
			A("Turret.chargingSFX", "Turret charging", Cat.Traps, danger: true);
			A("Turret.firingSFX", "Turret firing!", Cat.Traps, danger: true);
			A("Turret.firingFarSFX", "Turret firing", Cat.Traps, danger: true);
			A("Turret.bulletsHitWallSFX", "Bullets hitting", Cat.Traps, danger: true);
			A("Turret.turretActivate", "Turret on", Cat.Traps, danger: false);
			A("Turret.turretDeactivate", "Turret off", Cat.Traps, danger: false);
			A("Turret.@berserkAudio", "Turret going berserk!", Cat.Traps, danger: true);
			A("Landmine.mineTrigger", "Landmine clicks!", Cat.Traps, danger: true);
			A("Landmine.minePress", "Landmine pressed!", Cat.Traps, danger: true);
			A("Landmine.mineDetonate", "Explosion", Cat.Traps, danger: true);
			A("Landmine.mineDetonateFar", "Distant explosion", Cat.Traps, danger: false);
			A("Landmine.mineDeactivate", "Landmine disabled", Cat.Traps, danger: false);
			A("SpikeRoofTrap.@spikeTrapAudio", "Spike trap slams", Cat.Traps, danger: true);
			A("SteamValveHazard.valveBurstSFX", "Steam pipe bursts", Cat.Traps, danger: false);
			A("SteamValveHazard.valveCrackSFX", "Steam pipe cracking", Cat.Traps, danger: false);
			A("SteamValveHazard.steamBlowSFX", "Steam hissing", Cat.Traps, danger: false);
			A("BridgeTrigger.bridgeCreakSFX", "Bridge creaking!", Cat.Traps, danger: true);
			A("BridgeTrigger.bridgeFallSFX", "Bridge collapsing!", Cat.Traps, danger: true);
			A("SandSpiderWebTrap.@webAudio", "Spider web", Cat.Traps, danger: false);
			A("ShipAlarmCord.@hornClose", "Ship horn", Cat.Ship, danger: false);
			A("ShipAlarmCord.@hornFar", "Ship horn", Cat.Ship, danger: false);
			A("StartOfRound.shipDepartSFX", "Ship taking off", Cat.Ship, danger: false);
			A("StartOfRound.shipArriveSFX", "Ship landing", Cat.Ship, danger: false);
			A("StartOfRound.alarmSFX", "Ship alarm", Cat.Ship, danger: true);
			A("StartOfRound.allPlayersDeadAudio", "All crew lost", Cat.Ship, danger: false);
			A("StartOfRound.zeroDaysLeftAlertSFX", "Zero days left alert", Cat.Ship, danger: false);
			A("StartOfRound.HUDSystemAlertSFX", "System alert", Cat.Ship, danger: false);
			A("StartOfRound.suckedIntoSpaceSFX", "Ejected into space", Cat.Ship, danger: false);
			A("StartOfRound.airPressureSFX", "Air pressure", Cat.Ship, danger: false);
			A("StartOfRound.magnetOnAudio", "Ship magnet on", Cat.Ship, danger: false);
			A("StartOfRound.magnetOffAudio", "Ship magnet off", Cat.Ship, danger: false);
			A("HUDManager.shipAlarmHornSFX", "Ship alarm horn", Cat.Ship, danger: true);
			A("HUDManager.globalNotificationSFX", "Notification", Cat.Ship, danger: false);
			A("HUDManager.radiationWarningAudio", "Radiation warning", Cat.Ship, danger: true);
			A("HUDManager.meteorShowerWarningAudio", "Meteor shower warning", Cat.Ship, danger: true);
			A("HUDManager.warningSFX", "Warning", Cat.Ship, danger: true);
			A("HUDManager.criticalInjury", "Critical injury", Cat.Ship, danger: true);
			A("ShipTeleporter.@shipTeleporterAudio", "Teleporter", Cat.Ship, danger: false);
			A("ShipTeleporter.teleporterBeamUpSFX", "Teleporter beaming", Cat.Ship, danger: false);
			A("BreakerBox.switchPowerSFX", "Breaker switched", Cat.Ship, danger: false);
			A("RoundManager.@elevatorMotorAudio", "Ship motor", Cat.Ship, danger: false);
			A("ShotgunItem.gunShootSFX", "Gunshot!", Cat.Items, danger: true);
			A("ShotgunItem.gunReloadSFX", "Shotgun reloading", Cat.Items, danger: false);
			A("ShotgunItem.noAmmoSFX", "Gun clicks empty", Cat.Items, danger: false);
			A("StunGrenadeItem.explodeSFX", "Flashbang goes off", Cat.Items, danger: true);
			A("StunGrenadeItem.pullPinSFX", "Flashbang pin pulled", Cat.Items, danger: false);
			A("BoomboxItem.musicAudios", "Boombox music", Cat.Items, danger: false);
			A("WhoopieCushionItem.fartAudios", "Whoopie cushion", Cat.Items, danger: false);
			A("KiwiBabyItem.screamAudio", "Egg screaming", Cat.Items, danger: true);
			A("KiwiBabyItem.scream3SFX", "Egg screaming", Cat.Items, danger: true);
			A("RadarBoosterItem.flashSFX", "Radar booster flash", Cat.Items, danger: false);
			A("RadarBoosterItem.pingSFX", "Radar booster ping", Cat.Items, danger: false);
			S("JetpackItem.jetpackWarningBeepSFX", "Jetpack warning beeping!");
			S("JetpackItem.jetpackLowBatteriesSFX", "Jetpack battery low");
			A("JetpackItem.jetpackBrokenSFX", "Jetpack broke", Cat.Items, danger: true);
			A("JetpackItem.startJetpackSFX", "Jetpack", Cat.Items, danger: false);
			S("FlashlightItem.outOfBatteriesClip", "Flashlight out of battery");
			A("Shovel.hitSFX", "Shovel hit", Cat.Items, danger: false);
			A("KnifeItem.hitSFX", "Knife hit", Cat.Items, danger: false);
			A("ExtensionLadderItem.ladderExtendSFX", "Ladder extending", Cat.Items, danger: false);
			A("ExtensionLadderItem.ladderFallSFX", "Ladder falling", Cat.Items, danger: false);
			A("ExtensionLadderItem.blinkWarningSFX", "Ladder about to retract", Cat.Items, danger: false);
			A("WalkieTalkie.playerDieOnWalkieTalkieSFX", "Walkie: someone died", Cat.Teammates, danger: true);
			A("VehicleController.@hornAudio", "Cruiser horn", Cat.Items, danger: false);
			A("VehicleController.windshieldBreak", "Windshield shatters", Cat.Items, danger: false);
			A("VehicleController.maxCollisions", "Cruiser crash!", Cat.Items, danger: true);
			A("VehicleController.medCollisions", "Cruiser bump", Cat.Items, danger: false);
			A("VehicleController.engineStartSuccessful", "Cruiser engine starts", Cat.Items, danger: false);
			A("VehicleController.@radioAudio", "Cruiser radio", Cat.Items, danger: false);
			A("StormyWeather.strikeSFX", "Lightning strike!", Cat.Weather, danger: true);
			A("StormyWeather.distantThunderSFX", "Distant thunder", Cat.Weather, danger: false);
			A("StormyWeather.@staticElectricityAudio", "Static crackling - lightning about to strike!", Cat.Weather, danger: true);
			A("ThunderAndLightningScript.ThunderSoundsNormal", "Thunder", Cat.Weather, danger: false);
			A("ThunderAndLightningScript.ThunderSoundsIntense", "Thunder", Cat.Weather, danger: false);
			A("MeteorShowers.insideFactoryMeteorClip", "Meteors hitting", Cat.Weather, danger: true);
			string[] array = new string[12]
			{
				"SoundManager.DaytimeMusic", "SoundManager.EveningMusic", "SoundManager.heartbeatClips", "TimeOfDay.timeOfDayCues", "HUDManager.scanSFX", "HUDManager.dialogueBleeps", "HUDManager.addToScrapTotalSFX", "HUDManager.finishAddingToTotalSFX", "Terminal.keyboardClips", "StartOfRound.shipCreakSFX",
				"LevelAmbienceLibrary.insideAmbience", "LevelAmbienceLibrary.outsideAmbience"
			};
			foreach (string key in array)
			{
				table[key] = None;
			}
		}

		private static void A(string key, string text, Cat c, bool danger)
		{
			table[key] = new Info(text, c, danger, s: false);
		}

		private static void E(string key, string text, bool danger)
		{
			table[key] = new Info(text, Cat.Enemies, danger, s: false);
		}

		private static void F(string key, string text)
		{
			table[key] = new Info(text, Cat.Footsteps, d: false, s: false);
		}

		private static void S(string key, string text)
		{
			table[key] = new Info(text, Cat.Items, d: true, s: true);
		}

		internal static void Clear()
		{
			owners.Clear();
			cache.Clear();
			lastForClip.Clear();
			globalClips.Clear();
			globalsFor = null;
		}

		private static Owner GetOwner(AudioSource src)
		{
			int instanceID = ((Object)src).GetInstanceID();
			if (owners.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			value = new Owner();
			value.Item = ((Component)src).GetComponentInParent<GrabbableObject>();
			if ((Object)(object)value.Item == (Object)null)
			{
				value.Enemy = ((Component)src).GetComponentInParent<EnemyAI>();
			}
			if ((Object)(object)value.Item == (Object)null && (Object)(object)value.Enemy == (Object)null)
			{
				value.Player = ((Component)src).GetComponentInParent<PlayerControllerB>();
			}
			HashSet<int> hashSet = new HashSet<int>();
			Transform val = null;
			Transform val2 = ((Component)src).transform;
			int num = 0;
			while ((Object)(object)val2 != (Object)null && num < 8)
			{
				MonoBehaviour[] components = ((Component)val2).GetComponents<MonoBehaviour>();
				foreach (MonoBehaviour val3 in components)
				{
					if ((Object)(object)val3 == (Object)null || !hashSet.Add(((Object)val3).GetInstanceID()))
					{
						continue;
					}
					value.Comps.Add(val3);
					if (val3 is DoorLock)
					{
						value.HasDoorLock = true;
					}
					if (value.SrcField != null)
					{
						continue;
					}
					FieldInfo[] array = SrcFieldsOf(((object)val3).GetType());
					foreach (FieldInfo fieldInfo in array)
					{
						object obj = null;
						try
						{
							obj = fieldInfo.GetValue(val3);
						}
						catch
						{
						}
						if (obj == src)
						{
							value.SrcField = Key(fieldInfo.DeclaringType, fieldInfo.Name, source: true);
							val = val2;
							break;
						}
					}
				}
				if ((Object)(object)val != (Object)null || ((Object)(object)value.Enemy != (Object)null && (Object)(object)val2 == (Object)(object)((Component)value.Enemy).transform) || ((Object)(object)value.Item != (Object)null && (Object)(object)val2 == (Object)(object)((Component)value.Item).transform) || ((Object)(object)value.Player != (Object)null && (Object)(object)val2 == (Object)(object)((Component)value.Player).transform))
				{
					break;
				}
				num++;
				val2 = val2.parent;
			}
			Transform val4 = (((Object)(object)value.Enemy != (Object)null) ? ((Component)value.Enemy).transform : (((Object)(object)value.Item != (Object)null) ? ((Component)value.Item).transform : (((Object)(object)value.Player == (Object)null) ? val : null)));
			if ((Object)(object)val4 != (Object)null)
			{
				MonoBehaviour[] componentsInChildren = ((Component)val4).GetComponentsInChildren<MonoBehaviour>(true);
				if (componentsInChildren.Length <= 400)
				{
					MonoBehaviour[] components = componentsInChildren;
					foreach (MonoBehaviour val5 in components)
					{
						if ((Object)(object)val5 == (Object)null || !hashSet.Add(((Object)val5).GetInstanceID()))
						{
							continue;
						}
						value.Comps.Add(val5);
						if (value.SrcField != null)
						{
							continue;
						}
						FieldInfo[] array = SrcFieldsOf(((object)val5).GetType());
						foreach (FieldInfo fieldInfo2 in array)
						{
							object obj3 = null;
							try
							{
								obj3 = fieldInfo2.GetValue(val5);
							}
							catch
							{
							}
							if (obj3 == src)
							{
								value.SrcField = Key(fieldInfo2.DeclaringType, fieldInfo2.Name, source: true);
								break;
							}
						}
					}
				}
			}
			if (!value.HasDoorLock && (Object)(object)((Component)src).GetComponentInParent<DoorLock>() != (Object)null)
			{
				value.HasDoorLock = true;
			}
			owners[instanceID] = value;
			return value;
		}

		internal static Info Resolve(AudioSource src, AudioClip clip, out EnemyAI enemy, out GrabbableObject item, out PlayerControllerB player)
		{
			Owner owner = GetOwner(src);
			enemy = owner.Enemy;
			item = owner.Item;
			player = owner.Player;
			long key = ((long)((Object)src).GetInstanceID() << 32) ^ (uint)((Object)clip).GetInstanceID();
			if (cache.TryGetValue(key, out var value))
			{
				if (value != None)
				{
					return value;
				}
				return null;
			}
			value = Work(src, clip, owner) ?? None;
			cache[key] = value;
			if (value != None && value.Text != null && !lastForClip.ContainsKey(((Object)clip).GetInstanceID()))
			{
				lastForClip[((Object)clip).GetInstanceID()] = value;
			}
			if (value != None)
			{
				return value;
			}
			return null;
		}

		private static Info Work(AudioSource src, AudioClip clip, Owner o)
		{
			string text = null;
			MonoBehaviour val = null;
			foreach (MonoBehaviour comp in o.Comps)
			{
				if (!((Object)(object)comp == (Object)null))
				{
					string text2 = FindClip((Object)(object)comp, clip);
					if (text2 != null)
					{
						text = text2;
						val = comp;
						break;
					}
				}
			}
			if (text == null && (Object)(object)o.Enemy != (Object)null && (Object)(object)o.Enemy.enemyType != (Object)null)
			{
				text = FindClip((Object)(object)o.Enemy.enemyType, clip);
			}
			if (text == null && (Object)(object)o.Item != (Object)null && (Object)(object)o.Item.itemProperties != (Object)null)
			{
				text = FindClip((Object)(object)o.Item.itemProperties, clip);
			}
			if (text == null)
			{
				BuildGlobals();
				if (globalClips.TryGetValue(((Object)clip).GetInstanceID(), out var value))
				{
					text = value;
				}
			}
			if (text != null && table.TryGetValue(text, out var value2))
			{
				return value2;
			}
			if (o.SrcField != null && table.TryGetValue(o.SrcField, out value2))
			{
				return value2;
			}
			string text3 = (((Object)(object)o.Enemy != (Object)null) ? EnemyName(o.Enemy) : null);
			string text4 = text?.Substring(text.IndexOf('.') + 1);
			string s = (text4 + " " + ((Object)clip).name).ToLowerInvariant();
			if (o.Item is WalkieTalkie && text == null)
			{
				if (lastForClip.TryGetValue(((Object)clip).GetInstanceID(), out var value3))
				{
					return new Info("Walkie: " + value3.Text, value3.Cat, value3.Danger, s: false);
				}
				return null;
			}
			if ((Object)(object)o.Enemy != (Object)null)
			{
				if (text != null && text.StartsWith("EnemyType.", StringComparison.Ordinal))
				{
					switch (text4)
					{
					case "deathSFX":
						return new Info(text3 + " dies", Cat.Enemies, d: false, s: false);
					case "stunSFX":
						return new Info(text3 + " stunned", Cat.Enemies, d: false, s: false);
					case "hitBodySFX":
					case "hitEnemyVoiceSFX":
						return new Info(text3 + " hurt", Cat.Enemies, d: false, s: false);
					}
				}
				if (text4 == "dieSFX")
				{
					return new Info(text3 + " dies", Cat.Enemies, d: false, s: false);
				}
				if (Steppy(s))
				{
					return new Info(text3 + " footsteps", Cat.Footsteps, d: false, s: false);
				}
				if (text4 != null && !(val is PlayAudioAnimationEvent))
				{
					return new Info(text3 + " " + Human(text4), Cat.Enemies, d: false, s: false);
				}
				return new Info(text3 + " noise", Cat.Enemies, d: false, s: false);
			}
			if ((Object)(object)o.Player != (Object)null)
			{
				return null;
			}
			if (val is AnimatedObjectTrigger)
			{
				if (o.HasDoorLock)
				{
					if (text4 == "boolTrueAudios")
					{
						return new Info("Door opens", Cat.Doors, d: false, s: false);
					}
					if (text4 == "boolFalseAudios")
					{
						return new Info("Door closes", Cat.Doors, d: false, s: false);
					}
					return new Info("Door", Cat.Doors, d: false, s: false);
				}
				string text5 = Human(((Object)((Component)val).gameObject).name);
				if (text4 == "boolTrueAudios")
				{
					return new Info(text5 + " opens", Cat.Other, d: false, s: false);
				}
				if (text4 == "boolFalseAudios")
				{
					return new Info(text5 + " closes", Cat.Other, d: false, s: false);
				}
				return new Info(text5, Cat.Other, d: false, s: false);
			}
			if (o.HasDoorLock)
			{
				return new Info("Door", Cat.Doors, d: false, s: false);
			}
			if ((Object)(object)o.Item != (Object)null)
			{
				string text6 = (((Object)(object)o.Item.itemProperties != (Object)null) ? o.Item.itemProperties.itemName : Human(((object)o.Item).GetType().Name));
				if (o.Item is NoisemakerProp)
				{
					return new Info(text6 + " sounds", Cat.Items, d: false, s: false);
				}
				if (text4 != null)
				{
					return new Info(text6 + ": " + Human(text4), Cat.Other, d: false, s: false);
				}
				return null;
			}
			if (text != null)
			{
				return new Info(Human(text4), Cat.Other, d: false, s: false);
			}
			if (lastForClip.TryGetValue(((Object)clip).GetInstanceID(), out var value4))
			{
				return value4;
			}
			return null;
		}

		private static bool Steppy(string s)
		{
			if (!s.Contains("step") && !s.Contains("walk") && !s.Contains("foot") && !s.Contains("stomp"))
			{
				return s.Contains("skip");
			}
			return true;
		}

		internal static string EnemyName(EnemyAI e)
		{
			if (enemyNames.TryGetValue(((object)e).GetType().Name, out var value))
			{
				return value;
			}
			if ((Object)(object)e.enemyType != (Object)null && !string.IsNullOrEmpty(e.enemyType.enemyName))
			{
				return e.enemyType.enemyName;
			}
			return Human(((object)e).GetType().Name.Replace("AI", "").Replace("Enemy", ""));
		}

		private static string FindClip(Object obj, AudioClip clip)
		{
			FieldInfo[] array = ClipFieldsOf(((object)obj).GetType());
			foreach (FieldInfo fieldInfo in array)
			{
				object value;
				try
				{
					value = fieldInfo.GetValue(obj);
				}
				catch
				{
					continue;
				}
				if (value == null)
				{
					continue;
				}
				AudioClip val = (AudioClip)((value is AudioClip) ? value : null);
				if ((Object)(object)val != (Object)null)
				{
					if ((Object)(object)val == (Object)(object)clip)
					{
						return Key(fieldInfo.DeclaringType, fieldInfo.Name, source: false);
					}
				}
				else
				{
					if (!(value is AudioClip[] array2))
					{
						continue;
					}
					for (int j = 0; j < array2.Length; j++)
					{
						if ((Object)(object)array2[j] == (Object)(object)clip)
						{
							return Key(fieldInfo.DeclaringType, fieldInfo.Name, source: false);
						}
					}
				}
			}
			return null;
		}

		private static string Key(Type t, string field, bool source)
		{
			return t.Name + (source ? ".@" : ".") + field;
		}

		private static FieldInfo[] ClipFieldsOf(Type t)
		{
			if (clipFields.TryGetValue(t, out var value))
			{
				return value;
			}
			List<FieldInfo> list = new List<FieldInfo>();
			Type type = t;
			while (type != null && type != typeof(MonoBehaviour) && type != typeof(ScriptableObject) && type != typeof(object))
			{
				FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType == typeof(AudioClip) || fieldInfo.FieldType == typeof(AudioClip[]))
					{
						list.Add(fieldInfo);
					}
				}
				type = type.BaseType;
			}
			value = list.ToArray();
			clipFields[t] = value;
			return value;
		}

		private static FieldInfo[] SrcFieldsOf(Type t)
		{
			if (srcFields.TryGetValue(t, out var value))
			{
				return value;
			}
			List<FieldInfo> list = new List<FieldInfo>();
			Type type = t;
			while (type != null && type != typeof(MonoBehaviour) && type != typeof(object))
			{
				FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType == typeof(AudioSource))
					{
						list.Add(fieldInfo);
					}
				}
				type = type.BaseType;
			}
			value = list.ToArray();
			srcFields[t] = value;
			return value;
		}

		private static void BuildGlobals()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || (object)globalsFor == instance)
			{
				return;
			}
			globalsFor = (Object)(object)instance;
			globalClips.Clear();
			foreach (Object item in new List<Object>
			{
				(Object)(object)instance,
				(Object)(object)SoundManager.Instance,
				(Object)(object)HUDManager.Instance,
				(Object)(object)RoundManager.Instance,
				(Object)(object)TimeOfDay.Instance
			})
			{
				if (item == (Object)null)
				{
					continue;
				}
				FieldInfo[] array = ClipFieldsOf(((object)item).GetType());
				foreach (FieldInfo fieldInfo in array)
				{
					object value;
					try
					{
						value = fieldInfo.GetValue(item);
					}
					catch
					{
						continue;
					}
					string value2 = Key(fieldInfo.DeclaringType, fieldInfo.Name, source: false);
					AudioClip val = (AudioClip)((value is AudioClip) ? value : null);
					if ((Object)(object)val != (Object)null)
					{
						globalClips[((Object)val).GetInstanceID()] = value2;
					}
					else
					{
						if (!(value is AudioClip[] array2))
						{
							continue;
						}
						AudioClip[] array3 = array2;
						foreach (AudioClip val2 in array3)
						{
							if ((Object)(object)val2 != (Object)null)
							{
								globalClips[((Object)val2).GetInstanceID()] = value2;
							}
						}
					}
				}
			}
		}

		internal static string Human(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return "";
			}
			string[] array = new string[9] { "SFX", "Sfx", "Audios", "Audio", "Clips", "Clip", "Sounds", "Sound", "(Clone)" };
			foreach (string text in array)
			{
				if (s.Length > text.Length && s.EndsWith(text, StringComparison.Ordinal))
				{
					s = s.Substring(0, s.Length - text.Length);
					break;
				}
			}
			StringBuilder stringBuilder = new StringBuilder(s.Length + 8);
			for (int j = 0; j < s.Length; j++)
			{
				char c = s[j];
				if (c == '_' || c == '-')
				{
					stringBuilder.Append(' ');
				}
				else if (!char.IsDigit(c))
				{
					if (char.IsUpper(c) && j > 0 && !char.IsUpper(s[j - 1]) && s[j - 1] != ' ')
					{
						stringBuilder.Append(' ');
					}
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			return stringBuilder.ToString().Trim();
		}
	}
	internal class Captions : MonoBehaviour
	{
		private sealed class Cap
		{
			public string Text;

			public string Display;

			public Cat Cat;

			public bool Danger;

			public AudioSource Src;

			public Vector3 Pos;

			public bool Spatial;

			public float Gain;

			public float Born;

			public float Until;

			public float LastHit;

			public bool Muffled;

			public int Count = 1;

			public int Vert;

			public bool Dirty = true;
		}

		private sealed class Watch
		{
			public AudioSource Src;

			public AudioClip Clip;

			public Info Info;
		}

		internal static Captions I;

		private readonly List<Cap> caps = new List<Cap>();

		private readonly List<Watch> watches = new List<Watch>();

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

		private readonly Dictionary<int, AudioSource[]> enemySources = new Dictionary<int, AudioSource[]>();

		private readonly List<AudioSource> hazardSources = new List<AudioSource>();

		private readonly Dictionary<int, AnimationCurve> curves = new Dictionary<int, AnimationCurve>();

		private readonly List<Cap> shown = new List<Cap>();

		private bool[] wasAlive = new bool[0];

		private bool leaveAlert;

		private bool shipLeaving;

		private float nextPoll;

		private float nextHazardScan;

		private static int fails;

		private Texture2D arrow;

		private static readonly Comparison<Cap> order = (Cap a, Cap b) => (a.Danger != b.Danger) ? ((!a.Danger) ? 1 : (-1)) : b.LastHit.CompareTo(a.LastHit);

		private void Awake()
		{
			I = this;
			arrow = MakeArrow();
			SceneManager.sceneUnloaded += delegate
			{
				ClearAll();
			};
		}

		private void ClearAll()
		{
			Sounds.Clear();
			caps.Clear();
			watches.Clear();
			playing.Clear();
			enemySources.Clear();
			hazardSources.Clear();
			curves.Clear();
			nextHazardScan = 0f;
		}

		internal static void Fail(Exception e)
		{
			if (fails++ < 5)
			{
				Plugin.Log.LogWarning((object)("Caption error: " + e));
			}
		}

		private static Transform Listener()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.audioListener == (Object)null)
			{
				return null;
			}
			return ((Component)instance.audioListener).transform;
		}

		private static PlayerControllerB Local()
		{
			GameNetworkManager instance = GameNetworkManager.Instance;
			if (!((Object)(object)instance != (Object)null))
			{
				return null;
			}
			return instance.localPlayerController;
		}

		internal static void Heard(AudioSource src, AudioClip clip, float volumeScale, bool isPlay)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Captions i = I;
			if ((Object)(object)i == (Object)null || (Object)(object)src == (Object)null)
			{
				return;
			}
			if (isPlay)
			{
				i.playing[((Object)src).GetInstanceID()] = ((Object)clip).GetInstanceID();
			}
			if (src.mute)
			{
				return;
			}
			Transform val = Listener();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((!isPlay || !src.loop) && src.spatialBlend >= 0.5f)
			{
				Vector3 val2 = ((Component)src).transform.position - val.position;
				if (((Vector3)(ref val2)).sqrMagnitude > Plugin.MaxDistance.Value * Plugin.MaxDistance.Value)
				{
					return;
				}
			}
			EnemyAI enemy;
			GrabbableObject item;
			PlayerControllerB player;
			Info info = Sounds.Resolve(src, clip, out enemy, out item, out player);
			if (info == null || info.Text == null || !Plugin.CatOn(info.Cat))
			{
				return;
			}
			PlayerControllerB val3 = Local();
			if ((Object)(object)val3 != (Object)null && !info.Self && !Plugin.OwnSounds.Value && (((Object)(object)item != (Object)null) ? ((Object)(object)item.playerHeldBy == (Object)(object)val3) : ((Object)(object)player == (Object)(object)val3)))
			{
				return;
			}
			if (isPlay && src.loop)
			{
				bool flag = false;
				foreach (Watch watch in i.watches)
				{
					if ((Object)(object)watch.Src == (Object)(object)src)
					{
						watch.Clip = clip;
						watch.Info = info;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					i.watches.Add(new Watch
					{
						Src = src,
						Clip = clip,
						Info = info
					});
				}
			}
			i.Try(src, info, volumeScale, val, (isPlay && src.loop) ? 0f : clip.length);
		}

		private void Try(AudioSource src, Info info, float volumeScale, Transform lis, float clipLength)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (Audible(src, volumeScale, lis, out var gain, out var muffled))
			{
				Add(info.Text, info.Cat, info.Danger, src, ((Component)src).transform.position, src.spatialBlend >= 0.5f, gain, muffled, clipLength);
			}
		}

		private bool Audible(AudioSource src, float volumeScale, Transform lis, out float gain, out bool muffled)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			muffled = false;
			float num = (gain = src.volume * volumeScale);
			if (src.spatialBlend < 0.5f)
			{
				return num >= Plugin.MinLoudness.Value;
			}
			Vector3 position = ((Component)src).transform.position;
			Vector3 position2 = lis.position;
			float num2 = Vector3.Distance(position, position2);
			if (num2 > Plugin.MaxDistance.Value)
			{
				gain = 0f;
				return false;
			}
			float num3 = Mathf.Max(0.01f, src.minDistance);
			float num4 = Mathf.Max(num3 + 0.01f, src.maxDistance);
			AudioRolloffMode rolloffMode = src.rolloffMode;
			float num5;
			if ((int)rolloffMode != 1)
			{
				if ((int)rolloffMode == 2)
				{
					int instanceID = ((Object)src).GetInstanceID();
					if (!curves.TryGetValue(instanceID, out var value))
					{
						value = src.GetCustomCurve((AudioSourceCurveType)0);
						curves[instanceID] = value;
					}
					num5 = ((value != null && value.length > 0) ? Mathf.Clamp01(value.Evaluate(Mathf.Clamp01(num2 / num4))) : Mathf.Clamp01(1f - num2 / num4));
				}
				else
				{
					num5 = ((num2 <= num3) ? 1f : ((num2 >= num4) ? 0f : (num3 / num2)));
				}
			}
			else
			{
				num5 = Mathf.Clamp01(1f - (num2 - num3) / (num4 - num3));
			}
			gain = num * Mathf.Lerp(1f, num5, src.spatialBlend);
			if (gain < Plugin.MinLoudness.Value)
			{
				return false;
			}
			StartOfRound instance = StartOfRound.Instance;
			RaycastHit val = default(RaycastHit);
			if (num2 > 1.5f && (Object)(object)instance != (Object)null && Physics.Linecast(position2, position, ref val, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val)).distance < num2 - 1.5f)
			{
				muffled = true;
				gain *= Mathf.Clamp01(Plugin.WallMuffle.Value);
			}
			return gain >= Plugin.MinLoudness.Value;
		}

		private void Add(string text, Cat cat, bool danger, AudioSource src, Vector3 pos, bool spatial, float gain, bool muffled, float clipLength)
		{
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			float num = time + Mathf.Clamp(clipLength, 0f, 6f) + Mathf.Max(0.5f, Plugin.Seconds.Value);
			for (int i = 0; i < caps.Count; i++)
			{
				Cap cap = caps[i];
				if (cap.Text != text)
				{
					continue;
				}
				if ((Object)(object)src != (Object)(object)cap.Src && time - cap.LastHit > 0.35f)
				{
					cap.Count++;
					cap.Dirty = true;
				}
				else if ((Object)(object)src == (Object)(object)cap.Src && clipLength > 0f && time - cap.LastHit > 0.6f)
				{
					cap.Count++;
					cap.Dirty = true;
				}
				if (gain >= cap.Gain * 0.7f || time - cap.LastHit > 0.5f || (Object)(object)cap.Src == (Object)(object)src)
				{
					cap.Src = src;
					cap.Pos = pos;
					cap.Spatial = spatial;
					cap.Gain = gain;
					if (cap.Muffled != muffled)
					{
						cap.Muffled = muffled;
						cap.Dirty = true;
					}
				}
				cap.Until = Mathf.Max(cap.Until, num);
				cap.LastHit = time;
				return;
			}
			if (caps.Count >= 24)
			{
				int index = 0;
				for (int j = 1; j < caps.Count; j++)
				{
					if (caps[j].LastHit < caps[index].LastHit)
					{
						index = j;
					}
				}
				caps.RemoveAt(index);
			}
			caps.Add(new Cap
			{
				Text = text,
				Cat = cat,
				Danger = danger,
				Src = src,
				Pos = pos,
				Spatial = spatial,
				Gain = gain,
				Muffled = muffled,
				Born = time,
				LastHit = time,
				Until = num
			});
		}

		private void Update()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.On.Value)
			{
				if (caps.Count > 0)
				{
					caps.Clear();
				}
				return;
			}
			float time = Time.time;
			for (int num = caps.Count - 1; num >= 0; num--)
			{
				Cap cap = caps[num];
				if (time > cap.Until)
				{
					caps.RemoveAt(num);
				}
				else if ((Object)(object)cap.Src != (Object)null)
				{
					cap.Pos = ((Component)cap.Src).transform.position;
				}
			}
			if (time < nextPoll)
			{
				return;
			}
			nextPoll = time + 0.25f;
			Transform val = Listener();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			try
			{
				PollLoops(val);
				PollSources();
				PollDeaths(val);
				PollAlerts();
			}
			catch (Exception e)
			{
				Fail(e);
			}
		}

		private void PollLoops(Transform lis)
		{
			for (int num = watches.Count - 1; num >= 0; num--)
			{
				Watch watch = watches[num];
				if ((Object)(object)watch.Src == (Object)null || !watch.Src.isPlaying || (Object)(object)watch.Src.clip != (Object)(object)watch.Clip)
				{
					watches.RemoveAt(num);
				}
				else if (!watch.Src.mute && Plugin.CatOn(watch.Info.Cat))
				{
					Try(watch.Src, watch.Info, 1f, lis, 0f);
				}
			}
		}

		private void PollSources()
		{
			RoundManager instance = RoundManager.Instance;
			if ((Object)(object)instance != (Object)null && instance.SpawnedEnemies != null)
			{
				foreach (EnemyAI spawnedEnemy in instance.SpawnedEnemies)
				{
					if (!((Object)(object)spawnedEnemy == (Object)null))
					{
						int instanceID = ((Object)spawnedEnemy).GetInstanceID();
						if (!enemySources.TryGetValue(instanceID, out var value))
						{
							value = ((Component)spawnedEnemy).GetComponentsInChildren<AudioSource>(true);
							enemySources[instanceID] = value;
						}
						AudioSource[] array = value;
						foreach (AudioSource s in array)
						{
							Check(s);
						}
					}
				}
			}
			float time = Time.time;
			if (time >= nextHazardScan)
			{
				nextHazardScan = time + 5f;
				hazardSources.Clear();
				Turret[] array2 = Object.FindObjectsOfType<Turret>();
				foreach (Turret val in array2)
				{
					hazardSources.AddRange(((Component)val).GetComponentsInChildren<AudioSource>(true));
				}
				SpikeRoofTrap[] array3 = Object.FindObjectsOfType<SpikeRoofTrap>();
				foreach (SpikeRoofTrap val2 in array3)
				{
					hazardSources.AddRange(((Component)val2).GetComponentsInChildren<AudioSource>(true));
				}
				ShipAlarmCord[] array4 = Object.FindObjectsOfType<ShipAlarmCord>();
				foreach (ShipAlarmCord val3 in array4)
				{
					hazardSources.AddRange(((Component)val3).GetComponentsInChildren<AudioSource>(true));
				}
			}
			foreach (AudioSource hazardSource in hazardSources)
			{
				Check(hazardSource);
			}
		}

		private void Check(AudioSource s)
		{
			if ((Object)(object)s == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)s).GetInstanceID();
			AudioClip clip = s.clip;
			int num = ((s.isPlaying && (Object)(object)clip != (Object)null) ? ((Object)clip).GetInstanceID() : 0);
			playing.TryGetValue(instanceID, out var value);
			if (num != value)
			{
				playing[instanceID] = num;
				if (num != 0)
				{
					Heard(s, clip, 1f, isPlay: true);
				}
			}
		}

		private void PollDeaths(Transform lis)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			if (wasAlive.Length != allPlayerScripts.Length)
			{
				wasAlive = new bool[allPlayerScripts.Length];
			}
			PlayerControllerB val = Local();
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				PlayerControllerB val2 = allPlayerScripts[i];
				bool flag = (Object)(object)val2 != (Object)null && val2.isPlayerControlled && !val2.isPlayerDead;
				if (wasAlive[i] && (Object)(object)val2 != (Object)null && val2.isPlayerDead && (Object)(object)val2 != (Object)(object)val && !instance.inShipPhase && Plugin.Teammates.Value)
				{
					Vector3 val3 = ((val2.placeOfDeath != Vector3.zero) ? val2.placeOfDeath : ((Component)val2).transform.position);
					float num = Vector3.Distance(val3, lis.position);
					if (num <= Plugin.TeammateDeathRange.Value)
					{
						bool muffled = num > 1.5f && Physics.Linecast(lis.position, val3 + Vector3.up, ref val4, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val4)).distance < num - 1.5f;
						string text = (string.IsNullOrEmpty(val2.playerUsername) ? "A teammate" : val2.playerUsername);
						Add(text + " died", Cat.Teammates, danger: true, null, val3, spatial: true, 1f - num / Mathf.Max(1f, Plugin.TeammateDeathRange.Value) * 0.6f, muffled, 3f);
					}
				}
				wasAlive[i] = flag;
			}
		}

		private void PollAlerts()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			TimeOfDay instance = TimeOfDay.Instance;
			StartOfRound instance2 = StartOfRound.Instance;
			bool flag = (Object)(object)instance != (Object)null && instance.shipLeavingAlertCalled;
			bool flag2 = (Object)(object)instance2 != (Object)null && instance2.shipIsLeaving;
			if (Plugin.Ship.Value)
			{
				if (flag && !leaveAlert)
				{
					Add("Ship leaving soon - get back!", Cat.Ship, danger: true, null, Vector3.zero, spatial: false, 1f, muffled: false, 4f);
				}
				if (flag2 && !shipLeaving)
				{
					Add("Ship is leaving!", Cat.Ship, danger: true, null, Vector3.zero, spatial: false, 1f, muffled: false, 4f);
				}
			}
			leaveAlert = flag;
			shipLeaving = flag2;
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7 || !Plugin.On.Value || caps.Count == 0)
			{
				return;
			}
			Transform val = Listener();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_ = HUDManager.Instance;
			V.Begin(Mathf.Clamp(Plugin.Scale.Value, 0.5f, 3f));
			float s = V.S;
			float num = Mathf.Clamp(Plugin.TextSize.Value, 10f, 40f);
			float time = Time.time;
			shown.Clear();
			shown.AddRange(caps);
			shown.Sort(order);
			int num2 = Mathf.Min(shown.Count, Mathf.Max(1, Plugin.MaxLines.Value));
			Vector3 fwd = val.forward;
			fwd.y = 0f;
			if (((Vector3)(ref fwd)).sqrMagnitude < 0.0001f)
			{
				fwd = val.up;
			}
			fwd.y = 0f;
			((Vector3)(ref fwd)).Normalize();
			float num3 = (num + 12f) * s;
			float num4 = num3;
			float num5 = 10f * s;
			float num6 = 0f;
			for (int i = 0; i < num2; i++)
			{
				Cap cap = shown[i];
				int num7 = 0;
				if (cap.Spatial)
				{
					Vector3 val2 = cap.Pos - val.position;
					Vector2 val3 = new Vector2(val2.x, val2.z);
					float magnitude = ((Vector2)(ref val3)).magnitude;
					if (Mathf.Abs(val2.y) > 4f && Mathf.Abs(val2.y) > magnitude)
					{
						num7 = ((val2.y > 0f) ? 1 : (-1));
					}
				}
				if (num7 != cap.Vert)
				{
					cap.Vert = num7;
					cap.Dirty = true;
				}
				if (cap.Dirty)
				{
					string text = cap.Text;
					if (cap.Count > 1)
					{
						text = text + "  x" + Num.Of(cap.Count);
					}
					if (cap.Vert > 0)
					{
						text += "  (above)";
					}
					else if (cap.Vert < 0)
					{
						text += "  (below)";
					}
					if (cap.Muffled && Plugin.ShowMuffled.Value)
					{
						text += "  (muffled)";
					}
					cap.Display = text.ToUpperInvariant();
					cap.Dirty = false;
				}
				num6 = Mathf.Max(num6, V.Width(cap.Display, num));
			}
			float num8 = num6 + num4 + num5 * 2.5f;
			float num9 = (float)num2 * num3 + num5;
			float num10 = Plugin.OffsetX.Value * s;
			float num11 = Plugin.OffsetY.Value * s;
			float num12;
			float num13;
			switch (Plugin.Corner.Value)
			{
			case "BottomLeft":
				num12 = num10;
				num13 = (float)Screen.height - num11 - num9;
				break;
			case "TopRight":
				num12 = (float)Screen.width - num10 - num8;
				num13 = num11;
				break;
			case "TopLeft":
				num12 = num10;
				num13 = num11;
				break;
			case "BottomCenter":
				num12 = ((float)Screen.width - num8) / 2f;
				num13 = (float)Screen.height - num11 - num9;
				break;
			default:
				num12 = (float)Screen.width - num10 - num8;
				num13 = (float)Screen.height - num11 - num9;
				break;
			}
			V.Panel(new Rect(num12, num13, num8, num9), 0.55f);
			float num14 = (float)Screen.width / 2f;
			float num15 = (float)Screen.height / 2f;
			Rect val5 = default(Rect);
			Rect r = default(Rect);
			Rect r2 = default(Rect);
			for (int j = 0; j < num2; j++)
			{
				Cap cap2 = shown[j];
				float num16 = Mathf.Clamp01((cap2.Until - time) / 1f) * Mathf.Clamp01((time - cap2.Born) / 0.12f + 0.3f);
				float num17 = Mathf.Lerp(0.5f, 1f, Mathf.Clamp01(cap2.Gain / 0.45f));
				float num18 = num16 * num17;
				Color val4 = (cap2.Danger ? V.Red : ((cap2.Cat == Cat.Ship) ? V.Gold : (cap2.Muffled ? V.OrangeDim : V.Orange)));
				if (cap2.Danger && cap2.Muffled)
				{
					val4 = Color.Lerp(V.Red, V.OrangeDim, 0.35f);
				}
				val4.a = num18;
				if (time - cap2.LastHit < 0.4f)
				{
					V.Fill(new Rect(num12 + 2f * s, num13 + num5 * 0.5f + (float)j * num3 + 3f * s, 3f * s, num3 - 6f * s), new Color(val4.r, val4.g, val4.b, num18 * (1f - (time - cap2.LastHit) / 0.4f)));
				}
				((Rect)(ref val5))..ctor(num12 + num5, num13 + num5 * 0.5f + (float)j * num3, num8 - num5 * 2f, num3);
				((Rect)(ref r))..ctor(((Rect)(ref val5)).x, ((Rect)(ref val5)).y + (num3 - num4 * 0.62f) / 2f, num4 * 0.62f, num4 * 0.62f);
				if (cap2.Spatial)
				{
					float num19 = Angle(fwd, cap2.Pos - val.position);
					DrawArrow(r, num19, val4);
					if (cap2.Danger && Plugin.CrosshairArrows.Value)
					{
						float num20 = 90f * s;
						float num21 = num19 * ((float)Math.PI / 180f);
						float num22 = 22f * s;
						((Rect)(ref r2))..ctor(num14 + Mathf.Sin(num21) * num20 - num22 / 2f, num15 - Mathf.Cos(num21) * num20 - num22 / 2f, num22, num22);
						DrawArrow(r2, num19, new Color(V.Red.r, V.Red.g, V.Red.b, num18 * 0.9f));
					}
				}
				else
				{
					float num23 = 6f * s;
					V.Fill(new Rect(((Rect)(ref r)).center.x - num23 / 2f, ((Rect)(ref r)).center.y - num23 / 2f, num23, num23), val4);
				}
				V.Text(new Rect(((Rect)(ref val5)).x + num4, ((Rect)(ref val5)).y, ((Rect)(ref val5)).width - num4, num3), cap2.Display, num, val4, (TextAnchor)3);
			}
			V.End();
		}

		private static float Angle(Vector3 fwd, Vector3 to)
		{
			//IL_0020: 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)
			to.y = 0f;
			if (((Vector3)(ref to)).sqrMagnitude < 0.0001f)
			{
				return 0f;
			}
			return Vector3.SignedAngle(fwd, ((Vector3)(ref to)).normalized, Vector3.up);
		}

		private void DrawArrow(Rect r, float angle, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 matrix = GUI.matrix;
			GUIUtility.RotateAroundPivot(angle, ((Rect)(ref r)).center);
			GUI.color = new Color(V.Ink.r, V.Ink.g, V.Ink.b, c.a * 0.8f);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x + 1.5f * V.S, ((Rect)(ref r)).y + 1.5f * V.S, ((Rect)(ref r)).width, ((Rect)(ref r)).height), (Texture)(object)arrow);
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)arrow);
			GUI.matrix = matrix;
		}

		private static Texture2D MakeArrow()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0060: 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_0062: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(48, 48, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[2304];
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(24f, 3f);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(43f, 44f);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(5f, 44f);
			Vector2 inside = (val2 + val3 + val4) / 3f;
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(12f, 46f);
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(36f, 46f);
			Vector2 val7 = default(Vector2);
			((Vector2)(ref val7))..ctor(24f, 33f);
			Vector2 inside2 = (val5 + val6 + val7) / 3f;
			Vector2 p = default(Vector2);
			for (int i = 0; i < 48; i++)
			{
				for (int j = 0; j < 48; j++)
				{
					((Vector2)(ref p))..ctor((float)j + 0.5f, 48f - ((float)i + 0.5f));
					float num = Mathf.Max(Edge(p, val2, val3, inside), Mathf.Max(Edge(p, val3, val4, inside), Edge(p, val4, val2, inside)));
					float num2 = Mathf.Max(Edge(p, val5, val6, inside2), Mathf.Max(Edge(p, val6, val7, inside2), Edge(p, val7, val5, inside2)));
					num = Mathf.Max(num, 0f - num2);
					byte b = (byte)(Mathf.Clamp01(0.5f - num) * 255f);
					array[i * 48 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return val;
		}

		private static float Edge(Vector2 p, Vector2 a, Vector2 b, Vector2 inside)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = b - a;
			Vector2 val2 = new Vector2(val.y, 0f - val.x);
			Vector2 val3 = ((Vector2)(ref val2)).normalized;
			if (Vector2.Dot(inside - a, val3) > 0f)
			{
				val3 = -val3;
			}
			return Vector2.Dot(p - a, val3);
		}
	}
}