Decompiled source of OrdainUI v0.2.1

OrdainUI/OrdainUI.dll

Decompiled 3 hours ago
using System;
using System.Collections;
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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using OrdainUI.Core;
using OrdainUI.Panels;
using OrdainUI.Patches;
using OrdainUI.Services;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
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("OrdainUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1")]
[assembly: AssemblyProduct("OrdainUI")]
[assembly: AssemblyTitle("OrdainUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OrdainUI
{
	public class OrdainUIBehaviour : MonoBehaviour
	{
		private static bool _uiReady = false;

		private static MainMenuScreen _mainMenu;

		private static GOMSStatsPanel _statsPanel;

		private static InspectPlayerPanel _inspectPanel;

		private static ImagePreviewPanel _imagePreviewPanel;

		private static UIDesignPanel _uiDesignPanel;

		private static FamiliarPanel _familiarPanel;

		private static ForgePanel _forgePanel;

		private static QuestPanel _questPanel;

		private static AchievementsPanel _achPanel;

		private static VFXPanel _vfxPanel;

		private static UISettingsPanel _settingsPanel;

		private static LeaderboardPanel _lbPanel;

		private static HUDOverlay _hud;

		private static EventHUD _eventHUD;

		private static EventPhaseBannerHUD _eventPhaseBanner;

		private static QuestTrackerHUD _questTrackerHUD;

		private static NotificationPopup _notificationPopup;

		private static NPCPromptHUD _npcPromptHUD;

		private static NPCDialoguePanel _npcDialoguePanel;

		private static RiteOfferingPanel _riteOfferingPanel;

		private static TimerHUD _timerHUD;

		private static IchorHUD _ichorHUD;

		private static bool _dragLocked = true;

		private static bool _cursorOverridden = false;

		private static CursorLockMode _savedLockMode;

		private static bool _savedCursorVisible;

		private static bool _dirtyMainMenu = true;

		private static bool _dirtyStats = true;

		private static bool _dirtyFamiliar = true;

		private static bool _dirtyForge = true;

		private static bool _dirtyQuest = true;

		private static bool _dirtyAchievements = true;

		private static bool _dirtyLeaderboard = true;

		private static bool _dirtySettings = true;

		private static bool _dirtyInspect = true;

		private static bool _inspectPanelActive = false;

		private static SystemFeedPanel _systemFeedPanel;

		public OrdainUIBehaviour(IntPtr ptr)
			: base(ptr)
		{
		}

		[HideFromIl2Cpp]
		public static void MarkMainMenuDirty()
		{
			_dirtyMainMenu = true;
		}

		[HideFromIl2Cpp]
		public static void MarkStatsDirty()
		{
			_dirtyStats = true;
		}

		[HideFromIl2Cpp]
		public static void MarkFamiliarDirty()
		{
			_dirtyFamiliar = true;
		}

		public static void MarkForgeDirty()
		{
			_dirtyForge = true;
		}

		[HideFromIl2Cpp]
		public static void MarkQuestDirty()
		{
			_dirtyQuest = true;
		}

		[HideFromIl2Cpp]
		public static void MarkAchievementsDirty()
		{
			_dirtyAchievements = true;
		}

		[HideFromIl2Cpp]
		public static void MarkLeaderboardDirty()
		{
			_dirtyLeaderboard = true;
		}

		[HideFromIl2Cpp]
		public static void MarkSettingsDirty()
		{
			_dirtySettings = true;
		}

		[HideFromIl2Cpp]
		public static void MarkInspectDirty()
		{
			_dirtyInspect = true;
		}

		[HideFromIl2Cpp]
		public static void MarkAllPanelsDirty()
		{
			_dirtyMainMenu = true;
			_dirtyStats = true;
			_dirtyFamiliar = true;
			_dirtyQuest = true;
			_dirtyAchievements = true;
			_dirtyLeaderboard = true;
			_dirtySettings = true;
			_dirtyInspect = true;
		}

		[HideFromIl2Cpp]
		public static void SetUIReady(bool ready)
		{
			_uiReady = ready;
			Plugin.Verbose($"[OrdainUI] UIReady = {ready}");
			if (ready)
			{
				_hud = new HUDOverlay();
				_hud.Create();
				_eventHUD = new EventHUD();
				_eventPhaseBanner = new EventPhaseBannerHUD();
				_questTrackerHUD = new QuestTrackerHUD();
				_notificationPopup = new NotificationPopup();
				_npcPromptHUD = new NPCPromptHUD();
				_npcPromptHUD.Create();
				_npcDialoguePanel = new NPCDialoguePanel();
				_npcDialoguePanel.Create();
				_riteOfferingPanel = new RiteOfferingPanel();
				_riteOfferingPanel.Create();
				_timerHUD = new TimerHUD();
				_timerHUD.Create();
				_ichorHUD = new IchorHUD();
				_ichorHUD.Create();
				MarkAllPanelsDirty();
			}
		}

		[HideFromIl2Cpp]
		public static void SetDragLocked(bool locked)
		{
			_dragLocked = locked;
			UIConfig.UILocked = locked;
		}

		[HideFromIl2Cpp]
		public static void ResetHUDPositions()
		{
			_hud?.Destroy();
			_hud = new HUDOverlay();
			_hud.Create();
			_questTrackerHUD?.Destroy();
			_questTrackerHUD = new QuestTrackerHUD();
			_systemFeedPanel?.Destroy();
			_npcPromptHUD?.Destroy();
			_npcPromptHUD = new NPCPromptHUD();
			_npcPromptHUD.Create();
		}

		[HideFromIl2Cpp]
		public static void OpenNPCPanel(string npcId, string npcName, string npcType)
		{
			Plugin.Verbose($"[OrdainUI:NPC] OpenNPCPanel — id={npcId}, name={npcName}, type={npcType}");
			MainMenuScreen mainMenu = _mainMenu;
			if (mainMenu != null && mainMenu.IsVisible)
			{
				_mainMenu.Hide();
			}
			_npcDialoguePanel?.Show(npcId, npcName, npcType);
		}

		[HideFromIl2Cpp]
		public static void OpenInspectPanel(string targetName)
		{
			if (_uiReady && OrdainUI.Core.Core.Initialized)
			{
				EnsureInspectPanel();
				_mainMenu?.Hide();
				_statsPanel?.Hide();
				_inspectPanelActive = true;
				UIData.InspectPanelOpen = true;
				_inspectPanel.Show(targetName);
				MarkInspectDirty();
			}
		}

		[HideFromIl2Cpp]
		public static void CloseInspectPanel()
		{
			_inspectPanelActive = false;
			UIData.InspectPanelOpen = false;
			InspectPlayerPanel inspectPanel = _inspectPanel;
			if (inspectPanel != null && inspectPanel.IsVisible)
			{
				_inspectPanel.Hide();
			}
			MarkInspectDirty();
		}

		[HideFromIl2Cpp]
		public static void OpenImagePreviewPanel(string imagePath)
		{
			if (_uiReady && OrdainUI.Core.Core.Initialized)
			{
				EnsureImagePreviewPanel();
				_imagePreviewPanel.Show(imagePath);
			}
		}

		[HideFromIl2Cpp]
		public static void CloseImagePreviewPanel()
		{
			ImagePreviewPanel imagePreviewPanel = _imagePreviewPanel;
			if (imagePreviewPanel != null && imagePreviewPanel.IsVisible)
			{
				_imagePreviewPanel.Hide();
			}
		}

		[HideFromIl2Cpp]
		public static void OpenUIDesignPanel(string imagePath)
		{
			if (_uiReady && OrdainUI.Core.Core.Initialized)
			{
				EnsureUIDesignPanel();
				_uiDesignPanel.Show(imagePath);
			}
		}

		[HideFromIl2Cpp]
		public static void CloseUIDesignPanel()
		{
			UIDesignPanel uiDesignPanel = _uiDesignPanel;
			if (uiDesignPanel != null && uiDesignPanel.IsVisible)
			{
				_uiDesignPanel.Hide();
			}
		}

		[HideFromIl2Cpp]
		public static void SetNPCDialogueNode(string npcId, string nodeId, string text, int choiceCount)
		{
			_npcDialoguePanel?.SetNode(npcId, nodeId, text, choiceCount);
		}

		public static void TimerBegin(long endUtcMs, string label, bool flashOnZero)
		{
			_timerHUD?.Begin(endUtcMs, label, flashOnZero);
		}

		public static void TimerStop()
		{
			_timerHUD?.Stop();
		}

		public static void IchorSet(long value)
		{
			_ichorHUD?.SetValue(value);
		}

		public static void IchorHide()
		{
			_ichorHUD?.HideCounter();
		}

		[HideFromIl2Cpp]
		public static void AddNPCChoice(string choiceId, string choiceText, string action)
		{
			_npcDialoguePanel?.AddChoice(choiceId, choiceText, action);
		}

		[HideFromIl2Cpp]
		public static void OnNPCChoiceResult(bool success, string message)
		{
			_npcDialoguePanel?.OnChoiceResult(success, message);
		}

		[HideFromIl2Cpp]
		public static void ApplyUIScale(float scale)
		{
			GameObject[] array = (GameObject[])(object)new GameObject[0];
			for (int i = 0; i < array.Length; i++)
			{
				_ = array[i];
			}
		}

		[HideFromIl2Cpp]
		public static void ApplyOpacity(float opacity)
		{
		}

		[HideFromIl2Cpp]
		public static void EnqueueNotification(string text, string type, float duration)
		{
			_notificationPopup?.Enqueue(text, type, duration);
		}

		private void Update()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (!OrdainUI.Core.Core.Initialized || !_uiReady)
			{
				return;
			}
			NativeMenuWatcher.Tick();
			MainMenuScreen mainMenu = _mainMenu;
			CameraInputPatch.OrdainMenuOpen = (mainMenu != null && mainMenu.IsVisible) || (_npcDialoguePanel?.IsVisible ?? false);
			ShadowHoverBox.Tick();
			if (Input.GetKeyDown((KeyCode)282))
			{
				CommandSender.FamQuickSummon();
			}
			if (Input.GetKeyDown((KeyCode)287))
			{
				NPCDialoguePanel npcDialoguePanel = _npcDialoguePanel;
				if (npcDialoguePanel == null || !npcDialoguePanel.IsVisible)
				{
					if (_mainMenu == null)
					{
						CreateMainMenu();
					}
					_mainMenu.Toggle();
					CommandSender.QuestUiOpened();
				}
			}
			if (Input.GetKeyDown((KeyCode)289))
			{
				_questTrackerHUD?.CycleMode();
			}
			if (Input.GetKeyDown(UIConfig.NPCInteractKeyCode))
			{
				NPCDialoguePanel npcDialoguePanel2 = _npcDialoguePanel;
				if (npcDialoguePanel2 == null || !npcDialoguePanel2.IsVisible)
				{
					RiteOfferingManager.OfferingRecord offeringRecord = _npcPromptHUD?.ActiveOffering;
					if (offeringRecord != null)
					{
						if (_riteOfferingPanel != null && !_riteOfferingPanel.IsVisible)
						{
							_riteOfferingPanel.Show(offeringRecord);
						}
					}
					else
					{
						NPCManager.NPCClientRecord nPCClientRecord = _npcPromptHUD?.ActiveNPC;
						if (nPCClientRecord != null)
						{
							CommandSender.NPCInteract(nPCClientRecord.Id);
						}
					}
				}
			}
			RiteOfferingPanel riteOfferingPanel = _riteOfferingPanel;
			if (riteOfferingPanel != null && riteOfferingPanel.IsVisible && !RiteOfferingManager.HasOffering)
			{
				_riteOfferingPanel.Hide();
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				HandleEscape();
			}
			MainMenuScreen mainMenu2 = _mainMenu;
			int num;
			if (mainMenu2 == null || !mainMenu2.IsVisible)
			{
				GOMSStatsPanel statsPanel = _statsPanel;
				if (statsPanel == null || !statsPanel.IsVisible)
				{
					InspectPlayerPanel inspectPanel = _inspectPanel;
					if (inspectPanel == null || !inspectPanel.IsVisible)
					{
						ImagePreviewPanel imagePreviewPanel = _imagePreviewPanel;
						if (imagePreviewPanel == null || !imagePreviewPanel.IsVisible)
						{
							UIDesignPanel uiDesignPanel = _uiDesignPanel;
							if (uiDesignPanel == null || !uiDesignPanel.IsVisible)
							{
								FamiliarPanel familiarPanel = _familiarPanel;
								if (familiarPanel == null || !familiarPanel.IsVisible)
								{
									ForgePanel forgePanel = _forgePanel;
									if (forgePanel == null || !forgePanel.IsVisible)
									{
										QuestPanel questPanel = _questPanel;
										if (questPanel == null || !questPanel.IsVisible)
										{
											AchievementsPanel achPanel = _achPanel;
											if (achPanel == null || !achPanel.IsVisible)
											{
												VFXPanel vfxPanel = _vfxPanel;
												if (vfxPanel == null || !vfxPanel.IsVisible)
												{
													UISettingsPanel settingsPanel = _settingsPanel;
													if (settingsPanel == null || !settingsPanel.IsVisible)
													{
														LeaderboardPanel lbPanel = _lbPanel;
														if (lbPanel == null || !lbPanel.IsVisible)
														{
															num = ((_npcDialoguePanel?.IsVisible ?? false) ? 1 : 0);
															goto IL_025f;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			num = 1;
			goto IL_025f;
			IL_025f:
			UpdateCursor((byte)num != 0);
			MainMenuScreen mainMenu3 = _mainMenu;
			if (mainMenu3 != null && mainMenu3.IsVisible && _dirtyMainMenu)
			{
				_mainMenu.Refresh();
				_dirtyMainMenu = false;
			}
			GOMSStatsPanel statsPanel2 = _statsPanel;
			if (statsPanel2 != null && statsPanel2.IsVisible && _dirtyStats)
			{
				_statsPanel.Refresh();
				_dirtyStats = false;
			}
			InspectPlayerPanel inspectPanel2 = _inspectPanel;
			if (inspectPanel2 != null && inspectPanel2.IsVisible && _dirtyInspect)
			{
				_inspectPanel.Refresh();
				_dirtyInspect = false;
			}
			FamiliarPanel familiarPanel2 = _familiarPanel;
			if (familiarPanel2 != null && familiarPanel2.IsVisible && _dirtyFamiliar)
			{
				_familiarPanel.Refresh();
				_dirtyFamiliar = false;
			}
			ForgePanel forgePanel2 = _forgePanel;
			if (forgePanel2 != null && forgePanel2.IsVisible && _dirtyForge)
			{
				_forgePanel.Refresh();
				_dirtyForge = false;
			}
			QuestPanel questPanel2 = _questPanel;
			if (questPanel2 != null && questPanel2.IsVisible && _dirtyQuest)
			{
				_questPanel.Refresh();
				_dirtyQuest = false;
			}
			AchievementsPanel achPanel2 = _achPanel;
			if (achPanel2 != null && achPanel2.IsVisible && _dirtyAchievements)
			{
				_achPanel.Refresh();
				_dirtyAchievements = false;
			}
			UISettingsPanel settingsPanel2 = _settingsPanel;
			if (settingsPanel2 != null && settingsPanel2.IsVisible && _dirtySettings)
			{
				_settingsPanel.Refresh();
				_dirtySettings = false;
			}
			LeaderboardPanel lbPanel2 = _lbPanel;
			if (lbPanel2 != null && lbPanel2.IsVisible && _dirtyLeaderboard)
			{
				_lbPanel.Refresh();
				_dirtyLeaderboard = false;
			}
			QuestPanel questPanel3 = _questPanel;
			if (questPanel3 != null && questPanel3.IsVisible)
			{
				_questPanel.TickInput();
			}
			AchievementsPanel achPanel3 = _achPanel;
			if (achPanel3 != null && achPanel3.IsVisible)
			{
				_achPanel.TickInput();
			}
			LeaderboardPanel lbPanel3 = _lbPanel;
			if (lbPanel3 != null && lbPanel3.IsVisible)
			{
				_lbPanel.TickInput();
			}
			FamiliarPanel familiarPanel3 = _familiarPanel;
			if (familiarPanel3 != null && familiarPanel3.IsVisible)
			{
				_familiarPanel.TickInput();
			}
			_hud?.Refresh();
			_eventHUD?.Refresh();
			_eventPhaseBanner?.Refresh();
			_questTrackerHUD?.Refresh();
			_notificationPopup?.Update();
			_npcPromptHUD?.Refresh();
			_timerHUD?.Tick(Time.deltaTime);
			CanvasService.ButtonUpdate();
			if (num != 0 && !_dragLocked)
			{
				CanvasService.DragUpdate();
			}
		}

		private void CreateMainMenu()
		{
			_mainMenu = new MainMenuScreen(delegate
			{
				EnsureStatsPanel();
				_inspectPanel?.Hide();
				UIData.InspectPanelOpen = false;
				_statsPanel.Show();
			}, delegate
			{
				if (_familiarPanel == null)
				{
					_familiarPanel = new FamiliarPanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_familiarPanel.Show();
			}, delegate
			{
				if (_questPanel == null)
				{
					_questPanel = new QuestPanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_questPanel.Show();
			}, delegate
			{
				if (_achPanel == null)
				{
					_achPanel = new AchievementsPanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_achPanel.Show();
			}, delegate
			{
				if (_settingsPanel == null)
				{
					_settingsPanel = new UISettingsPanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_settingsPanel.Show();
			}, delegate
			{
				if (_lbPanel == null)
				{
					_lbPanel = new LeaderboardPanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_lbPanel.Show();
			}, delegate
			{
				if (_forgePanel == null)
				{
					_forgePanel = new ForgePanel(delegate
					{
						_mainMenu?.Toggle();
					});
				}
				_forgePanel.Show();
			});
		}

		private static void EnsureStatsPanel()
		{
			if (_statsPanel == null)
			{
				_statsPanel = new GOMSStatsPanel(delegate
				{
					_mainMenu?.Toggle();
				});
			}
		}

		private static void EnsureInspectPanel()
		{
			if (_inspectPanel == null)
			{
				_inspectPanel = new InspectPlayerPanel(delegate
				{
					_inspectPanelActive = false;
					UIData.InspectPanelOpen = false;
					_inspectPanel?.Hide();
				});
			}
		}

		private static void EnsureImagePreviewPanel()
		{
			if (_imagePreviewPanel == null)
			{
				_imagePreviewPanel = new ImagePreviewPanel();
			}
		}

		private static void EnsureUIDesignPanel()
		{
			if (_uiDesignPanel == null)
			{
				_uiDesignPanel = new UIDesignPanel();
			}
		}

		private static void UpdateCursor(bool uiOpen)
		{
			//IL_003e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			InputPatches.BlockCursorLock = uiOpen;
			if (uiOpen)
			{
				if (!_cursorOverridden)
				{
					_savedLockMode = Cursor.lockState;
					_savedCursorVisible = Cursor.visible;
					_cursorOverridden = true;
				}
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				if (!_cursorOverridden)
				{
					return;
				}
				Cursor.lockState = _savedLockMode;
				Cursor.visible = _savedCursorVisible;
				_cursorOverridden = false;
				try
				{
					EventSystem current = EventSystem.current;
					if ((Object)(object)current != (Object)null)
					{
						current.SetSelectedGameObject((GameObject)null);
					}
				}
				catch
				{
				}
			}
		}

		private void HandleEscape()
		{
			RiteOfferingPanel riteOfferingPanel = _riteOfferingPanel;
			if (riteOfferingPanel != null && riteOfferingPanel.IsVisible)
			{
				_riteOfferingPanel.Hide();
				return;
			}
			NPCDialoguePanel npcDialoguePanel = _npcDialoguePanel;
			if (npcDialoguePanel != null && npcDialoguePanel.IsVisible)
			{
				_npcDialoguePanel.Hide();
				return;
			}
			InspectPlayerPanel inspectPanel = _inspectPanel;
			if (inspectPanel != null && inspectPanel.IsVisible)
			{
				_inspectPanel.Hide();
				_inspectPanelActive = false;
				UIData.InspectPanelOpen = false;
				return;
			}
			ImagePreviewPanel imagePreviewPanel = _imagePreviewPanel;
			if (imagePreviewPanel != null && imagePreviewPanel.IsVisible)
			{
				_imagePreviewPanel.Hide();
				return;
			}
			UIDesignPanel uiDesignPanel = _uiDesignPanel;
			if (uiDesignPanel != null && uiDesignPanel.IsVisible)
			{
				_uiDesignPanel.Hide();
				return;
			}
			LeaderboardPanel lbPanel = _lbPanel;
			if (lbPanel != null && lbPanel.IsVisible)
			{
				_lbPanel.Hide();
				ShowMainMenu();
				return;
			}
			UISettingsPanel settingsPanel = _settingsPanel;
			if (settingsPanel != null && settingsPanel.IsVisible)
			{
				_settingsPanel.Hide();
				ShowMainMenu();
				return;
			}
			AchievementsPanel achPanel = _achPanel;
			if (achPanel != null && achPanel.IsVisible)
			{
				_achPanel.Hide();
				ShowMainMenu();
				return;
			}
			ForgePanel forgePanel = _forgePanel;
			if (forgePanel != null && forgePanel.IsVisible)
			{
				_forgePanel.Hide();
				ShowMainMenu();
				return;
			}
			QuestPanel questPanel = _questPanel;
			if (questPanel != null && questPanel.IsVisible)
			{
				_questPanel.Hide();
				ShowMainMenu();
				return;
			}
			FamiliarPanel familiarPanel = _familiarPanel;
			if (familiarPanel != null && familiarPanel.IsVisible)
			{
				_familiarPanel.Hide();
				ShowMainMenu();
				return;
			}
			GOMSStatsPanel statsPanel = _statsPanel;
			if (statsPanel != null && statsPanel.IsVisible)
			{
				_statsPanel.Hide();
				if (_inspectPanelActive)
				{
					_inspectPanelActive = false;
					_statsPanel.ClearInspectContext();
				}
				else
				{
					ShowMainMenu();
				}
				return;
			}
			VFXPanel vfxPanel = _vfxPanel;
			if (vfxPanel != null && vfxPanel.IsVisible)
			{
				_vfxPanel.Hide();
				return;
			}
			MainMenuScreen mainMenu = _mainMenu;
			if (mainMenu != null && mainMenu.IsVisible)
			{
				_mainMenu.Hide();
			}
		}

		private void ShowMainMenu()
		{
			if (_mainMenu == null)
			{
				CreateMainMenu();
			}
			MainMenuScreen mainMenu = _mainMenu;
			if (mainMenu == null || !mainMenu.IsVisible)
			{
				_mainMenu?.Toggle();
			}
		}

		private void OnDestroy()
		{
			_mainMenu?.Dispose();
			_statsPanel?.Dispose();
			_inspectPanel?.Dispose();
			_imagePreviewPanel?.Dispose();
			_uiDesignPanel?.Dispose();
			_familiarPanel?.Dispose();
			_questPanel?.Dispose();
			_achPanel?.Dispose();
			_vfxPanel?.Dispose();
			_settingsPanel?.Dispose();
			_lbPanel?.Dispose();
			_hud?.Destroy();
			_eventHUD?.Destroy();
			_eventPhaseBanner?.Destroy();
			_questTrackerHUD?.Destroy();
			_notificationPopup?.Destroy();
			_npcPromptHUD?.Destroy();
			_npcPromptHUD = null;
			_npcDialoguePanel?.Dispose();
			_npcDialoguePanel = null;
			_mainMenu = null;
			_statsPanel = null;
			_inspectPanel = null;
			_imagePreviewPanel = null;
			_uiDesignPanel = null;
			_familiarPanel = null;
			_questPanel = null;
			_achPanel = null;
			_vfxPanel = null;
			_settingsPanel = null;
			_lbPanel = null;
			_hud = null;
			_eventHUD = null;
			_eventPhaseBanner = null;
			_questTrackerHUD = null;
			_notificationPopup = null;
			_uiReady = false;
			_dragLocked = true;
			_inspectPanelActive = false;
			_cursorOverridden = false;
			MarkAllPanelsDirty();
			InputPatches.BlockCursorLock = false;
		}
	}
	public static class UIConfig
	{
		private class SavedSettings
		{
			public bool ShowXPBar { get; set; } = true;

			public bool ShowClassHUD { get; set; } = true;

			public bool ShowFamiliarStatus { get; set; } = true;

			public bool ShowNotifications { get; set; } = true;

			public bool ShowEventHUD { get; set; } = true;

			public bool ShowQuestTracker { get; set; } = true;

			public bool ShowSystemFeed { get; set; } = true;

			public bool SuppressFamCommands { get; set; } = true;

			public float UIScale { get; set; } = 1f;

			public float UIPanelOpacity { get; set; } = 0.92f;
		}

		public static bool ShowXPBar = true;

		public static bool ShowClassHUD = true;

		public static bool ShowFamiliarStatus = true;

		public static bool ShowNotifications = true;

		public static bool ShowEventHUD = true;

		public static bool ShowQuestTracker = true;

		public static bool ShowSystemFeed = true;

		public static bool UILocked = true;

		public static bool SuppressFamCommands = true;

		public static float UIScale = 1f;

		public static float UIPanelOpacity = 0.92f;

		public static KeyCode NPCInteractKeyCode = (KeyCode)284;

		private static string SettingsPath => Path.Combine(Paths.ConfigPath, "OrdainUI_Settings.json");

		public static string NPCInteractKey
		{
			get
			{
				//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_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Invalid comparison between Unknown and I4
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Invalid comparison between Unknown and I4
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Expected I4, but got Unknown
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Invalid comparison between Unknown and I4
				KeyCode nPCInteractKeyCode = NPCInteractKeyCode;
				if ((int)nPCInteractKeyCode <= 103)
				{
					if ((int)nPCInteractKeyCode == 101)
					{
						return "E";
					}
					if ((int)nPCInteractKeyCode == 103)
					{
						return "G";
					}
				}
				else
				{
					if ((int)nPCInteractKeyCode == 116)
					{
						return "T";
					}
					switch (nPCInteractKeyCode - 282)
					{
					case 0:
						return "F1";
					case 1:
						return "F2";
					case 2:
						return "F3";
					case 3:
						return "F4";
					case 4:
						return "F5";
					case 8:
						return "F9";
					case 9:
						return "F10";
					}
				}
				return ((object)Unsafe.As<KeyCode, KeyCode>(ref NPCInteractKeyCode)/*cast due to .constrained prefix*/).ToString();
			}
		}

		public static void Load()
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			try
			{
				if (File.Exists(SettingsPath))
				{
					SavedSettings savedSettings = JsonSerializer.Deserialize<SavedSettings>(File.ReadAllText(SettingsPath));
					if (savedSettings != null)
					{
						ShowXPBar = savedSettings.ShowXPBar;
						ShowClassHUD = savedSettings.ShowClassHUD;
						ShowFamiliarStatus = savedSettings.ShowFamiliarStatus;
						ShowNotifications = savedSettings.ShowNotifications;
						ShowEventHUD = savedSettings.ShowEventHUD;
						ShowQuestTracker = savedSettings.ShowQuestTracker;
						ShowSystemFeed = savedSettings.ShowSystemFeed;
						SuppressFamCommands = savedSettings.SuppressFamCommands;
						UIScale = savedSettings.UIScale;
						UIPanelOpacity = savedSettings.UIPanelOpacity;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OrdainUI] Failed to load settings: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val);
			}
		}

		public static void Save()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			try
			{
				SavedSettings value = new SavedSettings
				{
					ShowXPBar = ShowXPBar,
					ShowClassHUD = ShowClassHUD,
					ShowFamiliarStatus = ShowFamiliarStatus,
					ShowNotifications = ShowNotifications,
					ShowEventHUD = ShowEventHUD,
					ShowQuestTracker = ShowQuestTracker,
					ShowSystemFeed = ShowSystemFeed,
					SuppressFamCommands = SuppressFamCommands,
					UIScale = UIScale,
					UIPanelOpacity = UIPanelOpacity
				};
				File.WriteAllText(SettingsPath, JsonSerializer.Serialize(value));
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OrdainUI] Failed to save settings: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val);
			}
		}
	}
	public static class UIData
	{
		public class BoxInfo
		{
			public string Name;

			public int Count;

			public int Max = 10;
		}

		public class FamiliarListEntry
		{
			public int Index;

			public string Name;

			public string Rarity;

			public bool IsShiny;

			public int Level;

			public bool IsActive;
		}

		public class TriviaScore
		{
			public string Name;

			public int Score;
		}

		public class PartyMember
		{
			public string Name;

			public string ClassName;

			public float HP;

			public float MaxHP;

			public bool IsDead;

			public bool IsDisconnected;
		}

		public class LBEntry
		{
			public int Rank { get; set; }

			public string Name { get; set; }

			public string Value { get; set; }
		}

		public class LeaderboardData
		{
			public string BoardType = "";

			public List<LBEntry> Entries = new List<LBEntry>();

			public LBEntry PlayerEntry;

			public bool Loading;
		}

		public class QuestEntry
		{
			public string Id;

			public string Category;

			public string Status;

			public string Title;

			public string Description;

			public string Requirements;

			public string Location;

			public string RewardPreview;

			public int Progress;

			public int Required;

			public bool Completed;

			public bool Claimed;

			public bool CanClaim;
		}

		public class QuestHistoryEntry
		{
			public string Timestamp;

			public string Message;
		}

		public class AchievementEntry
		{
			public string Id;

			public string Title;

			public string Description;

			public string Category;

			public int Tier;

			public bool Secret;

			public bool AdminOnly;

			public int Required;

			public int Points;

			public long Progress;

			public bool Unlocked;
		}

		public class ParagonPerkEntry
		{
			public string Key;

			public string Name;

			public string Alias;

			public int Rank;

			public int MaxRank;

			public int NextCost;

			public string NextDescription;
		}

		public static class Forge
		{
			public static bool HasWeapon = false;

			public static string WeaponId = "";

			public static string WeaponName = "";

			public static List<ForgeNode> Nodes = new List<ForgeNode>();
		}

		public class ForgeNode
		{
			public int Slot;

			public int Guid;

			public string Name = "";

			public float Cooldown;

			public bool Selected;
		}

		public static string PlayerName = "";

		public static string EventDisplayName = "None Currently Active";

		public static string QuestDisplayName = "To Be Added Later";

		public static string ServerTimeText = "--:--";

		public static bool HasActiveStoryQuest = false;

		public static string StoryQuestId = "";

		public static string StoryQuestTitle = "";

		public static string StoryStepText = "";

		public static int StoryStepProgress = 0;

		public static int StoryStepRequired = 1;

		public static string StoryRewardPreview = "";

		public static int StoryCompletedCount = 0;

		public static int StoryClaimableCount = 0;

		public static bool HasStoryTargetNpc = false;

		public static string StoryTargetNpcId = "";

		public static string StoryTargetNpcName = "";

		public static string StoryTargetNpcStage = "";

		public static float StoryTargetNpcSpawnRange = 0f;

		public static string DailyResetText = "";

		public static string WeeklyResetText = "";

		public static List<QuestEntry> StoryQuests = new List<QuestEntry>();

		public static List<QuestEntry> DailyQuests = new List<QuestEntry>();

		public static List<QuestEntry> WeeklyQuests = new List<QuestEntry>();

		public static List<QuestEntry> EventQuests = new List<QuestEntry>();

		public static List<QuestEntry> CompletedQuests = new List<QuestEntry>();

		public const int MaxQuestHistoryEntries = 5;

		public static List<QuestHistoryEntry> QuestHistory = new List<QuestHistoryEntry>();

		public static int AchievementCatalogCount = 0;

		public static int AchievementCatalogHash = 0;

		public static int AchievementPoints = 0;

		public static int AchievementUnlockedCount = 0;

		public static int AchievementTotalCount = 0;

		public static int EventPoints = 0;

		public static int EventWins = 0;

		public static int EventParticipations = 0;

		public static Dictionary<string, AchievementEntry> Achievements = new Dictionary<string, AchievementEntry>(StringComparer.OrdinalIgnoreCase);

		public static LeaderboardData Leaderboard = new LeaderboardData();

		public static bool InspectPanelOpen = false;

		public static string InspectName = "";

		public static string InspectPortraitKey = "";

		public static string InspectTitle = "";

		public static string InspectTitleColor = "#FFD700";

		public static string InspectClassName = "None";

		public static int InspectLevel = 0;

		public static int InspectParagonLevel = 0;

		public static int InspectLevelRank = 0;

		public static int InspectVBloodRank = 0;

		public static int InspectMonsterRank = 0;

		public static int InspectWorldFirstRank = 0;

		public static int InspectFamiliarRank = 0;

		public static int InspectEventPointsRank = 0;

		public static int InspectEventWinsRank = 0;

		public static int InspectVBloodKills = 0;

		public static long InspectMonsterKills = 0L;

		public static int InspectWorldFirsts = 0;

		public static int InspectFamiliarsUnlocked = 0;

		public static int InspectEventPoints = 0;

		public static int InspectEventWins = 0;

		public static int InspectEventParticipations = 0;

		public static int Level = 0;

		public static float Experience = 0f;

		public static float ExperienceNeeded = 100f;

		public static int GearScore = 0;

		public static int UnspentAP = 0;

		public static bool IsParagon = false;

		public static int ParagonLevel = 0;

		public static int StatSTR = 0;

		public static int StatINT = 0;

		public static int StatDEX = 0;

		public static int StatLUK = 0;

		public static int StatCD = 0;

		public static int StatMS = 0;

		public static int StatHP = 0;

		public static int StatBE = 0;

		public static float AppliedPhysicalPower = 0f;

		public static float AppliedPhysicalLifeLeech = 0f;

		public static float AppliedSpellPower = 0f;

		public static float AppliedSpellLifeLeech = 0f;

		public static float AppliedAttackSpeed = 0f;

		public static float AppliedPhysicalCritChance = 0f;

		public static float AppliedSpellCritChance = 0f;

		public static float AppliedPhysicalCritDamage = 0f;

		public static float AppliedSpellCritDamage = 0f;

		public static float AppliedMovementSpeed = 0f;

		public static float AppliedMaxHealth = 0f;

		public static long IronBars = -1L;

		public static float AppliedReducedBloodDrain = 0f;

		public static float ParagonXP = 0f;

		public static float ParagonXPNeeded = 0f;

		public static int ParagonUnspentPoints = 0;

		public static int ParagonSpentPoints = 0;

		public static int ParagonMaxLevel = 300;

		public static Dictionary<string, ParagonPerkEntry> ParagonPerks = new Dictionary<string, ParagonPerkEntry>(StringComparer.OrdinalIgnoreCase);

		public static string ClassName = "None";

		public static string ClassTitle = "";

		public static string ClassPassive = "";

		public static string ClassAscendance = "";

		public static int Stacks = 0;

		public static int MaxStacks = 100;

		public static bool AscendanceActive = false;

		public static int AscendanceCooldown = 0;

		public static bool AscendanceLocked = false;

		public static string FamiliarName = "";

		public static string FamiliarRarity = "Common";

		public static bool FamiliarIsShiny = false;

		public static int FamiliarLevel = 0;

		public static float FamiliarHP = 0f;

		public static float FamiliarMaxHP = 100f;

		public static bool FamiliarActive = false;

		public static int FamiliarBondLevel = 1;

		public static string FamiliarBondName = "Stranger";

		public static string FamiliarMode = "";

		public static int FamiliarUnspentAP = 0;

		public static int FamiliarHPAlloc = 0;

		public static int FamiliarPhysAlloc = 0;

		public static int FamiliarSpellAlloc = 0;

		public static float FamiliarXP = 0f;

		public static float FamiliarXPNext = 100f;

		public static bool FamiliarEverstone = false;

		public static string ActiveBoxName = "";

		public static List<BoxInfo> Boxes = new List<BoxInfo>();

		public static List<FamiliarListEntry> FamiliarList = new List<FamiliarListEntry>();

		public static string EventName = "";

		public static string EventState = "";

		public static string EventPhase = "";

		public static float EventPhaseTimer = 0f;

		public static int EventActivePlayers = 0;

		public static int EventEliminatedPlayers = 0;

		public static string EventPlayerStatus = "";

		public static bool InEvent = false;

		public static string TriviaQuestion = "";

		public static int TriviaRound = 0;

		public static int TriviaTotalRounds = 0;

		public static List<TriviaScore> TriviaScores = new List<TriviaScore>();

		public static string DungeonName = "";

		public static int DungeonRoom = 0;

		public static int DungeonTotalRooms = 0;

		public static string DungeonRoomType = "";

		public static float DungeonTime = 0f;

		public static bool InDungeon = false;

		public static string BossName = "";

		public static float BossHP = 0f;

		public static float BossMaxHP = 0f;

		public static bool BossActive = false;

		public static List<PartyMember> Party = new List<PartyMember>();

		public static void AddQuestHistory(string message)
		{
			if (string.IsNullOrWhiteSpace(message))
			{
				return;
			}
			string text = message.Trim();
			if (QuestHistory.Count <= 0 || !string.Equals(QuestHistory[0].Message, text, StringComparison.Ordinal))
			{
				QuestHistory.Insert(0, new QuestHistoryEntry
				{
					Timestamp = DateTime.Now.ToString("HH:mm", CultureInfo.InvariantCulture),
					Message = text
				});
				if (QuestHistory.Count > 5)
				{
					QuestHistory.RemoveRange(5, QuestHistory.Count - 5);
				}
			}
		}
	}
	public static class UIStyles
	{
		private const float TEXT_SCALE = 1.08f;

		public static readonly Color PanelBG = new Color(0.1f, 0.1f, 0.18f, 0.9f);

		public static readonly Color PanelBorder = new Color(0.16f, 0.16f, 0.3f, 1f);

		public static readonly Color HeaderBG = new Color(0.12f, 0.12f, 0.22f, 0.95f);

		public static readonly Color ButtonNormal = new Color(0.18f, 0.18f, 0.3f, 1f);

		public static readonly Color ButtonHover = new Color(0.25f, 0.25f, 0.4f, 1f);

		public static readonly Color TextPrimary = Color.white;

		public static readonly Color TextSecondary = new Color(0.62f, 0.62f, 0.62f, 1f);

		public static readonly Color TextGold = new Color(1f, 0.84f, 0f, 1f);

		public static readonly Color TextDanger = new Color(1f, 0.27f, 0.27f, 1f);

		public static readonly Color TextSuccess = new Color(0.27f, 1f, 0.27f, 1f);

		public static readonly Color TextPink = new Color(1f, 0.41f, 0.71f, 1f);

		public static readonly Color BarBG = new Color(0.2f, 0.2f, 0.2f, 0.8f);

		public static readonly Color BarBorder = new Color(0.3f, 0.3f, 0.3f, 1f);

		public static readonly Color Blood = new Color(1f, 0f, 0f, 1f);

		public static readonly Color Chaos = new Color(0.61f, 0.19f, 1f, 1f);

		public static readonly Color Frost = new Color(0f, 0.5f, 1f, 1f);

		public static readonly Color Storm = new Color(1f, 0.84f, 0f, 1f);

		public static readonly Color Illusion = new Color(0f, 1f, 1f, 1f);

		public static readonly Color Unholy = new Color(0f, 1f, 0f, 1f);

		public static readonly Color Common = new Color(0.7f, 0.7f, 0.7f, 1f);

		public static readonly Color Uncommon = new Color(0.12f, 0.8f, 0.12f, 1f);

		public static readonly Color Rare = new Color(0.25f, 0.5f, 1f, 1f);

		public static readonly Color Epic = new Color(0.64f, 0.21f, 0.93f, 1f);

		public static readonly Color Legendary = new Color(1f, 0.84f, 0f, 1f);

		private static Texture2D _whiteTex;

		private static Texture2D _barBGTex;

		private static bool _initialized = false;

		public static void Initialize()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!_initialized)
			{
				_whiteTex = MakeTex(2, 2, Color.white);
				_barBGTex = MakeTex(2, 2, BarBG);
				_initialized = true;
			}
		}

		public static void DrawText(Rect rect, string text, Color color, int fontSize = 13, bool bold = false, bool centered = false)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle label = GUI.skin.label;
			Color textColor = label.normal.textColor;
			int fontSize2 = label.fontSize;
			FontStyle fontStyle = label.fontStyle;
			TextAnchor alignment = label.alignment;
			label.normal.textColor = color;
			label.fontSize = Mathf.Max(9, Mathf.RoundToInt((float)fontSize * 1.08f));
			label.fontStyle = (FontStyle)(bold ? 1 : 0);
			label.alignment = (TextAnchor)(centered ? 4 : 3);
			GUI.Label(rect, text);
			label.normal.textColor = textColor;
			label.fontSize = fontSize2;
			label.fontStyle = fontStyle;
			label.alignment = alignment;
		}

		public static bool DrawButton(Rect rect, string text, Color textColor = default(Color))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (textColor == default(Color))
			{
				textColor = TextPrimary;
			}
			DrawRect(rect, ButtonNormal);
			DrawBorder(rect, PanelBorder);
			if (((Rect)(ref rect)).Contains(Event.current.mousePosition))
			{
				DrawRect(rect, ButtonHover);
			}
			DrawText(rect, text, textColor, 13, bold: false, centered: true);
			if ((int)Event.current.type == 0 && ((Rect)(ref rect)).Contains(Event.current.mousePosition))
			{
				Event.current.Use();
				return true;
			}
			return false;
		}

		public static void DrawBar(Rect rect, float fillPercent, Color fillColor)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Initialize();
			GUI.DrawTexture(rect, (Texture)(object)_barBGTex);
			if (fillPercent > 0f)
			{
				Rect val = new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, (((Rect)(ref rect)).width - 2f) * Mathf.Clamp01(fillPercent), ((Rect)(ref rect)).height - 2f);
				Color color = GUI.color;
				GUI.color = fillColor;
				GUI.DrawTexture(val, (Texture)(object)_whiteTex);
				GUI.color = color;
			}
			DrawBorder(rect, BarBorder);
		}

		public static void DrawRect(Rect rect, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Initialize();
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
			GUI.color = color2;
		}

		public static void DrawBorder(Rect rect, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Initialize();
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_whiteTex);
			GUI.color = color2;
		}

		public static Color GetClassColor(string className)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (className == null)
			{
				return TextPrimary;
			}
			string text = className.ToLowerInvariant();
			if (text.StartsWith("blood"))
			{
				return Blood;
			}
			if (text.StartsWith("chaos"))
			{
				return Chaos;
			}
			if (text.StartsWith("frost"))
			{
				return Frost;
			}
			if (text.StartsWith("storm"))
			{
				return Storm;
			}
			if (text.StartsWith("illusion"))
			{
				return Illusion;
			}
			if (text.StartsWith("unholy"))
			{
				return Unholy;
			}
			return TextPrimary;
		}

		private static Texture2D MakeTex(int width, int height, Color color)
		{
			//IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ordain.ui";

		public const string PLUGIN_NAME = "OrdainUI";

		public const string PLUGIN_VERSION = "0.2.1";
	}
	[BepInPlugin("ordain.ui", "OrdainUI", "0.2.1")]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		public static readonly bool VerboseLogs;

		internal static Plugin Instance { get; private set; }

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

		public static void Verbose(string msg)
		{
			if (VerboseLogs)
			{
				Logger.LogInfo((object)msg);
			}
		}

		public override void Load()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			UIConfig.Load();
			Instance = this;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (Application.productName == "VRisingServer")
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OrdainUI");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is a client mod — skipping on server.");
				}
				log.LogInfo(val);
				return;
			}
			ClassInjector.RegisterTypeInIl2Cpp<OrdainUIBehaviour>();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OrdainUI");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.2.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded on client!");
			}
			log2.LogInfo(val);
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
}
namespace OrdainUI.Services
{
	internal static class ItemIdentityPatcher
	{
		private static readonly Dictionary<int, (string name, string desc)> _pending = new Dictionary<int, (string, string)>();

		private static bool _hasPending = false;

		private static readonly Dictionary<int, LocalizedStringBuilderBase> _origDesc = new Dictionary<int, LocalizedStringBuilderBase>();

		public static void SetIdentities(Dictionary<int, (string name, string desc)> identities)
		{
			_pending.Clear();
			foreach (KeyValuePair<int, (string, string)> identity in identities)
			{
				_pending[identity.Key] = identity.Value;
			}
			_hasPending = true;
			Apply();
		}

		public static void Apply()
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (!_hasPending)
			{
				return;
			}
			ManagedDataRegistry registry = GetRegistry();
			if (registry == null)
			{
				return;
			}
			Dictionary<AssetGuid, string> localizedStrings = Localization._LocalizedStrings;
			if (localizedStrings == null)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			PrefabGUID val = default(PrefabGUID);
			bool flag = default(bool);
			foreach (var (num4, tuple2) in _pending)
			{
				try
				{
					((PrefabGUID)(ref val))..ctor(num4);
					ManagedItemData orDefault = registry.GetOrDefault<ManagedItemData>(val, (ManagedItemData)null);
					if (orDefault == null)
					{
						num2++;
						continue;
					}
					if (!string.IsNullOrEmpty(tuple2.Item1))
					{
						AssetGuid key = orDefault.Name.Key;
						localizedStrings[key] = tuple2.Item1;
						num++;
					}
					if (!string.IsNullOrEmpty(tuple2.Item2))
					{
						_origDesc.TryAdd(num4, orDefault.Description);
						AssetGuid val2 = AssetGuid.FromString(Guid.NewGuid().ToString());
						localizedStrings[val2] = tuple2.Item2;
						LocalizedStringBuilderBase description = orDefault.Description;
						description.Key = new LocalizationKey(val2);
						orDefault.Description = description;
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = OrdainUI.Core.Core.Log;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[OrdainUI:Identity] Failed for ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num4);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val3);
					num2++;
				}
			}
			ManualLogSource log2 = OrdainUI.Core.Core.Log;
			BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(52, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[OrdainUI:Identity] Applied ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" identit(ies), ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num2);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" skipped.");
			}
			log2.LogDebug(val4);
		}

		public static void Restore()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			ManagedDataRegistry registry = GetRegistry();
			if (registry != null)
			{
				foreach (var (num2, description) in _origDesc)
				{
					try
					{
						ManagedItemData orDefault = registry.GetOrDefault<ManagedItemData>(new PrefabGUID(num2), (ManagedItemData)null);
						if (orDefault != null)
						{
							orDefault.Description = description;
						}
					}
					catch
					{
					}
				}
			}
			_origDesc.Clear();
			try
			{
				Localization.LoadDefaultLanguage();
			}
			catch
			{
			}
		}

		private static ManagedDataRegistry GetRegistry()
		{
			try
			{
				World world = OrdainUI.Core.Core.World;
				object result;
				if (world == null)
				{
					result = null;
				}
				else
				{
					ManagedDataSystem existingSystemManaged = world.GetExistingSystemManaged<ManagedDataSystem>();
					result = ((existingSystemManaged != null) ? ((ManagedDataSystem_Base)existingSystemManaged).ManagedDataRegistry : null);
				}
				return (ManagedDataRegistry)result;
			}
			catch
			{
				return null;
			}
		}
	}
	internal class CanvasService
	{
		private struct ButtonEntry
		{
			public RectTransform Rect;

			public Image Bg;

			public Color Normal;

			public Color Hover;

			public Action OnClick;
		}

		private struct DragEntry
		{
			public RectTransform Root;

			public RectTransform Handle;
		}

		private const float TEXT_SCALE = 1.08f;

		private static TMP_FontAsset _nocturneSerifFont;

		private static DateTime _nextNocturneLookupUtc = DateTime.MinValue;

		private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

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

		public static readonly Color BG_DARK = new Color(0.08f, 0.06f, 0.1f, 0.95f);

		public static readonly Color BG_PANEL = new Color(0.12f, 0.1f, 0.14f, 0.92f);

		public static readonly Color BG_HEADER = new Color(0.15f, 0.08f, 0.08f, 0.95f);

		public static readonly Color ACCENT_RED = new Color(0.7f, 0.15f, 0.15f, 1f);

		public static readonly Color ACCENT_GOLD = new Color(0.9f, 0.77f, 0.42f, 1f);

		public static readonly Color TEXT_PRIMARY = new Color(0.95f, 0.93f, 0.88f, 1f);

		public static readonly Color TEXT_SECONDARY = new Color(0.76f, 0.73f, 0.68f, 1f);

		public static readonly Color TEXT_DISABLED = new Color(0.52f, 0.5f, 0.46f, 1f);

		public static readonly Color BORDER_COLOR = new Color(0.55f, 0.24f, 0.24f, 0.82f);

		public static readonly Color BTN_NORMAL = new Color(0.14f, 0.12f, 0.16f, 0.85f);

		public static readonly Color BTN_HOVER = new Color(0.3f, 0.16f, 0.16f, 0.92f);

		public static readonly Color CLASS_BLOOD = new Color(1f, 0f, 0f, 1f);

		public static readonly Color CLASS_CHAOS = new Color(0.61f, 0.19f, 1f, 1f);

		public static readonly Color CLASS_FROST = new Color(0f, 0.5f, 1f, 1f);

		public static readonly Color CLASS_STORM = new Color(1f, 0.84f, 0f, 1f);

		public static readonly Color CLASS_ILLUSION = new Color(0f, 1f, 1f, 1f);

		public static readonly Color CLASS_UNHOLY = new Color(0f, 1f, 0f, 1f);

		public static readonly List<GameObject> RootWindows = new List<GameObject>();

		private static readonly Dictionary<GameObject, int> _windowOrders = new Dictionary<GameObject, int>();

		public static Canvas GameCanvasStatic;

		private static readonly List<ButtonEntry> _buttons = new List<ButtonEntry>();

		private static Vector2 _lastMousePosition = new Vector2(float.MinValue, float.MinValue);

		private static readonly List<DragEntry> _draggables = new List<DragEntry>();

		private static RectTransform _dragging;

		private static Vector2 _lastMouse;

		public UICanvasBase CanvasBase { get; private set; }

		public Canvas BottomBarCanvas { get; private set; }

		public int GameLayer { get; private set; }

		public CanvasService(UICanvasBase canvas)
		{
			CanvasBase = canvas;
			BottomBarCanvas = ((Component)canvas.BottomBarParent).gameObject.GetComponent<Canvas>();
			GameCanvasStatic = BottomBarCanvas;
			GameLayer = ((Component)BottomBarCanvas).gameObject.layer;
			Plugin.Verbose($"[OrdainUI] CanvasService initialized. Layer: {GameLayer}");
		}

		public GameObject CreateRootWindow(string name, float width, float height, int sortOrder = 100, bool aboveNativeUI = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OrdainUI_" + name);
			RootWindows.Add(val);
			_windowOrders[val] = sortOrder;
			val.layer = GameLayer;
			Object.DontDestroyOnLoad((Object)(object)val);
			SceneManager.MoveGameObjectToScene(val, SceneManager.GetSceneByName("VRisingWorld"));
			val.transform.SetParent(((Component)BottomBarCanvas).transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.5f, 0.5f);
			obj.anchorMax = new Vector2(0.5f, 0.5f);
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.sizeDelta = new Vector2(width, height);
			obj.anchoredPosition = Vector2.zero;
			Canvas val2 = val.AddComponent<Canvas>();
			if (aboveNativeUI)
			{
				val2.overrideSorting = true;
				val2.sortingOrder = sortOrder;
			}
			val.AddComponent<GraphicRaycaster>();
			ReorderWindowSiblings();
			((Graphic)val.AddComponent<Image>()).color = BG_DARK;
			return val;
		}

		private static void ReorderWindowSiblings()
		{
			foreach (GameObject item in (from w in RootWindows
				where (Object)(object)w != (Object)null && _windowOrders.ContainsKey(w)
				orderby _windowOrders[w]
				select w).ToList())
			{
				item.transform.SetAsLastSibling();
			}
		}

		public static GameObject CreatePanel(Transform parent, string name, float x, float y, float width, float height, Color? color = null)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			GameObject val = new GameObject("Panel_" + name);
			val.transform.SetParent(parent, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.anchoredPosition = new Vector2(x, 0f - y);
			obj.sizeDelta = new Vector2(width, height);
			((Graphic)val.AddComponent<Image>()).color = (Color)(((??)color) ?? BG_PANEL);
			return val;
		}

		public static GameObject CreateText(Transform parent, string name, string text, float x, float y, float width, float height, float fontSize = 14f, Color? color = null, TextAlignmentOptions alignment = (TextAlignmentOptions)257, bool applyNocturneFont = true)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00b2: 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)
			//IL_00e7: Expected O, but got Unknown
			GameObject val = new GameObject("Text_" + name);
			val.transform.SetParent(parent, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.anchoredPosition = new Vector2(x, 0f - y);
			obj.sizeDelta = new Vector2(width, height);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = Mathf.Max(8f, fontSize * 1.08f);
			((Graphic)val2).color = (Color)(((??)color) ?? TEXT_PRIMARY);
			((TMP_Text)val2).alignment = alignment;
			((TMP_Text)val2).enableWordWrapping = true;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
			if (applyNocturneFont)
			{
				TryApplyNocturneSerifFont(val2);
			}
			return val;
		}

		public static bool TryApplyNocturneSerifFont(TextMeshProUGUI target)
		{
			if ((Object)(object)target == (Object)null)
			{
				return false;
			}
			TMP_FontAsset val = ResolveNocturneSerifFont();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			((TMP_Text)target).font = val;
			target.UpdateFontAsset();
			return true;
		}

		private static TMP_FontAsset ResolveNocturneSerifFont()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			if ((Object)(object)_nocturneSerifFont != (Object)null)
			{
				return _nocturneSerifFont;
			}
			if (DateTime.UtcNow < _nextNocturneLookupUtc)
			{
				return null;
			}
			_nextNocturneLookupUtc = DateTime.UtcNow.AddSeconds(5.0);
			TMP_FontAsset val = null;
			try
			{
				TMP_FontAsset[] array = Il2CppArrayBase<TMP_FontAsset>.op_Implicit(Resources.FindObjectsOfTypeAll<TMP_FontAsset>());
				foreach (TMP_FontAsset val2 in array)
				{
					if ((Object)(object)val2 == (Object)null || string.IsNullOrWhiteSpace(((Object)val2).name))
					{
						continue;
					}
					string name = ((Object)val2).name;
					bool flag = name.IndexOf("Nocturne", StringComparison.OrdinalIgnoreCase) >= 0;
					bool flag2 = name.IndexOf("Serif", StringComparison.OrdinalIgnoreCase) >= 0;
					if (flag)
					{
						if ((Object)(object)val == (Object)null)
						{
							val = val2;
						}
						if (flag2)
						{
							_nocturneSerifFont = val2;
							break;
						}
					}
				}
				if (_nocturneSerifFont == null)
				{
					_nocturneSerifFont = val;
				}
				if ((Object)(object)_nocturneSerifFont != (Object)null)
				{
					Plugin.Verbose("[OrdainUI:Font] Found test font asset: " + ((Object)_nocturneSerifFont).name);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag3 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag3);
				if (flag3)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[OrdainUI:Font] Lookup failed: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val3);
				_nocturneSerifFont = null;
			}
			return _nocturneSerifFont;
		}

		public static GameObject CreateButton(Transform parent, string name, string label, float x, float y, float width, float height, Action onClick, float fontSize = 14f, Color? bgColor = null, Color? textColor = null, Color? hoverColor = null, bool applyNocturneFont = true)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			GameObject val = new GameObject("Button_" + name);
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0f, 1f);
			val2.anchorMax = new Vector2(0f, 1f);
			val2.pivot = new Vector2(0f, 1f);
			val2.anchoredPosition = new Vector2(x, 0f - y);
			val2.sizeDelta = new Vector2(width, height);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = (Color)(((??)bgColor) ?? BTN_NORMAL);
			CreateText(val.transform, name + "_Label", label, 8f, 0f, width - 16f, height, fontSize, (Color)(((??)textColor) ?? TEXT_PRIMARY), (TextAlignmentOptions)4097, applyNocturneFont);
			RegisterButton(val2, val3, (Color)(((??)bgColor) ?? BTN_NORMAL), (Color)(((??)hoverColor) ?? BTN_HOVER), onClick);
			return val;
		}

		public static GameObject CreateCloseButton(Transform parent, float parentWidth, Action onClose)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			float num = 28f;
			float num2 = 6f;
			return CreateButton(parent, "Close", "X", parentWidth - num - num2, num2, num, num, onClose, 16f, (Color?)new Color(0.5f, 0.1f, 0.1f, 0.8f), (Color?)Color.white, (Color?)new Color(0.7f, 0.15f, 0.15f, 1f), applyNocturneFont: false);
		}

		public static GameObject CreateDivider(Transform parent, string name, float x, float y, float width, float thickness = 1f, Color? color = null)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			GameObject val = new GameObject("Divider_" + name);
			val.transform.SetParent(parent, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.anchoredPosition = new Vector2(x, 0f - y);
			obj.sizeDelta = new Vector2(width, thickness);
			((Graphic)val.AddComponent<Image>()).color = (Color)(((??)color) ?? BORDER_COLOR);
			return val;
		}

		public static GameObject CreateImage(Transform parent, string name, float x, float y, float width, float height, Sprite sprite = null, Color? tint = null, bool preserveAspect = true, bool raycastTarget = false)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			GameObject val = new GameObject("Image_" + name);
			val.transform.SetParent(parent, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.anchoredPosition = new Vector2(x, 0f - y);
			obj.sizeDelta = new Vector2(width, height);
			Image obj2 = val.AddComponent<Image>();
			obj2.sprite = sprite;
			((Graphic)obj2).color = (Color)(((??)tint) ?? Color.white);
			obj2.preserveAspect = preserveAspect;
			((Graphic)obj2).raycastTarget = raycastTarget;
			return val;
		}

		public static Sprite LoadSpriteFromModImages(string relativePath, float pixelsPerUnit = 100f)
		{
			if (string.IsNullOrWhiteSpace(relativePath))
			{
				return null;
			}
			if (Path.IsPathRooted(relativePath))
			{
				return LoadSpriteFromFile(relativePath, pixelsPerUnit);
			}
			string text = relativePath.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
			text = text.TrimStart(Path.DirectorySeparatorChar);
			List<string> imageRootCandidates = GetImageRootCandidates();
			for (int i = 0; i < imageRootCandidates.Count; i++)
			{
				Sprite val = LoadSpriteFromFile(Path.Combine(imageRootCandidates[i], text), pixelsPerUnit);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			string item = "MISSING::" + text;
			if (_missingSpriteLog.Add(item))
			{
				Plugin.Verbose("[OrdainUI:Image] Missing '" + text + "'. Searched roots: " + string.Join(" | ", imageRootCandidates));
			}
			return null;
		}

		public static Sprite LoadSpriteFromFile(string path, float pixelsPerUnit = 100f)
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(path))
			{
				return null;
			}
			string fullPath;
			try
			{
				fullPath = Path.GetFullPath(path);
			}
			catch
			{
				return null;
			}
			if (_spriteCache.TryGetValue(fullPath, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if (!File.Exists(fullPath))
			{
				return null;
			}
			try
			{
				byte[] array = File.ReadAllBytes(fullPath);
				if (array == null || array.Length == 0)
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array), false))
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), Mathf.Max(1f, pixelsPerUnit));
				((Object)val2).name = "OrdainUI_" + Path.GetFileNameWithoutExtension(fullPath);
				_spriteCache[fullPath] = val2;
				return val2;
			}
			catch (Exception ex)
			{
				if (_missingSpriteLog.Add(fullPath))
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[OrdainUI:Image] Failed to load sprite '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(fullPath);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("': ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val3);
				}
				return null;
			}
		}

		public static string GetModImageRootPath()
		{
			try
			{
				string text = Path.Combine(Paths.ConfigPath, "GOMS.Ordain", "Images");
				Directory.CreateDirectory(text);
				return text;
			}
			catch
			{
			}
			return Path.Combine(Environment.CurrentDirectory, "BepInEx", "config", "GOMS.Ordain", "Images");
		}

		private static string GetUIConfigImageRootPath()
		{
			try
			{
				string text = Path.Combine(Paths.ConfigPath, "ordain.ui", "Images");
				Directory.CreateDirectory(text);
				return text;
			}
			catch
			{
			}
			return Path.Combine(Environment.CurrentDirectory, "BepInEx", "config", "ordain.ui", "Images");
		}

		private static List<string> GetImageRootCandidates()
		{
			List<string> list = new List<string>(6);
			list.Add(GetLegacyPluginImageRootPath());
			list.Add(Path.Combine(Environment.CurrentDirectory, "BepInEx", "plugins", "OrdainUI", "Images"));
			list.Add(GetModImageRootPath());
			list.Add(GetUIConfigImageRootPath());
			list.Add(Path.Combine(Environment.CurrentDirectory, "BepInEx", "config", "GOMS.Ordain", "Images"));
			list.Add(Path.Combine(Environment.CurrentDirectory, "BepInEx", "config", "ordain.ui", "Images"));
			List<string> list2 = list;
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			for (int num = list2.Count - 1; num >= 0; num--)
			{
				string text = list2[num];
				if (string.IsNullOrWhiteSpace(text))
				{
					list2.RemoveAt(num);
					continue;
				}
				string fullPath;
				try
				{
					fullPath = Path.GetFullPath(text);
				}
				catch
				{
					list2.RemoveAt(num);
					continue;
				}
				if (!hashSet.Add(fullPath))
				{
					list2.RemoveAt(num);
				}
				else
				{
					list2[num] = fullPath;
				}
			}
			return list2;
		}

		private static string GetLegacyPluginImageRootPath()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				if (!string.IsNullOrWhiteSpace(directoryName))
				{
					return Path.Combine(directoryName, "Images");
				}
			}
			catch
			{
			}
			return Path.Combine(Environment.CurrentDirectory, "BepInEx", "plugins", "OrdainUI", "Images");
		}

		public static GameObject CreateBar(Transform parent, string name, float x, float y, float width, float height, Color fillColor, float fillPercent = 1f)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreatePanel(parent, name + "_bg", x, y, width, height, (Color?)new Color(0.15f, 0.15f, 0.15f, 0.8f));
			GameObject val2 = new GameObject("Bar_" + name + "_fill");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj = val2.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(fillPercent, 1f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			((Graphic)val2.AddComponent<Image>()).color = fillColor;
			return val;
		}

		public static void RegisterClickable(GameObject go, Action onClick, Color normalColor, Color hoverColor)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			Image component2 = go.GetComponent<Image>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null))
			{
				RegisterButton(component, component2, normalColor, hoverColor, onClick);
			}
		}

		public static void RegisterButton(RectTransform rect, Image bg, Color normal, Color hover, Action onClick)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			_buttons.Add(new ButtonEntry
			{
				Rect = rect,
				Bg = bg,
				Normal = normal,
				Hover = hover,
				OnClick = onClick
			});
		}

		public static void ButtonUpdate()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (_buttons.Count == 0)
			{
				return;
			}
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			bool mouseButtonDown = Input.GetMouseButtonDown(0);
			bool flag = val != _lastMousePosition;
			_lastMousePosition = val;
			if (!mouseButtonDown && !flag)
			{
				return;
			}
			bool flag2 = false;
			for (int num = _buttons.Count - 1; num >= 0; num--)
			{
				ButtonEntry buttonEntry = _buttons[num];
				if ((Object)(object)buttonEntry.Rect == (Object)null)
				{
					_buttons.RemoveAt(num);
				}
				else if (((Component)buttonEntry.Rect).gameObject.activeInHierarchy)
				{
					bool flag3 = RectTransformUtility.RectangleContainsScreenPoint(buttonEntry.Rect, val, (Camera)null);
					if ((Object)(object)buttonEntry.Bg != (Object)null)
					{
						((Graphic)buttonEntry.Bg).color = (flag3 ? buttonEntry.Hover : buttonEntry.Normal);
					}
					if (flag3 && mouseButtonDown && !flag2)
					{
						flag2 = true;
						try
						{
							buttonEntry.OnClick?.Invoke();
						}
						catch (Exception ex)
						{
							Debug.LogWarning(Object.op_Implicit("[OrdainUI] Button error: " + ex.Message));
						}
					}
				}
			}
		}

		public static void MakeDraggable(GameObject rootWindow, Transform dragHandle = null)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = rootWindow.GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Transform val = dragHandle ?? rootWindow.transform;
			RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
			if ((Object)(object)component2 == (Object)null)
			{
				return;
			}
			if ((Object)(object)((Component)val).GetComponent<Graphic>() == (Object)null)
			{
				((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = Color.clear;
			}
			for (int num = _draggables.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_draggables[num].Root == (Object)(object)component)
				{
					_draggables.RemoveAt(num);
				}
			}
			_draggables.Add(new DragEntry
			{
				Root = component,
				Handle = component2
			});
		}

		public static void DragUpdate()
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			if (Input.GetMouseButtonDown(0))
			{
				foreach (DragEntry draggable in _draggables)
				{
					if (!((Object)(object)draggable.Root == (Object)null) && ((Component)draggable.Root).gameObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(draggable.Handle, val, (Camera)null))
					{
						_dragging = draggable.Root;
						_lastMouse = val;
						break;
					}
				}
			}
			if (Input.GetMouseButton(0) && (Object)(object)_dragging != (Object)null)
			{
				Vector2 val2 = val - _lastMouse;
				_lastMouse = val;
				Canvas componentInParent = ((Component)_dragging).GetComponentInParent<Canvas>();
				float num = (((Object)(object)componentInParent != (Object)null) ? componentInParent.scaleFactor : 1f);
				if (num > 0f)
				{
					val2 /= num;
				}
				RectTransform dragging = _dragging;
				dragging.anchoredPosition += val2;
			}
			if (!Input.GetMouseButtonUp(0))
			{
				return;
			}
			if ((Object)(object)_dragging != (Object)null)
			{
				string text = ((Object)((Component)_dragging).gameObject).name;
				if (text.StartsWith("OrdainUI_"))
				{
					text = text.Substring("OrdainUI_".Length);
				}
				HUDPositionService.Save(text, _dragging.anchoredPosition);
			}
			_dragging = null;
		}

		private static Vector2 ScreenToLocal(RectTransform rt, Vector2 screenPoint)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Canvas componentInParent = ((Component)rt).GetComponentInParent<Canvas>();
			Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			Transform parent = ((Transform)rt).parent;
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), screenPoint, val, ref result);
			return result;
		}

		public static Color GetClassColor(string className)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (className == null)
			{
				return TEXT_PRIMARY;
			}
			string text = className.ToLowerInvariant();
			if (text.StartsWith("blood"))
			{
				return CLASS_BLOOD;
			}
			if (text.StartsWith("chaos"))
			{
				return CLASS_CHAOS;
			}
			if (text.StartsWith("frost"))
			{
				return CLASS_FROST;
			}
			if (text.StartsWith("storm"))
			{
				return CLASS_STORM;
			}
			if (text.StartsWith("illusion"))
			{
				return CLASS_ILLUSION;
			}
			if (text.StartsWith("unholy"))
			{
				return CLASS_UNHOLY;
			}
			return TEXT_PRIMARY;
		}
	}
	internal static class CommandSender
	{
		private static readonly Queue<string> _queue = new Queue<string>();

		private static string _lastCmd = "";

		private static float _lastCmdTime = 0f;

		private const float DEDUP_WINDOW = 0.5f;

		public static Action OnFamiliarListChanged;

		public static bool SuppressChat => UIConfig.SuppressFamCommands;

		public static void FamBind(int index)
		{
			foreach (UIData.FamiliarListEntry familiar in UIData.FamiliarList)
			{
				familiar.IsActive = familiar.Index == index;
			}
			UIData.FamiliarActive = true;
			OrdainUIBehaviour.MarkFamiliarDirty();
			InvalidateFamiliarListHash();
			Q($".fam bind {index}");
		}

		public static void FamBindLast(int lastIndex)
		{
			UIData.FamiliarActive = true;
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q((lastIndex > 0) ? $".fam bind {lastIndex}" : ".fam call");
		}

		public static void FamUnbind()
		{
			foreach (UIData.FamiliarListEntry familiar in UIData.FamiliarList)
			{
				familiar.IsActive = false;
			}
			UIData.FamiliarActive = false;
			OrdainUIBehaviour.MarkFamiliarDirty();
			InvalidateFamiliarListHash();
			Q(".fam ub");
		}

		public static void FamCall()
		{
			Q(".fam call");
		}

		public static void FamQuickSummon()
		{
			Q(".fam qs");
		}

		public static void FamDismiss()
		{
			UIData.FamiliarActive = false;
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q(".fam dismiss");
		}

		public static void FamAggressive()
		{
			UIData.FamiliarMode = "Aggressive";
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q(".fam agg");
		}

		public static void FamPassive()
		{
			UIData.FamiliarMode = "Passive";
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q(".fam passive");
		}

		public static void FamEverstone()
		{
			UIData.FamiliarEverstone = !UIData.FamiliarEverstone;
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q(".fam everstone");
		}

		public static void FamBoxSwitch(string name)
		{
			UIData.ActiveBoxName = name;
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q(".fam box \"" + name + "\"");
		}

		public static void FamBoxCreate(string name)
		{
			Q(".fam box add \"" + name + "\"");
		}

		public static void FamMove(int index, string box)
		{
			Q($".fam move {index} \"{box}\"");
		}

		public static void FamAllocAP(string stat, int n)
		{
			if (UIData.FamiliarUnspentAP >= n)
			{
				UIData.FamiliarUnspentAP -= n;
				switch (stat)
				{
				case "hp":
					UIData.FamiliarHPAlloc += n;
					break;
				case "phys":
					UIData.FamiliarPhysAlloc += n;
					break;
				case "spell":
					UIData.FamiliarSpellAlloc += n;
					break;
				}
			}
			OrdainUIBehaviour.MarkFamiliarDirty();
			Q($".fam alloc {stat} {n}");
		}

		public static void RequestLeaderboard(string boardType)
		{
			UIData.Leaderboard.Loading = true;
			UIData.Leaderboard.BoardType = boardType;
			OrdainUIBehaviour.MarkLeaderboardDirty();
			_queue.Enqueue(boardType switch
			{
				"Level" => ".ordlb level", 
				"VBloodKills" => ".ordlb vblood", 
				"MonsterKills" => ".ordlb monster", 
				"WorldFirsts" => ".ordlb worldfirst", 
				"Familiars" => ".ordlb familiars", 
				"EventPoints" => ".ordlb eventpoints", 
				"EventWins" => ".ordlb eventwins", 
				_ => ".ordlb level", 
			});
		}

		public static void QuestUiOpened()
		{
			Q(".quest uiopened");
		}

		public static void QuestClaimStory(string questId = "")
		{
			Q(string.IsNullOrWhiteSpace(questId) ? ".quest claim" : (".quest claim " + questId));
		}

		public static void QuestClaimDaily(string questId = "")
		{
			Q(string.IsNullOrWhiteSpace(questId) ? ".quest claimdaily" : (".quest claimdaily " + questId));
		}

		public static void QuestClaimWeekly(string questId = "")
		{
			Q(string.IsNullOrWhiteSpace(questId) ? ".quest claimweekly" : (".quest claimweekly " + questId));
		}

		public static void StatsAlloc(string stat, int amount)
		{
			Q($".stats alloc {stat} {amount}");
		}

		public static void ParagonSpend(string perkAlias)
		{
			Q(".pg sd " + perkAlias);
		}

		public static void ClassAscend()
		{
			Q(".class ascend");
		}

		public static void RequestUISync(bool full = false)
		{
			Q(full ? ".ordui sync all" : ".ordui sync");
		}

		public static void NPCInteract(string npcId)
		{
			if (!string.IsNullOrWhiteSpace(npcId))
			{
				_queue.Enqueue("[ORD_CMD]|npc.interact|" + EscapeTransportField(npcId.Trim()));
			}
		}

		public static void NPCChoice(string npcId, string choiceId, string currentNodeId)
		{
			if (!string.IsNullOrWhiteSpace(npcId))
			{
				_queue.Enqueue($"[ORD_CMD]|npc.choice|{EscapeTransportField(npcId.Trim())}|{EscapeTransportField(choiceId ?? "")}|{EscapeTransportField(currentNodeId ?? "")}");
			}
		}

		public static void RiteOfferPick(int slot)
		{
			_queue.Enqueue($"[ORD_CMD]|rite.offer.pick|{slot}");
		}

		public static bool HasPending()
		{
			return _queue.Count > 0;
		}

		public static string Dequeue()
		{
			if (_queue.Count <= 0)
			{
				return null;
			}
			return _queue.Dequeue();
		}

		private static void InvalidateFamiliarListHash()
		{
			OnFamiliarListChanged?.Invoke();
		}

		private static void Q(string cmd)
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (!(cmd == _lastCmd) || !(realtimeSinceStartup - _lastCmdTime < 0.5f))
			{
				_lastCmd = cmd;
				_lastCmdTime = realtimeSinceStartup;
				_queue.Enqueue(cmd);
			}
		}

		public static void ForgeSelect(int slot, int abilityGuid, float cooldown)
		{
			Q((cooldown > 0f) ? $".forge skill {slot} {abilityGuid} {cooldown.ToString(CultureInfo.InvariantCulture)}" : $".forge skill {slot} {abilityGuid}");
		}

		public static void ForgeClearSkills()
		{
			Q(".forge skillclear");
		}

		private static string EscapeTransportField(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return "";
			}
			return value.Replace("\\", "\\\\").Replace("|", "\\|");
		}
	}
	internal static class HUDPositionService
	{
		private static readonly string FilePath = Path.Combine(Paths.ConfigPath, "OrdainUI_positions.json");

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

		private static Dictionary<string, float[]> Positions
		{
			get
			{
				if (_positions == null)
				{
					Load();
				}
				return _positions;
			}
		}

		public static void Save(string key, Vector2 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Positions[key] = new float[2] { pos.x, pos.y };
			Write();
		}

		public static void ApplySaved(GameObject root, string key)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Positions.TryGetValue(key, out var value))
			{
				RectTransform component = root.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchoredPosition = new Vector2(value[0], value[1]);
				}
			}
		}

		private static void Load()
		{
			_positions = new Dictionary<string, float[]>();
			try
			{
				if (!File.Exists(FilePath))
				{
					return;
				}
				string[] array = File.ReadAllLines(FilePath);
				foreach (string text in array)
				{
					int num = text.IndexOf('=');
					if (num >= 0)
					{
						string key = text.Substring(0, num).Trim();
						string[] array2 = text.Substring(num + 1).Split(',');
						if (array2.Length >= 2 && float.TryParse(array2[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2))
						{
							_positions[key] = new float[2] { result, result2 };
						}
					}
				}
			}
			catch
			{
				_positions = new Dictionary<string, float[]>();
			}
		}

		private static void Write()
		{
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				foreach (KeyValuePair<string, float[]> position in _positions)
				{
					stringBuilder.AppendLine(FormattableString.Invariant($"{position.Key}={position.Value[0]},{position.Value[1]}"));
				}
				File.WriteAllText(FilePath, stringBuilder.ToString());
			}
			catch
			{
			}
		}

		public static void ResetAll()
		{
			_positions = new Dictionary<string, float[]>();
			try
			{
				if (File.Exists(FilePath))
				{
					File.Delete(FilePath);
				}
			}
			catch
			{
			}
		}
	}
	internal class MessageService
	{
		private sealed class QuestSnapshot
		{
			public bool HasStoryQuest { get; set; }

			public string StoryQuestId { get; set; } = "";

			public string StoryQuestTitle { get; set; } = "";

			public string StoryStepText { get; set; } = "";

			public int StoryStepProgress { get; set; }

			public int StoryStepRequired { get; set; } = 1;

			public int StoryClaimableCount { get; set; }

			public string StoryRewardPreview { get; set; } = "";

			public List<QuestSnapshotEntry> DailyQuests { get; set; } = new List<QuestSnapshotEntry>();

			public List<QuestSnapshotEntry> WeeklyQuests { get; set; } = new List<QuestSnapshotEntry>();
		}

		private sealed class QuestSnapshotEntry
		{
			public string Id { get; set; } = "";

			public string Title { get; set; } = "";

			public string Description { get; set; } = "";

			public string RewardPreview { get; set; } = "";

			public int Progress { get; set; }

			public int Required { get; set; } = 1;

			public bool Completed { get; set; }

			public bool Claimed { get; set; }
		}

		private sealed class QuestWirePayload
		{
			public bool HasStoryQuest { get; set; }

			public string StoryQuestId { get; set; } = "";

			public string StoryQuestTitle { get; set; } = "";

			public string StoryStepText { get; set; } = "";

			public int StoryStepProgress { get; set; }

			public int StoryStepRequired { get; set; } = 1;

			public string StoryRewardPreview { get; set; } = "";

			public int StoryCompletedCount { get; set; }

			public int StoryClaimableCount { get; set; }

			public string DailyResetText { get; set; } = "";

			public string WeeklyResetText { get; set; } = "";

			public List<QuestWireEntry> DailyQuests { get; set; } = new List<QuestWireEntry>();

			public List<QuestWireEntry> WeeklyQuests { get; set; } = new List<QuestWireEntry>();
		}

		private sealed class QuestWireEntry
		{
			public string Id { get; set; } = "";

			public string Title { get; set; } = "";

			public string Description { get; set; } = "";

			public string RewardPreview { get; set; } = "";

			public int Progress { get; set; }

			public int Required { get; set; } = 1;

			public bool Completed { get; set; }

			public bool Claimed { get; set; }
		}

		private const string PREFIX = "[ORD_UI]";

		private QuestSnapshot _lastQu