Decompiled source of Better Lobbies v2.0.1

plugins/Better_Lobbies.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.ProBuilder;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Ryokune")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Enhance your multiplayer experience by having additional lobby related QoL features in game!")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+160a4c9a0984fdc8422ef5f8b0e6e81b5d28ddb8")]
[assembly: AssemblyProduct("Better_Lobbies")]
[assembly: AssemblyTitle("ryokune.better_lobbies")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/VisualError/Better-Lobbies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[AttributeUsage(AttributeTargets.Method)]
internal class HookInitAttribute : Attribute
{
}
[BepInPlugin("ryokune.better_lobbies", "Better_Lobbies", "2.0.1")]
public class Plugin : BaseUnityPlugin
{
	public static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Plugin Better_Lobbies is loaded!");
		Hook();
	}

	private static void Hook()
	{
		Log.LogInfo((object)"Starting Hooks!");
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		Type[] array = types;
		foreach (Type type in array)
		{
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo[] array2 = methods;
			foreach (MethodInfo methodInfo in array2)
			{
				if (methodInfo.GetCustomAttribute<HookInitAttribute>() != null)
				{
					Log.LogDebug((object)("Hooking " + type.Name));
					methodInfo.Invoke(null, null);
				}
			}
		}
	}
}
internal static class LCMPluginInfo
{
	public const string PLUGIN_GUID = "ryokune.better_lobbies";

	public const string PLUGIN_NAME = "Better_Lobbies";

	public const string PLUGIN_VERSION = "2.0.1";
}
namespace Better_Lobbies.Hooks
{
	internal class EnterLobbyCode
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__InitializeField;

			public static UnityAction<string> <1>__onSubmit;

			public static UnityAction<string> <2>__onEndEdit;

			public static UnityAction<string> <3>__onDeselect;

