Decompiled source of BloodCraftHub v0.27.1

BloodCraftHub.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Timers;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BloodCraftHub.Behaviors;
using BloodCraftHub.Config;
using BloodCraftHub.Patches;
using BloodCraftHub.Resources;
using BloodCraftHub.Services;
using BloodCraftHub.Services.Beelzebub;
using BloodCraftHub.Services.Uriel;
using BloodCraftHub.UI;
using BloodCraftHub.UI.Forms;
using BloodCraftHub.UI.Framework.CustomLib;
using BloodCraftHub.UI.Framework.CustomLib.Controls;
using BloodCraftHub.UI.Framework.CustomLib.Panel;
using BloodCraftHub.UI.Framework.CustomLib.Util;
using BloodCraftHub.UI.Framework.ModernLib;
using BloodCraftHub.UI.Framework.UniverseLib.UI;
using BloodCraftHub.UI.Framework.UniverseLib.UI.Models;
using BloodCraftHub.UI.Framework.UniverseLib.UI.ObjectPool;
using BloodCraftHub.UI.Framework.UniverseLib.UI.Panels;
using BloodCraftHub.UI.Framework.UniverseLib.UI.Widgets;
using BloodCraftHub.UI.Framework.UniverseLib.UI.Widgets.ScrollView;
using BloodCraftHub.UI.ModContent;
using BloodCraftHub.UI.ModContent.Data;
using BloodCraftHub.Utils;
using Engine.Console;
using Engine.Console.PublicInterface;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.UI;
using Stunlock.Core;
using TMPro;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("kdpen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Unified client UI for V Rising's Bloodcraft mod. Surfaces every Bloodcraft, KindredCommands, and KindredLogistics chat command as buttons + forms.")]
[assembly: AssemblyFileVersion("0.27.1.0")]
[assembly: AssemblyInformationalVersion("0.27.1+4a27d76594d51c1ba8e511d15fceb931212624c4")]
[assembly: AssemblyProduct("BloodCraftHub")]
[assembly: AssemblyTitle("BloodCraftHub")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.27.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BloodCraftHub
{
	internal static class Core
	{
		private static World _client;

		public static World ClientWorld => _client;

		public static EntityManager EntityManager => _client.EntityManager;

		public static ManualLogSource Log => Plugin.LogInstance;

		public static bool HasInitialized { get; private set; }

		public static Entity LocalCharacter { get; set; } = Entity.Null;


		public static Entity LocalUser { get; set; } = Entity.Null;


		public static byte[] SharedKey { get; set; }

		public static void Initialize(World clientWorld)
		{
			if (!HasInitialized)
			{
				_client = clientWorld;
				HasInitialized = true;
				Log.LogInfo((object)"Core initialized on client world.");
			}
		}

		public static void Reset()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_client = null;
			LocalCharacter = Entity.Null;
			LocalUser = Entity.Null;
			SharedKey = null;
			HasInitialized = false;
		}
	}
	[BepInProcess("VRising.exe")]
	[BepInPlugin("BloodCraftHub", "BloodCraftHub", "0.27.1")]
	public class Plugin : BasePlugin
	{
		public const bool IS_TESTING = false;

		private static World _client;

		private Harmony _harmony;

		public static Plugin Instance { get; private set; }

		public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;

		public static Settings Settings { get; private set; }

		public static BCHubUIManager UIManager { get; private set; }

		public static CoreUpdateBehavior CoreUpdateBehavior { get; private set; }

		public static bool IsClient { get; private set; }

		public static bool IsInitialized { get; private set; }

		public static bool IsGameDataInitialized { get; set; }

		public static EntityManager EntityManager => _client.EntityManager;

		public static Entity LocalCharacter { get; set; } = Entity.Null;


		public static bool IsClientNull()
		{
			return _client == null;
		}

		public override void Load()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Expected O, but got Unknown
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			Instance = this;
			IsClient = Application.productName != "VRisingServer";
			LogUtils.Init(((BasePlugin)this).Log);
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (!IsClient)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(45, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BloodCraftHub");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.27.1");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] is a client mod — not loading on server (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Application.productName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
				return;
			}
			Settings = new Settings().InitConfig();
			Theme.UIFontMultiplier = Settings.UITextScale;
			Theme.OverlayFontMultiplier = Settings.OverlayTextScale;
			EclipseProtocolService.Initialize();
			UIManager = new BCHubUIManager();
			CoreUpdateBehavior = new CoreUpdateBehavior();
			CoreUpdateBehavior.Setup();
			CoreUpdateBehavior.Actions.Add(MessageService.ProcessAllMessages);
			CoreUpdateBehavior.Actions.Add(MessageService.TickInterceptTimeouts);
			CoreUpdateBehavior.Actions.Add(VBloodScannerService.Tick);
			CoreUpdateBehavior.Actions.Add(ShiftCooldownService.Tick);
			CoreUpdateBehavior.Actions.Add(RecipeService.Tick);
			CoreUpdateBehavior.Actions.Add(TooltipHover.TickAll);
			CoreUpdateBehavior.Actions.Add(FormDropdownRegistry.TickCloseOnOutsideClick);
			CoreUpdateBehavior.Actions.Add(SliderClickRegistry.TickClickOnTrack);
			CoreUpdateBehavior.Actions.Add(TickHotkeys);
			CoreUpdateBehavior.Actions.Add(InputSuppression.TickChatFocus);
			CoreUpdateBehavior.Actions.Add(InputSuppression.DrainMenuOpenRequests);
			CoreUpdateBehavior.Actions.Add(TypingInputLock.Tick);
			CoreUpdateBehavior.Actions.Add(UIManager.TickDeferredRestore);
			CoreUpdateBehavior.Actions.Add(UIManager.TickPendingHide);
			CoreUpdateBehavior.Actions.Add(UIManager.TickNativeChatGuard);
			CoreUpdateBehavior.Actions.Add(UIManager.TickOverlayAvailability);
			CoreUpdateBehavior.Actions.Add(BeelzProtocolService.Tick);
			CoreUpdateBehavior.Actions.Add(BeelzProtocolService.TickKeybinds);
			CoreUpdateBehavior.Actions.Add(UrielProtocolService.Tick);
			CoreUpdateBehavior.Actions.Add(UrielBuildMode.Tick);
			_harmony = new Harmony("BloodCraftHub");
			ApplyPatches(_harmony);
			IsInitialized = true;
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(17, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BloodCraftHub");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.27.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded.");
			}
			log2.LogInfo(val);
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}

		public static void UIOnInitialize()
		{
			if (UIManager.IsInitialized)
			{
				UIManager.RestoreAfterRelogIfNeeded();
				return;
			}
			UIManager.SetupAndShowUI();
			UIManager.ScheduleOverlayRestore();
			LogUtils.LogInfo("UI Manager initialized.");
		}

		private void ApplyPatches(Harmony h)
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			bool flag = default(bool);
			if (BuildVariant.IsTestVariant)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(99, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("*** BloodCraftHub CRASH-TEST VARIANT: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((string)null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" — NOT a normal release; one patch group is compiled OFF. ***");
				}
				log.LogWarning(val);
			}
			bool enableChatSystemHooks = Settings.EnableChatSystemHooks;
			bool enableOverlayLayeringPatch = Settings.EnableOverlayLayeringPatch;
			bool enableInputSuppressionPatches = Settings.EnableInputSuppressionPatches;
			h.CreateClassProcessor(typeof(InitializationPatch)).Patch();
			if (enableChatSystemHooks)
			{
				h.CreateClassProcessor(typeof(ClientChatPatch)).Patch();
				((BasePlugin)this).Log.LogInfo((object)"[compat] Chat-system patches APPLIED (inbound parsing + tabbed chat window).");
			}
			else
			{
				((BasePlugin)this).Log.LogWarning((object)"[compat] Chat-system patches SKIPPED — tabbed chat + command-reply parsing are DISABLED. Diagnostic; expected to be ON for normal use.");
			}
			if (enableInputSuppressionPatches)
			{
				h.CreateClassProcessor(typeof(GameplayInputSuppressionPatch)).Patch();
				h.CreateClassProcessor(typeof(AbilityInputSuppressionPatch)).Patch();
				((BasePlugin)this).Log.LogInfo((object)"[compat] Input-suppression (movement/ability) APPLIED.");
			}
			else
			{
				((BasePlugin)this).Log.LogWarning((object)"[compat] Input-suppression (movement/ability) SKIPPED — your character may move/cast while you type. Diagnostic.");
			}
			if (enableOverlayLayeringPatch)
			{
				h.CreateClassProcessor(typeof(UICanvasSystemPatch)).Patch();
				((BasePlugin)this).Log.LogInfo((object)"[compat] Overlay-layering patch APPLIED (overlays-behind-menus).");
			}
			else
			{
				((BasePlugin)this).Log.LogWarning((object)"[compat] Overlay-layering patch SKIPPED — overlays always render on top. Diagnostic; expected to be ON for normal use.");
			}
			if (!enableChatSystemHooks)
			{
				return;
			}
			try
			{
				h.CreateClassProcessor(typeof(ClanWhisperRedirectPatch)).Patch();
				((BasePlugin)this).Log.LogInfo((object)"[compat] Social-menu whisper redirect APPLIED (right-click Whisper -> BCH chat).");
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = ((BasePlugin)this).Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(91, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[compat] Social-menu whisper redirect did not apply (non-fatal, native whisper unchanged): ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val);
			}
		}

		public static void GameDataOnInitialize(World world)
		{
			if (!IsGameDataInitialized && IsClient)
			{
				_client = world;
				IsGameDataInitialized = true;
				LogUtils.LogInfo("Client world bound; game data initialized.");
			}
		}

		public static void ResetGameData()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_client = null;
			IsGameDataInitialized = false;
			LocalCharacter = Entity.Null;
		}

		private static void TickHotkeys()
		{
			if (UIManager == null || !UIManager.IsInitialized || InputSuppression.ChatInputActive)
			{
				return;
			}
			BCHotkey hotkeyToggleMainPanel = Settings.HotkeyToggleMainPanel;
			if (!hotkeyToggleMainPanel.IsEmpty && hotkeyToggleMainPanel.IsDown())
			{
				try
				{
					LogUtils.LogDiagnostic($"Hotkey fired: HotkeyToggleMainPanel ({hotkeyToggleMainPanel})");
					UIManager.ToggleMainPanel();
				}
				catch (Exception value)
				{
					LogUtils.LogError($"HotkeyToggleMainPanel handler threw: {value}");
				}
			}
			BCHotkey hotkeyToggleAllOverlays = Settings.HotkeyToggleAllOverlays;
			if (hotkeyToggleAllOverlays.IsEmpty || !hotkeyToggleAllOverlays.IsDown())
			{
				return;
			}
			try
			{
				LogUtils.LogDiagnostic($"Hotkey fired: HotkeyToggleAllOverlays ({hotkeyToggleAllOverlays})");
				UIManager.ToggleAllOverlaysSuppressed();
			}
			catch (Exception value2)
			{
				LogUtils.LogError($"HotkeyToggleAllOverlays handler threw: {value2}");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BloodCraftHub";

		public const string PLUGIN_NAME = "BloodCraftHub";

		public const string PLUGIN_VERSION = "0.27.1";
	}
}
namespace BloodCraftHub.Utils
{
	public static class Extensions
	{
		private static EntityManager EntityManager => Plugin.EntityManager;

