/// <summary> /// Called when the local player joins the lobby. /// </summary> /// <param name="connection"></param> private void OnLobbyLocalPeerConnected(SteamConnection connection) { network.LocalConnection = connection; network.MaxPlayers = SteamMatchmaking.GetLobbyMemberLimit(connection.LobbyID); network.OnSetDefaultLobbyMemberData(connection); // Get Lobby Member Data int numMembers = SteamMatchmaking.GetNumLobbyMembers(connection.LobbyID); for (int i = 0; i < numMembers; i++) { CSteamID id = SteamMatchmaking.GetLobbyMemberByIndex(connection.LobbyID, i); if (id == connection.SteamID) { continue; } connection.AddConnection(id); } //GetModule<AuthModule>().BeginAuthentication(authenticationLevel); if (connection.IsHost) { HostSetup?.Invoke(connection); } else { ClientSetup?.Invoke(connection); } connection.IsConnected = true; }
/// <summary> /// Called when the local player disconnects. Resets the status of the network manager to default. /// </summary> /// <param name="peer"></param> private void OnLobbyLocalPeerDisconnected(SteamConnection peer) { //isActive = false; //GetModule<AuthModule>().CancelAuthTicket(); //if (GetModule<LobbyModule>().LobbyDisconnected != null) //{ // GetModule<LobbyModule>().LobbyDisconnected.Invoke(); //} //peer.Dispose(); //var modules = GetComponentsInChildren<NetworkModule>(); //foreach (var mod in modules) //{ // mod.Unload(this); // AddModule(mod); //} //isActive = true; }
/// <summary> /// Called when a player sucessfully finds a lobby to join. Starts the tranistion to the lobby scene: <see cref="HVR_MultiplayerSetup.LobbyScene"/> /// <para/> /// Assigns the scene load event <see cref="JoinNewMatch(Scene, LoadSceneMode)"/> to be called when the lobby scene is loaded. /// </summary> /// <param name="pCallback"></param> private void OnLobbyEntered(LobbyEnter_t pCallback) { if (NetLogFilter.logInfo) { Debug.Log($"Lobby Entered | ({Time.time})"); } CSteamID id = SteamUser.GetSteamID(); if (id.IsValid()) { SteamConnection conn = new SteamConnection(id, new CSteamID(pCallback.m_ulSteamIDLobby)); LobbyLocalConnectionConnected?.Invoke(conn); } else { if (NetLogFilter.logError) { Debug.Log("<color=red>SteamID is Invalid</color>"); } } }
public void OnSetDefaultLobbyMemberData(SteamConnection conn) { var result = SetDefaultLobbyMemberData?.Invoke(); SteamMatchmaking.SetLobbyMemberData(conn.LobbyID, SteamNetworkLobby.LobbyMemberData, result); }