Decompiled source of CubeX v2.2.3

plugins/CubeX.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CubeX.Core;
using CubeX.Core.Identity;
using CubeX.Features.Actions;
using CubeX.Features.Game;
using CubeX.Features.Host;
using CubeX.Features.Inventory;
using CubeX.Features.Misc;
using CubeX.Features.Misc.PauseMenuFeatures;
using CubeX.Features.Network;
using CubeX.Features.Player;
using CubeX.Features.Player.PlayerActions;
using CubeX.Features.Search;
using CubeX.Features.Self;
using CubeX.Features.Settings;
using CubeX.Features.Spawn;
using CubeX.Features.Teleport;
using CubeX.Features.Visuals;
using CubeX.Features.World;
using CubeX.Runtime.Actions;
using CubeX.Runtime.Diagnostics;
using CubeX.Runtime.Misc;
using CubeX.Runtime.Network;
using CubeX.Runtime.Player;
using CubeX.Runtime.Self;
using CubeX.UI;
using CubeX.UI.Features;
using ExitGames.Client.Photon;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Peak.Network;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice;
using Photon.Voice.PUN;
using Photon.Voice.Unity;
using Steamworks;
using TMPro;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.Serizalization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CubeX")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.3.0")]
[assembly: AssemblyInformationalVersion("2.2.3+207d2b24ccffa131404b61b2a7673ac8485a61c4")]
[assembly: AssemblyProduct("Cube-X mod menu for PEAK")]
[assembly: AssemblyTitle("CubeX")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
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 CubeX
{
	[BepInPlugin("com.mister9982.cubex", "Cube-X", "2.2.3")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private bool _updateFailureLogged;

		private int _lastTickFrame = -1;

		private const string ModGuid = "com.mister9982.cubex";

		private const string ModName = "Cube-X";

		public const string ModVersion = "2.2.3";

		public static Plugin Instance { get; private set; }

		public static ManualLogSource Log { get; private set; }

		private static FeatureManager FeatureManager { get; set; }

		private static MenuUI Menu { get; set; }

		internal static MenuUI MenuUi => Menu;

		private void Awake()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				FeatureManager = new FeatureManager();
				FeatureManager.RegisterAllFromAssembly();
				ConfigService.Initialize(FeatureManager);
				Menu = ((Component)this).gameObject.AddComponent<MenuUI>();
				Menu.Bind(FeatureManager);
				((Component)this).gameObject.AddComponent<GameEventNotifier>();
				((Component)this).gameObject.AddComponent<AfflictionRelayRuntime>();
				SteamLobbyJoinCoordinator.Ensure();
				NotificationSystem.MarkReady();
				_harmony = new Harmony("com.mister9982.cubex");
				PatchAllSafely();
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				CubeXDiagnostics.Info("Cube-X", "v2.2.3 loaded - press " + ((object)RuntimeKeybinds.MenuBind/*cast due to .constrained prefix*/).ToString() + " to open.", notify: true);
			}
			catch (Exception exception)
			{
				CubeXDiagnostics.Error("Cube-X", "Startup failed.", exception);
			}
		}

		private void PatchAllSafely()
		{
			int num = 0;
			int num2 = 0;
			Type[] typesSafely = GetTypesSafely(Assembly.GetExecutingAssembly());
			foreach (Type type in typesSafely)
			{
				if (!(type == null) && HasHarmonyPatch(type))
				{
					try
					{
						_harmony.CreateClassProcessor(type).Patch();
						num++;
					}
					catch (Exception ex)
					{
						num2++;
						CubeXDiagnostics.Warning("Harmony", "Skipped patch " + type.FullName + ": " + ex.GetBaseException().Message);
					}
				}
			}
			CubeXDiagnostics.Info("Harmony", "Patches applied: " + num + ", skipped: " + num2 + ".", num2 > 0);
		}

		private static Type[] GetTypesSafely(Assembly assembly)
		{
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type t) => t != null).ToArray();
			}
		}

		private static bool HasHarmonyPatch(Type type)
		{
			if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0)
			{
				return true;
			}
			return type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo t) => t.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0);
		}

		private void Update()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				MenuInputCapture.Tick();
				if (!RuntimeKeybinds.BlocksGlobalHotkeys && (Object)(object)Menu != (Object)null)
				{
					bool keyDown = Input.GetKeyDown(RuntimeKeybinds.MenuBind);
					bool flag = MenuControllerInput.ToggleMenuPressed();
					if (keyDown || flag)
					{
						Menu.IsOpen = !Menu.IsOpen;
					}
				}
			}
			catch (Exception exception)
			{
				if (!_updateFailureLogged)
				{
					_updateFailureLogged = true;
					CubeXDiagnostics.Error("Cube-X", "Update loop failed. Further update-loop errors will be logged only.", exception);
				}
				else
				{
					CubeXDiagnostics.Error("Cube-X", "Update loop failed.", exception, notify: false);
				}
			}
		}

		private void LateUpdate()
		{
			int frameCount = Time.frameCount;
			if (_lastTickFrame == frameCount)
			{
				return;
			}
			_lastTickFrame = frameCount;
			try
			{
				MenuInputCapture.Tick();
				RuntimeKeybinds.TickFeatureBinds(FeatureManager);
				FeatureManager?.Tick();
				ConfigService.Tick();
				MenuInputCapture.Tick();
			}
			catch (Exception exception)
			{
				if (!_updateFailureLogged)
				{
					_updateFailureLogged = true;
					CubeXDiagnostics.Error("Cube-X", "Frame tick failed. Further frame-tick errors will be logged only.", exception);
				}
				else
				{
					CubeXDiagnostics.Error("Cube-X", "Frame tick failed.", exception, notify: false);
				}
			}
		}

		private void FixedUpdate()
		{
			try
			{
				FeatureManager?.FixedTick();
			}
			catch (Exception exception)
			{
				if (!_updateFailureLogged)
				{
					_updateFailureLogged = true;
					CubeXDiagnostics.Error("Cube-X", "Fixed tick failed. Further fixed-tick errors will be logged only.", exception);
				}
				else
				{
					CubeXDiagnostics.Error("Cube-X", "Fixed tick failed.", exception, notify: false);
				}
			}
		}

		private void OnDestroy()
		{
			CubeXDiagnostics.Try("Cube-X", "Cancel pending lobby join", SteamLobbyJoinCoordinator.Shutdown, notifyErrors: false);
			CubeXDiagnostics.Try("Cube-X", "Unpatch Harmony", delegate
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}, notifyErrors: false);
			CubeXDiagnostics.Try("Cube-X", "Shutdown config", ConfigService.Shutdown, notifyErrors: false);
			CubeXDiagnostics.Try("Cube-X", "Disable features", delegate
			{
				FeatureManager?.DisableAll();
			}, notifyErrors: false);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CubeX";

		public const string PLUGIN_NAME = "Cube-X mod menu for PEAK";

		public const string PLUGIN_VERSION = "2.2.3";
	}
	internal static class CubeXBuildIdentity
	{
		public const bool IsDeveloperBuild = false;
	}
}
namespace CubeX.UI
{
	[HarmonyPatch(typeof(Character), "RPCA_Die")]
	internal static class CharacterDiedNotificationPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterEventNotifications.NotifyDied(__instance);
		}
	}
	internal static class CharacterEventNotifications
	{
		private const float Cooldown = 1.2f;

		private static readonly Dictionary<string, float> LastEvents = new Dictionary<string, float>();

		public static void NotifyDied(Character character)
		{
			NotifyCharacterEvent(character, "Player Died", NotificationKind.Error, "died");
		}

		public static void NotifyPassedOut(Character character)
		{
			NotifyCharacterEvent(character, "Player Passed Out", NotificationKind.Warning, "passed-out");
		}

		public static void NotifyRevived(Character character)
		{
			NotifyCharacterEvent(character, "Player Revived", NotificationKind.Success, "revived");
		}

		private static void NotifyCharacterEvent(Character character, string title, NotificationKind kind, string key)
		{
			if (NotificationSettings.PlayerLife && IsPlayerCharacter(character) && !IsCoolingDown(key + ":" + ((Object)character).GetInstanceID().ToString(CultureInfo.InvariantCulture)))
			{
				NotificationSystem.Push(title, GetCharacterNameForNotifications(character), kind);
			}
		}

		private static bool IsCoolingDown(string key)
		{
			float unscaledTime = Time.unscaledTime;
			if (LastEvents.TryGetValue(key, out var value) && unscaledTime - value < 1.2f)
			{
				return true;
			}
			LastEvents[key] = unscaledTime;
			return false;
		}

		private static bool IsPlayerCharacter(Character character)
		{
			if (!Object.op_Implicit((Object)(object)character))
			{
				return false;
			}
			if (character.isBot || character.isZombie || character.isScoutmaster)
			{
				return false;
			}
			PhotonView photonView = GetPhotonView((Component)(object)character);
			if (Object.op_Implicit((Object)(object)photonView))
			{
				return photonView.Owner != null;
			}
			return false;
		}

		public static string GetCharacterNameForNotifications(Character character)
		{
			PhotonView photonView = GetPhotonView((Component)(object)character);
			if (Object.op_Implicit((Object)(object)photonView) && photonView.Owner != null)
			{
				string nickName = photonView.Owner.NickName;
				if (!string.IsNullOrWhiteSpace(nickName))
				{
					return nickName + " #" + photonView.Owner.ActorNumber.ToString(CultureInfo.InvariantCulture);
				}
			}
			return "Player " + ((Object)character).GetInstanceID().ToString(CultureInfo.InvariantCulture);
		}

		private static PhotonView GetPhotonView(Component component)
		{
			if (!Object.op_Implicit((Object)(object)component))
			{
				return null;
			}
			return component.GetComponent<PhotonView>() ?? component.GetComponentInChildren<PhotonView>();
		}
	}
	[HarmonyPatch(typeof(Character), "RPCA_PassOut")]
	internal static class CharacterPassedOutNotificationPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterEventNotifications.NotifyPassedOut(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")]
	internal static class CharacterRevivedAtPositionNotificationPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterEventNotifications.NotifyRevived(__instance);
		}
	}
	[HarmonyPatch(typeof(Character), "RPCA_Revive")]
	internal static class CharacterRevivedNotificationPatch
	{
		private static void Postfix(Character __instance)
		{
			CharacterEventNotifications.NotifyRevived(__instance);
		}
	}
	public class GameEventNotifier : MonoBehaviourPunCallbacks
	{
		public override void OnJoinedRoom()
		{
			IncomingRpcGuard.NoteRoomJoined();
		}

		public override void OnLeftRoom()
		{
			IncomingRpcGuard.NoteRoomLeft();
		}

		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			IncomingRpcGuard.NotePlayerJoined(newPlayer);
			RecentPlayersStore.Record(newPlayer);
			PlayerDirectory.RequestImmediateRefresh();
			NameSpoofProtectionRuntime.CheckPlayer(newPlayer);
			if (!KnownCheaterProtectionRuntime.CheckKnownCheater(newPlayer, "room join") && !PlayerBlacklistStore.TryBlock(newPlayer) && NotificationSettings.JoinLeave && newPlayer != null && !newPlayer.IsLocal)
			{
				NotificationSystem.Push("Player Joined", GetPlayerName(newPlayer), NotificationKind.Success);
			}
		}

		public override void OnPlayerLeftRoom(Player otherPlayer)
		{
			IncomingRpcGuard.NotePlayerLeft(otherPlayer);
			RecentPlayersStore.Record(otherPlayer);
			PlayerDirectory.RequestImmediateRefresh();
			if (NotificationSettings.JoinLeave && otherPlayer != null && !otherPlayer.IsLocal)
			{
				NotificationSystem.Push("Player Left", GetPlayerName(otherPlayer), NotificationKind.Warning);
			}
		}

		public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
		{
		}

		public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
		{
			PlayerDirectory.RequestImmediateRefresh();
			KnownCheaterProtectionRuntime.CheckKnownCheater(targetPlayer, "player properties update");
		}

		public override void OnMasterClientSwitched(Player newMasterClient)
		{
			PlayerDirectory.RequestImmediateRefresh();
			ProtectionLog.Write("INFO", "Host Authority", "Master client switched to " + GetPlayerName(newMasterClient) + ".");
			if (newMasterClient != null && newMasterClient.IsLocal)
			{
				PlayerBlacklistStore.EnforceCurrentRoomBlacklist();
			}
		}

		private static string GetPlayerName(Player player)
		{
			if (player == null)
			{
				return "Unknown";
			}
			return (string.IsNullOrWhiteSpace(player.NickName) ? "Player" : player.NickName) + " #" + player.ActorNumber.ToString(CultureInfo.InvariantCulture);
		}
	}
	public static class NotificationSettings
	{
		public static bool JoinLeave = true;

		public static bool PlayerLife = true;

		public static bool RpcEvents = true;

		public static bool KeybindToggles = true;
	}
	public static class RpcEventNotifications
	{
		private const float Cooldown = 0.7f;

		private static readonly Dictionary<string, float> LastEvents = new Dictionary<string, float>();

		public static void NotifyExecuted(string methodName, Player sender, PhotonView view)
		{
			if (NotificationSettings.RpcEvents && !string.IsNullOrEmpty(methodName) && !IncomingRpcGuard.ShouldSuppressFallRpcNotification(methodName, sender, view) && !IsCoolingDown("rpc:" + methodName + ":" + GetSenderKey(sender) + ":" + (Object.op_Implicit((Object)(object)view) ? view.ViewID.ToString(CultureInfo.InvariantCulture) : "0")))
			{
				string text = ((sender != null && sender.IsLocal) ? "You" : GetPlayerName(sender));
				string targetText = GetTargetText(view);
				string description = (string.IsNullOrEmpty(targetText) ? text : (text + " -> " + targetText));
				NotificationSystem.Push("RPC " + methodName, description);
			}
		}

		public static void NotifyBlocked(string methodName, Player sender)
		{
			if (NotificationSettings.RpcEvents && !string.IsNullOrEmpty(methodName) && !IncomingRpcGuard.ShouldSuppressFallRpcNotification(methodName, sender, null) && !IsCoolingDown("blocked:" + methodName + ":" + GetSenderKey(sender)))
			{
				NotificationSystem.Push("RPC Blocked", methodName + " from " + GetPlayerName(sender), NotificationKind.Warning);
			}
		}

		public static void NotifyProtectionDetected(string eventName, Player sender, PhotonView view)
		{
			if (NotificationSettings.RpcEvents && !string.IsNullOrEmpty(eventName) && !IncomingRpcGuard.ShouldSuppressFallRpcNotification(eventName, sender, view) && !IsCoolingDown("protection:" + eventName + ":" + GetSenderKey(sender) + ":" + (Object.op_Implicit((Object)(object)view) ? view.ViewID.ToString(CultureInfo.InvariantCulture) : "0")))
			{
				string targetText = GetTargetText(view);
				string text = eventName + " from " + GetPlayerName(sender);
				if (!string.IsNullOrEmpty(targetText))
				{
					text = text + " -> " + targetText;
				}
				NotificationSystem.Push("Modder Detection", text, NotificationKind.Warning);
			}
		}

		public static void NotifyProtectionBlocked(string eventName, Player sender)
		{
			if (NotificationSettings.RpcEvents && !string.IsNullOrEmpty(eventName) && !IncomingRpcGuard.ShouldSuppressFallRpcNotification(eventName, sender, null) && !IsCoolingDown("protection-blocked:" + eventName + ":" + GetSenderKey(sender)))
			{
				NotificationSystem.Push("Protection Blocked", eventName + " from " + GetPlayerName(sender), NotificationKind.Warning);
			}
		}

		private static bool IsCoolingDown(string key)
		{
			float unscaledTime = Time.unscaledTime;
			if (LastEvents.TryGetValue(key, out var value) && unscaledTime - value < 0.7f)
			{
				return true;
			}
			LastEvents[key] = unscaledTime;
			return false;
		}

		private static string GetSenderKey(Player sender)
		{
			if (sender != null)
			{
				return sender.ActorNumber.ToString(CultureInfo.InvariantCulture);
			}
			return "unknown";
		}

		private static string GetPlayerName(Player player)
		{
			if (player == null)
			{
				return "Unknown";
			}
			return (string.IsNullOrWhiteSpace(player.NickName) ? "Player" : player.NickName) + " #" + player.ActorNumber.ToString(CultureInfo.InvariantCulture);
		}

		private static string GetTargetText(PhotonView view)
		{
			if (!Object.op_Implicit((Object)(object)view))
			{
				return string.Empty;
			}
			Character val = ((Component)view).GetComponent<Character>() ?? ((Component)view).GetComponentInParent<Character>() ?? ((Component)view).GetComponentInChildren<Character>();
			if (Object.op_Implicit((Object)(object)val))
			{
				return CharacterEventNotifications.GetCharacterNameForNotifications(val);
			}
			return "View " + view.ViewID.ToString(CultureInfo.InvariantCulture);
		}
	}
	internal sealed class SelectedPlayerPreviewPanel : IDisposable
	{
		private const int TextureWidth = 384;

		private const int TextureHeight = 512;

		private const int InventorySlotCount = 4;

		private const int CarriedItemSlotCount = 3;

		private const float RenderInterval = 1f / 12f;

		private const float MissingReferenceRetryInterval = 0.5f;

		private const float MissingCameraRetryInterval = 1f;

		private const float InventorySignatureInterval = 0.2f;

		private static readonly Color BackgroundColor = new Color(0.015f, 0.016f, 0.018f, 1f);

		private static readonly Renderer[] NoRenderers = Array.Empty<Renderer>();

		private static readonly int VertexGhost = Shader.PropertyToID("_VertexGhost");

		private readonly Item[] _observedInventoryPrefabs = (Item[])(object)new Item[3];

		private readonly Texture[] _inventoryIcons = (Texture[])(object)new Texture[4];

		private readonly bool[] _inventoryOccupied = new bool[4];

		private GameObject _root;

		private Camera _camera;

		private Camera _mainCamera;

		private RenderTexture _target;

		private bool _visible;

		private bool _targetCleared = true;

		private bool _renderCallbacksSubscribed;

		private float _nextRenderAt;

		private float _nextReferenceRetryAt;

		private float _nextCameraRetryAt;

		private float _nextInventorySignatureAt;

		private int _sceneHandle = int.MinValue;

		private int _lastReferenceCheckFrame = -1;

		private PlayerDirectory.SelectedPlayerInfo _lastSelectionSnapshot;

		private string _selectedPlayerId;

		private int _selectedActorNumber = -1;

		private Character _character;

		private Player _player;

		private PlayerGhost _ghost;

		private Transform _previewRoot;

		private Renderer[] _renderers = NoRenderers;

		private bool[] _temporarilyEnabledRenderers = Array.Empty<bool>();

		private bool[] _temporarilyOverriddenRenderers = Array.Empty<bool>();

		private MaterialPropertyBlock[] _originalRendererBlocks = Array.Empty<MaterialPropertyBlock>();

		private MaterialPropertyBlock[] _previewRendererBlocks = Array.Empty<MaterialPropertyBlock>();

		private Renderer _mouthRenderer;

		private Renderer[] _eyeRenderers = NoRenderers;

		private bool _usingGhost;

		private bool _inventoryDirty = true;

		private bool _observedBackpack;

		public bool SupportsInventory => true;

		public bool HasPreview
		{
			get
			{
				RefreshCachedReferences();
				return !string.IsNullOrEmpty(_selectedPlayerId);
			}
		}

		public Texture GetTexture()
		{
			SetVisible(visible: true);
			EnsureResources();
			RefreshCachedReferences();
			if (!Object.op_Implicit((Object)(object)_previewRoot) && !_targetCleared)
			{
				ClearTarget();
			}
			return (Texture)(object)_target;
		}

		public bool IsInventorySlotOccupied(int slotIndex)
		{
			if (slotIndex < 0 || slotIndex >= 4)
			{
				return false;
			}
			RefreshCachedReferences();
			RefreshInventoryIfNeeded();
			return _inventoryOccupied[slotIndex];
		}

		public Texture GetInventorySlotIcon(int slotIndex)
		{
			if (slotIndex < 0 || slotIndex >= 4)
			{
				return null;
			}
			RefreshCachedReferences();
			RefreshInventoryIfNeeded();
			Texture val = _inventoryIcons[slotIndex];
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return val;
		}

		public void Tick()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			RestoreTemporarilyEnabledRenderers();
			if (Object.op_Implicit((Object)(object)_camera) && ((Behaviour)_camera).enabled)
			{
				((Behaviour)_camera).enabled = false;
			}
			if (!_visible)
			{
				return;
			}
			EnsureResources();
			RefreshCachedReferences();
			RefreshInventoryIfNeeded();
			if (!Object.op_Implicit((Object)(object)_camera))
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextRenderAt)
			{
				return;
			}
			if (!TryGetRendererBounds(out var bounds))
			{
				_nextRenderAt = unscaledTime + 0.5f;
				if (!_targetCleared)
				{
					ClearTarget();
				}
			}
			else
			{
				ConfigureCamera(bounds);
				((Behaviour)_camera).enabled = true;
				_targetCleared = false;
				_nextRenderAt = unscaledTime + 1f / 12f;
			}
		}

		public void SetVisible(bool visible)
		{
			if (_visible == visible)
			{
				return;
			}
			_visible = visible;
			if (!visible)
			{
				RestoreTemporarilyEnabledRenderers();
				if (Object.op_Implicit((Object)(object)_camera))
				{
					((Behaviour)_camera).enabled = false;
				}
				_nextRenderAt = 0f;
			}
		}

		public void Dispose()
		{
			RestoreTemporarilyEnabledRenderers();
			BindPlayer(null);
			if (_renderCallbacksSubscribed)
			{
				RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
				RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
				_renderCallbacksSubscribed = false;
			}
			if (Object.op_Implicit((Object)(object)_camera))
			{
				((Behaviour)_camera).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)_target))
			{
				_target.Release();
				Object.Destroy((Object)(object)_target);
				_target = null;
			}
			if (Object.op_Implicit((Object)(object)_root))
			{
				Object.Destroy((Object)(object)_root);
				_root = null;
			}
			_camera = null;
			_mainCamera = null;
			ClearVisualTarget();
		}

		private void EnsureResources()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_root))
			{
				_root = new GameObject("CubeX Selected Player Live Preview")
				{
					hideFlags = (HideFlags)61
				};
				Object.DontDestroyOnLoad((Object)(object)_root);
				_camera = _root.AddComponent<Camera>();
				((Behaviour)_camera).enabled = false;
				_camera.clearFlags = (CameraClearFlags)2;
				_camera.backgroundColor = BackgroundColor;
				_camera.orthographic = true;
				_camera.nearClipPlane = 0.02f;
				_camera.farClipPlane = 18f;
				_camera.allowHDR = false;
				_camera.allowMSAA = false;
				_camera.useOcclusionCulling = false;
				_camera.depthTextureMode = (DepthTextureMode)0;
				_camera.renderingPath = (RenderingPath)1;
				_camera.depth = -100f;
			}
			if (!_renderCallbacksSubscribed)
			{
				RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
				RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
				_renderCallbacksSubscribed = true;
			}
			if (!Object.op_Implicit((Object)(object)_target))
			{
				_target = new RenderTexture(384, 512, 16, (RenderTextureFormat)0)
				{
					hideFlags = (HideFlags)61,
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1,
					antiAliasing = 1,
					useMipMap = false,
					autoGenerateMips = false
				};
				_target.Create();
				ClearTarget();
			}
			else if (!_target.IsCreated())
			{
				_target.Create();
				ClearTarget();
			}
			if (Object.op_Implicit((Object)(object)_camera) && (Object)(object)_camera.targetTexture != (Object)(object)_target)
			{
				_camera.targetTexture = _target;
			}
		}

		private void RefreshCachedReferences()
		{
			RefreshSceneState();
			PlayerDirectory.SelectedPlayerInfo selectedPlayer = PlayerDirectory.SelectedPlayer;
			int frameCount = Time.frameCount;
			if (_lastReferenceCheckFrame == frameCount && _lastSelectionSnapshot == selectedPlayer)
			{
				return;
			}
			_lastReferenceCheckFrame = frameCount;
			_lastSelectionSnapshot = selectedPlayer;
			string text = selectedPlayer?.Id;
			int num = ParseActorNumber(selectedPlayer?.ActorText);
			Player player = null;
			Character character = null;
			if (selectedPlayer != null)
			{
				if (num > 0)
				{
					TryGetRegisteredPlayerAndCharacter(num, out player, out character);
				}
				else
				{
					character = selectedPlayer.Character;
					if (!Object.op_Implicit((Object)(object)character))
					{
						character = null;
					}
					player = TryGetCharacterPlayer(character);
				}
			}
			bool num2 = !string.Equals(_selectedPlayerId, text, StringComparison.Ordinal) || _selectedActorNumber != num;
			bool flag = _character != character;
			bool flag2 = _player != player;
			if (num2 || flag)
			{
				_selectedPlayerId = text;
				_selectedActorNumber = num;
				_character = character;
				BindPlayer(player);
				RefreshVisualTarget(force: true);
				return;
			}
			if (flag2)
			{
				BindPlayer(player);
			}
			RefreshVisualTarget(force: false);
			if ((!Object.op_Implicit((Object)(object)_player) || !Object.op_Implicit((Object)(object)_previewRoot)) && Time.unscaledTime >= _nextReferenceRetryAt)
			{
				_nextReferenceRetryAt = Time.unscaledTime + 0.5f;
				if (!Object.op_Implicit((Object)(object)_player) && Object.op_Implicit((Object)(object)_character))
				{
					BindPlayer(TryGetCharacterPlayer(_character));
				}
				if (Object.op_Implicit((Object)(object)_previewRoot) && RendererCacheNeedsRefresh())
				{
					CacheRendererReferences();
				}
			}
		}

		private unsafe void RefreshSceneState()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			int num = (((Scene)(ref activeScene)).IsValid() ? ((object)(*(Scene*)(&activeScene))/*cast due to .constrained prefix*/).GetHashCode() : int.MinValue);
			if (num != _sceneHandle)
			{
				_sceneHandle = num;
				_mainCamera = null;
				_nextCameraRetryAt = 0f;
				_lastReferenceCheckFrame = -1;
				_lastSelectionSnapshot = null;
				_selectedPlayerId = null;
				_selectedActorNumber = -1;
				_character = null;
				BindPlayer(null);
				ClearVisualTarget();
			}
		}

		private void RefreshVisualTarget(bool force)
		{
			Character character = _character;
			if (!Object.op_Implicit((Object)(object)character) || !Object.op_Implicit((Object)(object)((Component)character).gameObject) || !((Component)character).gameObject.activeInHierarchy)
			{
				if (force || Object.op_Implicit((Object)(object)_previewRoot) || Object.op_Implicit((Object)(object)_ghost))
				{
					ClearVisualTarget();
				}
				return;
			}
			CharacterData data = character.data;
			bool flag = data != null && data.dead;
			PlayerGhost val = (flag ? character.Ghost : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)((Component)val).gameObject) || !((Component)val).gameObject.activeInHierarchy)
			{
				val = null;
			}
			bool flag2 = flag && Object.op_Implicit((Object)(object)val);
			Transform val2 = (flag2 ? ((Component)val).transform : ((!flag) ? GetCharacterPreviewRoot(character) : null));
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = null;
			}
			if (force || _usingGhost != flag2 || _ghost != val || _previewRoot != val2 || RendererCacheNeedsRefresh())
			{
				RestoreTemporarilyEnabledRenderers();
				_usingGhost = flag2;
				_ghost = val;
				_previewRoot = val2;
				CacheFaceRenderers();
				CacheRendererReferences();
				ResolveMainCamera(force: true);
				_nextRenderAt = 0f;
				if (!_targetCleared)
				{
					ClearTarget();
				}
			}
		}

		private void ClearVisualTarget()
		{
			RestoreTemporarilyEnabledRenderers();
			_ghost = null;
			_previewRoot = null;
			_renderers = NoRenderers;
			_temporarilyEnabledRenderers = Array.Empty<bool>();
			_temporarilyOverriddenRenderers = Array.Empty<bool>();
			_originalRendererBlocks = Array.Empty<MaterialPropertyBlock>();
			_previewRendererBlocks = Array.Empty<MaterialPropertyBlock>();
			_mouthRenderer = null;
			_eyeRenderers = NoRenderers;
			_usingGhost = false;
			_nextRenderAt = 0f;
			if (Object.op_Implicit((Object)(object)_camera))
			{
				((Behaviour)_camera).enabled = false;
			}
			if (!_targetCleared)
			{
				ClearTarget();
			}
		}

		private void CacheRendererReferences()
		{
			_renderers = (Object.op_Implicit((Object)(object)_previewRoot) ? ((Component)_previewRoot).GetComponentsInChildren<Renderer>(true) : NoRenderers);
			_temporarilyEnabledRenderers = ((_renderers.Length != 0) ? new bool[_renderers.Length] : Array.Empty<bool>());
			_temporarilyOverriddenRenderers = ((_renderers.Length != 0) ? new bool[_renderers.Length] : Array.Empty<bool>());
			_originalRendererBlocks = Array.Empty<MaterialPropertyBlock>();
			_previewRendererBlocks = Array.Empty<MaterialPropertyBlock>();
			if (_renderers.Length == 0)
			{
				_nextReferenceRetryAt = Time.unscaledTime + 0.5f;
			}
		}

		private bool RendererCacheNeedsRefresh()
		{
			if (!Object.op_Implicit((Object)(object)_previewRoot))
			{
				return _renderers.Length != 0;
			}
			if (_renderers == null || _renderers.Length == 0)
			{
				return Time.unscaledTime >= _nextReferenceRetryAt;
			}
			for (int i = 0; i < _renderers.Length; i++)
			{
				if (!Object.op_Implicit((Object)(object)_renderers[i]))
				{
					return true;
				}
			}
			return false;
		}

		private void CacheFaceRenderers()
		{
			_mouthRenderer = null;
			_eyeRenderers = NoRenderers;
			if (_usingGhost && Object.op_Implicit((Object)(object)_ghost))
			{
				_mouthRenderer = _ghost.mouthRenderer;
				_eyeRenderers = _ghost.EyeRenderers ?? NoRenderers;
				return;
			}
			Character character = _character;
			CustomizationRefs val = ((Object.op_Implicit((Object)(object)character) && Object.op_Implicit((Object)(object)character.refs?.customization)) ? character.refs.customization.refs : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				_mouthRenderer = val.mouthRenderer;
				_eyeRenderers = val.EyeRenderers ?? NoRenderers;
			}
		}

		private void BindPlayer(Player player)
		{
			if (_player == player)
			{
				return;
			}
			if (_player != null)
			{
				try
				{
					Player player2 = _player;
					player2.itemsChangedAction = (Action<ItemSlot[]>)Delegate.Remove(player2.itemsChangedAction, new Action<ItemSlot[]>(OnInventoryChanged));
				}
				catch
				{
				}
			}
			_player = player;
			if (Object.op_Implicit((Object)(object)_player))
			{
				try
				{
					Player player3 = _player;
					player3.itemsChangedAction = (Action<ItemSlot[]>)Delegate.Combine(player3.itemsChangedAction, new Action<ItemSlot[]>(OnInventoryChanged));
				}
				catch
				{
				}
			}
			ClearInventorySnapshot();
		}

		private void OnInventoryChanged(ItemSlot[] _)
		{
			_inventoryDirty = true;
		}

		private void RefreshInventoryIfNeeded()
		{
			float unscaledTime = Time.unscaledTime;
			if (!_inventoryDirty && unscaledTime < _nextInventorySignatureAt)
			{
				return;
			}
			_nextInventorySignatureAt = unscaledTime + 0.2f;
			bool flag = HasBackpack(_player);
			bool flag2 = _inventoryDirty || flag != _observedBackpack;
			for (int i = 0; i < 3; i++)
			{
				if (GetInventoryPrefab(_player, i) != _observedInventoryPrefabs[i])
				{
					flag2 = true;
				}
				Texture val = _inventoryIcons[i];
				if (val != null && !Object.op_Implicit((Object)(object)val))
				{
					flag2 = true;
				}
			}
			Texture val2 = _inventoryIcons[3];
			if (flag && (val2 == null || !Object.op_Implicit((Object)(object)val2)))
			{
				flag2 = true;
			}
			if (flag2)
			{
				for (int j = 0; j < 3; j++)
				{
					Item inventoryPrefab = GetInventoryPrefab(_player, j);
					_observedInventoryPrefabs[j] = inventoryPrefab;
					_inventoryOccupied[j] = Object.op_Implicit((Object)(object)inventoryPrefab);
					_inventoryIcons[j] = (Object.op_Implicit((Object)(object)inventoryPrefab) ? GetItemIcon(inventoryPrefab) : null);
				}
				_observedBackpack = flag;
				_inventoryOccupied[3] = flag;
				_inventoryIcons[3] = (flag ? GetBackpackIcon(_player) : null);
				_inventoryDirty = false;
			}
		}

		private void ClearInventorySnapshot()
		{
			Array.Clear(_observedInventoryPrefabs, 0, _observedInventoryPrefabs.Length);
			Array.Clear(_inventoryIcons, 0, _inventoryIcons.Length);
			Array.Clear(_inventoryOccupied, 0, _inventoryOccupied.Length);
			_observedBackpack = false;
			_inventoryDirty = true;
			_nextInventorySignatureAt = 0f;
		}

		private static Item GetInventoryPrefab(Player player, int index)
		{
			try
			{
				if (!Object.op_Implicit((Object)(object)player) || player.itemSlots == null || index < 0 || index >= player.itemSlots.Length)
				{
					return null;
				}
				ItemSlot val = player.itemSlots[index];
				if (val == null || val.IsEmpty())
				{
					return null;
				}
				Item prefab = val.prefab;
				return Object.op_Implicit((Object)(object)prefab) ? prefab : null;
			}
			catch
			{
				return null;
			}
		}

		private static bool HasBackpack(Player player)
		{
			try
			{
				return Object.op_Implicit((Object)(object)player) && player.backpackSlot != null && !((ItemSlot)player.backpackSlot).IsEmpty();
			}
			catch
			{
				return false;
			}
		}

		private static Texture GetBackpackIcon(Player player)
		{
			try
			{
				ItemSlot val = (ItemSlot)(object)(Object.op_Implicit((Object)(object)player) ? player.backpackSlot : null);
				Item val2 = val?.prefab;
				if (!Object.op_Implicit((Object)(object)val2))
				{
					val2 = GameActions.LoadItemPrefab(((val != null) ? val.GetPrefabName() : null) ?? "Backpack");
				}
				return Object.op_Implicit((Object)(object)val2) ? GetItemIcon(val2) : null;
			}
			catch
			{
				return null;
			}
		}

		private static Texture GetItemIcon(Item item)
		{
			if (!Object.op_Implicit((Object)(object)item))
			{
				return null;
			}
			try
			{
				ItemUIData uIData = item.UIData;
				Texture val = (Texture)(object)((uIData != null) ? uIData.GetIcon() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			catch
			{
			}
			try
			{
				Texture val2 = (Texture)(object)item.UIData?.icon;
				return Object.op_Implicit((Object)(object)val2) ? val2 : null;
			}
			catch
			{
				return null;
			}
		}

		private bool TryGetRendererBounds(out Bounds bounds)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			bounds = default(Bounds);
			if (!Object.op_Implicit((Object)(object)_previewRoot) || _renderers == null || _renderers.Length == 0)
			{
				return false;
			}
			bool allowDisabled = ShouldTemporarilyRevealGhost();
			bool flag = false;
			for (int i = 0; i < _renderers.Length; i++)
			{
				Renderer val = _renderers[i];
				if (ShouldUseRenderer(val, allowDisabled))
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			if (flag)
			{
				Vector3 size = ((Bounds)(ref bounds)).size;
				return ((Vector3)(ref size)).sqrMagnitude > 0.0001f;
			}
			return false;
		}

		private void ConfigureCamera(Bounds bounds)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00e5: 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)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			Camera val = ResolveMainCamera(force: false);
			_camera.cullingMask = ((Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)_camera) ? (val.cullingMask & -33) : (-33));
			_camera.backgroundColor = BackgroundColor;
			Vector3 center = ((Bounds)(ref bounds)).center;
			float num = Mathf.Max(0.75f, ((Bounds)(ref bounds)).size.y);
			float num2 = Mathf.Max(0.45f, ((Bounds)(ref bounds)).size.x);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(center.x, ((Bounds)(ref bounds)).min.y + num * 0.52f, center.z);
			Vector3 frontViewDirection = GetFrontViewDirection(center, val);
			float num3 = Mathf.Clamp(num * 1.3f, 1.5f, 4f);
			Vector3 val3 = val2 + frontViewDirection * num3 + Vector3.up * num * 0.02f;
			_camera.orthographic = true;
			((Component)_camera).transform.position = val3;
			((Component)_camera).transform.rotation = Quaternion.LookRotation(val2 - val3, Vector3.up);
			float num4 = 0.75f;
			float num5 = Mathf.Max(0.45f, num * 0.53f);
			float num6 = Mathf.Max(0.45f, num2 / Mathf.Max(0.1f, num4) * 0.68f);
			_camera.orthographicSize = Mathf.Max(num5, num6);
			_camera.nearClipPlane = 0.02f;
			_camera.farClipPlane = Mathf.Max(8f, num3 + 8f);
		}

		private Vector3 GetFrontViewDirection(Vector3 bodyCenter, Camera main)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: 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_0018: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0044: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetFaceDirection(bodyCenter, out var direction))
			{
				direction = ((!Object.op_Implicit((Object)(object)_previewRoot)) ? Vector3.forward : (_usingGhost ? _previewRoot.forward : (-_previewRoot.forward)));
			}
			direction = Vector3.ProjectOnPlane(direction, Vector3.up);
			if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f)
			{
				direction = (Object.op_Implicit((Object)(object)main) ? Vector3.ProjectOnPlane(-((Component)main).transform.forward, Vector3.up) : Vector3.forward);
				if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f)
				{
					direction = Vector3.forward;
				}
			}
			((Vector3)(ref direction)).Normalize();
			return direction;
		}

		private bool TryGetFaceDirection(Vector3 bodyCenter, out Vector3 direction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			direction = Vector3.zero;
			Vector3 center = Vector3.zero;
			int count = 0;
			bool allowDisabled = ShouldTemporarilyRevealGhost();
			AddRendererCenter(_mouthRenderer, allowDisabled, ref center, ref count);
			for (int i = 0; i < _eyeRenderers.Length; i++)
			{
				AddRendererCenter(_eyeRenderers[i], allowDisabled, ref center, ref count);
			}
			if (count <= 0)
			{
				return false;
			}
			center /= (float)count;
			Vector3 val = ((!_usingGhost && Object.op_Implicit((Object)(object)_character) && IsFinite(_character.Head)) ? _character.Head : bodyCenter);
			direction = Vector3.ProjectOnPlane(center - val, Vector3.up);
			return ((Vector3)(ref direction)).sqrMagnitude > 0.0001f;
		}

		private static void AddRendererCenter(Renderer renderer, bool allowDisabled, ref Vector3 center, ref int count)
		{
			//IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (ShouldUseRenderer(renderer, allowDisabled))
			{
				Vector3 val = center;
				Bounds bounds = renderer.bounds;
				center = val + ((Bounds)(ref bounds)).center;
				count++;
			}
		}

		private static bool ShouldUseRenderer(Renderer renderer, bool allowDisabled)
		{
			if (!Object.op_Implicit((Object)(object)renderer) || !Object.op_Implicit((Object)(object)((Component)renderer).gameObject) || !((Component)renderer).gameObject.activeInHierarchy)
			{
				return false;
			}
			if (!allowDisabled && !renderer.enabled)
			{
				return false;
			}
			Type type = ((object)renderer).GetType();
			if (type == typeof(ParticleSystemRenderer) || type == typeof(LineRenderer) || type == typeof(TrailRenderer))
			{
				return false;
			}
			string obj = ((Object)renderer).name ?? string.Empty;
			string text = ((Object)((Component)renderer).gameObject).name ?? string.Empty;
			if (obj.IndexOf("shadow", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return text.IndexOf("shadow", StringComparison.OrdinalIgnoreCase) < 0;
			}
			return false;
		}

		private Camera ResolveMainCamera(bool force)
		{
			if (!force && Object.op_Implicit((Object)(object)_mainCamera) && (Object)(object)_mainCamera != (Object)(object)_camera)
			{
				return _mainCamera;
			}
			float unscaledTime = Time.unscaledTime;
			if (!force && unscaledTime < _nextCameraRetryAt)
			{
				if (!Object.op_Implicit((Object)(object)_mainCamera) || !((Object)(object)_mainCamera != (Object)(object)_camera))
				{
					return null;
				}
				return _mainCamera;
			}
			_nextCameraRetryAt = unscaledTime + 1f;
			_mainCamera = Camera.main;
			if ((Object)(object)_mainCamera == (Object)(object)_camera)
			{
				_mainCamera = null;
			}
			return _mainCamera;
		}

		private void OnBeginCameraRendering(ScriptableRenderContext _, Camera renderingCamera)
		{
			if ((Object)(object)renderingCamera != (Object)(object)_camera)
			{
				return;
			}
			if (ShouldTemporarilyRevealGhost())
			{
				for (int i = 0; i < _renderers.Length; i++)
				{
					Renderer val = _renderers[i];
					if (ShouldUseRenderer(val, allowDisabled: true) && !val.enabled)
					{
						_temporarilyEnabledRenderers[i] = true;
						val.enabled = true;
					}
				}
			}
			if (!ShouldTemporarilyRevealLocalCharacter())
			{
				return;
			}
			EnsureRendererPropertyBlockCache();
			for (int j = 0; j < _renderers.Length; j++)
			{
				Renderer val2 = _renderers[j];
				if (ShouldUseRenderer(val2, allowDisabled: false))
				{
					MaterialPropertyBlock val3 = _originalRendererBlocks[j];
					MaterialPropertyBlock val4 = _previewRendererBlocks[j];
					val3.Clear();
					val4.Clear();
					val2.GetPropertyBlock(val3);
					val2.GetPropertyBlock(val4);
					val4.SetFloat(VertexGhost, 0f);
					val2.SetPropertyBlock(val4);
					_temporarilyOverriddenRenderers[j] = true;
				}
			}
		}

		private void OnEndCameraRendering(ScriptableRenderContext _, Camera renderingCamera)
		{
			if ((Object)(object)renderingCamera == (Object)(object)_camera)
			{
				RestoreTemporarilyEnabledRenderers();
			}
		}

		private bool ShouldTemporarilyRevealGhost()
		{
			try
			{
				return _usingGhost && Object.op_Implicit((Object)(object)_character) && _character.IsLocal;
			}
			catch
			{
				return false;
			}
		}

		private bool ShouldTemporarilyRevealLocalCharacter()
		{
			try
			{
				int result;
				if (!_usingGhost && Object.op_Implicit((Object)(object)_character) && _character.IsLocal)
				{
					CharacterData data = _character.data;
					if (data == null || !data.dead)
					{
						CharacterData data2 = _character.data;
						result = ((data2 == null || !data2.fullyPassedOut) ? 1 : 0);
						goto IL_005b;
					}
				}
				result = 0;
				goto IL_005b;
				IL_005b:
				return (byte)result != 0;
			}
			catch
			{
				return false;
			}
		}

		private void EnsureRendererPropertyBlockCache()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			if (_originalRendererBlocks.Length != _renderers.Length || _previewRendererBlocks.Length != _renderers.Length)
			{
				_originalRendererBlocks = (MaterialPropertyBlock[])(object)new MaterialPropertyBlock[_renderers.Length];
				_previewRendererBlocks = (MaterialPropertyBlock[])(object)new MaterialPropertyBlock[_renderers.Length];
				for (int i = 0; i < _renderers.Length; i++)
				{
					_originalRendererBlocks[i] = new MaterialPropertyBlock();
					_previewRendererBlocks[i] = new MaterialPropertyBlock();
				}
			}
		}

		private void RestoreTemporarilyEnabledRenderers()
		{
			Renderer[] renderers = _renderers;
			int num = ((renderers != null) ? renderers.Length : 0);
			bool[] temporarilyEnabledRenderers = _temporarilyEnabledRenderers;
			int num2 = Mathf.Min(num, (temporarilyEnabledRenderers != null) ? temporarilyEnabledRenderers.Length : 0);
			for (int i = 0; i < num2; i++)
			{
				if (_temporarilyEnabledRenderers[i])
				{
					Renderer val = _renderers[i];
					if (Object.op_Implicit((Object)(object)val))
					{
						val.enabled = false;
					}
					_temporarilyEnabledRenderers[i] = false;
				}
			}
			Renderer[] renderers2 = _renderers;
			int num3 = ((renderers2 != null) ? renderers2.Length : 0);
			bool[] temporarilyOverriddenRenderers = _temporarilyOverriddenRenderers;
			int num4 = Mathf.Min(num3, (temporarilyOverriddenRenderers != null) ? temporarilyOverriddenRenderers.Length : 0);
			int num5 = num4;
			MaterialPropertyBlock[] originalRendererBlocks = _originalRendererBlocks;
			num4 = Mathf.Min(num5, (originalRendererBlocks != null) ? originalRendererBlocks.Length : 0);
			for (int j = 0; j < num4; j++)
			{
				if (_temporarilyOverriddenRenderers[j])
				{
					Renderer val2 = _renderers[j];
					if (Object.op_Implicit((Object)(object)val2))
					{
						val2.SetPropertyBlock(_originalRendererBlocks[j]);
					}
					_temporarilyOverriddenRenderers[j] = false;
				}
			}
		}

		private void ClearTarget()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_target))
			{
				return;
			}
			RenderTexture active = RenderTexture.active;
			try
			{
				RenderTexture.active = _target;
				GL.Clear(true, true, BackgroundColor);
				_targetCleared = true;
			}
			finally
			{
				RenderTexture.active = active;
			}
		}

		private static Transform GetCharacterPreviewRoot(Character character)
		{
			if (!Object.op_Implicit((Object)(object)character))
			{
				return null;
			}
			CustomizationRefs val = (Object.op_Implicit((Object)(object)character.refs?.customization) ? character.refs.customization.refs : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				return ((Component)val).transform;
			}
			if (Object.op_Implicit((Object)(object)character.refs?.animationPositionTransform))
			{
				return character.refs.animationPositionTransform;
			}
			return ((Component)character).transform;
		}

		private static Player TryGetCharacterPlayer(Character character)
		{
			if (!Object.op_Implicit((Object)(object)character))
			{
				return null;
			}
			try
			{
				Player player = character.player;
				return Object.op_Implicit((Object)(object)player) ? player : null;
			}
			catch
			{
				return null;
			}
		}

		private static void TryGetRegisteredPlayerAndCharacter(int actorNumber, out Player player, out Character character)
		{
			player = null;
			character = null;
			try
			{
				player = PlayerHandler.GetPlayer(actorNumber);
				if (!Object.op_Implicit((Object)(object)player))
				{
					player = null;
				}
				else if (!PlayerHandler.TryGetCharacter(actorNumber, ref character) || !Object.op_Implicit((Object)(object)character))
				{
					character = null;
				}
			}
			catch
			{
				player = null;
				character = null;
			}
		}

		private static int ParseActorNumber(string actorText)
		{
			if (!int.TryParse(actorText, out var result) || result <= 0)
			{
				return -1;
			}
			return result;
		}

		private static bool IsFinite(Vector3 value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (float.IsFinite(value.x) && float.IsFinite(value.y))
			{
				return float.IsFinite(value.z);
			}
			return false;
		}
	}
	internal static class ClickGuiIcons
	{
		private const int TexSize = 48;

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

		private static readonly Dictionary<string, string> CategoryShapes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			["Self"] = "person",
			["Network"] = "people",
			["Players"] = "people",
			["Items"] = "box",
			["Teleport"] = "pin",
			["Spawn"] = "plus",
			["Visuals"] = "eye",
			["World"] = "globe",
			["Host"] = "crown",
			["Misc"] = "dots",
			["Search"] = "magnifier",
			["Settings"] = "gear"
		};

		public static Texture2D Tick => Get("tick");

		public static Texture2D Swap => Get("swap");

		public static Texture2D ForCategory(string category)
		{
			if (string.IsNullOrEmpty(category))
			{
				return null;
			}
			if (!CategoryShapes.TryGetValue(category, out var value))
			{
				return null;
			}
			return Get(value);
		}

		public static void Draw(Rect rect, Texture2D icon, Color tint)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)icon))
			{
				Color color = GUI.color;
				GUI.color = tint;
				GUI.DrawTexture(rect, (Texture)(object)icon, (ScaleMode)2, true);
				GUI.color = color;
			}
		}

		private static Texture2D Get(string shape)
		{
			if (Cache.TryGetValue(shape, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			Func<float, float, bool> shapeFunction = GetShapeFunction(shape);
			if (shapeFunction == null)
			{
				return null;
			}
			Texture2D val = Render(shapeFunction);
			Cache[shape] = val;
			return val;
		}

		private static Func<float, float, bool> GetShapeFunction(string shape)
		{
			return shape switch
			{
				"person" => (float x, float y) => Person(x, y, 0f, 0f, 1f), 
				"people" => People, 
				"box" => BoxIcon, 
				"pin" => Pin, 
				"plus" => Plus, 
				"eye" => Eye, 
				"globe" => Globe, 
				"crown" => Crown, 
				"dots" => Dots, 
				"magnifier" => Magnifier, 
				"gear" => Gear, 
				"swap" => SwapArrows, 
				"tick" => TickMark, 
				_ => null, 
			};
		}

		private static Texture2D Render(Func<float, float, bool> inside)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(48, 48, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			for (int i = 0; i < 48; i++)
			{
				for (int j = 0; j < 48; j++)
				{
					float num = 0f;
					for (int k = 0; k < 2; k++)
					{
						for (int l = 0; l < 2; l++)
						{
							float arg = ((float)j + 0.25f + (float)l * 0.5f) / 48f * 2f - 1f;
							float arg2 = ((float)i + 0.25f + (float)k * 0.5f) / 48f * 2f - 1f;
							if (inside(arg, arg2))
							{
								num += 0.25f;
							}
						}
					}
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num));
				}
			}
			val.Apply(false, false);
			return val;
		}

		private static bool Person(float x, float y, float cx, float cy, float s)
		{
			x = (x - cx) / s;
			y = (y - cy) / s;
			if (Circle(x, y, 0f, 0.42f, 0.3f))
			{
				return true;
			}
			float num = x / 0.52f;
			float num2 = (y + 0.52f) / 0.52f;
			if (num * num + num2 * num2 <= 1f)
			{
				return y <= -0.16f;
			}
			return false;
		}

		private static bool People(float x, float y)
		{
			if (!Person(x, y, -0.3f, 0.1f, 0.78f))
			{
				return Person(x, y, 0.38f, -0.16f, 0.7f);
			}
			return true;
		}

		private static bool BoxIcon(float x, float y)
		{
			if (!RoundRect(x, y, 0f, -0.05f, 0.62f, 0.55f, 0.1f))
			{
				return false;
			}
			if (!(y > 0.28f))
			{
				return y < 0.16f;
			}
			return true;
		}

		private static bool Pin(float x, float y)
		{
			if (Circle(x, y, 0f, 0.3f, 0.5f) && !Circle(x, y, 0f, 0.3f, 0.2f))
			{
				return true;
			}
			return Tri(x, y, -0.33f, 0.05f, 0.33f, 0.05f, 0f, -0.85f);
		}

		private static bool Plus(float x, float y)
		{
			if (!RoundRect(x, y, 0f, 0f, 0.58f, 0.17f, 0.08f))
			{
				return RoundRect(x, y, 0f, 0f, 0.17f, 0.58f, 0.08f);
			}
			return true;
		}

		private static bool Eye(float x, float y)
		{
			if (!Circle(x, y, 0f, 0.62f, 1.05f) || !Circle(x, y, 0f, -0.62f, 1.05f))
			{
				return false;
			}
			if (Circle(x, y, 0f, 0f, 0.34f))
			{
				return Circle(x, y, 0f, 0f, 0.15f);
			}
			return true;
		}

		private static bool Globe(float x, float y)
		{
			if (Ring(x, y, 0f, 0f, 0.82f, 0.64f))
			{
				return true;
			}
			if (!Circle(x, y, 0f, 0f, 0.72f))
			{
				return false;
			}
			if (Mathf.Abs(y) <= 0.09f)
			{
				return true;
			}
			float num = x / 0.36f;
			float num2 = y / 0.8f;
			return Mathf.Abs(Mathf.Sqrt(num * num + num2 * num2) - 1f) <= 0.16f;
		}

		private static bool Crown(float x, float y)
		{
			if (!RoundRect(x, y, 0f, -0.6f, 0.72f, 0.14f, 0.06f) && !Tri(x, y, -0.74f, -0.38f, -0.18f, -0.38f, -0.6f, 0.55f) && !Tri(x, y, -0.32f, -0.38f, 0.32f, -0.38f, 0f, 0.72f))
			{
				return Tri(x, y, 0.18f, -0.38f, 0.74f, -0.38f, 0.6f, 0.55f);
			}
			return true;
		}

		private static bool Dots(float x, float y)
		{
			if (!Circle(x, y, -0.58f, 0f, 0.18f) && !Circle(x, y, 0f, 0f, 0.18f))
			{
				return Circle(x, y, 0.58f, 0f, 0.18f);
			}
			return true;
		}

		private static bool Magnifier(float x, float y)
		{
			if (!Ring(x, y, -0.18f, 0.18f, 0.54f, 0.36f))
			{
				return Segment(x, y, 0.24f, -0.24f, 0.7f, -0.7f, 0.13f);
			}
			return true;
		}

		private static bool Gear(float x, float y)
		{
			float num = Mathf.Sqrt(x * x + y * y);
			if (num >= 0.3f && num <= 0.62f)
			{
				return true;
			}
			if (num > 0.62f && num <= 0.88f)
			{
				float num2 = Mathf.Repeat(Mathf.Atan2(y, x), MathF.PI / 4f);
				if (!(num2 <= 0.26f))
				{
					return num2 >= 0.5253982f;
				}
				return true;
			}
			return false;
		}

		private static bool SwapArrows(float x, float y)
		{
			bool num = Segment(x, y, -0.6f, 0.35f, 0.18f, 0.35f, 0.1f) || Tri(x, y, 0.12f, 0.62f, 0.12f, 0.08f, 0.66f, 0.35f);
			bool flag = Segment(x, y, -0.18f, -0.35f, 0.6f, -0.35f, 0.1f) || Tri(x, y, -0.12f, -0.08f, -0.12f, -0.62f, -0.66f, -0.35f);
			return num || flag;
		}

		private static bool TickMark(float x, float y)
		{
			if (!Segment(x, y, -0.62f, 0.05f, -0.16f, -0.44f, 0.15f))
			{
				return Segment(x, y, -0.16f, -0.44f, 0.62f, 0.42f, 0.15f);
			}
			return true;
		}

		private static bool Circle(float x, float y, float cx, float cy, float r)
		{
			float num = x - cx;
			float num2 = y - cy;
			return num * num + num2 * num2 <= r * r;
		}

		private static bool Ring(float x, float y, float cx, float cy, float outer, float inner)
		{
			float num = x - cx;
			float num2 = y - cy;
			float num3 = num * num + num2 * num2;
			if (num3 <= outer * outer)
			{
				return num3 >= inner * inner;
			}
			return false;
		}

		private static bool RoundRect(float x, float y, float cx, float cy, float halfW, float halfH, float r)
		{
			float num = Mathf.Abs(x - cx) - halfW + r;
			float num2 = Mathf.Abs(y - cy) - halfH + r;
			float num3 = Mathf.Max(num, 0f);
			float num4 = Mathf.Max(num2, 0f);
			return Mathf.Sqrt(num3 * num3 + num4 * num4) + Mathf.Min(Mathf.Max(num, num2), 0f) - r <= 0f;
		}

		private static bool Segment(float x, float y, float x1, float y1, float x2, float y2, float radius)
		{
			float num = x - x1;
			float num2 = y - y1;
			float num3 = x2 - x1;
			float num4 = y2 - y1;
			float num5 = num3 * num3 + num4 * num4;
			float num6 = ((num5 > 0f) ? Mathf.Clamp01((num * num3 + num2 * num4) / num5) : 0f);
			float num7 = num - num3 * num6;
			float num8 = num2 - num4 * num6;
			return num7 * num7 + num8 * num8 <= radius * radius;
		}

		private static bool Tri(float x, float y, float ax, float ay, float bx, float by, float cx, float cy)
		{
			float num = EdgeSign(x, y, ax, ay, bx, by);
			float num2 = EdgeSign(x, y, bx, by, cx, cy);
			float num3 = EdgeSign(x, y, cx, cy, ax, ay);
			bool flag = num < 0f || num2 < 0f || num3 < 0f;
			bool flag2 = num > 0f || num2 > 0f || num3 > 0f;
			return !(flag && flag2);
		}

		private static float EdgeSign(float px, float py, float ax, float ay, float bx, float by)
		{
			return (px - bx) * (ay - by) - (ax - bx) * (py - by);
		}
	}
	internal static class ClickGuiTheme
	{
		public static readonly Color WindowBg = Hex("#1D222Cff");

		public static readonly Color PanelBg = Hex("#2A303Dff");

		public static readonly Color SidebarBg = Hex("#12151Cff");

		public static readonly Color TitleBg = Hex("#050505ff");

		public static readonly Color TabIdle = Hex("#222834ff");

		public static readonly Color TabHover = Hex("#2E3648ff");

		public static readonly Color Text = Hex("#ECEFF4ff");

		public static readonly Color TextDim = Hex("#97A1B5ff");

		public static readonly Color IconIdle = Hex("#C7CEDBff");

		public static readonly Color CheckboxOff = Hex("#454D5Dff");

		public static readonly Color SliderTrack = Hex("#0A0C11ff");

		public static readonly Color ButtonBg = Hex("#414959ff");

		public static readonly Color ButtonHover = Hex("#4E586Cff");

		public static readonly Color CollapseBg = Hex("#0A0D13ff");

		public static readonly Color CollapseHover = Hex("#141926ff");

		public static readonly Color SubmenuBg = Hex("#1B202Bff");

		public static readonly Color PanelLine = Hex("#1B2130ff");

		public static readonly Color InputBg = Hex("#12161FCC");

		public static GUIStyle Title;

		public static GUIStyle PanelHeader;

		public static GUIStyle RowLabel;

		public static GUIStyle RowValue;

		public static GUIStyle ButtonText;

		public static GUIStyle CollapseText;

		public static GUIStyle TabGlyph;

		public static GUIStyle Tooltip;

		public static GUIStyle TextInput;

		public static GUIStyle Check;

		private static bool _init;

		private static float _appliedScale = -1f;

		private static bool _roundedSupported = true;

		public static Color Accent => MenuConfig.AccentColor;

		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			if (!_init)
			{
				_init = true;
				GUIStyle val = new GUIStyle();
				val.normal.textColor = Text;
				val.fontStyle = (FontStyle)1;
				val.alignment = (TextAnchor)4;
				Title = val;
				GUIStyle val2 = new GUIStyle();
				val2.normal.textColor = Accent;
				val2.fontStyle = (FontStyle)1;
				val2.alignment = (TextAnchor)3;
				PanelHeader = val2;
				GUIStyle val3 = new GUIStyle();
				val3.normal.textColor = Text;
				val3.alignment = (TextAnchor)3;
				val3.clipping = (TextClipping)1;
				RowLabel = val3;
				GUIStyle val4 = new GUIStyle();
				val4.normal.textColor = TextDim;
				val4.alignment = (TextAnchor)5;
				val4.clipping = (TextClipping)1;
				RowValue = val4;
				GUIStyle val5 = new GUIStyle();
				val5.normal.textColor = Text;
				val5.fontStyle = (FontStyle)1;
				val5.alignment = (TextAnchor)4;
				val5.clipping = (TextClipping)1;
				ButtonText = val5;
				GUIStyle val6 = new GUIStyle();
				val6.normal.textColor = Text;
				val6.fontStyle = (FontStyle)1;
				val6.alignment = (TextAnchor)3;
				val6.clipping = (TextClipping)1;
				CollapseText = val6;
				GUIStyle val7 = new GUIStyle();
				val7.normal.textColor = Text;
				val7.fontStyle = (FontStyle)1;
				val7.alignment = (TextAnchor)4;
				TabGlyph = val7;
				GUIStyle val8 = new GUIStyle();
				val8.normal.textColor = Text;
				val8.fontStyle = (FontStyle)1;
				val8.alignment = (TextAnchor)4;
				val8.clipping = (TextClipping)1;
				Tooltip = val8;
				GUIStyle val9 = new GUIStyle();
				val9.normal.textColor = Text;
				val9.focused.textColor = Text;
				val9.active.textColor = Text;
				val9.hover.textColor = Text;
				val9.alignment = (TextAnchor)3;
				val9.clipping = (TextClipping)1;
				TextInput = val9;
				GUIStyle val10 = new GUIStyle();
				val10.normal.textColor = Color.white;
				val10.fontStyle = (FontStyle)1;
				val10.alignment = (TextAnchor)4;
				Check = val10;
				ApplyScale(1f);
			}
		}

		public static void ApplyScale(float scale)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			if (_init)
			{
				scale = Mathf.Clamp(scale, 0.5f, 4f);
				if (!Mathf.Approximately(_appliedScale, scale))
				{
					_appliedScale = scale;
					Title.fontSize = Font(15f, scale);
					PanelHeader.fontSize = Font(14f, scale);
					RowLabel.fontSize = Font(12f, scale);
					RowValue.fontSize = Font(11f, scale);
					ButtonText.fontSize = Font(12f, scale);
					CollapseText.fontSize = Font(13f, scale);
					TabGlyph.fontSize = Font(17f, scale);
					Tooltip.fontSize = Font(11f, scale);
					TextInput.fontSize = Font(12f, scale);
					TextInput.padding = new RectOffset(Mathf.RoundToInt(6f * scale), Mathf.RoundToInt(6f * scale), 0, 0);
					Check.fontSize = Font(12f, scale);
				}
			}
		}

		public static void SyncAccent()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (_init)
			{
				PanelHeader.normal.textColor = Accent;
			}
		}

		private static int Font(float baseSize, float scale)
		{
			return Mathf.Max(1, Mathf.RoundToInt(baseSize * scale));
		}

		private static Color Hex(string h)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString(h, ref result);
			return result;
		}

		public static void Fill(Rect r, Color c)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}

		public static void RoundedFill(Rect r, Color c, float radius)
		{
			//IL_0060: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (((Rect)(ref r)).width <= 0f || ((Rect)(ref r)).height <= 0f)
			{
				return;
			}
			radius = Mathf.Min(radius, Mathf.Min(((Rect)(ref r)).width, ((Rect)(ref r)).height) * 0.5f);
			if (_roundedSupported && radius > 0.5f)
			{
				try
				{
					DrawRoundedInternal(r, c, radius);
					return;
				}
				catch (Exception)
				{
					_roundedSupported = false;
				}
			}
			Fill(r, c);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void DrawRoundedInternal(Rect r, Color c, float radius)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, c, 0f, radius);
		}
	}
	internal sealed class ClickGuiUI
	{
		private sealed class RowCache
		{
			public readonly List<object> Rows = new List<object>();

			public float NextRefreshTime = float.NegativeInfinity;
		}

		private struct PanelDef
		{
			public string Title;

			public string Category;

			public List<object> Rows;
		}

		private struct FitEntry
		{
			public float Width;

			public int BaseFontSize;

			public int FontSize;
		}

		private FeatureManager _features;

		public Action CloseRequested;

		private Rect _window;

		private bool _positioned;

		private bool _dragging;

		private Vector2 _dragOffset;

		private float _scale = 1f;

		private bool _themeInitialized;

		private bool _captureActive;

		private int _activeTab;

		private readonly Dictionary<string, float> _scrollByTab = new Dictionary<string, float>(StringComparer.Ordinal);

		private readonly HashSet<string> _expandedSubmenus = new HashSet<string>(StringComparer.Ordinal);

		private readonly Dictionary<string, RowCache> _rowCache = new Dictionary<string, RowCache>(StringComparer.Ordinal);

		private const float ProviderRefreshIntervalSeconds = 1f;

		private TextFeature _editTextFeature;

		private string _editText = string.Empty;

		private string _editTextOriginal = string.Empty;

		private bool _focusTextNext;

		private const string TextControl = "CubeX_ClickGuiText";

		private NumberFeature _dragSlider;

		private ColorFeature _expandedColor;

		private int _colorDrag;

		private float _colorHue;

		private float _colorSat;

		private float _colorVal;

		private Texture2D _hueTexture;

		private Texture2D _svTexture;

		private float _svTextureHue = -1f;

		private const int ColorTextureSize = 96;

		private const int ColorDragNone = 0;

		private const int ColorDragSv = 1;

		private const int ColorDragHue = 2;

		private Feature _hoverFeature;

		private string _hoverCategory;

		private Feature _lastHoverFeature;

		private float _hoverStartTime;

		private Rect _editBoxScreenRect;

		private Feature _sidePanelRow;

		private string _sidePanelRowCategory;

		private MenuSidePanel _activeSidePanel;

		private float _nextSidePanelRefreshTime = float.NegativeInfinity;

		private const float SidePanelRefreshIntervalSeconds = 0.15f;

		public SelectedPlayerPreviewPanel PlayerPreview;

		public Action<MenuSidePanel, Rect> SidePanelRenderer;

		private readonly Dictionary<string, string> _tabGlyphCache = new Dictionary<string, string>(StringComparer.Ordinal);

		private Font _glyphFont;

		private Rect _pendingTabTooltipRect;

		private string _pendingTabTooltipText;

		private const float WindowW = 700f;

		private const float WindowH = 560f;

		private const float TitleH = 34f;

		private const float SidebarW = 62f;

		private const float TabSize = 42f;

		private const float TabGap = 10f;

		private const float TabIconSize = 21f;

		private const float SidebarTopPad = 10f;

		private const float SidebarBottomReserve = 98f;

		private const float Pad = 14f;

		private const float ColGap = 14f;

		private const float HeaderH = 22f;

		private const float AccentBarH = 8f;

		private const float HeaderGap = 9f;

		private const float PanelGap = 18f;

		private const float RowH = 27f;

		private const float RowGap = 5f;

		private const float CheckSize = 17f;

		private const float ButtonH = 25f;

		private const float SliderH = 13f;

		private const float SubmenuBarH = 28f;

		private const float SubmenuIndent = 8f;

		private const float WindowRadius = 10f;

		private const int MaxSubmenuDepth = 8;

		private const float TooltipDelay = 0.55f;

		private const float ScrollbarW = 5f;

		private const float ScrollbarInset = 6f;

		private const float ScrollbarMinThumbH = 28f;

		private static readonly Dictionary<string, string> TabGlyphs = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			["Self"] = "●",
			["Network"] = "◎",
			["Players"] = "◎",
			["Items"] = "▰",
			["Teleport"] = "⌖",
			["Spawn"] = "✚",
			["Visuals"] = "★",
			["World"] = "◆",
			["Host"] = "▲",
			["Misc"] = "◇",
			["Search"] = "⌕",
			["Settings"] = "⚙"
		};

		private readonly List<PanelDef> _panelsBuffer = new List<PanelDef>();

		private readonly List<float> _panelHeights = new List<float>();

		private readonly List<object> _generalRowsBuffer = new List<object>();

		private readonly Dictionary<string, float> _submenuHeightCache = new Dictionary<string, float>(StringComparer.Ordinal);

		private bool _layoutDirty = true;

		private float _nextPanelRefreshTime = float.NegativeInfinity;

		private string _measuredCategory;

		private float _measuredColW = -1f;

		private float _measuredScale = -1f;

		private bool _contentClipActive;

		private float _contentClipMinY;

		private float _contentClipMaxY;

		private string _scrollbarDragCategory;

		private float _scrollbarDragOffset;

		private string _titleCategory;

		private string _titleText = "C U B E - X";

		private readonly Dictionary<string, float> _labelWidthCache = new Dictionary<string, float>(StringComparer.Ordinal);

		private readonly Dictionary<string, float> _buttonWidthCache = new Dictionary<string, float>(StringComparer.Ordinal);

		private readonly Dictionary<string, float> _tooltipWidthCache = new Dictionary<string, float>(StringComparer.Ordinal);

		private float _widthCacheScale = -1f;

		private static readonly GUIContent SharedContent = new GUIContent();

		private readonly Dictionary<(GUIStyle style, string text), FitEntry> _fitCache = new Dictionary<(GUIStyle, string), FitEntry>();

		private const int FitCacheLimit = 1500;

		private GUIStyle _closeIdleStyle;

		private GUIStyle _closeHoverStyle;

		private GUIStyle _versionStyle;

		private GUIStyle _tagStyle;

		private GUIStyle _tooltipBodyStyle;

		private GUIStyle _textPlaceholderStyle;

		private float _chromeStyleScale = -1f;

		private string _versionText;

		private readonly Dictionary<string, string> _submenuOpenLabels = new Dictionary<string, string>(StringComparer.Ordinal);

		private readonly Dictionary<string, string> _submenuClosedLabels = new Dictionary<string, string>(StringComparer.Ordinal);

		private readonly Dictionary<string, (string Label, string Text)> _keybindTextCache = new Dictionary<string, (string, string)>(StringComparer.Ordinal);

		private GUIStyle _centeredValueStyle;

		private float _centeredValueScale = -1f;

		private GUIStyle _sliderValueStyle;

		private GUIStyle _sliderValueShadowStyle;

		private float _sliderValueStyleScale = -1f;

		public bool BlocksGlobalHotkeys => _editTextFeature != null;

		public void Bind(FeatureManager features)
		{
			_features = features;
		}

		private float S(float value)
		{
			return value * _scale;
		}

		public void NotifyHidden()
		{
			if (_editTextFeature != null)
			{
				EndTextEdit(commit: true);
			}
			_dragSlider = null;
			_dragging = false;
			if (_expandedColor != null)
			{
				InvalidateLayout();
			}
			_expandedColor = null;
			_colorDrag = 0;
			_scrollbarDragCategory = null;
			_hoverFeature = null;
			_hoverCategory = null;
			_lastHoverFeature = null;
			_sidePanelRow = null;
			_sidePanelRowCategory = null;
			_activeSidePanel = null;
			_nextSidePanelRefreshTime = float.NegativeInfinity;
			PlayerPreview?.SetVisible(visible: false);
			EnsureCapture(active: false);
		}

		public void Render(float scale)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			if (_features == null)
			{
				return;
			}
			_scale = Mathf.Clamp(scale, 0.5f, 4f);
			EnsureTheme();
			EnsureWidthCaches();
			EnsureChromeStyles();
			EnsureCapture(active: true);
			List<string> categories = _features.Categories;
			if (categories.Count != 0)
			{
				_activeTab = Mathf.Clamp(_activeTab, 0, categories.Count - 1);
				string category = categories[_activeTab];
				Event current = Event.current;
				if ((int)current.type == 7)
				{
					_lastHoverFeature = _hoverFeature;
					_hoverFeature = null;
				}
				if ((int)current.type == 1)
				{
					_dragSlider = null;
					_colorDrag = 0;
					_scrollbarDragCategory = null;
				}
				HandleKeys();
				EnsureWindowRect();
				DrawShadow();
				ClickGuiTheme.RoundedFill(_window, ClickGuiTheme.WindowBg, S(10f));
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref _window)).x, ((Rect)(ref _window)).y, ((Rect)(ref _window)).width, S(34f));
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor(((Rect)(ref _window)).x, ((Rect)(ref val)).yMax, S(62f), ((Rect)(ref _window)).height - S(34f));
				Rect rect2 = default(Rect);
				((Rect)(ref rect2))..ctor(((Rect)(ref rect)).xMax, ((Rect)(ref val)).yMax, ((Rect)(ref _window)).width - S(62f), ((Rect)(ref _window)).height - S(34f));
				_pendingTabTooltipText = null;
				DrawTitleBar(val, category);
				DrawSidebar(rect, categories);
				DrawContent(rect2, category);
				if (_pendingTabTooltipText != null)
				{
					DrawTabTooltip(_pendingTabTooltipRect, _pendingTabTooltipText);
				}
				HandleDrag(val);
				DrawSidePanelIfAny();
				DrawTooltip();
				if (_editTextFeature != null && (int)current.rawType == 0 && !((Rect)(ref _editBoxScreenRect)).Contains(GUIUtility.GUIToScreenPoint(current.mousePosition)))
				{
					EndTextEdit(commit: true);
				}
			}
		}

		private void EnsureTheme()
		{
			if (!_themeInitialized)
			{
				ClickGuiTheme.Init();
				_themeInitialized = true;
			}
			ClickGuiTheme.ApplyScale(_scale);
			ClickGuiTheme.SyncAccent();
		}

		private void EnsureCapture(bool active)
		{
			if (_captureActive != active)
			{
				_captureActive = active;
				if (active)
				{
					MenuInputCapture.Begin(MenuInputCaptureReason.ClickGui);
				}
				else
				{
					MenuInputCapture.End(MenuInputCaptureReason.ClickGui);
				}
			}
		}

		private void EnsureWindowRect()
		{
			((Rect)(ref _window)).width = S(700f);
			int num = ((_features != null) ? _features.Categories.Count : 0);
			float num2 = S(10f) + (float)num * (S(42f) + S(10f)) + S(98f);
			float num3 = S(34f) + num2;
			float num4 = ((Screen.height > 0) ? ((float)Screen.height * 0.94f) : num3);
			((Rect)(ref _window)).height = Mathf.Min(Mathf.Max(S(560f), num3), Mathf.Max(S(320f), num4));
			if (!_positioned && Screen.width > 0 && Screen.height > 0)
			{
				((Rect)(ref _window)).x = Mathf.Clamp((float)Screen.width * 0.06f, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _window)).width));
				((Rect)(ref _window)).y = Mathf.Clamp((float)Screen.height * 0.08f, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _window)).height));
				_positioned = true;
			}
			((Rect)(ref _window)).x = Mathf.Clamp(((Rect)(ref _window)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _window)).width));
			((Rect)(ref _window)).y = Mathf.Clamp(((Rect)(ref _window)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _window)).height));
		}

		private void DrawShadow()
		{
			//IL_0044: 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)
			ClickGuiTheme.RoundedFill(new Rect(((Rect)(ref _window)).x + S(4f), ((Rect)(ref _window)).y + S(7f), ((Rect)(ref _window)).width, ((Rect)(ref _window)).height), new Color(0f, 0f, 0f, 0.5f), S(10f));
		}

		private void DrawTitleBar(Rect rect, string category)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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)
			ClickGuiTheme.RoundedFill(rect, ClickGuiTheme.TitleBg, S(10f));
			ClickGuiTheme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - S(10f), ((Rect)(ref rect)).width, S(10f)), ClickGuiTheme.TitleBg);
			if (!string.Equals(_titleCategory, category, StringComparison.Ordinal))
			{
				_titleCategory = category;
				_titleText = (string.IsNullOrEmpty(category) ? "C U B E - X" : ("C U B E - X   /   " + category));
			}
			GUI.Label(rect, _titleText, ClickGuiTheme.Title);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).xMax - S(28f), ((Rect)(ref rect)).y + S(6f), S(20f), S(20f));
			bool flag = ((Rect)(ref val)).Contains(Event.current.mousePosition);
			GUI.Label(val, "×", flag ? _closeHoverStyle : _closeIdleStyle);
			if (IsClick(val))
			{
				CloseRequested?.Invoke();
				Event.current.Use();
			}
		}

		private void DrawSidebar(Rect rect, List<string> tabs)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			float num = S(10f);
			ClickGuiTheme.RoundedFill(rect, ClickGuiTheme.SidebarBg, num);
			ClickGuiTheme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, num), ClickGuiTheme.SidebarBg);
			ClickGuiTheme.Fill(new Rect(((Rect)(ref rect)).xMax - num, ((Rect)(ref rect)).y, num, ((Rect)(ref rect)).height - num), ClickGuiTheme.SidebarBg);
			float num2 = S(42f);
			float num3 = S(10f);
			float num4 = ((Rect)(ref rect)).y + S(10f);
			float num5 = ((Rect)(ref rect)).height - S(10f) - S(98f);
			if (tabs.Count > 0 && (float)tabs.Count * (num2 + num3) > num5)
			{
				num3 = Mathf.Max(S(2f), num5 / (float)tabs.Count - num2);
				if ((float)tabs.Count * (num2 + num3) > num5)
				{
					num2 = Mathf.Max(S(24f), num5 / (float)tabs.Count - num3);
				}
			}
			float num6 = ((Rect)(ref rect)).x + (((Rect)(ref rect)).width - num2) * 0.5f;
			Rect val = default(Rect);
			for (int i = 0; i < tabs.Count; i++)
			{
				((Rect)(ref val))..ctor(num6, num4, num2, num2);
				bool flag = i == _activeTab;
				bool flag2 = ((Rect)(ref val)).Contains(Event.current.mousePosition);
				Color c = (flag ? ClickGuiTheme.Accent : (flag2 ? ClickGuiTheme.TabHover : ClickGuiTheme.TabIdle));
				ClickGuiTheme.RoundedFill(val, c, S(10f));
				DrawTabIcon(val, tabs[i], flag || flag2);
				if (flag2)
				{
					_pendingTabTooltipRect = val;
					_pendingTabTooltipText = tabs[i];
				}
				if (IsClick(val))
				{
					if (_activeTab != i)
					{
						_activeTab = i;
						CloseTransientEditors();
						_scrollbarDragCategory = null;
						InvalidateLayout();
					}
					Event.current.Use();
				}
				num4 += num2 + num3;
			}
			DrawSidebarFooter(rect);
		}

		private void DrawSidebarFooter(Rect rect)
		{
			//IL_0048: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_0083: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			float num = S(42f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x + (((Rect)(ref rect)).width - num) * 0.5f, ((Rect)(ref rect)).yMax - num - S(26f), num, num);
			bool flag = ((Rect)(ref val)).Contains(Event.current.mousePosition);
			ClickGuiTheme.RoundedFill(val, flag ? ClickGuiTheme.TabHover : ClickGuiTheme.TabIdle, S(10f));
			Texture2D swap = ClickGuiIcons.Swap;
			if (Object.op_Implicit((Object)(object)swap))
			{
				ClickGuiIcons.Draw(CenteredIconRect(val), swap, flag ? Color.white : ClickGuiTheme.IconIdle);
			}
			else
			{
				GUI.Label(val, GlyphOr("⇄", "≡"), ClickGuiTheme.TabGlyph);
			}
			if (IsClick(val))
			{
				SwitchToListUi();
				Event.current.Use();
			}
			if (flag)
			{
				_pendingTabTooltipRect = val;
				_pendingTabTooltipText = "Switch to List UI";
			}
			if (_versionText == null)
			{
				_versionText = "v2.2.3";
			}
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - S(20f), ((Rect)(ref rect)).width, S(16f)), _versionText, _versionStyle);
		}

		private void DrawTabTooltip(Rect tile, string text)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 7)
			{
				if (!_tooltipWidthCache.TryGetVa