Decompiled source of So Fly v2.1.0

tony4twenty-So Fly.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Peak;
using Peak.Afflictions;
using Peak.Island;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyTitle("So Fly")]
[assembly: AssemblyDescription("In-game fly menu for PEAK.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("tony4twenty")]
[assembly: AssemblyProduct("So Fly")]
[assembly: AssemblyCopyright("Copyright © tony4twenty 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("be90c841-fb92-42ee-80b7-fcedee6eb28f")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace SoFly
{
	[BepInPlugin("tony4twentys.So_Fly", "So Fly", "2.1.0")]
	[BepInProcess("PEAK.exe")]
	public class SoFlyPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "tony4twentys.So_Fly";

		public const string PluginName = "So Fly";

		public const string PluginVersion = "2.1.0";

		private Harmony _harmony;

		internal static SoFlyPlugin Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			SoFlyConfig.Bind(((BaseUnityPlugin)this).Config);
			DevTools.Initialize();
			HostHandshake.Initialize(this);
			FlyHud.Initialize(((Component)this).transform);
			SoFlyMenu.EnsureCreated();
			_harmony = new Harmony("tony4twentys.So_Fly");
			_harmony.PatchAll(typeof(SoFlyPlugin).Assembly);
			SceneManager.sceneLoaded += OnSceneLoaded;
			Log.LogInfo((object)"So Fly v2.1.0 loaded.");
		}

		internal static void StartRoutine(IEnumerator routine)
		{
			if ((Object)(object)Instance != (Object)null && routine != null)
			{
				((MonoBehaviour)Instance).StartCoroutine(routine);
			}
		}

		private void Update()
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter != (Object)null && (Object)(object)FlyController.Local == (Object)null)
			{
				SoFlyAttach.Attach(localCharacter);
			}
			FlyHud.Tick();
			DetectEsp.Tick();
			HandleMenuKey();
			HandleTeleportFireKey();
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			HostHandshake.Shutdown(this);
			FlyHud.Shutdown();
			DetectEsp.Shutdown();
			SoFlyMenu.DestroyInstance();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			DetectEsp.HandleSceneLoaded();
		}

		private static void HandleMenuKey()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!SoFlyMenu.IsCapturingKey)
			{
				KeyCode val = (KeyCode)((SoFlyConfig.MenuKey == null) ? 283 : ((int)SoFlyConfig.MenuKey.Value));
				if ((int)val != 0 && Input.GetKeyDown(val))
				{
					SoFlyMenu.Toggle();
				}
			}
		}

		private static void HandleTeleportFireKey()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			if (!SoFlyMenu.IsOpen && !SoFlyMenu.IsCapturingKey && SoFlyConfig.TeleportFireKey != null)
			{
				KeyCode value = SoFlyConfig.TeleportFireKey.Value;
				if ((int)value != 0 && Input.GetKeyDown(value))
				{
					FlyController.WarpLocalToCurrentCampfire();
				}
			}
		}

		internal static bool IsGameplayInputBlocked()
		{
			if (SoFlyMenu.IsOpen || SoFlyMenu.IsCapturingKey)
			{
				return true;
			}
			if (GUIManager.InPauseMenu)
			{
				return true;
			}
			GUIManager instance = GUIManager.instance;
			try
			{
				return (Object)(object)instance != (Object)null && instance.windowBlockingInput;
			}
			catch
			{
				return false;
			}
		}
	}
	internal enum SpeedMode
	{
		Incremental,
		Additive
	}
	[Flags]
	internal enum SoFlyAbility
	{
		None = 0,
		Fly = 1,
		Noclip = 2,
		Invuln = 4,
		Teleport = 8,
		Revive = 0x10,
		Afflictions = 0x20,
		DestroyItems = 0x40,
		Luggage = 0x80,
		All = 0xFF
	}
	internal static class SoFlyConfig
	{
		public const string DefaultIncremental = "10,25,50,75,100";

		public const float DefaultAdditiveCap = 300f;

		public static ConfigEntry<KeyCode> MenuKey;

		public static ConfigEntry<KeyCode> FlyToggleKey;

		public static ConfigEntry<KeyCode> FlyToggleModifier;

		public static ConfigEntry<bool> RequireModifierKey;

		public static ConfigEntry<KeyCode> SpeedAdjustKey;

		public static ConfigEntry<KeyCode> AdditiveResetKey;

		public static ConfigEntry<KeyCode> NoclipKey;

		public static ConfigEntry<KeyCode> TeleportFireKey;

		public static ConfigEntry<bool> NoclipEnabled;

		public static ConfigEntry<bool> InvulnEnabled;

		public static ConfigEntry<SpeedMode> SelectedSpeedMode;

		public static ConfigEntry<string> IncrementalSpeeds;

		public static ConfigEntry<string> AdditiveBase;

		public static ConfigEntry<string> AdditiveCap;

		public static ConfigEntry<bool> HideAllNotifications;

		public static ConfigEntry<string> OnColor;

		public static ConfigEntry<string> OffColor;

		public static ConfigEntry<string> SpeedColor;

		public static ConfigEntry<string> NoclipColor;

		public static ConfigEntry<string> NoFireColor;

		public static ConfigEntry<string> BlockedColor;

		public static ConfigEntry<string> HostMissingColor;

		public static ConfigEntry<int> OnSize;

		public static ConfigEntry<int> OffSize;

		public static ConfigEntry<int> SpeedSize;

		public static ConfigEntry<int> NoclipSize;

		public static ConfigEntry<int> NoFireSize;

		public static ConfigEntry<int> BlockedSize;

		public static ConfigEntry<int> HostMissingSize;

		public static ConfigEntry<float> OnPosX;

		public static ConfigEntry<float> OnPosY;

		public static ConfigEntry<float> OffPosX;

		public static ConfigEntry<float> OffPosY;

		public static ConfigEntry<float> SpeedPosX;

		public static ConfigEntry<float> SpeedPosY;

		public static ConfigEntry<float> NoclipPosX;

		public static ConfigEntry<float> NoclipPosY;

		public static ConfigEntry<float> NoFirePosX;

		public static ConfigEntry<float> NoFirePosY;

		public static ConfigEntry<float> BlockedPosX;

		public static ConfigEntry<float> BlockedPosY;

		public static ConfigEntry<float> HostMissingPosX;

		public static ConfigEntry<float> HostMissingPosY;

		public static ConfigEntry<float> MenuPosX;

		public static ConfigEntry<float> MenuPosY;

		public static ConfigEntry<bool> ShowLuggage;

		public static ConfigEntry<bool> ShowItems;

		public static ConfigEntry<bool> ShowDroppedItems;

		public static ConfigEntry<bool> ShowMobs;

		public static ConfigEntry<bool> ShowHazards;

		public static ConfigEntry<bool> DetectAllItems;

		public static ConfigEntry<string> DetectItemName;

		public static ConfigEntry<string> ItemEspColor;

		public static ConfigEntry<string> DroppedItemColor;

		public static ConfigEntry<bool>[] LuggageShown;

		public static ConfigEntry<string>[] LuggageColors;

		public static ConfigEntry<bool>[] MobsShown;

		public static ConfigEntry<string>[] MobColors;

		public static ConfigEntry<bool>[] HazardsShown;

		public static ConfigEntry<string>[] HazardColors;

		public static ConfigEntry<string> AfflictionAmount;

		public static ConfigEntry<bool> ShowPauseMenuButton;

		public static ConfigEntry<bool> AutoLightCampfire;

		public static ConfigEntry<bool> BringAllToFire;

		internal static void Bind(ConfigFile config)
		{
			MenuKey = config.Bind<KeyCode>("Hotkey", "MenuKey", (KeyCode)283, "Open / close the So Fly menu.");
			FlyToggleModifier = config.Bind<KeyCode>("Hotkey", "FlyToggleModifier", (KeyCode)308, "Modifier held with FlyToggleKey when RequireModifierKey is true.");
			RequireModifierKey = config.Bind<bool>("Hotkey", "RequireModifierKey", true, "Require the modifier key to toggle fly.");
			FlyToggleKey = config.Bind<KeyCode>("Hotkey", "FlyToggleKey", (KeyCode)102, "Toggle fly mode.");
			SpeedAdjustKey = config.Bind<KeyCode>("Hotkey", "SpeedAdjustKey", (KeyCode)118, "Cycle incremental speeds or add additive speed.");
			AdditiveResetKey = config.Bind<KeyCode>("Hotkey", "AdditiveResetKey", (KeyCode)114, "Reset additive speed back to the base value.");
			NoclipKey = config.Bind<KeyCode>("Hotkey", "NoclipKey", (KeyCode)110, "Toggle noclip while flying. None = unbound.");
			TeleportFireKey = config.Bind<KeyCode>("Hotkey", "TeleportFireKey", (KeyCode)116, "Teleport to this climb segment's campfire. Auto-light still applies. None = unbound.");
			NoclipEnabled = config.Bind<bool>("Flight", "NoclipEnabled", true, "No-clip through world and players while flying.");
			InvulnEnabled = config.Bind<bool>("Flight", "InvulnEnabled", true, "Stay invincible while flying until you land, climb, or pass out.");
			SelectedSpeedMode = config.Bind<SpeedMode>("Speed", "Mode", SpeedMode.Incremental, "Incremental cycles a CSV list. Additive adds the base each press.");
			IncrementalSpeeds = config.Bind<string>("Speed", "IncrementalSpeeds", "10,25,50,75,100", "Comma-separated fly speeds for Incremental mode.");
			AdditiveBase = config.Bind<string>("Speed", "AdditiveBase", "10", "Base speed added on each SpeedAdjustKey press in Additive mode.");
			AdditiveCap = config.Bind<string>("Speed", "AdditiveCap", "300", "Maximum additive fly speed.");
			HideAllNotifications = config.Bind<bool>("UI", "HideAllNotifications", false, "Hide on-screen So Fly alerts.");
			OnColor = config.Bind<string>("UI", "OnColor", "#00FF00", "SO FLY ON alert color.");
			OffColor = config.Bind<string>("UI", "OffColor", "#00FFFF", "SO FLY OFF alert color.");
			SpeedColor = config.Bind<string>("UI", "SpeedColor", "#FFFF00", "Current-speed alert color.");
			NoclipColor = config.Bind<string>("UI", "NoclipColor", "#FF9900", "NOCLIP ON/OFF alert color.");
			NoFireColor = config.Bind<string>("UI", "NoFireColor", "#FF4444", "NO SEGMENT FIRE alert color.");
			BlockedColor = config.Bind<string>("UI", "BlockedColor", "#FF66CC", "SO FLY BLOCKED alert color.");
			HostMissingColor = config.Bind<string>("UI", "HostMissingColor", "#FF66CC", "HOST MISSING SO FLY alert color.");
			OnSize = config.Bind<int>("UI", "OnSize", 60, "SO FLY ON text size.");
			OffSize = config.Bind<int>("UI", "OffSize", 60, "SO FLY OFF text size.");
			SpeedSize = config.Bind<int>("UI", "SpeedSize", 48, "Current-speed text size.");
			NoclipSize = config.Bind<int>("UI", "NoclipSize", 48, "NOCLIP ON/OFF text size.");
			NoFireSize = config.Bind<int>("UI", "NoFireSize", 48, "NO SEGMENT FIRE text size.");
			BlockedSize = config.Bind<int>("UI", "BlockedSize", 48, "SO FLY BLOCKED text size.");
			HostMissingSize = config.Bind<int>("UI", "HostMissingSize", 48, "HOST MISSING SO FLY text size.");
			OnPosX = config.Bind<float>("UI", "OnPosX", 0f, "SO FLY ON anchored X.");
			OnPosY = config.Bind<float>("UI", "OnPosY", -180f, "SO FLY ON anchored Y.");
			OffPosX = config.Bind<float>("UI", "OffPosX", 0f, "SO FLY OFF anchored X.");
			OffPosY = config.Bind<float>("UI", "OffPosY", -180f, "SO FLY OFF anchored Y.");
			SpeedPosX = config.Bind<float>("UI", "SpeedPosX", 0f, "Speed alert anchored X.");
			SpeedPosY = config.Bind<float>("UI", "SpeedPosY", -260f, "Speed alert anchored Y.");
			NoclipPosX = config.Bind<float>("UI", "NoclipPosX", 0f, "Noclip alert anchored X.");
			NoclipPosY = config.Bind<float>("UI", "NoclipPosY", -340f, "Noclip alert anchored Y.");
			NoFirePosX = config.Bind<float>("UI", "NoFirePosX", 0f, "NO SEGMENT FIRE anchored X.");
			NoFirePosY = config.Bind<float>("UI", "NoFirePosY", -420f, "NO SEGMENT FIRE anchored Y.");
			BlockedPosX = config.Bind<float>("UI", "BlockedPosX", 0f, "SO FLY BLOCKED anchored X.");
			BlockedPosY = config.Bind<float>("UI", "BlockedPosY", -500f, "SO FLY BLOCKED anchored Y.");
			HostMissingPosX = config.Bind<float>("UI", "HostMissingPosX", 0f, "HOST MISSING SO FLY anchored X.");
			HostMissingPosY = config.Bind<float>("UI", "HostMissingPosY", -580f, "HOST MISSING SO FLY anchored Y.");
			MenuPosX = config.Bind<float>("UI", "MenuPosX", 0f, "Menu panel anchored X.");
			MenuPosY = config.Bind<float>("UI", "MenuPosY", 0f, "Menu panel anchored Y.");
			ShowLuggage = config.Bind<bool>("DevTools", "ShowLuggage", false, "Draw see-through boxes around luggage. Exclusive with other detect modes.");
			ShowItems = config.Bind<bool>("DevTools", "ShowItems", false, "Draw see-through boxes around a chosen item name, or every item if DetectAllItems is on.");
			ShowDroppedItems = config.Bind<bool>("DevTools", "ShowDroppedItems", false, "Draw see-through boxes around items sitting on the ground.");
			ShowMobs = config.Bind<bool>("DevTools", "ShowMobs", false, "Draw see-through boxes around beetles, scoutmasters, zombies, bees, and similar. Exclusive with other detect modes.");
			ShowHazards = config.Bind<bool>("DevTools", "ShowHazards", false, "Draw see-through boxes around spiders, flytraps, geysers, and similar. Exclusive with other detect modes.");
			DetectAllItems = config.Bind<bool>("DevTools", "DetectAllItems", false, "When ShowItems is on, outline every item instead of the dropdown pick.");
			DetectItemName = config.Bind<string>("DevTools", "DetectItemName", "(pick an item)", "Item dropdown pick used when DetectAllItems is off.");
			ItemEspColor = config.Bind<string>("DevTools", "ItemEspColor", "#7CFF6B", "Outline color for named / all-item detection.");
			DroppedItemColor = config.Bind<string>("DevTools", "DroppedItemColor", "#FFB347", "Outline color for dropped-item detection.");
			AfflictionAmount = config.Bind<string>("DevTools", "AfflictionAmount", "0.2", "Amount added or subtracted for the selected status (most bars are 0-1).");
			ShowPauseMenuButton = config.Bind<bool>("UI", "ShowPauseMenuButton", true, "Show the So Fly button on the pause menu. F2 still works if this is off.");
			AutoLightCampfire = config.Bind<bool>("DevTools", "AutoLightCampfire", false, "Light the segment campfire when teleporting to it. If BringAllToFire is on, waits until everyone has warped first.");
			BringAllToFire = config.Bind<bool>("DevTools", "BringAllToFire", false, "Teleport every player to the fire with you.");
			LuggageKind[] all = LuggageKinds.All;
			LuggageShown = new ConfigEntry<bool>[all.Length];
			LuggageColors = new ConfigEntry<string>[all.Length];
			for (int i = 0; i < all.Length; i++)
			{
				LuggageKind luggageKind = all[i];
				bool flag = luggageKind != LuggageKind.Respawn;
				LuggageShown[i] = config.Bind<bool>("DevTools", "ShowLuggage" + luggageKind, flag, "Draw outlines for " + luggageKind.ToString() + " luggage.");
				LuggageColors[i] = config.Bind<string>("DevTools", "LuggageColor" + luggageKind, LuggageKinds.DefaultHex(luggageKind), "Outline color for " + luggageKind.ToString() + " luggage.");
			}
			MobKind[] all2 = MobKinds.All;
			MobsShown = new ConfigEntry<bool>[all2.Length];
			MobColors = new ConfigEntry<string>[all2.Length];
			for (int j = 0; j < all2.Length; j++)
			{
				MobKind kind = all2[j];
				MobsShown[j] = config.Bind<bool>("DevTools", "ShowMob" + kind, true, "Draw outlines for " + MobKinds.Label(kind) + ".");
				MobColors[j] = config.Bind<string>("DevTools", "MobColor" + kind, MobKinds.DefaultHex(kind), "Outline color for " + MobKinds.Label(kind) + ".");
			}
			HazardKind[] all3 = HazardKinds.All;
			HazardsShown = new ConfigEntry<bool>[all3.Length];
			HazardColors = new ConfigEntry<string>[all3.Length];
			for (int k = 0; k < all3.Length; k++)
			{
				HazardKind kind2 = all3[k];
				HazardsShown[k] = config.Bind<bool>("DevTools", "ShowHazard" + kind2, true, "Draw outlines for " + HazardKinds.Label(kind2) + ".");
				HazardColors[k] = config.Bind<string>("DevTools", "HazardColor" + kind2, HazardKinds.DefaultHex(kind2), "Outline color for " + HazardKinds.Label(kind2) + ".");
			}
		}

		internal static DetectKind? ActiveDetect()
		{
			if (ShowLuggage != null && ShowLuggage.Value)
			{
				return DetectKind.Luggage;
			}
			if (ShowItems != null && ShowItems.Value)
			{
				return DetectKind.Items;
			}
			if (ShowDroppedItems != null && ShowDroppedItems.Value)
			{
				return DetectKind.Dropped;
			}
			if (ShowMobs != null && ShowMobs.Value)
			{
				return DetectKind.Mobs;
			}
			if (ShowHazards != null && ShowHazards.Value)
			{
				return DetectKind.Hazards;
			}
			return null;
		}

		internal static void SetDetect(DetectKind kind, bool on)
		{
			if (ShowLuggage != null)
			{
				ShowLuggage.Value = on && kind == DetectKind.Luggage;
			}
			if (ShowItems != null)
			{
				ShowItems.Value = on && kind == DetectKind.Items;
			}
			if (ShowDroppedItems != null)
			{
				ShowDroppedItems.Value = on && kind == DetectKind.Dropped;
			}
			if (ShowMobs != null)
			{
				ShowMobs.Value = on && kind == DetectKind.Mobs;
			}
			if (ShowHazards != null)
			{
				ShowHazards.Value = on && kind == DetectKind.Hazards;
			}
			DetectEsp.RequestRebuild();
		}

		internal static bool IsLuggageShown(LuggageKind kind)
		{
			if (LuggageShown == null || kind < LuggageKind.Small || (int)kind >= LuggageShown.Length || LuggageShown[(int)kind] == null)
			{
				return kind != LuggageKind.Respawn;
			}
			return LuggageShown[(int)kind].Value;
		}

		internal static void SetLuggageShown(LuggageKind kind, bool shown)
		{
			if (LuggageShown != null && kind >= LuggageKind.Small && (int)kind < LuggageShown.Length && LuggageShown[(int)kind] != null)
			{
				LuggageShown[(int)kind].Value = shown;
				DetectEsp.RequestRebuild();
			}
		}

		internal static Color GetLuggageColor(LuggageKind kind)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Color val = LuggageKinds.DefaultColor(kind);
			if (LuggageColors == null || kind < LuggageKind.Small || (int)kind >= LuggageColors.Length)
			{
				return val;
			}
			return ParseColor(LuggageColors[(int)kind], val);
		}

		internal static Color GetItemEspColor()
		{
			//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_001f: 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)
			return ParseColor(ItemEspColor, new Color(0.49f, 1f, 0.42f));
		}

		internal static Color GetDroppedItemColor()
		{
			//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_001f: 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)
			return ParseColor(DroppedItemColor, new Color(1f, 0.7f, 0.28f));
		}

		internal static bool IsMobShown(MobKind kind)
		{
			if (MobsShown == null || kind < MobKind.Beetle || (int)kind >= MobsShown.Length || MobsShown[(int)kind] == null)
			{
				return true;
			}
			return MobsShown[(int)kind].Value;
		}

		internal static void SetMobShown(MobKind kind, bool shown)
		{
			if (MobsShown != null && kind >= MobKind.Beetle && (int)kind < MobsShown.Length && MobsShown[(int)kind] != null)
			{
				MobsShown[(int)kind].Value = shown;
				DetectEsp.RequestRebuild();
			}
		}

		internal static Color GetMobColor(MobKind kind)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Color val = MobKinds.DefaultColor(kind);
			if (MobColors == null || kind < MobKind.Beetle || (int)kind >= MobColors.Length)
			{
				return val;
			}
			return ParseColor(MobColors[(int)kind], val);
		}

		internal static ConfigEntry<string> GetMobColorEntry(MobKind kind)
		{
			if (MobColors == null || kind < MobKind.Beetle || (int)kind >= MobColors.Length)
			{
				return null;
			}
			return MobColors[(int)kind];
		}

		internal static bool IsHazardShown(HazardKind kind)
		{
			if (HazardsShown == null || kind < HazardKind.Spider || (int)kind >= HazardsShown.Length || HazardsShown[(int)kind] == null)
			{
				return true;
			}
			return HazardsShown[(int)kind].Value;
		}

		internal static void SetHazardShown(HazardKind kind, bool shown)
		{
			if (HazardsShown != null && kind >= HazardKind.Spider && (int)kind < HazardsShown.Length && HazardsShown[(int)kind] != null)
			{
				HazardsShown[(int)kind].Value = shown;
				DetectEsp.RequestRebuild();
			}
		}

		internal static Color GetHazardColor(HazardKind kind)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Color val = HazardKinds.DefaultColor(kind);
			if (HazardColors == null || kind < HazardKind.Spider || (int)kind >= HazardColors.Length)
			{
				return val;
			}
			return ParseColor(HazardColors[(int)kind], val);
		}

		internal static ConfigEntry<string> GetHazardColorEntry(HazardKind kind)
		{
			if (HazardColors == null || kind < HazardKind.Spider || (int)kind >= HazardColors.Length)
			{
				return null;
			}
			return HazardColors[(int)kind];
		}

		internal static ConfigEntry<string> GetLuggageColorEntry(LuggageKind kind)
		{
			if (LuggageColors == null || kind < LuggageKind.Small || (int)kind >= LuggageColors.Length)
			{
				return null;
			}
			return LuggageColors[(int)kind];
		}

		internal static float ParseAdditiveBase()
		{
			float num = ParsePositiveFloat((AdditiveBase != null) ? AdditiveBase.Value : "10", 10f);
			return Mathf.Min(num, ParseAdditiveCap());
		}

		internal static float ParseAdditiveCap()
		{
			float num = ParsePositiveFloat((AdditiveCap != null) ? AdditiveCap.Value : "300", 300f);
			return Mathf.Max(num, 1f);
		}

		private static float ParsePositiveFloat(string raw, float fallback)
		{
			if (string.IsNullOrWhiteSpace(raw))
			{
				return fallback;
			}
			if (!float.TryParse(raw, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				float.TryParse(raw, NumberStyles.Float, CultureInfo.CurrentCulture, out result);
			}
			return (result > 0f) ? result : fallback;
		}

		internal static Color ParseColor(ConfigEntry<string> entry, Color fallback)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (entry == null || string.IsNullOrWhiteSpace(entry.Value))
			{
				return fallback;
			}
			string text = entry.Value.Trim();
			if (!text.StartsWith("#", StringComparison.Ordinal))
			{
				text = "#" + text;
			}
			Color result = default(Color);
			if (ColorUtility.TryParseHtmlString(text, ref result))
			{
				return result;
			}
			return fallback;
		}

		internal static void SetColor(ConfigEntry<string> entry, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (entry != null)
			{
				entry.Value = "#" + ColorUtility.ToHtmlStringRGB(color);
			}
		}

		internal unsafe static string FormatKey(KeyCode key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((int)key == 0) ? "Unbound" : ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
		}

		internal static string AlertPreview(FlyAlertKind kind)
		{
			return kind switch
			{
				FlyAlertKind.On => "SO FLY ON", 
				FlyAlertKind.Off => "SO FLY OFF", 
				FlyAlertKind.Speed => "SPEED 50", 
				FlyAlertKind.Noclip => "NOCLIP ON", 
				FlyAlertKind.NoFire => "NO SEGMENT FIRE", 
				FlyAlertKind.Blocked => "SO FLY BLOCKED", 
				FlyAlertKind.HostMissing => "HOST MISSING SO FLY", 
				_ => kind.ToString(), 
			};
		}

		internal static Color AlertFallback(FlyAlertKind kind)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(kind switch
			{
				FlyAlertKind.On => Color.green, 
				FlyAlertKind.Off => Color.cyan, 
				FlyAlertKind.Speed => Color.yellow, 
				FlyAlertKind.Noclip => new Color(1f, 0.6f, 0f), 
				FlyAlertKind.NoFire => new Color(1f, 0.27f, 0.27f), 
				FlyAlertKind.Blocked => new Color(1f, 0.4f, 0.8f), 
				FlyAlertKind.HostMissing => new Color(1f, 0.4f, 0.8f), 
				_ => Color.white, 
			});
		}

		internal static Color AlertColor(FlyAlertKind kind)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return ParseColor(AlertColorEntry(kind), AlertFallback(kind));
		}

		internal static ConfigEntry<string> AlertColorEntry(FlyAlertKind kind)
		{
			return (ConfigEntry<string>)(kind switch
			{
				FlyAlertKind.On => OnColor, 
				FlyAlertKind.Off => OffColor, 
				FlyAlertKind.Speed => SpeedColor, 
				FlyAlertKind.Noclip => NoclipColor, 
				FlyAlertKind.NoFire => NoFireColor, 
				FlyAlertKind.Blocked => BlockedColor, 
				FlyAlertKind.HostMissing => HostMissingColor, 
				_ => OnColor, 
			});
		}

		internal static int AlertSize(FlyAlertKind kind)
		{
			return AlertSizeEntry(kind)?.Value ?? 48;
		}

		internal static ConfigEntry<int> AlertSizeEntry(FlyAlertKind kind)
		{
			return (ConfigEntry<int>)(kind switch
			{
				FlyAlertKind.On => OnSize, 
				FlyAlertKind.Off => OffSize, 
				FlyAlertKind.Speed => SpeedSize, 
				FlyAlertKind.Noclip => NoclipSize, 
				FlyAlertKind.NoFire => NoFireSize, 
				FlyAlertKind.Blocked => BlockedSize, 
				FlyAlertKind.HostMissing => HostMissingSize, 
				_ => SpeedSize, 
			});
		}

		internal static Vector2 AlertPos(FlyAlertKind kind)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			return (Vector2)(kind switch
			{
				FlyAlertKind.On => EntryPos(OnPosX, OnPosY, 0f, -180f), 
				FlyAlertKind.Off => EntryPos(OffPosX, OffPosY, 0f, -180f), 
				FlyAlertKind.Speed => EntryPos(SpeedPosX, SpeedPosY, 0f, -260f), 
				FlyAlertKind.Noclip => EntryPos(NoclipPosX, NoclipPosY, 0f, -340f), 
				FlyAlertKind.NoFire => EntryPos(NoFirePosX, NoFirePosY, 0f, -420f), 
				FlyAlertKind.Blocked => EntryPos(BlockedPosX, BlockedPosY, 0f, -500f), 
				FlyAlertKind.HostMissing => EntryPos(HostMissingPosX, HostMissingPosY, 0f, -580f), 
				_ => Vector2.zero, 
			});
		}

		internal static void SetAlertPos(FlyAlertKind kind, Vector2 pos)
		{
			//IL_0036: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0095: 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)
			switch (kind)
			{
			case FlyAlertKind.On:
				SetEntryPos(OnPosX, OnPosY, pos);
				break;
			case FlyAlertKind.Off:
				SetEntryPos(OffPosX, OffPosY, pos);
				break;
			case FlyAlertKind.Speed:
				SetEntryPos(SpeedPosX, SpeedPosY, pos);
				break;
			case FlyAlertKind.Noclip:
				SetEntryPos(NoclipPosX, NoclipPosY, pos);
				break;
			case FlyAlertKind.NoFire:
				SetEntryPos(NoFirePosX, NoFirePosY, pos);
				break;
			case FlyAlertKind.Blocked:
				SetEntryPos(BlockedPosX, BlockedPosY, pos);
				break;
			case FlyAlertKind.HostMissing:
				SetEntryPos(HostMissingPosX, HostMissingPosY, pos);
				break;
			}
		}

		private static Vector2 EntryPos(ConfigEntry<float> x, ConfigEntry<float> y, float dx, float dy)
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(x?.Value ?? dx, y?.Value ?? dy);
		}

		private static void SetEntryPos(ConfigEntry<float> x, ConfigEntry<float> y, Vector2 pos)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (x != null)
			{
				x.Value = pos.x;
			}
			if (y != null)
			{
				y.Value = pos.y;
			}
		}
	}
	internal static class SoFlyUi
	{
		internal static readonly Color PanelColor = new Color(0.08f, 0.06f, 0.05f, 0.94f);

		internal static readonly Color ButtonColor = new Color(0.1792453f, 0.1253449f, 0.09046815f, 62f / 85f);

		internal static readonly Color ButtonHover = new Color(0.26f, 0.18f, 0.13f, 0.92f);

		internal static readonly Color Cream = new Color(0.95f, 0.93f, 0.88f, 1f);

		internal static readonly Color CreamDim = new Color(0.82f, 0.78f, 0.72f, 0.92f);

		internal static readonly Color AccentOn = new Color(0.55f, 0.42f, 0.22f, 0.95f);

		private static readonly Color CheckboxWellColor = new Color(0.1f, 0.08f, 0.06f, 0.92f);

		private static Sprite _whiteSprite;

		private static GameObject _buttonDonor;

		private static TMP_FontAsset _cachedFont;

		private static int _cachedSceneHandle = -1;

		internal static Canvas CreateOverlayCanvas(GameObject root, int sortingOrder)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Canvas val = root.GetComponent<Canvas>() ?? root.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = sortingOrder;
			val.additionalShaderChannels = (AdditionalCanvasShaderChannels)25;
			CanvasScaler val2 = root.GetComponent<CanvasScaler>() ?? root.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			val2.matchWidthOrHeight = 1f;
			if ((Object)(object)root.GetComponent<GraphicRaycaster>() == (Object)null)
			{
				root.AddComponent<GraphicRaycaster>();
			}
			return val;
		}

		internal static RectTransform CreatePanel(Transform parent, string name, Vector2 size, Color color)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			component.anchorMax = val2;
			component.anchorMin = val2;
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = size;
			Image component2 = val.GetComponent<Image>();
			component2.sprite = WhiteSprite();
			component2.type = (Type)1;
			((Graphic)component2).color = color;
			((Graphic)component2).raycastTarget = true;
			return component;
		}

		internal static TextMeshProUGUI CreateLabel(Transform parent, string name, string text, float fontSize, FontStyles style = (FontStyles)0, TextAlignmentOptions align = (TextAlignmentOptions)513)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			});
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text ?? string.Empty;
			((TMP_Text)val2).fontSize = fontSize;
			((TMP_Text)val2).fontStyle = style;
			((TMP_Text)val2).alignment = align;
			((Graphic)val2).color = Cream;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).enableWordWrapping = false;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((MaskableGraphic)val2).maskable = true;
			ApplyFont(val2);
			return val2;
		}

		internal static LayoutElement MakeNonCollapsing(GameObject go, float height, float minWidth = 0f)
		{
			LayoutElement val = go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>();
			val.minHeight = height;
			val.preferredHeight = height;
			val.flexibleHeight = 0f;
			if (minWidth > 0f)
			{
				val.minWidth = minWidth;
				if (val.preferredWidth < minWidth)
				{
					val.preferredWidth = minWidth;
				}
			}
			return val;
		}

		internal static Button CreateButton(Transform parent, string label, UnityAction onClick, Vector2 preferredSize)
		{
			//IL_0015: 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)
			GameObject val = TryClonePauseButton(parent, label) ?? CreatePlainButtonObject(parent, label);
			ApplyButtonSize(val, preferredSize);
			TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).text = label;
				((TMP_Text)componentInChildren).fontStyle = (FontStyles)0;
				((TMP_Text)componentInChildren).enableAutoSizing = true;
				((TMP_Text)componentInChildren).fontSizeMin = 12f;
				((TMP_Text)componentInChildren).fontSizeMax = 20f;
				((Graphic)componentInChildren).color = Cream;
				ApplyFont(componentInChildren);
			}
			Button val2 = val.GetComponent<Button>() ?? val.AddComponent<Button>();
			((UnityEventBase)val2.onClick).RemoveAllListeners();
			if (onClick != null)
			{
				((UnityEvent)val2.onClick).AddListener(onClick);
			}
			return val2;
		}

		internal static Button CreatePlainButton(Transform parent, string label, UnityAction onClick, Vector2 preferredSize)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreatePlainButtonObject(parent, label);
			ApplyButtonSize(val, preferredSize);
			TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).text = label ?? string.Empty;
				ApplyFont(componentInChildren);
			}
			Button component = val.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			if (onClick != null)
			{
				((UnityEvent)component.onClick).AddListener(onClick);
			}
			return component;
		}

		internal static Image CreateSwatch(Transform parent, Color color, UnityAction onClick, Vector2 size)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Swatch", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			});
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.minWidth = size.x;
			val2.preferredWidth = size.x;
			val2.minHeight = size.y;
			val2.preferredHeight = size.y;
			Image component = val.GetComponent<Image>();
			component.sprite = WhiteSprite();
			((Graphic)component).color = color;
			((Graphic)component).raycastTarget = true;
			Button component2 = val.GetComponent<Button>();
			((UnityEvent)component2.onClick).AddListener(onClick);
			return component;
		}

		internal static GameObject ShowOptionList(Transform parent, string[] options, int selected, Action<int> onPicked)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			return ShowOptionList(parent, options, selected, onPicked, new Vector2(280f, Mathf.Min(520f, 48f + (float)options.Length * 34f)));
		}

		internal static GameObject ShowOptionList(Transform parent, string[] options, int selected, Action<int> onPicked, Vector2 size)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00d5: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0145: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_029a: 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_02b3: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: 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_026b: Expected O, but got Unknown
			if ((Object)(object)parent == (Object)null || options == null || options.Length == 0)
			{
				return null;
			}
			Transform val = parent.Find("OptionList");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			GameObject go = new GameObject("OptionList", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			go.transform.SetParent(parent, false);
			go.transform.SetAsLastSibling();
			RectTransform component = go.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			component.anchorMax = val2;
			component.anchorMin = val2;
			component.sizeDelta = size;
			Image component2 = go.GetComponent<Image>();
			component2.sprite = WhiteSprite();
			((Graphic)component2).color = PanelColor;
			LayoutElement val3 = go.AddComponent<LayoutElement>();
			val3.ignoreLayout = true;
			AddVerticalLayout(go, 4f, new RectOffset(10, 10, 10, 10));
			TextMeshProUGUI val4 = CreateLabel(go.transform, "Title", "Pick one", 16f, (FontStyles)0, (TextAlignmentOptions)514);
			MakeNonCollapsing(((Component)val4).gameObject, 22f);
			RectTransform content;
			ScrollRect val5 = CreateScrollView(go.transform, out content);
			LayoutElement val6 = ((Component)val5).gameObject.AddComponent<LayoutElement>();
			val6.flexibleHeight = 1f;
			val6.minHeight = 120f;
			AddVerticalLayout(((Component)content).gameObject, 4f, new RectOffset(4, 4, 4, 4));
			ContentSizeFitter val7 = ((Component)content).gameObject.AddComponent<ContentSizeFitter>();
			val7.verticalFit = (FitMode)2;
			for (int i = 0; i < options.Length; i++)
			{
				int index = i;
				string text = options[i];
				if (index == selected)
				{
					text = "> " + text;
				}
				CreatePlainButton((Transform)(object)content, text, (UnityAction)delegate
				{
					onPicked?.Invoke(index);
					Object.Destroy((Object)(object)go);
				}, new Vector2(Mathf.Max(240f, size.x - 40f), 30f));
			}
			CreatePlainButton(go.transform, "Cancel", (UnityAction)delegate
			{
				Object.Destroy((Object)(object)go);
			}, new Vector2(120f, 30f));
			return go;
		}

		internal static Toggle CreateToggle(Transform parent, string label, bool isOn, UnityAction<bool> onChanged, float height = 28f, bool highContrast = false)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00d5: 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_00da: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_019f: 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_0214: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Toggle_" + Sanitize(label), new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.minHeight = height;
			val2.preferredHeight = height;
			val2.flexibleWidth = 1f;
			HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 8f;
			((LayoutGroup)val3).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
			((LayoutGroup)val3).padding = new RectOffset(4, 4, 2, 2);
			Color well = (Color)(highContrast ? new Color(0.32f, 0.26f, 0.18f, 1f) : CheckboxWellColor);
			Color check = (Color)(highContrast ? new Color(1f, 0.92f, 0.28f, 1f) : Cream);
			float num = (highContrast ? 26f : 22f);
			float num2 = (highContrast ? 3f : 5f);
			GameObject val4 = new GameObject("Box", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val4.transform.SetParent(val.transform, false);
			Image boxImg = val4.GetComponent<Image>();
			boxImg.sprite = WhiteSprite();
			((Graphic)boxImg).color = well;
			LayoutElement val5 = val4.AddComponent<LayoutElement>();
			val5.preferredWidth = num;
			val5.preferredHeight = num;
			val5.minWidth = num;
			val5.minHeight = num;
			GameObject val6 = new GameObject("Check", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val6.transform.SetParent(val4.transform, false);
			Stretch(val6.GetComponent<RectTransform>(), num2, num2);
			Image checkImg = val6.GetComponent<Image>();
			checkImg.sprite = WhiteSprite();
			((Graphic)checkImg).color = check;
			((Graphic)checkImg).raycastTarget = false;
			TextMeshProUGUI val7 = CreateLabel(val.transform, "Label", label, highContrast ? 15f : 16f, (FontStyles)0, (TextAlignmentOptions)513);
			if (highContrast)
			{
				((TMP_Text)val7).fontStyle = (FontStyles)1;
			}
			LayoutElement val8 = ((Component)val7).gameObject.AddComponent<LayoutElement>();
			val8.flexibleWidth = 1f;
			val8.minHeight = height - 4f;
			val8.preferredHeight = height - 4f;
			Toggle val9 = val.AddComponent<Toggle>();
			((Selectable)val9).targetGraphic = (Graphic)(object)boxImg;
			val9.graphic = (Graphic)(object)checkImg;
			val9.SetIsOnWithoutNotify(isOn);
			((Behaviour)checkImg).enabled = true;
			((Graphic)checkImg).canvasRenderer.SetAlpha(isOn ? 1f : 0f);
			((UnityEvent<bool>)(object)val9.onValueChanged).AddListener((UnityAction<bool>)delegate(bool v)
			{
				//IL_0008: 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)
				((Graphic)boxImg).color = well;
				((Graphic)checkImg).color = check;
				((Behaviour)checkImg).enabled = true;
				((Graphic)checkImg).canvasRenderer.SetAlpha(v ? 1f : 0f);
				onChanged?.Invoke(v);
			});
			return val9;
		}

		internal static void SetToggleVisual(Toggle toggle, bool isOn)
		{
			if (!((Object)(object)toggle == (Object)null))
			{
				toggle.SetIsOnWithoutNotify(isOn);
				if ((Object)(object)toggle.graphic != (Object)null)
				{
					((Behaviour)toggle.graphic).enabled = true;
					toggle.graphic.canvasRenderer.SetAlpha(isOn ? 1f : 0f);
				}
			}
		}

		internal static ScrollRect CreateScrollView(Transform parent, out RectTransform content)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Scroll", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(ScrollRect)
			});
			val.transform.SetParent(parent, false);
			Image component = val.GetComponent<Image>();
			component.sprite = WhiteSprite();
			((Graphic)component).color = new Color(0.05f, 0.04f, 0.03f, 0.55f);
			ScrollRect component2 = val.GetComponent<ScrollRect>();
			component2.horizontal = false;
			component2.vertical = true;
			component2.movementType = (MovementType)2;
			component2.scrollSensitivity = 40f;
			GameObject val2 = new GameObject("Viewport", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(RectMask2D)
			});
			val2.transform.SetParent(val.transform, false);
			Stretch(val2.GetComponent<RectTransform>(), 0f, 0f);
			Image component3 = val2.GetComponent<Image>();
			component3.sprite = WhiteSprite();
			((Graphic)component3).color = new Color(1f, 1f, 1f, 0f);
			((Graphic)component3).raycastTarget = false;
			GameObject val3 = new GameObject("Content", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val2.transform, false);
			content = val3.GetComponent<RectTransform>();
			content.anchorMin = new Vector2(0f, 1f);
			content.anchorMax = new Vector2(1f, 1f);
			content.pivot = new Vector2(0.5f, 1f);
			content.anchoredPosition = Vector2.zero;
			content.sizeDelta = Vector2.zero;
			component2.viewport = val2.GetComponent<RectTransform>();
			component2.content = content;
			return component2;
		}

		internal static TMP_InputField CreateTextField(Transform parent, string placeholder, string value, UnityAction<string> onEndEdit, float height = 36f)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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)
			GameObject val = new GameObject("Field", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			Image component = val.GetComponent<Image>();
			component.sprite = WhiteSprite();
			((Graphic)component).color = new Color(0.06f, 0.05f, 0.04f, 0.95f);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.minHeight = height;
			val2.preferredHeight = height;
			val2.flexibleWidth = 1f;
			GameObject val3 = new GameObject("Text Area", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val3.transform.SetParent(val.transform, false);
			Stretch(val3.GetComponent<RectTransform>(), 10f, 6f);
			TextMeshProUGUI val4 = CreateLabel(val3.transform, "Text", value ?? string.Empty, 18f, (FontStyles)0, (TextAlignmentOptions)513);
			Stretch(((TMP_Text)val4).rectTransform, 0f, 0f);
			((Graphic)val4).raycastTarget = true;
			TextMeshProUGUI val5 = CreateLabel(val3.transform, "Placeholder", placeholder, 18f, (FontStyles)2, (TextAlignmentOptions)513);
			Stretch(((TMP_Text)val5).rectTransform, 0f, 0f);
			((Graphic)val5).color = CreamDim;
			TMP_InputField val6 = val.AddComponent<TMP_InputField>();
			val6.textViewport = val3.GetComponent<RectTransform>();
			val6.textComponent = (TMP_Text)(object)val4;
			val6.placeholder = (Graphic)(object)val5;
			val6.text = value ?? string.Empty;
			val6.caretColor = Cream;
			val6.customCaretColor = true;
			val6.selectionColor = new Color(0.45f, 0.35f, 0.2f, 0.45f);
			val6.onFocusSelectAll = false;
			val6.restoreOriginalTextOnEscape = false;
			((UnityEvent<string>)(object)val6.onEndEdit).AddListener((UnityAction<string>)delegate(string s)
			{
				onEndEdit?.Invoke(s);
			});
			if ((Object)(object)((TMP_Text)val4).font != (Object)null)
			{
				val6.fontAsset = ((TMP_Text)val4).font;
			}
			return val6;
		}

		internal static VerticalLayoutGroup AddVerticalLayout(GameObject go, float spacing, RectOffset padding)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			VerticalLayoutGroup val = go.GetComponent<VerticalLayoutGroup>() ?? go.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val).spacing = spacing;
			((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset(12, 12, 12, 12)));
			((LayoutGroup)val).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)val).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = true;
			return val;
		}

		internal static HorizontalLayoutGroup AddHorizontalLayout(GameObject go, float spacing)
		{
			HorizontalLayoutGroup val = go.GetComponent<HorizontalLayoutGroup>() ?? go.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val).spacing = spacing;
			((LayoutGroup)val).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false;
			return val;
		}

		internal static void Stretch(RectTransform rt, float padX, float padY)
		{
			//IL_0002: 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_001c: 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)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			rt.offsetMin = new Vector2(padX, padY);
			rt.offsetMax = new Vector2(0f - padX, 0f - padY);
		}

		internal static void MakeDraggable(GameObject handle, RectTransform target, Action onDropped = null)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Image val = handle.GetComponent<Image>() ?? handle.AddComponent<Image>();
			val.sprite = WhiteSprite();
			((Graphic)val).color = new Color(0.16f, 0.12f, 0.09f, 0.95f);
			((Graphic)val).raycastTarget = true;
			SoFlyDragHandle soFlyDragHandle = handle.GetComponent<SoFlyDragHandle>() ?? handle.AddComponent<SoFlyDragHandle>();
			soFlyDragHandle.Target = target;
			soFlyDragHandle.OnDropped = onDropped;
		}

		internal static void ApplyAllFonts(Transform root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			TextMeshProUGUI[] componentsInChildren = ((Component)root).GetComponentsInChildren<TextMeshProUGUI>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!((Object)(object)componentsInChildren[i] == (Object)null) && !((Object)(object)((Component)componentsInChildren[i]).GetComponentInParent<TMP_InputField>(true) != (Object)null))
				{
					ApplyFont(componentsInChildren[i]);
				}
			}
			TMP_InputField[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<TMP_InputField>(true);
			foreach (TMP_InputField val in componentsInChildren2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				TMP_FontAsset gameFont = GetGameFont();
				if (!((Object)(object)gameFont == (Object)null))
				{
					if ((Object)(object)val.textComponent != (Object)null)
					{
						val.textComponent.font = gameFont;
					}
					Graphic placeholder = val.placeholder;
					TextMeshProUGUI val2 = (TextMeshProUGUI)(object)((placeholder is TextMeshProUGUI) ? placeholder : null);
					if (val2 != null)
					{
						((TMP_Text)val2).font = gameFont;
					}
					val.fontAsset = gameFont;
				}
			}
		}

		internal static void ApplyFont(TextMeshProUGUI text)
		{
			if (!((Object)(object)text == (Object)null))
			{
				TMP_FontAsset gameFont = GetGameFont();
				if ((Object)(object)gameFont != (Object)null)
				{
					((TMP_Text)text).font = gameFont;
				}
				((TMP_Text)text).fontStyle = (FontStyles)0;
			}
		}

		internal static void ReleaseUiFocus()
		{
			try
			{
				EventSystem current = EventSystem.current;
				if (!((Object)(object)current == (Object)null))
				{
					GameObject currentSelectedGameObject = current.currentSelectedGameObject;
					if (!((Object)(object)currentSelectedGameObject == (Object)null) && !((Object)(object)currentSelectedGameObject.GetComponentInParent<SoFlyMenu>() == (Object)null))
					{
						current.SetSelectedGameObject((GameObject)null);
					}
				}
			}
			catch
			{
			}
		}

		internal static bool HasPeakButtonDonor()
		{
			return (Object)(object)ResolveButtonDonor() != (Object)null;
		}

		internal static void InvalidateButtonDonor()
		{
			_buttonDonor = null;
		}

		internal static Sprite WhiteSprite()
		{
			//IL_0037: 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)
			if ((Object)(object)_whiteSprite != (Object)null)
			{
				return _whiteSprite;
			}
			Texture2D whiteTexture = Texture2D.whiteTexture;
			_whiteSprite = Sprite.Create(whiteTexture, new Rect(0f, 0f, (float)((Texture)whiteTexture).width, (float)((Texture)whiteTexture).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)_whiteSprite).name = "SoFly_WhiteSprite";
			return _whiteSprite;
		}

		private static GameObject CreatePlainButtonObject(Transform parent, string label)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00b0: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Btn_" + Sanitize(label), new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			});
			val.transform.SetParent(parent, false);
			Image component = val.GetComponent<Image>();
			component.sprite = WhiteSprite();
			((Graphic)component).color = ButtonColor;
			Button component2 = val.GetComponent<Button>();
			((Selectable)component2).targetGraphic = (Graphic)(object)component;
			ColorBlock colors = ((Selectable)component2).colors;
			((ColorBlock)(ref colors)).normalColor = ButtonColor;
			((ColorBlock)(ref colors)).highlightedColor = ButtonHover;
			((ColorBlock)(ref colors)).pressedColor = AccentOn;
			((ColorBlock)(ref colors)).selectedColor = ButtonHover;
			((ColorBlock)(ref colors)).disabledColor = new Color(0.2f, 0.16f, 0.12f, 0.5f);
			((Selectable)component2).colors = colors;
			TextMeshProUGUI val2 = CreateLabel(val.transform, "Text", label, 18f, (FontStyles)0, (TextAlignmentOptions)514);
			Stretch(((TMP_Text)val2).rectTransform, 8f, 4f);
			((Graphic)val2).raycastTarget = false;
			return val;
		}

		private static void ApplyButtonSize(GameObject go, Vector2 preferredSize)
		{
			//IL_000d: 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_002d: 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)
			RectTransform component = go.GetComponent<RectTransform>();
			float num = Mathf.Max(32f, preferredSize.y);
			float num2 = Mathf.Max(72f, preferredSize.x);
			component.sizeDelta = new Vector2(num2, num);
			LayoutElement val = go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>();
			val.preferredWidth = num2;
			val.preferredHeight = num;
			val.minHeight = num;
			val.flexibleWidth = ((preferredSize.x >= 160f) ? 1f : 0f);
		}

		private static GameObject TryClonePauseButton(Transform parent, string label)
		{
			try
			{
				GameObject val = ResolveButtonDonor();
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val, parent, false);
				((Object)val2).name = "SoFly_Btn_" + Sanitize(label);
				val2.SetActive(true);
				LocalizedText[] componentsInChildren = val2.GetComponentsInChildren<LocalizedText>(true);
				foreach (LocalizedText val3 in componentsInChildren)
				{
					Object.Destroy((Object)(object)val3);
				}
				return val2;
			}
			catch
			{
				_buttonDonor = null;
				return null;
			}
		}

		private static GameObject ResolveButtonDonor()
		{
			if ((Object)(object)_buttonDonor != (Object)null)
			{
				return _buttonDonor;
			}
			try
			{
				PauseMenuMainPage val = null;
				if ((Object)(object)GUIManager.instance != (Object)null)
				{
					val = GUIManager.instance.pauseMenuMainPage;
				}
				if ((Object)(object)val == (Object)null)
				{
					val = Object.FindFirstObjectByType<PauseMenuMainPage>((FindObjectsInactive)1);
				}
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				Button val2 = val.m_resumeButton ?? val.m_settingsButton ?? val.m_quitButton;
				if ((Object)(object)val2 != (Object)null)
				{
					_buttonDonor = ((Component)val2).gameObject;
					return _buttonDonor;
				}
			}
			catch
			{
			}
			return null;
		}

		internal static TMP_FontAsset GetGameFont()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
			if ((Object)(object)_cachedFont != (Object)null && _cachedSceneHandle == num)
			{
				return _cachedFont;
			}
			try
			{
				if ((Object)(object)GUIManager.instance != (Object)null)
				{
					TextMeshProUGUI componentInChildren = ((Component)GUIManager.instance).GetComponentInChildren<TextMeshProUGUI>(true);
					if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((TMP_Text)componentInChildren).font != (Object)null)
					{
						_cachedFont = ((TMP_Text)componentInChildren).font;
						_cachedSceneHandle = num;
						return _cachedFont;
					}
				}
			}
			catch
			{
			}
			try
			{
				TextMeshProUGUI val = Object.FindFirstObjectByType<TextMeshProUGUI>((FindObjectsInactive)1);
				if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null)
				{
					_cachedFont = ((TMP_Text)val).font;
					_cachedSceneHandle = num;
					return _cachedFont;
				}
			}
			catch
			{
			}
			return _cachedFont;
		}

		internal static string Sanitize(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return "Btn";
			}
			char[] array = s.ToCharArray();
			for (int i = 0; i < array.Length; i++)
			{
				if (!char.IsLetterOrDigit(array[i]))
				{
					array[i] = '_';
				}
			}
			return new string(array);
		}
	}
	internal sealed class SoFlyDragHandle : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		internal RectTransform Target;

		internal Action OnDropped;

		private Vector2 _grabOffset;

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null) && eventData != null)
			{
				_grabOffset = Target.anchoredPosition - ScreenToAnchored(eventData);
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null) && eventData != null)
			{
				Target.anchoredPosition = ScreenToAnchored(eventData) + _grabOffset;
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			OnDropped?.Invoke();
		}

		private Vector2 ScreenToAnchored(PointerEventData eventData)
		{
			//IL_0030: 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_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_0043: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)Target).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val == (Object)null)
			{
				return eventData.position;
			}
			Camera pressEventCamera = eventData.pressEventCamera;
			Vector2 result = default(Vector2);
			if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val, eventData.position, pressEventCamera, ref result))
			{
				return result;
			}
			return Target.anchoredPosition;
		}
	}
	internal sealed class SoFlyMenu : MonoBehaviour
	{
		private enum Tab
		{
			Flight,
			Speed,
			Alerts,
			Players,
			Keys,
			Dev
		}

		[HarmonyPatch(typeof(GUIManager), "UpdateWindowStatus")]
		private static class Patch_UpdateWindowStatus
		{
			private static void Postfix(GUIManager __instance)
			{
				if (!((Object)(object)__instance == (Object)null) && IsOpen)
				{
					__instance.windowBlockingInput = true;
					__instance.windowShowingCursor = true;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "CanDoInput")]
		private static class Patch_CanDoInput
		{
			private static void Postfix(ref bool __result)
			{
				if (IsOpen)
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(CursorHandler), "Update")]
		private static class Patch_CursorHandler
		{
			private static void Postfix()
			{
				if (IsOpen)
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
			}
		}

		private const int SortOrder = 9300;

		private static SoFlyMenu _instance;

		private static KeyCode? _pendingBind;

		private Canvas _canvas;

		private RectTransform _panel;

		private TextMeshProUGUI _help;

		private TextMeshProUGUI _captureHint;

		private GameObject _flightPage;

		private GameObject _speedPage;

		private GameObject _alertsPage;

		private GameObject _playersPage;

		private GameObject _keysPage;

		private GameObject _devPage;

		private RectTransform _playerContent;

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

		private Toggle _incrementalToggle;

		private Toggle _additiveToggle;

		private Toggle _noclipToggle;

		private Toggle _invulnToggle;

		private Toggle _luggageToggle;

		private Toggle _itemsToggle;

		private Toggle _droppedToggle;

		private Toggle _mobsToggle;

		private Toggle _hazardsToggle;

		private Toggle _detectAllToggle;

		private Toggle _pauseButtonToggle;

		private Toggle _autoLightToggle;

		private Toggle _bringAllToggle;

		private readonly Dictionary<LuggageKind, Image> _luggageSwatches = new Dictionary<LuggageKind, Image>();

		private readonly Dictionary<LuggageKind, Toggle> _luggageShowToggles = new Dictionary<LuggageKind, Toggle>();

		private readonly Dictionary<MobKind, Image> _mobSwatches = new Dictionary<MobKind, Image>();

		private readonly Dictionary<MobKind, Toggle> _mobShowToggles = new Dictionary<MobKind, Toggle>();

		private readonly Dictionary<HazardKind, Image> _hazardSwatches = new Dictionary<HazardKind, Image>();

		private readonly Dictionary<HazardKind, Toggle> _hazardShowToggles = new Dictionary<HazardKind, Toggle>();

		private Button _afflictionTypeButton;

		private Button _itemPickButton;

		private TextMeshProUGUI _itemSearchHint;

		private Image _itemColorSwatch;

		private Image _droppedColorSwatch;

		private TMP_InputField _afflictionAmountField;

		private TextMeshProUGUI _itemIdLabel;

		private TextMeshProUGUI _detectStatusLabel;

		private int _afflictionIndex;

		private float _nextItemIdRefresh;

		private TMP_InputField _incrementalField;

		private TMP_InputField _additiveField;

		private TMP_InputField _additiveCapField;

		private readonly Dictionary<string, TextMeshProUGUI> _bindLabels = new Dictionary<string, TextMeshProUGUI>();

		private Tab _tab = Tab.Flight;

		private bool _visible;

		private bool _built;

		private CursorLockMode _prevLock;

		private bool _prevCursorVisible;

		private Vector2 _frozenLookValues;

		private bool _hasFrozenLook;

		private float _nextPlayerRefresh;

		private Action<KeyCode> _captureTarget;

		private TextMeshProUGUI _captureLabel;

		public static bool IsOpen => (Object)(object)_instance != (Object)null && _instance._visible && ((Component)_instance).gameObject.activeInHierarchy;

		public static bool IsCapturingKey => _pendingBind.HasValue;

		public static void EnsureCreated()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!((Object)(object)_instance != (Object)null))
			{
				GameObject val = new GameObject("SoFly_Menu");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<SoFlyMenu>();
				val.SetActive(false);
			}
		}

		public static void Toggle()
		{
			EnsureCreated();
			if (IsOpen)
			{
				_instance.CloseInternal();
			}
			else
			{
				_instance.Open();
			}
		}

		public static void Close()
		{
			if ((Object)(object)_instance != (Object)null)
			{
				_instance.CloseInternal();
			}
		}

		public static void DestroyInstance()
		{
			if (!((Object)(object)_instance == (Object)null))
			{
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
				_instance = null;
			}
		}

		public static void RefreshPlayersIfOpen()
		{
			if (IsOpen && _instance._tab == Tab.Players)
			{
				_instance.RebuildPlayerRows();
			}
		}

		public static void InjectPauseChip(PauseMenuMainPage page)
		{
			try
			{
				if ((Object)(object)page == (Object)null)
				{
					return;
				}
				Button val = page.m_quitButton ?? page.m_settingsButton ?? page.m_resumeButton;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Transform parent = ((Component)val).transform.parent;
				if ((Object)(object)parent == (Object)null)
				{
					return;
				}
				if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.pauseMenu != (Object)null)
				{
					Transform val2 = GUIManager.instance.pauseMenu.transform.Find("SoFly_PauseChip");
					if ((Object)(object)val2 != (Object)null && (Object)(object)val2.parent != (Object)(object)parent)
					{
						Object.Destroy((Object)(object)((Component)val2).gameObject);
					}
				}
				Transform val3 = parent.Find("SoFly_PauseChip");
				GameObject val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : CreatePauseStackButton(val, parent));
				PlaceAboveLeaveGame(val4.GetComponent<RectTransform>(), ((Component)val).GetComponent<RectTransform>(), parent);
				val4.SetActive(SoFlyConfig.ShowPauseMenuButton == null || SoFlyConfig.ShowPauseMenuButton.Value);
			}
			catch (Exception ex)
			{
				ManualLogSource log = SoFlyPlugin.Log;
				if (log != null)
				{
					log.LogDebug((object)("Pause chip inject failed: " + ex.Message));
				}
			}
		}

		internal static void RefreshPauseButton()
		{
			try
			{
				PauseMenuMainPage val = Object.FindFirstObjectByType<PauseMenuMainPage>((FindObjectsInactive)1);
				if ((Object)(object)val != (Object)null)
				{
					InjectPauseChip(val);
				}
			}
			catch
			{
			}
		}

		private static GameObject CreatePauseStackButton(Button donor, Transform parent)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)donor).gameObject, parent, false);
			((Object)val).name = "SoFly_PauseChip";
			val.SetActive(true);
			LocalizedText[] componentsInChildren = val.GetComponentsInChildren<LocalizedText>(true);
			foreach (LocalizedText val2 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val2);
			}
			TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).text = "So Fly";
			}
			Button component = val.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEvent)component.onClick).AddListener(new UnityAction(Toggle));
			}
			return val;
		}

		private static void PlaceAboveLeaveGame(RectTransform soFly, RectTransform leave, Transform parent)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)soFly == (Object)null || (Object)(object)leave == (Object)null)
			{
				return;
			}
			float num = 56f;
			if ((Object)(object)parent != (Object)null && parent.childCount >= 2)
			{
				Transform child = parent.GetChild(0);
				RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null);
				Transform child2 = parent.GetChild(1);
				RectTransform val2 = (RectTransform)(object)((child2 is RectTransform) ? child2 : null);
				if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
				{
					float num2 = Mathf.Abs(val.anchoredPosition.y - val2.anchoredPosition.y);
					if (num2 > 20f && num2 < 120f)
					{
						num = num2;
					}
				}
			}
			soFly.anchorMin = leave.anchorMin;
			soFly.anchorMax = leave.anchorMax;
			soFly.pivot = leave.pivot;
			soFly.sizeDelta = leave.sizeDelta;
			if (soFly.anchoredPosition.y > leave.anchoredPosition.y + 8f)
			{
				((Transform)soFly).SetSiblingIndex(((Transform)leave).GetSiblingIndex());
				return;
			}
			Vector2 val3 = (soFly.anchoredPosition = leave.anchoredPosition);
			leave.anchoredPosition = val3 + new Vector2(0f, 0f - num);
			((Transform)soFly).SetSiblingIndex(((Transform)leave).GetSiblingIndex());
		}

		private void Open()
		{
			//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_0099: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Build();
				_visible = true;
				((Component)this).gameObject.SetActive(true);
				_prevLock = Cursor.lockState;
				_prevCursorVisible = Cursor.visible;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				ApplyMenuInputBlock(block: true);
				CaptureFrozenLook();
				ShowTab(_tab);
				SyncFromConfig();
				SoFlyUi.ApplyAllFonts(((Component)this).transform);
				if ((Object)(object)_panel != (Object)null)
				{
					_panel.anchoredPosition = new Vector2(SoFlyConfig.MenuPosX.Value, SoFlyConfig.MenuPosY.Value);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = SoFlyPlugin.Log;
				if (log != null)
				{
					log.LogError((object)("So Fly menu failed to open: " + ex));
				}
				_visible = false;
				_hasFrozenLook = false;
				ApplyMenuInputBlock(block: false);
				((Component)this).gameObject.SetActive(false);
			}
		}

		private void CloseInternal()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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)
			_pendingBind = null;
			FlyHud.SetLayoutMode(enabled: false);
			_hasFrozenLook = false;
			SoFlyUi.ReleaseUiFocus();
			ApplyMenuInputBlock(block: false);
			if (_visible)
			{
				Cursor.lockState = _prevLock;
				Cursor.visible = _prevCursorVisible;
			}
			_visible = false;
			if ((Object)(object)_panel != (Object)null)
			{
				SoFlyConfig.MenuPosX.Value = _panel.anchoredPosition.x;
				SoFlyConfig.MenuPosY.Value = _panel.anchoredPosition.y;
			}
			((Component)this).gameObject.SetActive(false);
		}

		private void Update()
		{
			if (!_visible)
			{
				return;
			}
			if (_pendingBind.HasValue)
			{
				PollKeyCapture();
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				CloseInternal();
			}
			if (_tab == Tab.Players && Time.unscaledTime >= _nextPlayerRefresh)
			{
				_nextPlayerRefresh = Time.unscaledTime + 0.75f;
				RebuildPlayerRows();
			}
			if (_tab == Tab.Dev && Time.unscaledTime >= _nextItemIdRefresh)
			{
				_nextItemIdRefresh = Time.unscaledTime + 0.4f;
				RefreshItemIds();
			}
		}

		private void LateUpdate()
		{
			if (_visible)
			{
				HoldFrozenLook();
			}
		}

		private void Build()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0131: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			if (!_built)
			{
				_canvas = SoFlyUi.CreateOverlayCanvas(((Component)this).gameObject, 9300);
				_panel = SoFlyUi.CreatePanel(((Component)this).transform, "Panel", new Vector2(760f, 880f), SoFlyUi.PanelColor);
				SoFlyUi.AddVerticalLayout(((Component)_panel).gameObject, 6f, new RectOffset(18, 18, 14, 14));
				GameObject val = new GameObject("TitleBar", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent((Transform)(object)_panel, false);
				SoFlyUi.MakeNonCollapsing(val, 36f);
				TextMeshProUGUI val2 = SoFlyUi.CreateLabel(val.transform, "Title", "So Fly   (drag)", 26f, (FontStyles)0, (TextAlignmentOptions)514);
				SoFlyUi.Stretch(((TMP_Text)val2).rectTransform, 0f, 0f);
				SoFlyUi.MakeDraggable(val, _panel, delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Unknown result type (might be due to invalid IL or missing references)
					SoFlyConfig.MenuPosX.Value = _panel.anchoredPosition.x;
					SoFlyConfig.MenuPosY.Value = _panel.anchoredPosition.y;
				});
				_help = SoFlyUi.CreateLabel((Transform)(object)_panel, "Help", "Host controls other So Fly players. Your keys and colors stay local.", 15f, (FontStyles)0, (TextAlignmentOptions)514);
				((Graphic)_help).color = SoFlyUi.CreamDim;
				SoFlyUi.MakeNonCollapsing(((Component)_help).gameObject, 32f);
				((TMP_Text)_help).enableWordWrapping = true;
				BuildTabBar();
				_flightPage = BuildFlightPage();
				_speedPage = BuildSpeedPage();
				_alertsPage = BuildAlertsPage();
				_playersPage = BuildPlayersPage();
				_keysPage = BuildKeysPage();
				_devPage = BuildDevPage();
				_captureHint = SoFlyUi.CreateLabel((Transform)(object)_panel, "Capture", string.Empty, 16f, (FontStyles)0, (TextAlignmentOptions)514);
				((Graphic)_captureHint).color = SoFlyUi.CreamDim;
				SoFlyUi.MakeNonCollapsing(((Component)_captureHint).gameObject, 24f);
				SoFlyUi.CreatePlainButton((Transform)(object)_panel, "Close", new UnityAction(CloseInternal), new Vector2(200f, 36f));
				_built = true;
			}
		}

		private void BuildTabBar()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			GameObject val = new GameObject("Tabs", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)_panel, false);
			SoFlyUi.MakeNonCollapsing(val, 80f);
			SoFlyUi.AddVerticalLayout(val, 6f, new RectOffset(0, 0, 0, 0));
			GameObject val2 = MakeRow(val.transform);
			GameObject val3 = MakeRow(val.transform);
			AddTabButton(val2.transform, "Flight", Tab.Flight);
			AddTabButton(val2.transform, "Speed", Tab.Speed);
			AddTabButton(val2.transform, "Alerts", Tab.Alerts);
			AddTabButton(val3.transform, "Players", Tab.Players);
			AddTabButton(val3.transform, "Keys", Tab.Keys);
			AddTabButton(val3.transform, "Dev Tools", Tab.Dev);
		}

		private void AddTabButton(Transform parent, string label, Tab tab)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			SoFlyUi.CreatePlainButton(parent, label, (UnityAction)delegate
			{
				ShowTab(tab);
			}, new Vector2(220f, 34f));
		}

		private GameObject BuildFlightPage()
		{
			GameObject val = MakePage("FlightPage");
			_noclipToggle = SoFlyUi.CreateToggle(val.transform, "Noclip while flying", SoFlyConfig.NoclipEnabled.Value, delegate(bool v)
			{
				SoFlyConfig.NoclipEnabled.Value = v;
			});
			_invulnToggle = SoFlyUi.CreateToggle(val.transform, "Invincible until land / climb / pass out", SoFlyConfig.InvulnEnabled.Value, delegate(bool v)
			{
				SoFlyConfig.InvulnEnabled.Value = v;
			});
			AddHint(val.transform, "Noclip and invuln can still be denied by the host. Default both on.");
			return val;
		}

		private GameObject BuildSpeedPage()
		{
			GameObject val = MakePage("SpeedPage");
			AddHint(val.transform, "Checking one mode unchecks the other. Both number fields stay saved.");
			GameObject val2 = MakeRow(val.transform);
			_incrementalToggle = SoFlyUi.CreateToggle(val2.transform, "Incremental Speed", SoFlyConfig.SelectedSpeedMode.Value == SpeedMode.Incremental, OnIncrementalToggled);
			_incrementalField = SoFlyUi.CreateTextField(val2.transform, "10,25,50,75,100", SoFlyConfig.IncrementalSpeeds.Value, delegate(string v)
			{
				SoFlyConfig.IncrementalSpeeds.Value = v;
			});
			GameObject val3 = MakeRow(val.transform);
			_additiveToggle = SoFlyUi.CreateToggle(val3.transform, "Additive Speed", SoFlyConfig.SelectedSpeedMode.Value == SpeedMode.Additive, OnAdditiveToggled);
			_additiveField = SoFlyUi.CreateTextField(val3.transform, "10", SoFlyConfig.AdditiveBase.Value, delegate(string v)
			{
				SoFlyConfig.AdditiveBase.Value = v;
			});
			TextMeshProUGUI val4 = SoFlyUi.CreateLabel(val3.transform, "CapLbl", "Cap", 16f, (FontStyles)0, (TextAlignmentOptions)513);
			SoFlyUi.MakeNonCollapsing(((Component)val4).gameObject, 32f, 40f);
			_additiveCapField = SoFlyUi.CreateTextField(val3.transform, "300", SoFlyConfig.AdditiveCap.Value, delegate(string v)
			{
				SoFlyConfig.AdditiveCap.Value = v;
			});
			AddHint(val.transform, "Additive adds the base each V press, up to the cap, and R resets to base.");
			return val;
		}

		private GameObject BuildAlertsPage()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			GameObject val = MakePage("AlertsPage");
			RectTransform content;
			ScrollRect val2 = SoFlyUi.CreateScrollView(val.transform, out content);
			((Component)val2).gameObject.AddComponent<LayoutElement>().flexibleHeight = 1f;
			SoFlyUi.AddVerticalLayout(((Component)content).gameObject, 6f, new RectOffset(4, 4, 4, 4));
			ContentSizeFitter val3 = ((Component)content).gameObject.AddComponent<ContentSizeFitter>();
			val3.verticalFit = (FitMode)2;
			SoFlyUi.CreateToggle((Transform)(object)content, "Hide all alerts", SoFlyConfig.HideAllNotifications.Value, delegate(bool v)
			{
				SoFlyConfig.HideAllNotifications.Value = v;
			});
			AddHint((Transform)(object)content, "This tab shows live previews. Drag them on-screen to place them.");
			AddAlertRow((Transform)(object)content, "Fly ON", FlyAlertKind.On);
			AddAlertRow((Transform)(object)content, "Fly OFF", FlyAlertKind.Off);
			AddAlertRow((Transform)(object)content, "Speed", FlyAlertKind.Speed);
			AddAlertRow((Transform)(object)content, "Noclip", FlyAlertKind.Noclip);
			AddAlertRow((Transform)(object)content, "No fire", FlyAlertKind.NoFire);
			AddAlertRow((Transform)(object)content, "Blocked", FlyAlertKind.Blocked);
			AddAlertRow((Transform)(object)content, "No host", FlyAlertKind.HostMissing);
			return val;
		}

		private void AddAlertRow(Transform parent, string label, FlyAlertKind kind)
		{
			//IL_0061: 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_007a: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			GameObject val = MakeRow(parent);
			TextMeshProUGUI val2 = SoFlyUi.CreateLabel(val.transform, "N", label, 16f, (FontStyles)0, (TextAlignmentOptions)513);
			SoFlyUi.MakeNonCollapsing(((Component)val2).gameObject, 32f, 90f);
			SoFlyUi.CreatePlainButton(val.transform, "Color", (UnityAction)delegate
			{
				OpenColor(kind);
			}, new Vector2(90f, 32f));
			SoFlyUi.CreatePlainButton(val.transform, "Preview", (UnityAction)delegate
			{
				FlyHud.Preview(kind);
			}, new Vector2(100f, 32f));
			TMP_InputField val3 = SoFlyUi.CreateTextField(val.transform, "60", GetSize(kind).ToString(), delegate(string v)
			{
				if (int.TryParse(v, out var result))
				{
					SetSize(kind, Mathf.Clamp(result, 12, 120));
				}
			}, 32f);
			LayoutElement component = ((Component)val3).GetComponent<LayoutElement>();
			if ((Object)(object)component != (Object)null)
			{
				component.flexibleWidth = 0f;
				component.preferredWidth = 70f;
			}
		}

		private GameObject BuildPlayersPage()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			GameObject val = MakePage("PlayersPage");
			AddHint(val.transform, "Teleport and Revive on this tab still need those abilities granted. New So Fly players start with every ability off until you enable them.");
			ScrollRect val2 = SoFlyUi.CreateScrollView(val.transform, out _playerContent);
			((Component)val2).gameObject.AddComponent<LayoutElement>().flexibleHeight = 1f;
			SoFlyUi.AddVerticalLayout(((Component)_playerContent).gameObject, 6f, new RectOffset(4, 4, 4, 4));
			ContentSizeFitter val3 = ((Component)_playerContent).gameObject.AddComponent<ContentSizeFitter>();
			val3.verticalFit = (FitMode)2;
			return val;
		}

		private GameObject BuildKeysPage()
		{
			GameObject val = MakePage("KeysPage");
			AddBindRow(val.transform, "Menu", () => SoFlyConfig.MenuKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.MenuKey.Value = v;
			});
			AddBindRow(val.transform, "Fly modifier", () => SoFlyConfig.FlyToggleModifier, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.FlyToggleModifier.Value = v;
			});
			AddBindRow(val.transform, "Fly toggle", () => SoFlyConfig.FlyToggleKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.FlyToggleKey.Value = v;
			});
			SoFlyUi.CreateToggle(val.transform, "Require modifier for fly toggle", SoFlyConfig.RequireModifierKey.Value, delegate(bool v)
			{
				SoFlyConfig.RequireModifierKey.Value = v;
			});
			AddBindRow(val.transform, "Speed adjust", () => SoFlyConfig.SpeedAdjustKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.SpeedAdjustKey.Value = v;
			});
			AddBindRow(val.transform, "Additive reset", () => SoFlyConfig.AdditiveResetKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.AdditiveResetKey.Value = v;
			});
			AddBindRow(val.transform, "Noclip", () => SoFlyConfig.NoclipKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.NoclipKey.Value = v;
			});
			AddBindRow(val.transform, "Teleport to fire", () => SoFlyConfig.TeleportFireKey, delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				SoFlyConfig.TeleportFireKey.Value = v;
			});
			_pauseButtonToggle = SoFlyUi.CreateToggle(val.transform, "Show So Fly on the pause menu", SoFlyConfig.ShowPauseMenuButton.Value, delegate(bool v)
			{
				SoFlyConfig.ShowPauseMenuButton.Value = v;
				RefreshPauseButton();
			});
			AddHint(val.transform, "Click a bind, then press a key. Escape cancels. Clear removes the bind. F2 still works if the pause button is hidden. Teleport to fire uses Auto-light when that toggle is on.");
			return val;
		}

		private GameObject BuildDevPage()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: 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_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Expected O, but got Unknown
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Expected O, but got Unknown
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Expected O, but got Unknown
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Expected O, but got Unknown
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Expected O, but got Unknown
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Unknown result type (might be due to invalid IL or missing references)
			//IL_080f: Expected O, but got Unknown
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Expected O, but got Unknown
			//IL_0901: Unknown result type (might be due to invalid IL or missing references)
			//IL_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_091a: Expected O, but got Unknown
			//IL_092e: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0947: Expected O, but got Unknown
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_096a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0974: Expected O, but got Unknown
			//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakePage("DevPage");
			RectTransform content;
			ScrollRect val2 = SoFlyUi.CreateScrollView(val.transform, out content);
			((Component)val2).gameObject.AddComponent<LayoutElement>().flexibleHeight = 1f;
			SoFlyUi.AddVerticalLayout(((Component)content).gameObject, 6f, new RectOffset(4, 4, 4, 4));
			ContentSizeFitter val3 = ((Component)content).gameObject.AddComponent<ContentSizeFitter>();
			val3.verticalFit = (FitMode)2;
			AddHint((Transform)(object)content, "Local test helpers. Clients cannot use these until you grant them on the Players tab.");
			AddHint((Transform)(object)content, "Detect one thing at a time. Turning luggage, items, dropped items, mobs, or hazards on turns the others off.");
			_luggageToggle = SoFlyUi.CreateToggle((Transform)(object)content, "Show luggage through walls", SoFlyConfig.ShowLuggage.Value, delegate(bool v)
			{
				OnDetectToggled(DetectKind.Luggage, v);
			});
			_itemsToggle = SoFlyUi.CreateToggle((Transform)(object)content, "Show items through walls", SoFlyConfig.ShowItems.Value, delegate(bool v)
			{
				OnDetectToggled(DetectKind.Items, v);
			});
			_droppedToggle = SoFlyUi.CreateToggle((Transform)(object)content, "Show dropped items through walls", SoFlyConfig.ShowDroppedItems.Value, delegate(bool v)
			{
				OnDetectToggled(DetectKind.Dropped, v);
			});
			_mobsToggle = SoFlyUi.CreateToggle((Transform)(object)content, "Show mobs through walls", SoFlyConfig.ShowMobs.Value, delegate(bool v)
			{
				OnDetectToggled(DetectKind.Mobs, v);
			});
			_hazardsToggle = SoFlyUi.CreateToggle((Transform)(object)content, "Show hazards through walls", SoFlyConfig.ShowHazards.Value, delegate(bool v)
			{
				OnDetectToggled(DetectKind.Hazards, v);
			});
			_detectStatusLabel = SoFlyUi.CreateLabel((Transf