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 LobbyChatUpdated(LobbyChatUpdate_t update) { try { EChatMemberStateChange change = (EChatMemberStateChange)update.m_rgfChatMemberStateChange; if (change == EChatMemberStateChange.k_EChatMemberStateChangeEntered) { MultiplayerChat.AddChat(string.Format("User {0} joined the game!", SteamFriends.GetFriendPersonaName(new CSteamID(update.m_ulSteamIDUserChanged)))); Log(string.Format("User {0} joined the game!", SteamFriends.GetFriendPersonaName(new CSteamID(update.m_ulSteamIDUserChanged)))); if (!connectedPlayers.Contains(update.m_ulSteamIDUserChanged)) { PlayerJoinedManagers(update.m_ulSteamIDUserChanged); connectedPlayers.Add(update.m_ulSteamIDUserChanged); } if (update.m_ulSteamIDUserChanged != SteamUser.GetSteamID().m_SteamID) { otherPlayers.Add(update.m_ulSteamIDUserChanged); } } else if (change == EChatMemberStateChange.k_EChatMemberStateChangeLeft || change == EChatMemberStateChange.k_EChatMemberStateChangeKicked || change == EChatMemberStateChange.k_EChatMemberStateChangeDisconnected) { MultiplayerChat.AddChat(string.Format("User {0} left the game!", SteamFriends.GetFriendPersonaName(new CSteamID(update.m_ulSteamIDUserChanged)))); Log(string.Format("User {0} left the game!", SteamFriends.GetFriendPersonaName(new CSteamID(update.m_ulSteamIDUserChanged)))); PlayerLeftManagers(update.m_ulSteamIDUserChanged); connectedPlayers.Remove(update.m_ulSteamIDUserChanged); MultiplayerPlayerList.RemovePlayerLabel(update.m_ulSteamIDUserChanged); if (update.m_ulSteamIDUserChanged != SteamUser.GetSteamID().m_SteamID) { otherPlayers.Remove(update.m_ulSteamIDUserChanged); } if (update.m_ulSteamIDUserChanged == NetworkGameManager.managerID) { patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); //if ((patchPM.currentMainLoop is MultiplayerSleepAndDeathScreen) || (patchPM.currentMainLoop is SteamMultiplayerMenu) if (patchPM.musicPlayer != null) { patchPM.musicPlayer.FadeOutAllSongs(5f); patchPM.musicPlayer.MenuRequestsSong("RW_8 - Sundown", 1.4f, 2f); } if (patchPM.currentMainLoop is RainWorldGame) { (patchPM.currentMainLoop as RainWorldGame).ExitToMenu(); } else { patchPM.RequestMainProcessSwitch(ProcessManager.ProcessID.MainMenu); } if (monklandUI != null) { monklandUI.ClearSprites(); monklandUI = null; } this.OnGameExit(); } } } catch (System.Exception e) { Debug.LogError(e); } }
public void JoinLobby(CSteamID lobby) { { patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); if (patchPM.currentMainLoop is SteamMultiplayerMenu) { if (lobbyID.m_SteamID != 0) { LeaveLobby(); } } } joining = true; SteamMatchmaking.JoinLobby(lobby); }
public void LobbyJoinRequested(GameLobbyJoinRequested_t request) //Shift-Tab Menu { { patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); if (patchPM.currentMainLoop is SteamMultiplayerMenu) { if (lobbyID.m_SteamID != 0) { LeaveLobby(); } } patchPM.ImmediateSwitchCustom(new SteamMultiplayerMenu(patchPM)); } joining = true; SteamMatchmaking.JoinLobby(request.m_steamIDLobby); }
public void LobbyKicked(LobbyKicked_t kickResult) { lobbyID = new CSteamID(0); lobbyInfo = new LobbyInfo(lobbyID); patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); if (patchPM.musicPlayer != null) { patchPM.musicPlayer.FadeOutAllSongs(5f); patchPM.musicPlayer.MenuRequestsSong("RW_8 - Sundown", 1.4f, 2f); } patchPM.RequestMainProcessSwitch(ProcessManager.ProcessID.MainMenu); Log("Kicked from Lobby!"); OnGameExit(); joining = false; }
public void LobbyEntered(LobbyEnter_t enterLobby) { connectedPlayers.Clear(); otherPlayers.Clear(); ResetManagers(); { patch_ProcessManager patchPM = ((patch_ProcessManager)Patches.patch_Rainworld.mainRW.processManager); if (!(patchPM.currentMainLoop is SteamMultiplayerMenu)) { patchPM.ImmediateSwitchCustom(new SteamMultiplayerMenu(patchPM)); } } 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)); }