Decompiled source of NeonHUDv1 v1.0.0

NeonHUD.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using NeonHud.Core;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("NeonHUD")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0")]
[assembly: AssemblyProduct("NeonHUD")]
[assembly: AssemblyTitle("NeonHUD")]
[assembly: AssemblyVersion("1.5.0.0")]
namespace NeonHud
{
	internal sealed class SpectrumAnalyzer
	{
		private const int FftSize = 1024;

		private readonly float[] _fft = new float[1024];

		private readonly float[] _wave = new float[256];

		private readonly int[] _edges;

		private readonly float[] _hold = new float[16];

		public SpectrumAnalyzer()
		{
			int num = 16;
			_edges = new int[num + 1];
			for (int i = 0; i <= num; i++)
			{
				_edges[i] = (int)Math.Round(2.0 * Math.Pow(350.0, (double)i / (double)num));
				if (i > 0 && _edges[i] <= _edges[i - 1])
				{
					_edges[i] = _edges[i - 1] + 1;
				}
			}
		}

		public void Update(HudState s, float dt, float gainDb)
		{
			AudioListener.GetSpectrumData(_fft, 0, (FFTWindow)5);
			for (int i = 0; i < 16; i++)
			{
				float num = 0f;
				for (int j = _edges[i]; j < _edges[i + 1] && j < 1024; j++)
				{
					if (_fft[j] > num)
					{
						num = _fft[j];
					}
				}
				float num2 = M01((20f * (float)Math.Log10(num + 1E-09f) + (float)i * 1.2f + gainDb + 72f) / 60f);
				float num3 = s.Spectrum[i];
				num3 = ((num2 > num3) ? (num3 + (num2 - num3) * 0.6f) : Math.Max(num2, num3 - dt * 1.8f));
				s.Spectrum[i] = num3;
				if (num3 >= s.Peaks[i])
				{
					s.Peaks[i] = num3;
					_hold[i] = 0.45f;
				}
				else if (_hold[i] > 0f)
				{
					_hold[i] -= dt;
				}
				else
				{
					s.Peaks[i] = Math.Max(num3, s.Peaks[i] - dt * 0.55f);
				}
			}
			AudioListener.GetOutputData(_wave, 0);
			float num4 = 0f;
			for (int k = 0; k < _wave.Length; k++)
			{
				num4 += _wave[k] * _wave[k];
			}
			float num5 = (float)Math.Sqrt(num4 / (float)_wave.Length);
			s.SetLevel(Math.Max(-80f, 20f * (float)Math.Log10(num5 + 1E-09f)));
		}

		public static void Clear(HudState s)
		{
			for (int i = 0; i < 16; i++)
			{
				s.Spectrum[i] = 0f;
				s.Peaks[i] = 0f;
			}
			s.SetLevel(-80f);
		}

		private static float M01(float v)
		{
			if (!(v < 0f))
			{
				if (!(v > 1f))
				{
					return v;
				}
				return 1f;
			}
			return 0f;
		}
	}
	internal static class DevDump
	{
		private static readonly string[] Keywords = new string[10] { "speed", "velocity", "timer", "time", "clock", "song", "music", "bgm", "track", "ball" };

		private const int MaxLines = 20000;