		public static Color GetTransparent(this Color baseColor, float alpha = 0.7f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(baseColor.r, baseColor.g, baseColor.b, alpha);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
		}

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			TypeIndex typeIndex = new ComponentType(Il2CppType.Of<T>(), (AccessMode)0).TypeIndex;
			EntityManager entityManager = EntityManager;
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, typeIndex)));
		}

		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			TypeIndex typeIndex = new ComponentType(Il2CppType.Of<T>(), (AccessMode)0).TypeIndex;
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, typeIndex, (void*)ptr, num);
			}
		}

		public static bool HasValue(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return entity != Entity.Null;
		}

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (entity != Entity.Null && !Plugin.IsClientNull())
			{
				EntityManager entityManager = Plugin.EntityManager;
				return ((EntityManager)(ref entityManager)).Exists(entity);
			}
			return false;
		}

		private static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			try
			{
				Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
				Marshal.Copy(intPtr, array, 0, num);
				return array;
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}
	}
	public static class LogUtils
	{
		private static ManualLogSource _log;

		public static void Init(ManualLogSource log)
		{
			_log = log;
		}

		public static void LogInfo(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogInfo(msg);
			}
		}

		public static void LogWarning(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogWarning(msg);
			}
		}

		public static void LogError(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogError(msg);
			}
		}

		public static void LogDebug(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogDebug(msg);
			}
		}

		public static void LogDiagnostic(object msg)
		{
			if (Settings.DiagnosticMode)
			{
				ManualLogSource log = _log;
				if (log != null)
				{
					log.LogInfo((object)("[DIAG] " + msg));
				}
			}
		}
	}
}
namespace BloodCraftHub.UI
{
	public class BCHubUIManager : UIManagerBase
	{
		private readonly List<IPanelBase> _panels = new List<IPanelBase>();

		private FloatingButtonPanel _floatingButton;

		private MainPanel _mainPanel;

		private ExperienceOverlayPanel _experienceOverlay;

		private FamiliarOverlayPanel _familiarOverlay;

		private FamiliarBrowserOverlayPanel _familiarBrowserOverlay;

		private DailyQuestOverlayPanel _dailyQuestOverlay;

		private ProfessionOverlayPanel _professionOverlay;

		private ShiftSpellOverlayPanel _shiftSpellOverlay;

		private QuickActionsOverlayPanel _quickActionsOverlay;

		private BeelzActionBarOverlayPanel _beelzActionBarOverlay;

		private BeelzSummonsOverlayPanel _beelzSummonsOverlay;

		private BeelzTransformOverlayPanel _beelzTransformOverlay;

		private UrielSharedOverlayPanel _urielSharedOverlay;

		private ChatWindowOverlayPanel _chatWindowOverlay;

		private SecondaryChatOverlayPanel _secondaryChatOverlay;

		private HUDChatWindow _nativeChat;

		private CombinedOverlayPanel _combinedOverlay;

		private bool _overlaysSuppressed;

		private bool _uiActive = true;

		private bool _hideForLogoutPending;

		private bool _loggedOut;

		private bool _restoreArmed;

		private double _restoreFireAt;

		private bool _lastBcAvailable;

		private bool _lastBeelzAvailable;

		private bool _availabilityTrackInit;

		private bool _nativeHidden;

		private Action _deferredMainPanelRebuild;

		private Action _deferredOverlayRebuild;

		public bool IsMainPanelOpen
		{
			get
			{
				if (_mainPanel != null)
				{
					return _mainPanel.Enabled;
				}
				return false;
			}
		}

		public MainPanel MainPanel => _mainPanel;

		public ExperienceOverlayPanel ExperienceOverlay => _experienceOverlay;

		public FamiliarOverlayPanel FamiliarOverlay => _familiarOverlay;

		public FamiliarBrowserOverlayPanel FamiliarBrowserOverlay => _familiarBrowserOverlay;

		public DailyQuestOverlayPanel DailyQuestOverlay => _dailyQuestOverlay;

		public ProfessionOverlayPanel ProfessionOverlay => _professionOverlay;

		public ShiftSpellOverlayPanel ShiftSpellOverlay => _shiftSpellOverlay;

		public CombinedOverlayPanel CombinedOverlay => _combinedOverlay;

		public bool AreOverlaysSuppressed => _overlaysSuppressed;

		public void ApplyOverlayLockState()
		{
			bool lockOverlays = Settings.LockOverlays;
			ApplyPinnedTo(_experienceOverlay, lockOverlays);
			ApplyPinnedTo(_familiarOverlay, lockOverlays);
			ApplyPinnedTo(_familiarBrowserOverlay, lockOverlays);
			ApplyPinnedTo(_dailyQuestOverlay, lockOverlays);
			ApplyPinnedTo(_professionOverlay, lockOverlays);
			ApplyPinnedTo(_shiftSpellOverlay, lockOverlays);
			ApplyPinnedTo(_quickActionsOverlay, lockOverlays);
			ApplyPinnedTo(_beelzActionBarOverlay, lockOverlays);
			ApplyPinnedTo(_beelzSummonsOverlay, lockOverlays);
			ApplyPinnedTo(_beelzTransformOverlay, lockOverlays);
			ApplyPinnedTo(_urielSharedOverlay, lockOverlays);
			ApplyPinnedTo(_chatWindowOverlay, lockOverlays);
			ApplyPinnedTo(_secondaryChatOverlay, lockOverlays);
			ApplyPinnedTo(_combinedOverlay, lockOverlays);
		}

		private static void ApplyPinnedTo(ResizeablePanelBase panel, bool pinned)
		{
			if (panel != null)
			{
				panel.IsPinned = pinned;
			}
		}

		public override void Reset()
		{
			base.Reset();
			foreach (IPanelBase panel in _panels)
			{
				if (panel is ResizeablePanelBase resizeablePanelBase)
				{
					resizeablePanelBase.Reset();
				}
				panel.Destroy();
			}
			_panels.Clear();
			_floatingButton = null;
			_mainPanel = null;
			_experienceOverlay = null;
			_familiarOverlay = null;
			_familiarBrowserOverlay = null;
			_dailyQuestOverlay = null;
			_professionOverlay = null;
			_combinedOverlay = null;
			_shiftSpellOverlay = null;
			_quickActionsOverlay = null;
			_beelzActionBarOverlay = null;
			_beelzSummonsOverlay = null;
			_beelzTransformOverlay = null;
			_urielSharedOverlay = null;
		}

		protected override void AddMainContentPanel()
		{
			_floatingButton = new FloatingButtonPanel(base.UiBase);
			_panels.Add(_floatingButton);
		}

		public override void SetActive(bool active)
		{
			_uiActive = active;
			_mainPanel?.SetActive(active && IsMainPanelOpen);
			_experienceOverlay?.SetActive(active && (_experienceOverlay?.Enabled ?? false));
			_familiarOverlay?.SetActive(active && (_familiarOverlay?.Enabled ?? false));
			_familiarBrowserOverlay?.SetActive(active && (_familiarBrowserOverlay?.Enabled ?? false));
			_dailyQuestOverlay?.SetActive(active && (_dailyQuestOverlay?.Enabled ?? false));
			_professionOverlay?.SetActive(active && (_professionOverlay?.Enabled ?? false));
			_shiftSpellOverlay?.SetActive(active && (_shiftSpellOverlay?.Enabled ?? false));
			_quickActionsOverlay?.SetActive(active && (_quickActionsOverlay?.Enabled ?? false));
			_combinedOverlay?.SetActive(active && (_combinedOverlay?.Enabled ?? false));
			_chatWindowOverlay?.SetActive(active && (_chatWindowOverlay?.Enabled ?? false));
			_secondaryChatOverlay?.SetActive(active && (_secondaryChatOverlay?.Enabled ?? false));
			_beelzActionBarOverlay?.SetActive(active && (_beelzActionBarOverlay?.Enabled ?? false));
			_beelzSummonsOverlay?.SetActive(active && (_beelzSummonsOverlay?.Enabled ?? false));
			_beelzTransformOverlay?.SetActive(active && (_beelzTransformOverlay?.Enabled ?? false));
			_urielSharedOverlay?.SetActive(active && (_urielSharedOverlay?.Enabled ?? false));
			RefreshFloatingButtonVisibility();
		}

		public void RequestHideForLogout()
		{
			_hideForLogoutPending = true;
			_loggedOut = true;
		}

		public void TickPendingHide()
		{
			if (!_hideForLogoutPending)
			{
				return;
			}
			_hideForLogoutPending = false;
			try
			{
				SetActive(active: false);
			}
			catch (Exception ex)
			{
				LogUtils.LogDebug("Logout UI hide failed: " + ex.Message);
			}
		}

		public void RestoreAfterRelogIfNeeded()
		{
			if (_loggedOut)
			{
				_loggedOut = false;
				_hideForLogoutPending = false;
				_uiActive = true;
				RefreshFloatingButtonVisibility();
				try
				{
					_mainPanel?.RefreshTabGroupAvailabilityNow();
				}
				catch
				{
				}
				try
				{
					ApplyAvailabilityToOverlays();
				}
				catch
				{
				}
				try
				{
					_chatWindowOverlay?.ResetForServerSwitch();
				}
				catch
				{
				}
				ScheduleOverlayRestore();
			}
		}

		public void ToggleMainPanel()
		{
			EnsureMainPanel();
			bool flag = !_mainPanel.Enabled;
			LogUtils.LogDiagnostic($"ToggleMainPanel: {_mainPanel.Enabled} -> {flag}");
			_mainPanel.SetActive(flag);
			RefreshFloatingButtonVisibility();
		}

		internal void OnMainPanelFullscreenChanged(bool fullscreen)
		{
			RefreshFloatingButtonVisibility();
		}

		internal void RefreshFloatingButtonVisibility()
		{
			MainPanel mainPanel = _mainPanel;
			bool flag = mainPanel != null && mainPanel.Enabled && (_mainPanel?.IsFullscreen ?? false);
			_floatingButton?.SetActive(_uiActive && !flag);
		}

		public void ShowTab(PanelType tab)
		{
			EnsureMainPanel();
			_mainPanel.SetActive(active: true);
			_mainPanel.ShowTab(tab);
			RefreshFloatingButtonVisibility();
		}

		public void ToggleOverlay(PanelType overlay)
		{
			LogUtils.LogDiagnostic($"ToggleOverlay({overlay}).");
			switch (overlay)
			{
			case PanelType.ExperienceOverlay:
				EnsureExperienceOverlay();
				_experienceOverlay.SetActive(!_experienceOverlay.Enabled);
				Settings.SetShowExperienceOverlay(_experienceOverlay.Enabled);
				break;
			case PanelType.FamiliarOverlay:
				EnsureFamiliarOverlay();
				_familiarOverlay.SetActive(!_familiarOverlay.Enabled);
				Settings.SetShowFamiliarOverlay(_familiarOverlay.Enabled);
				break;
			case PanelType.FamiliarBrowserOverlay:
				EnsureFamiliarBrowserOverlay();
				_familiarBrowserOverlay.SetActive(!_familiarBrowserOverlay.Enabled);
				Settings.SetShowFamiliarBrowser(_familiarBrowserOverlay.Enabled);
				break;
			case PanelType.DailyQuestOverlay:
				EnsureDailyQuestOverlay();
				_dailyQuestOverlay.SetActive(!_dailyQuestOverlay.Enabled);
				Settings.SetShowDailyQuestOverlay(_dailyQuestOverlay.Enabled);
				break;
			case PanelType.ProfessionOverlay:
				EnsureProfessionOverlay();
				_professionOverlay.SetActive(!_professionOverlay.Enabled);
				Settings.SetShowProfessionOverlay(_professionOverlay.Enabled);
				break;
			case PanelType.ShiftSpellOverlay:
				EnsureShiftSpellOverlay();
				_shiftSpellOverlay.SetActive(!_shiftSpellOverlay.Enabled);
				Settings.SetShowShiftSpellOverlay(_shiftSpellOverlay.Enabled);
				break;
			case PanelType.QuickActionsOverlay:
				EnsureQuickActionsOverlay();
				_quickActionsOverlay.SetActive(!_quickActionsOverlay.Enabled);
				Settings.SetShowQuickActionsOverlay(_quickActionsOverlay.Enabled);
				break;
			case PanelType.BeelzActionBarOverlay:
				EnsureBeelzActionBarOverlay();
				_beelzActionBarOverlay.SetActive(!_beelzActionBarOverlay.Enabled);
				Settings.SetShowBeelzActionBarOverlay(_beelzActionBarOverlay.Enabled);
				break;
			case PanelType.BeelzSummonsOverlay:
				EnsureBeelzSummonsOverlay();
				_beelzSummonsOverlay.SetActive(!_beelzSummonsOverlay.Enabled);
				Settings.SetShowBeelzSummonsOverlay(_beelzSummonsOverlay.Enabled);
				break;
			case PanelType.BeelzTransformOverlay:
				EnsureBeelzTransformOverlay();
				_beelzTransformOverlay.SetActive(!_beelzTransformOverlay.Enabled);
				Settings.SetShowBeelzTransformOverlay(_beelzTransformOverlay.Enabled);
				break;
			case PanelType.UrielSharedOverlay:
				EnsureUrielSharedOverlay();
				_urielSharedOverlay.SetActive(!_urielSharedOverlay.Enabled);
				Settings.SetShowUrielSharedOverlay(_urielSharedOverlay.Enabled);
				break;
			case PanelType.ChatWindowOverlay:
				EnsureChatWindowOverlay();
				_chatWindowOverlay.SetActive(!_chatWindowOverlay.Enabled);
				Settings.SetShowChatWindowOverlay(_chatWindowOverlay.Enabled);
				ApplyNativeChatVisibility();
				break;
			case PanelType.SecondaryChatOverlay:
				EnsureSecondaryChatOverlay();
				_secondaryChatOverlay.SetActive(!_secondaryChatOverlay.Enabled);
				Settings.SetShowSecondaryChatOverlay(_secondaryChatOverlay.Enabled);
				break;
			case PanelType.CombinedOverlay:
				Settings.SetShowCombinedOverlay(!(_combinedOverlay?.Enabled ?? false));
				ApplyCombinedOverlayMutualExclusion();
				break;
			default:
				throw new ArgumentOutOfRangeException("overlay", overlay, "Not a secondary overlay.");
			}
		}

