Decompiled source of LobbyListRemake v1.0.0

LobbyList Remake.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using LobbyList.Behavior;
using LobbyList.Pojo;
using LobbyList.Properties;
using LobbyList.Util;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LobbyList:Remake")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("P R C")]
[assembly: AssemblyProduct("LobbyList:Remake")]
[assembly: AssemblyCopyright("Copyright © P R C 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("13de07c5-3242-47c8-b356-53ad9ec6ea32")]
[assembly: AssemblyFileVersion("0.4.8.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LobbyList
{
	public class ChatPatch
	{
		[HarmonyPatch(typeof(PlayerChatManager), "PostMessage")]
		[HarmonyPrefix]
		public static bool ChatPrePatch(ref PlayerChatManager __instance)
		{
			string currentValue = __instance.m_currentValue;
			string text = CmdParser.parseCmd(currentValue);
			if (text == null)
			{
				return true;
			}
			if (text.Equals("p"))
			{
				__instance.m_currentValue = (DoCreate(currentValue) ? LocalText.Publishing : LocalText.OnlyHostCanPublish);
			}
			else if (text.Equals("c"))
			{
				Common.CleanUp();
				__instance.m_currentValue = LocalText.LobbyCancelled;
			}
			return true;
		}

		public static bool DoCreate(string message)
		{
			string error;
			return LobbyPublisher.Publish(CmdParser.getArgument(message, 1), out error);
		}
	}
	public class Common
	{
		public static string Uuid;

		public static readonly string BASE_HOST = "192.140.180.104:8080";

		public static readonly string BASE_URL = "http://" + BASE_HOST + "/user/lobby/";

		public static Timer TtlTimer;

		public static PlayerChatManager playerChatManager;

		public static void StartTTL()
		{
			TtlTimer = new Timer(delegate
			{
				if (Uuid == null || Uuid.Equals(""))
				{
					TtlTimer.Dispose();
				}
				HttpUtil.Get(BASE_URL + "ttl?uuid=" + Uuid, delegate(string result)
				{
					if (result == null || result.Equals("") || !bool.Parse(result))
					{
						CleanUp();
					}
				});
			}, null, 10000, 10000);
		}

		public static void CleanUp()
		{
			if (Uuid != null)
			{
				HttpUtil.Get(BASE_URL + "CancelLobby?uuid=" + Uuid);
				MainPlugin.Logger.LogMessage((object)LocalText.PreviousUuidCancelled);
				Uuid = null;
			}
			if (TtlTimer != null)
			{
				TtlTimer.Dispose();
				TtlTimer = null;
			}
		}

		public static void CancelLobbyByCurrentLobbyId(string reason)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			try
			{
				if (!SNet.IsInLobby)
				{
					return;
				}
				SNet_Lobby lobby = SNet.Lobby;
				if (((lobby != null) ? lobby.Identifier : null) == null)
				{
					return;
				}
				string lobbyId = SNet.Lobby.Identifier.ID.ToString();
				if (string.IsNullOrWhiteSpace(lobbyId))
				{
					return;
				}
				HttpUtil.Get(BASE_URL + "CancelLobbyByLobbyId?lobbyId=" + lobbyId, delegate(string result)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Expected O, but got Unknown
					ManualLogSource logger2 = MainPlugin.Logger;
					if (logger2 != null)
					{
						bool flag2 = default(bool);
						BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(69, 3, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: requested lobby list cleanup by lobbyId=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(lobbyId);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", reason=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(reason);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", result=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(result);
						}
						logger2.LogMessage(val2);
					}
				});
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: failed to cleanup lobby list by lobby id: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val);
				}
			}
		}

		public static void tip(string msg)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: Expected O, but got Unknown
			string data = LocalText.SystemMessagePrefix + msg;
			pChatMessage val = new pChatMessage
			{
				fromPlayer = new pPlayer
				{
					IsBot = false,
					lookup = SNet.LocalPlayer.Lookup
				},
				toPlayer = default(pPlayer),
				message = new pString50
				{
					m_data = data,
					data = data
				}
			};
			playerChatManager.DoSendChatMessage(val);
		}
	}
	internal static class CurrentExpeditionTracker
	{
		private static readonly Dictionary<uint, string> RundownIconShortNamesByLayout = new Dictionary<uint, string>();

		private static readonly Dictionary<uint, string> RundownFullNamesByLayout = new Dictionary<uint, string>();

		public static string ExpeditionName { get; private set; } = LocalText.NoExpeditionSelected;

		public static string ExpeditionCode { get; private set; } = string.Empty;

		public static uint LevelLayoutData { get; private set; }

		private static int ExpeditionIndex { get; set; } = -1;

		public static void RefreshFromActiveExpedition()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition;
				pActiveExpedition activeExpeditionData = RundownManager.GetActiveExpeditionData();
				if (activeExpeditionData.expeditionIndex >= 0)
				{
					ExpeditionIndex = activeExpeditionData.expeditionIndex;
				}
				if (activeExpedition != null && activeExpedition.LevelLayoutData != 0)
				{
					LevelLayoutData = activeExpedition.LevelLayoutData;
				}
				object value;
				if (activeExpedition == null)
				{
					value = null;
				}
				else
				{
					DescriptiveData descriptive = activeExpedition.Descriptive;
					value = ((descriptive != null) ? descriptive.Prefix : null);
				}
				if (!string.IsNullOrWhiteSpace((string?)value))
				{
					ExpeditionName = ResolvePlayerFacingName(activeExpedition, ExpeditionIndex);
					ManualLogSource logger = MainPlugin.Logger;
					if (logger != null)
					{
						BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(59, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: active rundown prefix refreshed before publish: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ExpeditionName);
						}
						logger.LogMessage(val);
					}
				}
				else if (!string.IsNullOrWhiteSpace(ExpeditionName) && ExpeditionName != LocalText.NoExpeditionSelected)
				{
					ManualLogSource logger = MainPlugin.Logger;
					if (logger != null)
					{
						BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(55, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: using cached rundown prefix before publish: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ExpeditionName);
						}
						logger.LogMessage(val);
					}
				}
				else
				{
					ManualLogSource logger2 = MainPlugin.Logger;
					if (logger2 != null)
					{
						logger2.LogMessage((object)"LobbyList: rundown prefix is unavailable while publishing lobby.");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to refresh active expedition before publish: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}

		[HarmonyPatch(typeof(RundownManager), "SetActiveExpedition")]
		[HarmonyPostfix]
		private static void SetActiveExpeditionPostfix(pActiveExpedition expPackage, ExpeditionInTierData expTierData)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				LevelLayoutData = ((expTierData != null) ? expTierData.LevelLayoutData : 0u);
				ExpeditionCode = FormatExpeditionCode(expPackage);
				ExpeditionIndex = expPackage.expeditionIndex;
				object value;
				if (expTierData == null)
				{
					value = null;
				}
				else
				{
					DescriptiveData descriptive = expTierData.Descriptive;
					value = ((descriptive != null) ? descriptive.Prefix : null);
				}
				if (!string.IsNullOrWhiteSpace((string?)value))
				{
					ExpeditionName = ResolvePlayerFacingName(expTierData, ExpeditionIndex);
				}
				else if (!string.IsNullOrWhiteSpace(ExpeditionCode))
				{
					ExpeditionName = ExpeditionCode;
				}
				else if (LevelLayoutData != 0)
				{
					ExpeditionName = $"LevelLayout {LevelLayoutData}";
				}
				else
				{
					ExpeditionName = LocalText.NoExpeditionSelected;
				}
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: active expedition cached: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ExpeditionName);
					}
					logger.LogMessage(val);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to cache active expedition: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}

		[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "Setup")]
		[HarmonyPostfix]
		private static void ExpeditionIconSetupPostfix(CM_ExpeditionIcon_New __instance, ExpeditionInTierData data)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				uint num = ((data != null) ? data.LevelLayoutData : 0u);
				string text = ((__instance != null) ? __instance.ShortName : null);
				if (num == 0 || string.IsNullOrWhiteSpace(text))
				{
					return;
				}
				RundownIconShortNamesByLayout[num] = text;
				object obj = ((__instance != null) ? __instance.PublicName : null);
				if (obj == null)
				{
					if (data == null)
					{
						obj = null;
					}
					else
					{
						DescriptiveData descriptive = data.Descriptive;
						obj = ((descriptive != null) ? descriptive.PublicName : null);
					}
				}
				string text2 = BuildFullExpeditionName(text, (string)obj);
				if (!string.IsNullOrWhiteSpace(text2))
				{
					RundownFullNamesByLayout[num] = text2;
				}
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(51, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: cached rundown icon name: layout=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(num);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", name=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2 ?? text);
					}
					logger.LogMessage(val);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to cache rundown icon short name: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}

		private static string ResolvePlayerFacingName(ExpeditionInTierData expedition, int expeditionIndex)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			DescriptiveData val = ((expedition != null) ? expedition.Descriptive : null);
			string text = ((val != null) ? val.Prefix : null);
			if (val == null)
			{
				return text ?? string.Empty;
			}
			uint num = ((expedition != null) ? expedition.LevelLayoutData : 0u);
			if (num != 0 && RundownFullNamesByLayout.TryGetValue(num, out var value) && !string.IsNullOrWhiteSpace(value))
			{
				return value;
			}
			string activeExpeditionHeader = RundownManager.ActiveExpeditionHeader;
			if (!string.IsNullOrWhiteSpace(activeExpeditionHeader) && IsLikelyShortNameForPrefix(activeExpeditionHeader, text))
			{
				string text2 = BuildFullExpeditionName(activeExpeditionHeader, val.PublicName);
				if (!string.IsNullOrWhiteSpace(text2))
				{
					return text2;
				}
			}
			if (!string.IsNullOrWhiteSpace(text))
			{
				string text3 = ((val.SkipExpNumberInName || expeditionIndex < 0) ? text : $"{text}{expeditionIndex + 1}");
				string text4 = BuildFullExpeditionName(text3, val.PublicName);
				if (!string.IsNullOrWhiteSpace(text4))
				{
					return text4;
				}
				return text3;
			}
			try
			{
				string text5 = ((expedition != null) ? expedition.GetShortName(expeditionIndex) : null);
				if (!string.IsNullOrWhiteSpace(text5))
				{
					string text6 = BuildFullExpeditionName(text5, val.PublicName);
					return string.IsNullOrWhiteSpace(text6) ? text5 : text6;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to resolve fallback expedition short name: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
			return string.Empty;
		}

		private static bool IsLikelyShortNameForPrefix(string value, string prefix)
		{
			if (string.IsNullOrWhiteSpace(value) || string.IsNullOrWhiteSpace(prefix))
			{
				return false;
			}
			return value.StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
		}

		private static string BuildFullExpeditionName(string shortName, string publicName)
		{
			shortName = NormalizeNamePart(shortName);
			publicName = NormalizeNamePart(publicName);
			if (string.IsNullOrWhiteSpace(shortName))
			{
				return publicName ?? string.Empty;
			}
			if (string.IsNullOrWhiteSpace(publicName))
			{
				return shortName;
			}
			if (publicName.StartsWith(shortName, StringComparison.OrdinalIgnoreCase))
			{
				return publicName;
			}
			return shortName + ":" + publicName;
		}

		private static string NormalizeNamePart(string value)
		{
			if (string.IsNullOrWhiteSpace(value))
			{
				return string.Empty;
			}
			return value.Trim().Trim('"', '\'', ' ', '\t');
		}

		private static string FormatExpeditionCode(pActiveExpedition expPackage)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)expPackage.tier == 99 || expPackage.expeditionIndex < 0)
			{
				return string.Empty;
			}
			string value = ((object)expPackage.tier/*cast due to .constrained prefix*/).ToString().Replace("Tier", string.Empty);
			return $"{value}{expPackage.expeditionIndex + 1}";
		}
	}
	internal static class GameStateChangePatch
	{
		[HarmonyPatch(typeof(GameStateManager), "ChangeState")]
		[HarmonyPrefix]
		private static void ChangeStatePrefix(eGameStateName nextState)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CancelPublishedLobbyForState(nextState, "ChangeState");
		}

		[HarmonyPatch(typeof(GameStateManager), "DoChangeState")]
		[HarmonyPrefix]
		private static void DoChangeStatePrefix(eGameStateName nextState)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CancelPublishedLobbyForState(nextState, "DoChangeState");
		}

		private static void CancelPublishedLobbyForState(eGameStateName nextState, string source)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (((int)nextState != 6 && (int)nextState != 7 && (int)nextState != 8 && (int)nextState != 9 && (int)nextState != 10) || string.IsNullOrWhiteSpace(Common.Uuid))
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(44, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(source);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eGameStateName>(nextState);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", cancelling published lobby.");
					}
					logger.LogMessage(val);
				}
				Common.CleanUp();
			}
			catch (Exception ex)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to cancel published lobby on state change: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}
	}
	internal static class LoadoutPagePatch
	{
		private const float ButtonSpacing = 48f;

		private const float FixedButtonXRatio = 0.106f;

		private const float FixedButtonHorizontalOffset = 15f;

		private const float FixedButtonVerticalOffset = -5f;

		private const float FixedButtonBottomMarginRatio = 0.031f;

		private const float FixedButtonMinBottomMargin = 32f;

		private const float SideMargin = 160f;

		private const float ButtonScale = 0.85f;

		private const float ButtonTextWidth = 240f;

		private static GameObject _publishButtonObject;

		private static GameObject _cancelButtonObject;

		private static CM_PageLoadout _activePage;

		private static Transform _buttonParent;

		private static float _buttonAnchorZ;

		private static bool _loggedButtonPositions;

		[HarmonyPatch(typeof(CM_PageLoadout), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnablePostfix(CM_PageLoadout __instance)
		{
			_activePage = __instance;
			EnsureLobbyPublishButtons(__instance);
		}

		[HarmonyPatch(typeof(CM_PageLoadout), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisablePostfix(CM_PageLoadout __instance)
		{
			if ((Object)(object)_activePage == (Object)(object)__instance)
			{
				_activePage = null;
			}
			SetClonedButtonVisible(_publishButtonObject, visible: false);
			SetClonedButtonVisible(_cancelButtonObject, visible: false);
		}

		public static void RefreshLobbyPublishButtonText()
		{
			if (!((Object)(object)_activePage == (Object)null))
			{
				ObservePageLanguage(_activePage);
				PositionButtonsAtScreenBottom();
				SetClonedButtonVisible(_publishButtonObject, visible: true);
				SetClonedButtonVisible(_cancelButtonObject, visible: true);
				ApplyButtonText(_publishButtonObject, LocalText.PublishLobby);
				ApplyButtonText(_cancelButtonObject, LocalText.ClosePublicLobby);
			}
		}

		private static void EnsureLobbyPublishButtons(CM_PageLoadout page)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)page == (Object)null)
			{
				return;
			}
			ObservePageLanguage(page);
			if ((Object)(object)_publishButtonObject != (Object)null && (Object)(object)_cancelButtonObject != (Object)null)
			{
				RefreshLobbyPublishButtonText();
				return;
			}
			CM_Item val = FindButtonTemplate(page);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					logger.LogError((object)"LobbyList: unable to find loadout button template.");
				}
			}
			else
			{
				Transform parent = (_buttonParent = ((Component)val).transform.parent);
				_buttonAnchorZ = ((Component)val).transform.localPosition.z;
				GetBottomButtonPositions(out var publishPosition, out var cancelPosition);
				_publishButtonObject = CreateButton(val, parent, "LobbyList_PublishLobbyButton", publishPosition, LocalText.PublishLobby, PublishLobby);
				_cancelButtonObject = CreateButton(val, parent, "LobbyList_CancelPublishedLobbyButton", cancelPosition, LocalText.ClosePublicLobby, CancelPublishedLobby);
				LogButtonPositions("created");
			}
		}

		private static CM_Item FindButtonTemplate(CM_PageLoadout page)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			CM_Item[] array = Il2CppArrayBase<CM_Item>.op_Implicit(((Component)page).GetComponentsInChildren<CM_Item>(true));
			CM_Item val = null;
			CM_Item val2 = null;
			CM_Item val3 = null;
			float num = float.MinValue;
			CM_Item[] array2 = array;
			foreach (CM_Item val4 in array2)
			{
				if (!((Object)(object)val4 == (Object)null) && !IsLobbyListButton(((Component)val4).transform))
				{
					GameObject gameObject = ((Component)val4).gameObject;
					string text = ((gameObject != null) ? ((Object)gameObject).name : null) ?? string.Empty;
					Transform parent = ((Component)val4).transform.parent;
					string text2 = ((parent != null) ? ((Object)parent).name : null) ?? string.Empty;
					if (IsStartButtonCandidate(text + " " + text2))
					{
						val = val4;
					}
					if (text.IndexOf("discord", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("copy", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("lobby", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("id", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						val2 = val4;
					}
					float x = ((Component)val4).transform.localPosition.x;
					if (x > num)
					{
						num = x;
						val3 = val4;
					}
				}
			}
			CM_Item val5 = val ?? val2 ?? val3;
			ManualLogSource logger = MainPlugin.Logger;
			if (logger != null)
			{
				bool flag = default(bool);
				BepInExMessageLogInterpolatedStringHandler val6 = new BepInExMessageLogInterpolatedStringHandler(62, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("LobbyList: selected loadout button template=");
					object obj;
					if (val5 == null)
					{
						obj = null;
					}
					else
					{
						GameObject gameObject2 = ((Component)val5).gameObject;
						obj = ((gameObject2 != null) ? ((Object)gameObject2).name : null);
					}
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>((string)obj);
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", parent=");
					object obj2;
					if (val5 == null)
					{
						obj2 = null;
					}
					else
					{
						Transform parent2 = ((Component)val5).transform.parent;
						obj2 = ((parent2 != null) ? ((Object)parent2).name : null);
					}
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>((string)obj2);
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(", local=");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Vector3?>((val5 != null) ? new Vector3?(((Component)val5).transform.localPosition) : ((Vector3?)null));
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(".");
				}
				logger.LogMessage(val6);
			}
			return val5;
		}

		private static bool IsStartButtonCandidate(string text)
		{
			if (string.IsNullOrWhiteSpace(text))
			{
				return false;
			}
			if (text.IndexOf("start", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("ready", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("drop", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("elevator", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("launch", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("expedition", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return text.IndexOf("rundown", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return true;
		}

		private static void PositionButtonsAtScreenBottom()
		{
			//IL_002e: 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)_publishButtonObject == (Object)null) && !((Object)(object)_cancelButtonObject == (Object)null))
			{
				GetBottomButtonPositions(out var publishPosition, out var cancelPosition);
				_publishButtonObject.transform.localPosition = publishPosition;
				_cancelButtonObject.transform.localPosition = cancelPosition;
				if (!_loggedButtonPositions)
				{
					LogButtonPositions("positioned");
					_loggedButtonPositions = true;
				}
			}
		}

		private static void GetBottomButtonPositions(out Vector3 publishPosition, out Vector3 cancelPosition)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(640f, (float)Screen.width * 0.5f);
			float num2 = Mathf.Max(360f, (float)Screen.height * 0.5f);
			float num3 = Mathf.Max(32f, (float)Screen.height * 0.031f);
			float num4 = num * 0.106f;
			float num5 = 0f - num2 + num3;
			num4 = Mathf.Clamp(num4, 0f - num + 160f, num - 160f);
			num4 = Mathf.Clamp(num4 + 15f, 0f - num + 160f, num - 160f);
			num5 = Mathf.Clamp(num5 + -5f, 0f - num2 + 36f, num2 - 120f);
			float num6 = Mathf.Clamp(num5 + 48f, 0f - num2 + 36f, num2 - 72f);
			publishPosition = new Vector3(num4, num6, _buttonAnchorZ);
			cancelPosition = new Vector3(num4, num5, _buttonAnchorZ);
		}

		private static void LogButtonPositions(string stage)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = MainPlugin.Logger;
			if (logger == null)
			{
				return;
			}
			bool flag = default(bool);
			BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(73, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: loadout publish buttons ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(stage);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; parent=");
				GameObject publishButtonObject = _publishButtonObject;
				object obj;
				if (publishButtonObject == null)
				{
					obj = null;
				}
				else
				{
					Transform parent = publishButtonObject.transform.parent;
					obj = ((parent != null) ? ((Object)parent).name : null);
				}
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((string)obj);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; publishLocal=");
				GameObject publishButtonObject2 = _publishButtonObject;
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3?>((publishButtonObject2 != null) ? new Vector3?(publishButtonObject2.transform.localPosition) : ((Vector3?)null));
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; cancelLocal=");
				GameObject cancelButtonObject = _cancelButtonObject;
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3?>((cancelButtonObject != null) ? new Vector3?(cancelButtonObject.transform.localPosition) : ((Vector3?)null));
			}
			logger.LogMessage(val);
		}

		private static void SetClonedButtonVisible(GameObject buttonObject, bool visible)
		{
			if ((Object)(object)buttonObject != (Object)null)
			{
				buttonObject.SetActive(visible);
			}
		}

		private static GameObject CreateButton(CM_Item template, Transform parent, string name, Vector3 localPosition, string text, Action<int> callback)
		{
			//IL_001a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent);
			((Object)val).name = name;
			val.transform.localPosition = localPosition;
			val.transform.localRotation = ((Component)template).transform.localRotation;
			val.transform.localScale = ((Component)template).transform.localScale * 0.85f;
			val.SetActive(true);
			CM_Item component = val.GetComponent<CM_Item>();
			if ((Object)(object)component != (Object)null)
			{
				ApplyButtonText(val, text);
				component.OnBtnPressCallback = null;
				component.m_onBtnPress = new UnityEvent();
				component.OnBtnPressCallback += Action<int>.op_Implicit(callback);
				component.SetButtonEnabled(true);
			}
			else
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: loadout button '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' has no CM_Item.");
					}
					logger.LogError(val2);
				}
			}
			return val;
		}

		private static void ApplyButtonText(GameObject buttonObject, string text)
		{
			//IL_00ab: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)buttonObject == (Object)null)
			{
				return;
			}
			CM_Item component = buttonObject.GetComponent<CM_Item>();
			if (component != null)
			{
				component.SetText(text);
			}
			foreach (TextMeshPro componentsInChild in buttonObject.GetComponentsInChildren<TextMeshPro>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null))
				{
					((TMP_Text)componentsInChild).text = text;
					((TMP_Text)componentsInChild).enableWordWrapping = false;
					((TMP_Text)componentsInChild).enableAutoSizing = true;
					((TMP_Text)componentsInChild).fontSizeMin = (LocalText.UseChinese ? 14f : 13f);
					((TMP_Text)componentsInChild).fontSizeMax = (LocalText.UseChinese ? 20f : 18f);
					((TMP_Text)componentsInChild).overflowMode = (TextOverflowModes)0;
					((TMP_Text)componentsInChild).alignment = (TextAlignmentOptions)514;
					RectTransform component2 = ((Component)componentsInChild).GetComponent<RectTransform>();
					if ((Object)(object)component2 != (Object)null && component2.sizeDelta.x < 240f)
					{
						component2.sizeDelta = new Vector2(240f, component2.sizeDelta.y);
					}
				}
			}
		}

		private static void ObservePageLanguage(CM_PageLoadout page)
		{
			List<TextMeshPro> list = new List<TextMeshPro>();
			foreach (TextMeshPro componentsInChild in ((Component)page).GetComponentsInChildren<TextMeshPro>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null) && !IsLobbyListButton(componentsInChild.transform))
				{
					list.Add(componentsInChild);
				}
			}
			LocalText.ObserveGameTexts(list, (TextMeshPro label) => ((TMP_Text)label).text);
		}

		private static bool IsLobbyListButton(Transform transform)
		{
			if (!((Object)(object)_publishButtonObject != (Object)null) || !((Object)(object)transform != (Object)null) || !transform.IsChildOf(_publishButtonObject.transform))
			{
				if ((Object)(object)_cancelButtonObject != (Object)null && (Object)(object)transform != (Object)null)
				{
					return transform.IsChildOf(_cancelButtonObject.transform);
				}
				return false;
			}
			return true;
		}

		private static void PublishLobby(int unused)
		{
			ChatMsgBehaviour.Message = (LobbyPublisher.Publish(null, out var _) ? LocalText.Publishing : LocalText.OnlyHostCanPublish);
		}

		private static void CancelPublishedLobby(int unused)
		{
			Common.CleanUp();
			ChatMsgBehaviour.Message = LocalText.LobbyCancelled;
		}
	}
	internal static class LobbyDirectoryClient
	{
		public static void FetchLobbies(Action<List<PublishedLobby>> onSuccess, Action<string> onFailure)
		{
			HttpUtil.Get(Common.BASE_URL + "ListLobby", delegate(string result)
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Expected O, but got Unknown
				if (string.IsNullOrWhiteSpace(result))
				{
					onFailure?.Invoke("server returned an empty lobby list");
					return;
				}
				try
				{
					List<PublishedLobby> obj = ParseLobbyList(result);
					onSuccess?.Invoke(obj);
				}
				catch (Exception ex)
				{
					ManualLogSource logger = MainPlugin.Logger;
					if (logger != null)
					{
						bool flag = default(bool);
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: failed to parse lobby list: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						logger.LogError(val);
					}
					onFailure?.Invoke(ex.Message);
				}
			});
		}

		private static List<PublishedLobby> ParseLobbyList(string raw)
		{
			string text = raw.Trim();
			if (text.StartsWith("{", StringComparison.Ordinal))
			{
				using (JsonDocument jsonDocument = JsonDocument.Parse(text))
				{
					JsonElement rootElement = jsonDocument.RootElement;
					if (rootElement.TryGetProperty("data", out var value))
					{
						return ParseJsonArray(value);
					}
					if (rootElement.TryGetProperty("lobbies", out var value2))
					{
						return ParseJsonArray(value2);
					}
					return new List<PublishedLobby>();
				}
			}
			if (text.StartsWith("[", StringComparison.Ordinal))
			{
				using (JsonDocument jsonDocument2 = JsonDocument.Parse(text))
				{
					return ParseJsonArray(jsonDocument2.RootElement);
				}
			}
			return ParseLegacyLines(text);
		}

		private static List<PublishedLobby> ParseJsonArray(JsonElement array)
		{
			List<PublishedLobby> list = new List<PublishedLobby>();
			if (array.ValueKind != JsonValueKind.Array)
			{
				return list;
			}
			foreach (JsonElement item in array.EnumerateArray())
			{
				string lobbyId = ReadString(item, "lobbyId", "lobbyID", "id", "roomCode", "code");
				string text = ReadString(item, "name", "lobbyName", "gameName");
				string host = ReadString(item, "creatorName", "host", "hostName", "owner");
				string expeditionName = ReadString(item, "expeditionName", "expedition", "levelName", "rundown");
				int members = ReadInt(item, "amountOfMember", "memberCount", "players", "count");
				int maxMembers = ReadInt(item, "maxMembers", "maxPlayers", "capacity");
				if (string.IsNullOrWhiteSpace(text))
				{
					text = LocalText.DefaultListedLobbyName(host);
				}
				list.Add(new PublishedLobby(text, host, expeditionName, FormatPlayers(members, maxMembers), lobbyId));
			}
			return list;
		}

		private static List<PublishedLobby> ParseLegacyLines(string text)
		{
			List<PublishedLobby> list = new List<PublishedLobby>();
			string[] array = text.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split('|');
				if (array2.Length >= 4)
				{
					list.Add(new PublishedLobby(array2[1], (array2.Length > 2) ? array2[2] : string.Empty, (array2.Length > 5) ? array2[5] : string.Empty, (array2.Length > 3) ? array2[3] : "?/4", array2[0]));
				}
			}
			return list;
		}

		private static string ReadString(JsonElement element, params string[] names)
		{
			foreach (string propertyName in names)
			{
				if (element.TryGetProperty(propertyName, out var value))
				{
					if (value.ValueKind == JsonValueKind.String)
					{
						return value.GetString();
					}
					if (value.ValueKind == JsonValueKind.Number || value.ValueKind == JsonValueKind.True || value.ValueKind == JsonValueKind.False)
					{
						return value.ToString();
					}
				}
			}
			return string.Empty;
		}

		private static int ReadInt(JsonElement element, params string[] names)
		{
			foreach (string propertyName in names)
			{
				if (element.TryGetProperty(propertyName, out var value))
				{
					if (value.ValueKind == JsonValueKind.Number && value.TryGetInt32(out var value2))
					{
						return value2;
					}
					if (value.ValueKind == JsonValueKind.String && int.TryParse(value.GetString(), out value2))
					{
						return value2;
					}
				}
			}
			return 0;
		}

		private static string FormatPlayers(int members, int maxMembers)
		{
			if (members <= 0)
			{
				return "?/4";
			}
			return $"{members}/{((maxMembers > 0) ? maxMembers : 4)}";
		}
	}
	internal readonly struct PublishedLobby
	{
		public string Name { get; }

		public string Host { get; }

		public string ExpeditionName { get; }

		public string Players { get; }

		public string LobbyId { get; }

		public PublishedLobby(string name, string host, string expeditionName, string players, string lobbyId)
		{
			Name = name ?? string.Empty;
			Host = host ?? string.Empty;
			ExpeditionName = expeditionName ?? string.Empty;
			Players = players ?? "?/4";
			LobbyId = lobbyId ?? string.Empty;
		}
	}
	internal static class LobbyJoiner
	{
		public static bool TryJoin(string lobbyId, out string error)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			error = string.Empty;
			if (string.IsNullOrWhiteSpace(lobbyId))
			{
				error = LocalText.EmptyLobbyId;
				return false;
			}
			if (!ulong.TryParse(lobbyId.Trim(), out var result))
			{
				error = LocalText.InvalidLobbyId;
				return false;
			}
			bool flag = default(bool);
			try
			{
				if (SNet.IsInLobby)
				{
					SNet_Lobby lobby = SNet.Lobby;
					if (((lobby != null) ? lobby.Identifier : null) != null && SNet.Lobby.Identifier.ID == result)
					{
						error = LocalText.AlreadyInCurrentLobby;
						return false;
					}
				}
				SNet_LobbyIdentifier lobbyIdentifier = SNet.Core.GetLobbyIdentifier(result);
				if (lobbyIdentifier == null)
				{
					error = LocalText.LobbyIdentifierNotFound;
					return false;
				}
				SNet.Lobbies.JoinLobby(lobbyIdentifier, true);
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(29, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: joining lobby id ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lobbyId);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					}
					logger.LogMessage(val);
				}
				return true;
			}
			catch (Exception ex)
			{
				error = ex.Message;
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to join lobby id ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(lobbyId);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val2);
				}
				return false;
			}
		}
	}
	public sealed class LobbyListOverlay : MonoBehaviour
	{
		public static LobbyListOverlay Instance;

		private const string ServerText = "PUBLIC SERVER";

		private const string BrandText = "LOBBYLIST";

		private GUIStyle _titleStyle;

		private GUIStyle _headerStyle;

		private GUIStyle _cellStyle;

		private GUIStyle _smallCellStyle;

		private GUIStyle _dimStyle;

		private GUIStyle _buttonStyle;

		private GUIStyle _rowButtonStyle;

		private GUIStyle _panelStyle;

		private GUIStyle _tabTitleStyle;

		private GUIStyle _tabDescriptionStyle;

		private GUIStyle _brandStyle;

		private Texture2D _panelTexture;

		private Texture2D _sidebarTexture;

		private Texture2D _widgetTexture;

		private Texture2D _buttonTexture;

		private Texture2D _buttonHoverTexture;

		private Texture2D _buttonActiveTexture;

		private Texture2D _lineTexture;

		private Font _uiFont;

		private Action _onClose;

		private bool _cursorStateStored;

		private bool _previousCursorVisible;

		private CursorLockMode _previousCursorLockState;

		private List<PublishedLobby> _lobbies = new List<PublishedLobby>();

		private string _statusText = LocalText.StatusLoading;

		private bool _isLoading;

		private float _nextLobbyButtonTextRefreshTime;

		public bool IsVisible { get; private set; }

		public void Show(Action onClose = null)
		{
			bool isVisible = IsVisible;
			_onClose = onClose;
			StoreAndUnlockCursor();
			IsVisible = true;
			if (!isVisible)
			{
				RefreshLobbies();
			}
		}

		public void Hide()
		{
			IsVisible = false;
			RestoreCursor();
			Action onClose = _onClose;
			_onClose = null;
			onClose?.Invoke();
		}

		public void HideWithoutCallback()
		{
			IsVisible = false;
			RestoreCursor();
			_onClose = null;
		}

		private void Update()
		{
			if (Time.realtimeSinceStartup >= _nextLobbyButtonTextRefreshTime)
			{
				_nextLobbyButtonTextRefreshTime = Time.realtimeSinceStartup + 0.5f;
				RundownNewPatch.RefreshLobbyBrowserButtonText();
				LoadoutPagePatch.RefreshLobbyPublishButtonText();
			}
			if (IsVisible)
			{
				StoreAndUnlockCursor();
				if (Input.GetKeyDown((KeyCode)27))
				{
					Hide();
				}
			}
		}

		private void OnGUI()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: 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_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: 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)
			if (IsVisible)
			{
				EnsureStyles();
				StoreAndUnlockCursor();
				GUI.depth = -1000;
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.blackTexture, (ScaleMode)0);
				float num = Mathf.Max(18f, (float)Screen.width * 0.025f);
				float num2 = Mathf.Max(18f, (float)Screen.height * 0.032f);
				float num3 = (float)Screen.width - num * 2f;
				float num4 = (float)Screen.height - num2 * 2f;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(num, num2, num3, num4);
				GUI.Box(val, GUIContent.none, _panelStyle);
				float num5 = Mathf.Clamp(((Rect)(ref val)).width * 0.22f, 210f, 260f);
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, num5, ((Rect)(ref val)).height);
				DrawLine(rect, Color.white, _sidebarTexture);
				DrawLine(new Rect(((Rect)(ref rect)).xMax, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), new Color(0.094f, 0.102f, 0.141f, 1f));
				DrawBorder(val, new Color(0.094f, 0.102f, 0.141f, 1f));
				GUI.Label(new Rect(((Rect)(ref rect)).x + 24f, ((Rect)(ref rect)).y + 26f, ((Rect)(ref rect)).width - 48f, 32f), "LOBBYLIST", _brandStyle);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 24f, ((Rect)(ref rect)).y + 58f, ((Rect)(ref rect)).width - 48f, 24f), "PUBLIC SERVER", _dimStyle);
				DrawTab(new Rect(((Rect)(ref rect)).x + 14f, ((Rect)(ref rect)).y + 112f, ((Rect)(ref rect)).width - 28f, 56f));
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref val)).x + num5, ((Rect)(ref val)).y, ((Rect)(ref val)).width - num5, ((Rect)(ref val)).height);
				GUI.Label(new Rect(((Rect)(ref val2)).x + 34f, ((Rect)(ref val2)).y + 28f, 440f, 48f), LocalText.MatchLobby, _titleStyle);
				GUI.Label(new Rect(((Rect)(ref val2)).x + 36f, ((Rect)(ref val2)).y + 74f, ((Rect)(ref val2)).width - 72f, 26f), _statusText, _dimStyle);
				if (GUI.Button(new Rect(((Rect)(ref val2)).xMax - 150f, ((Rect)(ref val2)).y + 30f, 112f, 42f), LocalText.Back, _buttonStyle))
				{
					Hide();
				}
				if (GUI.Button(new Rect(((Rect)(ref val2)).xMax - 276f, ((Rect)(ref val2)).y + 30f, 112f, 42f), LocalText.Refresh, _buttonStyle))
				{
					RefreshLobbies();
				}
				Rect val3 = default(Rect);
				((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 34f, ((Rect)(ref val2)).y + 116f, ((Rect)(ref val2)).width - 68f, ((Rect)(ref val2)).height - 176f);
				GUI.Box(val3, GUIContent.none, _panelStyle);
				DrawBorder(val3, new Color(0.094f, 0.102f, 0.141f, 1f));
				float num6 = ((Rect)(ref val3)).x + 24f;
				float num7 = ((Rect)(ref val3)).y + 22f;
				float num8 = ((Rect)(ref val3)).width - 56f;
				DrawRowHeaders(num6, num7, num8);
				num7 += 50f;
				int num9 = Mathf.Min(_lobbies.Count, Mathf.Max(0, Mathf.FloorToInt((((Rect)(ref val3)).yMax - num7 - 14f) / 68f)));
				for (int i = 0; i < num9; i++)
				{
					PublishedLobby lobby = _lobbies[i];
					DrawLobbyRow(i, num6, num7, num8, lobby);
					num7 += 68f;
				}
				if (!_isLoading && _lobbies.Count == 0)
				{
					GUI.Label(new Rect(num6, ((Rect)(ref val3)).y + 92f, num8, 36f), LocalText.StatusEmpty, _cellStyle);
				}
				GUI.Label(new Rect(((Rect)(ref val2)).x + 36f, ((Rect)(ref val2)).yMax - 42f, ((Rect)(ref val2)).width - 72f, 26f), LocalText.FooterHint, _dimStyle);
			}
		}

		private void DrawTab(Rect rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			DrawLine(rect, new Color(0.086f, 0.086f, 0.118f, 1f), _widgetTexture);
			DrawLine(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 3f, ((Rect)(ref rect)).height), new Color(0.439f, 0.431f, 0.843f, 1f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 18f, ((Rect)(ref rect)).y + 7f, ((Rect)(ref rect)).width - 32f, 24f), LocalText.MatchLobby, _tabTitleStyle);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 18f, ((Rect)(ref rect)).y + 29f, ((Rect)(ref rect)).width - 32f, 20f), LocalText.TabDescription, _tabDescriptionStyle);
		}

		private void DrawRowHeaders(float x, float y, float width)
		{
			//IL_000e: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(x, y, width * 0.31f, 28f), LocalText.GameNameHeader, _headerStyle);
			GUI.Label(new Rect(x + width * 0.34f, y, width * 0.27f, 28f), LocalText.ExpeditionHeader, _headerStyle);
			GUI.Label(new Rect(x + width * 0.63f, y, width * 0.1f, 28f), LocalText.PlayersHeader, _headerStyle);
			GUI.Label(new Rect(x + width * 0.73f, y, Mathf.Max(120f, width - 344f - width * 0.73f), 28f), LocalText.HostHeader, _headerStyle);
			GUI.Label(new Rect(x + width - 126f, y, 126f, 28f), LocalText.ActionHeader, _headerStyle);
			DrawLine(new Rect(x, y + 31f, width, 1f), new Color(0.439f, 0.431f, 0.843f, 0.85f));
		}

		private void DrawLobbyRow(int index, float x, float y, float width, PublishedLobby lobby)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00c7: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			Color color = ((index % 2 == 0) ? new Color(0.058f, 0.058f, 0.067f, 0.95f) : new Color(0.082f, 0.09f, 0.102f, 0.95f));
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(x - 12f, y - 8f, width + 24f, 56f);
			if (((Rect)(ref rect)).Contains(Event.current.mousePosition))
			{
				((Color)(ref color))..ctor(0.086f, 0.086f, 0.118f, 1f);
			}
			DrawLine(rect, color);
			DrawLine(new Rect(x - 12f, y + 50f, width + 24f, 1f), new Color(0.11f, 0.12f, 0.16f, 1f));
			GUI.Label(new Rect(x, y + 4f, width * 0.31f, 32f), lobby.Name, _cellStyle);
			GUI.Label(new Rect(x + width * 0.34f, y + 5f, width * 0.27f, 32f), string.IsNullOrWhiteSpace(lobby.ExpeditionName) ? "--" : lobby.ExpeditionName, _smallCellStyle);
			GUI.Label(new Rect(x + width * 0.63f, y + 4f, width * 0.1f, 32f), lobby.Players, _cellStyle);
			GUI.Label(new Rect(x + width * 0.73f, y + 4f, Mathf.Max(120f, width - 344f - width * 0.73f), 32f), lobby.Host, _cellStyle);
			float num = 58f;
			Rect val = new Rect(x + width - 126f, y + 2f, num, 34f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(x + width - 62f, y + 2f, num, 34f);
			if (GUI.Button(val, LocalText.Join, _buttonStyle))
			{
				JoinLobby(lobby);
			}
			if (GUI.Button(val2, LocalText.Copy, _buttonStyle))
			{
				CopyLobbyId(lobby);
			}
		}

		private void RefreshLobbies()
		{
			if (!_isLoading)
			{
				_isLoading = true;
				_statusText = LocalText.StatusLoading;
				LobbyDirectoryClient.FetchLobbies(delegate(List<PublishedLobby> lobbies)
				{
					_lobbies = lobbies ?? new List<PublishedLobby>();
					_statusText = ((_lobbies.Count > 0) ? LocalText.LobbiesRead(_lobbies.Count) : LocalText.StatusEmpty);
					_isLoading = false;
				}, delegate(string error)
				{
					_lobbies = new List<PublishedLobby>();
					_statusText = LocalText.ServerConnectFailed(error);
					_isLoading = false;
				});
			}
		}

		private void JoinLobby(PublishedLobby lobby)
		{
			if (LobbyJoiner.TryJoin(lobby.LobbyId, out var error))
			{
				_statusText = LocalText.JoiningLobby(lobby.Name);
				Hide();
			}
			else
			{
				_statusText = LocalText.JoinLobbyFailure(error);
			}
		}

		private static void CopyLobbyId(PublishedLobby lobby)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if (!string.IsNullOrWhiteSpace(lobby.LobbyId))
			{
				GUIUtility.systemCopyBuffer = lobby.LobbyId;
			}
			ManualLogSource logger = MainPlugin.Logger;
			if (logger != null)
			{
				bool flag = default(bool);
				BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(48, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: copied lobby '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lobby.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' hosted by ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lobby.Host);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", lobbyId=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lobby.LobbyId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logger.LogMessage(val);
			}
		}

		private void DrawBorder(Rect rect, Color color)
		{
			//IL_001b: 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			DrawLine(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 2f), color);
			DrawLine(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 2f, ((Rect)(ref rect)).width, 2f), color);
			DrawLine(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 2f, ((Rect)(ref rect)).height), color);
			DrawLine(new Rect(((Rect)(ref rect)).xMax - 2f, ((Rect)(ref rect)).y, 2f, ((Rect)(ref rect)).height), color);
		}

		private void DrawLine(Rect rect, Color color)
		{
			//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)
			DrawLine(rect, color, _lineTexture);
		}

		private void DrawLine(Rect rect, Color color, Texture2D texture)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (texture == null)
			{
				texture = Texture2D.whiteTexture;
			}
			if (!((Object)(object)texture == (Object)null))
			{
				Color color2 = GUI.color;
				GUI.color = color;
				GUI.DrawTexture(rect, (Texture)(object)texture, (ScaleMode)0);
				GUI.color = color2;
			}
		}

		private void EnsureStyles()
		{
			//IL_0029: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_013a: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: 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_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Expected O, but got Unknown
			//IL_0334: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (_titleStyle == null)
			{
				_uiFont = CreateUiFont();
				_panelTexture = MakeTexture(new Color(0.047f, 0.047f, 0.047f, 0.98f));
				_sidebarTexture = MakeTexture(new Color(0.055f, 0.055f, 0.059f, 1f));
				_widgetTexture = MakeTexture(new Color(0.082f, 0.09f, 0.102f, 1f));
				_buttonTexture = MakeTexture(new Color(0.082f, 0.09f, 0.102f, 1f));
				_buttonHoverTexture = MakeTexture(new Color(0.086f, 0.086f, 0.118f, 1f));
				_buttonActiveTexture = MakeTexture(new Color(0.439f, 0.431f, 0.843f, 1f));
				_lineTexture = Texture2D.whiteTexture ?? MakeTexture(Color.white);
				GUIStyle val = new GUIStyle(GUI.skin.box);
				val.normal.background = _panelTexture;
				val.border = new RectOffset(2, 2, 2, 2);
				_panelStyle = val;
				_titleStyle = MakeTextStyle(32, (FontStyle)1, new Color(1f, 1f, 1f, 1f));
				_headerStyle = MakeTextStyle(17, (FontStyle)1, new Color(1f, 1f, 1f, 1f));
				_cellStyle = MakeTextStyle(18, (FontStyle)1, new Color(1f, 1f, 1f, 1f));
				_smallCellStyle = MakeTextStyle(16, (FontStyle)0, new Color(0.78f, 0.82f, 0.9f, 1f));
				_dimStyle = MakeTextStyle(14, (FontStyle)0, new Color(0.32f, 0.36f, 0.43f, 1f));
				_tabTitleStyle = MakeTextStyle(17, (FontStyle)1, new Color(1f, 1f, 1f, 1f));
				_tabDescriptionStyle = MakeTextStyle(13, (FontStyle)0, new Color(0.32f, 0.36f, 0.43f, 1f));
				_brandStyle = MakeTextStyle(20, (FontStyle)1, new Color(0.439f, 0.431f, 0.843f, 1f));
				GUIStyle val2 = new GUIStyle(GUI.skin.button)
				{
					font = _uiFont,
					fontSize = 18,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				val2.normal.background = _buttonTexture;
				val2.normal.textColor = Color.white;
				val2.hover.background = _buttonHoverTexture;
				val2.hover.textColor = Color.white;
				val2.active.background = _buttonActiveTexture;
				val2.active.textColor = Color.white;
				val2.border = new RectOffset(2, 2, 2, 2);
				val2.padding = new RectOffset(10, 10, 0, 1);
				_buttonStyle = val2;
				_rowButtonStyle = new GUIStyle(GUIStyle.none);
			}
		}

		private void StoreAndUnlockCursor()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!_cursorStateStored)
			{
				_previousCursorVisible = Cursor.visible;
				_previousCursorLockState = Cursor.lockState;
				_cursorStateStored = true;
			}
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
		}

		private void RestoreCursor()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (_cursorStateStored)
			{
				Cursor.visible = _previousCursorVisible;
				Cursor.lockState = _previousCursorLockState;
				_cursorStateStored = false;
			}
		}

		private GUIStyle MakeTextStyle(int size, FontStyle fontStyle, Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				font = _uiFont,
				fontSize = size,
				fontStyle = fontStyle,
				alignment = (TextAnchor)3,
				clipping = (TextClipping)1
			};
			val.normal.textColor = color;
			return val;
		}

		private static Texture2D MakeTexture(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}

		private static Font CreateUiFont()
		{
			try
			{
				return Font.CreateDynamicFontFromOSFont(Il2CppStringArray.op_Implicit(new string[4] { "Lexend", "Microsoft YaHei UI", "Segoe UI", "Arial" }), 16);
			}
			catch
			{
				return GUI.skin.font;
			}
		}
	}
	internal class LobbyPatch
	{
		private static void UpDateMember()
		{
			if (Common.Uuid == null)
			{
				CleanupDirectoryIfMasterIsGone("lobby update");
				return;
			}
			if (!SNet.IsMaster)
			{
				Common.CleanUp();
				Common.CancelLobbyByCurrentLobbyId("publishing player is no longer master");
				return;
			}
			HttpUtil.Get(Common.BASE_URL + "AmountOfMemberChanged?uuid=" + Common.Uuid + "&count=" + SNet.Lobby.Players.Count, delegate(string result)
			{
				if (result == null || result.Equals("") || !bool.Parse(result))
				{
					Common.CleanUp();
				}
				else
				{
					MainPlugin.Logger.LogMessage((object)LocalText.LobbyInfoUpdate);
				}
			});
		}

		[HarmonyPatch(typeof(SNet_Core_STEAM), "LeaveLobby")]
		[HarmonyPostfix]
		public static void LeaveLobbyPostPatch(ref SNet_Core_STEAM __instance)
		{
			Common.CleanUp();
		}

		[HarmonyPatch(typeof(SNet_Lobby_STEAM), "OnLobbyUpdate")]
		[HarmonyPostfix]
		public static void PlayerLeaveLobbyPostPatch(ref SNet_Lobby_STEAM __instance)
		{
			UpDateMember();
		}

		[HarmonyPatch(typeof(SNet_GlobalManager), "OnMasterChanged")]
		[HarmonyPostfix]
		public static void OnMasterChangedPostfix()
		{
			if (Common.Uuid != null && !SNet.IsMaster)
			{
				Common.CleanUp();
			}
			CleanupDirectoryIfMasterIsGone("master changed");
		}

		private static void CleanupDirectoryIfMasterIsGone(string reason)
		{
			if (SNet.IsInLobby && !SNet.IsMaster && !SNet.HasMaster)
			{
				Common.CancelLobbyByCurrentLobbyId(reason);
			}
		}
	}
	internal static class LobbyPublisher
	{
		public static bool Publish(string lobbyName, out string error)
		{
			error = string.Empty;
			if (!SNet.IsInLobby || (Object)(object)SNet.Lobby == (Object)null || !SNet.IsMaster)
			{
				error = "local player is not the lobby master";
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"LobbyList: publish rejected because local player is not the lobby master.");
				}
				return false;
			}
			Common.CleanUp();
			CurrentExpeditionTracker.RefreshFromActiveExpedition();
			LobbyInfo lobbyInfo = new LobbyInfo
			{
				name = lobbyName,
				creatorName = SNet.LocalPlayer.GetName(),
				expeditionName = CurrentExpeditionTracker.ExpeditionName,
				lobbyId = SNet.Lobby.Identifier.ID.ToString(),
				amountOfMember = SNet.Lobby.Players.Count
			};
			if (string.IsNullOrWhiteSpace(lobbyInfo.name))
			{
				lobbyInfo.name = string.Format(LocalText.DefaultLobbyName, lobbyInfo.creatorName);
			}
			string sendData = HttpUtil.ToPaeameter(lobbyInfo);
			HttpUtil.Post(Common.BASE_URL + "CreateLobby", sendData, delegate(string result)
			{
				if (string.IsNullOrWhiteSpace(result))
				{
					ChatMsgBehaviour.Message = LocalText.CreateLobbyFailure;
					ManualLogSource logger2 = MainPlugin.Logger;
					if (logger2 != null)
					{
						logger2.LogError((object)LocalText.CreateLobbyFailure);
					}
				}
				else
				{
					Common.Uuid = result;
					Common.StartTTL();
					ChatMsgBehaviour.Message = LocalText.CreateLobbySuccess;
					ManualLogSource logger3 = MainPlugin.Logger;
					if (logger3 != null)
					{
						logger3.LogMessage((object)LocalText.CreateLobbySuccess);
					}
				}
			});
			return true;
		}
	}
	[BepInPlugin("LobbyList.Remake", "LobbyList:Remake", "0.4.8-public-server-preview")]
	public class MainPlugin : BasePlugin
	{
		public static ManualLogSource Logger;

		public override void Load()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0089: Expected O, but got Unknown
			Harmony val = new Harmony("LobbyList.Remake");
			Logger = ((BasePlugin)this).Log;
			RegisterOverlayDriver();
			PatchSafely(val, typeof(LobbyPatch));
			PatchSafely(val, typeof(ChatPatch));
			PatchSafely(val, typeof(RundownNewPatch));
			PatchSafely(val, typeof(MatchmakingPagePatch));
			PatchSafely(val, typeof(LoadoutPagePatch));
			PatchSafely(val, typeof(CurrentExpeditionTracker));
			PatchSafely(val, typeof(GameStateChangePatch));
			((BasePlugin)this).Log.LogMessage((object)"LobbyList:Remake public server preview loaded!");
		}

		private static void PatchSafely(Harmony harmony, Type type)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				harmony.PatchAll(type);
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(20, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LobbyList: patched ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					}
					logger.LogMessage(val);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(29, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: failed to patch ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(type.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val2);
				}
			}
		}

		private static void RegisterOverlayDriver()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ClassInjector.RegisterTypeInIl2Cpp<LobbyListOverlay>();
				ClassInjector.RegisterTypeInIl2Cpp<ChatMsgBehaviour>();
			}
			catch
			{
			}
			GameObject val = new GameObject("LobbyList_Overlay");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			LobbyListOverlay.Instance = val.AddComponent<LobbyListOverlay>();
			val.AddComponent<ChatMsgBehaviour>();
		}
	}
	public static class MatchmakingPagePatch
	{
		private readonly struct DemoLobby
		{
			public string Name { get; }

			public string Host { get; }

			public string Players { get; }

			public DemoLobby(string name, string host, string players)
			{
				Name = name;
				Host = host;
				Players = players;
			}
		}

		private static readonly DemoLobby[] DemoLobbies = new DemoLobby[4]
		{
			new DemoLobby("R6B2 Contaminant 练习", "Remake", "2/4"),
			new DemoLobby("R6C3 Pressure Point", "Localia", "1/4"),
			new DemoLobby("R6D1 Nemesis 推进", "Natural", "3/4"),
			new DemoLobby("R6AX Dust 全收集", "Prisoner_07", "4/4")
		};

		private static readonly List<Renderer> HiddenNativeRenderers = new List<Renderer>();

		private static readonly List<CM_Item> DisabledNativeItems = new List<CM_Item>();

		private static readonly List<CM_Item> CustomInputItems = new List<CM_Item>();

		private static bool _openRequested;

		private static bool _lobbyBrowserActive;

		private static bool _nativeHidden;

		private static CM_PageMatchmaking _activePage;

		private static GameObject _root;

		private static Texture2D _solidTexture;

		private static Sprite _solidSprite;

		public static void RequestLobbyBrowserOpen()
		{
			_openRequested = true;
			_lobbyBrowserActive = true;
		}

		public static void TryShowLobbyBrowser(MainMenuGuiLayer guiLayer)
		{
			if (!_lobbyBrowserActive || guiLayer == null)
			{
				return;
			}
			CM_PageMatchmaking val = guiLayer.PageMatchmaking;
			if ((Object)(object)val == (Object)null)
			{
				CM_PageBase page = guiLayer.GetPage((eCM_MenuPage)20);
				val = (((Object)(object)page != (Object)null) ? ((Il2CppObjectBase)page).TryCast<CM_PageMatchmaking>() : null);
			}
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					logger.LogError((object)"LobbyList: unable to resolve matchmaking page for lobby browser.");
				}
			}
			else
			{
				_openRequested = false;
				ShowLobbyBrowser(val);
			}
		}

		[HarmonyPatch(typeof(MainMenuGuiLayer), "ChangePage")]
		[HarmonyPostfix]
		public static void ChangePagePostfix(MainMenuGuiLayer __instance, eCM_MenuPage pageEnum)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)pageEnum == 20)
			{
				TryShowLobbyBrowser(__instance);
			}
			else if (_lobbyBrowserActive)
			{
				RestoreNativeMatchmaking();
			}
		}

		[HarmonyPatch(typeof(CM_PageMatchmaking), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnablePostfix(CM_PageMatchmaking __instance)
		{
			if (_openRequested || _lobbyBrowserActive)
			{
				_openRequested = false;
				ShowLobbyBrowser(__instance);
			}
			else
			{
				RestoreNativeMatchmaking(__instance);
			}
		}

		private static void ShowLobbyBrowser(CM_PageMatchmaking page)
		{
			_activePage = page;
			ObservePageLanguage(page);
			if ((Object)(object)LobbyListOverlay.Instance != (Object)null && LobbyListOverlay.Instance.IsVisible)
			{
				HideNativeMatchmakingUi(page);
				return;
			}
			HideNativeMatchmakingUi(page);
			LobbyListOverlay.Instance?.Show(ReturnToRundown);
			SetActiveSafe(_root, active: false);
			ManualLogSource logger = MainPlugin.Logger;
			if (logger != null)
			{
				logger.LogMessage((object)"LobbyList: native lobby browser page shown.");
			}
		}

		private static void ObservePageLanguage(CM_PageMatchmaking page)
		{
			if ((Object)(object)page == (Object)null)
			{
				return;
			}
			List<TextMeshPro> list = new List<TextMeshPro>();
			foreach (TextMeshPro componentsInChild in ((Component)page).GetComponentsInChildren<TextMeshPro>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null) && !IsUnderLobbyRoot(componentsInChild.transform))
				{
					list.Add(componentsInChild);
				}
			}
			LocalText.ObserveGameTexts(list, (TextMeshPro label) => ((TMP_Text)label).text);
		}

		private static void RestoreNativeMatchmaking(CM_PageMatchmaking page = null)
		{
			_lobbyBrowserActive = false;
			if ((Object)(object)LobbyListOverlay.Instance != (Object)null && LobbyListOverlay.Instance.IsVisible)
			{
				LobbyListOverlay.Instance.HideWithoutCallback();
			}
			SetActiveSafe(_root, active: false);
			if (page == null)
			{
				page = _activePage;
			}
			if ((Object)(object)page != (Object)null)
			{
				SetNativeFieldObjectsVisible(page, visible: true);
			}
			foreach (Renderer hiddenNativeRenderer in HiddenNativeRenderers)
			{
				if ((Object)(object)hiddenNativeRenderer != (Object)null)
				{
					hiddenNativeRenderer.enabled = true;
				}
			}
			foreach (CM_Item disabledNativeItem in DisabledNativeItems)
			{
				if ((Object)(object)disabledNativeItem != (Object)null)
				{
					disabledNativeItem.SetButtonEnabled(true);
				}
			}
			HiddenNativeRenderers.Clear();
			DisabledNativeItems.Clear();
			_nativeHidden = false;
			_activePage = null;
		}

		private static void HideNativeMatchmakingUi(CM_PageMatchmaking page)
		{
			if (_nativeHidden)
			{
				return;
			}
			_activePage = page;
			foreach (Renderer componentsInChild in ((Component)page).GetComponentsInChildren<Renderer>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null) && !IsUnderLobbyRoot(((Component)componentsInChild).transform) && componentsInChild.enabled)
				{
					if (!HiddenNativeRenderers.Contains(componentsInChild))
					{
						HiddenNativeRenderers.Add(componentsInChild);
					}
					componentsInChild.enabled = false;
				}
			}
			foreach (CM_Item componentsInChild2 in ((Component)page).GetComponentsInChildren<CM_Item>(true))
			{
				if (!((Object)(object)componentsInChild2 == (Object)null) && !IsUnderLobbyRoot(((Component)componentsInChild2).transform) && !CustomInputItems.Contains(componentsInChild2))
				{
					if (!DisabledNativeItems.Contains(componentsInChild2))
					{
						DisabledNativeItems.Add(componentsInChild2);
					}
					componentsInChild2.SetButtonEnabled(false);
				}
			}
			SetNativeFieldObjectsVisible(page, visible: false);
			_nativeHidden = true;
		}

		private static void SetNativeFieldObjectsVisible(CM_PageMatchmaking page, bool visible)
		{
			SetActiveSafe(page.m_dropdowns, visible);
			SetActiveSafe((Component)(object)page.m_discordButton, visible);
			if ((Object)(object)page.m_matchmakeButton != (Object)null)
			{
				((RectTransformComp)page.m_matchmakeButton).SetVisible(visible);
				((CM_Item)page.m_matchmakeButton).SetButtonEnabled(visible);
			}
			if ((Object)(object)page.m_backButton != (Object)null)
			{
				((RectTransformComp)page.m_backButton).SetVisible(visible);
				((CM_Item)page.m_backButton).SetButtonEnabled(visible);
			}
		}

		private static void EnsureLobbyBrowserObjects(CM_PageMatchmaking page)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_root != (Object)null))
			{
				EnsureSolidSprite();
				Transform val = page.m_buttonLayer ?? ((Component)page).transform;
				_root = new GameObject("LobbyList_NativeLobbyBrowser");
				_root.transform.SetParent(val, false);
				_root.transform.localPosition = new Vector3(90f, -40f, 0f);
				_root.transform.localRotation = Quaternion.identity;
				_root.transform.localScale = Vector3.one;
				DrawPanel(page.m_header);
				CreateBackButton(page);
				for (int i = 0; i < DemoLobbies.Length; i++)
				{
					CreateLobbyRow(page, i, DemoLobbies[i]);
				}
			}
		}

		private static void DrawPanel(TextMeshPro fontSource)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0132: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			CreateRect("PanelFill", new Vector3(0f, 0f, 18f), new Vector2(1120f, 620f), new Color(0.005f, 0.012f, 0.014f, 0.92f));
			DrawBorder("PanelOuter", Vector3.zero, 1120f, 620f, new Color(0.55f, 0.9f, 1f, 0.78f), 3f);
			DrawBorder("PanelInner", Vector3.zero, 1098f, 598f, new Color(1f, 0.08f, 0.06f, 0.55f), 3f);
			CreateLabel("Title", LocalText.MatchLobby, fontSource, new Vector3(-510f, 258f, 10f), 30f, (FontStyles)1, new Color(0.9f, 0.98f, 1f, 1f));
			CreateLabel("PreviewHint", LocalText.PreviewText, fontSource, new Vector3(-508f, 214f, 10f), 14f, (FontStyles)0, new Color(0.45f, 0.66f, 0.72f, 1f));
			CreateRect("TableFill", new Vector3(0f, -38f, 17f), new Vector2(1048f, 420f), new Color(0.005f, 0.012f, 0.014f, 0.75f));
			DrawBorder("TableBorder", new Vector3(0f, -38f, 0f), 1048f, 420f, new Color(0.38f, 0.72f, 0.82f, 0.65f), 2f);
			CreateLabel("HeaderGameName", LocalText.GameNameHeader, fontSource, new Vector3(-490f, 123f, 10f), 19f, (FontStyles)1, new Color(1f, 0.62f, 0f, 1f));
			CreateLabel("HeaderPlayers", LocalText.PlayersHeader, fontSource, new Vector3(-35f, 123f, 10f), 19f, (FontStyles)1, new Color(1f, 0.62f, 0f, 1f));
			CreateLabel("HeaderHost", LocalText.HostHeader, fontSource, new Vector3(135f, 123f, 10f), 19f, (FontStyles)1, new Color(1f, 0.62f, 0f, 1f));
			CreateRect("HeaderLine", new Vector3(0f, 100f, 8f), new Vector2(1002f, 2f), new Color(1f, 0.58f, 0f, 0.72f));
			CreateLabel("Footer", LocalText.FooterText, fontSource, new Vector3(-508f, -282f, 10f), 14f, (FontStyles)0, new Color(0.45f, 0.66f, 0.72f, 1f));
		}

		private static void CreateLobbyRow(CM_PageMatchmaking page, int index, DemoLobby lobby)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_0224: 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_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			float num = 52f - (float)index * 68f;
			Color color = ((index % 2 == 0) ? new Color(0.05f, 0.15f, 0.17f, 0.58f) : new Color(0.02f, 0.09f, 0.11f, 0.58f));
			CreateRect($"LobbyRow_{index}_Fill", new Vector3(0f, num, 9f), new Vector2(1024f, 54f), color);
			CreateRect($"LobbyRow_{index}_Line", new Vector3(0f, num - 28f, 9f), new Vector2(1024f, 1f), new Color(0.55f, 0.9f, 1f, 0.28f));
			TextMeshPro header = page.m_header;
			CreateLabel($"LobbyRow_{index}_Name", lobby.Name, header, new Vector3(-490f, num - 7f, 10f), 20f, (FontStyles)0, new Color(0.82f, 0.94f, 1f, 1f));
			CreateLabel($"LobbyRow_{index}_Players", lobby.Players, header, new Vector3(-35f, num - 7f, 10f), 20f, (FontStyles)0, new Color(0.82f, 0.94f, 1f, 1f));
			CreateLabel($"LobbyRow_{index}_Host", lobby.Host, header, new Vector3(135f, num - 7f, 10f), 20f, (FontStyles)0, new Color(0.82f, 0.94f, 1f, 1f));
			CM_Item val = CreateInvisibleHitbox(page, $"LobbyList_LobbyRowHitbox_{index}", new Vector3(0f, num, 0f));
			if (!((Object)(object)val == (Object)null))
			{
				val.OnBtnPressCallback = null;
				val.OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)delegate
				{
					OnLobbyRowPressed(index);
				});
				val.SetButtonEnabled(true);
				CustomInputItems.Add(val);
			}
		}

		private static void CreateBackButton(CM_PageMatchmaking page)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			CreateRect("BackButtonFill", new Vector3(455f, 248f, 9f), new Vector2(104f, 38f), new Color(0.02f, 0.09f, 0.11f, 0.7f));
			DrawBorder("BackButtonBorder", new Vector3(455f, 248f, 0f), 104f, 38f, new Color(1f, 0.08f, 0.06f, 0.75f), 2f);
			CreateLabel("BackButtonText", LocalText.Back, page.m_header, new Vector3(424f, 238f, 10f), 20f, (FontStyles)1, new Color(1f, 0.65f, 0.04f, 1f));
			CM_Item val = CreateInvisibleHitbox(page, "LobbyList_BackHitbox", new Vector3(455f, 248f, 0f));
			if (!((Object)(object)val == (Object)null))
			{
				val.OnBtnPressCallback = null;
				val.OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)delegate
				{
					ReturnToRundown();
				});
				val.SetButtonEnabled(true);
				CustomInputItems.Add(val);
			}
		}

		private static CM_Item CreateInvisibleHitbox(CM_PageMatchmaking page, string name, Vector3 localPosition)
		{
			//IL_005a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			GameObject val = (((Object)(object)page.m_matchmakeButtonPrefab != (Object)null) ? page.m_matchmakeButtonPrefab : page.m_backButtonPrefab);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource logger = MainPlugin.Logger;
				if (logger != null)
				{
					logger.LogError((object)"LobbyList: unable to find matchmaking button prefab for hitbox.");
				}
				return null;
			}
			GameObject obj = Object.Instantiate<GameObject>(val, _root.transform);
			((Object)obj).name = name;
			obj.transform.localPosition = localPosition;
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = Vector3.one;
			obj.SetActive(true);
			HideVisualComponents(obj);
			CM_Item component = obj.GetComponent<CM_Item>();
			if ((Object)(object)component == (Object)null)
			{
				ManualLogSource logger2 = MainPlugin.Logger;
				if (logger2 != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LobbyList: hitbox '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' has no CM_Item.");
					}
					logger2.LogError(val2);
				}
			}
			return component;
		}

		private static void RegisterCustomInputItems(CM_PageMatchmaking page)
		{
			if (page.m_inputItems == null)
			{
				return;
			}
			foreach (CM_Item customInputItem in CustomInputItems)
			{
				if ((Object)(object)customInputItem != (Object)null && !page.m_inputItems.Contains(customInputItem))
				{
					page.m_inputItems.Add(customInputItem);
				}
			}
		}

		private static void HideVisualComponents(GameObject root)
		{
			foreach (Renderer componentsInChild in root.GetComponentsInChildren<Renderer>(true))
			{
				if ((Object)(object)componentsInChild != (Object)null)
				{
					componentsInChild.enabled = false;
				}
			}
		}

		private static TextMeshPro CreateLabel(string name, string text, TextMeshPro source, Vector3 localPosition, float fontSize, FontStyles fontStyle, Color color)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LobbyList_" + name);
			val.transform.SetParent(_root.transform, false);
			val.transform.localPosition = localPosition;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			if ((Object)(object)source != (Object)null)
			{
				((TMP_Text)val2).font = ((TMP_Text)source).font;
				((TMP_Text)val2).fontMaterial = ((TMP_Text)source).fontMaterial;
			}
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = fontSize;
			((TMP_Text)val2).fontStyle = fontStyle;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val2).enableWordWrapping = false;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
			SetSortingOrder(((Component)val2).gameObject, 30);
			return val2;
		}

		private static SpriteRenderer CreateRect(string name, Vector3 localPosition, Vector2 size, Color color)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LobbyList_" + name);
			val.transform.SetParent(_root.transform, false);
			val.transform.localPosition = localPosition;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = new Vector3(size.x, size.y, 1f);
			SpriteRenderer obj = val.AddComponent<SpriteRenderer>();
			obj.sprite = _solidSprite;
			obj.color = color;
			((Renderer)obj).sortingOrder = 20;
			return obj;
		}

		private static void DrawBorder(string name, Vector3 center, float width, float height, Color color, float thickness)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might