Decompiled source of PeakLobbies v1.0.4

BepInEx/patchers/PatchSteamLobbys.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using Steamworks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: AssemblyCompany("PatchSteamLobbys")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PatchSteamLobbys")]
[assembly: AssemblyTitle("PatchSteamLobbys")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PatchSteamLobbys;

public class LobbyUpdate
{
	public void OnLobbyList(LobbyMatchList_t list)
	{
	}
}
public static class Patcher
{
	public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };


	public static void Patch(AssemblyDefinition assembly)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		TypeDefinition type = assembly.MainModule.GetType("SteamLobbyHandler");
		if (type == null)
		{
			return;
		}
		foreach (MethodDefinition constructor in TypeDefinitionRocks.GetConstructors(type))
		{
			constructor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Ldarg_0));
			constructor.Body.Instructions.Insert(1, Instruction.Create(OpCodes.Ldftn, assembly.MainModule.ImportReference((MethodBase)typeof(LobbyUpdate).GetMethod("OnLobbyList", new Type[1] { typeof(LobbyMatchList_t) }))));
			constructor.Body.Instructions.Insert(2, Instruction.Create(OpCodes.Newobj, assembly.MainModule.ImportReference((MethodBase)typeof(DispatchDelegate<LobbyMatchList_t>).GetConstructors()[0])));
			constructor.Body.Instructions.Insert(3, Instruction.Create(OpCodes.Call, assembly.MainModule.ImportReference((MethodBase)typeof(Callback<LobbyMatchList_t>).GetMethod("Create", new Type[1] { typeof(DispatchDelegate<LobbyMatchList_t>) }))));
			constructor.Body.Instructions.Insert(4, Instruction.Create(OpCodes.Pop));
		}
	}

	public static void Initialize()
	{
		Console.WriteLine("PatchSteamLobby is work! By KoderTech");
	}
}