		public void ApplyCombinedOverlayMutualExclusion()
		{
			if (Settings.ShowCombinedOverlay)
			{
				EnsureCombinedOverlay();
				_combinedOverlay.SetActive(active: true);
				EnsureExperienceOverlay();
				_experienceOverlay.SetActive(active: false);
				_familiarOverlay?.SetActive(active: false);
				_dailyQuestOverlay?.SetActive(active: false);
				_professionOverlay?.SetActive(active: false);
				return;
			}
			_combinedOverlay?.SetActive(active: false);
			if (Settings.ShowExperienceOverlay)
			{
				EnsureExperienceOverlay();
				_experienceOverlay.SetActive(active: true);
			}
			if (Settings.ShowFamiliarOverlay)
			{
				EnsureFamiliarOverlay();
				_familiarOverlay.SetActive(active: true);
			}
			if (Settings.ShowDailyQuestOverlay)
			{
				EnsureDailyQuestOverlay();
				_dailyQuestOverlay.SetActive(active: true);
			}
			if (Settings.ShowProfessionOverlay)
			{
				EnsureProfessionOverlay();
				_professionOverlay.SetActive(active: true);
			}
		}

		public void RefreshCombinedOverlaySections()
		{
			_combinedOverlay?.RefreshSections();
		}

		public void ToggleAllOverlaysSuppressed()
		{
			_overlaysSuppressed = !_overlaysSuppressed;
			Settings.OverlaysSuppressedByUser = _overlaysSuppressed;
			ApplyOverlaySuppression();
		}

		private void ApplyOverlaySuppression()
		{
			bool flag = !EclipseProtocolService.StandDownForEclipse() && EclipseProtocolService.UserRegistered;
			bool isPresent = BeelzProtocolService.IsPresent;
			bool isPresent2 = UrielProtocolService.IsPresent;
			if (_overlaysSuppressed)
			{
				_experienceOverlay?.SetActive(active: false);
				_familiarOverlay?.SetActive(active: false);
				_familiarBrowserOverlay?.SetActive(active: false);
				_dailyQuestOverlay?.SetActive(active: false);
				_professionOverlay?.SetActive(active: false);
				_shiftSpellOverlay?.SetActive(active: false);
				_quickActionsOverlay?.SetActive(active: false);
				_combinedOverlay?.SetActive(active: false);
				_beelzActionBarOverlay?.SetActive(active: false);
				_beelzSummonsOverlay?.SetActive(active: false);
				_beelzTransformOverlay?.SetActive(active: false);
				_urielSharedOverlay?.SetActive(active: false);
				if (Settings.HideChatWithOverlaysToggle)
				{
					_chatWindowOverlay?.SetActive(active: false);
					ApplyNativeChatVisibility();
				}
				return;
			}
			if (flag && Settings.ShowExperienceOverlay)
			{
				EnsureExperienceOverlay();
				_experienceOverlay.SetActive(active: true);
			}
			if (flag && Settings.ShowFamiliarOverlay)
			{
				EnsureFamiliarOverlay();
				_familiarOverlay.SetActive(active: true);
			}
			if (Settings.ShowFamiliarBrowser)
			{
				EnsureFamiliarBrowserOverlay();
				_familiarBrowserOverlay.SetActive(active: true);
			}
			if (flag && Settings.ShowDailyQuestOverlay)
			{
				EnsureDailyQuestOverlay();
				_dailyQuestOverlay.SetActive(active: true);
			}
			if (flag && Settings.ShowProfessionOverlay)
			{
				EnsureProfessionOverlay();
				_professionOverlay.SetActive(active: true);
			}
			if (Settings.ShowShiftSpellOverlay)
			{
				EnsureShiftSpellOverlay();
				_shiftSpellOverlay.SetActive(active: true);
			}
			if (Settings.ShowQuickActionsOverlay)
			{
				EnsureQuickActionsOverlay();
				_quickActionsOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzActionBarOverlay)
			{
				EnsureBeelzActionBarOverlay();
				_beelzActionBarOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzSummonsOverlay)
			{
				EnsureBeelzSummonsOverlay();
				_beelzSummonsOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzTransformOverlay)
			{
				EnsureBeelzTransformOverlay();
				_beelzTransformOverlay.SetActive(active: true);
			}
			if (isPresent2 && Settings.ShowUrielSharedOverlay)
			{
				EnsureUrielSharedOverlay();
				_urielSharedOverlay.SetActive(active: true);
			}
			if (Settings.ShowChatWindowOverlay)
			{
				EnsureChatWindowOverlay();
				_chatWindowOverlay.SetActive(active: true);
			}
			if (Settings.ShowSecondaryChatOverlay)
			{
				EnsureSecondaryChatOverlay();
				_secondaryChatOverlay.SetActive(active: true);
			}
			ApplyNativeChatVisibility();
		}

		public void ScheduleOverlayRestore()
		{
			int uiBuildDelaySeconds = Settings.UiBuildDelaySeconds;
			if (uiBuildDelaySeconds <= 0)
			{
				DoDeferredBringUp();
				return;
			}
			_restoreFireAt = Time.realtimeSinceStartupAsDouble + (double)uiBuildDelaySeconds;
			_restoreArmed = true;
			LogUtils.LogDiagnostic($"Overlay restore deferred {uiBuildDelaySeconds}s past login.");
		}

		public void TickDeferredRestore()
		{
			if (_restoreArmed && !(Time.realtimeSinceStartupAsDouble < _restoreFireAt))
			{
				_restoreArmed = false;
				DoDeferredBringUp();
			}
		}

		private void DoDeferredBringUp()
		{
			try
			{
				RestoreOverlaysFromSettings();
			}
			catch (Exception value)
			{
				LogUtils.LogError($"Deferred overlay restore failed: {value}");
			}
			try
			{
				VBloodScannerService.Initialize();
			}
			catch (Exception value2)
			{
				LogUtils.LogError($"Deferred V-Blood scanner init failed: {value2}");
			}
		}

		public void RestoreOverlaysFromSettings()
		{
			bool flag = !EclipseProtocolService.StandDownForEclipse() && EclipseProtocolService.UserRegistered;
			bool isPresent = BeelzProtocolService.IsPresent;
			bool isPresent2 = UrielProtocolService.IsPresent;
			if (flag)
			{
				if (Settings.ShowCombinedOverlay)
				{
					ApplyCombinedOverlayMutualExclusion();
				}
				else
				{
					if (Settings.ShowExperienceOverlay)
					{
						EnsureExperienceOverlay();
						_experienceOverlay.SetActive(active: true);
					}
					if (Settings.ShowFamiliarOverlay)
					{
						EnsureFamiliarOverlay();
						_familiarOverlay.SetActive(active: true);
					}
					if (Settings.ShowDailyQuestOverlay)
					{
						EnsureDailyQuestOverlay();
						_dailyQuestOverlay.SetActive(active: true);
					}
					if (Settings.ShowProfessionOverlay)
					{
						EnsureProfessionOverlay();
						_professionOverlay.SetActive(active: true);
					}
				}
			}
			if (Settings.ShowShiftSpellOverlay)
			{
				EnsureShiftSpellOverlay();
				_shiftSpellOverlay.SetActive(active: true);
			}
			if (Settings.ShowFamiliarBrowser)
			{
				EnsureFamiliarBrowserOverlay();
				_familiarBrowserOverlay.SetActive(active: true);
			}
			if (Settings.ShowQuickActionsOverlay)
			{
				EnsureQuickActionsOverlay();
				_quickActionsOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzActionBarOverlay)
			{
				EnsureBeelzActionBarOverlay();
				_beelzActionBarOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzSummonsOverlay)
			{
				EnsureBeelzSummonsOverlay();
				_beelzSummonsOverlay.SetActive(active: true);
			}
			if (isPresent && Settings.ShowBeelzTransformOverlay)
			{
				EnsureBeelzTransformOverlay();
				_beelzTransformOverlay.SetActive(active: true);
			}
			if (isPresent2 && Settings.ShowUrielSharedOverlay)
			{
				EnsureUrielSharedOverlay();
				_urielSharedOverlay.SetActive(active: true);
			}
			if (Settings.ShowChatWindowOverlay)
			{
				EnsureChatWindowOverlay();
				_chatWindowOverlay.SetActive(active: true);
			}
			if (Settings.ShowSecondaryChatOverlay)
			{
				EnsureSecondaryChatOverlay();
				_secondaryChatOverlay.SetActive(active: true);
			}
			ApplyNativeChatVisibility();
			if (Settings.ShowCombinedOverlay && flag)
			{
				ApplyCombinedOverlayMutualExclusion();
			}
		}

		internal void TickOverlayAvailability()
		{
			if (!_uiActive)
			{
				return;
			}
			try
			{
				bool flag = !EclipseProtocolService.StandDownForEclipse() && EclipseProtocolService.UserRegistered;
				bool isPresent = BeelzProtocolService.IsPresent;
				if (!_availabilityTrackInit || flag != _lastBcAvailable || isPresent != _lastBeelzAvailable)
				{
					_availabilityTrackInit = true;
					_lastBcAvailable = flag;
					_lastBeelzAvailable = isPresent;
					ApplyAvailabilityToOverlays();
				}
			}
			catch (Exception ex)
			{
				LogUtils.LogDebug("TickOverlayAvailability: " + ex.Message);
			}
		}

