예제 #1
0
        private void endPublicLobbiesAction(IMyAsyncResult result, MyGuiScreenProgressAsync screen)
        {
            var loadResult = (LoadLobbyListResult)result;

            m_lobbies.Clear();

            if (m_showOnlyFriends.IsChecked)
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
            }
            else
            {
                LobbySearch.AddFriendLobbies(m_lobbies);
                LobbySearch.AddPublicLobbies(m_lobbies);
            }

            RefreshGameList();
            screen.CloseScreen();
        }
        private static void LobbiesRequestCompleted(Result result)
        {
            // if the request is ok
            if (result != Result.OK)
            {
                return;
            }

            var lobbies = new List <Lobby>();

            // Add all lobbies
            LobbySearch.AddPublicLobbies(lobbies);
            LobbySearch.AddFriendLobbies(lobbies);

            // search for new lobby
            foreach (var lobby in lobbies)
            {
                var owner = MyMultiplayerLobby.GetLobbyHostSteamId(lobby);
                if (owner == m_ownerId && lobby.LobbyId != m_oldLobbyId)
                {
                    //
                    MyScreenManager.RemoveScreenByType(typeof(MyGuiScreenProgress));
                    // Join the game
                    MyJoinGameHelper.JoinGame(lobby);
                    return;
                }
            }

            // Exit if the search is taking too long
            m_elapsedMs += 5000;
            if (m_elapsedMs > 120000)
            {
                // Remove the progress wheel
                MyScreenManager.RemoveScreenByType(typeof(MyGuiScreenProgress));
                return;
            }

            // Repeat the search
            FindLobby();
        }