Decompiled source of Mod Menu v1.0.1

BrigadeModMenu.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BrigadeModMenu;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ModMenuMod), "Mod Menu", "1.0.1", "BrigadeModMenu", null)]
[assembly: MelonGame("BoltBlasterGames", "TheSpellBrigade")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BrigadeModMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("BrigadeModMenu")]
[assembly: AssemblyTitle("BrigadeModMenu")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BrigadeModMenu
{
	public static class Menu
	{
		internal static readonly List<Page> Pages = new List<Page>();

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

		internal static int Version;

		public static Page AddPage(string id, Func<string> title)
		{
			if (string.IsNullOrEmpty(id))
			{
				throw new ArgumentException("A page needs an id", "id");
			}
			foreach (Page page2 in Pages)
			{
				if (page2.Id == id)
				{
					return page2;
				}
			}
			Page page = new Page(id, title ?? ((Func<string>)(() => id)));
			Pages.Add(page);
			HideCategory(id);
			Version++;
			return page;
		}

		public static Page AddPage(string id, string title)
		{
			return AddPage(id, () => title);
		}

		public static void HideCategory(string id)
		{
			if (!string.IsNullOrEmpty(id) && Claimed.Add(id))
			{
				Version++;
			}
		}

		public static void Refresh()
		{
			Version++;
		}

		internal static bool IsClaimed(string id)
		{
			return Claimed.Contains(id);
		}
	}
	public sealed class Page
	{
		internal readonly Func<string> Title;

		internal readonly List<Item> Items = new List<Item>();

		private static readonly IList<string> OnOff = new string[2] { "On", "Off" };

		public string Id { get; }

		internal Page(string id, Func<string> title)
		{
			Id = id;
			Title = title;
		}

		public Page Header(Func<string> text)
		{
			return Add(new HeaderItem
			{
				Label = text
			});
		}

		public Page Header(string text)
		{
			return Header(() => text);
		}

		public Page Note(Func<string> text)
		{
			return Add(new NoteItem
			{
				Label = text
			});
		}

		public Page Note(string text)
		{
			return Note(() => text);
		}

		public Page Toggle(Func<string> label, Func<bool> get, Action<bool> set, bool? defaultValue = null)
		{
			return Add(new OptionItem
			{
				Label = label,
				Options = () => OnOff,
				Get = () => (!get()) ? 1 : 0,
				Set = delegate(int i)
				{
					set(i == 0);
				},
				IsDefault = ((!defaultValue.HasValue) ? null : ((Func<bool>)(() => get() == defaultValue.Value))),
				Reset = ((!defaultValue.HasValue) ? null : ((Action)delegate
				{
					set(defaultValue.Value);
				}))
			});
		}

		public Page Toggle(string label, Func<bool> get, Action<bool> set, bool? defaultValue = null)
		{
			return Toggle(() => label, get, set, defaultValue);
		}

		public Page Choice(Func<string> label, Func<IList<string>> options, Func<int> get, Action<int> set, int? defaultValue = null)
		{
			return Add(new OptionItem
			{
				Label = label,
				Options = options,
				Get = get,
				Set = set,
				IsDefault = ((!defaultValue.HasValue) ? null : ((Func<bool>)(() => get() == defaultValue.Value))),
				Reset = ((!defaultValue.HasValue) ? null : ((Action)delegate
				{
					set(defaultValue.Value);
				}))
			});
		}

		public Page Choice(string label, IList<string> options, Func<int> get, Action<int> set, int? defaultValue = null)
		{
			return Choice(() => label, () => options, get, set, defaultValue);
		}

		public Page Number(Func<string> label, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format = null, float? defaultValue = null)
		{
			return Add(Numbers.Item(label, Numbers.Steps(min, max, step), get, set, format, defaultValue));
		}

		public Page Number(string label, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format = null, float? defaultValue = null)
		{
			return Number(() => label, min, max, step, get, set, format, defaultValue);
		}

		public Page Button(Func<string> text, Action onClick, bool danger = false)
		{
			return Buttons(new MenuButton(text, onClick, danger));
		}

		public Page Button(string text, Action onClick, bool danger = false)
		{
			return Button(() => text, onClick, danger);
		}

		public Page Buttons(params MenuButton[] buttons)
		{
			if (buttons != null && buttons.Length != 0)
			{
				return Add(new ButtonItem
				{
					Buttons = new List<MenuButton>(buttons)
				});
			}
			return this;
		}

		public Page Custom(float height, Func<RectTransform, Selectable> build)
		{
			return Add(new CustomItem
			{
				Height = height,
				Build = build
			});
		}

		public Page List(Func<IList<ListEntry>> entries, Func<string> whenEmpty = null)
		{
			return Add(new ListItem
			{
				Entries = entries,
				Empty = (whenEmpty ?? ((Func<string>)(() => "Nothing here yet.")))
			});
		}

		public Page Entry(ConfigEntryBase entry, Func<string> label = null)
		{
			if (entry == null)
			{
				return this;
			}
			Menu.HideCategory(entry.Definition.Section);
			OptionItem optionItem = Settings.ItemFor(Settings.From(entry), label);
			if (optionItem != null)
			{
				return Add(optionItem);
			}
			return this;
		}

		internal Page Add(Item item)
		{
			Items.Add(item);
			Menu.Version++;
			return this;
		}
	}
	internal abstract class Item
	{
		public Func<string> Label;
	}
	internal sealed class HeaderItem : Item
	{
	}
	internal sealed class NoteItem : Item
	{
	}
	internal sealed class OptionItem : Item
	{
		public Func<IList<string>> Options;

		public Func<int> Get;

		public Action<int> Set;

		public Func<bool> IsDefault;

		public Action Reset;
	}
	internal sealed class ButtonItem : Item
	{
		public List<MenuButton> Buttons;
	}
	public sealed class MenuButton
	{
		internal readonly Func<string> Text;

		internal readonly Action OnClick;

		internal readonly bool Danger;

		public MenuButton(Func<string> text, Action onClick, bool danger = false)
		{
			Text = text;
			OnClick = onClick;
			Danger = danger;
		}

		public MenuButton(string text, Action onClick, bool danger = false)
			: this(() => text, onClick, danger)
		{
		}
	}
	internal sealed class ListItem : Item
	{
		public Func<IList<ListEntry>> Entries;

		public Func<string> Empty;
	}
	public sealed class ListEntry
	{
		public readonly string Text;

		public readonly string Note;

		public readonly MenuButton[] Buttons;

		public ListEntry(string text, string note = null, params MenuButton[] buttons)
		{
			Text = text ?? "";
			Note = note;
			Buttons = buttons ?? Array.Empty<MenuButton>();
		}

		public ListEntry(string text, params MenuButton[] buttons)
			: this(text, null, buttons)
		{
		}

		internal string Key()
		{
			string text = Text + "\u0001" + Note;
			MenuButton[] buttons = Buttons;
			foreach (MenuButton menuButton in buttons)
			{
				text = text + "\u0001" + menuButton.Text?.Invoke();
			}
			return text;
		}
	}
	internal sealed class CustomItem : Item
	{
		public float Height;

		public Func<RectTransform, Selectable> Build;
	}
	internal static class Numbers
	{
		private static readonly float[] NiceSteps = new float[17]
		{
			0.01f, 0.02f, 0.05f, 0.1f, 0.2f, 0.25f, 0.5f, 1f, 2f, 5f,
			10f, 25f, 50f, 100f, 250f, 500f, 1000f
		};

		private static readonly float[] Common = new float[21]
		{
			0f, 0.1f, 0.25f, 0.5f, 0.75f, 1f, 1.5f, 2f, 3f, 4f,
			5f, 10f, 15f, 20f, 25f, 50f, 75f, 100f, 200f, 500f,
			1000f
		};

		public static List<float> Steps(float min, float max, float step)
		{
			if (max < min)
			{
				float num = max;
				max = min;
				min = num;
			}
			if (step <= 0f || (max - min) / step > 200f)
			{
				step = NiceSteps[NiceSteps.Length - 1];
				float[] niceSteps = NiceSteps;
				foreach (float num2 in niceSteps)
				{
					if ((max - min) / num2 <= 60f)
					{
						step = num2;
						break;
					}
				}
			}
			List<float> list = new List<float>();
			int num3 = (int)Math.Floor((max - min) / step + 0.0001f);
			for (int j = 0; j <= num3; j++)
			{
				list.Add((float)Math.Round(min + (float)j * step, 4));
			}
			if (list[list.Count - 1] < max - 0.0001f)
			{
				list.Add(max);
			}
			return list;
		}

		public static List<float> Unbounded(bool whole)
		{
			List<float> list = new List<float>();
			float[] common = Common;
			foreach (float num in common)
			{
				if (!whole || Math.Abs((double)num - Math.Round(num)) < 0.0001)
				{
					list.Add(num);
				}
			}
			return list;
		}

		public static OptionItem Item(Func<string> label, List<float> values, Func<float> get, Action<float> set, Func<float, string> format, float? defaultValue)
		{
			if (format == null)
			{
				format = (float v) => v.ToString("0.##", CultureInfo.InvariantCulture);
			}
			List<float> shown = new List<float>(values);
			return new OptionItem
			{
				Label = label,
				Options = delegate
				{
					Sync();
					return shown.ConvertAll((float v) => format(v));
				},
				Get = delegate
				{
					float now = get();
					return shown.FindIndex((float v) => Math.Abs(v - now) < 0.0001f);
				},
				Set = delegate(int i)
				{
					if (i >= 0 && i < shown.Count)
					{
						set(shown[i]);
					}
				},
				IsDefault = ((!defaultValue.HasValue) ? null : ((Func<bool>)(() => Math.Abs(get() - defaultValue.Value) < 0.0001f))),
				Reset = ((!defaultValue.HasValue) ? null : ((Action)delegate
				{
					set(defaultValue.Value);
				}))
			};
			void Sync()
			{
				float now = get();
				shown.Clear();
				shown.AddRange(values);
				if (shown.FindIndex((float v) => Math.Abs(v - now) < 0.0001f) < 0)
				{
					shown.Add(now);
					shown.Sort();
				}
			}
		}
	}
	public sealed class HudElement
	{
		public string Name;

		public Func<RectTransform, RectTransform> Build;

		public Action<RectTransform> Place;

		public Func<RectTransform> Live;

		public Func<Vector2> GetOffset;

		public Action<Vector2> SetOffset;

		public Func<float> GetSize;

		public Action<float> SetSize;

		public float MinSize = 0.5f;

		public float MaxSize = 2f;

		public float SizeStep = 0.05f;

		public Func<Vector2> GetDimensions;

		public Action<Vector2> SetDimensions;

		public Vector2 MinDimensions = new Vector2(50f, 50f);

		public Vector2 MaxDimensions = new Vector2(4000f, 4000f);

		public Action Reset;

		public string[] HideFromPreview;
	}
	public static class HudEditor
	{
		private enum DragKind
		{
			None,
			Move,
			Corner,
			Edge,
			Box
		}

		private static readonly List<HudElement> Elements = new List<HudElement>();

		private static readonly HashSet<string> WantedSprites = new HashSet<string>();

		private static Dictionary<string, float[]> _measured;

		private static IntPtr _run;

		private static float _runStart;

		private static bool _doneThisRun;

		private const string RunInfoKey = "ModMenu.RunInfo";

		private const string CyclePath = "RunInfoVisualizers/Icons_Panel/Cycle/CycleNumber_Text";

		private const string DevotionPath = "RunInfoVisualizers/Icons_Panel/Devotion/DevotionNumber_Text";

		private const float Grab = 26f;

		private static GameObject _root;

		private static Canvas _canvas;

		private static RectTransform _area;

		private static RectTransform _frame;

		private static RectTransform _box;

		private static Transform _hud;

		private static readonly List<(HudElement element, RectTransform root)> Shown = new List<(HudElement, RectTransform)>();

		private static readonly HashSet<HudElement> LiveShown = new HashSet<HudElement>();

		private static bool _inMission;

		private static readonly List<Canvas> HiddenCanvases = new List<Canvas>();

		private static BlurManager _blur;

		private static Canvas _gameHud;

		private static readonly Dictionary<IntPtr, (GameObject go, bool active)> ChangedActive = new Dictionary<IntPtr, (GameObject, bool)>();

		private static readonly Dictionary<IntPtr, (CanvasGroup group, float alpha)> ChangedAlpha = new Dictionary<IntPtr, (CanvasGroup, float)>();

		private static readonly Dictionary<IntPtr, (Canvas canvas, bool enabled)> ChangedCanvas = new Dictionary<IntPtr, (Canvas, bool)>();

		private static int _blurCount;

		private static int _selected;

		private static float _openedAt;

		private static bool _navWasOn;

		private static TMP_Text _title;

		private static Vector2 _boxOffset;

		private static DragKind _drag;

		private static Vector2 _dragStart;

		private static Vector2 _startOffset;

		private static Vector2 _startDims;

		private static Vector2 _fixedPoint;

		private static Vector2 _edgeDir;

		private static Vector2 _boxStart;

		private static float _startSize;

		private static float _startSpan;

		private static readonly Color Gold = new Color(0.96f, 0.76f, 0.3f, 1f);

		private static ButtonPromptConfiguration _prompts;

		private static bool _loggedIcons;

		private static TMP_FontAsset _font;

		private static readonly HashSet<string> Failed = new HashSet<string>();

		private static bool _changed;

		public static bool IsOpen
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return !((Il2CppObjectBase)_root).WasCollected;
				}
				return false;
			}
		}

		private static string MeasuredPath => Path.Combine(Path.GetDirectoryName(HudRecording.Path), "BrigadeModMenu_measured.txt");

		public static void Register(HudElement element)
		{
			if (element != null)
			{
				Elements.RemoveAll((HudElement e) => e.Name == element.Name);
				Elements.Add(element);
			}
		}

		public static void RecordSprites(params string[] names)
		{
			foreach (string text in names)
			{
				if (!string.IsNullOrEmpty(text))
				{
					WantedSprites.Add(text);
				}
			}
		}

		public static Sprite Sprite(string name)
		{
			foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
			{
				if ((Object)(object)item != (Object)null && ((Object)item).name == name)
				{
					return item;
				}
			}
			return HudRecording.Named(name);
		}

		public static RectTransform Recorded(string path)
		{
			if ((Object)(object)_hud == (Object)null || ((Il2CppObjectBase)_hud).WasCollected)
			{
				return null;
			}
			Transform val = _hud.Find(path);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return ((Component)val).GetComponent<RectTransform>();
		}

		public static void Measure(string key, params float[] values)
		{
			if (string.IsNullOrEmpty(key) || values == null || values.Length == 0)
			{
				return;
			}
			LoadMeasured();
			if (_measured.TryGetValue(key, out var value) && value.Length == values.Length)
			{
				bool flag = true;
				for (int i = 0; i < value.Length && flag; i++)
				{
					flag = Mathf.Abs(value[i] - values[i]) < 0.05f;
				}
				if (flag)
				{
					return;
				}
			}
			_measured[key] = (float[])values.Clone();
			try
			{
				CultureInfo ci = CultureInfo.InvariantCulture;
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, float[]> item in _measured)
				{
					list.Add(item.Key + "=" + string.Join(",", Array.ConvertAll(item.Value, (float v) => v.ToString("R", ci))));
				}
				File.WriteAllLines(MeasuredPath, list);
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("saving measurement " + key + ": " + ex.Message);
			}
		}

		public static float[] Measured(string key)
		{
			LoadMeasured();
			if (key == null || !_measured.TryGetValue(key, out var value))
			{
				return null;
			}
			return value;
		}

		private static void LoadMeasured()
		{
			if (_measured != null)
			{
				return;
			}
			_measured = new Dictionary<string, float[]>();
			try
			{
				if (!File.Exists(MeasuredPath))
				{
					return;
				}
				CultureInfo ci = CultureInfo.InvariantCulture;
				string[] array = File.ReadAllLines(MeasuredPath);
				foreach (string text in array)
				{
					int num = text.IndexOf('=');
					if (num <= 0)
					{
						continue;
					}
					try
					{
						_measured[text.Substring(0, num)] = Array.ConvertAll(text.Substring(num + 1).Split(','), (string s) => float.Parse(s, ci));
					}
					catch
					{
					}
				}
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("reading measurements: " + ex.Message);
			}
		}

		internal static void Tick()
		{
			if (IsOpen)
			{
				EditorTick();
			}
			else
			{
				WatchMission();
			}
		}

		private static void WatchMission()
		{
			try
			{
				RunManager instance = NetworkSingleton<RunManager>.Instance;
				if ((Object)(object)instance == (Object)null || !instance.runHasStarted)
				{
					_run = IntPtr.Zero;
					return;
				}
				if (((Il2CppObjectBase)instance).Pointer != _run)
				{
					_run = ((Il2CppObjectBase)instance).Pointer;
					_runStart = Time.unscaledTime;
					_doneThisRun = false;
				}
				if (_doneThisRun || Time.unscaledTime - _runStart < 10f || Time.timeScale < 0.5f)
				{
					return;
				}
				StoreManager instance2 = NetworkSingleton<StoreManager>.Instance;
				if (!((Object)(object)instance2 != (Object)null) || (!instance2.IsShopPanelActive && !instance2.IsExitingStore))
				{
					_doneThisRun = true;
					MeasureRunInfo();
					if (!HudRecording.IsCurrent())
					{
						HudRecorder.Record(ModPrefixes(), WantedSprites);
					}
				}
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("HUD recording: " + ex.Message);
				_doneThisRun = true;
			}
		}

		private static void MeasureRunInfo()
		{
			Canvas hud = MissionHud();
			if (!((Object)(object)hud == (Object)null))
			{
				float num = Number("RunInfoVisualizers/Icons_Panel/Cycle/CycleNumber_Text");
				float num2 = Number("RunInfoVisualizers/Icons_Panel/Devotion/DevotionNumber_Text");
				if (num >= 0f || num2 >= 0f)
				{
					Measure("ModMenu.RunInfo", num, num2);
				}
			}
			float Number(string path)
			{
				Transform obj = ((Component)hud).transform.Find(path);
				TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
				if (!((Object)(object)val != (Object)null) || !float.TryParse(val.text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					return -1f;
				}
				return result;
			}
		}

		private static void ApplyRunInfo()
		{
			float[] array = Measured("ModMenu.RunInfo");
			if (array != null && array.Length >= 2 && !((Object)(object)_hud == (Object)null))
			{
				Set("RunInfoVisualizers/Icons_Panel/Cycle/CycleNumber_Text", array[0]);
				Set("RunInfoVisualizers/Icons_Panel/Devotion/DevotionNumber_Text", array[1]);
			}
			static void Set(string path, float value)
			{
				Transform obj = _hud.Find(path);
				TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
				if ((Object)(object)val != (Object)null && value >= 0f)
				{
					val.text = ((int)value).ToString();
				}
			}
		}

		private static List<string> ModPrefixes()
		{
			List<string> list = new List<string> { "BrigadeModMenu", "MissionTimer", "ScrollCounter", "StatusEffects", "PinnedQuests", "BSM_", "CustomTitles" };
			foreach (HudElement element in Elements)
			{
				if (element.HideFromPreview != null)
				{
					list.AddRange(element.HideFromPreview);
				}
			}
			return list;
		}

		public static void Open(HudElement element)
		{
			if (IsOpen)
			{
				return;
			}
			if (element != null && !Elements.Contains(element))
			{
				Register(element);
			}
			try
			{
				Build(element);
			}
			catch (Exception value)
			{
				ModMenuMod.Log.Warning($"HUD editor: {value}");
				Close();
			}
		}

		public static void Close()
		{
			if ((Object)(object)_root != (Object)null && !((Il2CppObjectBase)_root).WasCollected)
			{
				Object.Destroy((Object)(object)_root);
			}
			_root = null;
			_hud = null;
			Shown.Clear();
			LiveShown.Clear();
			RestoreGame();
			_drag = DragKind.None;
			EventSystem current = EventSystem.current;
			if ((Object)(object)current != (Object)null)
			{
				current.sendNavigationEvents = _navWasOn;
			}
		}

		private static void Build(HudElement selected)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("BrigadeModMenu_HudEditor");
			Object.DontDestroyOnLoad((Object)(object)_root);
			_canvas = _root.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.sortingOrder = 30000;
			CanvasScaler obj = _root.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(3840f, 2160f);
			obj.screenMatchMode = (ScreenMatchMode)0;
			obj.matchWidthOrHeight = 1f;
			_root.AddComponent<GraphicRaycaster>();
			RectTransform component = _root.GetComponent<RectTransform>();
			Canvas val = MissionHud();
			_inMission = (Object)(object)val != (Object)null;
			if (!_inMission)
			{
				((Graphic)((Component)Full(((Graphic)new GameObject("Backdrop").AddComponent<Image>()).rectTransform, (Transform)(object)component)).GetComponent<Image>()).color = new Color(0.05f, 0.06f, 0.09f, 1f);
			}
			_area = Full(new GameObject("HUD Area").AddComponent<RectTransform>(), (Transform)(object)component);
			LayoutRebuilder.ForceRebuildLayoutImmediate(component);
			_hud = (Transform)(object)(_inMission ? null : HudRecording.Build(_area));
			ApplyRunInfo();
			if ((Object)(object)_hud == (Object)null && !_inMission)
			{
				TMP_Text obj2 = Text(_area, 46f, new Color(1f, 1f, 1f, 0.55f), (TextAlignmentOptions)514);
				obj2.text = "Play a mission once (about 10 seconds) and the game's HUD will show here, every time after that.";
				obj2.rectTransform.sizeDelta = new Vector2(2000f, 200f);
				obj2.rectTransform.anchoredPosition = new Vector2(0f, 400f);
			}
			Shown.Clear();
			LiveShown.Clear();
			foreach (HudElement element in Elements)
			{
				RectTransform val2 = null;
				bool flag = _inMission && element.Live != null;
				try
				{
					val2 = (flag ? element.Live() : element.Build?.Invoke(_area));
				}
				catch (Exception ex)
				{
					ModMenuMod.Log.Warning("HUD editor, " + element.Name + ": " + ex.Message);
				}
				if (!((Object)(object)val2 == (Object)null))
				{
					Shown.Add((element, val2));
					if (flag)
					{
						LiveShown.Add(element);
					}
				}
			}
			if (_inMission)
			{
				_gameHud = val;
				ShowWholeHud();
				HideCovering(val);
			}
			_selected = Math.Max(0, Shown.FindIndex(((HudElement element, RectTransform root) s) => s.element == selected));
			_frame = Frame();
			Controls();
			EventSystem current2 = EventSystem.current;
			_navWasOn = (Object)(object)current2 == (Object)null || current2.sendNavigationEvents;
			if ((Object)(object)current2 != (Object)null)
			{
				current2.sendNavigationEvents = false;
			}
			_openedAt = Time.unscaledTime;
		}

		private static Canvas MissionHud()
		{
			try
			{
				RunManager instance = NetworkSingleton<RunManager>.Instance;
				if ((Object)(object)instance == (Object)null || !instance.runHasStarted)
				{
					return null;
				}
				foreach (SpellSlotsDisplay item in Object.FindObjectsOfType<SpellSlotsDisplay>())
				{
					Canvas componentInParent = ((Component)item).GetComponentInParent<Canvas>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						return componentInParent.rootCanvas;
					}
				}
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("HUD editor, finding the mission HUD: " + ex.Message);
			}
			return null;
		}

		private static void HideCovering(Canvas hud)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			HashSet<IntPtr> hashSet = new HashSet<IntPtr>
			{
				((Il2CppObjectBase)hud).Pointer,
				((Il2CppObjectBase)_canvas).Pointer
			};
			foreach (var item2 in Shown)
			{
				RectTransform item = item2.root;
				Canvas val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponentInParent<Canvas>() : null);
				if ((Object)(object)val != (Object)null)
				{
					hashSet.Add(((Il2CppObjectBase)val.rootCanvas).Pointer);
				}
			}
			HiddenCanvases.Clear();
			foreach (Canvas item3 in Object.FindObjectsOfType<Canvas>())
			{
				if (!((Object)(object)item3 == (Object)null) && item3.isRootCanvas && ((Behaviour)item3).enabled && (int)item3.renderMode != 2 && !hashSet.Contains(((Il2CppObjectBase)item3).Pointer))
				{
					((Behaviour)item3).enabled = false;
					HiddenCanvases.Add(item3);
				}
			}
			try
			{
				_blur = Object.FindObjectOfType<BlurManager>();
				if ((Object)(object)_blur != (Object)null)
				{
					_blurCount = _blur.activeCount;
					_blur.activeCount = 0;
					_blur.SetActivenessOnBlurFeature();
				}
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("HUD editor, blur: " + ex.Message);
				_blur = null;
			}
		}

		private static void ShowWholeHud()
		{
			if ((Object)(object)_gameHud == (Object)null || ((Il2CppObjectBase)_gameHud).WasCollected)
			{
				return;
			}
			Enable(_gameHud);
			Opaque(((Component)_gameHud).GetComponent<CanvasGroup>());
			Transform transform = ((Component)_gameHud).transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if (HudRecorder.LeaveOut.Contains(((Object)child).name))
				{
					SetActive(((Component)child).gameObject, on: false);
				}
				else if (HudRecorder.GameParts.Contains(((Object)child).name) && (!(((Object)child).name == "PartyInfo_Panel") || HasShownChild(child.Find("Content"))))
				{
					SetActive(((Component)child).gameObject, on: true);
					Opaque(((Component)child).GetComponent<CanvasGroup>());
					Enable(((Component)child).GetComponent<Canvas>());
				}
			}
		}

		private static bool HasShownChild(Transform t)
		{
			if ((Object)(object)t == (Object)null)
			{
				return false;
			}
			for (int i = 0; i < t.childCount; i++)
			{
				if (((Component)t.GetChild(i)).gameObject.activeSelf)
				{
					return true;
				}
			}
			return false;
		}

		private static void SetActive(GameObject go, bool on)
		{
			if (go.activeSelf != on)
			{
				if (!ChangedActive.ContainsKey(((Il2CppObjectBase)go).Pointer))
				{
					ChangedActive[((Il2CppObjectBase)go).Pointer] = (go, go.activeSelf);
				}
				go.SetActive(on);
			}
		}

		private static void Opaque(CanvasGroup group)
		{
			if (!((Object)(object)group == (Object)null) && !(group.alpha >= 0.999f))
			{
				if (!ChangedAlpha.ContainsKey(((Il2CppObjectBase)group).Pointer))
				{
					ChangedAlpha[((Il2CppObjectBase)group).Pointer] = (group, group.alpha);
				}
				group.alpha = 1f;
			}
		}

		private static void Enable(Canvas canvas)
		{
			if (!((Object)(object)canvas == (Object)null) && !((Behaviour)canvas).enabled)
			{
				if (!ChangedCanvas.ContainsKey(((Il2CppObjectBase)canvas).Pointer))
				{
					ChangedCanvas[((Il2CppObjectBase)canvas).Pointer] = (canvas, ((Behaviour)canvas).enabled);
				}
				((Behaviour)canvas).enabled = true;
			}
		}

		private static void RestoreGame()
		{
			foreach (var (val, active) in ChangedActive.Values)
			{
				if ((Object)(object)val != (Object)null && !((Il2CppObjectBase)val).WasCollected)
				{
					val.SetActive(active);
				}
			}
			foreach (var (val2, alpha) in ChangedAlpha.Values)
			{
				if ((Object)(object)val2 != (Object)null && !((Il2CppObjectBase)val2).WasCollected)
				{
					val2.alpha = alpha;
				}
			}
			foreach (var (val3, enabled) in ChangedCanvas.Values)
			{
				if ((Object)(object)val3 != (Object)null && !((Il2CppObjectBase)val3).WasCollected)
				{
					((Behaviour)val3).enabled = enabled;
				}
			}
			ChangedActive.Clear();
			ChangedAlpha.Clear();
			ChangedCanvas.Clear();
			_gameHud = null;
			foreach (Canvas hiddenCanvase in HiddenCanvases)
			{
				if ((Object)(object)hiddenCanvase != (Object)null && !((Il2CppObjectBase)hiddenCanvase).WasCollected)
				{
					((Behaviour)hiddenCanvase).enabled = true;
				}
			}
			HiddenCanvases.Clear();
			try
			{
				if ((Object)(object)_blur != (Object)null && !((Il2CppObjectBase)_blur).WasCollected)
				{
					_blur.activeCount = _blurCount;
					_blur.SetActivenessOnBlurFeature();
				}
			}
			catch (Exception ex)
			{
				ModMenuMod.Log.Warning("HUD editor, blur: " + ex.Message);
			}
			_blur = null;
		}

		private static RectTransform Full(RectTransform r, Transform parent)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			((Transform)r).SetParent(parent, false);
			r.anchorMin = Vector2.zero;
			r.anchorMax = Vector2.one;
			Vector2 offsetMin = (r.offsetMax = Vector2.zero);
			r.offsetMin = offsetMin;
			return r;
		}

		private static RectTransform Frame()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = new GameObject("Picked").AddComponent<RectTransform>();
			((Transform)val).SetParent((Transform)(object)_area, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			val.pivot = val2;
			Vector2 anchorMin = (val.anchorMax = val2);
			val.anchorMin = anchorMin;
			for (int i = 0; i < 4; i++)
			{
				Image obj = new GameObject("Side").AddComponent<Image>();
				((Transform)((Graphic)obj).rectTransform).SetParent((Transform)(object)val, false);
				((Graphic)obj).color = new Color(Gold.r, Gold.g, Gold.b, 0.9f);
				((Graphic)obj).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj).rectTransform;
				bool flag = i >= 2;
				rectTransform.anchorMin = (flag ? new Vector2((i == 2) ? 0f : 1f, 0f) : new Vector2(0f, (i == 0) ? 0f : 1f));
				rectTransform.anchorMax = (flag ? new Vector2((i == 2) ? 0f : 1f, 1f) : new Vector2(1f, (i == 0) ? 0f : 1f));
				rectTransform.sizeDelta = (flag ? new Vector2(5f, 0f) : new Vector2(0f, 5f));
			}
			Vector2[] array = (Vector2[])(object)new Vector2[8]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f),
				new Vector2(0.5f, 0f),
				new Vector2(0.5f, 1f),
				new Vector2(0f, 0.5f),
				new Vector2(1f, 0.5f)
			};
			foreach (Vector2 val4 in array)
			{
				Image val5 = new GameObject("Handle").AddComponent<Image>();
				((Transform)((Graphic)val5).rectTransform).SetParent((Transform)(object)val, false);
				RectTransform rectTransform2 = ((Graphic)val5).rectTransform;
				anchorMin = (((Graphic)val5).rectTransform.anchorMax = val4);
				rectTransform2.anchorMin = anchorMin;
				((Graphic)val5).rectTransform.sizeDelta = new Vector2(22f, 22f);
				((Graphic)val5).color = Gold;
				((Graphic)val5).raycastTarget = false;
			}
			return val;
		}

		private static void Controls()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00fd: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			Image obj = new GameObject("Controls").AddComponent<Image>();
			_box = ((Graphic)obj).rectTransform;
			((Transform)_box).SetParent((Transform)(object)_area, false);
			RectTransform box = _box;
			RectTransform box2 = _box;
			RectTransform box3 = _box;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			box3.pivot = val;
			Vector2 anchorMin = (box2.anchorMax = val);
			box.anchorMin = anchorMin;
			_box.sizeDelta = new Vector2(1180f, 470f);
			_box.anchoredPosition = _boxOffset;
			((Graphic)obj).color = new Color(0f, 0f, 0f, 0.8f);
			_title = Text(_box, 54f, Color.white, (TextAlignmentOptions)514);
			Top(_title.rectTransform, 22f, 76f);
			TMP_Text obj2 = Text(_box, 26f, new Color(1f, 1f, 1f, 0.45f), (TextAlignmentOptions)514);
			Top(obj2.rectTransform, 94f, 34f);
			obj2.text = "drag this box to move it";
			InputDeviceType val3 = PadType();
			List<RectTransform[]> list = new List<RectTransform[]>();
			list.Add(Prompt(_box, 150f, "Pick", Icon((InputDeviceType)0, (ButtonPromptActionType)3), "Click", PadIcon(val3, "_y", "triangle", "north"), ""));
			list.Add(Prompt(_box, 214f, "Move", Icon((InputDeviceType)0, (ButtonPromptActionType)3), "Drag", StickIcon(val3), "Left Stick"));
			list.Add(Prompt(_box, 278f, "Resize", null, "Edges · Wheel", Icon(val3, (ButtonPromptActionType)0), "", Icon(val3, (ButtonPromptActionType)1)));
			list.Add(Prompt(_box, 342f, "Done", Icon((InputDeviceType)0, (ButtonPromptActionType)4), "", Icon(val3, (ButtonPromptActionType)3), "", Icon(val3, (ButtonPromptActionType)4)));
			List<RectTransform[]> list2 = list;
			float[] array = new float[3];
			foreach (RectTransform[] item in list2)
			{
				for (int i = 0; i < 3; i++)
				{
					array[i] = Mathf.Max(array[i], item[i].sizeDelta.x);
				}
			}
			float num = array[0] + array[1] + array[2] + 140f;
			float num2 = Mathf.Max(num, 740f) + 140f;
			_box.sizeDelta = new Vector2(num2, 560f);
			foreach (RectTransform[] item2 in list2)
			{
				float num3 = (0f - num) / 2f;
				for (int j = 0; j < 3; j++)
				{
					item2[j].anchoredPosition = new Vector2(num3, 0f);
					num3 += array[j] + 70f;
				}
			}
			Button(_box, "Reset", -200f, delegate
			{
				Picked()?.Reset?.Invoke();
			});
			Button(_box, "Done", 200f, Close);
		}

		private static ButtonPromptConfiguration Prompts()
		{
			if ((Object)(object)_prompts != (Object)null && !((Il2CppObjectBase)_prompts).WasCollected)
			{
				return _prompts;
			}
			foreach (ButtonPromptConfiguration item in Resources.FindObjectsOfTypeAll<ButtonPromptConfiguration>())
			{
				if ((Object)(object)item != (Object)null)
				{
					return _prompts = item;
				}
			}
			return null;
		}

		private static InputDeviceType PadType()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			try
			{
				InputDeviceType val = (InputDeviceType)((!((Object)(object)SingletonPersistent<UINavigator>.Instance != (Object)null)) ? 2 : ((int)SingletonPersistent<UINavigator>.Instance.CurrentInputDeviceType));
				return (InputDeviceType)(((int)val == 0) ? 2 : ((int)val));
			}
			catch
			{
				return (InputDeviceType)2;
			}
		}

		private static Sprite Icon(InputDeviceType device, ButtonPromptActionType action)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ButtonPromptConfiguration obj = Prompts();
				return (obj != null) ? obj.GetButtonPromptIcon(action, device) : null;
			}
			catch
			{
				return null;
			}
		}

		private static Sprite PadIcon(InputDeviceType device, params string[] keys)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			List<Sprite> list = new List<Sprite>();
			try
			{
				ButtonPromptConfiguration obj = Prompts();
				List<ButtonPrompt> val = ((obj != null) ? obj.ButtonPromptContainer : null);
				int num = 0;
				while (val != null && num < val.Count)
				{
					ButtonPrompt val2 = val[num];
					Sprite val3 = (((int)device == 1) ? val2.PlayStationIcon : (((int)device == 3) ? val2.SteamDeckIcon : val2.XboxIcon));
					if ((Object)(object)val3 != (Object)null)
					{
						list.Add(val3);
					}
					num++;
				}
			}
			catch
			{
			}
			if (!_loggedIcons && list.Count > 0)
			{
				_loggedIcons = true;
				ModMenuMod.Log.Msg($"button pictures ({device}): {string.Join(", ", list.ConvertAll((Sprite s) => ((Object)s).name))}");
			}
			foreach (string value in keys)
			{
				foreach (Sprite item in list)
				{
					if (((Object)item).name.ToLowerInvariant().Contains(value))
					{
						return item;
					}
				}
			}
			return null;
		}

		private static RectTransform[] Prompt(RectTransform parent, float y, string action, Sprite mouse, string mouseWord, Sprite pad1, string padWord, Sprite pad2 = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = new GameObject(action).AddComponent<RectTransform>();
			((Transform)val).SetParent((Transform)(object)parent, false);
			Top(val, y, 58f);
			RectTransform[] array = (RectTransform[])(object)new RectTransform[3];
			Vector2 val3 = default(Vector2);
			for (int i = 0; i < 3; i++)
			{
				RectTransform val2 = new GameObject("Column").AddComponent<RectTransform>();
				((Transform)val2).SetParent((Transform)(object)val, false);
				((Vector2)(ref val3))..ctor(0.5f, 0.5f);
				val2.anchorMax = val3;
				val2.anchorMin = val3;
				val2.pivot = new Vector2(0f, 0.5f);
				array[i] = val2;
			}
			float num = Cell(array[0], 0f, null, "<b>" + action + "</b>", 38f, Gold);
			float num2 = Cell(array[1], 0f, mouse, mouseWord);
			float num3 = Cell(array[2], 0f, pad1, ((Object)(object)pad1 != (Object)null) ? "" : (string.IsNullOrEmpty(padWord) ? "—" : padWord));
			if ((Object)(object)pad2 != (Object)null)
			{
				num3 = Cell(array[2], num3 + 8f, pad2, "");
			}
			array[0].sizeDelta = new Vector2(num, 58f);
			array[1].sizeDelta = new Vector2(num2, 58f);
			array[2].sizeDelta = new Vector2(num3, 58f);
			return array;
		}

		private static float Cell(RectTransform line, float x, Sprite icon, string word, float size = 34f, Color? color = null)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val2 = default(Vector2);
			if ((Object)(object)icon != (Object)null)
			{
				Image val = new GameObject("Icon").AddComponent<Image>();
				((Transform)((Graphic)val).rectTransform).SetParent((Transform)(object)line, false);
				RectTransform rectTransform = ((Graphic)val).rectTransform;
				RectTransform rectTransform2 = ((Graphic)val).rectTransform;
				((Vector2)(ref val2))..ctor(0f, 0.5f);
				rectTransform2.anchorMax = val2;
				rectTransform.anchorMin = val2;
				((Graphic)val).rectTransform.pivot = new Vector2(0f, 0.5f);
				((Graphic)val).rectTransform.sizeDelta = new Vector2(56f, 56f);
				((Graphic)val).rectTransform.anchoredPosition = new Vector2(x, 0f);
				val.sprite = icon;
				val.preserveAspect = true;
				((Graphic)val).raycastTarget = false;
				x += 56f;
				if (!string.IsNullOrEmpty(word))
				{
					x += 10f;
				}
			}
			if (!string.IsNullOrEmpty(word))
			{
				TMP_Text val3 = Text(line, size, (Color)(((??)color) ?? Color.white), (TextAlignmentOptions)4097);
				val3.textWrappingMode = (TextWrappingModes)0;
				RectTransform rectTransform3 = val3.rectTransform;
				RectTransform rectTransform4 = val3.rectTransform;
				((Vector2)(ref val2))..ctor(0f, 0.5f);
				rectTransform4.anchorMax = val2;
				rectTransform3.anchorMin = val2;
				val3.rectTransform.pivot = new Vector2(0f, 0.5f);
				val3.text = word;
				float x2 = val3.GetPreferredValues(word).x;
				val3.rectTransform.sizeDelta = new Vector2(x2 + 4f, 56f);
				val3.rectTransform.anchoredPosition = new Vector2(x, 0f);
				x += x2;
			}
			return x;
		}

		private static Sprite StickIcon(InputDeviceType pad)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			string[] array = (((int)pad != 1) ? new string[6] { "key_xbox_ls", "key_xbox_l3", "key_stick_l", "stick_l", "leftstick", "left_stick" } : new string[4] { "key_ps_l3", "key_ps_ls", "key_stick_l", "stick_l" });
			try
			{
				Il2CppArrayBase<Sprite> val = Resources.FindObjectsOfTypeAll<Sprite>();
				string[] array2 = array;
				foreach (string value in array2)
				{
					foreach (Sprite item in val)
					{
						if ((Object)(object)item != (Object)null && ((Object)item).name.ToLowerInvariant().StartsWith(value) && !((Object)item).name.ToLowerInvariant().Contains("_r"))
						{
							return item;
						}
					}
				}
				foreach (Sprite item2 in val)
				{
					if ((Object)(object)item2 != (Object)null && ((Object)item2).name.ToLowerInvariant().Contains("stick"))
					{
						ModMenuMod.Log.Msg("stick picture: " + ((Object)item2).name);
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static RectTransform Row(RectTransform parent, float y, string what, string mouse, string pad, float size, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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)
			RectTransform obj = new GameObject("Row").AddComponent<RectTransform>();
			((Transform)obj).SetParent((Transform)(object)parent, false);
			Top(obj, y, 44f);
			Column(obj, what, 0.04f, 0.2f, size, Gold, bold: true);
			Column(obj, mouse, 0.2f, 0.68f, size, color, bold: false);
			Column(obj, pad, 0.68f, 0.98f, size, color, bold: false);
			return obj;
		}

		private static void Column(RectTransform line, string text, float from, float to, float size, Color color, bool bold)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text val = Text(line, size, color, (TextAlignmentOptions)4097);
			val.rectTransform.anchorMin = new Vector2(from, 0f);
			val.rectTransform.anchorMax = new Vector2(to, 1f);
			RectTransform rectTransform = val.rectTransform;
			Vector2 offsetMin = (val.rectTransform.offsetMax = Vector2.zero);
			rectTransform.offsetMin = offsetMin;
			val.textWrappingMode = (TextWrappingModes)0;
			val.text = ((bold && text.Length > 0) ? ("<b>" + text + "</b>") : text);
		}

		private static void Top(RectTransform r, float y, float height)
		{
			//IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			r.anchorMin = new Vector2(0f, 1f);
			r.anchorMax = new Vector2(1f, 1f);
			r.pivot = new Vector2(0.5f, 1f);
			r.sizeDelta = new Vector2(0f, height);
			r.anchoredPosition = new Vector2(0f, 0f - y);
		}

		private static void Button(RectTransform parent, string text, float x, Action onClick)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			Image val = new GameObject(text).AddComponent<Image>();
			((Transform)((Graphic)val).rectTransform).SetParent((Transform)(object)parent, false);
			RectTransform rectTransform = ((Graphic)val).rectTransform;
			RectTransform rectTransform2 = ((Graphic)val).rectTransform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0f);
			rectTransform2.anchorMax = val2;
			rectTransform.anchorMin = val2;
			((Graphic)val).rectTransform.pivot = new Vector2(0.5f, 0f);
			((Graphic)val).rectTransform.sizeDelta = new Vector2(340f, 80f);
			((Graphic)val).rectTransform.anchoredPosition = new Vector2(x, 26f);
			((Graphic)val).color = Gold;
			((UnityEvent)((Component)val).gameObject.AddComponent<Button>().onClick).AddListener(UnityAction.op_Implicit(onClick));
			TMP_Text val3 = Text(((Graphic)val).rectTransform, 40f, Color.black, (TextAlignmentOptions)514);
			val3.rectTransform.anchorMin = Vector2.zero;
			val3.rectTransform.anchorMax = Vector2.one;
			val2 = (val3.rectTransform.offsetMin = (val3.rectTransform.offsetMax = Vector2.zero));
			val3.text = text;
		}

		private static TMP_Text Text(RectTransform parent, float size, Color color, TextAlignmentOptions align)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = new GameObject("Text").AddComponent<TextMeshProUGUI>();
			((Transform)((TMP_Text)val).rectTransform).SetParent((Transform)(object)parent, false);
			if ((Object)(object)_font == (Object)null || ((Il2CppObjectBase)_font).WasCollected)
			{
				foreach (TMP_FontAsset item in Resources.FindObjectsOfTypeAll<TMP_FontAsset>())
				{
					if ((Object)(object)item != (Object)null && ((Object)item).name == "TitilliumWeb-SemiBold SDF")
					{
						_font = item;
						break;
					}
				}
			}
			if ((Object)(object)_font != (Object)null)
			{
				((TMP_Text)val).font = _font;
				((TMP_Text)val).fontSharedMaterial = ((TMP_Asset)_font).material;
			}
			((TMP_Text)val).fontSize = size;
			((Graphic)val).color = color;
			((TMP_Text)val).alignment = align;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
			((Graphic)val).raycastTarget = false;
			return (TMP_Text)(object)val;
		}

		private static HudElement Picked()
		{
			if (_selected < 0 || _selected >= Shown.Count)
			{
				return null;
			}
			return Shown[_selected].element;
		}

		private static RectTransform PickedRoot()
		{
			if (_selected < 0 || _selected >= Shown.Count)
			{
				return null;
			}
			return Shown[_selected].root;
		}

		private static void EditorTick()
		{
			try
			{
				Keyboard current = Keyboard.current;
				Gamepad current2 = Gamepad.current;
				if (Time.unscaledTime - _openedAt > 0.3f && ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (Mouse.current != null && Mouse.current.rightButton.wasPressedThisFrame) || (current2 != null && (current2.buttonEast.wasPressedThisFrame || current2.buttonSouth.wasPressedThisFrame))))
				{
					Close();
					return;
				}
				if (_inMission)
				{
					ShowWholeHud();
				}
				for (int i = 0; i < Shown.Count; i++)
				{
					var (hudElement, val) = Shown[i];
					if (LiveShown.Contains(hudElement))
					{
						try
						{
							RectTransform val2 = hudElement.Live();
							if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != ((Il2CppObjectBase)val).Pointer)
							{
								Shown[i] = (hudElement, val2);
							}
						}
						catch (Exception value)
						{
							if (Failed.Add(hudElement.Name))
							{
								ModMenuMod.Log.Warning($"HUD editor, {hudElement.Name}: {value}");
							}
						}
					}
					else
					{
						if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).WasCollected)
						{
							continue;
						}
						try
						{
							hudElement.Place?.Invoke(val);
						}
						catch (Exception value2)
						{
							if (Failed.Add(hudElement.Name))
							{
								ModMenuMod.Log.Warning($"HUD editor, {hudElement.Name}: {value2}");
							}
						}
					}
				}
				Mouse();
				Pad();
				if (_drag == DragKind.None && _changed)
				{
					_changed = false;
					KeepInside();
				}
				ShowPicked();
			}
			catch (Exception value3)
			{
				ModMenuMod.Log.Warning($"HUD editor: {value3}");
				Close();
			}
		}

		private static Rect Area(RectTransform root)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			Il2CppStructArray<Vector3> corners = new Il2CppStructArray<Vector3>(4L);
			float x0 = float.MaxValue;
			float y0 = float.MaxValue;
			float x1 = float.MinValue;
			float y1 = float.MinValue;
			Canvas componentInParent = ((Component)root).GetComponentInParent<Canvas>();
			componentInParent = (((Object)(object)componentInParent != (Object)null) ? componentInParent.rootCanvas : null);
			Camera cam = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			bool ours = (Object)(object)componentInParent == (Object)null || ((Il2CppObjectBase)componentInParent).Pointer == ((Il2CppObjectBase)_canvas).Pointer;
			foreach (Graphic componentsInChild in ((Component)root).GetComponentsInChildren<Graphic>(false))
			{
				if ((Object)(object)componentsInChild == (Object)null || !((Behaviour)componentsInChild).enabled)
				{
					continue;
				}
				Rect rect = componentsInChild.rectTransform.rect;
				if (((Rect)(ref rect)).width <= 0.5f)
				{
					continue;
				}
				rect = componentsInChild.rectTransform.rect;
				if (!(((Rect)(ref rect)).height <= 0.5f))
				{
					TMP_Text val = ((Il2CppObjectBase)componentsInChild).TryCast<TMP_Text>();
					if ((Object)(object)val != (Object)null)
					{
						AddText(val);
					}
					else
					{
						Add(componentsInChild.rectTransform);
					}
				}
			}
			if (x0 > x1)
			{
				Add(root);
			}
			return Rect.MinMaxRect(x0, y0, x1, y1);
			void Add(RectTransform r)
			{
				r.GetWorldCorners(corners);
				AddCorners();
			}
			void AddCorners()
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: 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)
				Vector2 val3 = default(Vector2);
				for (int i = 0; i < 4; i++)
				{
					Vector3 val2;
					if (ours)
					{
						val2 = ((Transform)_area).InverseTransformPoint(((Il2CppArrayBase<Vector3>)(object)corners)[i]);
					}
					else
					{
						RectTransformUtility.ScreenPointToLocalPointInRectangle(_area, RectTransformUtility.WorldToScreenPoint(cam, ((Il2CppArrayBase<Vector3>)(object)corners)[i]), (Camera)null, ref val3);
						val2 = Vector2.op_Implicit(val3);
					}
					x0 = Mathf.Min(x0, val2.x);
					y0 = Mathf.Min(y0, val2.y);
					x1 = Mathf.Max(x1, val2.x);
					y1 = Mathf.Max(y1, val2.y);
				}
			}
			void AddText(TMP_Text t)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				t.ForceMeshUpdate(false, false);
				Bounds textBounds = t.textBounds;
				if (!(((Bounds)(ref textBounds)).size.x < 0.5f) && !(((Bounds)(ref textBounds)).size.y < 0.5f) && !float.IsNaN(((Bounds)(ref textBounds)).size.x) && !(((Bounds)(ref textBounds)).size.x > 1000000f))
				{
					((Il2CppArrayBase<Vector3>)(object)corners)[0] = t.transform.TransformPoint(new Vector3(((Bounds)(ref textBounds)).min.x, ((Bounds)(ref textBounds)).min.y, 0f));
					((Il2CppArrayBase<Vector3>)(object)corners)[1] = t.transform.TransformPoint(new Vector3(((Bounds)(ref textBounds)).min.x, ((Bounds)(ref textBounds)).max.y, 0f));
					((Il2CppArrayBase<Vector3>)(object)corners)[2] = t.transform.TransformPoint(new Vector3(((Bounds)(ref textBounds)).max.x, ((Bounds)(ref textBounds)).max.y, 0f));
					((Il2CppArrayBase<Vector3>)(object)corners)[3] = t.transform.TransformPoint(new Vector3(((Bounds)(ref textBounds)).max.x, ((Bounds)(ref textBounds)).min.y, 0f));
					AddCorners();
				}
			}
		}

		private static void ShowPicked()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00bd: 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)
			RectTransform val = PickedRoot();
			bool flag = (Object)(object)val != (Object)null && !((Il2CppObjectBase)val).WasCollected;
			if (((Component)_frame).gameObject.activeSelf != flag)
			{
				((Component)_frame).gameObject.SetActive(flag);
			}
			_title.text = (flag ? ("<b>" + Picked().Name + "</b>") : "No mod HUD elements");
			if (flag)
			{
				Rect val2 = Area(val);
				RectTransform frame = _frame;
				Vector2 center = ((Rect)(ref val2)).center;
				Rect rect = _area.rect;
				frame.anchoredPosition = center - ((Rect)(ref rect)).center;
				_frame.sizeDelta = new Vector2(((Rect)(ref val2)).width + 16f, ((Rect)(ref val2)).height + 16f);
				_box.anchoredPosition = _boxOffset;
			}
		}

		private static Vector2 MouseLocal(Vector2 screen)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(_area, screen, (Camera)null, ref result);
			return result;
		}

		private static void Mouse()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			Mouse current = Mouse.current;
			if (current == null)
			{
				return;
			}
			Vector2 val = MouseLocal(((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue());
			if (_drag != DragKind.None)
			{
				if (!current.leftButton.isPressed)
				{
					_drag = DragKind.None;
				}
				else
				{
					Drag(val);
				}
			}
			else if (current.leftButton.wasPressedThisFrame && RectTransformUtility.RectangleContainsScreenPoint(_box, ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(), (Camera)null) && !OverButton(((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue()))
			{
				_drag = DragKind.Box;
				_dragStart = val;
				_boxStart = _boxOffset;
			}
			else
			{
				if (RectTransformUtility.RectangleContainsScreenPoint(_box, ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(), (Camera)null))
				{
					return;
				}
				int num = -1;
				Rect val2 = default(Rect);
				List<int> list = new List<int>();
				if (_selected < Shown.Count)
				{
					list.Add(_selected);
				}
				for (int num2 = Shown.Count - 1; num2 >= 0; num2--)
				{
					if (num2 != _selected)
					{
						list.Add(num2);
					}
				}
				Rect val4 = default(Rect);
				foreach (int item in list)
				{
					if (!((Object)(object)Shown[item].root == (Object)null))
					{
						Rect val3 = Area(Shown[item].root);
						((Rect)(ref val4))..ctor(((Rect)(ref val3)).x - 26f, ((Rect)(ref val3)).y - 26f, ((Rect)(ref val3)).width + 52f, ((Rect)(ref val3)).height + 52f);
						if (((Rect)(ref val4)).Contains(val))
						{
							num = item;
							val2 = val3;
							break;
						}
					}
				}
				float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y;
				if (num >= 0 && Mathf.Abs(y) > 0.01f)
				{
					_selected = num;
					Resize(Mathf.Sign(y));
				}
				if (num < 0 || !current.leftButton.wasPressedThisFrame)
				{
					return;
				}
				_selected = num;
				HudElement hudElement = Picked();
				if (hudElement != null && hudElement.GetOffset != null && hudElement.SetOffset != null)
				{
					_dragStart = val;
					_startOffset = hudElement.GetOffset();
					_startSize = hudElement.GetSize?.Invoke() ?? 1f;
					_startDims = hudElement.GetDimensions?.Invoke() ?? Vector2.zero;
					bool flag = Mathf.Abs(val.x - ((Rect)(ref val2)).xMin) <= 26f;
					bool flag2 = Mathf.Abs(val.x - ((Rect)(ref val2)).xMax) <= 26f;
					bool num3 = Mathf.Abs(val.y - ((Rect)(ref val2)).yMin) <= 26f;
					bool flag3 = Mathf.Abs(val.y - ((Rect)(ref val2)).yMax) <= 26f;
					int num4 = (flag ? (-1) : (flag2 ? 1 : 0));
					int num5 = (num3 ? (-1) : (flag3 ? 1 : 0));
					_edgeDir = new Vector2((float)num4, (float)num5);
					_fixedPoint = new Vector2((num4 < 0) ? ((Rect)(ref val2)).xMax : ((num4 > 0) ? ((Rect)(ref val2)).xMin : ((Rect)(ref val2)).center.x), (num5 < 0) ? ((Rect)(ref val2)).yMax : ((num5 > 0) ? ((Rect)(ref val2)).yMin : ((Rect)(ref val2)).center.y));
					if (num4 != 0 && num5 != 0)
					{
						_drag = DragKind.Corner;
						Vector2 val5 = val - _fixedPoint;
						_startSpan = Mathf.Max(1f, ((Vector2)(ref val5)).magnitude);
					}
					else if (num4 != 0 || num5 != 0)
					{
						_drag = DragKind.Edge;
						_startSpan = Mathf.Max(1f, (num4 != 0) ? ((Rect)(ref val2)).width : ((Rect)(ref val2)).height);
					}
					else
					{
						_drag = DragKind.Move;
					}
				}
			}
		}

		private static bool OverButton(Vector2 screen)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Button componentsInChild in ((Component)_box).GetComponentsInChildren<Button>())
			{
				if (RectTransformUtility.RectangleContainsScreenPoint(((Component)componentsInChild).GetComponent<RectTransform>(), screen, (Camera)null))
				{
					return true;
				}
			}
			return false;
		}

		private static void Drag(Vector2 local)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			_changed = true;
			if (_drag == DragKind.Box)
			{
				_boxOffset = _boxStart + (local - _dragStart);
				return;
			}
			HudElement hudElement = Picked();
			RectTransform root = PickedRoot();
			if (hudElement == null || (Object)(object)root == (Object)null)
			{
				_drag = DragKind.None;
				return;
			}
			Vector2 val = local - _dragStart;
			switch (_drag)
			{
			case DragKind.Move:
				hudElement.SetOffset(Round(_startOffset + val));
				return;
			case DragKind.Corner:
				if (hudElement.SetSize != null)
				{
					Vector2 val3 = local - _fixedPoint;
					float num3 = ((Vector2)(ref val3)).magnitude / _startSpan;
					hudElement.SetSize(Mathf.Clamp(Mathf.Round(_startSize * num3 * 100f) / 100f, hudElement.MinSize, hudElement.MaxSize));
				}
				else if (hudElement.SetDimensions != null)
				{
					hudElement.SetDimensions(Clamp(_startDims + new Vector2(val.x * _edgeDir.x, val.y * _edgeDir.y) / Mathf.Max(0.01f, _startSize), hudElement));
				}
				break;
			case DragKind.Edge:
			{
				float num = ((_edgeDir.x != 0f) ? (val.x * _edgeDir.x) : (val.y * _edgeDir.y));
				if (hudElement.SetDimensions != null)
				{
					Vector2 val2 = ((_edgeDir.x != 0f) ? new Vector2(num, 0f) : new Vector2(0f, num));
					hudElement.SetDimensions(Clamp(_startDims + val2 / Mathf.Max(0.01f, _startSize), hudElement));
				}
				else if (hudElement.SetSize != null)
				{
					float num2 = (_startSpan + num) / _startSpan;
					hudElement.SetSize(Mathf.Clamp(Mathf.Round(_startSize * num2 * 100f) / 100f, hudElement.MinSize, hudElement.MaxSize));
				}
				break;
			}
			}
			hudElement.SetOffset(_startOffset);
			PlaceNow(hudElement, ref root);
			LayoutRebuilder.ForceRebuildLayoutImmediate(root);
			Rect val4 = Area(root);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor((_edgeDir.x < 0f) ? ((Rect)(ref val4)).xMax : ((_edgeDir.x > 0f) ? ((Rect)(ref val4)).xMin : ((Rect)(ref val4)).center.x), (_edgeDir.y < 0f) ? ((Rect)(ref val4)).yMax : ((_edgeDir.y > 0f) ? ((Rect)(ref val4)).yMin : ((Rect)(ref val4)).center.y));
			Vector2 val6 = _fixedPoint - val5;
			if (_edgeDir.x == 0f)
			{
				val6.x = 0f;
			}
			if (_edgeDir.y == 0f)
			{
				val6.y = 0f;
			}
			hudElement.SetOffset(Round(_startOffset + val6));
		}

		private static void PlaceNow(HudElement element, ref RectTransform root)
		{
			try
			{
				if (LiveShown.Contains(element))
				{
					RectTransform val = element.Live?.Invoke();
					if ((Object)(object)val != (Object)null)
					{
						root = val;
					}
				}
				else
				{
					element.Place?.Invoke(root);
				}
			}
			catch
			{
			}
		}

		private static Vector2 Clamp(Vector2 dims, HudElement e)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(Mathf.Round(Mathf.Clamp(dims.x, e.MinDimensions.x, e.MaxDimensions.x)), Mathf.Round(Mathf.Clamp(dims.y, e.MinDimensions.y, e.MaxDimensions.y)));
		}

		private static void Pad()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			Gamepad current = Gamepad.current;
			if (current == null)
			{
				return;
			}
			if (current.buttonNorth.wasPressedThisFrame && Shown.Count > 0)
			{
				_selected = (_selected + 1) % Shown.Count;
			}
			HudElement hudElement = Picked();
			if (hudElement != null && hudElement.GetOffset != null && hudElement.SetOffset != null)
			{
				Vector2 val = ((InputControl<Vector2>)(object)current.leftStick).ReadValue() + ((InputControl<Vector2>)(object)current.dpad).ReadValue();
				if (((Vector2)(ref val)).sqrMagnitude > 0.04f)
				{
					_changed = true;
				}
				if (((Vector2)(ref val)).sqrMagnitude > 0.04f)
				{
					hudElement.SetOffset(Round(hudElement.GetOffset() + val * (900f * Time.unscaledDeltaTime)));
				}
				if (current.rightShoulder.wasPressedThisFrame)
				{
					Resize(1f);
				}
				if (current.leftShoulder.wasPressedThisFrame)
				{
					Resize(-1f);
				}
			}
		}

		private static void Resize(float direction)
		{
			_changed = true;
			HudElement hudElement = Picked();
			if (hudElement != null && hudElement.GetSize != null && hudElement.SetSize != null)
			{
				float num = hudElement.GetSize() + direction * hudElement.SizeStep;
				hudElement.SetSize(Mathf.Clamp(Mathf.Round(num * 100f) / 100f, hudElement.MinSize, hudElement.MaxSize));
			}
		}

		private static Vector2 Round(Vector2 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(Mathf.Round(v.x), Mathf.Round(v.y));
		}

		private static void KeepInside()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			HudElement hudElement = Picked();
			RectTransform val = PickedRoot();
			if (hudElement == null || hudElement.GetOffset == null || hudElement.SetOffset == null || (Object)(object)val == (Object)null)
			{
				return;
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(val);
			Rect val2 = Area(val);
			Rect rect = _area.rect;
			float num = 0f;
			float num2 = 0f;
			if (((Rect)(ref val2)).width <= ((Rect)(ref rect)).width)
			{
				if (((Rect)(ref val2)).xMin < ((Rect)(ref rect)).xMin)
				{
					num = ((Rect)(ref rect)).xMin - ((Rect)(ref val2)).xMin;
				}
				else if (((Rect)(ref val2)).xMax > ((Rect)(ref rect)).xMax)
				{
					num = ((Rect)(ref rect)).xMax - ((Rect)(ref val2)).xMax;
				}
			}
			if (((Rect)(ref val2)).height <= ((Rect)(ref rect)).height)
			{
				if (((Rect)(ref val2)).yMin < ((Rect)(ref rect)).yMin)
				{
					num2 = ((Rect)(ref rect)).yMin - ((Rect)(ref val2)).yMin;
				}
				else if (((Rect)(ref val2)).yMax > ((Rect)(ref rect)).yMax)
				{
					num2 = ((Rect)(ref rect)).yMax - ((Rect)(ref val2)).yMax;
				}
			}
			if (Mathf.Abs(num) > 0.5f || Mathf.Abs(num2) > 0.5f)
			{
				hudElement.SetOffset(Round(hudElement.GetOffset() + new Vector2(num, num2)));
			}
		}
	}
	internal static class HudRecorder
	{
		internal static readonly HashSet<string> GameParts = new HashSet<string> { "SpellSlotsDisplay_Panel", "HealthDisplay_Panel", "PartyInfo_Panel", "Artifacts_Panel", "LevelDisplay_Panel", "ReviveManagerDisplay", "RunProgress_Panel", "RunInfoVisualizers" };

		internal static readonly HashSet<string> LeaveOut = new HashSet<string> { "ObjectiveResult_Panel", "BossResult_Panel", "FakeBossHealthBar", "CinematicCrop_Panel", "ObjectiveDetails_Panel", "Dead_Panel" };

		public static void Record(List<string> modPrefixes, IEnumerable<string> modSprites)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Canvas val = null;
			foreach (SpellSlotsDisplay item in Object.FindObjectsOfType<SpellSlotsDisplay>())
			{
				Canvas componentInParent = ((Component)item).GetComponentInParent<Canvas>();
				val = ((componentInParent != null) ? componentInParent.rootCanvas : null);
				if ((Object)(object)val != (Object)null)
				{
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject val2 = new GameObject("BrigadeModMenu_HudRecording");
			val2.SetActive(false);
			try
			{
				Transform transform = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform, false).transform;
				for (int num = transform.childCount - 1; num >= 0; num--)
				{
					Transform child = transform.GetChild(num);
					if (!GameParts.Contains(((Object)child).name))
					{
						Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
					}
				}
				foreach (Transform t in ((Component)transform).GetComponentsInChildren<Transform>(true))
				{
					if (!((Object)(object)t == (Object)null) && !((Il2CppObjectBase)t).WasCollected && !((Object)(object)t == (Object)(object)transform) && (LeaveOut.Contains(((Object)t).name) || modPrefixes.Exists((string p) => ((Object)t).name.StartsWith(p, StringComparison.Ordinal))))
					{
						Object.DestroyImmediate((Object)(object)((Component)t).gameObject);
					}
				}
				BlankSpellSlots(transform);
				FullHealth(transform);
				AddTeammates(((Component)val).transform, transform);
				HudRecording.Save(transform, modSprites);
				try
				{
					HudRecording.Dump(transform);
				}
				catch (Exception ex)
				{
					ModMenuMod.Log.Warning("HUD dump: " + ex.Message);
				}
			}
			catch (Exception value)
			{
				ModMenuMod.Log.Warning($"HUD recording: {value}");
			}
			finally
			{
				Object.Destroy((Object)(object)val2);
			}
		}

		private static void BlankSpellSlots(Transform copy)
		{
			Transform val = copy.Find("SpellSlotsDisplay_Panel");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			for (int i = 0; i < val.childCount; i++)
			{
				Transform child = val.GetChild(i);
				if (((Object)child).name.StartsWith("Layout_", StringComparison.Ordinal))
				{
					((Component)child).gameObject.SetActive(((Object)child).name == "Layout_4Slots");
				}
			}
			foreach (SpellSlot componentsInChild in ((Component)val).GetComponentsInChildren<SpellSlot>(true))
			{
				Blank(componentsInChild);
			}
		}

		private static void Blank(SpellSlot slot)
		{
			if ((Object)(object)slot.affectedByHighlightedStoreCardIndicator != (Object)null)
			{
				slot.affectedByHighlightedStoreCardIndicator.SetActive(false);
			}
			SpellFrame val = (((Object)(object)slot.frameVisualizer != (Object)null) ? slot.frameVisualizer.defaultFrame : null);
			foreach (SpellFrame componentsInChild in ((Component)slot).GetComponentsInChildren<SpellFrame>(true))
			{
				((Component)componentsInChild).gameObject.SetActive((Object)(object)val != (Object)null && ((Il2CppObjectBase)componentsInChild).Pointer == ((Il2CppObjectBase)val).Pointer);
			}
			if (!((Object)(object)val == (Object)null))
			{
				Sprite val2 = OrbIcon();
				if ((Object)(object)val.spellIcon != (Object)null)
				{
					((Component)val.spellIcon).gameObject.SetActive((Object)(object)val2 != (Object)null);
					val.spellIcon.sprite = val2;
					((Behaviour)val.spellIcon).enabled = (Object)(object)val2 != (Object)null;
				}
				if ((Object)(object)val.spellLevel != (Object)null)
				{
					((Component)val.spellLevel).gameObject.SetActive(true);
					val.spellLevel.text = "1";
				}
				if ((Object)(object)val.cooldownFiller != (Object)null)
				{
					val.cooldownFiller.fillAmount = 0f;
				}
			}
		}

		private static void FullHealth(Transform copy)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Transform val = copy.Find("HealthDisplay_Panel");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			foreach (Slider componentsInChild in ((Component)val).GetComponentsInChildren<Slider>(true))
			{
				componentsInChild.SetValueWithoutNotify(componentsInChild.maxValue);
			}
			Transform obj = val.Find("Bar/Fill Area/Fill");
			RectTransform val2 = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.anchorMax = new Vector2(1f, val2.anchorMax.y);
			}
			foreach (TMP_Text componentsInChild2 in ((Component)val).GetComponentsInChildren<TMP_Text>(true))
			{
				string[] array = (componentsInChild2.text ?? "").Split('/');
				if (array.Length == 2)
				{
					componentsInChild2.text = array[1].Trim() + "/" + array[1].Trim();
				}
			}
		}

		private static void AddTeammates(Transform hud, Transform copy)
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			GameplayPartyOverviewUI componentInChildren = ((Component)hud).GetComponentInChildren<GameplayPartyOverviewUI>(true);
			GameObject val = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.playerOverviewPrefab : null);
			Transform val2 = copy.Find("PartyInfo_Panel/Content");
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return;
			}
			for (int num = val2.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)val2.GetChild(num)).gameObject);
			}
			VerticalLayoutGroup val3 = (((Object)(object)componentInChildren.content != (Object)null) ? ((Component)componentInChildren.content).GetComponent<VerticalLayoutGroup>() : null);
			float num2 = (((Object)(object)val3 != (Object)null) ? ((HorizontalOrVerticalLayoutGroup)val3).spacing : 10f);
			float num3 = (((Object)(object)val3 != (Object)null) ? ((float)(-((LayoutGroup)val3).padding.top)) : 0f);
			float num4 = (((Object)(object)val3 != (Object)null) ? ((float)((LayoutGroup)val3).padding.left) : 0f);
			Vector2 val4 = default(Vector2);
			for (int i = 0; i < 3; i++)
			{
				GameObject obj = Object.Instantiate<GameObject>(val, val2, false);
				RectTransform component = obj.GetComponent<RectTransform>();
				((Vector2)(ref val4))..ctor(0f, 1f);
				component.anchorMax = val4;
				component.anchorMin = val4;
				component.pivot = new Vector2(0f, 1f);
				component.anchoredPosition = new Vector2(num4, num3);
				float num5 = num3;
				Rect rect = component.rect;
				num3 = num5 - (((Rect)(ref rect)).height + num2);
				GameplayPlayerOverviewUI component2 = obj.GetComponent<GameplayPlayerOverviewUI>();
				if ((Object)(object)component2 == (Object)null)
				{
					continue;
				}
				TMP_Text val5 = (((Object)(object)component2.playerName != (Object)null) ? ((Component)component2.playerName).GetComponent<TMP_Text>() : null);
				if ((Object)(object)val5 != (Object)null)
				{
					val5.text = $"Teammate {i + 1}";
				}
				if ((Object)(object)component2.playerDeadOverlay != (Object)null)
				{
					component2.playerDeadOverlay.SetActive(false);
				}
				if ((Object)(object)component2.healthSlider != (Object)null)
				{
					component2.healthSlider.value = component2.healthSlider.maxValue;
				}
				Transform spellSlotHolder = component2.spellSlotHolder;
				if ((Object)(object)spellSlotHolder == (Object)null)
				{
					continue;
				}
				GameObject val6 = ((spellSlotHolder.childCount > 0) ? ((Component)spellSlotHolder.GetChild(0)).gameObject : null);
				while ((Object)(object)val6 != (Object)null && spellSlotHolder.childCount < 4)
				{
					Object.Instantiate<GameObject>(val6, spellSlotHolder, false);
				}
				Sprite val7 = OrbIcon();
				foreach (GameplaySpellOverviewUI componentsInChild in ((Component)spellSlotHolder).GetComponentsInChildren<GameplaySpellOverviewUI>(true))
				{
					if ((Object)(object)componentsInChild.iconImage != (Object)null)
					{
						componentsInChild.iconImage.sprite = val7;
						((Behaviour)componentsInChild.iconImage).enabled = (Object)(object)val7 != (Object)null;
					}
				}
				foreach (TMP_Text componentsInChild2 in ((Component)spellSlotHolder).GetComponentsInChildren<TMP_Text>(true))
				{
					if (((Object)componentsInChild2).name == "Level_Text")
					{
						componentsInChild2.text = "1";
					}
				}
				HorizontalOrVerticalLayoutGroup component3 = ((Component)spellSlotHolder).GetComponent<HorizontalOrVerticalLayoutGroup>();
				if ((Object)(object)component3 != (Object)null)
				{
					LayOut(spellSlotHolder, component3);
				}
			}
		}

		private static Sprite OrbIcon()
		{
			try
			{
				SpellConfiguration obj = SpellConfigurationRepository.Get((SpellType)0);
				object result;
				if (obj == null)
				{
					result = null;
				}
				else
				{
					SpellIconContainer iconContainer = obj.IconContainer;
					result = ((iconContainer != null) ? iconContainer.DefaultIcon : null);
				}
				return (Sprite)result;
			}
			catch
			{
				return null;
			}
		}

		private static void LayOut(Transform holder, HorizontalOrVerticalLayoutGroup layout)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (Object)(object)((Il2CppObjectBase)layout).TryCast<HorizontalLayoutGroup>() != (Object)null;
			float num = (flag ? ((LayoutGroup)layout).padding.left : (-((LayoutGroup)layout).padding.top));
			Vector2 val = default(Vector2);
			for (int i = 0; i < holder.childCount; i++)
			{
				RectTransform component = ((Component)holder.GetChild(i)).GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null) && ((Component)component).gameObject.activeSelf)
				{
					((Vector2)(ref val))..ctor(0f, 1f);
					component.anchorMax = val;
					component.anchorMin = val;
					component.pivot = new Vector2(0f, 1f);
					Rect rect;
					if (flag)
					{
						component.anchoredPosition = new Vector2(num, (float)(-((LayoutGroup)layout).padding.top));
						float num2 = num;
						rect = component.rect;
						num = num2 + (((Rect)(ref rect)).width + layout.spacing);
					}
					else
					{
						component.anchoredPosition = new Vector2((float)((LayoutGroup)layout).padding.left, num);
						float num3 = num;
						rect = component.rect;
						num = num3 - (((Rect)(ref rect)).height + layout.spacing);
					}
				}
			}
		}
	}
	internal static class HudRecording
	{
		private sealed class Writer
		{
			public readonly BinaryWriter Out;

			public readonly Dictionary<IntPtr, int> SpriteIds = new Dictionary<IntPtr, int>();

			public readonly List<Sprite> Sprites = new List<Sprite>();

			public Writer(BinaryWriter w)
			{
				Out = w;
			}

			public int Sprite(Sprite s)
			{
				if ((Object)(object)s == (Object)null)
				{
					return -1;
				}
				if (SpriteIds.TryGetValue(((Il2CppObjectBase)s).Pointer, out var value))
				{
					return value;
				}
				value = Sprites.Count;
				Sprites.Add(s);
				SpriteIds[((Il2CppObjectBase)s).Pointer] = value;
				return value;
			}
		}

		private const string Magic = "BMMHUD6";

		private static List<Sprite> _sprites;

		private static readonly Dictionary<string, Sprite> ByName = new Dictionary<string, Sprite>();

		private static byte[] _nodes;

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

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		internal static string Path => System.IO.Path.Combine(Paths.ConfigPath, "BrigadeModMenu_hud.bin");

		public static bool IsCurrent()
		{
			try
			{
				if (!File.Exists(Path))
				{
					return false;
				}
				using BinaryReader binaryReader = new BinaryReader(File.OpenRead(Path));
				return binaryReader.ReadString() == "BMMHUD6" && binaryReader.ReadString() == Application.version;
			}
			catch
			{
				return false;
			}
		}

		public static void Save(Transform root, IEnumerable<string> extraSprites)
		{
			MemoryStream memoryStream = new MemoryStream();
			Writer writer = new Writer(new BinaryWriter(memoryStream));
			HashSet<string> hashSet = new HashSet<string>(extraSprites);
			if (hashSet.Count > 0)
			{
				foreach (Sprite item in Resources.FindObjectsOfTypeAll<Sprite>())
				{
					if ((Object)(object)item != (Object)null && hashSet.Remove(((Object)item).name))
					{
						writer.Sprite(item);
					}
				}
			}
			int count = 0;
			WriteNode(writer, root, ref count);
			writer.Out.Flush();
			using BinaryWriter binaryWriter = new BinaryWriter(File.Create(Path));
			binaryWriter.Write("BMMHUD6");
			binaryWriter.Write(Application.version);
			WriteSprites(binaryWriter, writer.Sprites);
			binaryWriter.Write(memoryStream.ToArray());
			ModMenuMod.Log.Msg($"recorded the mission HUD for the layout editor ({count} objects, {writer.Sprites.Count} pictures)");
		}

		private static void WriteNode(Writer w, Transform t, ref int count)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected I4, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected I4, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected I4, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected I4, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected I4, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected I4, but got Unknown
			count++;
			BinaryWriter binaryWriter = w.Out;
			RectTransform component = ((Component)t).GetComponent<RectTransform>();
			binaryWriter.Write(((Object)t).name);
			binaryWriter.Write((Object)(object)component != (Object)null);
			if (