		public void ApplyAvailabilityToOverlays()
		{
			try
			{
				bool num = !EclipseProtocolService.StandDownForEclipse() && EclipseProtocolService.UserRegistered;
				bool isPresent = BeelzProtocolService.IsPresent;
				bool isPresent2 = UrielProtocolService.IsPresent;
				if (!num)
				{
					_combinedOverlay?.SetActive(active: false);
					_experienceOverlay?.SetActive(active: false);
					_familiarOverlay?.SetActive(active: false);
					_dailyQuestOverlay?.SetActive(active: false);
					_professionOverlay?.SetActive(active: false);
				}
				else if (!_overlaysSuppressed)
				{
					if (Settings.ShowCombinedOverlay)
					{
						EnsureCombinedOverlay();
						ApplyCombinedOverlayMutualExclusion();
					}
					else
					{
						if (Settings.ShowExperienceOverlay)
						{
							EnsureExperienceOverlay();
							_experienceOverlay.SetActive(active: true);
						}
						if (Settings.ShowFamiliarOverlay)
						{
							EnsureFamiliarOverlay();
							_familiarOverlay.SetActive(active: true);
						}
						if (Settings.ShowDailyQuestOverlay)
						{
							EnsureDailyQuestOverlay();
							_dailyQuestOverlay.SetActive(active: true);
						}
						if (Settings.ShowProfessionOverlay)
						{
							EnsureProfessionOverlay();
							_professionOverlay.SetActive(active: true);
						}
					}
				}
				if (_shiftSpellOverlay != null && !_overlaysSuppressed && Settings.ShowShiftSpellOverlay)
				{
					_shiftSpellOverlay.SetActive(active: true);
				}
				if (!isPresent)
				{
					_beelzActionBarOverlay?.SetActive(active: false);
				}
				else if (!_overlaysSuppressed && Settings.ShowBeelzActionBarOverlay)
				{
					EnsureBeelzActionBarOverlay();
					_beelzActionBarOverlay.SetActive(active: true);
				}
				if (!isPresent)
				{
					_beelzSummonsOverlay?.SetActive(active: false);
				}
				else if (!_overlaysSuppressed && Settings.ShowBeelzSummonsOverlay)
				{
					EnsureBeelzSummonsOverlay();
					_beelzSummonsOverlay.SetActive(active: true);
				}
				if (!isPresent)
				{
					_beelzTransformOverlay?.SetActive(active: false);
				}
				else if (!_overlaysSuppressed && Settings.ShowBeelzTransformOverlay)
				{
					EnsureBeelzTransformOverlay();
					_beelzTransformOverlay.SetActive(active: true);
				}
				if (!isPresent2)
				{
					_urielSharedOverlay?.SetActive(active: false);
				}
				else if (!_overlaysSuppressed && Settings.ShowUrielSharedOverlay)
				{
					EnsureUrielSharedOverlay();
					_urielSharedOverlay.SetActive(active: true);
				}
				_mainPanel?.RefreshAllOverlayToggleStates();
			}
			catch (Exception value)
			{
				LogUtils.LogError($"ApplyAvailabilityToOverlays failed: {value}");
			}
		}

		public bool IsOverlayOpen(PanelType overlay)
		{
			return overlay switch
			{
				PanelType.ExperienceOverlay => _experienceOverlay?.Enabled ?? false, 
				PanelType.FamiliarOverlay => _familiarOverlay?.Enabled ?? false, 
				PanelType.FamiliarBrowserOverlay => _familiarBrowserOverlay?.Enabled ?? false, 
				PanelType.DailyQuestOverlay => _dailyQuestOverlay?.Enabled ?? false, 
				PanelType.ProfessionOverlay => _professionOverlay?.Enabled ?? false, 
				PanelType.ShiftSpellOverlay => _shiftSpellOverlay?.Enabled ?? false, 
				PanelType.QuickActionsOverlay => _quickActionsOverlay?.Enabled ?? false, 
				PanelType.BeelzActionBarOverlay => _beelzActionBarOverlay?.Enabled ?? false, 
				PanelType.BeelzSummonsOverlay => _beelzSummonsOverlay?.Enabled ?? false, 
				PanelType.BeelzTransformOverlay => _beelzTransformOverlay?.Enabled ?? false, 
				PanelType.UrielSharedOverlay => _urielSharedOverlay?.Enabled ?? false, 
				PanelType.ChatWindowOverlay => _chatWindowOverlay?.Enabled ?? false, 
				PanelType.SecondaryChatOverlay => _secondaryChatOverlay?.Enabled ?? false, 
				PanelType.CombinedOverlay => _combinedOverlay?.Enabled ?? false, 
				_ => false, 
			};
		}

		private void EnsureMainPanel()
		{
			if (_mainPanel == null)
			{
				_mainPanel = new MainPanel(base.UiBase);
				_panels.Add(_mainPanel);
				_mainPanel.SetActive(active: false);
			}
		}

		private void EnsureExperienceOverlay()
		{
			if (_experienceOverlay == null)
			{
				_experienceOverlay = new ExperienceOverlayPanel(base.UiBase);
				_panels.Add(_experienceOverlay);
				_experienceOverlay.SetActive(active: false);
			}
		}

		private void EnsureFamiliarBrowserOverlay()
		{
			if (_familiarBrowserOverlay == null)
			{
				_familiarBrowserOverlay = new FamiliarBrowserOverlayPanel(base.UiBase);
				_panels.Add(_familiarBrowserOverlay);
				_familiarBrowserOverlay.SetActive(active: false);
			}
		}

		private void EnsureDailyQuestOverlay()
		{
			if (_dailyQuestOverlay == null)
			{
				_dailyQuestOverlay = new DailyQuestOverlayPanel(base.UiBase);
				_panels.Add(_dailyQuestOverlay);
				_dailyQuestOverlay.SetActive(active: false);
			}
		}

		private void EnsureFamiliarOverlay()
		{
			if (_familiarOverlay == null)
			{
				_familiarOverlay = new FamiliarOverlayPanel(base.UiBase);
				_panels.Add(_familiarOverlay);
				_familiarOverlay.SetActive(active: false);
			}
		}

		private void EnsureProfessionOverlay()
		{
			if (_professionOverlay == null)
			{
				_professionOverlay = new ProfessionOverlayPanel(base.UiBase);
				_panels.Add(_professionOverlay);
				_professionOverlay.SetActive(active: false);
			}
		}

		private void EnsureShiftSpellOverlay()
		{
			if (_shiftSpellOverlay == null)
			{
				_shiftSpellOverlay = new ShiftSpellOverlayPanel(base.UiBase);
				_panels.Add(_shiftSpellOverlay);
				_shiftSpellOverlay.SetActive(active: false);
			}
		}

		private void EnsureQuickActionsOverlay()
		{
			if (_quickActionsOverlay == null)
			{
				_quickActionsOverlay = new QuickActionsOverlayPanel(base.UiBase);
				_panels.Add(_quickActionsOverlay);
				_quickActionsOverlay.SetActive(active: false);
			}
		}

		private void EnsureBeelzActionBarOverlay()
		{
			if (_beelzActionBarOverlay == null)
			{
				_beelzActionBarOverlay = new BeelzActionBarOverlayPanel(base.UiBase);
				_panels.Add(_beelzActionBarOverlay);
				_beelzActionBarOverlay.SetActive(active: false);
			}
		}

		private void EnsureBeelzSummonsOverlay()
		{
			if (_beelzSummonsOverlay == null)
			{
				_beelzSummonsOverlay = new BeelzSummonsOverlayPanel(base.UiBase);
				_panels.Add(_beelzSummonsOverlay);
				_beelzSummonsOverlay.SetActive(active: false);
			}
		}

		private void EnsureUrielSharedOverlay()
		{
			if (_urielSharedOverlay == null)
			{
				_urielSharedOverlay = new UrielSharedOverlayPanel(base.UiBase);
				_panels.Add(_urielSharedOverlay);
				_urielSharedOverlay.SetActive(active: false);
			}
		}

		private void EnsureBeelzTransformOverlay()
		{
			if (_beelzTransformOverlay == null)
			{
				_beelzTransformOverlay = new BeelzTransformOverlayPanel(base.UiBase);
				_panels.Add(_beelzTransformOverlay);
				_beelzTransformOverlay.SetActive(active: false);
			}
		}

		private void EnsureChatWindowOverlay()
		{
			if (_chatWindowOverlay == null)
			{
				_chatWindowOverlay = new ChatWindowOverlayPanel(base.UiBase);
				_panels.Add(_chatWindowOverlay);
				_chatWindowOverlay.SetActive(active: false);
			}
		}

		public void RefreshChatWindowOverlay()
		{
			_chatWindowOverlay?.Refresh();
		}

		private void EnsureSecondaryChatOverlay()
		{
			if (_secondaryChatOverlay == null)
			{
				_secondaryChatOverlay = new SecondaryChatOverlayPanel(base.UiBase);
				_panels.Add(_secondaryChatOverlay);
				_secondaryChatOverlay.SetActive(active: false);
			}
		}

		public void RefreshSecondaryChatOverlay()
		{
			_secondaryChatOverlay?.Refresh();
		}

		public bool IsNativeChatHideActive()
		{
			ChatWindowOverlayPanel chatWindowOverlay = _chatWindowOverlay;
			if (chatWindowOverlay != null && chatWindowOverlay.Enabled)
			{
				return Settings.HideNativeChat;
			}
			return false;
		}

		public void FocusChatInput()
		{
			_chatWindowOverlay?.FocusInput();
		}

		public void ReleaseChatInput()
		{
			_chatWindowOverlay?.ReleaseInput();
		}

		public bool IsNativeChatFocused()
		{
			try
			{
				return (Object)(object)_nativeChat != (Object)null && _nativeChat.IsChatFocused;
			}
			catch
			{
				return false;
			}
		}

		public bool IsChatInputFocused()
		{
			ChatWindowOverlayPanel chatWindowOverlay = _chatWindowOverlay;
			if (chatWindowOverlay != null && chatWindowOverlay.Enabled)
			{
				return _chatWindowOverlay?.IsInputFocused() ?? false;
			}
			return false;
		}

		public bool IsPointerOverChatWindow()
		{
			try
			{
				return _chatWindowOverlay?.IsPointerOverWindow() ?? false;
			}
			catch
			{
				return false;
			}
		}

		public bool IsPointerOverMainPanel()
		{
			//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)
			try
			{
				MainPanel mainPanel = _mainPanel;
				if (mainPanel == null || !mainPanel.Enabled || (Object)(object)mainPanel.Rect == (Object)null)
				{
					return false;
				}
				return RectTransformUtility.RectangleContainsScreenPoint(mainPanel.Rect, Vector2.op_Implicit(Input.mousePosition), (Camera)null);
			}
			catch
			{
				return false;
			}
		}

		public bool IsPointerOverAnyUI()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector3 mousePosition = Input.mousePosition;
				foreach (IPanelBase panel in _panels)
				{
					if (panel != null && panel.Enabled && !((Object)(object)panel.Rect == (Object)null) && RectTransformUtility.RectangleContainsScreenPoint(panel.Rect, Vector2.op_Implicit(mousePosition), (Camera)null))
					{
						return true;
					}
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		public bool BeginExternalWhisper(NetworkId id, string name)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EnsureChatWindowOverlay();
				if (_chatWindowOverlay == null)
				{
					return false;
				}
				if (!_chatWindowOverlay.Enabled)
				{
					_chatWindowOverlay.SetActive(active: true);
					Settings.SetShowChatWindowOverlay(v: true);
				}
				_chatWindowOverlay.BeginWhisperTo(name, id);
				_chatWindowOverlay.FocusInput();
				return true;
			}
			catch (Exception ex)
			{
				LogUtils.LogWarning("BeginExternalWhisper: " + ex.Message);
				return false;
			}
		}

		public void ApplyNativeChatVisibility()
		{
			try
			{
				bool flag = IsNativeChatHideActive();
				if (!flag && !_nativeHidden)
				{
					return;
				}
				if ((Object)(object)_nativeChat == (Object)null)
				{
					_nativeChat = Object.FindObjectOfType<HUDChatWindow>();
				}
				if (!((Object)(object)_nativeChat == (Object)null))
				{
					CanvasGroup contentCanvasGroup = _nativeChat.ContentCanvasGroup;
					if ((Object)(object)contentCanvasGroup != (Object)null)
					{
						contentCanvasGroup.alpha = (flag ? 0f : 1f);
						contentCanvasGroup.blocksRaycasts = !flag;
					}
					if (flag && _nativeChat.IsChatFocused)
					{
						_nativeChat.SetFocused(false);
					}
					_nativeHidden = flag;
				}
			}
			catch (Exception ex)
			{
				LogUtils.LogDebug("ApplyNativeChatVisibility: " + ex.Message);
			}
		}

		internal void TickNativeChatGuard()
		{
			try
			{
				if (IsNativeChatHideActive())
				{
					if ((Object)(object)_nativeChat == (Object)null)
					{
						_nativeChat = Object.FindObjectOfType<HUDChatWindow>();
					}
					if ((Object)(object)_nativeChat != (Object)null && _nativeChat.IsChatFocused)
					{
						_nativeChat.SetFocused(false);
					}
				}
			}
			catch
			{
			}
		}

