示例#1
0
        public bool TryGet([NotNull] string playerId, [NotNull] out VoicePlayerState state)
        {
            if (playerId == null)
            {
                throw new ArgumentNullException("playerId");
            }

            return(_playersLookup.TryGetValue(playerId, out state));
        }
示例#2
0
        public void Add([NotNull] VoicePlayerState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            if (_playersLookup.ContainsKey(state.Name))
            {
                throw Log.CreatePossibleBugException("Attempted to add a duplicate player to the player collection", "1AA3B631-9813-4FDA-878B-06CD2226C179");
            }

            _players.Add(state);
            _playersLookup.Add(state.Name, state);
        }
示例#3
0
        public void RemovePlayer([NotNull] VoicePlayerState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state", "Cannot stop tracking a null player");
            }

            //Save the tracker. The player could rejoin the session, in which case we'd need this tracker again
            var tracker = state.Tracker;

            if (tracker != null)
            {
                _unlinkedPlayerTrackers.Add(tracker.PlayerId, tracker);
            }

            state.Tracker = null;
        }
示例#4
0
        public void AddPlayer([NotNull] VoicePlayerState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state", "Cannot start tracking a null player");
            }

            //We've got a player and we *might* already have the tracker for it. Search for an unlinked tracker
            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);
            }
        }