BepInEx/plugins/PeakLobbies.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PatchSteamLobbys;
using PeakLobbies.Component;
using PeakLobbies.Menu;
using PeakLobbies.Other;
using PeakLobbies.Patchs;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakLobbies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PeakLobbies")]
[assembly: AssemblyTitle("PeakLobbies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PeakLobbies
{
	[BepInPlugin("KoderTech.PeakLobbies", "PeakLobbies", "1.0.4")]
	internal class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin KoderTech.PeakLobbies is loaded!");
			Init();
			if (!File.Exists("./BepInEx/patchers/PatchSteamLobbys.dll"))
			{
				Logger.LogError((object)"There is no patch on the steam lobby. Therefore, the mod is disabled.");
				return;
			}
			Variables.InitHarmony();
			Variables.v_harmony.PatchAll(typeof(HookMenu));
			Variables.v_harmony.PatchAll(typeof(MainMenuPatch));
			Variables.v_harmony.PatchAll(typeof(NetworkConnectorPatch));
			Variables.v_harmony.PatchAll(typeof(PauseMenuPatch));
			Variables.v_harmony.PatchAll(typeof(AirportCheckInKioskPatch));
		}

		public void Init()
		{
			Variables.InitAssetBundle();
			if ((Object)(object)Variables.v_assetBundle == (Object)null)
			{
				Logger.LogInfo((object)("Error path: " + Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/'))));
			}
			Variables.InitCacheRoom();
			Variables.InitCacheRoomSteam();
			Variables.InitRooms();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PeakLobbies";

		public const string PLUGIN_NAME = "PeakLobbies";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace PeakLobbies.Patchs
{
	public class AirportCheckInKioskPatch : MonoBehaviourPun
	{
		[HarmonyPatch(typeof(AirportCheckInKiosk), "LoadIslandMaster")]
		[HarmonyPrefix]
		public static void AirportCheckInKiosk_LoadIslandMaster(AirportCheckInKiosk __instance)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Plugin.Logger.LogMessage((object)"Close Lobby Active");
				PhotonNetwork.CurrentRoom.IsVisible = false;
			}
		}
	}
	public class MainMenuPatch
	{
		[HarmonyPatch(typeof(MainMenu), "Update")]
		[HarmonyPostfix]
		public static void MainMenu_Update(MainMenu __instance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Unknown result type (might be due to invalid IL or missing references)
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0836: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)Variables.v_MenuFindLobby != (Object)null))
				{
					return;
				}
				Variables.v_MenuFindLobby.transform.GetChild(0).position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 190f, Variables.v_instanceMainMenu.credits.transform.position.y - 75f, Variables.v_instanceMainMenu.credits.transform.position.z);
				Variables.v_MenuPanel.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 190f, Variables.v_MenuPanel.transform.position.y, Variables.v_MenuPanel.transform.position.z);
				Variables.v_MenuLogoText.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 170f, Variables.v_MenuPanel.transform.position.y, Variables.v_MenuPanel.transform.position.z);
				Variables.v_MenuSwitchPhoton.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 300f, Variables.v_MenuPanel.transform.position.y - 50f, Variables.v_MenuPanel.transform.position.z);
				Variables.v_MenuSwitchSteam.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 90f, Variables.v_MenuPanel.transform.position.y - 50f, Variables.v_MenuPanel.transform.position.z);
				Variables.v_ButtonRefresh.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 400f, Variables.v_instanceMainMenu.credits.transform.position.y, Variables.v_instanceMainMenu.credits.transform.position.z);
				Variables.v_MenuText.SetActive(false);
				if (!Variables.v_isSteam)
				{
					foreach (KeyValuePair<string, RoomInfo> room2 in Variables.v_cachedRoomList)
					{
						if (!Variables.v_Rooms.Any((GameObject e) => ((Object)e).name == room2.Key))
						{
							GameObject val = DefaultControls.CreateButton(default(Resources));
							val.transform.parent = Variables.v_MenuFindLobby.transform.GetChild(0).GetChild(0).GetChild(0);
							val.GetComponentInChildren<Text>().text = string.Format("{0}\n{1} / {2}\nLicense: {3}", room2.Key, room2.Value.PlayerCount, room2.Value.MaxPlayers - 1, room2.Value.CustomProperties[(object)"License"].ToString());
							((Object)val).name = room2.Key ?? "";
							Vector2 val3 = (val.GetComponent<RectTransform>().sizeDelta = new Vector2(160f, 60f));
							Vector2 val4 = val3;
							((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
							{
								PhotonNetwork.LeaveLobby();
								GameObject.Find("Conn").GetComponent<PhotonConnect>().StartScene(room2.Value.Name);
							});
							Variables.v_Rooms.Add(val);
						}
						else if ((Object)(object)GameObject.Find(room2.Key) != (Object)null)
						{
							GameObject val5 = GameObject.Find(room2.Key);
							val5.GetComponentInChildren<Text>().text = string.Format("{0}\n {1} / {2}\nLicense: {3}", room2.Key, room2.Value.PlayerCount, room2.Value.MaxPlayers - 1, room2.Value.CustomProperties[(object)"License"].ToString());
						}
					}
					if (Variables.v_cachedRoomList.Count == 0 && (Object)(object)Variables.v_MenuText != (Object)null)
					{
						Variables.v_MenuText.SetActive(true);
						Variables.v_MenuText.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 170f, Variables.v_instanceMainMenu.credits.transform.position.y, Variables.v_instanceMainMenu.credits.transform.position.z);
					}
					return;
				}
				foreach (KeyValuePair<CSteamID, Variables.RoomSteam> room in Variables.v_cachedRoomListSteam)
				{
					CSteamID key;
					if (!Variables.v_Rooms.Any(delegate(GameObject e)
					{
						//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)
						string name = ((Object)e).name;
						CSteamID key2 = room.Key;
						return name == ((object)(CSteamID)(ref key2)).ToString();
					}))
					{
						GameObject val6 = DefaultControls.CreateButton(default(Resources));
						val6.transform.parent = Variables.v_MenuFindLobby.transform.GetChild(0).GetChild(0).GetChild(0);
						Text componentInChildren = val6.GetComponentInChildren<Text>();
						key = room.Key;
						componentInChildren.text = $"{((object)(CSteamID)(ref key)).ToString()}\n{room.Value.Player} / {room.Value.MaxPlayer - 1}";
						key = room.Key;
						((Object)val6).name = ((object)(CSteamID)(ref key)).ToString() ?? "";
						Vector2 val3 = (val6.GetComponent<RectTransform>().sizeDelta = new Vector2(160f, 60f));
						Vector2 val8 = val3;
						((UnityEvent)val6.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
						{
							//IL_000d: Unknown result type (might be due to invalid IL or missing references)
							//IL_0012: Unknown result type (might be due to invalid IL or missing references)
							PhotonNetwork.LeaveLobby();
							SteamMatchmaking.JoinLobby(room.Key);
						});
						Variables.v_Rooms.Add(val6);
					}
					else
					{
						key = room.Key;
						if ((Object)(object)GameObject.Find(((object)(CSteamID)(ref key)).ToString()) != (Object)null)
						{
							key = room.Key;
							GameObject val9 = GameObject.Find(((object)(CSteamID)(ref key)).ToString());
							Text componentInChildren2 = val9.GetComponentInChildren<Text>();
							key = room.Key;
							componentInChildren2.text = $"{((object)(CSteamID)(ref key)).ToString()}\n {room.Value.Player} / {room.Value.MaxPlayer - 1}";
						}
					}
				}
				if (Variables.v_cachedRoomListSteam.Count == 0 && (Object)(object)Variables.v_MenuText != (Object)null)
				{
					Variables.v_MenuText.SetActive(true);
					Variables.v_MenuText.transform.position = new Vector3(Variables.v_instanceMainMenu.credits.transform.position.x - 170f, Variables.v_instanceMainMenu.credits.transform.position.y, Variables.v_instanceMainMenu.credits.transform.position.z);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogInfo((object)ex.Message);
				Plugin.Logger.LogInfo((object)ex.Source);
				Plugin.Logger.LogInfo((object)ex.StackTrace);
			}
		}

		[HarmonyPatch(typeof(LobbyUpdate), "OnLobbyList")]
		[HarmonyPrefix]
		public static bool LobbyUpdate_OnLobbyList(LobbyMatchList_t list)
		{
			//IL_0001: 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_0047: 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_005e: 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_007a: 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)
			//IL_00ac: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			uint nLobbiesMatching = list.m_nLobbiesMatching;
			Plugin.Logger.LogInfo((object)(nLobbiesMatching + " Active Lobby Seacrh Patch"));
			if (nLobbiesMatching >= 0)
			{
				for (int i = 0; i < nLobbiesMatching; i++)
				{
					Variables.RoomSteam roomSteam = new Variables.RoomSteam();
					CSteamID lobbyByIndex = SteamMatchmaking.GetLobbyByIndex(i);
					string lobbyData = SteamMatchmaking.GetLobbyData(lobbyByIndex, "PeakVersion");
					BuildVersion val = new BuildVersion(Application.version);
					if (!(lobbyData != ((BuildVersion)(ref val)).ToMatchmaking()))
					{
						string lobbyData2 = SteamMatchmaking.GetLobbyData(lobbyByIndex, "CurrentScene");
						if (!(lobbyData2 != "Airport"))
						{
							roomSteam.Player = SteamMatchmaking.GetNumLobbyMembers(lobbyByIndex);
							roomSteam.MaxPlayer = SteamMatchmaking.GetLobbyMemberLimit(lobbyByIndex);
							ManualLogSource logger = Plugin.Logger;
							CSteamID val2 = lobbyByIndex;
							logger.LogInfo((object)("Lobby " + ((object)(CSteamID)(ref val2)).ToString()));
							Variables.v_cachedRoomListSteam[lobbyByIndex] = roomSteam;
						}
					}
				}
			}
			else
			{
				Plugin.Logger.LogInfo((object)"No Lobby!");
			}
			return false;
		}

		[HarmonyPatch(typeof(MainMenuMainPage), "PlayClicked")]
		[HarmonyPrefix]
		public static bool MainMenuMainPage_PlayClicked(MainMenuMainPage __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			PhotonNetwork.LeaveLobby();
			SteamMatchmaking.CreateLobby((ELobbyType)2, NetworkConnector.MAX_PLAYERS);
			return false;
		}

		[HarmonyPatch(typeof(MainMenuPageHandler), "GetPrettyStateName")]
		[HarmonyPrefix]
		public static bool MainMenuPageHandler_GetPrettyStateName(ref string __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0017: 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_0038: Expected I4, but got Unknown
			ClientState networkClientState = PhotonNetwork.NetworkClientState;
			ClientState val = networkClientState;
			ClientState val2 = val;
			if ((int)val2 != 1)
			{
				if ((int)val2 != 4)
				{
					switch (val2 - 12)
					{
					case 0:
					case 4:
					case 5:
						__result = "Connecting...";
						break;
					case 3:
						__result = "";
						break;
					default:
						__result = ((object)(ClientState)(ref networkClientState)).ToString();
						break;
					}
				}
				else
				{
					__result = "";
				}
			}
			else
			{
				__result = "Authenticating...";
			}
			return false;
		}
	}
	public class NetworkConnectorPatch
	{
		[HarmonyPatch(typeof(NetworkConnector), "HostRoomOptions")]
		[HarmonyPrefix]
		public static bool NetworkConnector_HostRoomOptions(NetworkConnector __instance, ref RoomOptions __result)
		{
			//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_002a: Expected O, but got Unknown
			//IL_002c: Expected O, but got Unknown
			//IL_002d: 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_003a: 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_004f: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			string[] customRoomPropertiesForLobby = new string[1] { "License" };
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"License", (object)CheckLicense.Test());
			Hashtable customRoomProperties = val;
			__result = new RoomOptions
			{
				IsVisible = true,
				IsOpen = true,
				MaxPlayers = NetworkConnector.MAX_PLAYERS + 1,
				PublishUserId = true,
				CustomRoomProperties = customRoomProperties,
				CustomRoomPropertiesForLobby = customRoomPropertiesForLobby
			};
			return false;
		}

		[HarmonyPatch(typeof(NetworkConnector), "HandleConnectionState")]
		[HarmonyPrefix]
		public static bool NetworkConnector_HandleConnectionState(NetworkConnector __instance, ref ConnectionState state)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			ConnectionState obj = state;
			HostState val = (HostState)(object)((obj is HostState) ? obj : null);
			if (val != null)
			{
				RoomOptions val2 = NetworkConnector.HostRoomOptions();
				PhotonNetwork.CreateRoom(SteamFriends.GetPersonaName(), val2, (TypedLobby)null, (string[])null);
			}
			JoinSpecificRoomState joinState = default(JoinSpecificRoomState);
			ref JoinSpecificRoomState reference = ref joinState;
			ConnectionState obj2 = state;
			reference = (JoinSpecificRoomState)(object)((obj2 is JoinSpecificRoomState) ? obj2 : null);
			if (joinState != null)
			{
				Debug.Log((object)("$Connecting to specific region: " + joinState.RegionToJoin + " with app ID " + PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime + ". Is currently connected to: " + PhotonNetwork.CloudRegion));
				if (PhotonNetwork.CloudRegion != joinState.RegionToJoin && !string.IsNullOrEmpty(joinState.RegionToJoin))
				{
					Debug.Log((object)("Disconnecting and reconnecting to specfic region: " + joinState.RegionToJoin));
					PhotonNetwork.Disconnect();
					((object)__instance).GetType().GetMethod("PrepareSteamAuthTicket", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Invoke(__instance, new object[1] { (object)(UnityAction)delegate
					{
						PhotonNetwork.ConnectToRegion(joinState.RegionToJoin);
					} });
				}
				else
				{
					Debug.Log((object)("Joining specific room: " + joinState.RoomName));
					PhotonNetwork.JoinRoom(joinState.RoomName, (string[])null);
				}
			}
			return false;
		}
	}
	public class PauseMenuPatch
	{
		[HarmonyPatch(typeof(PauseMenuMainPage), "OnQuitClicked")]
		[HarmonyPostfix]
		public static void PauseMenuMainPage_QuitClicked()
		{
			PhotonNetwork.LeaveLobby();
			Variables.v_cachedRoomList.Clear();
			Variables.v_Rooms.Clear();
			Variables.v_isLobby = false;
		}
	}
}
namespace PeakLobbies.Other
{
	internal class CheckLicense
	{
		public static bool Test()
		{
			if (File.Exists("./OnlineFix64.dll") | File.Exists("./SteamFix64.dll"))
			{
				return false;
			}
			return true;
		}
	}
	internal class Variables
	{
		internal class RoomSteam
		{
			public int Player { get; set; }

