Decompiled source of CubeX v1.4.3
plugins/CubeX.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
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.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using CubeX.Core; 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.Diagnostics; using CubeX.Runtime.Network; using CubeX.Runtime.Player; 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("1.4.3.0")] [assembly: AssemblyInformationalVersion("1.4.3+6ac64bd843fef04fac22c8eaa7299f76a04637a4")] [assembly: AssemblyProduct("Cube-X mod menu for PEAK")] [assembly: AssemblyTitle("CubeX")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.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", "1.4.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 = "1.4.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; } private void Awake() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) 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>(); NotificationSystem.MarkReady(); _harmony = new Harmony("com.mister9982.cubex"); PatchAllSafely(); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); CubeXDiagnostics.Info("Cube-X", "v1.4.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 OnDestroy() { 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 = "1.4.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 : MonoBehaviour, IInRoomCallbacks { private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } public void OnPlayerEnteredRoom(Player newPlayer) { IncomingRpcGuard.NotePlayerJoined(newPlayer); RecentPlayersStore.Record(newPlayer); if (!PlayerBlacklistStore.TryBlock(newPlayer) && NotificationSettings.JoinLeave && newPlayer != null && !newPlayer.IsLocal) { NotificationSystem.Push("Player Joined", GetPlayerName(newPlayer), NotificationKind.Success); } } public void OnPlayerLeftRoom(Player otherPlayer) { IncomingRpcGuard.NotePlayerLeft(otherPlayer); RecentPlayersStore.Record(otherPlayer); if (NotificationSettings.JoinLeave && otherPlayer != null && !otherPlayer.IsLocal) { NotificationSystem.Push("Player Left", GetPlayerName(otherPlayer), NotificationKind.Warning); } } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnMasterClientSwitched(Player 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 static readonly Color BackgroundColor = new Color(0.015f, 0.016f, 0.018f, 1f); private GameObject _root; private Camera _camera; private RenderTexture _target; private bool _visible; public bool HasPreview { get { if (PlayerDirectory.TryGetSelectedCharacter(out var character)) { return Object.op_Implicit((Object)(object)character); } return false; } } public Texture GetTexture() { SetVisible(visible: true); EnsureResources(); RefreshCamera(); return (Texture)(object)_target; } public void SetVisible(bool visible) { _visible = visible; if (!visible && Object.op_Implicit((Object)(object)_camera)) { ((Behaviour)_camera).enabled = false; } } public void Dispose() { 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; } 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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; } 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(); } if (Object.op_Implicit((Object)(object)_camera) && (Object)(object)_camera.targetTexture != (Object)(object)_target) { _camera.targetTexture = _target; } } private void RefreshCamera() { if (!Object.op_Implicit((Object)(object)_camera)) { return; } if (_visible && PlayerDirectory.TryGetSelectedCharacter(out var character) && Object.op_Implicit((Object)(object)character)) { CharacterData data = character.data; if (data == null || !data.dead) { ConfigureCamera(character); ((Behaviour)_camera).enabled = true; return; } } ((Behaviour)_camera).enabled = false; ClearTarget(); } private void ConfigureCamera(Character character) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00de: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; _camera.cullingMask = ((Object.op_Implicit((Object)(object)main) && (Object)(object)main != (Object)(object)_camera) ? (main.cullingMask & -33) : (-1)); _camera.backgroundColor = BackgroundColor; Bounds bounds; bool num = TryGetCharacterBounds(character, out bounds); Vector3 fallbackCenter = GetFallbackCenter(character); Vector3 val = (num ? ((Bounds)(ref bounds)).center : fallbackCenter); float num2 = (num ? Mathf.Max(0.75f, ((Bounds)(ref bounds)).size.y) : 1.7f); float num3 = (num ? Mathf.Max(0.45f, ((Bounds)(ref bounds)).size.x) : 0.8f); Vector3 val2 = (Vector3)(num ? new Vector3(val.x, ((Bounds)(ref bounds)).min.y + num2 * 0.52f, val.z) : (fallbackCenter + Vector3.up * 0.15f)); Vector3 frontViewDirection = GetFrontViewDirection(character, val, main); float num4 = Mathf.Clamp(num2 * 1.3f, 1.5f, 4f); Vector3 val3 = val2 + frontViewDirection * num4 + Vector3.up * num2 * 0.02f; _camera.orthographic = true; ((Component)_camera).transform.position = val3; ((Component)_camera).transform.rotation = Quaternion.LookRotation(val2 - val3, Vector3.up); float num5 = 0.75f; float num6 = Mathf.Max(0.45f, num2 * 0.53f); float num7 = Mathf.Max(0.45f, num3 / Mathf.Max(0.1f, num5) * 0.68f); _camera.orthographicSize = Mathf.Max(num6, num7); _camera.nearClipPlane = 0.02f; _camera.farClipPlane = Mathf.Max(8f, num4 + 8f); } private static Vector3 GetFrontViewDirection(Character character, Vector3 bodyCenter, Camera main) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0057: 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_0041: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (!TryGetFaceDirection(character, bodyCenter, out var direction)) { Transform previewRoot = GetPreviewRoot(character); direction = (Object.op_Implicit((Object)(object)previewRoot) ? (-previewRoot.forward) : (Object.op_Implicit((Object)(object)((Component)character).transform) ? (-((Component)character).transform.forward) : Vector3.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 static bool TryGetFaceDirection(Character character, 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_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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) direction = Vector3.zero; CustomizationRefs val = (Object.op_Implicit((Object)(object)character.refs?.customization) ? character.refs.customization.refs : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } Vector3 center = Vector3.zero; int count = 0; AddRendererCenter(val.mouthRenderer, ref center, ref count); Renderer[] eyeRenderers = val.EyeRenderers; if (eyeRenderers != null) { for (int i = 0; i < eyeRenderers.Length; i++) { AddRendererCenter(eyeRenderers[i], ref center, ref count); } } if (count <= 0) { return false; } center /= (float)count; Vector3 val2 = ((Object.op_Implicit((Object)(object)character) && IsFinite(character.Head)) ? character.Head : bodyCenter); direction = Vector3.ProjectOnPlane(center - val2, Vector3.up); return ((Vector3)(ref direction)).sqrMagnitude > 0.0001f; } private static void AddRendererCenter(Renderer renderer, ref Vector3 center, ref int count) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (ShouldUseRenderer(renderer)) { Vector3 val = center; Bounds bounds = renderer.bounds; center = val + ((Bounds)(ref bounds)).center; count++; } } private static bool TryGetCharacterBounds(Character character, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); Transform previewRoot = GetPreviewRoot(character); if (!Object.op_Implicit((Object)(object)previewRoot)) { return false; } bool flag = TryGetRendererBounds(previewRoot, out bounds); if (!flag && Object.op_Implicit((Object)(object)((Component)character).transform) && (Object)(object)previewRoot != (Object)(object)((Component)character).transform) { flag = TryGetRendererBounds(((Component)character).transform, out bounds); } return flag; } private static Transform GetPreviewRoot(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 bool TryGetRendererBounds(Transform root, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); if (!Object.op_Implicit((Object)(object)root)) { return false; } Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(false); bool flag = false; foreach (Renderer val in componentsInChildren) { if (ShouldUseRenderer(val)) { 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 static bool ShouldUseRenderer(Renderer renderer) { if (!Object.op_Implicit((Object)(object)renderer) || !renderer.enabled || !((Component)renderer).gameObject.activeInHierarchy) { 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.op_Implicit((Object)(object)((Component)renderer).gameObject) ? (((Object)((Component)renderer).gameObject).name ?? string.Empty) : string.Empty); if (obj.IndexOf("shadow", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("shadow", StringComparison.OrdinalIgnoreCase) < 0; } return false; } private void ClearTarget() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_target)) { RenderTexture active = RenderTexture.active; RenderTexture.active = _target; GL.Clear(true, true, BackgroundColor); RenderTexture.active = active; } } private static Vector3 GetFallbackCenter(Character character) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)character)) { return Vector3.zero; } Vector3 center = character.Center; if (IsFinite(center)) { return center; } if (!Object.op_Implicit((Object)(object)((Component)character).transform)) { return Vector3.zero; } return ((Component)character).transform.position + Vector3.up * 0.9f; } 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 DiscordCommunityPrompt { private const string InviteUrl = "https://discord.gg/cHmp58MqPf"; private static bool _dismissedThisSession; private static bool? _dismissedPersisted; private static GUIStyle _titleStyle; private static GUIStyle _bodyStyle; private static GUIStyle _buttonStyle; private const string StateFolderName = "State"; private static string StatePath => AppDataPaths.FilePath("State", "discord_prompt_seen"); public static bool ShouldRender { get { if (!_dismissedThisSession) { return !IsDismissedPersisted(); } return false; } } public static void OpenInvite() { Application.OpenURL("https://discord.gg/cHmp58MqPf"); } public static void Render() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) if (ShouldRender) { EnsureStyles(); float num = Mathf.Min(420f, Mathf.Max(280f, (float)Screen.width - 36f)); float num2 = 168f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, Mathf.Max(24f, (float)Screen.height * 0.18f), num, num2); Theme.Fill(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new Color(0f, 0f, 0f, 0.42f)); Theme.Fill(val, new Color(0.035f, 0.035f, 0.04f, 0.96f)); Theme.Fill(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 4f, ((Rect)(ref val)).height), MenuConfig.AccentColor); DrawOutline(val, new Color(1f, 1f, 1f, 0.14f), 1f); GUI.Label(new Rect(((Rect)(ref val)).x + 20f, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width - 40f, 28f), "Join the Cube-X Discord?", _titleStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 20f, ((Rect)(ref val)).y + 52f, ((Rect)(ref val)).width - 40f, 46f), "Get updates, support, and community help from the Discord server.", _bodyStyle); Rect val2 = new Rect(((Rect)(ref val)).x + ((Rect)(ref val)).width - 220f, ((Rect)(ref val)).yMax - 52f, 96f, 32f); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref val)).x + ((Rect)(ref val)).width - 114f, ((Rect)(ref val)).yMax - 52f, 94f, 32f); if (GUI.Button(val2, "Join", _buttonStyle)) { Dismiss(); OpenInvite(); Event.current.Use(); } if (GUI.Button(val3, "Not Now", _buttonStyle)) { Dismiss(); Event.current.Use(); } } } private static void Dismiss() { _dismissedThisSession = true; _dismissedPersisted = true; try { Directory.CreateDirectory(AppDataPaths.DirectoryPath("State")); File.WriteAllText(StatePath, "1"); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Discord Prompt] Failed to persist dismissal: " + ex.Message)); } } } private static bool IsDismissedPersisted() { if (_dismissedPersisted.HasValue) { return _dismissedPersisted.Value; } try { AppDataPaths.MigrateFileToDirectory("discord_prompt_seen", "State"); _dismissedPersisted = File.Exists(StatePath); } catch { _dismissedPersisted = false; } return _dismissedPersisted.Value; } private static void EnsureStyles() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0093: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if (_titleStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1 }; val.normal.textColor = Color.white; val.clipping = (TextClipping)1; _titleStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 13 }; val2.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f); val2.wordWrap = true; _bodyStyle = val2; _buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 13, fontStyle = (FontStyle)1 }; } } private static void DrawOutline(Rect rect, Color color, float thickness) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) Theme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, thickness), color); Theme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - thickness, ((Rect)(ref rect)).width, thickness), color); Theme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), color); Theme.Fill(new Rect(((Rect)(ref rect)).xMax - thickness, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), color); } } public struct ColorPreset { public readonly string Name; public readonly Color Color; public ColorPreset(string name, Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Name = name; Color = color; } } public static class MenuConfig { public static readonly ColorPreset[] Presets = new ColorPreset[8] { new ColorPreset("Teal", new Color(0.243f, 0.706f, 0.537f, 1f)), new ColorPreset("Purple", new Color(0.486f, 0.361f, 1f, 1f)), new ColorPreset("Crimson", new Color(0.937f, 0.267f, 0.267f, 1f)), new ColorPreset("Sky", new Color(0.231f, 0.62f, 0.965f, 1f)), new ColorPreset("Lime", new Color(0.486f, 0.831f, 0.267f, 1f)), new ColorPreset("Amber", new Color(0.976f, 0.69f, 0.086f, 1f)), new ColorPreset("Pink", new Color(0.945f, 0.345f, 0.62f, 1f)), new ColorPreset("Cyan", new Color(0.063f, 0.808f, 0.851f, 1f)) }; public static int PresetIndex = 0; public static Color AccentColor = Presets[0].Color; private const float ReferenceWidth = 1920f; private const float ReferenceHeight = 1080f; private const float MinUIScale = 0.5f; private const float MaxConfiguredUIScale = 4f; private const float DefaultMenuWidth = 480f; private const float DefaultUIScale = 1f; private const float DefaultHighlightLerpSpeed = 18f; private const int DefaultMaxVisibleRows = 12; public static float MenuWidth = 480f; public static float UIScale = 1f; public static float HighlightLerpSpeed = 18f; public static int MaxVisibleRows = 12; public static bool ShowBreadcrumb = true; public static bool ShowDescription = true; public static bool ShowFooter = true; public static bool ShowScrollbar = true; public static bool AutoSave = false; public static bool AutoLoadOnStart = true; public static bool OpenMenuOnLaunch = true; public static void ApplyPreset(int index) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) int num = Presets.Length; PresetIndex = (index % num + num) % num; AccentColor = Presets[PresetIndex].Color; } public static void SetAccentColor(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0045: 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_007f: Unknown result type (might be due to invalid IL or missing references) AccentColor = new Color(Mathf.Clamp01(color.r), Mathf.Clamp01(color.g), Mathf.Clamp01(color.b), 1f); for (int i = 0; i < Presets.Length; i++) { Color color2 = Presets[i].Color; if (Mathf.Abs(color2.r - AccentColor.r) <= 0.001f && Mathf.Abs(color2.g - AccentColor.g) <= 0.001f && Mathf.Abs(color2.b - AccentColor.b) <= 0.001f) { PresetIndex = i; break; } } } public static float GetMaxUIScale() { if (Screen.width <= 0 || Screen.height <= 0) { return 4f; } float num = (float)Screen.width / 1920f; float num2 = (float)Screen.height / 1080f; return Mathf.Max(1f, Mathf.Min(num, num2)); } public static float GetResolvedUIScale() { return Mathf.Clamp(UIScale, 0.5f, GetMaxUIScale()); } public static void SetUIScale(float scale) { UIScale = Mathf.Clamp(scale, 0.5f, GetMaxUIScale()); } public static void ResetToDefaults() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) PresetIndex = 0; AccentColor = Presets[0].Color; MenuWidth = 480f; UIScale = 1f; HighlightLerpSpeed = 18f; MaxVisibleRows = 12; ShowBreadcrumb = true; ShowDescription = true; ShowFooter = true; ShowScrollbar = true; AutoSave = false; AutoLoadOnStart = true; OpenMenuOnLaunch = true; } } internal static class MenuControllerInput { private sealed class DirectionRepeater { private int _heldDirection; private float _nextRepeatAt; public int Consume(int direction) { if (direction == 0) { Reset(); return 0; } float unscaledTime = Time.unscaledTime; if (direction != _heldDirection) { _heldDirection = direction; _nextRepeatAt = unscaledTime + 0.32f; return direction; } if (unscaledTime < _nextRepeatAt) { return 0; } _nextRepeatAt = unscaledTime + 0.09f; return direction; } public void Reset() { _heldDirection = 0; _nextRepeatAt = 0f; } } private const float RepeatDelay = 0.32f; private const float RepeatInterval = 0.09f; private static readonly DirectionRepeater VerticalRepeat = new DirectionRepeater(); private static readonly DirectionRepeater HorizontalRepeat = new DirectionRepeater(); private static bool _confirmHeld; private static bool _backHeld; private static bool _toggleChordHeld; public static bool ToggleMenuPressed() { bool flag = ToggleMenuChordHeld(); bool result = flag && !_toggleChordHeld; _toggleChordHeld = flag; return result; } public static bool ToggleMenuChordHeld() { Gamepad val = CurrentGamepad(); if (val != null && val.dpad.right.isPressed) { return val.rightShoulder.isPressed; } return false; } public static bool ConfirmPressed() { Gamepad obj = CurrentGamepad(); return ConsumePress(obj != null && obj.buttonSouth.isPressed, ref _confirmHeld); } public static bool BackPressed() { Gamepad obj = CurrentGamepad(); return ConsumePress(obj != null && obj.buttonEast.isPressed, ref _backHeld); } public static int ConsumeVerticalDirection() { Gamepad val = CurrentGamepad(); int direction = 0; if (val != null) { if (val.dpad.up.isPressed) { direction = -1; } else if (val.dpad.down.isPressed) { direction = 1; } } return VerticalRepeat.Consume(direction); } public static int ConsumeHorizontalDirection() { Gamepad val = CurrentGamepad(); int direction = 0; if (val != null) { if (val.dpad.left.isPressed) { direction = -1; } else if (val.dpad.right.isPressed && !val.rightShoulder.isPressed) { direction = 1; } } return HorizontalRepeat.Consume(direction); } public static void Reset() { VerticalRepeat.Reset(); HorizontalRepeat.Reset(); _confirmHeld = false; _backHeld = false; } private static Gamepad CurrentGamepad() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Gamepad current = Gamepad.current; if (current != null) { return current; } if (Gamepad.all.Count <= 0) { return null; } return Gamepad.all[0]; } private static bool ConsumePress(bool pressed, ref bool held) { bool result = pressed && !held; held = pressed; return result; } } [Flags] internal enum MenuInputCaptureReason { None = 0, Prompt = 1, ColorPicker = 2, TextInput = 4, KeybindCapture = 8 } internal static class MenuInputCapture { private static MenuInputCaptureReason _activeReasons; private static bool _menuOpen; private static bool _savedCursorVisible; private static CursorLockMode _savedLockState; private static bool _lastFocusedCursorVisible; private static CursorLockMode _lastFocusedLockState; private static bool _hasLastFocusedCursorState; private static bool _restorePending; public static bool BlocksPlayerInput => _activeReasons != MenuInputCaptureReason.None; public static bool SuppressesMenuEmoteInput => _menuOpen; public static Action ReleaseGameInputsHandler { get; set; } public static void SetMenuOpen(bool open) { _menuOpen = open; ReleaseGameInputs(); } public static void Begin() { Begin(MenuInputCaptureReason.ColorPicker); } public static void Begin(MenuInputCaptureReason reason) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (reason != MenuInputCaptureReason.None) { if (_activeReasons == MenuInputCaptureReason.None) { RecordFocusedCursorState(); _savedCursorVisible = (_hasLastFocusedCursorState ? _lastFocusedCursorVisible : Cursor.visible); _savedLockState = (_hasLastFocusedCursorState ? _lastFocusedLockState : Cursor.lockState); _restorePending = false; } _activeReasons |= reason; ApplyCursor(); } } public static void Tick() { if (_activeReasons != MenuInputCaptureReason.None) { ApplyCursor(); } else if (_restorePending && Application.isFocused) { RestoreCursorNow(); _restorePending = false; RecordFocusedCursorState(); } else { RecordFocusedCursorState(); } } public static void End() { End(MenuInputCaptureReason.ColorPicker); } public static void End(MenuInputCaptureReason reason) { if (reason != MenuInputCaptureReason.None && (_activeReasons & reason) != MenuInputCaptureReason.None) { _activeReasons &= ~reason; if (_activeReasons == MenuInputCaptureReason.None) { RestoreCursor(); } } } public static void EndAll() { if (_activeReasons != MenuInputCaptureReason.None) { _activeReasons = MenuInputCaptureReason.None; RestoreCursor(); } } public static void ReleaseGameInputs() { ReleaseGameInputsHandler?.Invoke(); } private static void RestoreCursor() { if (!Application.isFocused) { _restorePending = true; return; } RestoreCursorNow(); RecordFocusedCursorState(); } private static void RestoreCursorNow() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Cursor.visible = _savedCursorVisible; Cursor.lockState = _savedLockState; } private static void ApplyCursor() { if (Application.isFocused) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private static void RecordFocusedCursorState() { //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) if (Application.isFocused) { _lastFocusedCursorVisible = Cursor.visible; _lastFocusedLockState = Cursor.lockState; _hasLastFocusedCursorState = true; } } } internal interface IMenuInputProvider { bool AnyKey { get; } bool AnyKeyDown(); bool GetKey(KeyCode key); bool GetKeyDown(KeyCode key); } internal static class MenuInputProvider { private sealed class UnityMenuInputProvider : IMenuInputProvider { public bool AnyKey { get { try { return Input.anyKey; } catch (InvalidOperationException) { return false; } } } public bool AnyKeyDown() { try { return Input.anyKeyDown; } catch (InvalidOperationException) { return false; } } public bool GetKey(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { return Input.GetKey(key); } catch (InvalidOperationException) { return false; } } public bool GetKeyDown(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { return Input.GetKeyDown(key); } catch (InvalidOperationException) { return false; } } } public static IMenuInputProvider Current { get; set; } = new UnityMenuInputProvider(); } public class MenuUI : MonoBehaviour { private readonly struct MenuNavigationState { public string Category { get; } public int SelectedIndex { get; } public float ScrollY { get; } public float ScrollYTarget { get; } public MenuNavigationState(string category, int selectedIndex, float scrollY, float scrollYTarget) { Category = category; SelectedIndex = selectedIndex; ScrollY = scrollY; ScrollYTarget = scrollYTarget; } } private FeatureManager _features; private bool _isOpen; private string _category; private int _selected; private readonly List<object> _rows = new List<object>(); private readonly Dictionary<string, string> _categoryTitles = new Dictionary<string, string>(); private readonly Stack<MenuNavigationState> _navigationStack = new Stack<MenuNavigationState>(); private float _highlightY; private float _highlightYTarget; private float _scrollY; private float _scrollYTarget; private bool _animationsInited; private bool _editingNumber; private NumberFeature _editingNumberFeature; private int _editingNumberIndex = -1; private string _editingText = string.Empty; private bool _focusNumberInputNext; private const string NumberInputControl = "CubeX_NumberInput"; private bool _editingTextFeatureActive; private TextFeature _editingTextFeature; private int _editingTextIndex = -1; private string _editingTextOriginal = string.Empty; private bool _focusTextInputNext; private const string TextInputControl = "CubeX_TextInput"; private bool _editingColor; private ColorFeature _editingColorFeature; private int _editingColorIndex = -1; private float _colorHue; private float _colorSaturation; private float _colorValue; private Color _editingColorPreview = Color.white; private int _colorDragTarget; private Texture2D _colorHueTexture; private Texture2D _colorSatValTexture; private Texture2D _staminaStripeTexture; private float _colorSatValTextureHue = -1f; private GUIStyle _descriptionTextStyle; private float _descriptionTextStyleScale = -1f; private readonly StringBuilder _descriptionWrapBuilder = new StringBuilder(); private readonly Dictionary<string, float> _smoothPlayerMetrics = new Dictionary<string, float>(); private readonly Dictionary<string, string> _afflictionKeyCache = new Dictionary<string, string>(StringComparer.Ordinal); private float[] _afflictionPercentsBuffer = new float[32]; private GUIStyle _statusBannerLabel; private GUIStyle _statusBannerStatus; private GUIStyle _statusBannerValue; private GUIStyle _vitalsLabel; private GUIStyle _vitalsValue; private GUIStyle _miniCardLabel; private GUIStyle _miniCardIcon; private GUIStyle _miniCardValue; private float _panelStylesScale = -1f; private readonly SelectedPlayerPreviewPanel _selectedPlayerPreviewPanel = new SelectedPlayerPreviewPanel(); private Rect _window = new Rect(-1f, -1f, 480f, 720f); private bool _hasPositionedWindow; private bool _dragging; private Vector2 _dragOffset; private float _scale = 1f; private bool _themeInitialized; private bool _rowsDirty = true; private int _lastMenuRefreshFrame = -1; private int _lastRowsRefreshFrame = -1; private int _lastOverlayRenderFrame = -1; private float _heroH; private float _titleH; private float _rowsH; private float _pickerH; private float _footerGapH; private float _footerH; private float _descriptionGapH; private float _descriptionH; private float _toggleTextWidth = -1f; private float _toggleTextWidthScale = -1f; private float _layoutScale = -1f; private float _layoutMenuWidth = -1f; private int _layoutRowsCount = -1; private int _layoutSelected = -1; private int _layoutMaxVisibleRows = -1; private bool _layoutEditingColor; private bool _layoutShowFooter; private bool _layoutShowDescription; private string _layoutDescription = string.Empty; private const float HeroH = 96f; private const float TitleBarH = 34f; private const float RowH = 38f; private const float Gap = 8f; private const float DescMinH = 54f; private const float DescMaxH = 320f; private const float FooterH = 38f; private const float FooterGapH = 8f; private const float DiamondSize = 56f; private const float NumberBoolValueW = 72f; private const float VectorBoolValueW = 128f; private const float ToggleGapW = 8f; private const float ColorPickerH = 224f; private const float ColorSwatchSize = 20f; private const float ColorHueStripW = 22f; private const float DescPadX = 16f; private const float DescPadTop = 12f; private const float DescPadBottom = 12f; private const float SidePanelW = 430f; private const float SidePanelGap = 10f; private const float SidePanelTitleH = 38f; private const float PlayerPreviewPanelW = 300f; private const float ScrollbarW = 8f; private const float ScrollbarGap = 9f; private const float InitialWindowInsetX = 140f; private const float InitialWindowInsetY = 88f; private const float InitialWindowScreenInsetX = 0.1f; private const float InitialWindowScreenInsetY = 0.1f; private const int OverlayGuiDepth = 2000; private const int MenuGuiDepth = 0; private const int NotificationGuiDepth = -2000; private const int ColorTextureSize = 128; private const int ColorDragNone = 0; private const int ColorDragSaturationValue = 1; private const int ColorDragHue = 2; private static int _lastNotificationRenderFrame = -1; private static readonly Color AfflictionColorFallback = new Color(0.55f, 0.55f, 0.55f, 1f); private static readonly Dictionary<string, Color> AfflictionColors = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase) { ["injury"] = new Color(0.82f, 0.16f, 0.14f, 1f), ["hunger"] = new Color(0.92f, 0.54f, 0.12f, 1f), ["cold"] = new Color(0.22f, 0.58f, 0.94f, 1f), ["poison"] = new Color(0.46f, 0.78f, 0.18f, 1f), ["crab"] = new Color(0.9f, 0.32f, 0.22f, 1f), ["curse"] = new Color(0.56f, 0.28f, 0.86f, 1f), ["drowsy"] = new Color(0.56f, 0.58f, 0.66f, 1f), ["weight"] = new Color(0.86f, 0.68f, 0.28f, 1f), ["hot"] = new Color(0.95f, 0.28f, 0.08f, 1f), ["thorns"] = new Color(0.24f, 0.72f, 0.26f, 1f), ["spores"] = new Color(0.32f, 0.74f, 0.52f, 1f), ["web"] = new Color(0.72f, 0.82f, 0.9f, 1f) }; private static readonly HashSet<string> AfflictionStatusNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "injury", "hunger", "cold", "poison", "crab", "curse", "drowsy", "weight", "hot", "thorns", "spores", "web" }; private static readonly Dictionary<string, string> StatIcons = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { ["actor"] = "#", ["steam"] = "ID", ["distance"] = "M", ["position"] = "XYZ", ["max stamina"] = "ST", ["total stamina"] = "ST", ["extra stamina"] = "ST", ["stamina mod"] = "ST", ["stamina delta"] = "ST", ["move mod"] = "MV", ["sprint mod"] = "MV", ["move force"] = "MV", ["speed"] = "MV", ["jump impulse"] = "JP", ["jumps"] = "JP", ["fall time"] = "FT", ["grounded"] = "GR", ["climbing"] = "CL", ["rope"] = "CL", ["vine"] = "CL", ["passed out"] = "PO", ["full pass out"] = "PO", ["will pass out"] = "PO", ["affliction sum"] = "AF", ["webbed"] = "WB", ["web"] = "WB" }; private static readonly Dictionary<string, string> SidePanelIcons = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { ["status"] = "●", ["actor"] = "#", ["steam"] = "◎", ["session"] = "◆", ["stamina"] = "★", ["bonus stamina"] = "⚡", ["infinite stamina"] = "⚡", ["run"] = "▲", ["climb"] = "△", ["hunger"] = "☾", ["no hunger"] = "☾", ["drowsy"] = "Zz", ["weight"] = "▰", ["cold"] = "❄", ["poison"] = "!", ["injury"] = "+", ["curse"] = "?", ["clear status"] = "✓", ["low gravity"] = "↟", ["jump"] = "↥", ["morale"] = "★", ["invincibility"] = "★", ["random effect"] = "?", ["effects"] = "FX", ["category"] = "CAT", ["use"] = "USE", ["carry weight"] = "WT", ["mass"] = "WT", ["total uses"] = "#", ["item tags"] = "TAG", ["pass out"] = "!", ["distance"] = "◇", ["position"] = "⌖", ["speed"] = "MV" }; private static readonly Dictionary<string, Color> SidePanelAccentColors = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase) { ["run"] = new Color(0.62f, 0.92f, 0.12f, 1f), ["climb"] = new Color(0.62f, 0.92f, 0.12f, 1f), ["bonus stamina"] = new Color(0.62f, 0.92f, 0.12f, 1f), ["infinite stamina"] = new Color(0.62f, 0.92f, 0.12f, 1f), ["drowsy"] = new Color(0.96f, 0.34f, 0.72f, 1f), ["hunger"] = new Color(1f, 0.72f, 0.16f, 1f), ["no hunger"] = new Color(1f, 0.72f, 0.16f, 1f), ["weight"] = new Color(0.78f, 0.42f, 0.08f, 1f), ["cold"] = new Color(0.28f, 0.7f, 1f, 1f), ["poison"] = new Color(0.54f, 0.86f, 0.18f, 1f), ["injury"] = new Color(0.9f, 0.22f, 0.18f, 1f), ["curse"] = new Color(0.62f, 0.34f, 0.9f, 1f), ["random effect"] = new Color(0.62f, 0.34f, 0.9f, 1f), ["clear status"] = new Color(0.24f, 0.74f, 0.46f, 1f), ["morale"] = new Color(0.24f, 0.74f, 0.46f, 1f), ["invincibility"] = new Color(0.24f, 0.74f, 0.46f, 1f) }; public bool IsOpen { get { return _isOpen; } set { if (_isOpen != value) { _isOpen = value; MenuInputCapture.SetMenuOpen(value); MenuControllerInput.Reset(); } } } public bool BlocksGlobalHotkeys { get { if (IsOpen) { if (!_editingNumber && !_editingTextFeatureActive) { return _editingColor; } return true; } return false; } } private float RowHeight => S(38f); public MenuUI() { //IL_004d: 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_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) IsOpen = MenuConfig.OpenMenuOnLaunch; } private float S(float value) { return value * _scale; } private void Awake() { EnsureThemeInitialized(); } public void Bind(FeatureManager fm) { _features = fm; RefreshRows(force: true); RecalculateMenuLayout(); } private void Update() { if (IsOpen && _features != null) { HandleController(); } if (_animationsInited) { float unscaledDeltaTime = Time.unscaledDeltaTime; float num = Mathf.Max(1f, MenuConfig.HighlightLerpSpeed); float num2 = 1f - Mathf.Exp((0f - num) * unscaledDeltaTime); _highlightY = Mathf.Lerp(_highlightY, _highlightYTarget, num2); _scrollY = Mathf.Lerp(_scrollY, _scrollYTarget, num2); } } private void OnGUI() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) EnsureThemeInitialized(); EventType type = Event.current.type; if (((int)type == 8 || (int)type == 11) ? true : false) { return; } RenderFeatureOverlays(); if (!IsOpen || _features == null) { _selectedPlayerPreviewPanel.SetVisible(visible: false); if (_editingNumber) { CancelNumberTextInput(); } if (_editingTextFeatureActive) { CancelTextInput(restoreOriginal: false); } if (_editingColor) { CancelColorPicker(); } RenderDiscordPrompt(); RuntimeKeybinds.RenderPendingConfirmation(); RenderNotifications(); return; } GUI.depth = 0; HandleNumberEditorCommitKeys(); HandleTextEditorCommitKeys(); RefreshMenuForFrame(); float y = ((Rect)(ref _window)).y; DrawShadow(); DrawHero(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _heroH)); y += _heroH; DrawTitleBar(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _titleH), _titleH); y += _titleH; DrawRows(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _rowsH)); y += _rowsH; if (_editingColor && _editingColorFeature != null) { DrawColorPicker(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _pickerH), _editingColorFeature); y += _pickerH; } if (MenuConfig.ShowFooter) { DrawFooterSpacer(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _footerGapH)); y += _footerGapH; DrawFooter(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _footerH)); y += _footerH; } if (MenuConfig.ShowDescription) { if (_descriptionGapH > 0f) { DrawGap(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _descriptionGapH)); y += _descriptionGapH; } DrawDescription(new Rect(((Rect)(ref _window)).x, y, ((Rect)(ref _window)).width, _descriptionH)); } DrawSidePanelIfNeeded(); HandleKeyboard(); HandleDrag(); RenderDiscordPrompt(); RuntimeKeybinds.RenderPendingConfirmation(); RenderNotifications(); } private void OnDestroy() { MenuInputCapture.SetMenuOpen(open: false); MenuInputCapture.EndAll(); MenuControllerInput.Reset(); _selectedPlayerPreviewPanel.Dispose(); } private void EnsureThemeInitialized() { if (!_themeInitialized) { Theme.Init(); _themeInitialized = true; } } private void RefreshMenuForFrame() { int frameCount = Time.frameCount; if (_lastMenuRefreshFrame != frameCount) { _lastMenuRefreshFrame = frameCount; _scale = MenuConfig.GetResolvedUIScale(); Theme.ApplyScale(_scale); RefreshRows(); RecalculateMenuLayout(); } } private void RecalculateMenuLayout() { string text = (MenuConfig.ShowDescription ? DescriptionFor(SelectedRow()) : string.Empty); if (!NeedsLayoutRecalculation(text)) { EnsureInitialWindowPosition(); ClampWindowToScreen(); return; } ((Rect)(ref _window)).width = MenuConfig.MenuWidth * _scale; _heroH = S(96f); _titleH = S(34f); _footerH = (MenuConfig.ShowFooter ? S(38f) : 0f); _footerGapH = (MenuConfig.ShowFooter ? S(8f) : 0f); _descriptionGapH = ((MenuConfig.ShowDescription && !MenuConfig.ShowFooter) ? S(8f) : 0f); _descriptionH = (MenuConfig.ShowDescription ? CalculateDescriptionHeight(((Rect)(ref _window)).width, text) : 0f); _pickerH = (_editingColor ? S(224f) : 0f); int num = Mathf.Min(_rows.Count, Mathf.Max(1, MenuConfig.MaxVisibleRows)); _rowsH = (float)num * RowHeight; _highlightYTarget = (float)_selected * RowHeight; EnsureSelectedVisible(); ((Rect)(ref _window)).height = _heroH + _titleH + _rowsH + _pickerH + _footerGapH + _footerH + _descriptionGapH + _descriptionH; EnsureInitialWindowPosition(); ClampWindowToScreen(); CacheLayoutState(text); if (!_animationsInited) { _highlightY = (float)_selected * RowHeight; _highlightYTarget = _highlightY; _animationsInited = true; } } private bool NeedsLayoutRecalculation(string selectedDescription) { if (Mathf.Approximately(_layoutScale, _scale) && Mathf.Approximately(_layoutMenuWidth, MenuConfig.MenuWidth) && _layoutRowsCount == _rows.Count && _layoutSelected == _selected && _layoutMaxVisibleRows == MenuConfig.MaxVisibleRows && _layoutEditingColor == _editingColor && _layoutShowFooter == MenuConfig.ShowFooter && _layoutShowDescription == MenuConfig.ShowDescription) { return !string.Equals(_layoutDescription, selectedDescription, StringComparison.Ordinal); } return true; } private void CacheLayoutState(string selectedDescription) { _layoutScale = _scale; _layoutMenuWidth = MenuConfig.MenuWidth; _layoutRowsCount = _rows.Count; _layoutSelected = _selected; _layoutMaxVisibleRows = MenuConfig.MaxVisibleRows; _layoutEditingColor = _editingColor; _layoutShowFooter = MenuConfig.ShowFooter; _layoutShowDescription = MenuConfig.ShowDescription; _layoutDescription = selectedDescription ?? string.Empty; } private void RenderFeatureOverlays() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)Event.current.type != 7) { return; } int frameCount = Time.frameCount; if (_lastOverlayRenderFrame == frameCount) { return; } _lastOverlayRenderFrame = frameCount; int depth = GUI.depth; GUI.depth = 2000; try { _features?.Render(); } finally { GUI.depth = depth; } } private static void RenderNotifications() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)Event.current.type != 7) { return; } int frameCount = Time.frameCount; if (_lastNotificationRenderFrame == frameCount) { return; } _lastNotificationRenderFrame = frameCount; int depth = GUI.depth; GUI.depth = -2000; try { NotificationSystem.Render(); } finally { GUI.depth = depth; } } private static void RenderDiscordPrompt() { int depth = GUI.depth; GUI.depth = -2100; try { DiscordCommunityPrompt.Render(); } finally { GUI.depth = depth; } } private void RefreshRows(bool force = false) { int frameCount = Time.frameCount; if ((!force && (_editingNumber || _editingColor)) || (!force && _editingTextFeatureActive && !CanRefreshRowsWhileEditingText()) || (!force && !_rowsDirty && _lastRowsRefreshFrame == frameCount)) { return; } _rowsDirty = false; _lastRowsRefreshFrame = frameCount; _rows.Clear(); if (_features == null) { return; } if (_category == null) { foreach (string category in _features.Categories) { _rows.Add(category); } } else { foreach (Feature item in _features.InCategory(_category)) { _rows.Add(item); } foreach (IMenuRowProvider rowProvider in _features.RowProviders) { foreach (object row in rowProvider.GetRows(_category)) { if (row != null) { _rows.Add(row); } } } } _selected = Mathf.Clamp(_selected, 0, Mathf.Max(0, _rows.Count - 1)); NormalizeSelected(); _highlightYTarget = (float)_selected * RowHeight; EnsureSelectedVisible(); } private void RefreshRowsNow() { _rowsDirty = true; RefreshRows(force: true); RecalculateMenuLayout(); } private void EnsureSelectedVisible() { float rowHeight = RowHeight; float num = (float)Mathf.Max(1, MenuConfig.MaxVisibleRows) * rowHeight; float num2 = (float)_selected * rowHeight; float num3 = num2 + rowHeight; if (num2 < _scrollYTarget) { _scrollYTarget = num2; } if (num3 > _scrollYTarget + num) { _scrollYTarget = num3 - num; } float num4 = Mathf.Max(0f, (float)_rows.Count * rowHeight - num); _scrollYTarget = Mathf.Clamp(_scrollYTarget, 0f, num4); } 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) Theme.Fill(new Rect(((Rect)(ref _window)).x + S(4f), ((Rect)(ref _window)).y + S(8f), ((Rect)(ref _window)).width, ((Rect)(ref _window)).height), new Color(0f, 0f, 0f, 0.55f)); } private void DrawHero(Rect rect) { //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_000d: Unknown result type (might be due to invalid IL or missing references) Theme.Fill(rect, Theme.Accent); Theme.DrawDiamond(((Rect)(ref rect)).center, S(56f)); } private void DrawTitleBar(Rect rect, float h) { //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_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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) Theme.Fill(rect, Theme.BarBg); Theme.Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - Mathf.Max(1f, S(2f)), ((Rect)(ref rect)).width, Mathf.Max(1f, S(2f))), Theme.Accent); string text = ((!MenuConfig.ShowBreadcrumb) ? ((_category == null) ? "Main Menu" : GetCategoryTitle(_category)) : ((_category == null) ? "Home" : ("Home › " + FormatCategoryPath(_category)))); string counterText = GetCounterText(); GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - S(92f), h), text, Theme.Breadcrumb); GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, h), counterText, Theme.Counter); } private void DrawRows(Rect rect) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) Theme.Fill(rect, Theme.MenuBg); float rowHeight = RowHeight; GUI.BeginGroup(rect); int num = 0; int num2 = -1; if (_rows.Count > 0) { num = ((rowHeight > 0f) ? Mathf.Clamp(Mathf.FloorToInt(_scrollY / rowHeight), 0, _rows.Count - 1) : 0); num2 = ((rowHeight > 0f) ? Mathf.Clamp(Mathf.CeilToInt((_scrollY + ((Rect)(ref rect)).height) / rowHeight), 0, _rows.Count - 1) : (_rows.Count - 1)); } for (int i = num; i <= num2; i++) { Theme.Fill(new Rect(0f, (float)i * rowHeight - _scrollY, ((Rect)(ref rect)).width, rowHeight), Theme.RowBg); } if (_rows.Count > 0) { Rect r = default(Rect); ((Rect)(ref r))..ctor(0f, _highlightY - _scrollY, ((Rect)(ref rect)).width, rowHeight); if (IsSelectable(SelectedRow())) { Theme.Fill(r, Theme.SelectedBg); } } int num3 = ((rowHeight > 0f) ? Mathf.Clamp(Mathf.RoundToInt(_highlightY / rowHeight), 0, Mathf.Max(0, _rows.Count - 1)) : 0); Rect rowRect = default(Rect); for (int j = num; j <= num2; j++) { ((Rect)(ref rowRect))..ctor(0f, (float)j * rowHeight - _scrollY, ((Rect)(ref rect)).width, rowHeight); DrawRowContent(rowRect, _rows[j], j, j == num3); } GUI.EndGroup(); DrawRowsScrollbar(rect); HandleRowMouse(rect); } private void DrawRowContent(Rect rowRect, object row, int index, bool highlighted) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (row is SeparatorFeature) { DrawSeparator(rowRect, highlighted); return; } DrawRowLabel(rowRect, row, highlighted); DrawRowRight(rowRect, row, index, highlighted); } private void DrawRowLabel(Rect rowRect, object row, bool highlighted) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) string text = RowLabel(row); GUIStyle val = (highlighted ? Theme.RowSelected : Theme.Row); List<MenuTag> tags = GetTags(row); float num = ((row is TextFeature) ? GetTextRightReserve(rowRect) : GetRowRightReserve(row)); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref rowRect)).x, ((Rect)(ref rowRect)).y, Mathf.Max(1f, ((Rect)(ref rowRect)).width - num), ((Rect)(ref rowRect)).height); if (tags == null || tags.Count == 0) { GUI.Label(val2, text, val); } else { DrawLabelWithTags(val2, text, val, Mathf.Max(8, Mathf.RoundToInt(10f * _scale)), tags, highlighted, alignTagsRight: true); } } private float GetRowRightReserve(object row) { if (row is string || row is SubmenuFeature) { return S(48f); } if (row is ButtonFeature) { return S(96f); } if (row is InfoFeature) { return S(120f); } if (row is ColorFeature) { return S(118f); } if (row is NumberBoolFeature) { return S(142f); } if (row is NumberFeature) { return S(118f); } if (row is Feature) { return S(52f); } return 0f; } private static string RowLabel(object row) { if (row is string result) { return result; } if (row is Feature feature) { return feature.Name; } if (row == null) { return "?"; } return row.ToString(); } private static List<MenuTag> GetTags(object row) { if (!(row is IMenuTagProvider menuTagProvider)) { return null; } return menuTagProvider.Tags; } private void DrawRowRight(Rect rowRect, object row, int index, bool highlighted) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_008e: 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_00bf: 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) if (row is string || row is SubmenuFeature) { DrawChevron(rowRect, highlighted); } else if (row is InfoFeature infoFeature) { GUI.Label(rowRect, infoFeature.ValueText, highlighted ? Theme.RowRightSelected : Theme.RowRight); } else if (row is ButtonFeature buttonFeature) { GUI.Label(rowRect, buttonFeature.ButtonLabel.ToUpperInvariant(), highlighted ? Theme.RowRightSelected : Theme.RowRight); } else if (row is ColorFeature color) { DrawColorRight(rowRect, color, index, highlighted); } else if (row is TextFeature text) { DrawTextRight(rowRect, text, index, highlighted); } else if (row is NumberBoolFeature number) { DrawNumberBoolRight(rowRect, number, index, highlighted); } else if (row is NumberFeature number2) { DrawNumberRight(rowRect, number2, index, highlighted); } else if (row is Feature feature) { DrawToggleState(rowRect, feature.Enabled, highlighted); } } private void DrawChevron(Rect rowRect, bool highlighted) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(highlighted ? Theme.RowRightSelected : Theme.RowRight) { fontSize = Mathf.Max(1, Mathf.RoundToInt(20f * _scale)), fontStyle = (FontStyle)1 }; GUI.Label(rowRect, "›", val); } private void DrawNumberRight(Rect rowRect, NumberFeature number, int index, bool highlighted) { //IL_0014: 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_004d: Unknown result type (might be due to invalid IL or missing references) if (IsEditing(number, index) && number.AllowTextInput) { DrawNumberTextInput(GetNumberValueRect(rowRect, reserveToggleSlot: false)); return; } string displayValue = number.GetDisplayValue(); string text = ((highlighted && number.AllowTextInput) ? ("‹ " + displayValue + " ›") : displayValue); GUI.Label(rowRect, text, highlighted ? Theme.RowRightSelected : Theme.RowRight); } private void DrawNumberBoolRight(Rect rowRect, NumberBoolFeature number, int index, bool highlighted) { //IL_0001: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0096: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00b3: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) Rect numberValueRect = GetNumberValueRect(rowRect, reserveToggleSlot: true, (number is VectorBoolFeature) ? 128f : 72f); Rect numberBoolToggleRect = GetNumberBoolToggleRect(rowRect); if (IsEditing(number, index) && number.AllowTextInput) { DrawNumberTextInput(numberValueRect); DrawNumberBoolToggle(numberBoolToggleRect, number.Enabled, highlighted); return; } string displayValue = number.GetDisplayValue(); string text = ((highlighted && (number.AllowTextInput || number is VectorBoolFeature)) ? ("‹ " + displayValue + " ›") : displayValue); GUIStyle val = new GUIStyle(highlighted ? Theme.RowRightSelected : Theme.RowRight) { alignment = (TextAnchor)5, padding = new RectOffset(0, 0, 0, 0) }; GUI.Label(numberValueRect, text, val); DrawNumberBoolToggle(numberBoolToggleRect, number.Enabled, highlighted); } private void DrawTextRight(Rect rowRect, TextFeature text, int index, bool highlighted) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) Rect textValueRect = GetTextValueRect(rowRect); if (IsEditing(text, index)) { DrawTextInput(textValueRect); return; } GUIStyle style = new GUIStyle(highlighted ? Theme.RowRightSelected : Theme.RowRight) { alignment = (TextAnchor)5, padding = new RectOffset(0, 0, 0, 0), wordWrap = false, clipping = (TextClipping)1 }; string displayValue = text.GetDisplayValue(); DrawClippedLabel(textValueRect, highlighted ? ("‹ " + displayValue + " ›") : displayValue, style); } private void DrawColorRight(Rect rowRect, ColorFeature color, int index, bool highlighted) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007b: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) float num = S(20f); float num2 = S(16f); Rect rect = default(Rect); ((Rect)(ref rect))..ctor(((Rect)(ref rowRect)).xMax - num2 - num, ((Rect)(ref rowRect)).y + (((Rect)(ref rowRect)).height - num) * 0.5f, num, num); GUIStyle val = new GUIStyle(highlighted ? Theme.RowRightSelected : Theme.RowRight) { padding = new RectOffset(0, Mathf.RoundToInt(num2 + num + S(10f)), 0, 0) }; GUI.Label(rowRect, color.GetDisplayValue(), val); DrawColorSwatch(rect, color.Value, highlighted, IsEditing(color, index)); } private bool IsEditing(NumberFeature number, int index) { if (_editingNumber && _editingNumberFeature == number) { return _editingNumberIndex == index; } return false; } private bool IsEditing(TextFeature text, int index) { if (_editingTextFeatureActive && _editingTextFeature == text) { return _editingTextIndex == index; } return false; } private bool IsEditing(ColorFeature color, int index) { if (_editingColor && _editingColorFeature == color) { return _editingColorIndex == index; } return false; } private bool CanRefreshRowsWhileEditingText() { if (_editingTextFeatureActive && _editingTextFeature != null) { return _editingTextFeature.RefreshRowsWhileEditing; } return false; } private float GetTextRightReserve(Rect rowRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Rect textValueRect = GetTextValueRect(rowRect); return Mathf.Max(0f, ((Rect)(ref rowRect)).xMax - ((Rect)(ref textValueRect)).x); } private Rect GetTextValueRect(Rect rowRect) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) float num = S(16f); float num2 = Mathf.Max(((Rect)(ref rowRect)).x, ((Rect)(ref rowRect)).xMax - num); float num3 = Mathf.Min(S(132f), Mathf.Max(1f, ((Rect)(ref rowRect)).width - S(72f) - num)); float num4 = Mathf.Max(1f, num2 - ((Rect)(ref rowRect)).x - num3); float num5 = Mathf.Min(S(220f), ((Rect)(ref rowRect)).width * 0.44f); float num6 = Mathf.Min(Mathf.Max(S(72f), num5), num4); float num7 = Mathf.Max(((Rect)(ref rowRect)).x, num2 - num6); return new Rect(num7, ((Rect)(ref rowRect)).y, Mathf.Max(1f, num2 - num7), ((Rect)(ref rowRect)).height); } private Rect GetNumberValueRect(Rect rowRect, bool reserveToggleSlot, float compactValueWidth = 72f) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (reserveToggleSlot) { float num = S(compactValueWidth); Rect numberBoolToggleRect = GetNumberBoolToggleRect(rowRect); return new Rect(((Rect)(ref numberBoolToggleRect)).x - S(8f) - num, ((Rect)(ref rowRect)).y, num, ((Rect)(ref rowRect)).height); } float num2 = ((Rect)(ref rowRect)).x + ((Rect)(ref rowRect)).width * 0.55f; float num3 = S(16f); float num4 = Mathf.Max(S(96f), ((Rect)(ref rowRect)).xMax - num3 - num2); return new Rect(num2, ((Rect)(ref rowRect)).y, num4, ((Rect)(ref rowRect)).height); } private Rect GetNumberBoolToggleRect(Rect rowRect) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) float num = S(16f); float toggleTextWidth = GetToggleTextWidth(); return new Rect(((Rect)(ref rowRect)).xMax - num - toggleTextWidth, ((Rect)(ref rowRect)).y, toggleTextWidth, ((Rect)(ref rowRect)).height); } private void DrawNumberTextInput(Rect valueRect) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref valueRect)).x, ((Rect)(ref valueRect)).y + S(5f), ((Rect)(ref valueRect)).width, ((Rect)(ref valueRect)).height - S(10f)); GUI.SetNextControlName("CubeX_NumberInput"); _editingText = GUI.TextField(val, _editingText, Theme.NumberInput); if (_focusNumberInputNext) { GUI.FocusControl("CubeX_NumberInput"); _focusNumberInputNext = false; } } private void DrawTextInput(Rect valueRect) { //IL_003b: 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_005a: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0