			public static OnValidateInput <4>__ValidateInput;
		}

		private static GameObject? FieldObj;

		internal static TMP_InputField? InputField;

		private static bool stop;

		[HookInit]
		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__InitializeField;
			if (obj == null)
			{
				hook_Awake val = InitializeField;
				<>O.<0>__InitializeField = val;
				obj = (object)val;
			}
			MenuManager.Awake += (hook_Awake)obj;
		}

		private static void InitializeField(orig_Awake orig, MenuManager self)
		{
			orig.Invoke(self);
			GetFieldObj();
			if (!((Object)(object)FieldObj == (Object)null) && !FieldObj.activeInHierarchy)
			{
				FieldObj.SetActive(true);
				GetInputField(FieldObj);
				InitializeInputField(InputField);
				Plugin.Log.LogInfo((object)"Initialized Lobby search field!");
			}
		}

		private static void GetFieldObj()
		{
			if ((Object)(object)FieldObj == (Object)null)
			{
				FieldObj = GameObject.Find("/Canvas/MenuContainer/LobbyList/JoinCode");
				Plugin.Log.LogDebug((object)$"Trying to find Lobby Code Field OBJ. Got: {(Object)(object)FieldObj != (Object)null}");
			}
		}

		private static void GetInputField(GameObject gameObject)
		{
			if ((Object)(object)InputField == (Object)null)
			{
				InputField = gameObject.GetComponent<TMP_InputField>();
				Plugin.Log.LogDebug((object)$"Trying to find Input Field. Got: {(Object)(object)InputField != (Object)null}");
			}
		}

		private static void InitializeInputField(TMP_InputField? field)
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			if (!((Object)(object)field == (Object)null))
			{
				((Selectable)field).interactable = true;
				((TMP_Text)((Component)field.placeholder).gameObject.GetComponent<TextMeshProUGUI>()).text = "Search or Enter a room code...";
				((UnityEventBase)field.onEndEdit).m_PersistentCalls.Clear();
				((UnityEventBase)field.onEndTextSelection).m_PersistentCalls.Clear();
				((UnityEventBase)field.onSubmit).m_PersistentCalls.Clear();
				((UnityEvent<string>)(object)field.onSubmit).AddListener((UnityAction<string>)onSubmit);
				((UnityEvent<string>)(object)field.onEndEdit).AddListener((UnityAction<string>)onEndEdit);
				((UnityEvent<string>)(object)field.onDeselect).AddListener((UnityAction<string>)onDeselect);
				OnValidateInput onValidateInput = field.onValidateInput;
				object obj = <>O.<4>__ValidateInput;
				if (obj == null)
				{
					OnValidateInput val = ValidateInput;
					<>O.<4>__ValidateInput = val;
					obj = (object)val;
				}
				field.onValidateInput = (OnValidateInput)Delegate.Combine((Delegate?)(object)onValidateInput, (Delegate?)obj);
			}
		}

		private static void onEndEdit(string value)
		{
			stop = false;
		}

		private static void onDeselect(string value)
		{
			stop = false;
			if ((Object)(object)InputField != (Object)null)
			{
				InputField.text = "";
			}
		}

		private static char ValidateInput(string text, int charIndex, char addedChar)
		{
			Plugin.Log.LogWarning((object)addedChar);
			if (addedChar == '"')
			{
				stop = true;
			}
			if ((!char.IsDigit(addedChar) && !char.IsControl(addedChar)) || stop)
			{
				return '\0';
			}
			return addedChar;
		}

		private static void onSubmit(string value)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (!ulong.TryParse(value, out var result))
			{
				SteamLobbyManager? instance = SteamLobbyManager.Instance;
				if (instance != null)
				{
					instance.LoadServerList();
				}
			}
			Lobby val = default(Lobby);
			((Lobby)(ref val))..ctor(SteamId.op_Implicit(result));
			if (Utility.IsNullOrWhiteSpace(((Lobby)(ref val)).GetData("vers")))
			{
				SteamLobbyManager? instance2 = SteamLobbyManager.Instance;
				if (instance2 != null)
				{
					instance2.LoadServerList();
				}
			}
			else
			{
				LobbySlot.JoinLobbyAfterVerifying(val, ((Lobby)(ref val)).Owner.Id);
			}
		}
	}
	internal class InGameMenu
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__InsertCustomUI;

			public static hook_OpenQuickMenu <1>__OpenQuickMenu;

			public static hook_CloseQuickMenu <2>__QuickMenuManager_CloseQuickMenu;
		}

		private static GameObject? QuickMenu;

		private static GameObject? DebugMenu;

		private static GameObject? LobbyCodeObj;

		private static GameObject? QuitObj;

		private static TextMeshProUGUI? LobbyCodeTextMesh;

		private static RectTransform? LobbyCodeRect;

		private static RectTransform? ResumeRect;

		[HookInit]
		private static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__InsertCustomUI;
			if (obj == null)
			{
				hook_Start val = InsertCustomUI;
				<>O.<0>__InsertCustomUI = val;
				obj = (object)val;
			}
			QuickMenuManager.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__OpenQuickMenu;
			if (obj2 == null)
			{
				hook_OpenQuickMenu val2 = OpenQuickMenu;
				<>O.<1>__OpenQuickMenu = val2;
				obj2 = (object)val2;
			}
			QuickMenuManager.OpenQuickMenu += (hook_OpenQuickMenu)obj2;
			object obj3 = <>O.<2>__QuickMenuManager_CloseQuickMenu;
			if (obj3 == null)
			{
				hook_CloseQuickMenu val3 = QuickMenuManager_CloseQuickMenu;
				<>O.<2>__QuickMenuManager_CloseQuickMenu = val3;
				obj3 = (object)val3;
			}
			QuickMenuManager.CloseQuickMenu += (hook_CloseQuickMenu)obj3;
		}

		private static void QuickMenuManager_CloseQuickMenu(orig_CloseQuickMenu orig, QuickMenuManager self)
		{
			orig.Invoke(self);
			if ((Object)(object)LobbyCodeTextMesh != (Object)null)
			{
				((TMP_Text)LobbyCodeTextMesh).text = "> Lobby Code";
			}
		}

		private static void OpenQuickMenu(orig_OpenQuickMenu orig, QuickMenuManager self)
		{
			orig.Invoke(self);
			AdjustLobbyCode();
			AddCrewCount();
		}

		private static void AddCrewCount()
		{
			//IL_0056: 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_0075: 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)
			GameObject? quickMenu = QuickMenu;
			TextMeshProUGUI val = ((quickMenu != null) ? ((Component)quickMenu.transform.Find("PlayerList/Image/Header")).GetComponentInChildren<TextMeshProUGUI>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				object arg = (StartOfRound.Instance?.connectedPlayersAmount ?? 0) + 1;
				Lobby value = GameNetworkManager.Instance.currentLobby.Value;
				object arg2 = ((Lobby)(ref value)).MaxMembers;
				value = GameNetworkManager.Instance.currentLobby.Value;
				((TMP_Text)val).text = string.Format("CREW ({0}/{1}):\n{2}", arg, arg2, ((Lobby)(ref value)).GetData("name"));
			}
		}

		private static void AdjustLobbyCode()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)LobbyCodeRect == (Object)null || (Object)(object)LobbyCodeObj == (Object)null)
			{
				return;
			}
			if ((Object)(object)DebugMenu != (Object)null && DebugMenu.activeSelf)
			{
				LobbyCodeObj.transform.SetParent(DebugMenu.transform);
				((Transform)LobbyCodeRect).localPosition = new Vector3(125f, 185f, 0f);
				((Transform)LobbyCodeRect).localScale = new Vector3(1f, 1f, 1f);
			}
			else if ((Object)(object)ResumeRect != (Object)null && (Object)(object)QuitObj != (Object)null)
			{
				GameObject? lobbyCodeObj = LobbyCodeObj;
				if (lobbyCodeObj != null)
				{
					lobbyCodeObj.transform.SetParent(QuitObj.transform.parent);
				}
				((Transform)LobbyCodeRect).localPosition = ((Transform)ResumeRect).localPosition + new Vector3(0f, -55.5941f, 0f);
				((Transform)LobbyCodeRect).localScale = ((Transform)ResumeRect).localScale;
			}
		}

		private static void InsertCustomUI(orig_Start orig, QuickMenuManager self)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			orig.Invoke(self);
			QuickMenu = GameObject.Find("/Systems/UI/Canvas/QuickMenu/");
			Transform obj = QuickMenu.transform.Find("DebugMenu");
			DebugMenu = ((obj != null) ? ((Component)obj).gameObject : null);
			Transform obj2 = QuickMenu.transform.Find("MainButtons/Quit/");
			QuitObj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			if (!((Object)(object)QuitObj == (Object)null))
			{
				ResumeRect = QuitObj.GetComponent<RectTransform>();
				LobbyCodeObj = Object.Instantiate<GameObject>(QuitObj.gameObject, QuitObj.transform.parent);
				LobbyCodeTextMesh = LobbyCodeObj.GetComponentInChildren<TextMeshProUGUI>();
				Button LobbyCodeButton = LobbyCodeObj.GetComponent<Button>();
				LobbyCodeRect = LobbyCodeObj.GetComponent<RectTransform>();
				((Transform)LobbyCodeRect).localPosition = QuitObj.transform.localPosition + new Vector3(0f, -55.5941f, 0f);
				((Transform)LobbyCodeRect).localScale = QuitObj.transform.localScale;
				((UnityEventBase)LobbyCodeButton.onClick).m_PersistentCalls.Clear();
				((UnityEvent)LobbyCodeButton.onClick).AddListener((UnityAction)delegate
				{
					((MonoBehaviour)LobbyCodeButton).StartCoroutine(CopyCode(LobbyCodeTextMesh));
				});
				((Object)LobbyCodeObj).name = "CopyLobbyCode";
				((TMP_Text)LobbyCodeTextMesh).text = "> Lobby Code";
			}
		}

		private static IEnumerator CopyCode(TextMeshProUGUI textMesh)
		{
			if (!GameNetworkManager.Instance.currentLobby.HasValue)
			{
				((TMP_Text)textMesh).text = "Can't get Lobby code!";
			}
			else
			{
				((TMP_Text)textMesh).text = "(Copied to clipboard!)";
				Lobby value = GameNetworkManager.Instance.currentLobby.Value;
				SteamId id = ((Lobby)(ref value)).Id;
				string text = ((object)(SteamId)(ref id)).ToString();
				string[] obj = new string[5] { "Lobby Code: ", text, "\nLobby Name: \"", null, null };
				value = GameNetworkManager.Instance.currentLobby.Value;
				obj[3] = ((Lobby)(ref value)).GetData("name");
				obj[4] = "\"";
				GUIUtility.systemCopyBuffer = string.Concat(obj);
				Plugin.Log.LogInfo((object)("Lobby code copied to clipboard: " + text));
			}
			yield return (object)new WaitForSeconds(1.2f);
			((TMP_Text)textMesh).text = "> Lobby Code";
		}
	}
	internal class LobbyConnection
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnEnable <0>__GameNetworkManager_OnEnable;

			public static Action<Lobby> <1>__SetPreviouslyJoinedLobby;
		}

		internal static Lobby? PreviousLobby;

		[HookInit]
		private static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__GameNetworkManager_OnEnable;
			if (obj == null)
			{
				hook_OnEnable val = GameNetworkManager_OnEnable;
				<>O.<0>__GameNetworkManager_OnEnable = val;
				obj = (object)val;
			}
			GameNetworkManager.OnEnable += (hook_OnEnable)obj;
		}

		private static void GameNetworkManager_OnEnable(orig_OnEnable orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			SteamMatchmaking.OnLobbyEntered += SetPreviouslyJoinedLobby;
		}

		private static void SetPreviouslyJoinedLobby(Lobby obj)
		{
			//IL_0019: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
			{
				PreviousLobby = obj;
				ManualLogSource log = Plugin.Log;
				Lobby value = PreviousLobby.Value;
				log.LogDebug((object)$"Setting previously joined lobby to {((Lobby)(ref value)).Id}");
			}
		}
	}
	internal class LobbyList
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_loadLobbyListAndFilter <0>__SteamLobbyManager_loadLobbyListAndFilter;
		}

		[HookInit]
		private static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__SteamLobbyManager_loadLobbyListAndFilter;
			if (obj == null)
			{
				hook_loadLobbyListAndFilter val = SteamLobbyManager_loadLobbyListAndFilter;
				<>O.<0>__SteamLobbyManager_loadLobbyListAndFilter = val;
				obj = (object)val;
			}
			SteamLobbyManager.loadLobbyListAndFilter += (hook_loadLobbyListAndFilter)obj;
		}

		private static IEnumerator SteamLobbyManager_loadLobbyListAndFilter(orig_loadLobbyListAndFilter orig, SteamLobbyManager self, Lobby[] lobbyList)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (LobbyConnection.PreviousLobby.HasValue)
			{
				if (!lobbyList.Contains(LobbyConnection.PreviousLobby.Value))
				{
					ArrayUtility.Add<Lobby>(lobbyList, lobbyList[0]);
					Plugin.Log.LogInfo((object)"Adding private lobby as rejoinable");
				}
				else
				{
					int num = MiscHelpers.IndexOf<Lobby>((IEnumerable<Lobby>)lobbyList, LobbyConnection.PreviousLobby.Value);
					lobbyList[num] = lobbyList[0];
				}
				lobbyList[0] = LobbyConnection.PreviousLobby.Value;
			}
			return orig.Invoke(self, lobbyList);
		}
	}
	internal class LobbySlot
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__LobbySlot_Awake;
		}

		[HookInit]
		private static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__LobbySlot_Awake;
			if (obj == null)
			{
				hook_Awake val = LobbySlot_Awake;
				<>O.<0>__LobbySlot_Awake = val;
				obj = (object)val;
			}
			LobbySlot.Awake += (hook_Awake)obj;
		}

		private static void LobbySlot_Awake(orig_Awake orig, LobbySlot self)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			LobbySlot self2 = self;
			orig.Invoke(self2);
			((TMP_Text)self2.playerCount).text = $"{((Lobby)(ref self2.thisLobby)).MemberCount} / {((Lobby)(ref self2.thisLobby)).MaxMembers}";
			Button componentInChildren = ((Component)self2).GetComponentInChildren<Button>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Button val = Object.Instantiate<Button>(componentInChildren, ((Component)componentInChildren).transform.parent);
				((Object)val).name = "LobbyCode";
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition -= new Vector2(78f, 0f);
				TextMeshProUGUI TextMesh = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)TextMesh).text = "Code";
				((UnityEventBase)val.onClick).m_PersistentCalls.Clear();
				((UnityEvent)val.onClick).AddListener((UnityAction)delegate
				{
					((MonoBehaviour)self2).StartCoroutine(CopyCode(self2, TextMesh));
				});
				((MonoBehaviour)self2).StartCoroutine(InitializeRejoin(self2, componentInChildren));
			}
		}

		private static IEnumerator CopyCode(LobbySlot lobbySlot, TextMeshProUGUI textMesh)
		{
			string text = ((object)(SteamId)(ref lobbySlot.lobbyId)).ToString();
			if (Utility.IsNullOrWhiteSpace(text))
			{
				((TMP_Text)textMesh).text = "Can't get Lobby code!";
			}
			else
			{
				GUIUtility.systemCopyBuffer = "Lobby Code: " + text + "\nLobby Name: \"" + ((TMP_Text)lobbySlot.LobbyName).text + "\"";
				Plugin.Log.LogInfo((object)("Lobby code copied to clipboard: " + text));
				((TMP_Text)textMesh).text = "Copied!";
			}
			yield return (object)new WaitForSeconds(1.2f);
			((TMP_Text)textMesh).text = "Code";
		}

		private static IEnumerator InitializeRejoin(LobbySlot lobbySlot, Button joinButton)
		{
			LobbySlot lobbySlot2 = lobbySlot;
			if (LobbyConnection.PreviousLobby.HasValue)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => SteamId.op_Implicit(((Lobby)(ref lobbySlot2.thisLobby)).Id) != 0));
				Lobby value = LobbyConnection.PreviousLobby.Value;
				if (SteamId.op_Implicit(((Lobby)(ref value)).Id) == SteamId.op_Implicit(lobbySlot2.lobbyId))
				{
					TextMeshProUGUI componentInChildren = ((Component)joinButton).GetComponentInChildren<TextMeshProUGUI>();
					((TMP_Text)componentInChildren).text = "Rejoin";
				}
			}
		}
	}
	internal class SteamLobbyManager
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnEnable <0>__SteamLobbyManager_OnEnable;
		}

		internal static SteamLobbyManager? Instance;

		[HookInit]
		private static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__SteamLobbyManager_OnEnable;
			if (obj == null)
			{
				hook_OnEnable val = SteamLobbyManager_OnEnable;
				<>O.<0>__SteamLobbyManager_OnEnable = val;
				obj = (object)val;
			}
			SteamLobbyManager.OnEnable += (hook_OnEnable)obj;
		}

		private static void SteamLobbyManager_OnEnable(orig_OnEnable orig, SteamLobbyManager self)
		{
			orig.Invoke(self);
			Instance = self;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}