			public int MaxPlayer { get; set; }
		}

		internal const string Version = "1.0.4";

		internal static bool v_isLobby { get; set; }

		internal static Harmony v_harmony { get; set; }

		internal static AssetBundle v_assetBundle { get; set; }

		internal static MainMenu v_instanceMainMenu { get; set; }

		internal static GameObject v_ButtonPlayLobbys { get; set; }

		internal static GameObject v_ButtonRefresh { get; set; }

		internal static GameObject v_MenuFindLobby { get; set; }

		internal static GameObject v_MenuText { get; set; }

		internal static GameObject v_MenuPanel { get; set; }

		internal static GameObject v_MenuLogoText { get; set; }

		internal static GameObject v_MenuSwitchPhoton { get; set; }

		internal static GameObject v_MenuSwitchSteam { get; set; }

		internal static Dictionary<string, RoomInfo> v_cachedRoomList { get; set; }

		internal static Dictionary<CSteamID, RoomSteam> v_cachedRoomListSteam { get; set; }

		internal static List<GameObject> v_Rooms { get; set; }

		internal static bool v_isSteam { get; set; }

		internal static void InitHarmony()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			v_harmony = new Harmony("KoderTech.PeakLobbys");
		}

		internal static void InitAssetBundle()
		{
			v_assetBundle = AssetBundle.LoadFromFile(Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/')) + "/BepInEx/plugins/PeakLobbies/menulobby");
		}

		internal static void InitCacheRoom()
		{
			v_cachedRoomList = new Dictionary<string, RoomInfo>();
		}

		internal static void InitCacheRoomSteam()
		{
			v_cachedRoomListSteam = new Dictionary<CSteamID, RoomSteam>();
		}

		internal static void InitRooms()
		{
			v_Rooms = new List<GameObject>();
		}

		internal static void InitMenuMain(MainMenu main)
		{
			v_instanceMainMenu = main;
		}

		internal static void InitButtonPlayLobby(GameObject button)
		{
			v_ButtonPlayLobbys = button;
		}

		internal static void InitMenuFindLobby(GameObject menu)
		{
			v_MenuFindLobby = menu;
		}
	}
}
namespace PeakLobbies.Menu
{
	public class HookMenu : MonoBehaviour
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnClickLobbyButton;

