private void Net_PlayerJoined([NotNull] string playerId) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse (Justification: Sanity check against network system returning incorrect values) // ReSharper disable once HeuristicUnreachableCode if (Log.AssertAndLogError(playerId != null, "86074592-4BAD-4DF5-9B2C-1DF42A68FAF8", "Received a player-joined event for a null player ID")) { return; } if (playerId == LocalPlayerName) { return; } //Get a playback component for this player var playback = _playbackPool.Get(playerId); //Create the state object for this player var state = new RemoteVoicePlayerState(playback); _players.Add(state); //Associate state with the position tracker for this player (if there is one) _playerTrackers.AddPlayer(state); //Now we've set everything up activate the playback playback.gameObject.SetActive(true); if (OnPlayerJoinedSession != null) { OnPlayerJoinedSession(state); } }
private void Net_PlayerJoined(string playerId) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse (Justification: Sanity check against network system returning incorrect values) if (playerId == null) { Log.Warn(Log.PossibleBugMessage("Received a player-joined event for a null player ID", "86074592-4BAD-4DF5-9B2C-1DF42A68FAF8")); return; } if (playerId == LocalPlayerName) { return; } //Get a playback component for this player var playback = _playbackPool.Get(); playback.transform.parent = transform; playback.gameObject.name = "Player " + playerId + " voice comms"; playback.PlayerName = playerId; //Create the state object for this player var state = new RemoteVoicePlayerState(playback); _players.Add(state); _playersLookup.Add(playerId, state); //Associate it with the position tracker for this player (if there is one) IDissonancePlayer tracker; if (_unlinkedPlayerTrackers.TryGetValue(state.Name, out tracker)) { state.Tracker = tracker; _unlinkedPlayerTrackers.Remove(state.Name); Log.Debug("Linked an unlinked player tracker for player '{0}'", state.Name); } playback.gameObject.SetActive(true); if (OnPlayerJoinedSession != null) { OnPlayerJoinedSession(state); } }