Decompiled source of LobbyKit v1.0.0
LobbyKit.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.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using HarmonyLib; using Il2Cpp; using Il2CppDissonance.Integrations.FishNet; using Il2CppEpic.OnlineServices; using Il2CppEpic.OnlineServices.Lobby; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing.Server; using Il2CppFishNet.Managing.Timing; using Il2CppFishNet.Object; using Il2CppFishNet.Object.Synchronizing; using Il2CppFishNet.Transporting; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppPlayEveryWare.EpicOnlineServices.Samples; using Il2CppSystem; using Il2CppSystem.Reflection; using Il2CppTMPro; using Il2CppTankAndHealerStudioAssets; using Il2Cpp_Scripts.Managers; using Il2Cpp_Scripts.Systems.Chat; using Il2Cpp_Scripts.UI.Components; using Il2Cpp_Scripts.UI.Pre_Game; using LobbyKit; using LobbyKit.Features.Lobby; using LobbyKit.Features.PlayerList; using LobbyKit.Features.Settings; using LobbyKit.Patches; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(LobbyKitCore), "LobbyKit", "1.0.0", "Spyci", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Spyci")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3522b61da9e4916bffd54f7fe3492106d7d59219")] [assembly: AssemblyProduct("LobbyKit")] [assembly: AssemblyTitle("LobbyKit")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LobbyKit { public class LobbyKitCore : MelonMod { [HarmonyPatch(typeof(PlayerReferenceManager), "OnPlayerReferenceAdded")] public static class PlayerJoinPatch { private static void Postfix(PlayerReferenceManager __instance, int index) { SyncList<PlayerReference> playerReferences = __instance.GetPlayerReferences(); if (playerReferences == null || index < 0 || index >= playerReferences.Count) { return; } PlayerReference val = playerReferences[index]; if (val != null) { if (val.IsLocalPlayerInstance()) { Instance.localPlayer = val; isHost = val.ConnectionID == 32767; } Instance.PlayerJoinedGame(val); } } } [HarmonyPatch(typeof(PlayerReferenceManager), "OnPlayerReferenceRemoved")] public static class PlayerLeavePatch { private static void Postfix(PlayerReferenceManager __instance, int index, PlayerReference removedItem) { Instance.PlayerLeftGame(removedItem); } } [CompilerGenerated] private sealed class <LoadReferences>d__109 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public LobbyKitCore <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadReferences>d__109(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown int num = <>1__state; LobbyKitCore lobbyKitCore = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((Object)lobbyKitCore._playerReferenceManager == (Object)null) { lobbyKitCore._playerReferenceManager = PlayerReferenceManager.Instance; <>2__current = null; <>1__state = 1; return true; } lobbyKitCore.ReferencesLoaded = true; Debug.Log(Object.op_Implicit("[Core] Scene references loaded successfully.")); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static LobbyKitCore Instance; private PlayerReference localPlayer; private readonly List<PlayerReference> players = new List<PlayerReference>(); private readonly Dictionary<int, double> _playerJoinTimes = new Dictionary<int, double>(); private readonly Dictionary<string, double> _playerJoinTimesByProductId = new Dictionary<string, double>(); public static bool isHost; private static MelonPreferences_Category _preferences; private static MelonPreferences_Entry<bool> _enableGuestBangCommands; private static MelonPreferences_Entry<string> _serverName; private static MelonPreferences_Entry<int> _serverCapacity; private static MelonPreferences_Entry<int> _searchMinPlayers; private static MelonPreferences_Entry<int> _searchMaxPlayers; private static MelonPreferences_Entry<bool> _searchShowLocked; private static MelonPreferences_Entry<bool> _searchShowModded; private static MelonPreferences_Entry<bool> _searchShowYourLanguageOnly; private static MelonPreferences_Entry<bool> _searchOnlyPeacefulLobbies; private static MelonPreferences_Entry<bool> _searchHidePeacefulLobbies; private static MelonPreferences_Entry<int> _searchRegionMode; private static MelonPreferences_Entry<bool> _isPublicLobby; private static MelonPreferences_Entry<bool> _isPasswordProtected; private static MelonPreferences_Entry<string> _lobbyPassword; private static MelonPreferences_Entry<bool> _isPeacefulMode; private static MelonPreferences_Entry<bool> _isTextChatOnly; private static MelonPreferences_Entry<string> _messageOfTheDay; private static MelonPreferences_Entry<bool> _showJoinMessages; private static MelonPreferences_Entry<bool> _showLeaveMessages; private static MelonPreferences_Entry<int> _joinMessageSize; private static MelonPreferences_Entry<int> _leaveMessageSize; private PlayerReferenceManager _playerReferenceManager; public bool ReferencesLoaded; public static bool EnableGuestBangCommands => _enableGuestBangCommands?.Value ?? true; public static string ServerName => _serverName?.Value ?? string.Empty; public static int ServerCapacity => _serverCapacity?.Value ?? 8; public static int SearchMinPlayers => _searchMinPlayers?.Value ?? 1; public static int SearchMaxPlayers => _searchMaxPlayers?.Value ?? 0; public static bool SearchShowLocked => _searchShowLocked?.Value ?? true; public static bool SearchShowModded => _searchShowModded?.Value ?? true; public static bool SearchShowYourLanguageOnly => _searchShowYourLanguageOnly?.Value ?? false; public static bool SearchOnlyPeacefulLobbies => _searchOnlyPeacefulLobbies?.Value ?? false; public static bool SearchHidePeacefulLobbies => _searchHidePeacefulLobbies?.Value ?? false; public static int SearchRegionMode => _searchRegionMode?.Value ?? 1; public static bool IsPublicLobby => _isPublicLobby?.Value ?? true; public static bool IsPasswordProtected => _isPasswordProtected?.Value ?? false; public static string LobbyPassword => _lobbyPassword?.Value ?? string.Empty; public static bool IsPeacefulMode => _isPeacefulMode?.Value ?? false; public static bool IsTextChatOnly => _isTextChatOnly?.Value ?? false; public static string MessageOfTheDay => _messageOfTheDay?.Value ?? string.Empty; public static bool ShowJoinMessages => _showJoinMessages?.Value ?? true; public static bool ShowLeaveMessages => _showLeaveMessages?.Value ?? true; public static int JoinMessageSize => _joinMessageSize?.Value ?? 75; public static int LeaveMessageSize => _leaveMessageSize?.Value ?? 75; public void SavePrefs() { MelonPreferences.Save(); } public override void OnInitializeMelon() { Instance = this; _preferences = MelonPreferences.CreateCategory("LobbyKit", "LobbyKit"); _enableGuestBangCommands = _preferences.CreateEntry<bool>("EnableGuestBangCommands", true, "Enable Guest Bang Commands", "Allow non-host players to use custom bang chat commands like !tp.", false, false, (ValueValidator)null, (string)null); _serverName = _preferences.CreateEntry<string>("ServerName", string.Empty, "Server Name", "Custom default lobby/server name. Leave empty to use '<PlayerName>'s Lobby'.", false, false, (ValueValidator)null, (string)null); _serverCapacity = _preferences.CreateEntry<int>("ServerCapacity", 8, "Server Capacity", "Saved default value for the max players slider.", false, false, (ValueValidator)null, (string)null); _isPublicLobby = _preferences.CreateEntry<bool>("IsPublicLobby", true, "Public Lobby", "Saved default for public/private lobby.", false, false, (ValueValidator)null, (string)null); _isPasswordProtected = _preferences.CreateEntry<bool>("IsPasswordProtected", false, "Password Protected", "Saved default for password protection.", false, false, (ValueValidator)null, (string)null); _lobbyPassword = _preferences.CreateEntry<string>("LobbyPassword", string.Empty, "Lobby Password", "Saved default lobby password.", false, false, (ValueValidator)null, (string)null); _isPeacefulMode = _preferences.CreateEntry<bool>("IsPeacefulMode", false, "Peaceful Mode", "Saved default for peaceful mode.", false, false, (ValueValidator)null, (string)null); _isTextChatOnly = _preferences.CreateEntry<bool>("IsTextChatOnly", false, "Text Chat Only", "Saved default for text-chat-only mode.", false, false, (ValueValidator)null, (string)null); _searchMaxPlayers = _preferences.CreateEntry<int>("SearchMaxPlayers", 0, "Search Max Players", "Maximum players filter for lobby search. 0 == Any.", false, false, (ValueValidator)null, (string)null); _searchShowLocked = _preferences.CreateEntry<bool>("SearchShowLocked", true, "Search Show Locked", "Include locked lobbies in search results.", false, false, (ValueValidator)null, (string)null); _searchShowModded = _preferences.CreateEntry<bool>("SearchShowModded", true, "Search Show Modded", "Include modded lobbies in search results.", false, false, (ValueValidator)null, (string)null); _searchShowYourLanguageOnly = _preferences.CreateEntry<bool>("SearchShowYourLanguageOnly", false, "Search Your Language Only", "Filter to language-matching lobbies.", false, false, (ValueValidator)null, (string)null); _searchOnlyPeacefulLobbies = _preferences.CreateEntry<bool>("SearchOnlyPeacefulLobbies", false, "Search Only Peaceful Lobbies", "Only show peaceful-mode lobbies in search results.", false, false, (ValueValidator)null, (string)null); _searchHidePeacefulLobbies = _preferences.CreateEntry<bool>("SearchHidePeacefulLobbies", false, "Search Hide Peaceful Lobbies", "Hide peaceful-mode lobbies in search results.", false, false, (ValueValidator)null, (string)null); _searchRegionMode = _preferences.CreateEntry<int>("SearchRegionMode", 1, "Search Region Mode", "Lobby search region filter: 0 near, 1 nearby regions, 2 far, 3 worldwide.", false, false, (ValueValidator)null, (string)null); _messageOfTheDay = _preferences.CreateEntry<string>("MessageOfTheDay", string.Empty, "Message of the Day", "Private chat message sent to each player when they join your hosted lobby. Leave empty to disable.", false, false, (ValueValidator)null, (string)null); _showJoinMessages = _preferences.CreateEntry<bool>("ShowJoinMessages", true, "Show Join Messages", "Broadcast a chat message when a player joins your hosted lobby.", false, false, (ValueValidator)null, (string)null); _showLeaveMessages = _preferences.CreateEntry<bool>("ShowLeaveMessages", true, "Show Leave Messages", "Broadcast a chat message when a player leaves your hosted lobby.", false, false, (ValueValidator)null, (string)null); _joinMessageSize = _preferences.CreateEntry<int>("JoinMessageSize", 75, "Join Message Size", "Font size percentage for join messages (e.g. 75 for 75%).", false, false, (ValueValidator)null, (string)null); _leaveMessageSize = _preferences.CreateEntry<int>("LeaveMessageSize", 75, "Leave Message Size", "Font size percentage for leave messages (e.g. 75 for 75%).", false, false, (ValueValidator)null, (string)null); MelonPreferences.Save(); ((MelonBase)this).HarmonyInstance.PatchAll(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { ReferencesLoaded = false; players.Clear(); _playerJoinTimes.Clear(); _playerJoinTimesByProductId.Clear(); MelonCoroutines.Start(LoadReferences()); } public void PlayerJoinedGame(PlayerReference p) { if (p != null) { bool flag = p.IsLocalPlayerInstance(); bool flag2 = !players.Any((PlayerReference player) => player != null && player.ConnectionID == p.ConnectionID); if (flag2) { players.Add(p); } if (flag2 && (isHost || flag)) { TrackPlayerJoinTime(p, GetLobbyUptimeSeconds()); } if (flag) { localPlayer = p; isHost = p.ConnectionID == 32767; } else if (isHost && flag2 && ShowJoinMessages) { string value = ChatSystem.AutoCloseTmpRichText(string.IsNullOrWhiteSpace(p.Username) ? "A player" : p.Username); ChatSystem.BroadcastSystemMessage($"<size={JoinMessageSize}%><#FA0>{value} joined."); } if (isHost) { ChatSystem.SendMotdToPlayer(p); } } } public void PlayerLeftGame(PlayerReference removedPlayer) { if (removedPlayer != null) { bool flag = players.Any((PlayerReference player) => player != null && player.ConnectionID == removedPlayer.ConnectionID); bool flag2 = removedPlayer.IsLocalPlayerInstance(); if (isHost && flag && !flag2 && ShowLeaveMessages) { string value = ChatSystem.AutoCloseTmpRichText(string.IsNullOrWhiteSpace(removedPlayer.Username) ? "A player" : removedPlayer.Username); ChatSystem.BroadcastSystemMessage($"<size={LeaveMessageSize}%><#FA0>{value} left."); } players.RemoveAll((PlayerReference player) => player == null || player.ConnectionID == removedPlayer.ConnectionID); _playerJoinTimes.Remove(removedPlayer.ConnectionID); if (!string.IsNullOrWhiteSpace(removedPlayer.ProductUserId)) { _playerJoinTimesByProductId.Remove(removedPlayer.ProductUserId); } ChatSystem.ForgetMotdRecipient(removedPlayer.ConnectionID); ChatSystem.ForgetTeleportRequests(removedPlayer.ConnectionID); if (localPlayer != null && localPlayer.ConnectionID == removedPlayer.ConnectionID) { localPlayer = null; isHost = false; } } } public PlayerReference GetLocalPlayer() { if (localPlayer == null) { return null; } return localPlayer; } public bool TryGetPlayerJoinTime(PlayerReference playerReference, out double joinTimeSeconds) { joinTimeSeconds = 0.0; if (!isHost || playerReference == null) { return false; } return _playerJoinTimes.TryGetValue(playerReference.ConnectionID, out joinTimeSeconds); } public bool TryGetPlayerSessionDuration(PlayerReference playerReference, out double sessionSeconds) { sessionSeconds = 0.0; if (!isHost || playerReference == null) { return false; } double lobbyUptimeSeconds = GetLobbyUptimeSeconds(); if (!_playerJoinTimes.TryGetValue(playerReference.ConnectionID, out var value)) { value = ((playerReference.ConnectionID == 32767) ? 0.0 : lobbyUptimeSeconds); TrackPlayerJoinTime(playerReference, value); } sessionSeconds = lobbyUptimeSeconds - value; return true; } public bool TryGetPlayerSessionDuration(string productUserId, out double sessionSeconds) { sessionSeconds = 0.0; if (!isHost || string.IsNullOrWhiteSpace(productUserId)) { return false; } double lobbyUptimeSeconds = GetLobbyUptimeSeconds(); if (!_playerJoinTimesByProductId.TryGetValue(productUserId, out var value)) { value = lobbyUptimeSeconds; _playerJoinTimesByProductId[productUserId] = value; } sessionSeconds = lobbyUptimeSeconds - value; return true; } public bool TryGetPlayerListTimerDuration(string productUserId, bool isLobbyOwner, out double sessionSeconds) { sessionSeconds = 0.0; if (string.IsNullOrWhiteSpace(productUserId)) { return false; } if (!isHost) { double lobbyUptimeSeconds = GetLobbyUptimeSeconds(); if (isLobbyOwner) { sessionSeconds = lobbyUptimeSeconds; return true; } if (!IsLocalPlayerProductId(productUserId)) { return false; } if (!_playerJoinTimesByProductId.TryGetValue(productUserId, out var value)) { value = lobbyUptimeSeconds; _playerJoinTimesByProductId[productUserId] = value; } sessionSeconds = lobbyUptimeSeconds - value; return true; } return TryGetPlayerSessionDuration(productUserId, out sessionSeconds); } private bool IsLocalPlayerProductId(string productUserId) { if (localPlayer != null && !string.IsNullOrWhiteSpace(localPlayer.ProductUserId)) { return string.Equals(localPlayer.ProductUserId, productUserId, StringComparison.Ordinal); } return false; } private void TrackPlayerJoinTime(PlayerReference playerReference, double joinTimeSeconds) { _playerJoinTimes[playerReference.ConnectionID] = joinTimeSeconds; if (!string.IsNullOrWhiteSpace(playerReference.ProductUserId)) { _playerJoinTimesByProductId[playerReference.ProductUserId] = joinTimeSeconds; } } public static string FormatLobbyJoinTime(double uptimeSeconds) { if (uptimeSeconds < 0.0) { uptimeSeconds = 0.0; } TimeSpan timeSpan = TimeSpan.FromSeconds(uptimeSeconds); if (!(timeSpan.TotalHours >= 1.0)) { return $"{(int)timeSpan.TotalMinutes}:{timeSpan.Seconds:00}"; } return $"{(int)timeSpan.TotalHours}:{timeSpan.Minutes:00}:{timeSpan.Seconds:00}"; } private static double GetLobbyUptimeSeconds() { TimeManager timeManager = InstanceFinder.TimeManager; if ((Object)(object)timeManager == (Object)null) { return Time.unscaledTimeAsDouble; } if (timeManager.Tick != 0) { return timeManager.TicksToTime(timeManager.Tick); } if (timeManager.ServerUptime > 0f) { return timeManager.ServerUptime; } if (timeManager.ClientUptime > 0f) { return timeManager.ClientUptime; } return Time.unscaledTimeAsDouble; } public static void SetEnableGuestBangCommands(bool value) { if (_enableGuestBangCommands != null) { _enableGuestBangCommands.Value = value; MelonPreferences.Save(); } } public static void SetServerName(string value) { if (_serverName != null) { _serverName.Value = value ?? string.Empty; MelonPreferences.Save(); } } public static void SetServerCapacity(int value) { if (_serverCapacity != null) { _serverCapacity.Value = Math.Clamp(value, 1, 64); MelonPreferences.Save(); } } public static void SetSearchMinPlayers(int value) { if (_searchMinPlayers != null) { _searchMinPlayers.Value = Math.Clamp(value, 1, 64); MelonPreferences.Save(); } } public static void SetSearchMaxPlayers(int value) { if (_searchMaxPlayers != null) { _searchMaxPlayers.Value = ((value != 0) ? Math.Clamp(value, 1, 64) : 0); MelonPreferences.Save(); } } public static void SetSearchShowLocked(bool value) { if (_searchShowLocked != null) { _searchShowLocked.Value = value; MelonPreferences.Save(); } } public static void SetSearchShowModded(bool value) { if (_searchShowModded != null) { _searchShowModded.Value = value; MelonPreferences.Save(); } } public static void SetSearchShowYourLanguageOnly(bool value) { if (_searchShowYourLanguageOnly != null) { _searchShowYourLanguageOnly.Value = value; MelonPreferences.Save(); } } public static void SetSearchOnlyPeacefulLobbies(bool value) { if (_searchOnlyPeacefulLobbies != null) { _searchOnlyPeacefulLobbies.Value = value; if (value && _searchHidePeacefulLobbies != null) { _searchHidePeacefulLobbies.Value = false; } MelonPreferences.Save(); } } public static void SetSearchHidePeacefulLobbies(bool value) { if (_searchHidePeacefulLobbies != null) { _searchHidePeacefulLobbies.Value = value; if (value && _searchOnlyPeacefulLobbies != null) { _searchOnlyPeacefulLobbies.Value = false; } MelonPreferences.Save(); } } public static void SetSearchRegionMode(int value) { if (_searchRegionMode != null) { _searchRegionMode.Value = Math.Clamp(value, 0, 3); MelonPreferences.Save(); } } public static void SetIsPublicLobby(bool value) { if (_isPublicLobby != null) { _isPublicLobby.Value = value; MelonPreferences.Save(); } } public static void SetIsPasswordProtected(bool value) { if (_isPasswordProtected != null) { _isPasswordProtected.Value = value; MelonPreferences.Save(); } } public static void SetLobbyPassword(string value) { if (_lobbyPassword != null) { _lobbyPassword.Value = value ?? string.Empty; MelonPreferences.Save(); } } public static void SetIsPeacefulMode(bool value) { if (_isPeacefulMode != null) { _isPeacefulMode.Value = value; MelonPreferences.Save(); } } public static void SetIsTextChatOnly(bool value) { if (_isTextChatOnly != null) { _isTextChatOnly.Value = value; MelonPreferences.Save(); } } public static void SetMessageOfTheDay(string value) { if (_messageOfTheDay != null) { _messageOfTheDay.Value = value ?? string.Empty; MelonPreferences.Save(); } } public static void SetShowJoinMessages(bool value) { if (_showJoinMessages != null) { _showJoinMessages.Value = value; MelonPreferences.Save(); } } public static void SetShowLeaveMessages(bool value) { if (_showLeaveMessages != null) { _showLeaveMessages.Value = value; MelonPreferences.Save(); } } public static void SetJoinMessageSize(int value) { if (_joinMessageSize != null) { _joinMessageSize.Value = Math.Clamp(value, 50, 100); MelonPreferences.Save(); } } public static void SetLeaveMessageSize(int value) { if (_leaveMessageSize != null) { _leaveMessageSize.Value = Math.Clamp(value, 50, 100); MelonPreferences.Save(); } } [IteratorStateMachine(typeof(<LoadReferences>d__109))] private IEnumerator LoadReferences() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadReferences>d__109(0) { <>4__this = this }; } } internal static class NativeUiBackend { private static int _lastAutoCaptureFrame = -1; private static readonly Color FallbackPanelColor = new Color(0.09f, 0.5f, 0.74f, 0.97f); private static readonly Color FallbackInputColor = new Color(0.95f, 0.96f, 0.98f, 1f); private static readonly Color FallbackToggleCheckColor = new Color(0.17f, 0.74f, 0.45f, 1f); internal static NativeUiTemplateSet Defaults { get; } = new NativeUiTemplateSet(); private static void SetDefaults(NativeUiTemplateSet references, bool overwriteExisting = true) { if (references != null) { Defaults.Button = PickDefault<Button>(Defaults.Button, references.Button, overwriteExisting); Defaults.Label = PickDefault<TMP_Text>(Defaults.Label, references.Label, overwriteExisting); Defaults.HeaderLabel = PickDefault<TMP_Text>(Defaults.HeaderLabel, references.HeaderLabel, overwriteExisting); Defaults.ButtonLabel = PickDefault<TMP_Text>(Defaults.ButtonLabel, references.ButtonLabel, overwriteExisting); Defaults.ToggleLabel = PickDefault<TMP_Text>(Defaults.ToggleLabel, references.ToggleLabel, overwriteExisting); Defaults.SliderLabel = PickDefault<TMP_Text>(Defaults.SliderLabel, references.SliderLabel, overwriteExisting); Defaults.InputText = PickDefault<TMP_Text>(Defaults.InputText, references.InputText, overwriteExisting); Defaults.InputPlaceholder = PickDefault<TMP_Text>(Defaults.InputPlaceholder, references.InputPlaceholder, overwriteExisting); Defaults.InputField = PickDefault<TMP_InputField>(Defaults.InputField, references.InputField, overwriteExisting); Defaults.Toggle = PickDefault<Toggle>(Defaults.Toggle, references.Toggle, overwriteExisting); Defaults.Slider = PickDefault<MySliderUI>(Defaults.Slider, references.Slider, overwriteExisting); Defaults.Scrollbar = PickDefault<Scrollbar>(Defaults.Scrollbar, references.Scrollbar, overwriteExisting); Defaults.Background = PickDefault<Image>(Defaults.Background, references.Background, overwriteExisting); Defaults.Shadow = PickDefault<Shadow>(Defaults.Shadow, references.Shadow, overwriteExisting); Defaults.Panel = PickDefault<GameObject>(Defaults.Panel, references.Panel, overwriteExisting); } } private static void SetDefault(Button template, bool overwriteExisting = true) { Defaults.Button = PickDefault<Button>(Defaults.Button, template, overwriteExisting); Defaults.ButtonLabel = PickDefault<TMP_Text>(Defaults.ButtonLabel, ((Object)(object)template != (Object)null) ? ((Component)template).GetComponentInChildren<TMP_Text>(true) : null, overwriteExisting); Defaults.Shadow = PickDefault<Shadow>(Defaults.Shadow, ((Object)(object)template != (Object)null) ? ((Component)template).GetComponent<Shadow>() : null, overwriteExisting); } internal static void CaptureDefaultsFrom(Transform root, bool overwriteExisting = false) { if (!((Object)(object)root == (Object)null)) { Button val = FindButtonTemplate(root); Toggle val2 = FindToggleTemplate(root); MySliderUI componentInChildren = ((Component)root).GetComponentInChildren<MySliderUI>(true); TMP_InputField componentInChildren2 = ((Component)root).GetComponentInChildren<TMP_InputField>(true); TMP_Text buttonLabel = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<TMP_Text>(true) : null); TMP_Text toggleLabel = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentInChildren<TMP_Text>(true) : null); TMP_Text sliderLabel = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponentInChildren<TMP_Text>(true) : null); TMP_Text inputText = (((Object)(object)componentInChildren2 != (Object)null) ? componentInChildren2.textComponent : null); TMP_Text inputPlaceholder = (((Object)(object)componentInChildren2 != (Object)null && (Object)(object)componentInChildren2.placeholder != (Object)null) ? ((Component)componentInChildren2.placeholder).GetComponent<TMP_Text>() : null); SetDefaults(new NativeUiTemplateSet { Button = val, Label = ((Component)root).GetComponentInChildren<TMP_Text>(true), ButtonLabel = buttonLabel, ToggleLabel = toggleLabel, SliderLabel = sliderLabel, InputText = inputText, InputPlaceholder = inputPlaceholder, InputField = componentInChildren2, Toggle = val2, Slider = componentInChildren, Scrollbar = ((Component)root).GetComponentInChildren<Scrollbar>(true), Background = FindBackgroundImage(root), Shadow = ((Component)root).GetComponentInChildren<Shadow>(true), Panel = FindPanelTemplate(root) }, overwriteExisting); } } internal static void CaptureSceneDefaults(bool overwriteExisting = false) { GameObject val = FindNamedObject("UI_CreateLobby"); if ((Object)(object)val != (Object)null) { CaptureCreateLobbyDefaults(val.transform, overwriteExisting); CaptureDefaultsFrom(val.transform, overwriteExisting); } Button val2 = FindNamedComponent<Button>(new string[3] { "(Button) HOST", "(Button) Join", "(Button) JOIN" }); if ((Object)(object)val2 != (Object)null) { SetDefault(val2, overwriteExisting); } TMP_Text candidate = FindNamedComponent<TMP_Text>(new string[3] { "(Text) quick changes", "(Text) SECTION TITLE", "(Text) chat related section" }); Defaults.HeaderLabel = PickDefault<TMP_Text>(Defaults.HeaderLabel, candidate, overwriteExisting); GameObject obj = FindNamedObject("UI_MainMenu"); object obj2; if (obj == null) { obj2 = null; } else { Transform obj3 = obj.transform.Find("Panel"); obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null); } GameObject val3 = (GameObject)obj2; if ((Object)(object)val3 != (Object)null) { CaptureDefaultsFrom(val3.transform, overwriteExisting); } } internal static UiElement Assume(GameObject gameObject) { return new UiElement(gameObject); } internal static UiElement Assume(Component component) { return new UiElement(((Object)(object)component != (Object)null) ? component.gameObject : null); } internal static UiElement Assume(Transform transform) { return new UiElement(((Object)(object)transform != (Object)null) ? ((Component)transform).gameObject : null); } internal static UiElement Find(string sceneObjectName) { return new UiElement(string.IsNullOrEmpty(sceneObjectName) ? null : FindNamedObject(sceneObjectName)); } internal static UiElement Create(string name, Transform parent = null, bool active = true) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GameObject val = new GameObject(string.IsNullOrEmpty(name) ? "UI Element" : name); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, false); } EnsureRectTransform(val); val.SetActive(active); return new UiElement(val); } internal static UiElement Clone(GameObject template, Transform parent, string name = null, int? siblingIndex = null, bool active = true) { if ((Object)(object)template == (Object)null) { return new UiElement(null); } GameObject val = Object.Instantiate<GameObject>(template, parent); if ((Object)(object)val == (Object)null) { return new UiElement(null); } if (!string.IsNullOrEmpty(name)) { ((Object)val).name = name; } if (siblingIndex.HasValue) { val.transform.SetSiblingIndex(siblingIndex.Value); } val.SetActive(active); return new UiElement(val); } internal static T CloneComponent<T>(T template, Transform parent, string name = null, int? siblingIndex = null, bool active = true) where T : Component { return Clone(((Object)(object)template != (Object)null) ? ((Component)template).gameObject : null, parent, name, siblingIndex, active).Get<T>(); } internal static TMP_InputField CloneInputField(TMP_InputField template, Transform parent, string name = null, string text = null, string placeholder = null, int? siblingIndex = null, bool clearListeners = true) { TMP_InputField val = NativeUiBackend.CloneComponent<TMP_InputField>(template, parent, name, siblingIndex, active: true); if ((Object)(object)val == (Object)null) { return null; } if (clearListeners) { ClearInputFieldEvents(val); } if (text != null) { val.text = text; } TMP_Text val2 = (((Object)(object)val.placeholder != (Object)null) ? ((Component)val.placeholder).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null && placeholder != null) { SetText(val2, placeholder); } return val; } internal static Toggle CloneToggle(Toggle template, Transform parent, string name = null, string label = null, bool? isOn = null, UnityAction<bool> onValueChanged = null, int? siblingIndex = null, bool clearListeners = true) { Toggle val = NativeUiBackend.CloneComponent<Toggle>(template, parent, name, siblingIndex, active: true); if ((Object)(object)val == (Object)null) { return null; } if (label != null) { SetText(((Component)val).GetComponentInChildren<TMP_Text>(true), label); } if (clearListeners) { ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); } if (isOn.HasValue) { val.isOn = isOn.Value; } ApplyToggleStyle(val, template); if ((Delegate)(object)onValueChanged != (Delegate)null) { ((UnityEvent<bool>)(object)val.onValueChanged).AddListener(onValueChanged); } return val; } internal static TMP_Text CreatePlainLabel(Transform parent, string text, string name = "Label", TMP_Text template = null, bool active = true) { TextMeshProUGUI obj = Create(string.IsNullOrEmpty(name) ? "Label" : name, parent, active).GameObject.AddComponent<TextMeshProUGUI>(); ApplyTextStyle((TMP_Text)(object)obj, template ?? Defaults.Label); ((Graphic)obj).raycastTarget = false; SetText((TMP_Text)(object)obj, text); return (TMP_Text)(object)obj; } internal static MySliderUI CreateSlider(Transform parent, string name = "Slider", MySliderUI template = null, float? minValue = null, float? maxValue = null, float? value = null, UnityAction<float> onValueChanged = null, int? siblingIndex = null, bool active = true, bool clearListeners = true) { CaptureSceneDefaultsIf((Object)(object)template == (Object)null && (Object)(object)Defaults.Slider == (Object)null); MySliderUI val = NativeUiBackend.CloneComponent<MySliderUI>(template ?? Defaults.Slider, parent, name, siblingIndex, active: true); if ((Object)(object)val == (Object)null || (Object)(object)val.slider == (Object)null) { return val; } if (clearListeners) { ((UnityEventBase)val.slider.onValueChanged).RemoveAllListeners(); val.OnSliderValueFinishedChanging = null; } if (minValue.HasValue) { val.slider.minValue = minValue.Value; } if (maxValue.HasValue) { val.slider.maxValue = maxValue.Value; } if (value.HasValue) { val.slider.SetValueWithoutNotify(value.Value); } if ((Delegate)(object)onValueChanged != (Delegate)null) { ((UnityEvent<float>)(object)val.slider.onValueChanged).AddListener(onValueChanged); } val.UpdateSliderValueDisplay(); ((Component)val).gameObject.SetActive(active); return val; } private static Scrollbar CreateScrollbar(Transform parent, string name = "Scrollbar", Scrollbar template = null, float? value = null, float? size = null, UnityAction<float> onValueChanged = null, int? siblingIndex = null, bool active = true, bool clearListeners = true) { CaptureSceneDefaultsIf((Object)(object)template == (Object)null && (Object)(object)Defaults.Scrollbar == (Object)null); Scrollbar val = NativeUiBackend.CloneComponent<Scrollbar>(template ?? Defaults.Scrollbar, parent, name, siblingIndex, active: true); if ((Object)(object)val == (Object)null) { return null; } if (clearListeners) { ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); } if (size.HasValue) { val.size = size.Value; } if (value.HasValue) { val.value = value.Value; } if ((Delegate)(object)onValueChanged != (Delegate)null) { ((UnityEvent<float>)(object)val.onValueChanged).AddListener(onValueChanged); } ((Component)val).gameObject.SetActive(active); return val; } internal static ScrollViewport CreateScrollViewport(Transform parent, string name = "Scroll Viewport", Vector2? sizeDelta = null, Scrollbar scrollbarTemplate = null) { //IL_0138: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0213: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = Create(name, parent).GameObject; if (sizeDelta.HasValue) { RectTransform rectTransform = EnsureRectTransform(gameObject); Vector2? sizeDelta2 = sizeDelta; SetRect(rectTransform, null, sizeDelta2); } float? flexibleHeight = 1f; float? flexibleWidth = 1f; SetLayout(gameObject, null, null, flexibleWidth, flexibleHeight); ScrollRect val = gameObject.GetComponent<ScrollRect>() ?? gameObject.AddComponent<ScrollRect>(); Image val2 = CreateBackground(gameObject.transform, "Viewport Background", Defaults.Background ?? (((Object)(object)Defaults.Panel != (Object)null) ? Defaults.Panel.GetComponent<Image>() : null)); RectTransform val3 = EnsureRectTransform(((Component)val2).gameObject); val3.anchorMin = new Vector2(0f, 0f); val3.anchorMax = new Vector2(1f, 1f); val3.offsetMin = Vector2.zero; val3.offsetMax = new Vector2(-42f, 0f); GameObject val4 = new GameObject("Content"); val4.transform.SetParent((Transform)(object)val3, false); RectTransform val5 = EnsureRectTransform(val4); val5.anchorMin = new Vector2(0f, 1f); val5.anchorMax = new Vector2(1f, 1f); val5.pivot = new Vector2(0.5f, 1f); val5.anchoredPosition = Vector2.zero; val5.sizeDelta = new Vector2(0f, 0f); SetVerticalLayout(val4, new RectOffset(0, 16, 0, 0), 8f); val4.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; val.content = val5; val.viewport = val3; val.horizontal = false; val.vertical = true; val.movementType = (MovementType)2; Scrollbar val6 = null; if (scrollbarTemplate == null) { scrollbarTemplate = Defaults.Scrollbar; } if ((Object)(object)scrollbarTemplate != (Object)null) { val6 = CreateScrollbar(gameObject.transform, "Scrollbar", scrollbarTemplate); if ((Object)(object)val6 != (Object)null) { RectTransform obj = EnsureRectTransform(((Component)val6).gameObject); obj.anchorMin = new Vector2(1f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-24f, 0f); obj.sizeDelta = new Vector2(18f, 0f); val.verticalScrollbar = val6; val.verticalScrollbarVisibility = (ScrollbarVisibility)0; } } (((Component)val2).gameObject.GetComponent<Mask>() ?? ((Component)val2).gameObject.AddComponent<Mask>()).showMaskGraphic = false; return new ScrollViewport { Root = gameObject, ViewportRect = val3, ContentRect = val5, ScrollRect = val, Scrollbar = val6 }; } internal static UiElement CreatePanel(Transform parent, string name = "Panel", GameObject template = null, Vector2? sizeDelta = null, Vector2? anchoredPosition = null, int? siblingIndex = null, bool active = true, bool cloneTemplate = false) { //IL_01a8: 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) CaptureSceneDefaultsIf((Object)(object)template == (Object)null && (Object)(object)Defaults.Panel == (Object)null && (Object)(object)Defaults.Background == (Object)null); Image val = (((Object)(object)template == (Object)null) ? FindLobbyPanelBackground() : null); GameObject val2 = template ?? (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null) ?? Defaults.Panel ?? (((Object)(object)Defaults.Background != (Object)null) ? ((Component)Defaults.Background).gameObject : null); if (cloneTemplate && (Object)(object)val2 != (Object)null) { UiElement uiElement = Clone(val2, parent, name, siblingIndex, active); NormalizeClonedUiRoot(uiElement.GameObject); SetRect(uiElement.RectTransform, anchoredPosition, sizeDelta); return uiElement; } UiElement uiElement2 = Create(name, parent, active); if (siblingIndex.HasValue) { uiElement2.SiblingIndex(siblingIndex.Value); } Image val3 = val ?? (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Image>() : null); if (val3 == null) { val3 = Defaults.Background; } Image val4 = CopyImage(val3, uiElement2.GameObject); if ((Object)(object)val4 != (Object)null) { ((Graphic)val4).raycastTarget = true; if ((Object)(object)val2 == (Object)null && (Object)(object)Defaults.Background == (Object)null) { ((Graphic)val4).color = FallbackPanelColor; } } else if ((Object)(object)val2 == (Object)null && (Object)(object)Defaults.Background == (Object)null) { val4 = uiElement2.GameObject.AddComponent<Image>(); ((Graphic)val4).color = FallbackPanelColor; ((Graphic)val4).raycastTarget = true; } Shadow val5 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<Shadow>() : null); if (val5 == null) { val5 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Shadow>() : null); } if (val5 == null) { val5 = Defaults.Shadow; } if ((Object)(object)val5 != (Object)null) { CopyShadow(val5, uiElement2.GameObject); } LayoutElement val6 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<LayoutElement>() : null); if ((Object)(object)val6 != (Object)null) { CopyLayout(val6, uiElement2.GameObject); } SetRect(uiElement2.RectTransform, anchoredPosition, sizeDelta); return uiElement2; } internal static Image CreateBackground(Transform parent, string name = "Background", Image template = null, Color? color = null, Vector2? sizeDelta = null, Vector2? anchoredPosition = null, int? siblingIndex = null, bool active = true) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) CaptureSceneDefaultsIf((Object)(object)template == (Object)null && (Object)(object)Defaults.Background == (Object)null); UiElement uiElement = Create(name, parent, active); if (siblingIndex.HasValue) { uiElement.SiblingIndex(siblingIndex.Value); } Image val = CopyImage(template ?? Defaults.Background ?? (((Object)(object)Defaults.Button != (Object)null) ? ((Component)Defaults.Button).GetComponent<Image>() : null), uiElement.GameObject); if ((Object)(object)val == (Object)null) { return null; } if (color.HasValue) { ((Graphic)val).color = color.Value; } else if ((Object)(object)template == (Object)null && (Object)(object)Defaults.Background == (Object)null && (Object)(object)Defaults.Button == (Object)null) { ((Graphic)val).color = FallbackPanelColor; } SetRect((Component)(object)val, anchoredPosition, sizeDelta); return val; } internal static Image CreateScreenBackdrop(Transform parent, string name = "Backdrop", Image template = null, Color? color = null) { //IL_005b: 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_004a: Unknown result type (might be due to invalid IL or missing references) UiElement uiElement = Create(name, parent); Image val = CopyImage(template, uiElement.GameObject); if ((Object)(object)val == (Object)null) { return null; } ((Graphic)val).color = (Color)(((??)color) ?? (((Object)(object)template != (Object)null) ? ((Graphic)template).color : new Color(0f, 0f, 0f, 0.45f))); ((Graphic)val).raycastTarget = true; Stretch(uiElement.GameObject); return val; } internal static RectTransform EnsureRectTransform(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return null; } RectTransform component = gameObject.GetComponent<RectTransform>(); if (!((Object)(object)component != (Object)null)) { return gameObject.AddComponent<RectTransform>(); } return component; } internal static void SetRect(Component component, Vector2? anchoredPosition = null, Vector2? sizeDelta = null, Vector2? anchorMin = null, Vector2? anchorMax = null, Vector2? pivot = null, Vector3? scale = null) { SetRect(((Object)(object)component != (Object)null) ? component.GetComponent<RectTransform>() : null, anchoredPosition, sizeDelta, anchorMin, anchorMax, pivot, scale); } internal static void SetRect(RectTransform rectTransform, Vector2? anchoredPosition = null, Vector2? sizeDelta = null, Vector2? anchorMin = null, Vector2? anchorMax = null, Vector2? pivot = null, Vector3? scale = null) { //IL_0016: 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_0042: 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_006e: 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) if (!((Object)(object)rectTransform == (Object)null)) { if (anchoredPosition.HasValue) { rectTransform.anchoredPosition = anchoredPosition.Value; } if (sizeDelta.HasValue) { rectTransform.sizeDelta = sizeDelta.Value; } if (anchorMin.HasValue) { rectTransform.anchorMin = anchorMin.Value; } if (anchorMax.HasValue) { rectTransform.anchorMax = anchorMax.Value; } if (pivot.HasValue) { rectTransform.pivot = pivot.Value; } if (scale.HasValue) { ((Transform)rectTransform).localScale = scale.Value; } } } internal static void SetCanvasGroups(Transform root, float alpha = 1f, bool interactable = true, bool blocksRaycasts = true, bool includeInactive = true, bool setRootActive = false) { if ((Object)(object)root == (Object)null) { return; } if (setRootActive) { ((Component)root).gameObject.SetActive(true); } foreach (CanvasGroup componentsInChild in ((Component)root).GetComponentsInChildren<CanvasGroup>(includeInactive)) { componentsInChild.alpha = alpha; componentsInChild.interactable = interactable; componentsInChild.blocksRaycasts = blocksRaycasts; } } internal static void ActivatePathToRoot(Transform start, Transform root) { Transform val = start; while ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(true); if (!((Object)(object)val == (Object)(object)root)) { val = val.parent; continue; } break; } } internal static void SetChildrenActive(Transform parent, bool active, string skipNameContains = null) { if ((Object)(object)parent == (Object)null) { return; } for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (!((Object)(object)child == (Object)null) && (string.IsNullOrEmpty(skipNameContains) || !((Object)child).name.Contains(skipNameContains))) { ((Component)child).gameObject.SetActive(active); } } } internal static VerticalLayoutGroup SetVerticalLayout(GameObject gameObject, RectOffset padding = null, float spacing = 0f, bool childControlWidth = true, bool childControlHeight = true, bool childForceExpandWidth = true, bool childForceExpandHeight = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return null; } VerticalLayoutGroup val = gameObject.GetComponent<VerticalLayoutGroup>(); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent<VerticalLayoutGroup>(); } ((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset())); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((HorizontalOrVerticalLayoutGroup)val).childControlWidth = childControlWidth; ((HorizontalOrVerticalLayoutGroup)val).childControlHeight = childControlHeight; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = childForceExpandWidth; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = childForceExpandHeight; return val; } internal static HorizontalLayoutGroup SetHorizontalLayout(GameObject gameObject, float spacing = 0f, RectOffset padding = null, bool childControlWidth = true, bool childControlHeight = true, bool childForceExpandWidth = false, bool childForceExpandHeight = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return null; } HorizontalLayoutGroup val = gameObject.GetComponent<HorizontalLayoutGroup>(); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent<HorizontalLayoutGroup>(); } ((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset())); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((HorizontalOrVerticalLayoutGroup)val).childControlWidth = childControlWidth; ((HorizontalOrVerticalLayoutGroup)val).childControlHeight = childControlHeight; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = childForceExpandWidth; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = childForceExpandHeight; return val; } internal static UiElement CreateHorizontalRow(Transform parent, string name = "Row", float height = 38f, float spacing = 14f) { UiElement uiElement = Create(name, parent); SetHorizontalLayout(uiElement.GameObject, spacing); GameObject gameObject = uiElement.GameObject; float? preferredHeight = height; SetFixedLayoutSize(gameObject, null, preferredHeight); return uiElement; } internal static UiElement CreateFlexRow(Transform parent, string name = "Row", float height = 38f, float spacing = 14f, RectOffset padding = null) { UiElement uiElement = Create(name, parent); SetHorizontalLayout(uiElement.GameObject, spacing, padding, childControlWidth: false); GameObject gameObject = uiElement.GameObject; float? preferredHeight = height; SetFixedLayoutSize(gameObject, null, preferredHeight); return uiElement; } internal static GridTrackRow CreateGridTrackRow(Transform parent, string name = "Row", float height = 38f, float spacing = 14f, RectOffset padding = null, params float[] trackWidths) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) UiElement uiElement = Create(name, parent); GameObject gameObject = uiElement.GameObject; float? preferredHeight = height; SetFixedLayoutSize(gameObject, null, preferredHeight); if (trackWidths == null || trackWidths.Length == 0) { trackWidths = new float[3] { 0f, 0f, 1f }; } RectTransform[] array = (RectTransform[])(object)new RectTransform[trackWidths.Length]; float num = 0f; for (int i = 0; i < trackWidths.Length; i++) { if (trackWidths[i] > 0f) { num += trackWidths[i]; } } for (int j = 0; j < trackWidths.Length; j++) { RectTransform val = EnsureRectTransform(Create($"{name} Track {j}", uiElement.GameObject.transform).GameObject); val.anchorMin = new Vector2(0f, 0.5f); val.anchorMax = new Vector2(0f, 0.5f); val.pivot = new Vector2(0f, 0.5f); val.anchoredPosition = Vector2.zero; val.sizeDelta = new Vector2(0f, height); array[j] = val; } GridTrackRow gridTrackRow = new GridTrackRow(uiElement.GameObject, array); LayoutGridTracks(gridTrackRow, spacing, padding, trackWidths); return gridTrackRow; } internal static void LayoutGridTracks(GridTrackRow gridRow, float spacing = 14f, RectOffset padding = null, params float[] trackWidths) { //IL_0061: 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_0084: 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_0077: 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_00b3: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) if (gridRow == null || gridRow.Tracks == null || gridRow.Tracks.Length == 0) { return; } RectTransform val = (((Object)(object)gridRow.GameObject != (Object)null) ? gridRow.GameObject.GetComponent<RectTransform>() : null); if ((Object)(object)val == (Object)null) { return; } float num = ((padding != null) ? ((float)padding.left) : 0f); float num2 = ((padding != null) ? ((float)padding.right) : 0f); Rect rect = val.rect; float num3; if (!(((Rect)(ref rect)).width > 0f)) { num3 = val.sizeDelta.x; } else { rect = val.rect; num3 = ((Rect)(ref rect)).width; } float num4 = num3; if (num4 <= 0f) { Transform parent = ((Transform)val).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val2 != null) { rect = val2.rect; float num5; if (!(((Rect)(ref rect)).width > 0f)) { num5 = val2.sizeDelta.x; } else { rect = val2.rect; num5 = ((Rect)(ref rect)).width; } num4 = num5; } } if (num4 <= 0f) { return; } if (trackWidths == null || trackWidths.Length != gridRow.Tracks.Length) { trackWidths = new float[gridRow.Tracks.Length]; } float num6 = 0f; for (int i = 0; i < trackWidths.Length; i++) { if (trackWidths[i] > 0f) { num6 += trackWidths[i]; } } float num7 = Mathf.Max(0f, num4 - num - num2 - spacing * (float)Mathf.Max(0, trackWidths.Length - 1)); float num8 = ((num6 > 0f) ? (num7 / num6) : 0f); float num9 = num; for (int j = 0; j < gridRow.Tracks.Length; j++) { RectTransform val3 = gridRow.Tracks[j]; if (!((Object)(object)val3 == (Object)null)) { float num10 = ((trackWidths[j] > 0f) ? (trackWidths[j] * num8) : 0f); val3.anchorMin = new Vector2(0f, 0.5f); val3.anchorMax = new Vector2(0f, 0.5f); val3.pivot = new Vector2(0f, 0.5f); val3.anchoredPosition = new Vector2(num9, 0f); float num11; if (!(val3.sizeDelta.y > 0f)) { rect = val.rect; num11 = ((Rect)(ref rect)).height; } else { num11 = val3.sizeDelta.y; } val3.sizeDelta = new Vector2(num10, num11); num9 += num10 + spacing; } } } internal static LayoutElement SetFixedLayoutSize(GameObject gameObject, float? preferredWidth = null, float? preferredHeight = null, float? flexibleWidth = null, float? flexibleHeight = null) { LayoutElement val = SetLayout(gameObject, preferredWidth, preferredHeight, flexibleWidth, flexibleHeight, preferredWidth, preferredHeight); if ((Object)(object)val != (Object)null) { val.ignoreLayout = false; val.layoutPriority = 1; } return val; } internal static LayoutElement SetLayout(GameObject gameObject, float? preferredWidth = null, float? preferredHeight = null, float? flexibleWidth = null, float? flexibleHeight = null, float? minWidth = null, float? minHeight = null) { if ((Object)(object)gameObject == (Object)null) { return null; } LayoutElement val = gameObject.GetComponent<LayoutElement>(); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent<LayoutElement>(); } if (preferredWidth.HasValue) { val.preferredWidth = preferredWidth.Value; } if (preferredHeight.HasValue) { val.preferredHeight = preferredHeight.Value; } if (flexibleWidth.HasValue) { val.flexibleWidth = flexibleWidth.Value; } if (flexibleHeight.HasValue) { val.flexibleHeight = flexibleHeight.Value; } if (minWidth.HasValue) { val.minWidth = minWidth.Value; } if (minHeight.HasValue) { val.minHeight = minHeight.Value; } return val; } internal static void StabilizeClonedControl(GameObject gameObject) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return; } LeanTween.cancel(gameObject); gameObject.transform.localScale = Vector3.one; foreach (ContentSizeFitter componentsInChild in gameObject.GetComponentsInChildren<ContentSizeFitter>(true)) { if ((Object)(object)componentsInChild != (Object)null) { ((Behaviour)componentsInChild).enabled = false; } } foreach (Selectable componentsInChild2 in gameObject.GetComponentsInChildren<Selectable>(true)) { if ((Object)(object)componentsInChild2 != (Object)null) { componentsInChild2.transition = (Transition)1; } } foreach (AnimationSelectableUi componentsInChild3 in gameObject.GetComponentsInChildren<AnimationSelectableUi>(true)) { if (!((Object)(object)componentsInChild3 == (Object)null)) { LeanTween.cancel(((Component)componentsInChild3).gameObject); ((Component)componentsInChild3).transform.localScale = Vector3.one; ((Behaviour)componentsInChild3).enabled = false; componentsInChild3.OnSelect = null; componentsInChild3.OnDeselect = null; Object.Destroy((Object)(object)componentsInChild3); } } foreach (Component componentsInChild4 in gameObject.GetComponentsInChildren<Component>(true)) { if ((Object)(object)componentsInChild4 != (Object)null && ((MemberInfo)((Object)componentsInChild4).GetIl2CppType()).Name == "AnimationSelectableUi") { Behaviour val = (Behaviour)(object)((componentsInChild4 is Behaviour) ? componentsInChild4 : null); if (val != null) { val.enabled = false; } Object.Destroy((Object)(object)componentsInChild4); } } NormalizeClonedUiRoot(gameObject); } internal static void SetTextMetrics(TMP_Text textComponent, float fontSize, TextAlignmentOptions alignment = 513, bool autoSize = false, float minFontSize = 12f) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)textComponent == (Object)null)) { textComponent.fontSize = fontSize; textComponent.fontSizeMax = fontSize; textComponent.fontSizeMin = minFontSize; textComponent.enableAutoSizing = autoSize; textComponent.alignment = alignment; textComponent.fontStyle = (FontStyles)0; textComponent.enableWordWrapping = false; textComponent.overflowMode = (TextOverflowModes)1; textComponent.characterSpacing = 0f; textComponent.wordSpacing = 0f; textComponent.lineSpacing = 0f; textComponent.paragraphSpacing = 0f; textComponent.ForceMeshUpdate(false, false); } } internal static void SetInputTextStyle(TMP_InputField input, float fontSize, TextAlignmentOptions alignment = 4097, bool autoSize = false, float minFontSize = 14f) { //IL_0046: 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) if ((Object)(object)input == (Object)null) { return; } if ((Object)(object)input.textComponent != (Object)null) { if ((Object)(object)Defaults.InputText != (Object)null) { ApplyTextStyle(input.textComponent, Defaults.InputText); } SetTextMetrics(input.textComponent, fontSize, alignment, autoSize, minFontSize); } TMP_Text val = (((Object)(object)input.placeholder != (Object)null) ? ((Component)input.placeholder).GetComponent<TMP_Text>() : null); if ((Object)(object)val != (Object)null) { TMP_Text val2 = Defaults.InputPlaceholder ?? Defaults.InputText; if ((Object)(object)val2 != (Object)null) { ApplyTextStyle(val, val2); } SetTextMetrics(val, fontSize, alignment, autoSize, minFontSize); } } internal static TMP_Text SetText(TMP_Text textComponent, string text, bool removeLocalization = true) { if ((Object)(object)textComponent == (Object)null) { return null; } if (removeLocalization) { RemoveLocalization((Component)(object)textComponent); } textComponent.text = text ?? string.Empty; textComponent.ForceMeshUpdate(false, false); return textComponent; } internal static void RemoveLocalization(Component component) { if ((Object)(object)component == (Object)null) { return; } foreach (Component component2 in component.GetComponents<Component>()) { if (!((Object)(object)component2 == (Object)null)) { string name = ((MemberInfo)((Object)component2).GetIl2CppType()).Name; if (name.Contains("LocalizeStringEvent") || name.Contains("Localisation") || name.Contains("Localization")) { Object.Destroy((Object)(object)component2); } } } } internal static void ApplyTextStyle(TMP_Text target, TMP_Text template = null) { //IL_0048: 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_0060: 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_0023: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { if (template == null) { template = Defaults.Label; } if ((Object)(object)template == (Object)null) { ((Graphic)target).color = Color.white; return; } target.font = template.font; target.fontSharedMaterial = template.fontSharedMaterial; target.fontStyle = template.fontStyle; ((Graphic)target).color = ((Graphic)template).color; target.alignment = template.alignment; target.enableWordWrapping = template.enableWordWrapping; target.overflowMode = template.overflowMode; target.characterSpacing = template.characterSpacing; target.wordSpacing = template.wordSpacing; target.lineSpacing = template.lineSpacing; target.paragraphSpacing = template.paragraphSpacing; } } internal static void ApplyToggleStyle(Toggle toggle, Toggle template = null) { //IL_009f: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)toggle == (Object)null)) { if (template == null) { template = Defaults.Toggle; } Image val = FindChildImage(((Object)(object)template != (Object)null) ? ((Component)template).transform : null, "Background"); Image val2 = FindChildImage(((Object)(object)template != (Object)null) ? ((Component)template).transform : null, "Checkmark"); GameObject val3 = FindOrCreateChild(((Component)toggle).transform, "Background"); Image val4 = CopyImage(val ?? Defaults.Background, val3); if ((Object)(object)val4 != (Object)null && (Object)(object)val == (Object)null && (Object)(object)Defaults.Background == (Object)null) { ((Graphic)val4).color = FallbackInputColor; } RectTransform val5 = EnsureRectTransform(val3); RectTransform val6 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<RectTransform>() : null); if ((Object)(object)val6 != (Object)null) { CopyRect(val6, val5); } else { val5.anchorMin = new Vector2(0f, 0.5f); val5.anchorMax = new Vector2(0f, 0.5f); val5.pivot = new Vector2(0.5f, 0.5f); val5.anchoredPosition = new Vector2(10f, 0f); ((Transform)val5).localScale = Vector3.one; val5.sizeDelta = new Vector2(20f, 20f); } GameObject val7 = FindOrCreateChild(val3.transform, "Checkmark"); Image val8 = CopyImage(val2, val7); if ((Object)(object)val8 != (Object)null && (Object)(object)val2 == (Object)null) { ((Graphic)val8).color = FallbackToggleCheckColor; } RectTransform val9 = EnsureRectTransform(val7); RectTransform val10 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<RectTransform>() : null); if ((Object)(object)val10 != (Object)null) { CopyRect(val10, val9); } else { val9.anchorMin = new Vector2(0.5f, 0.5f); val9.anchorMax = new Vector2(0.5f, 0.5f); val9.pivot = new Vector2(0.5f, 0.5f); val9.anchoredPosition = Vector2.zero; ((Transform)val9).localScale = Vector3.one; val9.sizeDelta = new Vector2(10f, 10f); } ((Selectable)toggle).targetGraphic = (Graphic)(object)val4; toggle.graphic = (Graphic)(object)val8; if ((Object)(object)((Component)toggle).GetComponent<MyToggleUI>() == (Object)null) { ((Component)toggle).gameObject.AddComponent<MyToggleUI>(); } if ((Object)(object)template != (Object)null) { ((Selectable)toggle).transition = ((Selectable)template).transition; ((Selectable)toggle).colors = ((Selectable)template).colors; ((Selectable)toggle).spriteState = ((Selectable)template).spriteState; ((Selectable)toggle).animationTriggers = ((Selectable)template).animationTriggers; ((Selectable)toggle).navigation = ((Selectable)template).navigation; } ApplyTextStyle(((Component)toggle).GetComponentInChildren<TMP_Text>(true), ((Object)(object)template != (Object)null) ? ((Component)template).GetComponentInChildren<TMP_Text>(true) : (Defaults.ToggleLabel ?? Defaults.Label)); NormalizeClonedUiRoot(((Component)toggle).gameObject); } } private static Image SetImageColor(Component component, Color color) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Image val = (((Object)(object)component != (Object)null) ? component.GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { ((Graphic)val).color = color; } return val; } private static Shadow SetShadowColor(Component component, Color color) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Shadow val = (((Object)(object)component != (Object)null) ? component.GetComponent<Shadow>() : null); if ((Object)(object)val != (Object)null) { val.effectColor = color; } return val; } internal static void SetButtonColors(Button button, Color imageColor, Color shadowColor) { //IL_0001: 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) SetImageColor((Component)(object)button, imageColor); SetShadowColor((Component)(object)button, shadowColor); } internal static Shadow CopyShadow(Shadow template, GameObject target) { if (!((Object)(object)target != (Object)null)) { return null; } return CopyShadow(template, (Component)(object)target.transform); } internal static Shadow CopyShadow(Shadow template, Component component) { //IL_0032: 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) if ((Object)(object)component == (Object)null) { return null; } Shadow val = component.GetComponent<Shadow>(); if ((Object)(object)val == (Object)null) { val = component.gameObject.AddComponent<Shadow>(); } if ((Object)(object)template != (Object)null) { val.effectColor = template.effectColor; val.effectDistance = template.effectDistance; val.useGraphicAlpha = template.useGraphicAlpha; } return val; } internal static Image CopyImage(Image template, GameObject target) { //IL_0040: 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) if ((Object)(object)target == (Object)null) { return null; } Image val = target.GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = target.AddComponent<Image>(); } if ((Object)(object)template != (Object)null) { CopyGraphic((Graphic)(object)template, (Graphic)(object)val); val.sprite = template.sprite; val.type = template.type; val.preserveAspect = template.preserveAspect; val.fillCenter = template.fillCenter; val.fillMethod = template.fillMethod; val.fillAmount = template.fillAmount; val.fillClockwise = template.fillClockwise; val.fillOrigin = template.fillOrigin; val.pixelsPerUnitMultiplier = template.pixelsPerUnitMultiplier; } return val; } private static void CopyGraphic(Graphic template, Graphic target) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)template == (Object)null) && !((Object)(object)target == (Object)null)) { target.color = template.color; target.material = template.material; target.raycastTarget = template.raycastTarget; } } private static void CopyRect(RectTransform template, RectTransform target) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0045: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)template == (Object)null) && !((Object)(object)target == (Object)null)) { target.anchorMin = template.anchorMin; target.anchorMax = template.anchorMax; target.pivot = template.pivot; target.anchoredPosition = template.anchoredPosition; target.sizeDelta = template.sizeDelta; target.offsetMin = template.offsetMin; target.offsetMax = template.offsetMax; ((Transform)target).localScale = Vector3.one; } } private static LayoutElement CopyLayout(LayoutElement template, GameObject target) { if ((Object)(object)target == (Object)null) { return null; } LayoutElement val = target.GetComponent<LayoutElement>(); if ((Object)(object)val == (Object)null) { val = target.AddComponent<LayoutElement>(); } if ((Object)(object)template != (Object)null) { val.ignoreLayout = template.ignoreLayout; val.minWidth = template.minWidth; val.minHeight = template.minHeight; val.preferredWidth = template.preferredWidth; val.preferredHeight = template.preferredHeight; val.flexibleWidth = template.flexibleWidth; val.flexibleHeight = template.flexibleHeight; val.layoutPriority = template.layoutPriority; } return val; } private static void ClearInputFieldEvents(TMP_InputField inputField) { if (!((Object)(object)inputField == (Object)null)) { ((UnityEventBase)inputField.onValueChanged).RemoveAllListeners(); ((UnityEventBase)inputField.onSubmit).RemoveAllListeners(); ((UnityEventBase)inputField.onSelect).RemoveAllListeners(); ((UnityEventBase)inputField.onDeselect).RemoveAllListeners(); } } private static T PickDefault<T>(T current, T candidate, bool overwriteExisting) where T : class { if (candidate == null) { return current; } if (!overwriteExisting && current != null) { return current; } return candidate; } private static void CaptureSceneDefaultsIf(bool shouldCapture) { if (shouldCapture && _lastAutoCaptureFrame != Time.frameCount) { _lastAutoCaptureFrame = Time.frameCount; CaptureSceneDefaults(); } } private static void CaptureCreateLobbyDefaults(Transform root, bool overwriteExisting) { if (!((Object)(object)root == (Object)null)) { Transform obj = root.Find("Panels/Lobby Settings (mini)/(Image) Background"); Image val = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null); Transform obj2 = root.Find("Panels/Lobby Settings (mini)/(Button) CONFIRM HOST"); object obj3 = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null); if (obj3 == null) { Transform obj4 = root.Find("Panels/Lobby Settings (mini)/ButtonContainer/(Button) Close Menu"); obj3 = ((obj4 != null) ? ((Component)obj4).GetComponent<Button>() : null); } Button val2 = (Button)obj3; Transform obj5 = root.Find("Panels/Lobby Settings (mini)/CustomLobbyNameInput"); object obj6 = ((obj5 != null) ? ((Component)obj5).GetComponent<TMP_InputField>() : null); if (obj6 == null) { Transform obj7 = root.Find("Panels/Lobby Settings (mini)/password toggles/(Input) lobby setting password"); obj6 = ((obj7 != null) ? ((Component)obj7).GetComponent<TMP_InputField>() : null); } TMP_InputField val3 = (TMP_InputField)obj6; Transform obj8 = root.Find("Panels/Lobby Settings (mini)/lobby type toggles/(Toggle) Game Type public/private"); object obj9 = ((obj8 != null) ? ((Component)obj8).GetComponent<Toggle>() : null); if (obj9 == null) { Transform obj10 = root.Find("Panels/Lobby Settings (mini)/password toggles/(Toggle) uses password"); obj9 = ((obj10 != null) ? ((Component)obj10).GetComponent<Toggle>() : null); } Toggle val4 = (Toggle)obj9; Transform obj11 = root.Find("Panels/Lobby Settings (mini)/(Slider) player count slider"); MySliderUI val5 = ((obj11 != null) ? ((Component)obj11).GetComponent<MySliderUI>() : null); Scrollbar componentInChildren = ((Component)root).GetComponentInChildren<Scrollbar>(true); Transform obj12 = root.Find("Panels/Lobby Settings (mini)/(Text) Settings Text"); object obj13 = ((obj12 != null) ? ((Component)obj12).GetComponent<TMP_Text>() : null); if (obj13 == null) { Transform obj14 = root.Find("Panels/Lobby Settings (mini)/(Text) Lobby Settings"); obj13 = ((obj14 != null) ? ((Component)obj14).GetComponent<TMP_Text>() : null) ?? ((val2 != null) ? ((Component)val2).GetComponentInChildren<TMP_Text>(true) : null) ?? ((val4 != null) ? ((Component)val4).GetComponentInChildren<TMP_Text>(true) : null); } TMP_Text label = (TMP_Text)obj13; TMP_Text inputText = (((Object)(object)val3 != (Object)null) ? val3.textComponent : null); TMP_Text inputPlaceholder = (((Object)(object)val3 != (Object)null && (Object)(object)val3.placeholder != (Object)null) ? ((Component)val3.placeholder).GetComponent<TMP_Text>() : null); SetDefaults(new NativeUiTemplateSet { Button = val2, Label = label, ButtonLabel = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentInChildren<TMP_Text>(true) : null), ToggleLabel = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponentInChildren<TMP_Text>(true) : null), SliderLabel = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponentInChildren<TMP_Text>(true) : null), InputText = inputText, InputPlaceholder = inputPlaceholder, InputField = val3, Toggle = val4, Slider = val5, Scrollbar = componentInChildren, Background = val, Shadow = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Shadow>() : null), Panel = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null) }, overwriteExisting); } } private static Button FindButtonTemplate(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Button val = null; foreach (Button componentsInChild in ((Component)root).GetComponentsInChildren<Button>(true)) { if (!((Object)(object)componentsInChild == (Object)null) && !((Object)(object)((Component)componentsInChild).GetComponent<Image>() == (Object)null)) { string text = ((Object)componentsInChild).name.ToLowerInvariant(); if (text.Contains("host") || text.Contains("join") || text.Contains("settings") || text.Contains("create")) { return componentsInChild; } if (val == null) { val = componentsInChild; } } } return val; } private static Toggle FindToggleTemplate(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Toggle val = null; foreach (Toggle componentsInChild in ((Component)root).GetComponentsInChildren<Toggle>(true)) { if (!((Object)(object)componentsInChild == (Object)null)) { if ((Object)(object)((Component)componentsInChild).GetComponent<MyToggleUI>() != (Object)null && (Object)(object)FindChildImage(((Component)componentsInChild).transform, "Background") != (Object)null && (Object)(object)FindChildImage(((Component)componentsInChild).transform, "Checkmark") != (Object)null) { return componentsInChild; } if (val == null) { val = componentsInChild; } } } return val; } private static T FindNamedComponent<T>(params string[] names) where T : Component { for (int i = 0; i < names.Length; i++) { GameObject val = FindNamedObject(names[i]); T val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<T>() : default(T)); if ((Object)(object)val2 != (Object)null) { return val2; } } return default(T); } private static GameObject FindNamedObject(string name) { if (string.IsNullOrEmpty(name)) { return null; } GameObject val = GameObject.Find(name); if ((Object)(object)val != (Object)null) { return val; } foreach (GameObject item in Resources.FindObjectsOfTypeAll<GameObject>()) { if ((Object)(object)item != (Object)null && ((Object)item).name == name) { return item; } } return null; } private static GameObject FindPanelTemplate(Transform root) { Image val = FindBackgroundImage(root); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).gameObject; } private static Image FindLobbyPanelBackground() { GameObject obj = FindNamedObject("UI_CreateLobby"); Transform val = ((obj != null) ? obj.transform.Find("Panels/Lobby Settings (mini)/(Image) Background") : null); Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 != (Object)null) { return val2; } foreach (GameObject item in Resources.FindObjectsOfTypeAll<GameObject>()) { if (!((Object)(object)item == (Object)null) && !(((Object)item).name != "(Image) Background")) { val2 = item.GetComponent<Image>(); if ((Object)(object)val2 != (Object)null && HasAncestor(item.transform, "Lobby Settings")) { return val2; } } } return null; } private static bool HasAncestor(Transform transform, string nameContains) { Transform val = transform; while ((Object)(object)val != (Object)null) { if (((Object)val).name.Contains(nameContains)) { return true; } val = val.parent; } return false; } private static Image FindBackgroundImage(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Image val = null; foreach (Image componentsInChild in ((Component)root).GetComponentsInChildren<Image>(true)) { string text = ((Object)componentsInChild).name.ToLowerInvariant(); string text2 = (((Object)(object)componentsInChild.sprite != (Object)null) ? ((Object)componentsInChild.sprite).name.ToLowerInvariant() : string.Empty); if (!IsControlImage(componentsInChild) && !text.Contains("fade") && !text.Contains("icon") && !text2.Contains("icon")) { if (text.Contains("panel") || text.Contains("background")) { return componentsInChild; } if ((Object)(object)val == (Object)null) { val = componentsInChild; } } } return val ?? ((Component)root).GetComponentInChildren<Image>(true); } private static GameObject FindOrCreateChild(Transform parent, string name) { if ((Object)(object)parent == (Object)null) { return null; } Image val = FindChildImage(parent, name); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject; } Transform val2 = parent.Find(name); if ((Object)(object)val2 != (Object)null) { return ((Component)val2).gameObject; } return Create(name, parent).GameObject; } private static Image FindChildImage(Transform root, string name) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(name)) { return null; } foreach (Image componentsInChild in ((Component)root).GetComponentsInChildren<Image>(true)) { if ((Object)(object)componentsInChild != (Object)null && ((Object)componentsInChild).name == name) { return componentsInChild; } } return null; } private static void NormalizeClonedUiRoot(GameObject gameObject) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return; } foreach (RectTransform componentsInChild in gameObject.GetComponentsInChildren<RectTransform>(true)) { if ((Object)(object)componentsInChild != (Object)null) { ((Transform)componentsInChild).localScale = Vector3.one; } } } internal static RectTransform Stretch(GameObject gameObject) { //IL_0007: 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_001d: 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) RectTransform obj = EnsureRectTransform(gameObject); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; return obj; } private static bool IsControlImage(Image image) { if ((Object)(object)image == (Object)null) { return false; } Transform val = ((Component)image).transform; while ((Object)(object)val != (Object)null) { if ((Object)(object)((Component)val).GetComponent<Button>() != (Object)null || (Object)(object)((Component)val).GetComponent<Toggle>() != (Object)null || (Object)(object)((Component)val).GetComponent<Slider>() != (Object)null || (Object)(object)((Component)val).GetComponent<Scrollbar>() != (Object)null || (Object)(object)((Component)val).GetComponent<TMP_InputField>() != (Object)null) { return true; } val = val.parent; } return false; } } internal static class SleddingUiAdapter { public static UiElement Assume(GameObject gameObject) { return NativeUiBackend.Assume(gameObject); } public static UiElement Assume(Component component) { return NativeUiBackend.Assume(component); } public static UiElement Assume(Transform transform) { return NativeUiBackend.Assume(transform); } public static UiElement Find(string sceneObjectName) { return NativeUiBackend.Find(sceneObjectName); } public static void CaptureSceneTemplates(bool overwriteExisting = false) { NativeUiTemplates.CaptureScene(overwriteExisting); } public static void CaptureTemplatesFrom(Transform root, bool overwriteExisting = false) { NativeUiTemplates.CaptureFrom(root, overwriteExisting); } } internal static class SleddingUiPaths { public const string CreateLobbyRoot = "UI_CreateLobby"; public const string BackgroundFade = "UI_BackgroundFade"; public const string MainMenuRoot = "UI_MainMenu"; public const string MainMenuPanel = "Panel"; public const string HostButton = "(Button) HOST"; public const string JoinButton = "(Button) Join"; public const string JoinButtonUpper = "(Button) JOIN"; public const string QuitButton = "(Button) Quit"; public const string SettingsHeaderQuickChanges = "(Text) quick changes"; public const string SettingsHeaderSectionTitle = "(Text) SECTION TITLE"; public const string SettingsHeaderChatRelated = "(Text) chat related section"; public const string LobbySettingsPanelBackground = "Panels/Lobby Settings (mini)/(Image) Background"; public const string LobbyConfirmHostButton = "Panels/Lobby Settings (mini)/(Button) CONFIRM HOST"; public const string LobbyCloseButton = "Panels/Lobby Settings (mini)/ButtonContainer/(Button) Close Menu"; public const string LobbyRootCloseButton = "ButtonContainer/(Button) Close Menu"; public const string CustomLobbyNameInput = "Panels/Lobby Settings (mini)/CustomLobbyNameInput"; public const string LobbyPasswordInput = "Panels/Lobby Settings (mini)/password toggles/(Input) lobby setting password"; public const string LobbyPublicPrivateToggle = "Panels/Lobby Settings (mini)/lobby type toggles/(Toggle) Game Type public/private"; public const string LobbyPasswordToggle = "Panels/Lobby Settings (mini)/password toggles/(Toggle) uses password"; public const string LobbyPlayerCountSlider = "Panels/Lobby Settings (mini)/(Slider) player count slider"; public const string LobbySettingsText = "Panels/Lobby Settings (mini)/(Text) Settings Text"; public const string LobbySettingsTitleText = "Panels/Lobby Settings (mini)/(Text) Lobby Settings"; public const string BackgroundImageName = "(Image) Background"; public const string LobbySettingsAncestorName = "Lobby Settings"; public const string BackgroundFadeNameContains = "BackgroundFade"; public const string PanelsNameContains = "Panels"; public const string EditorNameContains = "Editor"; } public class UiElement { public GameObject GameObject { get; } public Transform Transform { get { if (!((Object)(object)GameObject != (Object)null)) { return null; } return GameObject.transform; } } public RectTransform RectTransform { get { if (!((Object)(object)GameObject != (Object)null)) { return null; } return GameObject.GetComponent<RectTransform>(); } } public bool Exists => (Object)(object)GameObject != (Object)null; public UiElement(GameObject gameObject) { GameObject = gameObject; } public T Get<T>() where T : Component { if (!((Object)(object)GameObject != (Object)null)) { return default(T); } return GameObject.GetComponent<T>(); } public T GetInChildren<T>(bool includeInactive = true) where T : Component { if (!((Object)(object)GameObject != (Object)null)) { return default(T); } return GameObject.GetComponentInChildren<T>(includeInactive); } public UiElement Show() { return SetActive(active: true); } public UiElement Hide() { return SetActive(active: false); } public UiElement SetActive(bool active) { if ((Object)(object)GameObject != (Object)null) { GameObject.SetActive(active); } return this; } public UiElement Reparent(Transform parent, bool worldPositionStays = false) { if ((Object)(object)Transform != (Object)null && (Object)(object)parent != (Object)null) { Transform.SetParent(parent, worldPositionStays); } return this; } public UiElement SiblingIndex(int index) { if ((Object)(object)Transform != (Object)null) { Transform.SetSiblingIndex(index); } return this; } public UiElement LastSibling() { if ((Object)(object)Transform != (Object)null) { Transform.SetAsLastSibling(); } return this; } public UiElement FirstSibling() { if ((Object)(object)Transform != (Object)null) { Transform.SetAsFirstSibling(); } return this; } public UiElement Move(Vector2 anchoredPosition) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RectTransform != (Object)null) { RectTransform.anchoredPosition = anchoredPosition; } return this; } public UiElement Resize(Vector2 sizeDelta) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RectTransform != (Object)null) { RectTransform.sizeDelta = sizeDelta; } return this; } public UiElement Scale(float scale) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Scale(new Vector3(scale, scale, 1f)); } public UiElement Scale(Vector3 scale) { //IL_0014: 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) if ((Object)(object)RectTransform != (Object)null) { ((Transform)RectTransform).localScale = scale; } else if ((Object)(object)Transform != (Object)null) { Transform.localScale = scale; } return this; } public UiElement Anchor(Vector2 anchorMin, Vector2 anchorMax) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RectTransform != (Object)null) { RectTransform.anchorMin = anchorMin; RectTransform.anchorMax = anchorMax; } return this; } public UiElement Pivot(Vector2 pivot) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RectTransform != (Object)null) { RectTransform.pivot = pivot; } return this; } public UiElement CenterAnchors() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); return Anchor(val, val).Pivot(val); } public UiElement CanvasGroup(float alpha = 1f, bool interactable = true, bool blocksRaycasts = true) { NativeUiBackend.SetCanvasGroups(Transform, alpha, interactable, blocksRaycasts); return this; } public UiElement Layout(float? preferredWidth = null, float? preferredHeight = null, float? flexibleWidth = null, float? flexibleHeight = null, float? minWidth = null, float? minHeight = null) { NativeUiBackend.SetLayout(GameObject, preferredWidth, preferredHeight, flexibleWidth, flexibleHeight, minWidth, minHeight); return this; } public UiElement Destroy() { if ((Object)(object)GameObject != (Object)null) { Object.Destroy((Object)(object)GameObject); } return this; } public UiElement DestroyImmediate() { if ((Object)(object)GameObject != (Object)null) { Object.DestroyImmediate((Object)(object)GameObject); } return this; } } internal sealed class NativeUiTemplateSet { public Button Button; public TMP_Text Label; public TMP_Text HeaderLabel; public TMP_Text ButtonLabel; public TMP_Text ToggleLabel; public TMP_Text SliderLabel; public TMP_Text InputText; public TMP_Text InputPlaceholder; public TMP_InputField InputField; public Toggle Toggle; public MySliderUI Slider; public Scrollbar Scrollbar; public Image Background; public Shadow Shadow; public GameObject Panel; } internal sealed class ScrollViewport { public GameObject Root; public RectTransform ViewportRect; public RectTransform ContentRect; public ScrollRect ScrollRect; public Scrollbar Scrollbar; } internal sealed class GridTrackRow { public GameObject GameObject { get; } public RectTransform[] Tracks { get; } public GridTrackRow(GameObject gameObject, RectTransform[] tracks) { GameObject = gameObject; Tracks = tracks; } } internal static class NativeUiTemplates { public static NativeUiTemplateSet Current => NativeUiBackend.Defaults; public static void CaptureScene(bool overwriteExisting = false) { NativeUiBackend.CaptureSceneDefaults(overwriteExisting); } public static void CaptureFrom(Transform root, bool overwriteExisting = false) { NativeUiBackend.CaptureDefaultsFrom(root, overwriteExisting); } } internal static class UiStyles { public static void ApplyText(TMP_Text target, TMP_Text template = null) { NativeUiBackend.ApplyTextStyle(target, template); } public static void SetText(TMP_Text target, string text, bool removeLocalization = true) { NativeUiBackend.SetText(target, text, removeLocalization); } public static void SetButtonColors(Button button, Color imageColor, Color shadowColor) { //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) NativeUiBackend.SetButtonColors(button, imageColor, shadowColor); } public static Image CopyImage(Image template, GameObject target) { return NativeUiBackend.CopyImage(template, target); } public static Shadow CopyShadow(Shadow template, GameObject target) { return NativeUiBackend.CopyShadow(template, target); } public static void SetTextMetrics(TMP_Text text, float fontSize, TextAlignmentOptions alignment = 513, bool autoSize = false, float minFontSize = 10f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) NativeUiBackend.SetTextMetrics(text, fontSize, alignment, autoSize, minFontSize); } public static void SetInputTextStyle(TMP_InputField input, float fontSize, bool autoSize = false, float minFontSize = 10f) { NativeUiBackend.SetInputTextStyle(input, fontSize, (TextAlignmentOptions)4097, autoSize, minFontSize); } } internal static class UiLayout { public static VerticalLayoutGroup SetVertical(GameObject gameObject, RectOffset padding = null, float spacing = 0f, bool childControlWidth = true, bool childControlHeight = true, bool childForceExpandWidth = true, bool childForceExpandHeight = false) { return NativeUiBackend.SetVerticalLayout(gameObject, padding, spacing, childControlWidth, childControlHeight, childForceExpandWidth, childForceExpandHeight); } public static void SetRect(Component component, Vector2? anchorMin = null, Vector2? anchorMax = null, Vector2? pivot = null, Vector2? anchoredPosition = null, Vector2? sizeDelta = null, Vector3? scale = null) { NativeUiBackend.SetRect(component, anchoredPosition, sizeDelta, anchorMin, anchorMax, pivot, scale); } public static LayoutElement SetLayout(GameObject gameObject, float? preferredWidth = null, float? preferredHeight = null, float? flexibleWidth = null, float? flexibleHeight = null, float? minWidth = null, float? minHeight = null) { return NativeUiBackend.SetLayout(gameObject, preferredWidth, preferredHeight, flexibleWidth, flexibleHeight, minWidth, minHeight); } public static void SetFixedSize(GameObject gameObject, float? preferredWidth = null, float? preferredHeight = null, float? flexibleWidth = null, float? flexibleHeight = null) { NativeUiBackend.SetFixedLayoutSize(gameObject, preferredWidth, preferredHeight, flexibleWidth, flexibleHeight); } public static void Stretch(GameObject gameObject) { NativeUiBackend.Stretch(gameObject); } public static void LayoutGridTracks(GridTrackRow row, float spacing, float[] trackWidths) { NativeUiBackend.LayoutGridTracks(row, spacing, null, trackWidths); } public static void StabilizeClonedControl(GameObject gameObject) { NativeUiBackend.StabilizeClonedControl(gameObject); } public static void SetCanvasGroups(Transform root, float alpha, bool interactable, bool blocksRaycasts) { NativeUiBackend.SetCanvasGroups(root, alpha, interactable, blocksRaycasts); } public static void ActivatePathToRoot(Transform start, Transform root) { NativeUiBackend.ActivatePathToRoot(start, root); } public static void SetChildrenActive(Transform parent, bool active, string skipNameContains = null) { NativeUiBackend.SetChildrenActive(parent, active, skipNameContains); } } internal static class NativeUiFactory { public static UiElement Object(string name, Transform parent = null) { return NativeUiBackend.Create(name, parent); } public static TMP_Text Label(Transform parent, string text, string name = "Label", TMP_Text template = null) { return NativeUiBackend.CreatePlainLabel(parent, text, name, template); } public static TMP_InputField Input(Transform parent, string text = "", string placeholder = "", string name = "Input Field", UnityAction<string> onValueChanged = null) { TMP_InputField val = NativeUiBackend.CloneInputField(NativeUiTemplates.Current.InputField, parent, name, text, placeholder); if ((Object)(object)val != (Object)null && (Delegate)(object)onValueChanged != (Delegate)null) { ((UnityEvent<string>)(object)val.onValueChanged).AddListener(onValueChanged); } return val; } public static TMP_InputField InputFromTemplate(TMP_InputField template, Transform parent, string text = null, string placeholder = null, string name = "Input Field", int? siblingIndex