using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using ClientUI.Hooks; using ClientUI.UI; using ClientUI.UI.Panel; using ClientUI.UI.Util; using ClientUI.UniverseLib.UI; using ClientUI.UniverseLib.UI.Models; using ClientUI.UniverseLib.UI.ObjectPool; using ClientUI.UniverseLib.UI.Panels; using ClientUI.UniverseLib.UI.Widgets; using ClientUI.UniverseLib.UI.Widgets.ScrollView; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Network; using ProjectM.UI; using TMPro; using Unity.Collections; using Unity.Entities; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using XPShared; using XPShared.Hooks; using XPShared.Services; using XPShared.Transport.Messages; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("XPRising.ClientUI")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.2.0")] [assembly: AssemblyInformationalVersion("0.5.2+1.Branch.main.Sha.87328b40f46456fe5a53cd05519afe51105b8a20.87328b40f46456fe5a53cd05519afe51105b8a20")] [assembly: AssemblyProduct("XPRising.ClientUI")] [assembly: AssemblyTitle("XPRising.ClientUI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 ClientUI { public static class ChatUtils { private static readonly ComponentType[] NetworkEventComponents = (ComponentType[])(object)new ComponentType[4] { ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()), ComponentType.ReadOnly(Il2CppType.Of()) }; private static readonly NetworkEventType ChatEventType = new NetworkEventType { IsAdminEvent = false, EventId = NetworkEvents.EventId_ChatMessageEvent, IsDebugEvent = false }; private static readonly int ClientNonce = Random.Shared.Next(); public static void SendInitialisation() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (!(ClientChatPatch.LocalUser == Entity.Null)) { ChatService.RegisterClientNonce(ClientChatPatch.LocalSteamId, ClientNonce); ChatUtils.SendToServer(new ClientRegisterMessage(ClientNonce, ClientChatPatch.LocalSteamId)); } } public static void SendToServer(T msg) where T : IChatMessage { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //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_0047: 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_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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0087: 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_0092: Unknown result type (might be due to invalid IL or missing references) Plugin.Log((LogLevel)32, "[CLIENT] [SEND] IChatMessage"); string text = ChatService.SerialiseMessage(msg, ClientNonce); ChatMessageEvent val = new ChatMessageEvent { MessageText = new FixedString512Bytes(text), MessageType = (ChatMessageType)4, ReceiverEntity = Extensions.Read(ClientChatPatch.LocalUser) }; EntityManager entityManager = Plugin.World.EntityManager; Entity val2 = ((EntityManager)(ref entityManager)).CreateEntity(NetworkEventComponents); Extensions.Write(val2, new FromCharacter { Character = ClientChatPatch.LocalCharacter, User = ClientChatPatch.LocalUser }); Extensions.Write(val2, ChatEventType); Extensions.Write(val2, val); } } [BepInPlugin("XPRising.ClientUI", "XPRising.ClientUI", "0.5.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private static ManualLogSource _logger; private const string ConnectionGroup = "InternalConnection"; private static FrameTimer _uiInitialisedTimer = new FrameTimer(); private static FrameTimer _connectUiTimer; private static FrameTimer _connectionUpdateTimer; private float _connectionProgressValue; private static Harmony _harmonyBootPatch; private static Harmony _harmonyCanvasPatch; private static Harmony _harmonyMenuPatch; internal static Harmony _harmonyVersionStringPatch; private const string TurboColourMap = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402"; private float _testValue; private FrameTimer _testTimer1; private FrameTimer _testTimer2; private bool _buttonEnabled; private int _testValue2; internal static Plugin Instance { get; private set; } public override void Load() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown Instance = this; _logger = ((BasePlugin)this).Log; if (Plugin.IsServer) { Log((LogLevel)4, "Plugin XPRising.ClientUI is a client plugin only. Not continuing to load on server."); return; } UIManager.Initialize(); _harmonyBootPatch = Harmony.CreateAndPatchAll(typeof(GameManangerPatch), (string)null); _harmonyMenuPatch = Harmony.CreateAndPatchAll(typeof(MainMenuNewViewPatch), (string)null); _harmonyCanvasPatch = Harmony.CreateAndPatchAll(typeof(UICanvasSystemPatch), (string)null); _harmonyVersionStringPatch = Harmony.CreateAndPatchAll(typeof(VersionStringPatch), (string)null); _connectUiTimer = new FrameTimer(); _connectUiTimer.Initialise((Action)delegate { ChatUtils.SendInitialisation(); Log((LogLevel)16, "Sending client initialisation..."); }, TimeSpan.FromSeconds(1.0), 5); _connectionUpdateTimer = new FrameTimer(); _connectionUpdateTimer.Initialise((Action)delegate { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0054: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_01b0: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown if (_connectUiTimer.Enabled) { _connectionProgressValue = (_connectionProgressValue + 0.0125f) % 100f; UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "InternalConnection", Label = "Connecting", Colour = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402", Active = (ActiveState)2, Change = "", Header = "", ProgressPercentage = _connectionProgressValue % 1f, Tooltip = $"Connecting ... {_connectUiTimer.TimeSinceStart.Seconds}s ({_connectUiTimer.RunCount}/5)" }); } else { UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "InternalConnection", Label = "Connecting", Colour = "red", Active = (ActiveState)2, Change = "", Header = "", ProgressPercentage = 1f, Tooltip = "Server connection failed!" }); UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "InternalConnection", ID = "RetryConnection", Label = "Retry Connection?", Colour = "red", Enabled = true }, delegate { ClientChatPatch.ResetUser(); UIManager.Reset(); _connectUiTimer.Start(); }); UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "InternalConnection", ID = "HideUI", Label = "Hide UI", Colour = "red", Enabled = true }, delegate { ClientChatPatch.ResetUser(); UIManager.Reset(); UIManager.SetActive(active: false); }); UIManager.ContentPanel.OpenActionPanel("InternalConnection"); } }, TimeSpan.FromMilliseconds(50.0), -1); RegisterMessages(); Log((LogLevel)16, "Plugin XPRising.ClientUI is loaded!"); } public override bool Unload() { _harmonyBootPatch.UnpatchSelf(); _harmonyCanvasPatch.UnpatchSelf(); _harmonyMenuPatch.UnpatchSelf(); _harmonyVersionStringPatch.UnpatchSelf(); return true; } public static void GameDataOnInitialize(World world) { if (!Plugin.IsClient) { return; } _uiInitialisedTimer.Initialise((Action)delegate { if (!UIManager.IsInitialised) { UIManager.OnInitialized(); } _connectUiTimer.Start(); _connectionUpdateTimer.Start(); }, TimeSpan.FromSeconds(5.0), 1).Start(); } private static void GameDataOnDestroy() { } private static void RegisterMessages() { ChatService.RegisterType((Action)delegate(ProgressSerialisedMessage message, ulong steamId) { if (UIManager.IsInitialised) { UIManager.ContentPanel.ChangeProgress(message); } }); ChatService.RegisterType((Action)delegate(ActionSerialisedMessage message, ulong steamId) { if (UIManager.IsInitialised) { UIManager.ContentPanel.SetButton(message); } }); ChatService.RegisterType((Action)delegate(NotificationMessage message, ulong steamId) { if (UIManager.IsInitialised) { UIManager.ContentPanel.AddMessage(message); } }); ChatService.RegisterType((Action)delegate { _connectUiTimer.Stop(); _connectionUpdateTimer.Stop(); UIManager.Reset(); Log((LogLevel)16, "Client initialisation successful"); }); ChatService.RegisterType((Action)delegate(DisplayTextMessage message, ulong steamId) { if (message.Reset) { UIManager.TextPanel.SetText(message.Title, message.Text); } else { UIManager.TextPanel.AddText(message.Text); } }); } public static void Log(LogLevel level, string message) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = _logger; bool flag = default(bool); BepInExLogInterpolatedStringHandler val = new BepInExLogInterpolatedStringHandler(2, 2, level, ref flag); if (flag) { val.AppendFormatted(DateTime.Now, "u"); val.AppendLiteral(": "); val.AppendFormatted(message); } logger.Log(level, val); } private void AddTestUI() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00a9: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown UIManager.OnInitialized(); _testTimer1 = new FrameTimer(); _testTimer2 = new FrameTimer(); UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "Test1", Label = "TEST BAR", Colour = "red", Active = (ActiveState)2, Change = "", Header = "1X", ProgressPercentage = 0.45f, Tooltip = "Test Progress" }); UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "Test", Label = "TEST BAR 2", Colour = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402", Active = (ActiveState)2, Change = "", Header = "00", ProgressPercentage = 0f, Tooltip = "Test Progress 2", Flash = false }); UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "Test", ID = "TestButton2", Label = "Test disabled", Enabled = _buttonEnabled }, delegate { }); UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "Test", ID = "TestButton", Label = "Test colour and enable", Colour = "blue", Enabled = true }, delegate { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown _buttonEnabled = !_buttonEnabled; UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "Test", ID = "TestButton2", Label = (_buttonEnabled ? "Test enabled" : "Test disabled"), Enabled = _buttonEnabled }); }); _testTimer1.Initialise((Action)delegate { //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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00b3: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown float num = 0.0125f; bool flash = _testValue % 1f > (_testValue + num) % 1f && _testValue % 2f < 1f; _testValue = (_testValue + num) % 100f; UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "Test", Label = "TEST BAR 2", Colour = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402", Active = (ActiveState)2, Change = "whoop", Header = $"{(int)_testValue:D2}", ProgressPercentage = _testValue % 1f, Tooltip = "Test Progress 2", Flash = flash }); }, TimeSpan.FromMilliseconds(50.0), -1).Start(); _testTimer2.Initialise((Action)delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown UIManager.ContentPanel.AddMessage(new NotificationMessage { ID = "testMessage", Message = $"{DateTime.Now:u}: This is a test message", Severity = (LogLevel)4 }); _testValue2++; if (_testValue2 % 3 == 0) { _testValue2 = 0; UIManager.TextPanel.AddText($"{DateTime.Now:u}: This is a bunch of text to be added to the scrollable panel.\n\n"); } }, TimeSpan.FromSeconds(3.0), -1).Start(); UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage { Group = "Test", Label = "TEST BAR 3", Colour = "white", Active = (ActiveState)2, Change = "", Header = "Xx", ProgressPercentage = 0.65f, Tooltip = "Test text colour" }); UIManager.TextPanel.SetText("Test text panel", "This is some multiline text and this text should be able to be scrollable.\n\nThis is some more text\n\n"); UIManager.ContentPanel.SetButton(new ActionSerialisedMessage { Group = "Test", ID = "TestButton3", Label = "Show test text panel", Colour = "white", Enabled = true }, delegate { UIManager.TextPanel.SetText("Test text panel", "Restarting the multiline, scrollable, test text panel.\n\n"); }); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "XPRising.ClientUI"; public const string PLUGIN_NAME = "XPRising.ClientUI"; public const string PLUGIN_VERSION = "0.5.2"; } } namespace ClientUI.UniverseLib.UI { public static class CoroutineUtility { private static ConcurrentBag _nextFrameRoutines = new ConcurrentBag(); private static ConcurrentBag _thisFrameRoutines = new ConcurrentBag(); public static void StartCoroutine(IEnumerator coroutine) { _nextFrameRoutines.Add(coroutine); } public static void TickRoutines() { ConcurrentBag nextFrameRoutines = _nextFrameRoutines; ConcurrentBag thisFrameRoutines = _thisFrameRoutines; _thisFrameRoutines = nextFrameRoutines; _nextFrameRoutines = thisFrameRoutines; while (!_thisFrameRoutines.IsEmpty) { if (_thisFrameRoutines.TryTake(out var result) && result.MoveNext()) { _nextFrameRoutines.Add(result); } } } } public static class Il2CppExtensions { public static void AddListener(this UnityEvent action, Action listener) { action.AddListener(UnityAction.op_Implicit(listener)); } public static void AddListener(this UnityEvent action, Action listener) { action.AddListener(UnityAction.op_Implicit(listener)); } public static void RemoveListener(this UnityEvent action, Action listener) { action.RemoveListener(UnityAction.op_Implicit(listener)); } public static void RemoveListener(this UnityEvent action, Action listener) { action.RemoveListener(UnityAction.op_Implicit(listener)); } public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value) { group.childControlHeight = value; } public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value) { group.childControlWidth = value; } } public class UIBase { internal static readonly int TOP_SORTORDER = 30000; public string ID { get; } public GameObject RootObject { get; } public RectTransform RootRect { get; } public Canvas Canvas { get; } public CanvasScaler Scaler { get; } public Action UpdateMethod { get; } public PanelManager Panels { get; } public bool Enabled { get { if (Object.op_Implicit((Object)(object)RootObject)) { return RootObject.activeSelf; } return false; } set { UniversalUI.SetUIActive(ID, value); } } public UIBase(string id, Action updateMethod) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(id)) { throw new ArgumentException("Cannot register a UI with a null or empty id!"); } if (UniversalUI.registeredUIs.ContainsKey(id)) { throw new ArgumentException("A UI with the id '" + id + "' is already registered!"); } ID = id; UpdateMethod = updateMethod; RootObject = UIFactory.CreateUIObject(id + "_Root", UniversalUI.CanvasRoot); RootObject.SetActive(false); RootRect = RootObject.GetComponent(); Canvas = RootObject.AddComponent(); Canvas.renderMode = (RenderMode)0; Canvas.referencePixelsPerUnit = 100f; Canvas.sortingOrder = TOP_SORTORDER; Canvas.overrideSorting = true; Scaler = RootObject.AddComponent(); Scaler.referenceResolution = UniversalUI.CanvasDimensions; Scaler.uiScaleMode = (ScaleMode)1; Scaler.screenMatchMode = (ScreenMatchMode)0; RootObject.AddComponent(); RectTransform component = RootObject.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.pivot = new Vector2(0.5f, 0.5f); Panels = CreatePanelManager(); RootObject.SetActive(true); UniversalUI.registeredUIs.Add(id, this); UniversalUI.uiBases.Add(this); } protected virtual PanelManager CreatePanelManager() { return new PanelManager(this); } public void SetOnTop() { RootObject.transform.SetAsLastSibling(); foreach (UIBase uiBasis in UniversalUI.uiBases) { int num = UniversalUI.CanvasRoot.transform.childCount - ((Transform)uiBasis.RootRect).GetSiblingIndex(); uiBasis.Canvas.sortingOrder = TOP_SORTORDER - num; } UniversalUI.uiBases.Sort((UIBase a, UIBase b) => b.RootObject.transform.GetSiblingIndex().CompareTo(a.RootObject.transform.GetSiblingIndex())); } internal void Update() { try { Panels.Update(); UpdateMethod?.Invoke(); } catch (Exception value) { Plugin.Log((LogLevel)4, $"Exception invoking update method for {ID}: {value}"); } } } public static class UIFactory { internal static Vector2 largeElementSize = new Vector2(100f, 30f); internal static Vector2 smallElementSize = new Vector2(25f, 25f); internal static Vector2 outlineDistance = new Vector2(2f, 2f); public static GameObject PlayerHUDCanvas { get; set; } public static TMP_FontAsset Font { get; set; } public static Material FontMaterial { get; set; } public static GameObject CreateUIObject(string name, GameObject parent, Vector2 sizeDelta = default(Vector2)) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = 5, hideFlags = (HideFlags)61 }; if (Object.op_Implicit((Object)(object)parent)) { val.transform.SetParent(parent.transform, false); } val.AddComponent().sizeDelta = sizeDelta; return val; } internal static void SetDefaultTextValues(TextMeshProUGUI text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)text).color = Colour.DefaultText; ((TMP_Text)text).font = Font; ((TMP_Text)text).fontSize = 14f; } internal static ColorBlock CreateColourBlock(Color baseColour) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_003c: 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_0066: 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) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(baseColour, ref num, ref num2, ref num3); ColorBlock result = default(ColorBlock); ((ColorBlock)(ref result)).normalColor = baseColour; ((ColorBlock)(ref result)).highlightedColor = Color.HSVToRGB(num, num2, num3 * 1.2f); ((ColorBlock)(ref result)).selectedColor = Color.HSVToRGB(num, num2, num3 * 1.1f); ((ColorBlock)(ref result)).pressedColor = Color.HSVToRGB(num, num2, num3 * 0.7f); ((ColorBlock)(ref result)).disabledColor = Color.HSVToRGB(num, num2, num3 * 0.4f); ((ColorBlock)(ref result)).colorMultiplier = 1f; return result; } internal static void SetDefaultSelectableValues(Selectable selectable) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = selectable.navigation; navigation.mode = (Mode)4; selectable.navigation = navigation; selectable.colors = CreateColourBlock(new Color(0.2f, 0.2f, 0.2f)); } public static LayoutElement SetLayoutElement(GameObject gameObject, int? minWidth = null, int? minHeight = null, int? flexibleWidth = null, int? flexibleHeight = null, int? preferredWidth = null, int? preferredHeight = null, bool? ignoreLayout = null) { LayoutElement val = gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)val)) { val = gameObject.AddComponent(); } if (minWidth.HasValue) { val.minWidth = minWidth.Value; } if (minHeight.HasValue) { val.minHeight = minHeight.Value; } if (flexibleWidth.HasValue) { val.flexibleWidth = flexibleWidth.Value; } if (flexibleHeight.HasValue) { val.flexibleHeight = flexibleHeight.Value; } if (preferredWidth.HasValue) { val.preferredWidth = preferredWidth.Value; } if (preferredHeight.HasValue) { val.preferredHeight = preferredHeight.Value; } if (ignoreLayout.HasValue) { val.ignoreLayout = ignoreLayout.Value; } return val; } public static T SetLayoutGroup(GameObject gameObject, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup { T val = gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)val)) { val = gameObject.AddComponent(); } return SetLayoutGroup(val, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop, padBottom, padLeft, padRight, childAlignment); } public static T SetLayoutGroup(T group, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup { //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (forceWidth.HasValue) { ((HorizontalOrVerticalLayoutGroup)group).childForceExpandWidth = forceWidth.Value; } if (forceHeight.HasValue) { ((HorizontalOrVerticalLayoutGroup)group).childForceExpandHeight = forceHeight.Value; } if (childControlWidth.HasValue) { ((HorizontalOrVerticalLayoutGroup)group).childControlWidth = childControlWidth.Value; } if (childControlHeight.HasValue) { ((HorizontalOrVerticalLayoutGroup)group).childControlHeight = childControlHeight.Value; } if (spacing.HasValue) { ((HorizontalOrVerticalLayoutGroup)group).spacing = spacing.Value; } if (padTop.HasValue) { ((LayoutGroup)(object)group).padding.top = padTop.Value; } if (padBottom.HasValue) { ((LayoutGroup)(object)group).padding.bottom = padBottom.Value; } if (padLeft.HasValue) { ((LayoutGroup)(object)group).padding.left = padLeft.Value; } if (padRight.HasValue) { ((LayoutGroup)(object)group).padding.right = padRight.Value; } if (childAlignment.HasValue) { ((LayoutGroup)(object)group).childAlignment = childAlignment.Value; } return group; } public static GameObject CreatePanel(string name, GameObject parent, out GameObject contentHolder, Color? bgColor = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUIObject(name, parent); UIFactory.SetLayoutGroup(val, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); RectTransform component = val.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.anchoredPosition = Vector2.zero; component.sizeDelta = Vector2.zero; contentHolder = CreateUIObject("Content", val); UIFactory.SetLayoutGroup(contentHolder, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); Image obj = contentHolder.AddComponent(); obj.type = (Type)3; ((Graphic)obj).color = (Color)(((??)bgColor) ?? Colour.DarkBackground); Outline obj2 = contentHolder.AddComponent(); ((Shadow)obj2).effectColor = Colour.DarkBackground; ((Shadow)obj2).effectDistance = outlineDistance; return val; } public static GameObject CreateVerticalGroup(GameObject parent, string name, bool forceWidth, bool forceHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color? bgColor = null, TextAnchor? childAlignment = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_004c: 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_0089: 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) GameObject obj = CreateUIObject(name, parent); UIFactory.SetLayoutGroup(obj, (bool?)forceWidth, (bool?)forceHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment); ((Graphic)obj.AddComponent()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground); return obj; } public static GameObject CreateHorizontalGroup(GameObject parent, string name, bool forceExpandWidth, bool forceExpandHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color? bgColor = null, TextAnchor? childAlignment = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_004c: 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_0089: 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) GameObject obj = CreateUIObject(name, parent); UIFactory.SetLayoutGroup(obj, (bool?)forceExpandWidth, (bool?)forceExpandHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment); ((Graphic)obj.AddComponent()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground); return obj; } public static GameObject CreateGridGroup(GameObject parent, string name, Vector2 cellSize, Vector2 spacing, Color? bgColor = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateUIObject(name, parent); GridLayoutGroup obj2 = obj.AddComponent(); ((LayoutGroup)obj2).childAlignment = (TextAnchor)0; obj2.cellSize = cellSize; obj2.spacing = spacing; ((Graphic)obj.AddComponent()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground); return obj; } public static TextMeshProUGUI CreateLabel(GameObject parent, string name, string defaultText, TextAlignmentOptions alignment = (TextAlignmentOptions)514, Color? color = null, int fontSize = 14) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = CreateUIObject(name, parent).AddComponent(); ((Graphic)val).color = (Color)(((??)color) ?? Colour.DefaultText); ((TMP_Text)val).font = Font; ((TMP_Text)val).text = defaultText; ((TMP_Text)val).alignment = alignment; ((TMP_Text)val).fontSize = fontSize; try { ((TMP_Text)val).outlineWidth = 0.15f; ((TMP_Text)val).outlineColor = Color32.op_Implicit(Color.black); } catch (Exception) { } return val; } public static ButtonRef CreateButton(GameObject parent, string name, string text, Color? normalColor = null) { //IL_0014: 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_0019: 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_0025: 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_0032: Unknown result type (might be due to invalid IL or missing references) Color baseColour = (Color)(((??)normalColor) ?? Colour.SliderFill); ButtonRef buttonRef = CreateButton(parent, name, text, default(ColorBlock)); ((Selectable)buttonRef.Component).colors = CreateColourBlock(baseColour); return buttonRef; } public static ButtonRef CreateButton(GameObject parent, string name, string text, ColorBlock colors) { //IL_0002: 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_001b: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00ac: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUIObject(name, parent, smallElementSize); GameObject val2 = CreateUIObject("Text", val); Image obj = val.AddComponent(); obj.type = (Type)1; ((Graphic)obj).color = Color.white; Outline obj2 = val.AddComponent(); ((Shadow)obj2).effectColor = Colour.DarkBackground; ((Shadow)obj2).effectDistance = outlineDistance; Button obj3 = val.AddComponent