		private void EnsureCombinedOverlay()
		{
			if (_combinedOverlay == null)
			{
				_combinedOverlay = new CombinedOverlayPanel(base.UiBase);
				_panels.Add(_combinedOverlay);
				_combinedOverlay.SetActive(active: false);
			}
		}

		public void RefreshAllOpacities()
		{
			_experienceOverlay?.RefreshOpacity();
			_familiarOverlay?.RefreshOpacity();
			_familiarBrowserOverlay?.RefreshOpacity();
			_dailyQuestOverlay?.RefreshOpacity();
			_professionOverlay?.RefreshOpacity();
			_shiftSpellOverlay?.RefreshOpacity();
			_quickActionsOverlay?.RefreshOpacity();
			_beelzActionBarOverlay?.RefreshOpacity();
			_beelzSummonsOverlay?.RefreshOpacity();
			_beelzTransformOverlay?.RefreshOpacity();
			_urielSharedOverlay?.RefreshOpacity();
			_chatWindowOverlay?.RefreshOpacity();
			_secondaryChatOverlay?.RefreshOpacity();
			_combinedOverlay?.RefreshOpacity();
			_mainPanel?.RefreshOpacity();
			_floatingButton?.RefreshOpacity();
		}

		public void RefreshChatWindowBackground()
		{
			_chatWindowOverlay?.RefreshBackgroundColor();
		}

		public void RefreshAllPanelBackgrounds()
		{
			_mainPanel?.RefreshBackgroundColor();
			_experienceOverlay?.RefreshBackgroundColor();
			_familiarOverlay?.RefreshBackgroundColor();
			_familiarBrowserOverlay?.RefreshBackgroundColor();
			_dailyQuestOverlay?.RefreshBackgroundColor();
			_professionOverlay?.RefreshBackgroundColor();
			_shiftSpellOverlay?.RefreshBackgroundColor();
			_quickActionsOverlay?.RefreshBackgroundColor();
			_beelzActionBarOverlay?.RefreshBackgroundColor();
			_beelzSummonsOverlay?.RefreshBackgroundColor();
			_beelzTransformOverlay?.RefreshBackgroundColor();
			_urielSharedOverlay?.RefreshBackgroundColor();
			_chatWindowOverlay?.RefreshBackgroundColor();
			_secondaryChatOverlay?.RefreshBackgroundColor();
			_combinedOverlay?.RefreshBackgroundColor();
		}

		public void RefreshAllButtonColors()
		{
			UIFactory.ApplyThemedButtonColor();
		}

		public void RefreshFloatingButtonScale()
		{
			_floatingButton?.RefreshScale();
		}

		public void RefreshScopedInnerBackgrounds()
		{
			_mainPanel?.RefreshInnerBackgroundColor();
			_familiarBrowserOverlay?.RefreshInnerBackgroundColor();
		}

		public void RefreshProfessionOverlay()
		{
			_professionOverlay?.Refresh();
		}

		public void ApplyServerFeatureFlagsToOverlays()
		{
		}

		public static bool IsSystemAvailable(PlayerStateService.SystemKind kind)
		{
			return true;
		}

		public void RequestRebuildMainPanel()
		{
			if (_mainPanel != null)
			{
				CoreUpdateBehavior.Actions.Add(delegate
				{
					CoreUpdateBehavior.Actions.Remove(_deferredMainPanelRebuild);
					_deferredMainPanelRebuild = null;
					RebuildMainPanelNow();
				});
			}
		}

		private void RebuildMainPanelNow()
		{
			if (_mainPanel != null)
			{
				bool enabled = _mainPanel.Enabled;
				PanelType activeTab = _mainPanel.ActiveTab;
				_mainPanel?.Reset();
				_mainPanel.Destroy();
				_panels.Remove(_mainPanel);
				_mainPanel = null;
				if (enabled)
				{
					EnsureMainPanel();
					_mainPanel.SetActive(active: true);
					_mainPanel.ShowTab(activeTab);
				}
			}
		}

		public void RequestRebuildAllOverlays()
		{
			CoreUpdateBehavior.Actions.Add(delegate
			{
				CoreUpdateBehavior.Actions.Remove(_deferredOverlayRebuild);
				_deferredOverlayRebuild = null;
				RebuildAllOverlaysNow();
			});
		}

		private void RebuildAllOverlaysNow()
		{
			bool showCombinedOverlay = Settings.ShowCombinedOverlay;
			RebuildOverlay(ref _experienceOverlay, !showCombinedOverlay && Settings.ShowExperienceOverlay, (UIBase b) => new ExperienceOverlayPanel(b));
			RebuildOverlay(ref _familiarOverlay, !showCombinedOverlay && Settings.ShowFamiliarOverlay, (UIBase b) => new FamiliarOverlayPanel(b));
			RebuildOverlay(ref _familiarBrowserOverlay, Settings.ShowFamiliarBrowser, (UIBase b) => new FamiliarBrowserOverlayPanel(b));
			RebuildOverlay(ref _dailyQuestOverlay, !showCombinedOverlay && Settings.ShowDailyQuestOverlay, (UIBase b) => new DailyQuestOverlayPanel(b));
			RebuildOverlay(ref _professionOverlay, !showCombinedOverlay && Settings.ShowProfessionOverlay, (UIBase b) => new ProfessionOverlayPanel(b));
			RebuildOverlay(ref _shiftSpellOverlay, Settings.ShowShiftSpellOverlay, (UIBase b) => new ShiftSpellOverlayPanel(b));
			RebuildOverlay(ref _quickActionsOverlay, Settings.ShowQuickActionsOverlay, (UIBase b) => new QuickActionsOverlayPanel(b));
			RebuildOverlay(ref _beelzActionBarOverlay, Settings.ShowBeelzActionBarOverlay, (UIBase b) => new BeelzActionBarOverlayPanel(b));
			RebuildOverlay(ref _beelzSummonsOverlay, Settings.ShowBeelzSummonsOverlay, (UIBase b) => new BeelzSummonsOverlayPanel(b));
			RebuildOverlay(ref _beelzTransformOverlay, Settings.ShowBeelzTransformOverlay, (UIBase b) => new BeelzTransformOverlayPanel(b));
			RebuildOverlay(ref _urielSharedOverlay, Settings.ShowUrielSharedOverlay, (UIBase b) => new UrielSharedOverlayPanel(b));
			RebuildOverlay(ref _chatWindowOverlay, Settings.ShowChatWindowOverlay, (UIBase b) => new ChatWindowOverlayPanel(b));
			RebuildOverlay(ref _secondaryChatOverlay, Settings.ShowSecondaryChatOverlay, (UIBase b) => new SecondaryChatOverlayPanel(b));
			RebuildOverlay(ref _combinedOverlay, showCombinedOverlay, (UIBase b) => new CombinedOverlayPanel(b));
			_mainPanel?.RefreshAllOverlayToggleStates();
		}

		private void RebuildOverlay<T>(ref T slot, bool wasVisibleByConfig, Func<UIBase, T> factory) where T : ResizeablePanelBase
		{
			if (slot != null)
			{
				slot.Reset();
				slot.Destroy();
				_panels.Remove(slot);
				slot = null;
				if (wasVisibleByConfig)
				{
					T val = factory(base.UiBase);
					_panels.Add(val);
					val.SetActive(active: true);
					slot = val;
				}
			}
		}
	}
	public static class TooltipHover
	{
		private struct Binding
		{
			public RectTransform Rt;

			public string Text;

			public Func<string> TextFunc;

			public Camera Cam;

			public bool CamResolved;
		}

		private static readonly List<Binding> _bindings = new List<Binding>();

		public static TextMeshProUGUI Sink;

		public static string IdlePlaceholder = "Hint: hover any control for help.";

		private static bool _firstHitLogged;

		private const float TickIntervalSeconds = 1f / 30f;

		private static float _lastTickAt;

		public static int BindingCount => _bindings.Count;

		public static void Attach(GameObject target, string text)
		{
			if (!((Object)(object)target == (Object)null) && !string.IsNullOrEmpty(text))
			{
				RectTransform component = target.GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					_bindings.Add(new Binding
					{
						Rt = component,
						Text = text
					});
				}
			}
		}

		public static void Attach(GameObject target, Func<string> textFunc)
		{
			if (!((Object)(object)target == (Object)null) && textFunc != null)
			{
				RectTransform component = target.GetComponent<RectTransform>();
				if (!((Object)(object)component == (Object)null))
				{
					_bindings.Add(new Binding
					{
						Rt = component,
						TextFunc = textFunc
					});
				}
			}
		}

		public static void TickAll()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Sink == (Object)null)
			{
				return;
			}
			BCHubUIManager uIManager = Plugin.UIManager;
			if (uIManager == null || !uIManager.IsMainPanelOpen)
			{
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup - _lastTickAt < 1f / 30f)
			{
				return;
			}
			_lastTickAt = realtimeSinceStartup;
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			string text = null;
			for (int num = _bindings.Count - 1; num >= 0; num--)
			{
				Binding value = _bindings[num];
				if ((Object)(object)value.Rt == (Object)null)
				{
					_bindings.RemoveAt(num);
				}
				else if (((Component)value.Rt).gameObject.activeInHierarchy)
				{
					if (!value.CamResolved)
					{
						Canvas componentInParent = ((Component)value.Rt).GetComponentInParent<Canvas>();
						value.Cam = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
						value.CamResolved = true;
						_bindings[num] = value;
					}
					if (RectTransformUtility.RectangleContainsScreenPoint(value.Rt, val, value.Cam))
					{
						if (value.TextFunc != null)
						{
							try
							{
								text = value.TextFunc();
							}
							catch
							{
								text = null;
							}
						}
						if (text == null)
						{
							text = value.Text;
						}
						break;
					}
				}
			}
			string text2 = text ?? IdlePlaceholder;
			if (((TMP_Text)Sink).text != text2)
			{
				((TMP_Text)Sink).text = text2;
			}
			if (text == null || _firstHitLogged)
			{
				return;
			}
			_firstHitLogged = true;
			try
			{
				LogUtils.LogInfo($"TooltipHover: first hover registered ({_bindings.Count} bindings tracked).");
			}
			catch
			{
			}
		}
	}
}
namespace BloodCraftHub.UI.ModContent
{
	public class BeelzActionBarOverlayPanel : ResizeablePanelBase
	{
		private sealed class Tile
		{
			public string HotkeyName;

			public string AbilityGuid;

			public Image Bg;

			public Image Icon;

			public TextMeshProUGUI Name;

			public Image Radial;

			public TextMeshProUGUI Countdown;

			public int IconHash;

			public bool IconResolved;

			public int IconTries;

			public float CooldownEnd;

			public float CooldownTotal;
		}

		private const float DEFAULT_COOLDOWN_SECONDS = 8f;

		private static readonly Color TILE_READY = new Color(0.3f, 0.18f, 0.36f, 0.95f);

		private static readonly Color TILE_BUSY = new Color(0.16f, 0.12f, 0.2f, 0.95f);

		private static readonly Color TILE_SLOT_BG = new Color(0.08f, 0.07f, 0.11f, 0.96f);

		private static readonly Color RADIAL = new Color(0.04f, 0.04f, 0.06f, 0.78f);

		private GameObject _tileRow;

		private TextMeshProUGUI _emptyLabel;

		private readonly List<Tile> _tiles = new List<Tile>();

		private Action _ticker;

		private bool _subscribed;

		private float _nextIconTryAt;

		private static Sprite _whiteSprite;

		public override string PanelId => "BeelzActionBarOverlay";

		public override PanelType PanelType => PanelType.BeelzActionBarOverlay;

		public override int MinWidth => 120;

		public override int MinHeight => 90;

		public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPivot => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPosition => new Vector2(0f, (0f - base.Owner.Scaler.m_ReferenceResolution.y) * 0.5f + 200f);

