public void Refresh() { if (!refreshing) { ServerListingUI.Clear(); switch (roomMode) { case RoomDisplayMode.dedicated: AddServers(); break; case RoomDisplayMode.hosted: AddLobbies(); break; case RoomDisplayMode.both: AddServers(); AddLobbies(); break; default: break; } } }
/// <summary> /// Spawns the listing UI prefab and initializes it's values /// </summary> /// <param name="server"></param> public static void CreateServerListing(Steamworks.Data.ServerInfo server) { if (MainMenu.singleton.serverListingParent != null) { ServerListingUI s = Instantiate(MainMenu.singleton.serverListingPrefab, MainMenu.singleton.serverListingParent).GetComponent <ServerListingUI>(); s.isDedicated = true; s.server = server; s.InitServer(); } }
/// <summary> /// Spawns the listing UI prefab and initializes it's values /// </summary> /// <param name="server"></param> public static void CreateLobbyListing(Steamworks.Data.Lobby lobby) { if (MainMenu.singleton.serverListingParent != null) { ServerListingUI s = Instantiate(MainMenu.singleton.serverListingPrefab, MainMenu.singleton.serverListingParent).GetComponent <ServerListingUI>(); s.isDedicated = false; s.lobby = lobby; s.InitLobby(); } }
/// <summary> /// Refreshes the list of lobbies. This is usually connected to a button. /// </summary> private async void AddLobbies() { var responsive = await SteamManager.singleton.ResponsiveLobbies(); // Now sort based on pingSortLowToHigh bool and populationSortLowToHighBool PingSort(ref responsive); PopulationSort(ref responsive); foreach (var lobby in responsive) { ServerListingUI.CreateLobbyListing(lobby); } }
/// <summary> /// Refreshes the list of servers. This is usually connected to a button. /// </summary> private async void AddServers() { refreshing = true; var responsive = await SteamManager.singleton.ResponsiveServers(); // Now sort based on pingSortLowToHigh bool and populationSortLowToHighBool PingSort(ref responsive); PopulationSort(ref responsive); foreach (var server in responsive) { ServerListingUI.CreateServerListing(server); } refreshing = false; }