			public static UnityAction <1>__OnClickSwitchPhoton;

			public static UnityAction <2>__OnClickSwitchSteam;
		}

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

			public static UnityAction <>9__0_0;

			internal void <MainMenu_Initialize>b__0_0()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				SteamMatchmaking.RequestLobbyList();
				Plugin.Logger.LogMessage((object)"Refresh");
			}
		}

		[HarmonyPatch(typeof(MainMenu), "Initialize")]
		[HarmonyPostfix]
		public static void MainMenu_Initialize(MainMenu __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: 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_02a0: 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_02ab: Expected O, but got Unknown
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: 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_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected O, but got Unknown
			Variables.InitMenuMain(__instance);
			GameObject val = GameObject.Find("Button_PlayWithFriends");
			GameObject val2 = Object.Instantiate<GameObject>(val);
			val2.transform.parent = GameObject.Find("Buttons").transform;
			((Object)val2).name = "Button_PlayLobbys";
			Variables.InitButtonPlayLobby(val2);
			Button component = val2.GetComponent<Button>();
			val2.transform.position = new Vector3(867.6552f, 566.6418f, 0f);
			val2.transform.localPosition = new Vector3(68.4034f, 179.1612f, 0f);
			val2.transform.localScale = new Vector3(1f, 1f, 1f);
			((UnityEventBase)component.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick = component.onClick;
			object obj = <>O.<0>__OnClickLobbyButton;
			if (obj == null)
			{
				UnityAction val3 = OnClickLobbyButton;
				<>O.<0>__OnClickLobbyButton = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject val4 = Variables.v_assetBundle.LoadAsset<GameObject>("Assets/Canvas.prefab");
			GameObject val5 = Object.Instantiate<GameObject>(val4);
			Variables.InitMenuFindLobby(val5);
			((HorizontalOrVerticalLayoutGroup)((Component)val5.transform.GetChild(0).GetChild(0).GetChild(0)).GetComponent<VerticalLayoutGroup>()).spacing = 10f;
			GameObject val6 = new GameObject("Conn");
			val6.AddComponent<PhotonConnect>();
			GameObject val7 = new GameObject("TextEmpty");
			val7.AddComponent<CanvasRenderer>();
			((TMP_Text)val7.AddComponent<TextMeshProUGUI>()).text = "There are no active rooms";
			((TMP_Text)val7.GetComponent<TextMeshProUGUI>()).fontSize = 26f;
			((Graphic)val7.GetComponent<TextMeshProUGUI>()).color = Color.grey;
			val7.transform.parent = val5.transform;
			Variables.v_MenuText = val7;
			GameObject val8 = GameObject.Find("PanelMain");
			val8.GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 150f);
			Variables.v_MenuPanel = val8;
			GameObject val9 = new GameObject("TextLogo");
			val9.transform.parent = val8.transform;
			val9.AddComponent<CanvasRenderer>();
			((TMP_Text)val9.AddComponent<TextMeshProUGUI>()).text = "PeakLobbies";
			((TMP_Text)val9.GetComponent<TextMeshProUGUI>()).fontSize = 26f;
			((Graphic)val9.GetComponent<TextMeshProUGUI>()).color = Color.white;
			Variables.v_MenuLogoText = val9;
			GameObject val10 = DefaultControls.CreateButton(default(Resources));
			val10.transform.parent = val8.transform;
			val10.GetComponentInChildren<Text>().text = "Photon";
			((Graphic)val10.GetComponentInChildren<Text>()).color = Color.gray;
			ButtonClickedEvent onClick2 = val10.GetComponent<Button>().onClick;
			object obj2 = <>O.<1>__OnClickSwitchPhoton;
			if (obj2 == null)
			{
				UnityAction val11 = OnClickSwitchPhoton;
				<>O.<1>__OnClickSwitchPhoton = val11;
				obj2 = (object)val11;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			Variables.v_MenuSwitchPhoton = val10;
			GameObject val12 = DefaultControls.CreateButton(default(Resources));
			val12.transform.parent = val8.transform;
			val12.GetComponentInChildren<Text>().text = "Steam";
			((Graphic)val12.GetComponentInChildren<Text>()).color = Color.gray;
			ButtonClickedEvent onClick3 = val12.GetComponent<Button>().onClick;
			object obj3 = <>O.<2>__OnClickSwitchSteam;
			if (obj3 == null)
			{
				UnityAction val13 = OnClickSwitchSteam;
				<>O.<2>__OnClickSwitchSteam = val13;
				obj3 = (object)val13;
			}
			((UnityEvent)onClick3).AddListener((UnityAction)obj3);
			Variables.v_MenuSwitchSteam = val12;
			GameObject val14 = DefaultControls.CreateButton(default(Resources));
			val14.transform.parent = val8.transform;
			val14.GetComponentInChildren<Text>().text = "Refresh";
			((Graphic)val14.GetComponentInChildren<Text>()).color = Color.gray;
			ButtonClickedEvent onClick4 = val14.GetComponent<Button>().onClick;
			object obj4 = <>c.<>9__0_0;
			if (obj4 == null)
			{
				UnityAction val15 = delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					SteamMatchmaking.RequestLobbyList();
					Plugin.Logger.LogMessage((object)"Refresh");
				};
				<>c.<>9__0_0 = val15;
				obj4 = (object)val15;
			}
			((UnityEvent)onClick4).AddListener((UnityAction)obj4);
			Variables.v_ButtonRefresh = val14;
			Variables.v_MenuFindLobby.SetActive(false);
			Variables.v_isSteam = false;
			Variables.v_ButtonRefresh.SetActive(false);
			Plugin.Logger.LogMessage((object)"Init Menu Lobby!");
		}

		[HarmonyPatch(typeof(MainMenu), "Update")]
		[HarmonyPostfix]
		public static void MainMenu_Update()
		{
			TextMeshProUGUI componentInChildren = Variables.v_ButtonPlayLobbys.GetComponentInChildren<TextMeshProUGUI>();
			if (((TMP_Text)componentInChildren).text != "Find Rooms")
			{
				((TMP_Text)componentInChildren).text = "Find Rooms";
			}
		}

		public static void OnClickLobbyButton()
		{
			Variables.v_MenuFindLobby.SetActive(!Variables.v_MenuFindLobby.activeSelf);
		}

		public static void ClearChildsContent()
		{
			for (int i = 0; i < Variables.v_MenuFindLobby.transform.GetChild(0).GetChild(0).GetChild(0)
				.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)Variables.v_MenuFindLobby.transform.GetChild(0).GetChild(0).GetChild(0)
					.GetChild(i)).gameObject);
			}
		}

		public static void OnClickSwitchPhoton()
		{
			Variables.v_ButtonRefresh.SetActive(false);
			ClearChildsContent();
			Variables.v_Rooms.Clear();
			Variables.v_isSteam = false;
		}

		public static void OnClickSwitchSteam()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Variables.v_ButtonRefresh.SetActive(true);
			ClearChildsContent();
			Variables.v_Rooms.Clear();
			SteamMatchmaking.RequestLobbyList();
			Variables.v_isSteam = true;
		}
	}
}
namespace PeakLobbies.Component
{
	public class PhotonConnect : MonoBehaviourPunCallbacks
	{
		public override void OnRoomListUpdate(List<RoomInfo> roomList)
		{
			Plugin.Logger.LogInfo((object)("Active Rooms: " + roomList.Count));
			for (int i = 0; i < roomList.Count; i++)
			{
				RoomInfo val = roomList[i];
				if (val.RemovedFromList)
				{
					if ((Object)(object)GameObject.Find(val.Name) != (Object)null)
					{
						Variables.v_cachedRoomList.Remove(val.Name);
						Variables.v_Rooms.Remove(GameObject.Find(val.Name));
						Object.Destroy((Object)(object)GameObject.Find(val.Name));
					}
				}
				else
				{
					Variables.v_cachedRoomList[val.Name] = val;
				}
			}
		}

