public void LobbySearchFinished(LobbyMatchList_t pLobbyMatchList)
        {
            lobbies.Clear();
            int numberOfResults = (int)pLobbyMatchList.m_nLobbiesMatching;
            int numberOfLobbies = 0;

            for (int i = 0; i < numberOfResults; i++)
            {
                CSteamID  lobby = SteamMatchmaking.GetLobbyByIndex(i);
                LobbyInfo info  = new LobbyInfo(lobby);
                if (info.UpdateLobbyInfo(lobby))
                {
                    lobbies.Add(info);
                    numberOfLobbies++;
                }
            }
            searching = false;
            {
                patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager);
                if ((patchPM.currentMainLoop is LobbyFinderMenu))
                {
                    (patchPM.currentMainLoop as LobbyFinderMenu).searchFinished(numberOfLobbies);
                }
            }
        }
        public void LobbyEntered(LobbyEnter_t enterLobby)
        {
            connectedPlayers.Clear();
            otherPlayers.Clear();
            ResetManagers();
            {
                if (!(RainWorldHK.mainRW.processManager.currentMainLoop is SteamMultiplayerMenu))
                {
                    ProcessManagerHK.ImmediateSwitchCustom(RainWorldHK.mainRW.processManager, new SteamMultiplayerMenu(RainWorldHK.mainRW.processManager));
                }
            }

            joining = false;
            lobbyID = (CSteamID)enterLobby.m_ulSteamIDLobby;
            int playerCount = SteamMatchmaking.GetNumLobbyMembers((CSteamID)enterLobby.m_ulSteamIDLobby);

            MultiplayerChat.AddChat("Entered Lobby!");

            //Send packets to all players, to establish P2P connections with them
            if (playerCount > 1)
            {
                for (int i = 0; i < playerCount; i++)
                {
                    CSteamID lobbyMember = SteamMatchmaking.GetLobbyMemberByIndex(lobbyID, i);
                    SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 0);
                    SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 1);
                    SteamNetworking.SendP2PPacket(lobbyMember, new byte[] { 255 }, 1, EP2PSend.k_EP2PSendReliable, 2);
                    if (!connectedPlayers.Contains(lobbyMember.m_SteamID))
                    {
                        connectedPlayers.Add(lobbyMember.m_SteamID);
                        PlayerJoinedManagers(lobbyMember.m_SteamID);
                    }
                    if (lobbyMember != SteamUser.GetSteamID())
                    {
                        otherPlayers.Add(lobbyMember.m_SteamID);
                    }
                }
            }

            //Set up network data
            NetworkGameManager.managerID = ulong.Parse(SteamMatchmaking.GetLobbyData(lobbyID, MANAGER_ID));
            NetworkGameManager.playerID  = SteamUser.GetSteamID().m_SteamID;
            if (NetworkGameManager.managerID != NetworkGameManager.playerID)
            {
                lobbyInfo = new LobbyInfo((CSteamID)enterLobby.m_ulSteamIDLobby);
                lobbyInfo.UpdateLobbyInfo((CSteamID)enterLobby.m_ulSteamIDLobby);
                lobbyInfo.owner = new CSteamID(NetworkGameManager.managerID);
            }

            if (!connectedPlayers.Contains(SteamUser.GetSteamID().m_SteamID))
            {
                connectedPlayers.Add(SteamUser.GetSteamID().m_SteamID);
                PlayerJoinedManagers(SteamUser.GetSteamID().m_SteamID);
            }

            MultiplayerChat.AddChat("This game's manager is " + SteamFriends.GetFriendPersonaName((CSteamID)NetworkGameManager.managerID));
            isInGame = true;
            Log("Entered Lobby! \nThis game's manager is " + SteamFriends.GetFriendPersonaName((CSteamID)NetworkGameManager.managerID));
        }