using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using SpongePEAK.Core.Logging; using SpongePEAK.Core.Patching; using SpongePEAK.Lib.Features; using SpongePEAK.Lib.Plugin; using SpongePEAK.Lib.UI; using SpongePEAK.Lobby.Features; using SpongePEAK.Lobby.Matchmaking; using SpongePEAK.Lobby.UI; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("sponge")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) sponge")] [assembly: AssemblyDescription("Public lobby browser with host-set lock codes.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ddcbf023fcb4c2065ad9b038910633cd4a3a93b0")] [assembly: AssemblyProduct("SpongePEAKLobby")] [assembly: AssemblyTitle("com.sponge.peaklobby")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SpongePEAK.Lobby { [BepInPlugin("com.sponge.peaklobby", "SpongePEAKLobby", "1.0.0")] public sealed class LobbyPlugin : SpongePlugin { public const string Guid = "com.sponge.peaklobby"; private FeatureRegistry _registry; private LobbyBrowserFeature _browser; private BrowserWindow _window; private ConfigEntry _key; protected override string DisplayName => "SpongePEAKLobby"; protected override void OnLoad() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown _registry = new FeatureRegistry(((BaseUnityPlugin)this).Config, ((SpongePlugin)this).Log); _key = ((BaseUnityPlugin)this).Config.Bind("Lobby", "BrowserKey", (KeyCode)287, "Opens the lobby browser."); _browser = new LobbyBrowserFeature(); _browser.Configure(((BaseUnityPlugin)this).Config); _registry.Register((ModFeature)(object)_browser); _registry.EnableAll(((SpongePlugin)this).Patches); if (((ModFeature)_browser).IsActive) { _window = new BrowserWindow(_browser, ((SpongePlugin)this).Log); MenuIntegration.AddMainMenuButton("LOBBY BROWSER", (Action)delegate { _window?.Toggle(); }); } } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (_browser != null && ((ModFeature)_browser).IsActive) { _browser.Tick(); ConfigEntry key = _key; if (Input.GetKeyDown((KeyCode)((key == null) ? 287 : ((int)key.Value)))) { _window?.Toggle(); } _window?.Tick(); } } protected override void OnUnload() { _browser?.Cleanup(); } } } namespace SpongePEAK.Lobby.UI { public sealed class BrowserWindow { private readonly LobbyBrowserFeature _feature; private readonly ModLog _log; private GameObject _root; private ModalCursorWindow _modal; private TMP_InputField _searchField; private TMP_InputField _hostField; private RectTransform _results; private ScrollRect _scroll; private TextMeshProUGUI _searchHint; private TextMeshProUGUI _status; private TextMeshProUGUI _lockState; private Toggle _listToggle; private readonly List _rows = new List(); private int _lastResultCount = -1; private bool _suppressCallbacks; public bool IsOpen { get; private set; } public BrowserWindow(LobbyBrowserFeature feature, ModLog log) { _feature = feature; _log = log; } public void Toggle() { if (IsOpen) { Close(); } else if (!((Object)(object)_root == (Object)null) || Build()) { IsOpen = true; _root.SetActive(true); ModalCursorWindow modal = _modal; if (modal != null) { modal.SetOpen(true); } _feature.Search.Search(((Object)(object)_searchField != (Object)null) ? _searchField.text : string.Empty); Refresh(force: true); } } public void Close() { if (IsOpen) { IsOpen = false; ModalCursorWindow modal = _modal; if (modal != null) { modal.SetOpen(false); } if ((Object)(object)_root != (Object)null) { _root.SetActive(false); } } } public void Tick() { if (IsOpen) { Refresh(); } } private bool Build() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) try { _root = new GameObject("SpongeUI_LobbyBrowser", new Type[3] { typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)_root); Canvas component = _root.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = 510; CanvasScaler component2 = _root.GetComponent(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; RectTransform val = NewRect("Panel", _root.transform); Vector2 anchorMin = (val.anchorMax = new Vector2(0.5f, 0.5f)); val.anchorMin = anchorMin; val.pivot = new Vector2(0.5f, 0.5f); val.sizeDelta = new Vector2(760f, 820f); val.anchoredPosition = Vector2.zero; ((Graphic)((Component)val).gameObject.AddComponent()).color = new Color(0.13f, 0.1f, 0.07f, 0.96f); Label(val, "PEAK LOBBIES", 26f, new Vector2(0f, -16f), new Color(0.98f, 0.86f, 0.55f)); _searchField = Field(val, "Search code (blank = public lobbies)", new Vector2(-220f, -60f), new Vector2(420f, 44f)); RectTransform val3 = NewRect("Find", (Transform)(object)val); anchorMin = (val3.anchorMax = new Vector2(0.5f, 1f)); val3.anchorMin = anchorMin; val3.pivot = new Vector2(0.5f, 1f); val3.sizeDelta = new Vector2(140f, 44f); val3.anchoredPosition = new Vector2(120f, -60f); PeakStyle.CreateButton("SEARCH", (Transform)(object)val3, (Action)delegate { _feature.Search.Search(((Object)(object)_searchField != (Object)null) ? _searchField.text : string.Empty); }); _searchHint = Label(val, "", 15f, new Vector2(0f, -110f), new Color(1f, 1f, 1f, 0.55f)); RectTransform val5 = NewRect("Results", (Transform)(object)val); val5.anchorMin = new Vector2(0f, 0f); val5.anchorMax = new Vector2(1f, 1f); val5.offsetMin = new Vector2(24f, 240f); val5.offsetMax = new Vector2(-24f, -140f); _results = val5; _scroll = ScrollableList.Ensure((Transform)(object)_results, _log, 3f); _status = Label(val, "", 16f, new Vector2(0f, -150f), new Color(1f, 1f, 1f, 0.7f)); BuildHostControls(val); _modal = _root.AddComponent(); _modal.SetLogger(_log); _modal.Closed = delegate { IsOpen = false; if ((Object)(object)_root != (Object)null) { _root.SetActive(false); } }; _root.SetActive(false); return true; } catch (Exception ex) { ModLog log = _log; if (log != null) { log.Exception("Could not build the lobby browser", ex); } _root = null; return false; } } private void BuildHostControls(RectTransform panel) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)Label(panel, "YOUR LOBBY", 18f, Vector2.zero, new Color(0.98f, 0.86f, 0.55f, 0.9f))).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.sizeDelta = new Vector2(400f, 28f); rectTransform.anchoredPosition = new Vector2(0f, 196f); _hostField = Field(panel, "Lock code (blank = unlocked)", Vector2.zero, new Vector2(360f, 44f)); RectTransform component = ((Component)_hostField).GetComponent(); ((Vector2)(ref val))..ctor(0.5f, 0f); component.anchorMax = val; component.anchorMin = val; component.pivot = new Vector2(0.5f, 0f); component.anchoredPosition = new Vector2(-120f, 144f); RectTransform val2 = NewRect("SetCode", (Transform)(object)panel); ((Vector2)(ref val))..ctor(0.5f, 0f); val2.anchorMax = val; val2.anchorMin = val; val2.pivot = new Vector2(0.5f, 0f); val2.sizeDelta = new Vector2(110f, 44f); val2.anchoredPosition = new Vector2(125f, 144f); PeakStyle.CreateButton("LOCK", (Transform)(object)val2, (Action)delegate { if ((Object)(object)_hostField != (Object)null && LockCode.IsValid(_hostField.text)) { _feature.SetCode(_hostField.text); Refresh(force: true); } }); RectTransform val3 = NewRect("ClearCode", (Transform)(object)panel); ((Vector2)(ref val))..ctor(0.5f, 0f); val3.anchorMax = val; val3.anchorMin = val; val3.pivot = new Vector2(0.5f, 0f); val3.sizeDelta = new Vector2(110f, 44f); val3.anchoredPosition = new Vector2(245f, 144f); PeakStyle.CreateButton("UNLOCK", (Transform)(object)val3, (Action)delegate { if ((Object)(object)_hostField != (Object)null) { _hostField.text = string.Empty; } _feature.ClearCode(); Refresh(force: true); }); RectTransform val4 = NewRect("ListToggle", (Transform)(object)panel); ((Vector2)(ref val))..ctor(0.5f, 0f); val4.anchorMax = val; val4.anchorMin = val; val4.pivot = new Vector2(0.5f, 0f); val4.sizeDelta = new Vector2(28f, 28f); val4.anchoredPosition = new Vector2(-250f, 104f); Image val5 = ((Component)val4).gameObject.AddComponent(); ((Graphic)val5).color = new Color(0.05f, 0.04f, 0.03f, 0.95f); RectTransform obj = NewRect("Check", (Transform)(object)val4); obj.anchorMin = new Vector2(0.18f, 0.18f); obj.anchorMax = new Vector2(0.82f, 0.82f); obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; Image val6 = ((Component)obj).gameObject.AddComponent(); ((Graphic)val6).color = new Color(0.98f, 0.86f, 0.55f); _listToggle = ((Component)val4).gameObject.AddComponent(); ((Selectable)_listToggle).targetGraphic = (Graphic)(object)val5; _listToggle.graphic = (Graphic)(object)val6; ((UnityEvent)(object)_listToggle.onValueChanged).AddListener((UnityAction)delegate(bool v) { if (!_suppressCallbacks) { _feature.SetListed(v); Refresh(force: true); } }); TextMeshProUGUI obj2 = Label(panel, "List my lobby publicly", 15f, Vector2.zero, Color.white); RectTransform rectTransform2 = ((TMP_Text)obj2).rectTransform; ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform2.anchorMax = val; rectTransform2.anchorMin = val; rectTransform2.pivot = new Vector2(0f, 0f); rectTransform2.sizeDelta = new Vector2(340f, 24f); rectTransform2.anchoredPosition = new Vector2(-226f, 106f); ((TMP_Text)obj2).alignment = (TextAlignmentOptions)4097; _lockState = Label(panel, "", 14f, Vector2.zero, new Color(1f, 1f, 1f, 0.6f)); RectTransform rectTransform3 = ((TMP_Text)_lockState).rectTransform; ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform3.anchorMax = val; rectTransform3.anchorMin = val; rectTransform3.pivot = new Vector2(0.5f, 0f); rectTransform3.sizeDelta = new Vector2(700f, 52f); rectTransform3.anchoredPosition = new Vector2(0f, 46f); ((TMP_Text)_lockState).alignment = (TextAlignmentOptions)258; RectTransform val7 = NewRect("Close", (Transform)(object)panel); ((Vector2)(ref val))..ctor(1f, 0f); val7.anchorMax = val; val7.anchorMin = val; val7.pivot = new Vector2(1f, 0f); val7.sizeDelta = new Vector2(130f, 34f); val7.anchoredPosition = new Vector2(-24f, 8f); PeakStyle.CreateButton("CLOSE", (Transform)(object)val7, (Action)Close); } private void Refresh(bool force = false) { LobbySearch search = _feature.Search; string text = (((Object)(object)_searchField != (Object)null) ? _searchField.text.Trim() : string.Empty); if ((Object)(object)_searchHint != (Object)null) { ((TMP_Text)_searchHint).text = ((text.Length > 0) ? "Showing only lobbies using this exact code." : "Showing public lobbies. Type a code to find a locked one."); } if ((Object)(object)_status != (Object)null) { if (search.Searching) { ((TMP_Text)_status).text = "Searching..."; } else if (search.Error.Length > 0) { ((TMP_Text)_status).text = search.Error; } else if (search.Results.Count == 0) { ((TMP_Text)_status).text = ((text.Length > 0) ? "No lobby is using that code. Check it with whoever sent it." : "No public lobbies right now."); } else { ((TMP_Text)_status).text = $"{search.Results.Count} lobby(s) found."; } } if (force || search.Results.Count != _lastResultCount) { _lastResultCount = search.Results.Count; BuildRows(search.Results); } LobbyPublisher publisher = _feature.Publisher; _suppressCallbacks = true; try { if ((Object)(object)_listToggle != (Object)null) { _listToggle.isOn = publisher.IsListed; ((Selectable)_listToggle).interactable = !publisher.IsLocked; } } finally { _suppressCallbacks = false; } if ((Object)(object)_lockState != (Object)null) { ((TMP_Text)_lockState).text = (publisher.IsLocked ? "Locked. Hidden from lobby browsers. Anyone with the code can find it, and your Steam friends can still join from their friends list as usual." : (publisher.IsListed ? "Visible to anyone browsing lobbies." : "Not listed. Friends can still join through Steam.")); } } private void BuildRows(IReadOnlyList entries) { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown for (int i = 0; i < entries.Count; i++) { GameObject val = ((i < _rows.Count) ? _rows[i] : CreateRow()); if ((Object)(object)val == (Object)null) { continue; } LobbyEntry entry = entries[i]; val.SetActive(true); TextMeshProUGUI componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { string arg = ((entry.Name.Length > 0) ? entry.Name : "PEAK lobby"); ((TMP_Text)componentInChildren).text = $"{arg} {entry.Players}/{entry.Capacity}" + ((entry.Scene.Length > 0) ? (" (" + entry.Scene + ")") : "") + ""; ((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097; ((TMP_Text)componentInChildren).fontSize = 17f; } Button componentInChildren2 = val.GetComponentInChildren