		private void Start()
		{
			BuildVersion val = default(BuildVersion);
			((BuildVersion)(ref val))..ctor(Application.version);
			PhotonNetwork.AutomaticallySyncScene = true;
			PhotonNetwork.GameVersion = ((object)(BuildVersion)(ref val)).ToString();
			PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion = ((BuildVersion)(ref val)).ToMatchmaking();
			PhotonNetwork.ConnectUsingSettings();
			Plugin.Logger.LogInfo((object)"PhotonConnect Start Work!");
		}

		private void LateUpdate()
		{
			if ((Object)(object)GameObject.Find("WhiteFade") == (Object)null && !Variables.v_isLobby)
			{
				PhotonNetwork.JoinLobby();
				Variables.v_isLobby = true;
			}
		}

		public async void StartScene(string name)
		{
			JoinSpecificRoomState joinSpecificRoomState = ((StateMachine<ConnectionState>)(object)GameHandler.GetService<ConnectionService>().StateMachine).SwitchState<JoinSpecificRoomState>(false);
			joinSpecificRoomState.RoomName = name;
			joinSpecificRoomState.RegionToJoin = "eu";
			Variables.v_cachedRoomList.Clear();
			Variables.v_Rooms.Clear();
			Awaiter val = AsyncOperationAwaitableExtensions.GetAwaiter(SceneManager.LoadSceneAsync("Airport"));
			if (!((Awaiter)(ref val)).IsCompleted)
			{
				await val;
				Awaiter val2 = default(Awaiter);
				val = val2;
			}
			((Awaiter)(ref val)).GetResult();
		}

		public override void OnConnectedToMaster()
		{
			((MonoBehaviourPunCallbacks)this).OnConnectedToMaster();
		}
	}
}