		public override bool CanDrag => true;

		public override PanelDragger.ResizeTypes CanResize => PanelDragger.ResizeTypes.All;

		public override float Opacity => Settings.TransparencyToAlpha(Settings.BeelzActionBarOverlayTransparency);

		public override bool UsesCustomBackgroundColor => true;

		private static Sprite GetWhiteSprite()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_whiteSprite != (Object)null)
			{
				return _whiteSprite;
			}
			try
			{
				_whiteSprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, (float)((Texture)Texture2D.whiteTexture).width, (float)((Texture)Texture2D.whiteTexture).height), new Vector2(0.5f, 0.5f));
			}
			catch
			{
				_whiteSprite = null;
			}
			return _whiteSprite;
		}

		public BeelzActionBarOverlayPanel(UIBase owner)
			: base(owner)
		{
		}

		protected override void ConstructPanelContent()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructPanelContent();
			SetTitle("Beelz Action Bar");
			GameObject contentRoot = base.ContentRoot;
			Vector4 padding = new Vector4(2f, 2f, 2f, 2f);
			TextAnchor? childAlignment = (TextAnchor)4;
			_tileRow = UIFactory.CreateHorizontalGroup(contentRoot, "BeelzTileRow", forceExpandWidth: false, forceExpandHeight: false, childControlWidth: false, childControlHeight: false, 4, padding, null, childAlignment);
			GameObject tileRow = _tileRow;
			int? minWidth = MinWidth - 8;
			int? preferredWidth = MinWidth - 8;
			int? num = 1;
			UIFactory.SetLayoutElement(minHeight: 66, flexibleWidth: num, preferredHeight: 66, gameObject: tileRow, minWidth: minWidth, flexibleHeight: 0, preferredWidth: preferredWidth);
			_emptyLabel = UIFactory.CreateLabel(base.ContentRoot, "BeelzActionEmpty", "No hotkey abilities bound.\nBind some on the Beelzebub → Hotkeys tab.", (TextAlignmentOptions)514, null, Theme.ScaledOverlay(11)).TextMesh;
			GameObject gameObject = ((Component)_emptyLabel).gameObject;
			int? minWidth2 = 100;
			int? preferredWidth2 = 140;
			num = 1;
			UIFactory.SetLayoutElement(minHeight: 40, flexibleWidth: num, preferredHeight: 44, gameObject: gameObject, minWidth: minWidth2, flexibleHeight: 0, preferredWidth: preferredWidth2);
			((TMP_Text)_emptyLabel).fontStyle = (FontStyles)2;
			if (!_subscribed)
			{
				BeelzState.HotkeysChanged += RebuildTiles;
				BeelzProtocolService.AbilityCast += OnAbilityCast;
				_subscribed = true;
			}
			if (_ticker == null)
			{
				_ticker = OnTick;
				CoreUpdateBehavior.Actions.Add(_ticker);
			}
			RebuildTiles();
			if (BeelzState.Present && BeelzState.Hotkeys.Count == 0)
			{
				BeelzClient.RequestHotkeys();
			}
		}

		private void RebuildTiles()
		{
			if ((Object)(object)_tileRow == (Object)null)
			{
				return;
			}
			for (int num = _tileRow.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = _tileRow.transform.GetChild(num);
				if ((Object)(object)child != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
			_tiles.Clear();
			IReadOnlyList<BeelzHotkey> hotkeys = BeelzState.Hotkeys;
			bool flag = hotkeys.Count > 0 && BeelzState.HotkeysEnabled;
			if ((Object)(object)_tileRow != (Object)null)
			{
				_tileRow.SetActive(flag);
			}
			if ((Object)(object)_emptyLabel != (Object)null)
			{
				((Component)_emptyLabel).gameObject.SetActive(!flag);
			}
			if (!flag)
			{
				return;
			}
			foreach (BeelzHotkey item in hotkeys)
			{
				_tiles.Add(BuildTile(item));
			}
		}

		private Tile BuildTile(BeelzHotkey hk)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			Tile tile = new Tile
			{
				HotkeyName = hk.Name,
				AbilityGuid = hk.AbilityGuid
			};
			GameObject val = UIFactory.CreateUIObject("BeelzTile_" + hk.Name, _tileRow);
			val.GetComponent<RectTransform>().sizeDelta = new Vector2(56f, 56f);
			int? minWidth = 56;
			int? preferredWidth = 56;
			int? num = 0;
			UIFactory.SetLayoutElement(minHeight: 56, flexibleWidth: num, preferredHeight: 56, gameObject: val, minWidth: minWidth, flexibleHeight: 0, preferredWidth: preferredWidth);
			tile.Bg = val.AddComponent<Image>();
			((Graphic)tile.Bg).color = TILE_READY;
			Button obj = val.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)tile.Bg;
			string castName = hk.Name;
			((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
			{
				try
				{
					BeelzClient.Cast(castName);
				}
				catch (Exception value3)
				{
					LogUtils.LogError($"Beelz cast '{castName}' failed: {value3}");
				}
			}));
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = new Color(0.85f, 0.8f, 0.9f, 0.9f);
			((Shadow)obj2).effectDistance = new Vector2(1.1f, -1.1f);
			GameObject obj3 = UIFactory.CreateUIObject("Backing", val);
			RectTransform component = obj3.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(2.5f, 2.5f);
			component.offsetMax = new Vector2(-2.5f, -2.5f);
			Image obj4 = obj3.AddComponent<Image>();
			((Graphic)obj4).color = TILE_SLOT_BG;
			((Graphic)obj4).raycastTarget = false;
			GameObject val2 = UIFactory.CreateUIObject("Icon", val);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(4f, 4f);
			component2.offsetMax = new Vector2(-4f, -4f);
			tile.Icon = val2.AddComponent<Image>();
			((Graphic)tile.Icon).raycastTarget = false;
			tile.Icon.preserveAspect = true;
			((Behaviour)tile.Icon).enabled = false;
			int.TryParse(hk.AbilityGuid, out tile.IconHash);
			GameObject val3 = UIFactory.CreateUIObject("Radial", val);
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			tile.Radial = val3.AddComponent<Image>();
			((Graphic)tile.Radial).color = RADIAL;
			((Graphic)tile.Radial).raycastTarget = false;
			Sprite whiteSprite = GetWhiteSprite();
			if ((Object)(object)whiteSprite != (Object)null)
			{
				tile.Radial.sprite = whiteSprite;
				tile.Radial.type = (Type)3;
				tile.Radial.fillMethod = (FillMethod)4;
				tile.Radial.fillOrigin = 2;
				tile.Radial.fillClockwise = true;
				tile.Radial.fillAmount = 0f;
			}
			else
			{
				Color color = ((Graphic)tile.Radial).color;
				color.a = 0f;
				((Graphic)tile.Radial).color = color;
			}
			((Behaviour)tile.Radial).enabled = false;
			GameObject obj5 = UIFactory.CreateUIObject("Name", val);
			RectTransform component4 = obj5.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.offsetMin = Vector2.zero;
			component4.offsetMax = Vector2.zero;
			TextMeshProUGUI val4 = obj5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val4).alignment = (TextAlignmentOptions)258;
			((TMP_Text)val4).fontSize = Theme.ScaledOverlay(9);
			((Graphic)val4).color = Color.white;
			((TMP_Text)val4).enableWordWrapping = false;
			((TMP_Text)val4).overflowMode = (TextOverflowModes)1;
			((Graphic)val4).raycastTarget = false;
			((TMP_Text)val4).outlineWidth = 0.2f;
			((TMP_Text)val4).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)210);
			((TMP_Text)val4).text = (string.IsNullOrEmpty(hk.Name) ? "?" : hk.Name);
			tile.Name = val4;
			GameObject val5 = UIFactory.CreateUIObject("Countdown", val);
			RectTransform component5 = val5.GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = Vector2.zero;
			component5.offsetMax = Vector2.zero;
			tile.Countdown = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)tile.Countdown).alignment = (TextAlignmentOptions)514;
			((TMP_Text)tile.Countdown).fontSize = Theme.ScaledOverlay(18);
			((TMP_Text)tile.Countdown).fontStyle = (FontStyles)1;
			((Graphic)tile.Countdown).color = Color.white;
			((Graphic)tile.Countdown).raycastTarget = false;
			((TMP_Text)tile.Countdown).outlineWidth = 0.25f;
			((TMP_Text)tile.Countdown).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220);
			((TMP_Text)tile.Countdown).text = "";
			string abilGuid = hk.AbilityGuid;
			string fallbackName = (string.IsNullOrEmpty(hk.AbilityName) ? hk.Name : BeelzNames.Ability(hk.AbilityName));
			TooltipHover.Attach(val, delegate
			{
				string value = fallbackName;
				string value2 = "";
				if (BeelzState.TryGetAbilityInfo(abilGuid, out var info2) && info2 != null)
				{
					if (!string.IsNullOrEmpty(info2.Label))
					{
						value = info2.Label;
					}
					else if (!string.IsNullOrEmpty(info2.AbilityName))
					{
						value = BeelzNames.Ability(info2.AbilityName);
					}
					if (!string.IsNullOrEmpty(info2.Desc))
					{
						value2 = "\n" + info2.Desc;
					}
				}
				return $"{value} — click to force-cast (.beelz cast {castName}).{value2}" + "\nThe ring shows an estimated cooldown (client-side; the server enforces the real one).";
			});
			if (!BeelzState.TryGetAbilityInfo(hk.AbilityGuid, out var _))
			{
				RequestInfoForAbility(hk.AbilityGuid);
			}
			return tile;
		}

		private static void RequestInfoForAbility(string abilityGuid)
		{
			if (string.IsNullOrEmpty(abilityGuid))
			{
				return;
			}
			foreach (BeelzCapture capture in BeelzState.Captures)
			{
				if (capture.AbilityGuid == abilityGuid)
				{
					BeelzClient.RequestInfo(capture.Index);
					return;
				}
			}
			BeelzClient.RequestInfoGuid(abilityGuid);
		}

		private void OnAbilityCast(string abilityGuid)
		{
			float num = 8f;
			if (BeelzState.TryGetAbilityInfo(abilityGuid, out var info))
			{
				num = info.EffectiveCooldownSeconds;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			foreach (Tile tile in _tiles)
			{
				if (!(tile.AbilityGuid != abilityGuid))
				{
					tile.CooldownTotal = num;
					tile.CooldownEnd = realtimeSinceStartup + num;
				}
			}
		}

		private void OnTick()
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			if (_tiles.Count == 0)
			{
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (Settings.EnableBeelzAbilityIcons && realtimeSinceStartup >= _nextIconTryAt)
			{
				_nextIconTryAt = realtimeSinceStartup + 0.4f;
				foreach (Tile tile in _tiles)
				{
					if (!tile.IconResolved && tile.IconHash != 0 && tile.IconTries < 12)
					{
						tile.IconTries++;
						TryResolveTileIcon(tile);
						break;
					}
				}
			}
			foreach (Tile tile2 in _tiles)
			{
				if ((Object)(object)tile2.Radial == (Object)null)
				{
					continue;
				}
				float num = tile2.CooldownEnd - realtimeSinceStartup;
				if (!(num > 0.05f))
				{
					if (((Behaviour)tile2.Radial).enabled)
					{
						((Behaviour)tile2.Radial).enabled = false;
					}
					if ((Object)(object)tile2.Bg != (Object)null)
					{
						((Graphic)tile2.Bg).color = TILE_READY;
					}
					if ((Object)(object)tile2.Countdown != (Object)null && ((TMP_Text)tile2.Countdown).text.Length != 0)
					{
						((TMP_Text)tile2.Countdown).text = "";
					}
					continue;
				}
				if (!((Behaviour)tile2.Radial).enabled)
				{
					((Behaviour)tile2.Radial).enabled = true;
				}
				tile2.Radial.fillAmount = ((tile2.CooldownTotal > 0.01f) ? Mathf.Clamp01(num / tile2.CooldownTotal) : 0f);
				if ((Object)(object)tile2.Bg != (Object)null)
				{
					((Graphic)tile2.Bg).color = TILE_BUSY;
				}
				if ((Object)(object)tile2.Countdown != (Object)null)
				{
					((TMP_Text)tile2.Countdown).text = ((num < 10f) ? $"{num:0.0}" : $"{(int)num}");
				}
			}
		}

		private void TryResolveTileIcon(Tile t)
		{
			if (t != null && !((Object)(object)t.Icon == (Object)null) && AbilityIconResolver.TryGetIcon(t.IconHash, out var icon) && (Object)(object)icon != (Object)null)
			{
				t.Icon.sprite = icon;
				if (!((Behaviour)t.Icon).enabled)
				{
					((Behaviour)t.Icon).enabled = true;
				}
				t.IconResolved = true;
				if ((Object)(object)t.Name != (Object)null && ((Component)t.Name).gameObject.activeSelf)
				{
					((Component)t.Name).gameObject.SetActive(false);
				}
			}
		}

		internal override void Reset()
		{
			if (_subscribed)
			{
				BeelzState.HotkeysChanged -= RebuildTiles;
				BeelzProtocolService.AbilityCast -= OnAbilityCast;
				_subscribed = false;
			}
			if (_ticker != null)
			{
				CoreUpdateBehavior.Actions.Remove(_ticker);
				_ticker = null;
			}
			_tiles.Clear();
		}
	}
	public class BeelzSummonsOverlayPanel : ResizeablePanelBase
	{
		private static readonly Color STASH_COLOR = new Color(0.3f, 0.18f, 0.36f, 0.95f);

		private static readonly Color RESTORE_COLOR = new Color(0.18f, 0.34f, 0.22f, 0.95f);

		private bool _stashed;

		private ButtonRef _toggleBtn;

		public override string PanelId => "BeelzSummonsOverlay";

		public override PanelType PanelType => PanelType.BeelzSummonsOverlay;

		public override int MinWidth => 120;

		public override int MinHeight => 58;

		public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPivot => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPosition => new Vector2((0f - base.Owner.Scaler.m_ReferenceResolution.x) * 0.5f + 220f, (0f - base.Owner.Scaler.m_ReferenceResolution.y) * 0.5f + 340f);

		public override bool CanDrag => true;

		public override PanelDragger.ResizeTypes CanResize => PanelDragger.ResizeTypes.All;

		public override float Opacity => Settings.TransparencyToAlpha(Settings.BeelzSummonsOverlayTransparency);

		public override bool UsesCustomBackgroundColor => true;

		public BeelzSummonsOverlayPanel(UIBase owner)
			: base(owner)
		{
		}

		protected override void ConstructPanelContent()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructPanelContent();
			SetTitle("Summons");
			_toggleBtn = UIFactory.CreateButton(base.ContentRoot, "BeelzSummonsToggle", "Stash Summons");
			GameObject gameObject = _toggleBtn.GameObject;
			int? minWidth = 100;
			int? preferredWidth = 150;
			int? num = 1;
			UIFactory.SetLayoutElement(minHeight: 28, flexibleWidth: num, preferredHeight: 32, gameObject: gameObject, minWidth: minWidth, flexibleHeight: 0, preferredWidth: preferredWidth);
			_toggleBtn.OnClick = OnToggle;
			ApplyToggleVisual();
			TooltipHover.Attach(_toggleBtn.GameObject, "Toggle your summons between stashed and restored.\n• Stash (.beelz summons stash) — tuck your minions away (e.g. before a waygate).\n• Restore (.beelz summons restore) — bring the stashed minions back.\nThe label tracks what the next press will do (client-side — the server is authoritative).");
			GameObject obj = UIFactory.CreateHorizontalGroup(base.ContentRoot, "BeelzSummonsRow", forceExpandWidth: true, forceExpandHeight: false, childControlWidth: true, childControlHeight: true, 4, new Vector4(0f, 0f, 2f, 0f));
			int? minWidth2 = 100;
			int? preferredWidth2 = 150;
			num = 1;
			UIFactory.SetLayoutElement(minHeight: 24, flexibleWidth: num, preferredHeight: 28, gameObject: obj, minWidth: minWidth2, flexibleHeight: 0, preferredWidth: preferredWidth2);
			ButtonRef buttonRef = UIFactory.CreateButton(obj, "BeelzSummonsRecall", "Recall");
			GameObject gameObject2 = buttonRef.GameObject;
			int? minWidth3 = 48;
			preferredWidth = 72;
			num = 1;
			UIFactory.SetLayoutElement(minHeight: 22, flexibleWidth: num, preferredHeight: 26, gameObject: gameObject2, minWidth: minWidth3, flexibleHeight: 0, preferredWidth: preferredWidth);
			buttonRef.OnClick = delegate
			{
				Send(".beelz tp");
			};
			TooltipHover.Attach(buttonRef.GameObject, "Recall your summons to you (.beelz tp).");
			ButtonRef buttonRef2 = UIFactory.CreateButton(obj, "BeelzSummonsClear", "Clear");
			GameObject gameObject3 = buttonRef2.GameObject;
			int? minWidth4 = 48;
			preferredWidth2 = 72;
			num = 1;
			UIFactory.SetLayoutElement(minHeight: 22, flexibleWidth: num, preferredHeight: 26, gameObject: gameObject3, minWidth: minWidth4, flexibleHeight: 0, preferredWidth: preferredWidth2);
			buttonRef2.OnClick = delegate
			{
				Send(".beelz summons clear");
				_stashed = false;
				ApplyToggleVisual();
			};
			TooltipHover.Attach(buttonRef2.GameObject, "Despawn ALL your summons (.beelz summons clear).");
		}

		private void OnToggle()
		{
			if (!_stashed)
			{
				Send(".beelz summons stash");
				_stashed = true;
			}
			else
			{
				Send(".beelz summons restore");
				_stashed = false;
			}
			ApplyToggleVisual();
		}

		private void ApplyToggleVisual()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (_toggleBtn != null)
			{
				TextMeshProUGUI val = (((Object)(object)_toggleBtn.Component != (Object)null) ? ((Component)_toggleBtn.Component).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val != (Object)null)
				{
					((TMP_Text)val).text = (_stashed ? "Restore Summons" : "Stash Summons");
				}
				Image val2 = (((Object)(object)_toggleBtn.Component != (Object)null) ? ((Component)_toggleBtn.Component).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = (_stashed ? RESTORE_COLOR : STASH_COLOR);
				}
			}
		}

		private static void Send(string cmd)
		{
			try
			{
				BeelzClient.SendUser(cmd);
			}
			catch (Exception value)
			{
				LogUtils.LogError($"Beelz summons overlay '{cmd}' failed: {value}");
			}
		}

		internal override void Reset()
		{
		}
	}
	public class BeelzTransformOverlayPanel : ResizeablePanelBase
	{
		private static readonly Color ROW_ACTIVE = new Color(0.18f, 0.34f, 0.22f, 0.95f);

		private static readonly Color ROW_ARMED = new Color(0.3f, 0.18f, 0.36f, 0.95f);

		private GameObject _activeRow;

		private GameObject _listContainer;

		private TextMeshProUGUI _status;

		private bool _subscribed;

		private string _armedGuid;

		private float _armedAt;

		private const float DOUBLE_CLICK_SECONDS = 0.6f;

		public override string PanelId => "BeelzTransformOverlay";

		public override PanelType PanelType => PanelType.BeelzTransformOverlay;

		public override int MinWidth => 220;

		public override int MinHeight => 150;

		public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPivot => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPosition => new Vector2((0f - base.Owner.Scaler.m_ReferenceResolution.x) * 0.5f + 240f, 60f);

		public override bool CanDrag => true;

		public override PanelDragger.ResizeTypes CanResize => PanelDragger.ResizeTypes.All;

		public override float Opacity => Settings.TransparencyToAlpha(Settings.BeelzTransformOverlayTransparency);

		public override bool UsesCustomBackgroundColor => true;

		public BeelzTransformOverlayPanel(UIBase owner)
			: base(owner)
		{
		}

		protected override void ConstructPanelContent()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructPanelContent();
			SetTitle("Transforms");
			GameObject obj = UIFactory.CreateHorizontalGroup(base.ContentRoot, "BeelzTfOvToolbar", forceExpandWidth: true, forceExpandHeight: false, childControlWidth: true, childControlHeight: true, 4, new Vector4(2f, 2f, 2f, 2f));
			int? minWidth = MinWidth - 8;
			int? num = 1;
			UIFactory.SetLayoutElement(minHeight: 26, flexibleWidth: num, preferredHeight: 28, gameObject: obj, minWidth: minWidth, flexibleHeight: 0);
			ButtonRef buttonRef = UIFactory.CreateButton(obj, "BeelzTfOvRefresh", "Refresh");
			GameObject gameObject = buttonRef.GameObject;
			int? minWidth2 = 70;
			int? preferredWidth = 90;
			num = 0;
			UIFactory.SetLayoutElement(minHeight: 24, flexibleWidth: num, preferredHeight: 26, gameObject: gameObject, minWidth: minWidth2, flexibleHeight: 0, preferredWidth: preferredWidth);
			buttonRef.OnClick = delegate
			{
				if (BeelzState.Present)
				{
					BeelzClient.RequestTransforms();
					BeelzClient.RequestActive();
				}
			};
			TooltipHover.Attach(buttonRef.GameObject, "Re-pull your transforms + the active form (api transforms / active).");
			_activeRow = UIFactory.CreateVerticalGroup(base.ContentRoot, "BeelzTfOvActive", forceWidth: true, forceHeight: false, childControlWidth: true, childControlHeight: true, 2, new Vector4(2f, 2f, 2f, 2f));
			UIFactory.SetLayoutElement(_activeRow, MinWidth - 8, flexibleWidth: 1, minHeight: 26, flexibleHeight: 0);
			_listContainer = UIFactory.CreateVerticalGroup(base.ContentRoot, "BeelzTfOvList", forceWidth: true, forceHeight: false, childControlWidth: true, childControlHeight: true, 2, new Vector4(2f, 2f, 2f, 2f));
			UIFactory.SetLayoutElement(_listContainer, MinWidth - 8, flexibleWidth: 1, minHeight: 40, flexibleHeight: 1);
			_status = UIFactory.CreateLabel(base.ContentRoot, "BeelzTfOvStatus", "", (TextAlignmentOptions)4097, null, Theme.ScaledOverlay(10)).TextMesh;
			GameObject gameObject2 = ((Component)_status).gameObject;
			int? minWidth5 = MinWidth - 8;
			int? num2 = 1;
			UIFactory.SetLayoutElement(minHeight: 16, flexibleWidth: num2, preferredHeight: 18, gameObject: gameObject2, minWidth: minWidth5, flexibleHeight: 0);
			((TMP_Text)_status).fontStyle = (FontStyles)2;
			((TMP_Text)_status).enableWordWrapping = true;
			if (!_subscribed)
			{
				BeelzState.TransformsChanged += Rebuild;
				BeelzState.ActiveChanged += Rebuild;
				_subscribed = true;
			}
			Rebuild();
			if (BeelzState.Present && BeelzState.Transforms.Count == 0)
			{
				BeelzClient.RequestTransforms();
				BeelzClient.RequestActive();
			}
		}

		private void SetStatus(string msg)
		{
			if (!((Object)(object)_status == (Object)null))
			{
				((TMP_Text)_status).text = msg ?? "";
				((Component)_status).gameObject.SetActive(!string.IsNullOrEmpty(msg));
			}
		}

		private void Rebuild()
		{
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_listContainer == (Object)null || (Object)(object)_activeRow == (Object)null)
			{
				return;
			}
			for (int num = _activeRow.transform.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)_activeRow.transform.GetChild(num)).gameObject);
			}
			for (int num2 = _listContainer.transform.childCount - 1; num2 >= 0; num2--)
			{
				Object.Destroy((Object)(object)((Component)_listContainer.transform.GetChild(num2)).gameObject);
			}
			if (!BeelzState.Present)
			{
				AddSimpleLabel(_listContainer, "(Beelzebub not detected)");
				return;
			}
			BeelzActive active = BeelzState.Active;
			bool flag = active != null && !active.None;
			if (flag)
			{
				string value = BeelzNames.Unit(active.UnitName);
				string value2 = (string.IsNullOrEmpty(active.Ttl) ? "" : ("  (" + active.Ttl + ")"));
				AddSimpleLabel(_activeRow, $"<color=#90EE90>Active:</color> {value}   <color=#BFBFBF>Phase {active.Phase}{value2}</color>");
				GameObject val = UIFactory.CreateHorizontalGroup(_activeRow, "BeelzTfOvActiveBtns", forceExpandWidth: true, forceExpandHeight: false, childControlWidth: true, childControlHeight: true, 4, new Vector4(0f, 0f, 0f, 0f));
				int? minWidth = MinWidth - 12;
				int? num3 = 1;
				UIFactory.SetLayoutElement(minHeight: 24, flexibleWidth: num3, preferredHeight: 26, gameObject: val, minWidth: minWidth, flexibleHeight: 0);
				AddOverlayButton(val, "BeelzTfOvP1", "Phase 1", "Switch to phase 1 (.beelz phase 1).", delegate
				{
					BeelzClient.Phase(1);
					SetStatus("Switching to phase 1…");
				});
				AddOverlayButton(val, "BeelzTfOvP2", "Phase 2", "Switch to phase 2 (.beelz phase 2).", delegate
				{
					BeelzClient.Phase(2);
					SetStatus("Switching to phase 2…");
				});
				AddOverlayButton(val, "BeelzTfOvRevert", "Revert", "End the active transform (.beelz revert).", delegate
				{
					BeelzClient.Revert();
					SetStatus("Reverting…");
				}, danger: true);
			}
			else
			{
				AddSimpleLabel(_activeRow, "<color=#BFBFBF>No active transform — double-click a form below.</color>");
			}
			IReadOnlyList<BeelzTransform> transforms = BeelzState.Transforms;
			if (transforms.Count == 0)
			{
				AddSimpleLabel(_listContainer, "(no transforms unlocked — defeat a transform boss)");
				return;
			}
			foreach (BeelzTransform item in transforms)
			{
				string unitGuid = item.UnitGuid;
				string text = BeelzNames.Unit(item.UnitName);
				bool flag2 = flag && active.UnitGuid == unitGuid;
				bool flag3 = _armedGuid == unitGuid;
				GameObject obj = UIFactory.CreateUIObject("BeelzTfOvRow_" + unitGuid, _listContainer);
				int? minWidth2 = MinWidth - 12;
				int? num4 = 1;
				UIFactory.SetLayoutElement(minHeight: 24, flexibleWidth: num4, preferredHeight: 26, gameObject: obj, minWidth: minWidth2, flexibleHeight: 0);
				Image val2 = obj.AddComponent<Image>();
				((Graphic)val2).color = (Color)(flag2 ? ROW_ACTIVE : (flag3 ? ROW_ARMED : new Color(0.16f, 0.14f, 0.2f, 0.85f)));
				Button val3 = obj.AddComponent<Button>();
				((Selectable)val3).targetGraphic = (Graphic)(object)val2;
				LabelRef labelRef = UIFactory.CreateLabel(obj, "Label", text + (item.Enabled ? "" : "  <color=#FFB070>(disabled)</color>") + (item.Shard ? "  <color=#BFBFBF>· shard</color>" : ""), (TextAlignmentOptions)4097, null, Theme.ScaledOverlay(12));
				RectTransform component = labelRef.GameObject.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(6f, 0f);
				component.offsetMax = new Vector2(-6f, 0f);
				((Graphic)labelRef.TextMesh).raycastTarget = false;
				((TMP_Text)labelRef.TextMesh).enableWordWrapping = false;
				((TMP_Text)labelRef.TextMesh).overflowMode = (TextOverflowModes)1;
				string capName = text;
				string capGuid = unitGuid;
				int capIndex = item.Index;
				((UnityEvent)val3.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					OnRowClick(capGuid, capIndex, capName);
				}));
				TooltipHover.Attach(obj, "Double-click to transform into " + text + " (.beelz transform). Failure reasons reply in chat.");
			}
		}

		private void OnRowClick(string guid, int index, string name)
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (_armedGuid == guid && realtimeSinceStartup - _armedAt < 0.6f)
			{
				_armedGuid = null;
				try
				{
					BeelzClient.TransformSafe(index.ToString(CultureInfo.InvariantCulture));
				}
				catch (Exception value)
				{
					LogUtils.LogError($"Beelz transform '{name}' failed: {value}");
				}
				SetStatus("<color=#90EE90>Transforming into " + name + "…</color> (Watch chat for the result.)");
			}
			else
			{
				_armedGuid = guid;
				_armedAt = realtimeSinceStartup;
				SetStatus("Click " + name + " again to transform.");
			}
			Rebuild();
		}

		private void AddSimpleLabel(GameObject parent, string text)
		{
			LabelRef labelRef = UIFactory.CreateLabel(parent, "Lbl", text, (TextAlignmentOptions)4097, null, Theme.ScaledOverlay(11));
			GameObject gameObject = labelRef.GameObject;
			int? minWidth = MinWidth - 12;
			int? num = 1;
			UIFactory.SetLayoutElement(minHeight: 18, flexibleWidth: num, preferredHeight: 20, gameObject: gameObject, minWidth: minWidth, flexibleHeight: 0);
			((TMP_Text)labelRef.TextMesh).enableWordWrapping = true;
		}

		private void AddOverlayButton(GameObject parent, string name, string label, string tooltip, Action onClick, bool danger = false)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			ButtonRef buttonRef = UIFactory.CreateButton(parent, name, label);
			GameObject gameObject = buttonRef.GameObject;
			int? minWidth = 56;
			int? preferredWidth = 80;
			int? num = 1;
			UIFactory.SetLayoutElement(minHeight: 22, flexibleWidth: num, preferredHeight: 24, gameObject: gameObject, minWidth: minWidth, flexibleHeight: 0, preferredWidth: preferredWidth);
			TextMeshProUGUI val = (((Object)(object)buttonRef.Component != (Object)null) ? ((Component)buttonRef.Component).GetComponentInChildren<TextMeshProUGUI>() : null);
			if ((Object)(object)val != (Object)null)
			{
				((TMP_Text)val).fontSize = Theme.ScaledOverlay(11);
				((TMP_Text)val).alignment = (TextAlignmentOptions)514;
			}
			if (danger)
			{
				Image val2 = (((Object)(object)buttonRef.Component != (Object)null) ? ((Component)buttonRef.Component).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0.55f, 0.18f, 0.18f, 0.95f);
				}
			}
			buttonRef.OnClick = delegate
			{
				onClick?.Invoke();
			};
			TooltipHover.Attach(buttonRef.GameObject, tooltip);
		}

		internal override void Reset()
		{
			if (_subscribed)
			{
				BeelzState.TransformsChanged -= Rebuild;
				BeelzState.ActiveChanged -= Rebuild;
				_subscribed = false;
			}
		}
	}
	public class ChatWindowOverlayPanel : ResizeablePanelBase
	{
		private readonly struct SendTarget
		{
			public readonly ChatMessageType? Channel;

			public readonly string Whisper;

			public readonly string Label;

			public bool IsWhisper => !Channel.HasValue;

			private SendTarget(ChatMessageType? channel, string whisper, string label)
			{
				Channel = channel;
				Whisper = whisper;
				Label = label;
			}

			public static SendTarget Chan(ChatMessageType c, string label)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return new SendTarget(c, null, label);
			}

			public static SendTarget Whis(string partner)
			{
				return new SendTarget(null, partner, "@" + partner);
			}
		}

		private readonly struct TabCols
		{
			public readonly bool UsePx;

			public readonly int ChanStart;

			public readonly int NameStart;

			public readonly int MsgStart;

			public TabCols(bool usePx, int chanStart, int nameStart, int msgStart)
			{
				UsePx = usePx;
				ChanStart = chanStart;
				NameStart = nameStart;
				MsgStart = msgStart;
			}
		}

		private static readonly (ChatRelayService.Channel? Filter, string Label)[] TabDefs = new(ChatRelayService.Channel?, string)[6]
		{
			(null, "All"),
			(ChatRelayService.Channel.Global, "Global"),
			(ChatRelayService.Channel.Local, "Local"),
			(ChatRelayService.Channel.Clan, "Clan"),
			(ChatRelayService.Channel.System, "System"),
			(ChatRelayService.Channel.Whisper, "Whispers")
		};

		private int _activeTab;

		private TextMeshProUGUI _log;

		private bool _subscribed;

		private readonly List<ButtonRef> _tabButtons = new List<ButtonRef>();

		private InputFieldRef _input;

		private GameObject _inputRow;

		private ScrollRect _scrollRect;

		private RectTransform _scrollContentRect;

		private const float InputBaseHeight = 24f;

		private const float InputMaxHeight = 96f;

		private GameObject _whisperSubRow;

		private GameObject _whisperEntryRow;

		private InputFieldRef _whisperNameInput;

		private readonly List<ButtonRef> _whisperSubButtons = new List<ButtonRef>();

		private readonly List<string> _whisperSubPartners = new List<string>();

		private string _activeWhisperPartner;

		private readonly HashSet<string> _initiatedPartners = new HashSet<string>();

		private readonly HashSet<string> _closedPartners = new HashSet<string>();

		private TMP_Dropdown _whisperPicker;

		private List<PlayerRosterService.PlayerRef> _pickerRoster;

		private static readonly int WhispersTabIndex = Array.FindIndex(TabDefs, ((ChatRelayService.Channel? Filter, string Label) t) => t.Filter.GetValueOrDefault() == ChatRelayService.Channel.Whisper);

		private readonly int[] _unread = new int[TabDefs.Length];

		private const int MaxChatChars = 500;

		private GameObject _composeDropdownObj;

		private TMP_Dropdown _composeDropdown;

		private readonly List<SendTarget> _composeTargets = new List<SendTarget>();

		private int _composeIndex;

		private string _composeSignature = "";

		private Action _composeKeyTicker;

		private Action _tabHotkeyTicker;

		private Action _nameClickTicker;

		private float _lastNameClickTime;

		private string _lastNameClickId;

		private float _nextComposeRefresh;

		private int _inputFocusGrace;

		private const string WhisperLinkColorHex = "#7FB6FF";

		public override string PanelId => "ChatWindowOverlay";

		public override PanelType PanelType => PanelType.ChatWindowOverlay;

		public override int MinWidth => 320;

		public override int MinHeight => 180;

		public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPivot => new Vector2(0.5f, 0.5f);

		public override Vector2 DefaultPosition => new Vector2((0f - base.Owner.Scaler.m_ReferenceResolution.x) * 0.5f + 30f, (0f - base.Owner.Scaler.m_ReferenceResolution.y) * 0.5f + 220f);

		public override bool CanDrag => true;

		public override PanelDragger.ResizeTypes CanResize => PanelDragger.ResizeTypes.All;

		public override float Opacity => Settings.TransparencyToAlpha(Settings.ChatWindowOverlayTransparency);

		public override bool UsesCustomBackgroundColor => true;

		public override void RefreshBackgroundColor()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			Color chatWindowBackgroundColor = Settings.ChatWindowBackgroundColor;
			UIFactory.ApplyBackgroundColorRgbToPanel(uiRoot, chatWindowBackgroundColor);
			try
			{
				Transform val = (((Object)(object)uiRoot != (Object)null) ? uiRoot.transform.Find("Content") : null);
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					Color color = ((Graphic)val2).color;
					((Graphic)val2).color = new Color(chatWindowBackgroundColor.r, chatWindowBackgroundColor.g, chatWindowBackgroundColor.b, color.a);
				}
			}
			catch
			{
			}
		}

		public ChatWindowOverlayPanel(UIBase owner)
			: base(owner)
		{
		}

		protected override void ConstructPanelContent()
		{
			//IL_0058: Unknown result type (migh