		public static string Write()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder sb = new StringBuilder(65536);
			int lines = 0;
			Action<string> action = delegate(string s)
			{
				if (lines++ < 20000)
				{
					sb.Append(s).Append('\n');
				}
			};
			action("NeonHUD dump  " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
			string[] obj = new string[8] { "Scene: ", null, null, null, null, null, null, null };
			Scene activeScene = SceneManager.GetActiveScene();
			obj[1] = ((Scene)(ref activeScene)).name;
			obj[2] = "   Screen: ";
			obj[3] = Screen.width.ToString();
			obj[4] = "x";
			obj[5] = Screen.height.ToString();
			obj[6] = "   Unity ";
			obj[7] = Application.unityVersion;
			action(string.Concat(obj));
			action("");
			List<Transform> list = new List<Transform>();
			Object[] array = Object.FindObjectsOfType(typeof(Transform));
			foreach (Object obj2 in array)
			{
				Transform val = (Transform)(object)((obj2 is Transform) ? obj2 : null);
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			List<Transform> list2 = new List<Transform>();
			foreach (Transform item in list)
			{
				if ((Object)(object)item.parent == (Object)null)
				{
					list2.Add(item);
				}
			}
			list2.Sort((Transform a, Transform b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name));
			action("=== TEXT OBJECTS (paste a line's spec into Data.*Source) ===");
			foreach (Transform item2 in list2)
			{
				WalkText(item2, Path(item2), action);
			}
			action("");
			action("=== OBJECTS WITH KEYWORD NAMES (track:/ui: candidates) ===");
			foreach (Transform item3 in list)
			{
				if (Matches(((Object)item3).name.ToLowerInvariant()))
				{
					action("track:" + Path(item3) + "    components: " + Components(((Component)item3).gameObject));
				}
			}
			action("");
			action("=== PLAYING AUDIO ===");
			array = Object.FindObjectsOfType(typeof(AudioSource));
			foreach (Object obj3 in array)
			{
				AudioSource val2 = (AudioSource)(object)((obj3 is AudioSource) ? obj3 : null);
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.clip == (Object)null))
				{
					action((val2.isPlaying ? "[playing] " : "[stopped] ") + ((Object)val2.clip).name + "  len=" + val2.clip.length.ToString("0.0") + "s loop=" + val2.loop + "  on " + Path(((Component)val2).transform));
				}
			}
			action("");
			action("=== LOADED FONTS (for General.FontName) ===");
			SortedDictionary<string, bool> sortedDictionary = new SortedDictionary<string, bool>();
			array = Resources.FindObjectsOfTypeAll(typeof(Font));
			foreach (Object val3 in array)
			{
				sortedDictionary[val3.name] = true;
			}
			foreach (string key in sortedDictionary.Keys)
			{
				action("  " + key);
			}
			action("");
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				string name = assembly.GetName().Name;
				if (!(name != "Assembly-CSharp") || name.StartsWith("LLB", StringComparison.OrdinalIgnoreCase))
				{
					action("=== MEMBERS IN " + name + " (reflect: = static, find: = on a scene object) ===");
					DumpMembers(assembly, action);
					action("");
				}
			}
			action("=== FULL HIERARCHY (active objects) ===");
			foreach (Transform item4 in list2)
			{
				WalkAll(item4, 0, action);
			}
			if (lines >= 20000)
			{
				sb.Append("... truncated at " + 20000 + " lines\n");
			}
			string text = System.IO.Path.Combine(Paths.BepInExRootPath, "NeonHUD_dump.txt");
			File.WriteAllText(text, sb.ToString());
			return text;
		}

		private static bool Matches(string lower)
		{
			string[] keywords = Keywords;
			foreach (string value in keywords)
			{
				if (lower.IndexOf(value, StringComparison.Ordinal) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static string Path(Transform t)
		{
			List<string> list = new List<string>();
			Transform val = t;
			while ((Object)(object)val != (Object)null)
			{
				list.Add(((Object)val).name);
				val = val.parent;
			}
			list.Reverse();
			return string.Join("/", list.ToArray());
		}

		private static string Components(GameObject go)
		{
			List<string> list = new List<string>();
			Component[] components = go.GetComponents<Component>();
			foreach (Component val in components)
			{
				list.Add(((Object)(object)val == (Object)null) ? "<missing>" : ((object)val).GetType().Name);
			}
			return string.Join(", ", list.ToArray());
		}

		private static void WalkText(Transform t, string path, Action<string> L)
		{
			Component[] components = ((Component)t).GetComponents<Component>();
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null || !TextAccess.Find(((object)val).GetType(), out var prop, out var field))
				{
					continue;
				}
				object obj = null;
				try
				{
					obj = (((object)prop != null) ? prop.GetValue(val, null) : field.GetValue(val));
				}
				catch
				{
				}
				string text = obj as string;
				if (text != null)
				{
					if (text.Length > 60)
					{
						text = text.Substring(0, 60) + "...";
					}
					L("ui:" + path + "    [" + ((object)val).GetType().Name + "]  \"" + text.Replace("\n", "\\n") + "\"" + (((Component)t).gameObject.activeInHierarchy ? "" : "  (inactive)"));
				}
			}
			for (int j = 0; j < t.childCount; j++)
			{
				Transform child = t.GetChild(j);
				WalkText(child, path + "/" + ((Object)child).name, L);
			}
		}

		private static void WalkAll(Transform t, int depth, Action<string> L)
		{
			L(new string(' ', depth * 2) + ((Object)t).name + (((Component)t).gameObject.activeInHierarchy ? "" : " [inactive]") + "  {" + Components(((Component)t).gameObject) + "}");
			for (int i = 0; i < t.childCount; i++)
			{
				WalkAll(t.GetChild(i), depth + 1, L);
			}
		}

		private static void DumpMembers(Assembly asm, Action<string> L)
		{
			Type[] types;
			try
			{
				types = asm.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				types = ex.Types;
			}
			Type[] array = types;
			foreach (Type type in array)
			{
				if ((object)type == null)
				{
					continue;
				}
				bool flag = Matches(type.Name.ToLowerInvariant());
				string fullName = type.FullName;
				string text = "reflect:" + fullName + "::";
				string text2 = (typeof(Object).IsAssignableFrom(type) ? ("find:" + fullName + "::") : null);
				FieldInfo[] fields;
				PropertyInfo[] properties;
				MethodInfo[] methods;
				try
				{
					fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				}
				catch
				{
					continue;
				}
				FieldInfo[] array2 = fields;
				foreach (FieldInfo fieldInfo in array2)
				{
					if (flag || Matches(fieldInfo.Name.ToLowerInvariant()))
					{
						string text3 = (fieldInfo.IsStatic ? text : text2);
						if (text3 != null)
						{
							L(text3 + fieldInfo.Name + "    : " + fieldInfo.FieldType.Name);
						}
					}
				}
				PropertyInfo[] array3 = properties;
				foreach (PropertyInfo propertyInfo in array3)
				{
					MethodInfo getMethod = propertyInfo.GetGetMethod(nonPublic: true);
					if ((object)getMethod != null && propertyInfo.GetIndexParameters().Length == 0 && (flag || Matches(propertyInfo.Name.ToLowerInvariant())))
					{
						string text4 = (getMethod.IsStatic ? text : text2);
						if (text4 != null)
						{
							L(text4 + propertyInfo.Name + "    : " + propertyInfo.PropertyType.Name + " (property)");
						}
					}
				}
				MethodInfo[] array4 = methods;
				foreach (MethodInfo methodInfo in array4)
				{
					if (!methodInfo.IsStatic || (object)methodInfo.ReturnType == typeof(void) || methodInfo.IsSpecialName || !Matches(methodInfo.Name.ToLowerInvariant()))
					{
						continue;
					}
					ParameterInfo[] parameters = methodInfo.GetParameters();
					bool flag2 = true;
					List<string> list = new List<string>();
					ParameterInfo[] array5 = parameters;
					for (int k = 0; k < array5.Length; k++)
					{
						Type parameterType = array5[k].ParameterType;
						if (!parameterType.IsPrimitive && !parameterType.IsEnum && (object)parameterType != typeof(string))
						{
							flag2 = false;
							break;
						}
						list.Add(parameterType.Name);
					}
					if (flag2)
					{
						L(text + methodInfo.Name + "(" + string.Join(",", list.ToArray()) + ")    : " + methodInfo.ReturnType.Name + " (method)");
					}
				}
			}
		}
	}
	public enum HudAnchor
	{
		Bottom,
		Top
	}
	public enum HudLayout
	{
		Compact,
		Full
	}
	internal sealed class HudConfig
	{
		public const string LlbSpeed = "feed|find:LLScreen.ScreenGameHud::shownSpeedTarget";

		public const string LlbTimer = "feed|reflect:World::GetTimeLeftSecs()|elapsed";

		public const string LlbSong = "feed|find:LLScreen.ScreenGameHud::lbTrack.text|reflect:LLHandlers.AudioHandler::GetCurrentMusic()|audio|scene";

		public const string LlbVanillaHud = "find:LLScreen.ScreenGameHud::rtBoomBox";

		public const string LlbVanillaPlayers = "find:LLScreen.ScreenGameHud::playerInfos[0]; find:LLScreen.ScreenGameHud::playerInfos[1]; find:LLScreen.ScreenGameHud::playerInfos[2]; find:LLScreen.ScreenGameHud::playerInfos[3]";

		private const string V11VanillaHud = "find:LLScreen.ScreenGameHud::imtextSpeed; find:LLScreen.ScreenGameHud::imtextTime; find:LLScreen.ScreenGameHud::lbTrack";

		private const int CurrentConfigVersion = 3;

		public readonly ConfigEntry<bool> Enabled;

		public readonly ConfigEntry<bool> OnlyInMatch;

		public readonly ConfigEntry<bool> HideVanillaHud;

		public readonly ConfigEntry<KeyboardShortcut> ToggleKey;

		public readonly ConfigEntry<KeyboardShortcut> DemoKey;

		public readonly ConfigEntry<KeyboardShortcut> DumpKey;

		public readonly ConfigEntry<KeyboardShortcut> ReloadKey;

		public readonly ConfigEntry<KeyboardShortcut> VanillaKey;

		public readonly ConfigEntry<HudAnchor> Anchor;

		public readonly ConfigEntry<HudLayout> Layout;

		public readonly ConfigEntry<float> Scale;

		public readonly ConfigEntry<float> OffsetX;

		public readonly ConfigEntry<float> OffsetY;

		public readonly ConfigEntry<float> Opacity;

		public readonly ConfigEntry<string> FontName;

		public readonly ConfigEntry<string> ShowInScenes;

		public readonly ConfigEntry<string> HideInScenes;

		public readonly ConfigEntry<string> MatchScreenType;

		public readonly ConfigEntry<string> VanillaHudElements;

		public readonly ConfigEntry<string> HideVanillaObjects;

		public readonly ConfigEntry<string> VanillaPlayerElements;

		public readonly ConfigEntry<bool> PlayerCards;

		public readonly ConfigEntry<bool> PlayerBand;

		public readonly ConfigEntry<float> PlayerCardsOffsetY;

		public readonly ConfigEntry<float> PlayerCardsScale;

		public readonly ConfigEntry<string> TeamRed;

		public readonly ConfigEntry<string> TeamBlue;

		public readonly ConfigEntry<string> TeamYellow;

		public readonly ConfigEntry<string> TeamGreen;

		public readonly ConfigEntry<ThemePreset> Preset;

		public readonly ConfigEntry<string> Background;

		public readonly ConfigEntry<string> Primary;

		public readonly ConfigEntry<string> Secondary;

		public readonly ConfigEntry<string> Accent;

		public readonly ConfigEntry<string> Warn;

		public readonly ConfigEntry<string> TextColour;

		public readonly ConfigEntry<string> Title;

		public readonly ConfigEntry<string> HitColour;

		public readonly ConfigEntry<string> GhostColour;

		public readonly ConfigEntry<bool> Scanlines;

		public readonly ConfigEntry<bool> Chromatic;

		public readonly ConfigEntry<bool> Glitch;

		public readonly ConfigEntry<bool> Spectrum;

		public readonly ConfigEntry<bool> DataLog;

		public readonly ConfigEntry<bool> ReactiveColours;

		public readonly ConfigEntry<bool> JapaneseAccents;

		public readonly ConfigEntry<bool> ReleaseMeter;

		public readonly ConfigEntry<float> SpectrumGainDb;

		public readonly ConfigEntry<float> ReleaseWindow;

		public readonly ConfigEntry<string> ReducedColour;

		public readonly ConfigEntry<string> SpeedSource;

		public readonly ConfigEntry<string> TimerSource;

		public readonly ConfigEntry<string> SongSource;

		public readonly ConfigEntry<string> ReleaseSource;

		public readonly ConfigEntry<float> SpeedMultiplier;

		public readonly ConfigEntry<float> TimerMultiplier;

		public readonly ConfigEntry<float> Tier1;

		public readonly ConfigEntry<float> Tier2;

		public readonly ConfigEntry<float> Tier3;

		public readonly ConfigEntry<float> SpeedBarMax;

		public readonly ConfigEntry<float> TimerWarnSeconds;

		public readonly ConfigEntry<bool> TimerCountsDown;

		private readonly ConfigEntry<int> ConfigVersion;

		private const string SourceHelp = "Where the value comes from. Try several with '|', first that gives a usable value wins.\n  feed                     - pushed by another plugin via NeonHud.NeonHudFeed\n  reflect:Type::a.b[0].c   - static member path (fields, properties, Method(1) calls, [i] indexers)\n  find:Type::a.b           - member path on Object.FindObjectOfType(Type)\n  ui:Path/To/TextObject    - read the text of a vanilla HUD label\n  track:Path/To/Object     - (speed) how fast that object moves\n  elapsed                  - (timer) seconds since the scene loaded\n  audio / scene            - (song) longest playing music clip / scene name\n  static:TEXT | none\nPress the dump key in a match to get copy-paste candidates in BepInEx/NeonHUD_dump.txt.";

		private static readonly KeyCode[] NoModifiers = (KeyCode[])(object)new KeyCode[0];

		private static readonly object[] NoTags = new object[0];

		private static KeyboardShortcut Key(KeyCode key)
		{
			//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)
			return new KeyboardShortcut(key, NoModifiers);
		}

		private static ConfigDescription Range(string description, float min, float max)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			return new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), NoTags);
		}

		public HudConfig(ConfigFile cfg)
		{
			//IL_006f: 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_00b9: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			Enabled = cfg.Bind<bool>("General", "Enabled", true, "Master switch.");
			OnlyInMatch = cfg.Bind<bool>("General", "OnlyInMatch", true, "Only show the HUD during a match (while MatchScreenType exists). Demo mode always shows.");
			MatchScreenType = cfg.Bind<string>("General", "MatchScreenType", "LLScreen.ScreenGameHud", "Type whose presence means a match is running.");
			ToggleKey = cfg.Bind<KeyboardShortcut>("General", "ToggleKey", Key((KeyCode)288), "Show/hide the HUD.");
			VanillaKey = cfg.Bind<KeyboardShortcut>("General", "VanillaHudKey", Key((KeyCode)289), "Toggle hiding the game's own speed/timer/track display (saved to HideVanillaHud).");
			DemoKey = cfg.Bind<KeyboardShortcut>("General", "DemoKey", Key((KeyCode)291), "Toggle demo data (preview the HUD without linking anything).");
			DumpKey = cfg.Bind<KeyboardShortcut>("General", "DumpKey", Key((KeyCode)290), "Write BepInEx/NeonHUD_dump.txt with linkable objects and members.");
			ReloadKey = cfg.Bind<KeyboardShortcut>("General", "ReloadKey", Key((KeyCode)287), "Reload this config file from disk without restarting.");
			Anchor = cfg.Bind<HudAnchor>("General", "Anchor", HudAnchor.Bottom, "Screen edge the HUD sits on.");
			Layout = cfg.Bind<HudLayout>("General", "Layout", HudLayout.Compact, "Compact = small HUD (release meter, song, speed, timer, slim spectrum) and slim player cards. Full = the big layout with telemetry and decoration.");
			Scale = cfg.Bind<float>("General", "Scale", 1f, Range("Size of the bottom HUD (1 = designed for 1080p, scales with resolution). Try 0.8 for smaller.", 0.3f, 3f));
			OffsetX = cfg.Bind<float>("General", "OffsetX", 0f, "Horizontal nudge in 1080p pixels.");
			OffsetY = cfg.Bind<float>("General", "OffsetY", 12f, "Distance from the anchored edge in 1080p pixels.");
			Opacity = cfg.Bind<float>("General", "Opacity", 1f, Range("Overall HUD opacity.", 0.1f, 1f));
			FontName = cfg.Bind<string>("General", "FontName", "", "Font for HUD text: a font the game has loaded (see dump) or an installed OS font. Empty = Unity default.");
			ShowInScenes = cfg.Bind<string>("General", "ShowInScenes", "", "Comma list of scene names to show the HUD in. Empty = all scenes.");
			HideInScenes = cfg.Bind<string>("General", "HideInScenes", "", "Comma list of scene names to never show the HUD in (e.g. menus).");
			HideVanillaHud = cfg.Bind<bool>("General", "HideVanillaHud", false, "Hide the game's own bottom HUD cluster (speed, timer, track, hitstun bars) while NeonHUD shows. F8 toggles.");
			VanillaHudElements = cfg.Bind<string>("General", "VanillaHudElements", "find:LLScreen.ScreenGameHud::rtBoomBox", "What HideVanillaHud hides: ';'-separated member paths (find:/reflect:) or GameObject paths.");
			HideVanillaObjects = cfg.Bind<string>("General", "HideVanillaObjects", "", "Extra GameObject paths (from the dump) hidden along with VanillaHudElements.");
			VanillaPlayerElements = cfg.Bind<string>("General", "VanillaPlayerElements", "find:LLScreen.ScreenGameHud::playerInfos[0]; find:LLScreen.ScreenGameHud::playerInfos[1]; find:LLScreen.ScreenGameHud::playerInfos[2]; find:LLScreen.ScreenGameHud::playerInfos[3]", "The game's player panels, hidden by F8 while NeonHUD's player cards are on.");
			PlayerCards = cfg.Bind<bool>("PlayerCards", "Enabled", true, "Neon player cards along the top: HP (with ball-threat overlay and LETHAL warning), energy, stocks/points.");
			PlayerBand = cfg.Bind<bool>("PlayerCards", "Background", true, "Dark background band behind the player cards.");
			PlayerCardsOffsetY = cfg.Bind<float>("PlayerCards", "OffsetY", 0f, "Move the cards down from the top edge (1080p pixels).");
			PlayerCardsScale = cfg.Bind<float>("PlayerCards", "Scale", 1f, Range("Size of the player cards, separate from the bottom HUD's Scale.", 0.3f, 3f));
			TeamRed = cfg.Bind<string>("PlayerCards", "TeamRed", "#FF3B4E", "Custom preset only. Team colours, in the game's team order.");
			TeamBlue = cfg.Bind<string>("PlayerCards", "TeamBlue", "#2FA8FF", "");
			TeamYellow = cfg.Bind<string>("PlayerCards", "TeamYellow", "#FCEE0A", "");
			TeamGreen = cfg.Bind<string>("PlayerCards", "TeamGreen", "#39FF5A", "");
			Preset = cfg.Bind<ThemePreset>("Theme", "Preset", ThemePreset.Mono, "Mono = black & white with purple highlights. Neon = cyan / magenta / yellow. Custom = use the colours below (they start as the Neon values).");
			Background = cfg.Bind<string>("Theme", "Background", "#07070DE0", "Custom preset only. Panel fill, #RRGGBB or #RRGGBBAA.");
			Primary = cfg.Bind<string>("Theme", "Primary", "#00F0FF", "Main neon (cyan).");
			Secondary = cfg.Bind<string>("Theme", "Secondary", "#FF2A6D", "Second neon (magenta).");
			Accent = cfg.Bind<string>("Theme", "Accent", "#FCEE0A", "Label tabs / highlights (yellow).");
			Warn = cfg.Bind<string>("Theme", "Warn", "#FF003C", "Critical speed / timer warning (red).");
			TextColour = cfg.Bind<string>("Theme", "Text", "#E8FBFF", "Main text colour.");
			ReducedColour = cfg.Bind<string>("Theme", "Reduced", "#B026FF", "Custom preset only. Release meter colour during the game's 'reduced' hitstun.");
			HitColour = cfg.Bind<string>("Theme", "Hit", "#FCEE0A", "Custom preset only. Release window and SP READY ('act now').");
			GhostColour = cfg.Bind<string>("Theme", "DamageGhost", "#FFFFFF", "Custom preset only. Chunk of HP just lost on the player cards.");
			Title = cfg.Bind<string>("Theme", "Title", "NEON//LEAGUE", "Logo text under the speed panel.");
			Scanlines = cfg.Bind<bool>("Effects", "Scanlines", true, "CRT scanlines over panels.");
			Chromatic = cfg.Bind<bool>("Effects", "ChromaticAberration", true, "Magenta/cyan split on digits and title.");
			Glitch = cfg.Bind<bool>("Effects", "Glitch", true, "Slice glitch on hits plus rare idle flicker.");
			Spectrum = cfg.Bind<bool>("Effects", "Spectrum", true, "Live audio spectrum bars.");
			DataLog = cfg.Bind<bool>("Effects", "DataLog", true, "Scrolling hex log behind the speed digits.");
			ReactiveColours = cfg.Bind<bool>("Effects", "ReactiveColours", true, "Speed panel changes colour with ball speed tier.");
			JapaneseAccents = cfg.Bind<bool>("Effects", "JapaneseAccents", true, "Small katakana/kanji labels. Turn off if they show as boxes.");
			SpectrumGainDb = cfg.Bind<float>("Effects", "SpectrumGainDb", 0f, Range("Raise if the bars look too low, lower if they're pinned.", -30f, 30f));
			ReleaseMeter = cfg.Bind<bool>("Effects", "ReleaseMeter", true, "Show the release (ball hitstun) meter above the HUD.");
			ReleaseWindow = cfg.Bind<float>("Effects", "ReleaseWindow", 0.8f, Range("How far through the hitstun the meter turns yellow ('hit now'). 0.8 = last 20%.", 0.3f, 0.99f));
			SpeedSource = cfg.Bind<string>("Data", "SpeedSource", "feed|find:LLScreen.ScreenGameHud::shownSpeedTarget", "Where the value comes from. Try several with '|', first that gives a usable value wins.\n  feed                     - pushed by another plugin via NeonHud.NeonHudFeed\n  reflect:Type::a.b[0].c   - static member path (fields, properties, Method(1) calls, [i] indexers)\n  find:Type::a.b           - member path on Object.FindObjectOfType(Type)\n  ui:Path/To/TextObject    - read the text of a vanilla HUD label\n  track:Path/To/Object     - (speed) how fast that object moves\n  elapsed                  - (timer) seconds since the scene loaded\n  audio / scene            - (song) longest playing music clip / scene name\n  static:TEXT | none\nPress the dump key in a match to get copy-paste candidates in BepInEx/NeonHUD_dump.txt.");
			SpeedMultiplier = cfg.Bind<float>("Data", "SpeedMultiplier", 1f, "Speed value is multiplied by this (calibrate track: or fixed-point values).");
			TimerSource = cfg.Bind<string>("Data", "TimerSource", "feed|reflect:World::GetTimeLeftSecs()|elapsed", "Seconds (number) or \"m:ss\" text. See SpeedSource for the syntax.");
			TimerMultiplier = cfg.Bind<float>("Data", "TimerMultiplier", 1f, "Timer value is multiplied by this (e.g. 0.016667 if the game stores frames).");
			TimerCountsDown = cfg.Bind<bool>("Data", "TimerCountsDown", true, "The linked timer counts down (enables the low-time warning). The 'elapsed' fallback always counts up.");
			TimerWarnSeconds = cfg.Bind<float>("Data", "TimerWarnSeconds", 30f, "Blink red below this many seconds (countdown timers only).");
			SongSource = cfg.Bind<string>("Data", "SongSource", "feed|find:LLScreen.ScreenGameHud::lbTrack.text|reflect:LLHandlers.AudioHandler::GetCurrentMusic()|audio|scene", "Now-playing text. See SpeedSource for the syntax.");
			ReleaseSource = cfg.Bind<string>("Data", "ReleaseSource", "feed|llb", "Release meter data. 'llb' = the ball's hitstun timer exactly as LLB's own HUD reads it; 'feed' = NeonHudFeed.SetRelease from another plugin; 'none' = off. '|' tries in order.");
			Tier1 = cfg.Bind<float>("Data", "SpeedTierHeating", 40f, "Speed where the panel turns yellow.");
			Tier2 = cfg.Bind<float>("Data", "SpeedTierOverdrive", 100f, "Speed where it turns magenta.");
			Tier3 = cfg.Bind<float>("Data", "SpeedTierCritical", 200f, "Speed where it turns red with hazard stripes.");
			SpeedBarMax = cfg.Bind<float>("Data", "SpeedBarMax", 600f, "Speed that fills the segment bar (log scale).");
			ConfigVersion = cfg.Bind<int>("Internal", "ConfigVersion", 0, "Used to upgrade old settings. Don't edit.");
			Migrate();
		}

		private void Migrate()
		{
			if (ConfigVersion.Value >= 3)
			{
				return;
			}
			if (ConfigVersion.Value < 2)
			{
				if (SpeedSource.Value == "feed")
				{
					SpeedSource.Value = "feed|find:LLScreen.ScreenGameHud::shownSpeedTarget";
				}
				if (TimerSource.Value == "feed|elapsed")
				{
					TimerSource.Value = "feed|reflect:World::GetTimeLeftSecs()|elapsed";
				}
				if (SongSource.Value == "feed|audio|scene")
				{
					SongSource.Value = "feed|find:LLScreen.ScreenGameHud::lbTrack.text|reflect:LLHandlers.AudioHandler::GetCurrentMusic()|audio|scene";
				}
				if (!TimerCountsDown.Value)
				{
					TimerCountsDown.Value = true;
				}
			}
			if (ConfigVersion.Value < 3)
			{
				if (VanillaHudElements.Value == "find:LLScreen.ScreenGameHud::imtextSpeed; find:LLScreen.ScreenGameHud::imtextTime; find:LLScreen.ScreenGameHud::lbTrack")
				{
					VanillaHudElements.Value = "find:LLScreen.ScreenGameHud::rtBoomBox";
				}
				string text = (HideVanillaObjects.Value ?? "").Trim();
				if (text == "find:LLScreen.ScreenGameHud" || text == "find:LLScreen.ScreenGameHud::rtBoomBox")
				{
					HideVanillaObjects.Value = "";
				}
			}
			ConfigVersion.Value = 3;
		}

		public void ApplyTo(HudTheme t)
		{
			if (Preset.Value == ThemePreset.Custom)
			{
				t.Background = Col.FromHex(Background.Value, t.Background);
				t.Primary = Col.FromHex(Primary.Value, t.Primary);
				t.Secondary = Col.FromHex(Secondary.Value, t.Secondary);
				t.Accent = Col.FromHex(Accent.Value, t.Accent);
				t.Warn = Col.FromHex(Warn.Value, t.Warn);
				t.Text = Col.FromHex(TextColour.Value, t.Text);
				t.Hit = Col.FromHex(HitColour.Value, t.Hit);
				t.Ghost = Col.FromHex(GhostColour.Value, t.Ghost);
				t.Reduced = Col.FromHex(ReducedColour.Value, t.Reduced);
				t.TeamColours[0] = Col.FromHex(TeamRed.Value, t.TeamColours[0]);
				t.TeamColours[1] = Col.FromHex(TeamBlue.Value, t.TeamColours[1]);
				t.TeamColours[2] = Col.FromHex(TeamYellow.Value, t.TeamColours[2]);
				t.TeamColours[3] = Col.FromHex(TeamGreen.Value, t.TeamColours[3]);
			}
			else
			{
				Palettes.Apply(t, Preset.Value);
			}
			t.Title = Title.Value ?? "";
			t.Opacity = Opacity.Value;
			t.Compact = Layout.Value == HudLayout.Compact;
			t.Scanlines = Scanlines.Value;
			t.Chromatic = Chromatic.Value;
			t.Glitch = Glitch.Value;
			t.Spectrum = Spectrum.Value;
			t.DataLog = DataLog.Value;
			t.ReactiveColours = ReactiveColours.Value;
			t.JapaneseAccents = JapaneseAccents.Value;
			t.ShowRelease = ReleaseMeter.Value;
			t.ReleaseWindow = ReleaseWindow.Value;
			t.PlayerCards = PlayerCards.Value;
			t.PlayerBand = PlayerBand.Value;
			t.Tier1 = Tier1.Value;
			t.Tier2 = Tier2.Value;
			t.Tier3 = Tier3.Value;
			t.SpeedBarMax = SpeedBarMax.Value;
			t.TimerCountsDown = TimerCountsDown.Value;
			t.TimerWarnSeconds = TimerWarnSeconds.Value;
		}
	}
	internal sealed class ImguiCanvas : ICanvas
	{
		private Texture2D _white;

		private Texture2D _scan;

		private Texture2D _stripes;

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

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

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

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

		private readonly GUIStyle _panelStyle = new GUIStyle();

		private readonly GUIContent _content = new GUIContent();

		private readonly Stack<Vector2> _groups = new Stack<Vector2>();

		private float _ox;

		private float _oy;

		private Color _savedColor;

		private Color _savedBg;

		private Font _font;

		public Font Font
		{
			get
			{
				return _font;
			}
			set
			{
				_font = value;
				_textStyles.Clear();
			}
		}

		public void Begin()
		{
			//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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			EnsureBasics();
			_ox = 0f;
			_oy = 0f;
			_savedColor = GUI.color;
			_savedBg = GUI.backgroundColor;
		}

		public void End()
		{
			//IL_0017: 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)
			while (_groups.Count > 0)
			{
				PopClip();
			}
			GUI.color = _savedColor;
			GUI.backgroundColor = _savedBg;
		}

		public void Fill(RectF r, Col c)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!(c.A <= 0f) && !(r.W <= 0f) && !(r.H <= 0f))
			{
				GUI.color = ToColor(c);
				GUI.DrawTexture(ToRect(r), (Texture)(object)_white);
			}
		}

		public void Panel(RectF r, float chamferTL, float chamferBR, Col fill, Col edge, float edgeWidth)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_011a: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			int num = Math.Max(0, (int)Math.Round(chamferTL));
			int num2 = Math.Max(0, (int)Math.Round(chamferBR));
			int num3 = ((edge.A > 0f && edgeWidth > 0f) ? Math.Max(1, (int)Math.Round(edgeWidth)) : 0);
			int key = num | (num2 << 10) | (num3 << 20);
			Texture2D edge2;
			RectOffset border;
			if (!_fillTex.TryGetValue(key, out var value) || (Object)(object)value == (Object)null)
			{
				BuildPanelTextures(num, num2, Math.Max(1, num3), out value, out edge2, out border);
				_fillTex[key] = value;
				_edgeTex[key] = edge2;
				_borders[key] = border;
			}
			edge2 = _edgeTex[key];
			border = _borders[key];
			Rect val = ToRect(r);
			_panelStyle.border = border;
			GUI.backgroundColor = Color.white;
			if (fill.A > 0f)
			{
				GUI.color = ToColor(fill);
				_panelStyle.normal.background = value;
				_panelStyle.Draw(val, false, false, false, false);
			}
			if (num3 > 0)
			{
				GUI.color = ToColor(edge);
				_panelStyle.normal.background = edge2;
				_panelStyle.Draw(val, false, false, false, false);
			}
		}

		public void Text(RectF r, string s, float size, Col c, TextAlign align, bool bold)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(s) && !(c.A <= 0f))
			{
				GUIStyle val = Style(size, bold);
				val.alignment = (TextAnchor)(align switch
				{
					TextAlign.Center => 4, 
					TextAlign.Left => 3, 
					_ => 5, 
				});
				val.normal.textColor = ToColor(c);
				GUI.color = Color.white;
				_content.text = s;
				GUI.Label(ToRect(r), _content, val);
			}
		}

		public float Measure(string s, float size, bool bold)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(s))
			{
				return 0f;
			}
			_content.text = s;
			return Style(size, bold).CalcSize(_content).x;
		}

		public void PushClip(RectF r)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			GUI.BeginGroup(ToRect(r));
			_groups.Push(new Vector2(_ox, _oy));
			_ox = r.X;
			_oy = r.Y;
		}

		public void PopClip()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (_groups.Count != 0)
			{
				GUI.EndGroup();
				Vector2 val = _groups.Pop();
				_ox = val.x;
				_oy = val.y;
			}
		}

		public void Scanlines(RectF r, float period, Col c)
		{
			//IL_0017: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!(c.A <= 0f) && !(period <= 0f))
			{
				GUI.color = ToColor(c);
				GUI.DrawTextureWithTexCoords(ToRect(r), (Texture)(object)_scan, new Rect(0f, 0f, 1f, r.H / period));
			}
		}

		public void Stripes(RectF r, float period, Col c)
		{
			//IL_0017: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!(c.A <= 0f) && !(period <= 0f))
			{
				GUI.color = ToColor(c);
				GUI.DrawTextureWithTexCoords(ToRect(r), (Texture)(object)_stripes, new Rect(0f, 0f, r.W / period, r.H / period));
			}
		}

		private Rect ToRect(RectF r)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(r.X - _ox, r.Y - _oy, r.W, r.H);
		}

		private static Color ToColor(Col c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.R, c.G, c.B, c.A);
		}

		private GUIStyle Style(float size, bool bold)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			int num = Math.Max(1, (int)Math.Round(size));
			int key = num * 2 + (bold ? 1 : 0);
			if (!_textStyles.TryGetValue(key, out var value))
			{
				value = new GUIStyle();
				value.font = _font;
				value.fontSize = num;
				value.fontStyle = (FontStyle)(bold ? 1 : 0);
				value.wordWrap = false;
				value.richText = false;
				value.clipping = (TextClipping)0;
				_textStyles[key] = value;
			}
			return value;
		}

		private static Texture2D NewTex(int w, int h, FilterMode filter, TextureWrapMode wrap)
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			return new Texture2D(w, h, (TextureFormat)5, false)
			{
				filterMode = filter,
				wrapMode = wrap,
				hideFlags = (HideFlags)61
			};
		}

		private void EnsureBasics()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_white == (Object)null)
			{
				_white = NewTex(1, 1, (FilterMode)0, (TextureWrapMode)1);
				_white.SetPixel(0, 0, Color.white);
				_white.Apply();
			}
			if ((Object)(object)_scan == (Object)null)
			{
				_scan = NewTex(1, 3, (FilterMode)0, (TextureWrapMode)0);
				_scan.SetPixel(0, 0, new Color(1f, 1f, 1f, 1f));
				_scan.SetPixel(0, 1, new Color(1f, 1f, 1f, 0f));
				_scan.SetPixel(0, 2, new Color(1f, 1f, 1f, 0f));
				_scan.Apply();
			}
			if (!((Object)(object)_stripes == (Object)null))
			{
				return;
			}
			_stripes = NewTex(32, 32, (FilterMode)1, (TextureWrapMode)0);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					_stripes.SetPixel(j, i, new Color(1f, 1f, 1f, ((j + i) % 32 < 16) ? 1f : 0f));
				}
			}
			_stripes.Apply();
		}

		private static void BuildPanelTextures(int tl, int br, int ew, out Texture2D fill, out Texture2D edge, out RectOffset border)
		{
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			int num = Math.Max(tl, ew) + 2;
			int num2 = Math.Max(br, ew) + 2;
			int num3 = num + num2 + 2;
			fill = NewTex(num3, num3, (FilterMode)1, (TextureWrapMode)1);
			edge = NewTex(num3, num3, (FilterMode)1, (TextureWrapMode)1);
			for (int i = 0; i < num3; i++)
			{
				for (int j = 0; j < num3; j++)
				{
					float num4 = (float)j + 0.5f;
					float num5 = (float)i + 0.5f;
					float val = num5;
					float num6 = (float)num3 - num4;
					float num7 = (float)num3 - num5;
					float val2 = ((tl > 0) ? ((num4 + num5 - (float)tl) * 0.70710677f) : 1000000f);
					float val3 = ((br > 0) ? ((num6 + num7 - (float)br) * 0.70710677f) : 1000000f);
					float num8 = Math.Min(val2, val3);
					float num9 = ((num8 >= 0.5f) ? 1f : ((num8 <= -0.5f) ? 0f : (num8 + 0.5f)));
					float val4 = Math.Min(Math.Min(num4, num6), Math.Min(val, num7));
					val4 = Math.Min(val4, num8);
					float num10 = (float)ew + 0.5f - val4;
					num10 = ((num10 < 0f) ? 0f : ((num10 > 1f) ? 1f : num10));
					int num11 = num3 - 1 - i;
					fill.SetPixel(j, num11, new Color(1f, 1f, 1f, num9));
					edge.SetPixel(j, num11, new Color(1f, 1f, 1f, num9 * num10));
				}
			}
			fill.Apply();
			edge.Apply();
			border = new RectOffset(num, num2, num, num2);
		}

		public void Release()
		{
			foreach (Texture2D value in _fillTex.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			foreach (Texture2D value2 in _edgeTex.Values)
			{
				if ((Object)(object)value2 != (Object)null)
				{
					Object.Destroy((Object)(object)value2);
				}
			}
			_fillTex.Clear();
			_edgeTex.Clear();
			_borders.Clear();
			if ((Object)(object)_white != (Object)null)
			{
				Object.Destroy((Object)(object)_white);
			}
			if ((Object)(object)_scan != (Object)null)
			{
				Object.Destroy((Object)(object)_scan);
			}
			if ((Object)(object)_stripes != (Object)null)
			{
				Object.Destroy((Object)(object)_stripes);
			}
		}
	}
	internal sealed class LlbPlayers
	{
		private const BindingFlags S = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private const BindingFlags I = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private const double FixOne = 4294967296.0;

		private readonly ManualLogSource _log;

		private bool _bound;

		private bool _broken;

		private float _nextBind;

		private float _retry = 2f;

		private FieldInfo _hudInstance;

		private FieldInfo _infos;

		private FieldInfo _onlyP0;

		private FieldInfo _shownPlayer;

		private FieldInfo _lbName;

		private FieldInfo _playerEntity;

		private FieldInfo _playerData;

		private FieldInfo _character;

		private FieldInfo _hp;

		private FieldInfo _energy;

		private FieldInfo _stocks;

		private FieldInfo _points;

		private FieldInfo _team;

		private FieldInfo _raw;

		private FieldInfo _settings;

		private FieldInfo _hpFactor;

		private FieldInfo _energyMax;

		private FieldInfo _mode;

		private MethodInfo _pointsMode;

		private MethodInfo _score;

		private FieldInfo _ballHandler;

		private FieldInfo _worldState;

		private MethodInfo _getBall;

		private MethodInfo _noBalls;

		private MethodInfo _getDamage;

		private readonly object[] _scoreArgs = new object[3];

		private readonly object[] _ballArgs = new object[1] { 0 };

		private readonly object[] _teamArg = new object[1];

		private readonly string[] _rawNames = new string[4];

		private readonly string[] _cleanNames = new string[4];

		public LlbPlayers(ManualLogSource log)
		{
			_log = log;
		}

		public bool Read(PlayerCard[] cards, float now)
		{
			for (int i = 0; i < cards.Length; i++)
			{
				cards[i].Present = false;
			}
			if (!Bind(now))
			{
				return false;
			}
			try
			{
				object? value = _hudInstance.GetValue(null);
				Object val = (Object)((value is Object) ? value : null);
				if (val == (Object)null)
				{
					return true;
				}
				if (!(_infos.GetValue(val) is Array array))
				{
					return true;
				}
				bool flag = (object)_onlyP0 != null && (bool)_onlyP0.GetValue(val);
				object value2 = _settings.GetValue(null);
				string obj = ((value2 != null) ? _hpFactor.GetValue(value2).ToString() : "HP_100");
				bool flag2 = obj == "OFF";
				int hpMax = HpMax(obj);
				int num = ((value2 != null) ? ((int)_energyMax.GetValue(value2)) : 0);
				bool pointsMode = value2 != null && (object)_pointsMode != null && (bool)_pointsMode.Invoke(value2, null);
				object obj2 = (((object)_mode != null) ? _mode.GetValue(null) : null);
				object obj3 = null;
				bool flag3 = false;
				object value3 = _ballHandler.GetValue(null);
				if (value3 != null)
				{
					flag3 = Convert.ToInt32(_worldState.GetValue(null)) == 1 && !(bool)_noBalls.Invoke(value3, null);
					if (flag3)
					{
						obj3 = _getBall.Invoke(value3, _ballArgs);
					}
					if ((Object)((obj3 is Object) ? obj3 : null) == (Object)null)
					{
						obj3 = null;
						flag3 = false;
					}
				}
				for (int j = 0; j < cards.Length && j < array.Length; j++)
				{
					if (flag && j > 0)
					{
						continue;
					}
					object? value4 = array.GetValue(j);
					Object val2 = (Object)((value4 is Object) ? value4 : null);
					if (val2 == (Object)null)
					{
						continue;
					}
					object value5 = _shownPlayer.GetValue(val2);
					if (value5 == null)
					{
						continue;
					}
					object? value6 = _playerEntity.GetValue(value5);
					Object val3 = (Object)((value6 is Object) ? value6 : null);
					if (val3 == (Object)null)
					{
						continue;
					}
					object value7 = _playerData.GetValue(val3);
					if (value7 != null)
					{
						PlayerCard obj4 = cards[j];
						object value8 = _team.GetValue(value7);
						long num2 = Raw(_hp.GetValue(value7));
						float threat = 0f;
						bool lethal = false;
						if (flag3 && !flag2)
						{
							_teamArg[0] = value8;
							long num3 = Raw(_getDamage.Invoke(obj3, _teamArg));
							threat = (float)((double)num3 / 4294967296.0);
							lethal = num3 >= num2;
						}
						obj4.Present = true;
						obj4.SetIdentity(j, Convert.ToInt32(value8), CharacterName(_character.GetValue(val3)), CleanName(j, val2));
						obj4.SetHp((float)((double)num2 / 4294967296.0), hpMax, flag2, threat, lethal, now);
						int num4 = (int)_energy.GetValue(value7);
						obj4.Energy01 = ((num > 0) ? ((float)num4 / (float)num) : 0f);
						obj4.EnergyFull = num > 0 && num4 >= num;
						int stocks = (int)_stocks.GetValue(value7);
						int points = (((object)_points != null) ? ((int)_points.GetValue(value7)) : (-1));
						if (obj2 != null && (object)_score != null)
						{
							_scoreArgs[0] = val3;
							_scoreArgs[1] = 0;
							_scoreArgs[2] = 0;
							_score.Invoke(obj2, _scoreArgs);
							stocks = (int)_scoreArgs[1];
							points = (int)_scoreArgs[2];
						}
						obj4.SetScore(pointsMode, stocks, points);
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				Exception ex2 = ((ex is TargetInvocationException && ex.InnerException != null) ? ex.InnerException : ex);
				_broken = true;
				_log.LogWarning((object)("Player cards: reading player data failed, cards disabled until config reload: " + ex2.GetType().Name + ": " + ex2.Message));
				for (int k = 0; k < cards.Length; k++)
				{
					cards[k].Present = false;
				}
				return false;
			}
		}

		private long Raw(object fixedPoint)
		{
			return (long)_raw.GetValue(fixedPoint);
		}

		private static int HpMax(string factor)
		{
			return factor switch
			{
				"HP_200" => 200, 
				"HP_175" => 175, 
				"HP_150" => 150, 
				"HP_125" => 125, 
				"HP_75" => 75, 
				"HP_50" => 50, 
				_ => 100, 
			};
		}

		private static string CharacterName(object character)
		{
			string text = ((character != null) ? character.ToString() : "");
			return text switch
			{
				"KID" => "RAPTOR", 
				"ROBOT" => "SWITCH", 
				"CANDY" => "CANDYMAN", 
				"BOOM" => "SONATA", 
				"CROC" => "LATCH", 
				"PONG" => "DICE", 
				"BOSS" => "DOOMBOX", 
				"COP" => "NITRO", 
				"ELECTRO" => "GRID", 
				"SKATE" => "JET", 
				"GRAF" => "TOXIC", 
				"BAG" => "DUST & ASHES", 
				_ => text, 
			};
		}

		private string CleanName(int i, object info)
		{
			string text = null;
			object obj = (((object)_lbName != null) ? _lbName.GetValue(info) : null);
			if (obj != null && TextAccess.Find(obj.GetType(), out var prop, out var field))
			{
				text = (((object)prop != null) ? prop.GetValue(obj, null) : field.GetValue(obj)) as string;
			}
			if (text == _rawNames[i])
			{
				return _cleanNames[i];
			}
			_rawNames[i] = text;
			if (text == null)
			{
				return _cleanNames[i] = "";
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length);
			bool flag = false;
			string text2 = text;
			foreach (char c in text2)
			{
				if (c == '<')
				{
					flag = true;
				}
				else if (flag)
				{
					if (c == '>')
					{
						flag = false;
					}
				}
				else if (c != '\n' && c != '\r')
				{
					stringBuilder.Append(c);
				}
			}
			return _cleanNames[i] = stringBuilder.ToString().Trim().ToUpperInvariant();
		}

		private bool Bind(float now)
		{
			if (_bound)
			{
				return true;
			}
			if (_broken || now < _nextBind)
			{
				return false;
			}
			Type type = ReflectionPath.FindType("LLScreen.ScreenGameHud");
			if ((object)type == null)
			{
				_nextBind = now + _retry;
				_retry = Math.Min(30f, _retry * 2f);
				return false;
			}
			_hudInstance = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_infos = type.GetField("playerInfos", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_onlyP0 = type.GetField("onlyShowPlayerInfo0", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Type type2 = (((object)_infos != null) ? _infos.FieldType.GetElementType() : null);
			_shownPlayer = type2?.GetField("shownPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_lbName = type2?.GetField("lbName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Type type3 = ReflectionPath.FindType("GameplayEntities.PlayerEntity");
			_playerEntity = (((object)_shownPlayer != null && (object)type3 != null) ? FieldOfType(_shownPlayer.FieldType, type3, "JCCIAMJEODH") : null);
			_playerData = (((object)type3 != null) ? Find(type3, "playerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_character = (((object)type3 != null) ? Find(type3, "character", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			Type type4 = (((object)_playerData != null) ? _playerData.FieldType : null);
			_hp = (((object)type4 != null) ? Find(type4, "hp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_energy = (((object)type4 != null) ? Find(type4, "energy", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_stocks = (((object)type4 != null) ? Find(type4, "stocks", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_points = (((object)type4 != null) ? Find(type4, "points", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_team = (((object)type4 != null) ? Find(type4, "team", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_raw = (((object)_hp != null) ? RawField(_hp.FieldType) : null);
			Type type5 = ReflectionPath.FindType("JOMBNFKIHIC");
			_settings = type5?.GetField("GIGAKBJGFDI", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_hpFactor = type5?.GetField("BKKMIBGLAEC", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_energyMax = type5?.GetField("IKGAIFLLLAG", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_pointsMode = type5?.GetMethod("JFNLOKKDCEB", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			Type type6 = ReflectionPath.FindType("NCMFHODLNAJ");
			_mode = type6?.GetField("GIGAKBJGFDI", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_score = (((object)type6 != null && (object)type3 != null) ? type6.GetMethod("BPDKCCGOHPO", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3]
			{
				type3,
				typeof(int).MakeByRefType(),
				typeof(int).MakeByRefType()
			}, null) : null);
			if ((object)_mode == null)
			{
				_score = null;
			}
			Type type7 = ReflectionPath.FindType("LLHandlers.BallHandler");
			_ballHandler = type7?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_getBall = type7?.GetMethod("GetBall", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null);
			_noBalls = type7?.GetMethod("NoBallsActivelyInMatch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			Type type8 = ReflectionPath.FindType("GameplayEntities.GetHitBallEntity");
			_getDamage = (((object)type8 != null && (object)_team != null) ? type8.GetMethod("GetDamage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { _team.FieldType }, null) : null);
			_worldState = ReflectionPath.FindType("World")?.GetField("state", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			string text = (((object)_hudInstance == null) ? "ScreenGameHud.instance" : (((object)_infos == null) ? "ScreenGameHud.playerInfos" : (((object)_shownPlayer == null) ? "GameHudPlayerInfo.shownPlayer" : (((object)_playerEntity == null) ? "Player -> PlayerEntity" : (((object)_playerData == null || (object)_hp == null || (object)_energy == null || (object)_stocks == null || (object)_team == null) ? "PlayerData fields" : (((object)_character == null) ? "PlayerEntity.character" : (((object)_raw == null) ? "fixed-point raw value" : (((object)_settings == null || (object)_hpFactor == null || (object)_energyMax == null) ? "game settings (HP factor / max energy)" : (((object)_ballHandler == null || (object)_getBall == null || (object)_noBalls == null || (object)_getDamage == null || (object)_worldState == null) ? "ball damage" : null)))))))));
			if (text != null)
			{
				_broken = true;
				_log.LogWarning((object)("Player cards: couldn't find " + text + " in this game version; cards disabled."));
				return false;
			}
			if ((object)_score == null)
			{
				_log.LogInfo((object)"Player cards: game-mode score lookup not found, using stocks/points fields directly.");
			}
			_bound = true;
			_log.LogInfo((object)"Player cards linked to the game's player data.");
			return true;
		}

		private static FieldInfo Find(Type t, string name, BindingFlags flags)
		{
			while ((object)t != null)
			{
				FieldInfo field = t.GetField(name, flags | BindingFlags.DeclaredOnly);
				if ((object)field != null)
				{
					return field;
				}
				t = t.BaseType;
			}
			return null;
		}

		private static FieldInfo FieldOfType(Type owner, Type fieldType, string preferred)
		{
			FieldInfo field = owner.GetField(preferred, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if ((object)field != null && fieldType.IsAssignableFrom(field.FieldType))
			{
				return field;
			}
			FieldInfo fieldInfo = null;
			FieldInfo[] fields = owner.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo2 in fields)
			{
				if (fieldType.IsAssignableFrom(fieldInfo2.FieldType))
				{
					if ((object)fieldInfo != null)
					{
						return null;
					}
					fieldInfo = fieldInfo2;
				}
			}
			return fieldInfo;
		}

		private static FieldInfo RawField(Type fixedType)
		{
			FieldInfo fieldInfo = null;
			FieldInfo[] fields = fixedType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo2 in fields)
			{
				if ((object)fieldInfo2.FieldType == typeof(long))
				{
					if ((object)fieldInfo != null)
					{
						return null;
					}
					fieldInfo = fieldInfo2;
				}
			}
			return fieldInfo;
		}
	}
	internal sealed class LlbRelease
	{
		private const BindingFlags Static = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private const BindingFlags Inst = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private const long DefaultFrame = 71582788L;

		private readonly ManualLogSource _log;

		private bool _bound;

		private bool _broken;

		private float _nextBind;

		private float _retry = 2f;

		private FieldInfo _entity;

		private FieldInfo _reduced;

		private FieldInfo _data;

		private FieldInfo _timer;

		private FieldInfo _duration;

		private FieldInfo _raw;

		private FieldInfo _delta;

		public LlbRelease(ManualLogSource log)
		{
			_log = log;
		}

		public bool TryRead(float now, out bool active, out float progress, out int framesLeft, out bool reduced)
		{
			active = false;
			progress = 0f;
			framesLeft = -1;
			reduced = false;
			if (!Bind(now))
			{
				return false;
			}
			try
			{
				object? value = _entity.GetValue(null);
				Object val = (Object)((value is Object) ? value : null);
				if (val == (Object)null)
				{
					return true;
				}
				object value2 = _data.GetValue(val);
				if (value2 == null)
				{
					return true;
				}
				long num = Raw(_timer.GetValue(value2));
				long num2 = Raw(_duration.GetValue(value2));
				if (num2 <= 0 || num >= num2)
				{
					return true;
				}
				active = true;
				progress = ((num <= 0) ? 0f : ((float)((double)num / (double)num2)));
				long num3 = (((object)_delta != null) ? Raw(_delta.GetValue(null)) : 71582788);
				if (num3 <= 0)
				{
					num3 = 71582788L;
				}
				framesLeft = (int)((num2 - num + num3 - 1) / num3);
				reduced = (object)_reduced != null && (bool)_reduced.GetValue(null);
				return true;
			}
			catch (Exception ex)
			{
				_broken = true;
				_log.LogWarning((object)("Release meter: reading the game's hitstun failed, meter disabled until config reload: " + ex.Message));
				return false;
			}
		}

		private long Raw(object fixedPoint)
		{
			return (long)_raw.GetValue(fixedPoint);
		}

		private bool Bind(float now)
		{
			if (_bound)
			{
				return true;
			}
			if (_broken || now < _nextBind)
			{
				return false;
			}
			Type type = ReflectionPath.FindType("LLScreen.ScreenGameHud");
			if ((object)type == null)
			{
				_nextBind = now + _retry;
				_retry = Math.Min(30f, _retry * 2f);
				return false;
			}
			_entity = type.GetField("hitStunEntity", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_reduced = type.GetField("hitStunReduced", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			_data = (((object)_entity != null) ? FindField(_entity.FieldType, "hitableData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_timer = (((object)_data != null) ? FindField(_data.FieldType, "hitstunTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_duration = (((object)_data != null) ? FindField(_data.FieldType, "hitstunDuration", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : null);
			_raw = (((object)_timer != null) ? RawField(_timer.FieldType) : null);
			_delta = ReflectionPath.FindType("World")?.GetField("FDELTA_TIME", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if ((object)_delta != null && (object)_timer != null && (object)_delta.FieldType != _timer.FieldType)
			{
				_delta = null;
			}
			string text = (((object)_entity == null) ? "ScreenGameHud.hitStunEntity" : (((object)_data == null) ? "HitableEntity.hitableData" : (((object)_timer == null) ? "HitableData.hitstunTimer" : (((object)_duration == null) ? "HitableData.hitstunDuration" : (((object)_raw == null) ? "fixed-point raw value" : null)))));
			if (text != null)
			{
				_broken = true;
				_log.LogWarning((object)("Release meter: couldn't find " + text + " in this game version; meter disabled."));
				return false;
			}
			_bound = true;
			_log.LogInfo((object)("Release meter linked to the game's ball hitstun" + (((object)_delta == null) ? " (assuming 60 fps frames)" : "") + "."));
			return true;
		}

		private static FieldInfo FindField(Type t, string name, BindingFlags flags)
		{
			while ((object)t != null)
			{
				FieldInfo field = t.GetField(name, flags | BindingFlags.DeclaredOnly);
				if ((object)field != null)
				{
					return field;
				}
				t = t.BaseType;
			}
			return null;
		}

		private static FieldInfo RawField(Type fixedType)
		{
			if ((object)fixedType == typeof(long))
			{
				return null;
			}
			FieldInfo fieldInfo = null;
			FieldInfo[] fields = fixedType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo2 in fields)
			{
				if ((object)fieldInfo2.FieldType == typeof(long))
				{
					if ((object)fieldInfo != null)
					{
						return null;
					}
					fieldInfo = fieldInfo2;
				}
			}
			return fieldInfo;
		}
	}
	internal sealed class MatchDetector
	{
		private readonly ManualLogSource _log;

		private string _typeName;

		private Type _type;

		private bool _typeMissing;

		private Object _obj;

		private float _next;

		private float _typeRetry = 2f;

		public MatchDetector(ManualLogSource log)
		{
			_log = log;
		}

		public void Configure(string typeName)
		{
			typeName = (typeName ?? "").Trim();
			if (!(typeName == _typeName))
			{
				_typeName = typeName;
				_type = null;
				_obj = null;
				_typeMissing = false;
				_next = 0f;
				_typeRetry = 2f;
			}
		}

		public bool Poll(float now)
		{
			if (string.IsNullOrEmpty(_typeName))
			{
				return true;
			}
			if (_obj != (Object)null)
			{
				return true;
			}
			if (now < _next)
			{
				return _typeMissing;
			}
			_next = now + 0.5f;
			if ((object)_type == null)
			{
				_type = ReflectionPath.FindType(_typeName);
				if ((object)_type == null)
				{
					if (!_typeMissing)
					{
						_log.LogWarning((object)("Match type '" + _typeName + "' not found; showing the HUD everywhere."));
					}
					_typeMissing = true;
					_next = now + _typeRetry;
					_typeRetry = Math.Min(30f, _typeRetry * 2f);
					return true;
				}
				_typeMissing = false;
			}
			_obj = Object.FindObjectOfType(_type);
			return _obj != (Object)null;
		}
	}
	[BepInPlugin("NeonHUD", "NeonHUD", "1.5.0")]
	public sealed class NeonHudPlugin : BaseUnityPlugin
	{
		public const string Guid = "NeonHUD";

		public const string PluginName = "NeonHUD";

		public const string Version = "1.5.0";

		internal static ManualLogSource Log;

		private HudConfig _cfg;

		private readonly HudTheme _theme = new HudTheme();

		private readonly HudState _state = new HudState();

		private readonly HudPainter _painter = new HudPainter();

		private readonly DemoFeed _demo = new DemoFeed();

		private readonly VanillaHider _hider = new VanillaHider();

		private readonly SongText _songText = new SongText();

		private MatchDetector _match;

		private LlbRelease _llbRelease;

		private LlbPlayers _llbPlayers;

		private readonly PlayerCardsPainter _cardsPainter = new PlayerCardsPainter();

		private float _nextPlayerRead;

		private bool _releaseFeed;

		private bool _releaseLlb;

		private ImguiCanvas _canvas;

		private SpectrumAnalyzer _spectrum;

		private Source _speedSrc;

		private Source _timerSrc;

		private Source _songSrc;

		private bool _ready;

		private bool _visible = true;

		private bool _demoOn;

		private bool _sceneAllowed = true;

		private bool _fontPending;

		private bool _inMatch;

		private bool _wasInMatch;

		private string _scene;

		private float _nextScenePoll;

		private float _nextClock;

		private float _fpsTime;

		private int _fpsFrames;

		private readonly HashSet<string> _showScenes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private readonly HashSet<string> _hideScenes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private bool Showing
		{
			get
			{
				if (_ready && _cfg.Enabled.Value && _visible && _sceneAllowed)
				{
					if (!_demoOn)
					{
						return _inMatch;
					}
					return true;
				}
				return false;
			}
		}

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"NeonHUD 1.5.0 starting...");
			try
			{
				_cfg = new HudConfig(((BaseUnityPlugin)this).Config);
				_canvas = new ImguiCanvas();
				_spectrum = new SpectrumAnalyzer();
				_match = new MatchDetector(Log);
				_llbRelease = new LlbRelease(Log);
				((MonoBehaviour)this).useGUILayout = false;
				ApplyConfig();
				((BaseUnityPlugin)this).Config.SettingChanged += delegate
				{
					ApplyConfig();
				};
				_ready = true;
				Log.LogInfo((object)"NeonHUD 1.5.0 loaded. F7 toggle, F8 vanilla HUD, F10 demo, F9 dump, F6 reload config.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("NeonHUD failed to start: " + ex));
				((Behaviour)this).enabled = false;
			}
		}

		private void ApplyConfig()
		{
			_cfg.ApplyTo(_theme);
			_speedSrc = SourceFactory.Create(_cfg.SpeedSource.Value, ValueKind.Speed, Log);
			_timerSrc = SourceFactory.Create(_cfg.TimerSource.Value, ValueKind.Timer, Log);
			_songSrc = SourceFactory.Create(_cfg.SongSource.Value, ValueKind.Song, Log);
			_releaseFeed = (_releaseLlb = false);
			string[] array = (_cfg.ReleaseSource.Value ?? "").Split(new char[1] { '|' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim().ToLowerInvariant();
				if (text == "feed")
				{
					_releaseFeed = true;
				}
				else if (text == "llb")
				{
					_releaseLlb = true;
				}
			}
			_llbRelease = new LlbRelease(Log);
			_llbPlayers = new LlbPlayers(Log);
			List<string> list = new List<string>();
			if (_cfg.HideVanillaHud.Value)
			{
				list.AddRange(VanillaHider.Split(_cfg.VanillaHudElements.Value));
				if (_cfg.PlayerCards.Value)
				{
					list.AddRange(VanillaHider.Split(_cfg.VanillaPlayerElements.Value));
				}
				list.AddRange(VanillaHider.Split(_cfg.HideVanillaObjects.Value));
			}
			_hider.Configure(list, Log);
			_match.Configure(_cfg.OnlyInMatch.Value ? _cfg.MatchScreenType.Value : "");
			FillSet(_showScenes, _cfg.ShowInScenes.Value);
			FillSet(_hideScenes, _cfg.HideInScenes.Value);
			_sceneAllowed = SceneAllowed(_scene);
			_canvas.Font = null;
			_fontPending = !string.IsNullOrEmpty(_cfg.FontName.Value);
		}

		private static void FillSet(HashSet<string> set, string csv)
		{
			set.Clear();
			if (string.IsNullOrEmpty(csv))
			{
				return;
			}
			string[] array = csv.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (text.Trim().Length > 0)
				{
					set.Add(text.Trim());
				}
			}
		}

		private bool SceneAllowed(string scene)
		{
			if (scene == null)
			{
				return true;
			}
			if (_hideScenes.Contains(scene))
			{
				return false;
			}
			if (_showScenes.Count != 0)
			{
				return _showScenes.Contains(scene);
			}
			return true;
		}

		private void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			if (!_ready)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			KeyboardShortcut value = _cfg.ToggleKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				_visible = !_visible;
			}
			value = _cfg.VanillaKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				_cfg.HideVanillaHud.Value = !_cfg.HideVanillaHud.Value;
				Log.LogInfo((object)("Vanilla HUD " + (_cfg.HideVanillaHud.Value ? "hidden" : "shown")));
			}
			value = _cfg.DemoKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				_demoOn = !_demoOn;
				_state.ResetMatch();
				Log.LogInfo((object)("Demo mode " + (_demoOn ? "on" : "off")));
			}
			value = _cfg.ReloadKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				((BaseUnityPlugin)this).Config.Reload();
				ApplyConfig();
				Log.LogInfo((object)"Config reloaded");
			}
			value = _cfg.DumpKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				try
				{
					Log.LogInfo((object)("Dump written to " + DevDump.Write()));
				}
				catch (Exception ex)
				{
					Log.LogError((object)("Dump failed: " + ex));
				}
			}
			PollScene(unscaledTime);
			_inMatch = _match.Poll(unscaledTime);
			if (_inMatch && !_wasInMatch)
			{
				_state.ResetMatch();
			}
			_wasInMatch = _inMatch;
			_state.Time = unscaledTime;
			if (Showing)
			{
				if (_demoOn)
				{
					_demo.Step(_state, unscaledTime);
				}
				else
				{
					UpdateData(unscaledTime);
				}
				UpdateTelemetry(unscaledTime);
			}
		}

		private void UpdateData(float now)
		{
			if (_speedSrc.TryGet(out var value) && ValueConv.ToFloat(value, out var f))
			{
				_state.SetSpeed(f * _cfg.SpeedMultiplier.Value, now);
			}
			else
			{
				_state.ClearSpeed();
			}
			if (_timerSrc.TryGet(out value) && ValueConv.ToSeconds(value, out f))
			{
				bool countdown = _theme.TimerCountsDown && _timerSrc.Label != "ELAPSED";
				_state.SetTimer(f * _cfg.TimerMultiplier.Value, countdown, _timerSrc.Label);
			}
			else
			{
				_state.ClearTimer();
			}
			string title = null;
			if (_songSrc.TryGet(out value) && value != null)
			{
				title = _songText.Clean((value as string) ?? value.ToString());
			}
			_state.SetSong(title, now);
			_state.SourceLabel = SourceLabel(_songSrc.Label);
			UpdateRelease(now);
			UpdatePlayers(now);
			if (_theme.Spectrum)
			{
				_spectrum.Update(_state, Time.unscaledDeltaTime, _cfg.SpectrumGainDb.Value);
			}
			else
			{
				SpectrumAnalyzer.Clear(_state);
			}
		}

		private void UpdatePlayers(float now)
		{
			PlayerCard[] players = _state.Players;
			if (!_theme.PlayerCards)
			{
				for (int i = 0; i < players.Length; i++)
				{
					players[i].Present = false;
				}
			}
			else if (!(now < _nextPlayerRead))
			{
				_nextPlayerRead = now + 1f / 30f;
				_llbPlayers.Read(players, now);
			}
		}

		private void UpdateRelease(float now)
		{
			bool active;
			float progress;
			int framesLeft;
			bool reduced;
			if (!_theme.ShowRelease)
			{
				_state.ClearRelease();
			}
			else if (_releaseFeed && NeonHudFeed.TryGetRelease(out active, out progress, out framesLeft, out reduced))
			{
				_state.SetRelease(active, progress, framesLeft, reduced, now);
			}
			else if (_releaseLlb && _llbRelease.TryRead(now, out active, out progress, out framesLeft, out reduced))
			{
				_state.SetRelease(active, progress, framesLeft, reduced, now);
			}
			else
			{
				_state.ClearRelease();
			}
		}

		private static string SourceLabel(string label)
		{
			return label switch
			{
				"AUDIO" => "SRC:AUDIO", 
				"SCENE" => "SRC:SCENE", 
				"FEED" => "SRC:FEED", 
				"NO LINK" => "SRC:NONE", 
				_ => "SRC:GAME", 
			};
		}

		private void UpdateTelemetry(float now)
		{
			_fpsFrames++;
			if (now - _fpsTime >= 0.5f)
			{
				_state.FpsLabel = "FPS " + (int)Math.Round((float)_fpsFrames / (now - _fpsTime));
				_fpsFrames = 0;
				_fpsTime = now;
			}
			if (now >= _nextClock)
			{
				_nextClock = now + 1f;
				_state.ClockLabel = "LOCAL " + DateTime.Now.ToString("HH:mm");
			}
		}

		private void PollScene(float now)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (now < _nextScenePoll)
			{
				return;
			}
			_nextScenePoll = now + 0.5f;
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name != _scene)
			{
				_scene = name;
				_state.ResetMatch();
				string text = Pretty.Name(name) ?? "";
				if (text.Length > 18)
				{
					text = text.Substring(0, 18);
				}
				_state.SceneLabel = "SCN " + text;
				_sceneAllowed = SceneAllowed(name);
				if (!string.IsNullOrEmpty(_cfg.FontName.Value) && (Object)(object)_canvas.Font == (Object)null)
				{
					_fontPending = true;
				}
			}
			if (_fontPending)
			{
				_fontPending = false;
				_canvas.Font = FindFont(_cfg.FontName.Value);
				if ((Object)(object)_canvas.Font == (Object)null)
				{
					Log.LogWarning((object)("Font '" + _cfg.FontName.Value + "' not found; using Unity default (will retry next scene)."));
				}
			}
		}

		private static Font FindFont(string name)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Font));
			foreach (Object val in array)
			{
				if (string.Equals(val.name, name, StringComparison.OrdinalIgnoreCase))
				{
					return (Font)val;
				}
			}
			MethodInfo method = typeof(Font).GetMethod("CreateDynamicFontFromOSFont", new Type[2]
			{
				typeof(string),
				typeof(int)
			});
			if ((object)method == null)
			{
				return null;
			}
			try
			{
				object? obj = method.Invoke(null, new object[2] { name, 32 });
				Font val2 = (Font)((obj is Font) ? obj : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Object)val2).hideFlags = (HideFlags)61;
				}
				return val2;
			}
			catch
			{
				return null;
			}
		}

		private void LateUpdate()
		{
			if (_ready)
			{
				_hider.Apply(Showing && !_demoOn);
			}
		}

		private void OnGUI()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			if (!Showing)
			{
				return;
			}
			Event current = Event.current;
			if (current == null || (int)current.type != 7)
			{
				return;
			}
			HudPainter.Size(_theme, out var w, out var h);
			float num = (float)Screen.height / 1080f * _cfg.Scale.Value;
			float num2 = (float)Screen.width * 0.98f;
			if (w * num > num2)
			{
				num = num2 / w;
			}
			float num3 = w * num;
			float num4 = h * num;
			float originX = ((float)Screen.width - num3) * 0.5f + _cfg.OffsetX.Value * num;
			float originY = ((_cfg.Anchor.Value == HudAnchor.Bottom) ? ((float)Screen.height - num4 - _cfg.OffsetY.Value * num) : (_cfg.OffsetY.Value * num));
			GUI.depth = -1000;
			_canvas.Begin();
			try
			{
				_painter.Paint(_canvas, _state, _theme, originX, originY, num);
				if (_theme.PlayerCards)
				{
					_cardsPainter.Paint(_canvas, _state.Players, _theme, Screen.width, _state.Time, (float)Screen.height / 1080f * _cfg.PlayerCardsScale.Value, _cfg.PlayerCardsOffsetY.Value);
				}
			}
			catch (Exception ex)
			{
				_visible = false;
				Log.LogError((object)("HUD paint failed, hiding HUD (press toggle key to retry): " + ex));
			}
			finally
			{
				_canvas.End();
			}
		}

		private void OnDestroy()
		{
			_hider.Restore();
			if (_canvas != null)
			{
				_canvas.Release();
			}
		}
	}
	internal sealed class ReflectionPath
	{
		private sealed class Seg
		{
			public string Name;

			public object[] Args;

			public int[] Indexes;

			public Type CachedFor;

			public FieldInfo Field;

			public PropertyInfo Prop;

			public MethodInfo Method;

			public object[] ConvertedArgs;
		}

		private const BindingFlags All = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private readonly string _text;

		private readonly string _typeName;

		private readonly Seg[] _segs;

		private readonly bool _findRoot;

		private readonly ManualLogSource _log;

		private Type _type;

		private float _nextTypeLookup;

		private float _typeRetry = 2f;

		private Object _root;

		private float _nextFind;

		private string _lastError;

		private ReflectionPath(string text, string typeName, Seg[] segs, bool findRoot, ManualLogSource log)
		{
			_text = text;
			_typeName = typeName;
			_segs = segs;
			_findRoot = findRoot;
			_log = log;
		}

		public static ReflectionPath Parse(string text, bool findRoot, ManualLogSource log)
		{
			int num = text.IndexOf("::", StringComparison.Ordinal);
			string text2 = ((num < 0) ? text : text.Substring(0, num)).Trim();
			string obj = ((num < 0) ? "" : text.Substring(num + 2).Trim());
			if (text2.Length == 0)
			{
				throw new FormatException("missing type name before '::'");
			}
			if (obj.Length == 0 && !findRoot)
			{
				throw new FormatException("missing member after '::'");
			}
			List<Seg> list = new List<Seg>();
			foreach (string item in SplitMembers(obj))
			{
				string text3 = item.Trim();
				if (text3.Length == 0)
				{
					continue;
				}
				Seg seg = new Seg();
				int i;
				for (i = 0; i < text3.Length && text3[i] != '(' && text3[i] != '['; i++)
				{
				}
				seg.Name = text3.Substring(0, i).Trim();
				if (i < text3.Length && text3[i] == '(')
				{
					int num2 = text3.IndexOf(')', i);
					if (num2 < 0)
					{
						throw new FormatException("unclosed '(' in " + text3);
					}
					seg.Args = ParseArgs(text3.Substring(i + 1, num2 - i - 1));
					i = num2 + 1;
				}
				List<int> list2 = new List<int>();
				while (i < text3.Length && text3[i] == '[')
				{
					int num3 = text3.IndexOf(']', i);
					if (num3 < 0)
					{
						throw new FormatException("unclosed '[' in " + text3);
					}
					list2.Add(int.Parse(text3.Substring(i + 1, num3 - i - 1).Trim(), CultureInfo.InvariantCulture));
					i = num3 + 1;
				}
				seg.Indexes = list2.ToArray();
				list.Add(seg);
			}
			return new ReflectionPath(text, text2, list.ToArray(), findRoot, log);
		}

		private static IEnumerable<string> SplitMembers(string s)
		{
			int depth = 0;
			int num = 0;
			for (int i = 0; i < s.Length; i++)
			{
				switch (s[i])
				{
				case '(':
					depth++;
					break;
				case ')':
					depth--;
					break;
				case '.':
					if (depth == 0)
					{
						yield return s.Substring(num, i - num);
						num = i + 1;
					}
					break;
				}
			}
			if (num < s.Length)
			{
				yield return s.Substring(num);
			}
		}

		private static object[] ParseArgs(string s)
		{
			s = s.Trim();
			if (s.Length == 0)
			{
				return new object[0];
			}
			string[] array = s.Split(new char[1] { ',' });
			object[] array2 = new object[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				int result;
				double result2;
				bool result3;
				if (text.StartsWith("\"") && text.EndsWith("\"") && text.Length >= 2)
				{
					array2[i] = text.Substring(1, text.Length - 2);
				}
				else if (int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
				{
					array2[i] = result;
				}
				else if (double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out result2))
				{
					array2[i] = result2;
				}
				else if (bool.TryParse(text, out result3))
				{
					array2[i] = result3;
				}
				else
				{
					array2[i] = text;
				}
			}
			return array2;
		}

		public bool TryEvaluate(out object value)
		{
			value = null;
			try
			{
				if (!ResolveType())
				{
					return false;
				}
				object obj = null;
				if (_findRoot)
				{
					if (_root == (Object)null)
					{
						float unscaledTime = Time.unscaledTime;
						if (unscaledTime < _nextFind)
						{
							return false;
						}
						_nextFind = unscaledTime + 0.5f;
						_root = Object.FindObjectOfType(_type);
						if (_root == (Object)null)
						{
							return false;
						}
					}
					obj = _root;
				}
				for (int i = 0; i < _segs.Length; i++)
				{
					Seg seg = _segs[i];
					Type type = ((obj != null) ? obj.GetType() : _type);
					if ((object)seg.CachedFor != type && !Bind(seg, type))
					{
						return false;
					}
					if (obj == null && !IsStaticSeg(seg))
					{
						Warn("'" + seg.Name + "' is an instance member; use find: instead of reflect:, or start from a static member");
						return false;
					}
					object obj2;
					if ((object)seg.Method != null)
					{
						obj2 = seg.Method.Invoke(seg.Method.IsStatic ? null : obj, seg.ConvertedArgs);
					}
					else if ((object)seg.Field != null)
					{
						obj2 = seg.Field.GetValue(seg.Field.IsStatic ? null : obj);
					}
					else
					{
						MethodInfo? getMethod = seg.Prop.GetGetMethod(nonPublic: true);
						obj2 = getMethod.Invoke(getMethod.IsStatic ? null : obj, null);
					}
					for (int j = 0; j < seg.Indexes.Length; j++)
					{
						if (obj2 == null)
						{
							break;
						}
						obj2 = Index(obj2, seg.Indexes[j]);
					}
					if (obj2 == null)
					{
						return false;
					}
					obj = obj2;
				}
				value = obj;
				_lastError = null;
				return obj != null;
			}
			catch (Exception ex)
			{
				Exception ex2 = ((ex is TargetInvocationException && ex.InnerException != null) ? ex.InnerException : ex);
				Warn(ex2.GetType().Name + ": " + ex2.Message);
				return false;
			}
		}

		private static bool IsStaticSeg(Seg seg)
		{
			if ((object)seg.Method != null)
			{
				return seg.Method.IsStatic;
			}
			if ((object)seg.Field != null)
			{
				return seg.Field.IsStatic;
			}
			return seg.Prop.GetGetMethod(nonPublic: true)?.IsStatic ?? false;
		}

		private static object Index(object o, int i)
		{
			if (o is Array array)
			{
				if (i < 0 || i >= array.Length)
				{
					return null;
				}
				return array.GetValue(i);
			}
			if (o is IList list)
			{
				if (i < 0 || i >= list.Count)
				{
					return null;
				}
				return list[i];
			}
			return null;
		}

		private bool Bind(Seg seg, Type type)
		{
			seg.Field = null;
			seg.Prop = null;
			seg.Method = null;
			seg.ConvertedArgs = null;
			Type type2 = type;
			while ((object)type2 != null)
			{
				if (seg.Args != null)
				{
					MethodInfo[] methods = type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo in methods)
					{
						if (methodInfo.Name != seg.Name)
						{
							continue;
						}
						ParameterInfo[] parameters = methodInfo.GetParameters();
						if (parameters.Length != seg.Args.Length)
						{
							continue;
						}
						object[] array = new object[parameters.Length];
						bool flag = true;
						for (int j = 0; j < parameters.Length && flag; j++)
						{
							try
							{
								array[j] = (parameters[j].ParameterType.IsEnum ? Enum.ToObject(parameters[j].ParameterType, seg.Args[j]) : Convert.ChangeType(seg.Args[j], parameters[j].ParameterType, CultureInfo.InvariantCulture));
							}
							catch
							{
								flag = false;
							}
						}
						if (flag)
						{
							seg.Method = methodInfo;
							seg.ConvertedArgs = array;
							break;
						}
					}
					if ((object)seg.Method != null)
					{
						break;
					}
				}
				else
				{
					seg.Field = type2.GetField(seg.Name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if ((object)seg.Field != null)
					{
						break;
					}
					seg.Prop = type2.GetProperty(seg.Name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if ((object)seg.Prop != null && seg.Prop.GetIndexParameters().Length == 0 && (object)seg.Prop.GetGetMethod(nonPublic: true) != null)
					{
						break;
					}
					seg.Prop = null;
				}
				type2 = type2.BaseType;
			}
			if ((object)seg.Field == null && (object)seg.Prop == null && (object)seg.Method == null)
			{
				Warn("no member '" + seg.Name + ((seg.Args != null) ? ("(" + seg.Args.Length + " args)") : "") + "' on " + type.FullName);
				seg.CachedFor = null;
				return false;
			}
			seg.CachedFor = type;
			return true;
		}

		private bool ResolveType()
		{
			if ((object)_type != null)
			{
				return true;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextTypeLookup)
			{
				return false;
			}
			_type = FindType(_typeName);
			if ((object)_type == null)
			{
				_nextTypeLookup = unscaledTime + _typeRetry;
				_typeRetry = Math.Min(30f, _typeRetry * 2f);
				Warn("type '" + _typeName + "' not found (will retry)");
				return false;
			}
			_log.LogInfo((object)("Linked '" + _text + "' -> " + _type.AssemblyQualifiedName));
			return true;
		}

		internal static Type FindType(string name)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			for (int i = 0; i < array.Length; i++)
			{
				Type type = array[i].GetType(name, throwOnError: false);
				if ((object)type != null)
				{
					return type;
				}
			}
			array = assemblies;
			foreach (Assembly assembly in array)
			{
				Type[] types;
				try
				{
					types = assembly.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					types = ex.Types;
				}
				catch
				{
					continue;
				}
				Type[] array2 = types;
				foreach (Type type2 in array2)
				{
					if ((object)type2 != null && (type2.Name == name || type2.FullName == name))
					{
						return type2;
					}
				}
			}
			return null;
		}

		private void Warn(string msg)
		{
			if (!(msg == _lastError))
			{
				_lastError = msg;
				_log.LogWarning((object)("[" + _text + "] " + msg));
			}
		}
	}
	public enum ValueKind
	{
		Speed,
		Timer,
		Song
	}
	public static class NeonHudFeed
	{
		private static float _speed;

		private static float _speedAt = -100f;

		private static float _timer;

		private static float _timerAt = -100f;

		private static string _song;

		private static float _relProgress;

		private static float _relAt = -100f;

		private static int _relFrames = -1;

		private static bool _relActive;

		private static bool _relReduced;

		public static void SetBallSpeed(float speed)
		{
			_speed = speed;
			_speedAt = Time.unscaledTime;
		}

		public static void SetTimer(float seconds)
		{
			_timer = seconds;
			_timerAt = Time.unscaledTime;
		}

		public static void SetSong(string title)
		{
			_song = title;
		}

		public static void SetRelease(float progress, int framesLeft, bool reduced)
		{
			_relActive = true;
			_relProgress = progress;
			_relFrames = framesLeft;
			_relReduced = reduced;
			_relAt = Time.unscaledTime;
		}

		public static void SetNoRelease()
		{
			_relActive = false;
			_relAt = Time.unscaledTime;
		}

		internal static bool TryGetRelease(out bool active, out float progress, out int framesLeft, out bool reduced)
		{
			active = _relActive;
			progress = _relProgress;
			framesLeft = _relFrames;
			reduced = _relReduced;
			return Time.unscaledTime - _relAt < 0.5f;
		}

		internal static bool TryGet(ValueKind kind, out object value)
		{
			float unscaledTime = Time.unscaledTime;
			switch (kind)
			{
			case ValueKind.Speed:
				value = _speed;
				return unscaledTime - _speedAt < 1f;
			case ValueKind.Timer:
				value = _timer;
				return unscaledTime - _timerAt < 1f;
			default:
				value = _song;
				return !string.IsNullOrEmpty(_song);
			}
		}
	}
	internal abstract class Source
	{
		public virtual string Label => "CFG";

		public abstract bool TryGet(out object value);
	}
	internal sealed class NullSource : Source
	{
		public override string Label => "NO LINK";

		public override bool TryGet(out object value)
		{
			value = null;
			return false;
		}
	}
	internal sealed class ChainSource : Source
	{
		private readonly Source[] _items;

		private readonly ValueKind _kind;

		private string _label;

		public override string Label => _label;

		public ChainSource(Source[] items, ValueKind kind)
		{
			_items = items;
			_kind = kind;
			_label = ((items.Length != 0) ? items[0].Label : "NO LINK");
		}

		public override bool TryGet(out object value)
		{
			for (int i = 0; i < _items.Length; i++)
			{
				if (_items[i].TryGet(out value) && Usable(_kind, value))
				{
					_label = _items[i].Label;
					return true;
				}
			}
			value = null;
			_label = "NO LINK";
			return false;
		}

		internal static bool Usable(ValueKind kind, object v)
		{
			if (v == null)
			{
				return false;
			}
			float f;
			switch (kind)
			{
			case ValueKind.Speed:
				if (ValueConv.ToFloat(v, out f) && f >= 0f && !float.IsNaN(f))
				{
					return !float.IsInfinity(f);
				}
				return false;
			case ValueKind.Timer:
				if (ValueConv.ToSeconds(v, out f) && f >= 0f)
				{
					return f < 360000f;
				}
				return false;
			default:
			{
				string text = (v as string) ?? v.ToString();
				if (text != null)
				{
					return text.Trim().Length > 0;
				}
				return false;
			}
			}
		}
	}
	internal sealed class StaticSource : Source
	{
		private readonly string _text;

		public StaticSource(string text)
		{
			_text = text;
		}

		public override bool TryGet(out object value)
		{
			value = _text;
			return true;
		}
	}
	internal sealed class FeedSource : Source
	{
		private readonly ValueKind _kind;

		public override string Label => "FEED";

		public FeedSource(ValueKind kind)
		{
			_kind = kind;
		}

		public override bool TryGet(out object value)
		{
			return NeonHudFeed.TryGet(_kind, out value);
		}
	}
	internal sealed class ReflectSource : Source
	{
		private readonly ReflectionPath _path;

		public override string Label => "MATCH";

		public ReflectSource(ReflectionPath path)
		{
			_path = path;
		}

		public override bool TryGet(out object value)
		{
			return _path.TryEvaluate(out value);
		}
	}
	internal sealed class ElapsedSource : Source
	{
		public override string Label => "ELAPSED";

		public override bool TryGet(out object value)
		{
			value = Time.timeSinceLevelLoad;
			return true;
		}
	}
	internal sealed class SceneSource : Source
	{
		private string _scene;

		private string _pretty;

		public override string Label => "SCENE";

		public override bool TryGet(out object value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name != _scene)
			{
				_scene = name;
				_pretty = Pretty.Name(name);
			}
			value = _pretty;
			return !string.IsNullOrEmpty(_pretty);
		}
	}
	internal sealed class UiTextSource : Source
	{
		private readonly string _path;

		private Component _comp;

		private PropertyInfo _prop;

		private FieldInfo _field;

		private float _nextFind;

		public override string Label => "MATCH";

		public UiTextSource(string path)
		{
			_path = path;
		}

		public override bool TryGet(out object value)
		{
			value = null;
			if ((Object)(object)_comp == (Object)null)
			{
				float unscaledTime = Time.unscaledTime;
				if (unscaledTime < _nextFind)
				{
					return false;
				}
				_nextFind = unscaledTime + 1f;
				GameObject val = GameObject.Find(_path);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				Component[] components = val.GetComponents<Component>();
				foreach (Component val2 in components)
				{
					if (!((Object)(object)val2 == (Object)null) && TextAccess.Find(((object)val2).GetType(), out var prop, out var field))
					{
						_comp = val2;
						_prop = prop;
						_field = field;
						break;
					}
				}
				if ((Object)(object)_comp == (Object)null)
				{
					return false;
				}
			}
			value = (((object)_prop != null) ? _prop.GetValue(_comp, null) : _field.GetValue(_comp));
			return value != null;
		}
	}
	internal sealed class TrackSource : Source
	{
		private readonly string _name;

		private Transform _t;

		private float _nextFind;

		private float _lastMoving;

		private float _speed;

		private Vector3 _last;

		private bool _hasLast;

		private int _lastFrame = -1;

		public override string Label => "TRACK";

		public TrackSource(string name)
		{
			_name = name;
		}

		public override bool TryGet(out object value)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			value = null;
			if ((Object)(object)_t == (Object)null)
			{
				float unscaledTime = Time.unscaledTime;
				if (unscaledTime < _nextFind)
				{
					return false;
				}
				_nextFind = unscaledTime + 1f;
				GameObject val = GameObject.Find(_name);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				_t = val.transform;
				_hasLast = false;
			}
			if (Time.frameCount == _lastFrame)
			{
				value = _speed;
				return true;
			}
			_lastFrame = Time.frameCount;
			Vector3 position = _t.position;
			float deltaTime = Time.deltaTime;
			if (!_hasLast || deltaTime <= 0f)
			{
				_last = position;
				_hasLast = true;
				value = _speed;
				return true;
			}
			Vector3 val2 = position - _last;
			float num = ((Vector3)(ref val2)).magnitude / deltaTime;
			_last = position;
			float unscaledTime2 = Time.unscaledTime;
			if (num > 0.01f)
			{
				_speed = ((_speed <= 0f) ? num : (_speed + (num - _speed) * 0.35f));
				_lastMoving = unscaledTime2;
			}
			else if (unscaledTime2 - _lastMoving > 0.75f)
			{
				_speed = 0f;
			}
			value = _speed;
			return true;
		}
	}
	internal sealed class AudioSongSource : Source
	{
		private float _next;

		private AudioClip _clip;

		private string _title;

		public override string Label => "AUDIO";

		public override bool TryGet(out object value)
		{
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime >= _next)
			{
				_next = unscaledTime + 1f;
				AudioSource val = null;
				float num = 0f;
				Object[] array = Object.FindObjectsOfType(typeof(AudioSource));
				foreach (Object obj in array)
				{
					AudioSource val2 = (AudioSource)(object)((obj is AudioSource) ? obj : null);
					if ((Object)(object)val2 == (Object)null || !val2.isPlaying || (Object)(object)val2.clip == (Object)null)
					{
						continue;
					}
					float length = val2.clip.length;
					if (!(length < 30f))
					{
						float num2 = length * (val2.loop ? 2f : 1f);
						if (num2 > num)
						{
							val = val2;
							num = num2;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					_clip = null;
					_title = null;
				}
				else if ((Object)(object)val.clip != (Object)(object)_clip)
				{
					_clip = val.clip;
					_title = Pretty.Name(((Object)_clip).name);
				}
			}
			value = _title;
			return _title != null;
		}
	}
	internal static class TextAccess
	{
		private static readonly Dictionary<Type, MemberInfo> Cache = new Dictionary<Type, MemberInfo>();

		public static bool Find(Type t, out PropertyInfo prop, out FieldInfo field)
		{
			prop = null;
			field = null;
			if (!Cache.TryGetValue(t, out var value))
			{
				PropertyInfo property = t.GetProperty("text", BindingFlags.Instance | BindingFlags.Public);
				if ((object)property != null && (object)property.PropertyType == typeof(string) && property.CanRead && property.GetIndexParameters().Length == 0)
				{
					value = property;
				}
				else
				{
					FieldInfo fieldInfo = t.GetField("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? t.GetField("m_text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? t.GetField("m_Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if ((object)fieldInfo != null && (object)fieldInfo.FieldType == typeof(string))
					{
						value = fieldInfo;
					}
				}
				Cache[t] = value;
			}
			prop = value as PropertyInfo;
			field = value as FieldInfo;
			return (object)value != null;
		}
	}
	internal sealed class SongText
	{
		private string _raw;

		private string _clean;

		public string Clean(string raw)
		{
			if (raw == null)
			{
				return null;
			}
			if (raw == _raw)
			{
				return _clean;
			}
			_raw = raw;
			_clean = Convert(raw);
			return _clean;
		}

		internal static string Convert(string raw)
		{
			StringBuilder stringBuilder = new StringBuilder(raw.Length);
			bool flag = false;
			string text = raw;
			foreach (char c in text)
			{
				if (c == '<')
				{
					flag = true;
				}
				else if (flag)
				{
					if (c == '>')
					{
						flag = false;
					}
				}
				else
				{
					stringBuilder.Append(c);
				}
			}
			string text2 = stringBuilder.ToString().Trim();
			if (text2.Length == 0)
			{
				return null;
			}
			int num = text2.LastIndexOfAny(new char[2] { '/', '\\' });
			if (num >= 0 && num < text2.Length - 1 && text2.IndexOf(' ') < 0)
			{
				text2 = text2.Substring(num + 1);
			}
			if (text2.IndexOf(' ') < 0)
			{
				return Pretty.Name(text2);
			}
			stringBuilder.Length = 0;
			bool flag2 = false;
			text = text2;
			foreach (char c2 in text)
			{
				switch (c2)
				{
				case '\n':
					stringBuilder.Append(" // ");
					flag2 = true;
					continue;
				case '\r':
					continue;
				}
				if (char.IsWhiteSpace(c2))
				{
					if (!flag2)
					{
						stringBuilder.Append(' ');
					}
					flag2 = true;
				}
				else
				{
					stringBuilder.Append(c2);
					flag2 = false;
				}
			}
			return stringBuilder.ToString().Trim().ToUpperInvariant();
		}
	}
	internal static class Pretty
	{
		private static readonly string[] Prefixes = new string[7] { "bgm_", "bgm", "music_", "mus_", "song_", "track_", "snd_" };

		public static string Name(string raw)
		{
			if (string.IsNullOrEmpty(raw))
			{
				return raw;
			}
			string text = raw.Trim();
			string text2 = text.ToLowerInvariant();
			string[] prefixes = Prefixes;
			foreach (string text3 in prefixes)
			{
				if (text2.StartsWith(text3) && text.Length > text3.Length)
				{
					text = text.Substring(text3.Length);
					break;
				}
			}
			if (text.EndsWith("_loop", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(0, text.Length - 5);
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length + 4);
			char c = ' ';
			string text4 = text;
			foreach (char c2 in text4)
			{
				char c3 = ((c2 == '_' || c2 == '-') ? ' ' : c2);
				if (c3 != ' ' || c != ' ')
				{
					if (char.IsUpper(c3) && char.IsLower(c))
					{
						stringBuilder.Append(' ');
					}
					stringBuilder.Append(c3);
					c = c3;
				}
			}
			return stringBuilder.ToString().Trim().ToUpperInvariant();
		}
	}
	internal static class ValueConv
	{
		public static bool ToFloat(object o, out float f)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			f = 0f;
			if (o == null)
			{
				return false;
			}
			if (o is float)
			{
				f = (float)o;
				return true;
			}
			if (o is int)
			{
				f = (int)o;
				return true;
			}
			if (o is double)
			{
				f = (float)(double)o;
				return true;
			}
			if (o is long)
			{
				f = (long)o;
				return true;
			}
			if (o is bool)
			{
				f = (((bool)o) ? 1f : 0f);
				return true;
			}
			if (o is Vector3)
			{
				Vector3 val = (Vector3)o;
				f = ((Vector3)(ref val)).magnitude;
				return true;
			}
			if (o is Vector2)
			{
				Vector2 val2 = (Vector2)o;
				f = ((Vector2)(ref val2)).magnitude;
				return true;
			}
			if (o is string s)
			{
				return Number(s, out f);
			}
			if (o is IConvertible)
			{
				try
				{
					f = Convert.ToSingle(o, CultureInfo.InvariantCulture);
					return true;
				}
				catch
				{
				}
			}
			return Number(o.ToString(), out f);
		}

		public static bool ToSeconds(object o, out float secs)
		{
			if (o is string text && text.IndexOf(':') >= 0)
			{
				secs = 0f;
				string[] array = text.Trim().Split(new char[1] { ':' });
				for (int i = 0; i < array.Length; i++)
				{
					if (!Number(array[i], out var f))
					{
						return false;
					}
					secs = secs * 60f + f;
				}
				return true;
			}
			return ToFloat(o, out secs);
		}

		public static bool Number(string s, out float f)
		{
			f = 0f;
			if (string.IsNullOrEmpty(s))
			{
				return false;
			}
			int i;
			for (i = 0; i < s.Length && !char.IsDigit(s[i]); i++)
			{
			}
			if (i >= s.Length)
			{
				return false;
			}
			bool flag = i > 0 && s[i - 1] == '-';
			StringBuilder stringBuilder = new StringBuilder(12);
			bool flag2 = false;
			for (; i < s.Length; i++)
			{
				char c = s[i];
				if (char.IsDigit(c))
				{
					stringBuilder.Append(c);
				}
				else if (c == '.' && !flag2)
				{
					flag2 = true;
					stringBuilder.Append(c);
				}
				else if (c != ',')
				{
					break;
				}
			}
			if (!float.TryParse(stringBuilder.ToString(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return false;
			}
			f = (flag ? (0f - result) : result);
			return true;
		}
	}
	internal static class SourceFactory
	{
		public static So