Decompiled source of PEAKLobbyBrowser v1.1.1

plugins/PEAKLobbyBrowser.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using PEAKLib.UI;
using PEAKLib.UI.Elements;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PEAKLobbyBrowser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("PEAKLobbyBrowser")]
[assembly: AssemblyTitle("LobbyBrowser")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PEAKLobbyBrowser
{
	public enum LobbyVisibility
	{
		Public,
		FriendsOnly,
		Private
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("PEAKLobbyBrowser", "PEAK Lobby Browser", "1.1.0")]
	public class PEAKLobbyBrowser : BaseUnityPlugin
	{
		public struct LobbyDetails
		{
			public CSteamID LobbyID;

			public string HostName;

			public int MemberCount;

			public int MaxMembers;

			public string LobbyName;

			public string Language;

			public string Description;

			public string ModpackId;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__31_4;

			public static Func<LobbyDetails, bool> <>9__32_0;

			public static Func<LobbyDetails, bool> <>9__33_0;

			public static UnityAction <>9__37_2;

			internal void <CreateLobbyBrowserPage>b__31_4()
			{
				((MenuWindow)lobbyBrowserPage).Hide();
			}

			internal bool <PopulateLobbyPage>b__32_0(LobbyDetails lobby)
			{
				return (lobby.LobbyName != null && lobby.LobbyName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.HostName != null && lobby.HostName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.Language != null && lobby.Language.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.ModpackId != null && lobby.ModpackId.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
			}

			internal bool <GoToNextPage>b__33_0(LobbyDetails lobby)
			{
				return (lobby.LobbyName != null && lobby.LobbyName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.HostName != null && lobby.HostName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
			}

			internal void <CreateLobbySettingsPage>b__37_2()
			{
				((MenuWindow)lobbySettingsPage).Hide();
			}
		}

		[CompilerGenerated]
		private sealed class <ModifyLobbyBrowserButton>d__30 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject buttonObject;

			public PEAKLobbyBrowser <>4__this;

			private RectTransform <buttonRect>5__1;

			private TextMeshProUGUI <buttonText>5__2;

			private Button <buttonComponent>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ModifyLobbyBrowserButton>d__30(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<buttonRect>5__1 = null;
				<buttonText>5__2 = null;
				<buttonComponent>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_0075: 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_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Object)buttonObject).name = "Button_LobbyBrowser";
					<buttonRect>5__1 = buttonObject.GetComponent<RectTransform>();
					if ((Object)(object)<buttonRect>5__1 != (Object)null)
					{
						RectTransform obj = <buttonRect>5__1;
						obj.anchoredPosition += new Vector2(-20f, 130f);
					}
					<buttonText>5__2 = buttonObject.GetComponentInChildren<TextMeshProUGUI>();
					if ((Object)(object)<buttonText>5__2 != (Object)null)
					{
						((TMP_Text)<buttonText>5__2).text = "LOBBY BROWSER";
					}
					<buttonComponent>5__3 = buttonObject.GetComponent<Button>();
					if ((Object)(object)<buttonComponent>5__3 != (Object)null)
					{
						((UnityEventBase)<buttonComponent>5__3.onClick).RemoveAllListeners();
						((UnityEvent)<buttonComponent>5__3.onClick).AddListener((UnityAction)delegate
						{
							<>4__this.OpenLobbyBrowserPage();
						});
					}
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <ShowPageAfterCreation>d__28 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PeakCustomPage page;

			public PEAKLobbyBrowser <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ShowPageAfterCreation>d__28(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)page != (Object)null)
					{
						((MenuWindow)page).Show();
					}
					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();
			}
		}

		internal static ManualLogSource Log;

		private bool isSearchingForLobbies = false;

		private List<LobbyDetails> publicLobbies = new List<LobbyDetails>();

		private const string LobbyBrowserKey = "peak_lobby_browser_public";

		protected Callback<LobbyMatchList_t> m_LobbyMatchList;

		private static PeakCustomPage lobbyBrowserPage;

		private static PeakScrollableContent lobbyListContainer;

		private static PeakCustomPage lobbySettingsPage;

		private static PeakTextInput lobbyNameInput;

		private static PeakTextInput lobbyLanguageInput;

		private static PeakTextInput lobbyDescriptionInput;

		private static PeakTextInput modpackIdInput;

		private static PeakButton visibilityButton;

		private static LobbyVisibility currentVisibility = LobbyVisibility.Public;

		private static PeakTextInput searchInput;

		private static string currentSearchTerm = "";

		private static int currentPage = 0;

		private const int LobbiesPerPage = 5;

		private static PeakText pageInfoText;

		private static PeakMenuButton previousButton;

		private static PeakMenuButton nextButton;

		public static PEAKLobbyBrowser Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Log = Logger.CreateLogSource("PEAKLobbyBrowser");
			m_LobbyMatchList = Callback<LobbyMatchList_t>.Create((DispatchDelegate<LobbyMatchList_t>)OnLobbyMatchList);
			InitializeInGameUI();
			Log.LogInfo((object)"PEAK Lobby Browser Initialized!");
		}

		private void OnDestroy()
		{
			if (m_LobbyMatchList != null)
			{
				m_LobbyMatchList.Dispose();
			}
		}

		private void InitializeInGameUI()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			try
			{
				MenuAPI.AddToMainMenu((BuilderDelegate)delegate
				{
					LobbyBrowserMainMenuButton();
				});
				MenuAPI.AddToPauseMenu((BuilderDelegate)delegate(Transform parent)
				{
					LobbySettingsPauseMenuButton(parent);
				});
			}
			catch (Exception ex)
			{
				Log.LogFatal((object)("Could not initialize PEAKLib.UI buttons: " + ex.Message));
			}
		}

		[IteratorStateMachine(typeof(<ShowPageAfterCreation>d__28))]
		private IEnumerator ShowPageAfterCreation(PeakCustomPage page)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ShowPageAfterCreation>d__28(0)
			{
				<>4__this = this,
				page = page
			};
		}

		private void LobbyBrowserMainMenuButton()
		{
			try
			{
				GameObject val = GameObject.Find("MainMenu/Canvas/MainPage/Menu/Buttons/Button_PlaySolo");
				if ((Object)(object)val == (Object)null)
				{
					Log.LogWarning((object)"Could not find template button 'Button_PlaySolo'.");
					return;
				}
				GameObject buttonObject = Object.Instantiate<GameObject>(val, val.transform.parent);
				((MonoBehaviour)this).StartCoroutine(ModifyLobbyBrowserButton(buttonObject));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to build lobby browser menu button: " + ex.Message));
			}
		}

		[IteratorStateMachine(typeof(<ModifyLobbyBrowserButton>d__30))]
		private IEnumerator ModifyLobbyBrowserButton(GameObject buttonObject)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ModifyLobbyBrowserButton>d__30(0)
			{
				<>4__this = this,
				buttonObject = buttonObject
			};
		}

		private void CreateLobbyBrowserPage()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Expected O, but got Unknown
			//IL_038c: 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_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Expected O, but got Unknown
			if ((Object)(object)lobbyBrowserPage != (Object)null)
			{
				return;
			}
			lobbyBrowserPage = MenuAPI.CreatePageWithBackground("Lobby Browser Page");
			ElementExtensions.SetPosition<PeakText>(ElementExtensions.SetPivot<PeakText>(ElementExtensions.SetAnchorMinMax<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Public Lobbies").SetFontSize(48f), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -50f));
			searchInput = ElementExtensions.SetSize<PeakTextInput>(ElementExtensions.SetPosition<PeakTextInput>(ElementExtensions.SetPivot<PeakTextInput>(ElementExtensions.SetAnchorMinMax<PeakTextInput>(ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("SearchInput"), ((Component)lobbyBrowserPage).transform).SetPlaceholder("Search for Lobby Name, Host, Language or Modpack....."), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(-75f, -120f)), new Vector2(650f, 50f));
			ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Search"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(325f, -120f)), new Vector2(150f, 50f)).OnClick((UnityAction)delegate
			{
				currentPage = 0;
				currentSearchTerm = searchInput.InputField.text;
				PopulateLobbyPage();
			});
			lobbyListContainer = ElementExtensions.SetSize<PeakScrollableContent>(ElementExtensions.SetPosition<PeakScrollableContent>(ElementExtensions.SetPivot<PeakScrollableContent>(ElementExtensions.SetAnchorMinMax<PeakScrollableContent>(ElementExtensions.ParentTo<PeakScrollableContent>(MenuAPI.CreateScrollableContent("LobbyList"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -180f)), new Vector2(800f, 625f));
			VerticalLayoutGroup component = ((Component)lobbyListContainer.Content).GetComponent<VerticalLayoutGroup>();
			if ((Object)(object)component != (Object)null)
			{
				((HorizontalOrVerticalLayoutGroup)component).spacing = 5f;
			}
			previousButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("<< Previous"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 0f)), new Vector2(2.2f, 0f)), new Vector2(0f, 100f)).SetWidth(200f).OnClick((UnityAction)delegate
			{
				GoToPreviousPage();
			});
			nextButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Next >>"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 0f)), new Vector2(-1.2f, 0f)), new Vector2(0f, 100f)).SetWidth(200f).OnClick((UnityAction)delegate
			{
				GoToNextPage();
			});
			ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Refresh"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 0f)), new Vector2(1.1f, 0f)), new Vector2(0f, 100f)).SetWidth(200f).OnClick((UnityAction)delegate
			{
				if ((Object)(object)searchInput != (Object)null)
				{
					searchInput.InputField.text = "";
				}
				currentSearchTerm = "";
				currentPage = 0;
				RefreshLobbyList();
			});
			PeakMenuButton obj = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Close"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 0f)), new Vector2(-0.1f, 0f)), new Vector2(0f, 100f)).SetWidth(200f);
			object obj2 = <>c.<>9__31_4;
			if (obj2 == null)
			{
				UnityAction val = delegate
				{
					((MenuWindow)lobbyBrowserPage).Hide();
				};
				<>c.<>9__31_4 = val;
				obj2 = (object)val;
			}
			obj.OnClick((UnityAction)obj2);
			pageInfoText = ElementExtensions.SetPosition<PeakText>(ElementExtensions.SetPivot<PeakText>(ElementExtensions.SetAnchorMinMax<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Page 1 / 1"), ((Component)lobbyBrowserPage).transform), new Vector2(0.5f, 0f)), new Vector2(0.5f, 0f)), new Vector2(0f, 70f)).SetFontSize(24f);
		}

		private void PopulateLobbyPage()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Expected O, but got Unknown
			if ((Object)(object)lobbyListContainer == (Object)null)
			{
				return;
			}
			foreach (Transform item in (Transform)lobbyListContainer.Content)
			{
				Transform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			List<LobbyDetails> list = (string.IsNullOrWhiteSpace(currentSearchTerm) ? publicLobbies : publicLobbies.Where((LobbyDetails lobby) => (lobby.LobbyName != null && lobby.LobbyName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.HostName != null && lobby.HostName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.Language != null && lobby.Language.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.ModpackId != null && lobby.ModpackId.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0)).ToList());
			int count = list.Count;
			int num = (int)Math.Ceiling((double)count / 5.0);
			if (num == 0)
			{
				num = 1;
			}
			IEnumerable<LobbyDetails> enumerable = list.Skip(currentPage * 5).Take(5);
			if ((Object)(object)pageInfoText != (Object)null)
			{
				((TMP_Text)pageInfoText.TextMesh).text = $"Page {currentPage + 1} / {num}";
			}
			if ((Object)(object)previousButton != (Object)null)
			{
				((Selectable)previousButton.Button).interactable = currentPage > 0;
			}
			if ((Object)(object)nextButton != (Object)null)
			{
				((Selectable)nextButton.Button).interactable = currentPage < num - 1;
			}
			if (!enumerable.Any())
			{
				ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText(isSearchingForLobbies ? "Searching..." : "No matching lobbies found."), (Transform)(object)lobbyListContainer.Content).SetFontSize(28f).SetColor(Color.yellow);
				return;
			}
			foreach (LobbyDetails lobby2 in enumerable)
			{
				PeakButton val2 = ElementExtensions.ParentTo<PeakButton>(MenuAPI.CreateButton("Entry_" + lobby2.HostName), (Transform)(object)lobbyListContainer.Content).SetHeight(120f).OnClick((UnityAction)delegate
				{
					if (!string.IsNullOrEmpty(lobby2.ModpackId))
					{
						GUIUtility.systemCopyBuffer = lobby2.ModpackId;
						Log.LogInfo((object)("Copied Modpack ID to clipboard: " + lobby2.ModpackId));
					}
				});
				if ((Object)(object)val2.Text != (Object)null && (Object)(object)val2.Text.TextMesh != (Object)null)
				{
					((TMP_Text)val2.Text.TextMesh).text = "";
				}
				string text = lobby2.LobbyName + "\n<color=grey><i>" + lobby2.Description + "</i></color>";
				if (!string.IsNullOrEmpty(lobby2.ModpackId))
				{
					text = text + "\n<color=yellow>Modpack:</color> " + lobby2.ModpackId;
				}
				text += $"\n<color=orange>Host:</color> {lobby2.HostName} | <color=orange>Language:</color> {lobby2.Language} | <color=orange>Players:</color> {lobby2.MemberCount}/{lobby2.MaxMembers}";
				ElementExtensions.SetPosition<PeakText>(ElementExtensions.SetPivot<PeakText>(ElementExtensions.SetAnchorMinMax<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText(text), ((Component)val2).transform), new Vector2(0f, 0.5f)), new Vector2(0f, 0.5f)), new Vector2(20f, 0f)).SetFontSize(20f);
				ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Join"), ((Component)val2).transform), new Vector2(1f, 0.5f)), new Vector2(1f, 0.5f)), new Vector2(-20f, 0f)).SetWidth(150f).OnClick((UnityAction)delegate
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					PEAKLobbyBrowser pEAKLobbyBrowser = this;
					CSteamID lobbyID = lobby2.LobbyID;
					pEAKLobbyBrowser.AttemptToJoinLobby(((object)(CSteamID)(ref lobbyID)).ToString());
					((MenuWindow)lobbyBrowserPage).Hide();
				});
			}
		}

		private void GoToNextPage()
		{
			List<LobbyDetails> list = (string.IsNullOrWhiteSpace(currentSearchTerm) ? publicLobbies : publicLobbies.Where((LobbyDetails lobby) => (lobby.LobbyName != null && lobby.LobbyName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || (lobby.HostName != null && lobby.HostName.IndexOf(currentSearchTerm, StringComparison.OrdinalIgnoreCase) >= 0)).ToList());
			int num = (int)Math.Ceiling((double)list.Count / 5.0);
			if (currentPage < num - 1)
			{
				currentPage++;
				PopulateLobbyPage();
			}
		}

		private void GoToPreviousPage()
		{
			if (currentPage > 0)
			{
				currentPage--;
				PopulateLobbyPage();
			}
		}

		private void OpenLobbyBrowserPage()
		{
			CreateLobbyBrowserPage();
			((MonoBehaviour)this).StartCoroutine(ShowPageAfterCreation(lobbyBrowserPage));
			if ((Object)(object)searchInput != (Object)null)
			{
				searchInput.InputField.text = "";
			}
			currentSearchTerm = "";
			currentPage = 0;
			((MenuWindow)lobbyBrowserPage).Show();
			RefreshLobbyList();
		}

		private void LobbySettingsPauseMenuButton(Transform parent)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			try
			{
				ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreatePauseMenuButton("LOBBY SETTINGS"), parent).OnClick((UnityAction)delegate
				{
					OpenLobbySettingsPage();
				});
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to create lobby settings pause button: " + ex.Message));
			}
		}

		private void CreateLobbySettingsPage()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Expected O, but got Unknown
			if ((Object)(object)lobbySettingsPage != (Object)null)
			{
				return;
			}
			lobbySettingsPage = MenuAPI.CreatePageWithBackground("Lobby Settings Page");
			Canvas component = ((Component)lobbySettingsPage).GetComponent<Canvas>();
			if ((Object)(object)component != (Object)null)
			{
				component.overrideSorting = true;
				component.sortingOrder = 999;
			}
			ElementExtensions.SetPosition<PeakText>(ElementExtensions.SetPivot<PeakText>(ElementExtensions.SetAnchorMinMax<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Lobby Settings").SetFontSize(48f), ((Component)lobbySettingsPage).transform), new Vector2(0.5f, 1f)), new Vector2(0.5f, 1f)), new Vector2(0f, -50f));
			PeakScrollableContent val = ElementExtensions.SetSize<PeakScrollableContent>(ElementExtensions.SetPivot<PeakScrollableContent>(ElementExtensions.SetAnchorMinMax<PeakScrollableContent>(ElementExtensions.ParentTo<PeakScrollableContent>(MenuAPI.CreateScrollableContent("SettingsContainer"), ((Component)lobbySettingsPage).transform), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(600f, 600f));
			RectTransform content = val.Content;
			ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Lobby Name:"), (Transform)(object)content).SetFontSize(24f);
			lobbyNameInput = ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("LobbyNameInput"), (Transform)(object)content);
			lobbyNameInput.InputField.characterLimit = 40;
			ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Language:"), (Transform)(object)content).SetFontSize(24f);
			lobbyLanguageInput = ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("LobbyLanguageInput"), (Transform)(object)content);
			lobbyLanguageInput.InputField.characterLimit = 10;
			ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Description:"), (Transform)(object)content).SetFontSize(22f);
			lobbyDescriptionInput = ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("LobbyDescriptionInput"), (Transform)(object)content);
			lobbyDescriptionInput.InputField.characterLimit = 60;
			ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Modpack:"), (Transform)(object)content).SetFontSize(18f);
			modpackIdInput = ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("ModpackIdInput"), (Transform)(object)content);
			modpackIdInput.InputField.characterLimit = 44;
			visibilityButton = ElementExtensions.ParentTo<PeakButton>(MenuAPI.CreateButton("Visibility: Public"), (Transform)(object)content).SetHeight(50f).OnClick((UnityAction)delegate
			{
				CycleLobbyVisibility();
			});
			ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Apply Settings"), ((Component)lobbySettingsPage).transform), new Vector2(0.5f, 0f)), new Vector2(1.1f, 0f)), new Vector2(0f, 100f)).SetWidth(200f).OnClick((UnityAction)delegate
			{
				ApplyLobbySettings();
			});
			PeakMenuButton obj = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetPivot<PeakMenuButton>(ElementExtensions.SetAnchorMinMax<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("Close"), ((Component)lobbySettingsPage).transform), new Vector2(0.5f, 0f)), new Vector2(-0.1f, 0f)), new Vector2(0f, 100f)).SetWidth(200f);
			object obj2 = <>c.<>9__37_2;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					((MenuWindow)lobbySettingsPage).Hide();
				};
				<>c.<>9__37_2 = val2;
				obj2 = (object)val2;
			}
			obj.OnClick((UnityAction)obj2);
		}

		private void CycleLobbyVisibility()
		{
			currentVisibility = (LobbyVisibility)((int)(currentVisibility + 1) % 3);
			UpdateVisibilityButtonText();
		}

		private void UpdateVisibilityButtonText()
		{
			if ((Object)(object)visibilityButton != (Object)null && (Object)(object)visibilityButton.Text != (Object)null && (Object)(object)visibilityButton.Text.TextMesh != (Object)null)
			{
				((TMP_Text)visibilityButton.Text.TextMesh).text = $"Visibility: {currentVisibility}";
			}
		}

		private void OpenLobbySettingsPage()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			CreateLobbySettingsPage();
			((MonoBehaviour)this).StartCoroutine(ShowPageAfterCreation(lobbySettingsPage));
			CSteamID val = default(CSteamID);
			if (GameHandler.GetService<SteamLobbyHandler>().InSteamLobby(ref val))
			{
				lobbyNameInput.InputField.text = SteamMatchmaking.GetLobbyData(val, "lobbyName");
				lobbyLanguageInput.InputField.text = SteamMatchmaking.GetLobbyData(val, "language");
				lobbyDescriptionInput.InputField.text = SteamMatchmaking.GetLobbyData(val, "description");
				modpackIdInput.InputField.text = SteamMatchmaking.GetLobbyData(val, "modpackId");
				if (string.IsNullOrWhiteSpace(lobbyLanguageInput.InputField.text))
				{
					string text = SteamApps.GetCurrentGameLanguage();
					if (!string.IsNullOrEmpty(text))
					{
						text = char.ToUpper(text[0]) + text.Substring(1);
					}
					lobbyLanguageInput.InputField.text = text;
				}
				if (SteamMatchmaking.GetLobbyData(val, "peak_lobby_browser_public") == "true")
				{
					currentVisibility = LobbyVisibility.Public;
				}
				else
				{
					currentVisibility = LobbyVisibility.Public;
				}
				UpdateVisibilityButtonText();
			}
			((MenuWindow)lobbySettingsPage).Show();
		}

		private void ApplyLobbySettings()
		{
			//IL_0034: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			CSteamID val = default(CSteamID);
			if (GameHandler.GetService<SteamLobbyHandler>().InSteamLobby(ref val))
			{
				Log.LogInfo((object)$"Applying new lobby settings. Visibility: {currentVisibility}");
				SteamMatchmaking.SetLobbyData(val, "hostName", SteamFriends.GetPersonaName());
				SteamMatchmaking.SetLobbyData(val, "lobbyName", lobbyNameInput.InputField.text);
				SteamMatchmaking.SetLobbyData(val, "language", lobbyLanguageInput.InputField.text);
				SteamMatchmaking.SetLobbyData(val, "description", lobbyDescriptionInput.InputField.text);
				SteamMatchmaking.SetLobbyData(val, "modpackId", modpackIdInput.InputField.text);
				switch (currentVisibility)
				{
				case LobbyVisibility.Public:
					SteamMatchmaking.SetLobbyType(val, (ELobbyType)2);
					SteamMatchmaking.SetLobbyData(val, "peak_lobby_browser_public", "true");
					break;
				case LobbyVisibility.FriendsOnly:
					SteamMatchmaking.SetLobbyType(val, (ELobbyType)1);
					SteamMatchmaking.SetLobbyData(val, "peak_lobby_browser_public", "false");
					break;
				case LobbyVisibility.Private:
					SteamMatchmaking.SetLobbyType(val, (ELobbyType)0);
					SteamMatchmaking.SetLobbyData(val, "peak_lobby_browser_public", "false");
					break;
				}
			}
			else
			{
				Log.LogWarning((object)"Cannot apply settings, not in a Steam lobby.");
			}
			((MenuWindow)lobbySettingsPage).Hide();
		}

		public void RefreshLobbyList()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!isSearchingForLobbies)
			{
				Log.LogInfo((object)"Requesting public lobby list...");
				isSearchingForLobbies = true;
				publicLobbies.Clear();
				PopulateLobbyPage();
				SteamMatchmaking.AddRequestLobbyListDistanceFilter((ELobbyDistanceFilter)3);
				SteamMatchmaking.AddRequestLobbyListStringFilter("peak_lobby_browser_public", "true", (ELobbyComparison)0);
				SteamMatchmaking.RequestLobbyList();
			}
		}

		private void OnLobbyMatchList(LobbyMatchList_t pCallback)
		{
			//IL_000b: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo((object)$"Found {pCallback.m_nLobbiesMatching} public lobbies.");
			publicLobbies.Clear();
			for (int i = 0; i < pCallback.m_nLobbiesMatching; i++)
			{
				CSteamID lobbyByIndex = SteamMatchmaking.GetLobbyByIndex(i);
				publicLobbies.Add(new LobbyDetails
				{
					LobbyID = lobbyByIndex,
					HostName = SteamMatchmaking.GetLobbyData(lobbyByIndex, "hostName"),
					MemberCount = SteamMatchmaking.GetNumLobbyMembers(lobbyByIndex),
					MaxMembers = SteamMatchmaking.GetLobbyMemberLimit(lobbyByIndex),
					LobbyName = SteamMatchmaking.GetLobbyData(lobbyByIndex, "lobbyName"),
					Language = SteamMatchmaking.GetLobbyData(lobbyByIndex, "language"),
					Description = SteamMatchmaking.GetLobbyData(lobbyByIndex, "description"),
					ModpackId = SteamMatchmaking.GetLobbyData(lobbyByIndex, "modpackId")
				});
			}
			isSearchingForLobbies = false;
			currentPage = 0;
			PopulateLobbyPage();
		}

		public void AttemptToJoinLobby(string lobbyInput)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			ulong result;
			if (string.IsNullOrWhiteSpace(lobbyInput))
			{
				Log.LogError((object)"Lobby ID field is empty.");
			}
			else if (ulong.TryParse(lobbyInput.Trim(), out result))
			{
				Log.LogInfo((object)$"Attempting to join lobby by ID: {result}");
				CSteamID val = default(CSteamID);
				((CSteamID)(ref val))..ctor(result);
				GameHandler.GetService<SteamLobbyHandler>().TryJoinLobby(val);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}