public static void Disconnect() { try { Logger.Debug($"Disconnect from current lobby"); SteamMatchmaking.SetLobbyMemberData(_lobbyInfo.LobbyID, "STATUS", "DISCONNECTED"); Controllers.PlayerController.Instance.StopBroadcasting(); _lobbyInfo.HostName = ""; SendLobbyInfo(true); Connection = ConnectionState.DISCONNECTED; SteamMatchmaking.LeaveLobby(_lobbyInfo.LobbyID); Controllers.PlayerController.Instance.DestroyAvatars(); WaitingMenu.firstInit = true; WaitingMenu.queuedSong = null; _lobbyInfo = new LobbyInfo(); UpdateUserInfo(); Scoreboard.Instance.RemoveAll(); SongListUtils.InSong = false; Controllers.PlayerController.Instance._playerInfo = new PlayerInfo(GetUserName(), GetUserID()); LobbyData.Clear(); } catch (Exception e) { Logger.Error(e); } }
public static void Init() { UpdateUserInfo(); OnLobbyMatchListCallResult = CallResult <LobbyMatchList_t> .Create(OnLobbyMatchList); OnLobbyCreatedCallResult = CallResult <LobbyCreated_t> .Create(OnLobbyCreated); callbacks = new SteamCallbacks(); _lobbyInfo = new LobbyInfo(); string[] args = System.Environment.GetCommandLineArgs(); string input = ""; for (int i = 0; i < args.Length; i++) { if (args[i] == "+connect_lobby" && args.Length > i + 1) { input = args[i + 1]; } } if (!string.IsNullOrEmpty(input)) { ulong lobbyId = Convert.ToUInt64(input); if (lobbyId > 0) { Logger.Debug($"Game was started with +connect_lobby, lets join it @ {lobbyId}"); JoinLobby(new CSteamID(lobbyId)); } } }
public static void OnLobbyMatchList(LobbyMatchList_t pCallback, bool bIOFailure) { if (!SteamManager.Initialized) { Logger.Error("CONNECTION FAILED"); return; } uint numLobbies = pCallback.m_nLobbiesMatching; Logger.Debug($"Found {numLobbies} total lobbies"); LobbyData.Clear(); MultiplayerListing.refreshLobbyList(); try { for (int i = 0; i < numLobbies; i++) { CSteamID lobbyId = SteamMatchmaking.GetLobbyByIndex(i); if (lobbyId.m_SteamID == _lobbyInfo.LobbyID.m_SteamID) { continue; } LobbyInfo info = new LobbyInfo(SteamMatchmaking.GetLobbyData(lobbyId, "LOBBY_INFO")); SetOtherLobbyData(lobbyId.m_SteamID, info, false); Logger.Info($"{info.HostName} has {info.UsedSlots} users in it and is currently {info.Status}"); } } catch (Exception e) { Logger.Error(e); } MultiplayerListing.refreshLobbyList(); }
public static void SetOtherLobbyData(ulong lobbyId, LobbyInfo info, bool refresh = true) { string version = SteamMatchmaking.GetLobbyData(new CSteamID(lobbyId), "version"); info.UsedSlots = SteamMatchmaking.GetNumLobbyMembers(new CSteamID(lobbyId)); if (info.UsedSlots > 0 && info.HostName != "" && version == PACKET_VERSION) { LobbyData.Add(lobbyId, info); MultiplayerListing.refreshLobbyList(); } }
public void OnLobbyDataUpdate(LobbyDataUpdate_t pCallback) { if (pCallback.m_ulSteamIDLobby == pCallback.m_ulSteamIDMember) { LobbyInfo info = new LobbyInfo(SteamMatchmaking.GetLobbyData(new CSteamID(pCallback.m_ulSteamIDLobby), "LOBBY_INFO")); if (pCallback.m_ulSteamIDLobby == 0) { return; } Logger.Debug($"Received: {info.ToString()}"); if (pCallback.m_ulSteamIDLobby == SteamAPI.getLobbyID().m_SteamID) { SteamAPI.UpdateLobbyInfo(info); if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.WAITING)) { currentScreen = info.Screen; Logger.Debug($"Song has been selected, going to the waiting screen"); WaitingMenu.Instance.Present(); } else if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.MENU)) { currentScreen = info.Screen; Logger.Debug($"Song has finished, updating state to menu"); GameController.Instance.SongFinished(null, null, null, null); } else if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.PLAY_SONG)) { currentScreen = info.Screen; Logger.Debug($"Host requested to play the current song {info.CurrentSongId}"); LevelSO song = SongListUtils.GetInstalledSong(); if (SteamAPI.IsHost()) { SteamAPI.setLobbyStatus("Playing " + song.songName + " by " + song.songAuthorName); } SteamAPI.ClearPlayerReady(new CSteamID(SteamAPI.GetUserID()), true); SongListUtils.StartSong(song, SteamAPI.GetSongDifficulty(), info.GameplayModifiers); } } else { SteamAPI.SetOtherLobbyData(pCallback.m_ulSteamIDLobby, info); } } else { string status = SteamMatchmaking.GetLobbyMemberData(new CSteamID(pCallback.m_ulSteamIDLobby), new CSteamID(pCallback.m_ulSteamIDMember), "STATUS"); if (status == "DISCONNECTED") { SteamAPI.DisconnectPlayer(pCallback.m_ulSteamIDMember); } else if (status.StartsWith("KICKED")) { ulong playerId = Convert.ToUInt64(status.Substring(7)); if (playerId != 0 && playerId == SteamAPI.GetUserID()) { SteamAPI.Disconnect(); } } } }
public static void UpdateLobbyInfo(LobbyInfo info) { _lobbyInfo = info; }