コード例 #1
0
        internal void RemovePlayer(Player player)
        {
            if (player.Id != 0)
            {
                //first need to inform the room, if there is one, of the player's disconnect.
                //Otherwise a new player might obtain the id and send that to a new room before this message gets there
                player.DisconnectOnRoom();

                //this will clean up the player whether or not they actually finished being added.
                lock (_players)
                {
                    _players.Remove(player.Id);
                    PlayerCount--;
                }

                Room.MovePlayerCount(this, player.CurrentRoomGuid, Guid.Empty);
            }

            //it is necessary that we still raise the event, in case users are doing something during verification
            try
            {
                PlayerRemoved?.Invoke(player);
            }
            catch (Exception e) { Debug.LogException(e); }
        }
コード例 #2
0
        /// <summary>
        /// called by rooms when a player finishes connecting
        /// </summary>
        internal void FinishedRoomSwitch()
        {
#if DEBUG
            Debug.Log($"Finished switching {this}");
#endif
            //update our actual room
            _currentRoom     = _switchingToRoom;
            _switchingToRoom = Guid.Empty;
            Room.MovePlayerCount(Server, _oldRoom, _currentRoom);
            _oldRoom = Guid.Empty;
            //and synchronize data
            SynchNetData();

            try
            {
                FinishedSwitchingRooms.Raise(Server.GetRoom(_currentRoom));
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            if (Interlocked.Exchange(ref _changingRooms, 0) != 1)
            {
                Debug.LogError($"Player {this} was marked as having finished switching rooms, but they were not actually in the process of doing so. This should never happen");
            }
        }
コード例 #3
0
        private void RemovePlayer(Player player)
        {
            if (player.Id == 0)
            {
                return;
            }

            //first need to inform the room, if there is one, of the player's disconnect.
            //Otherwise a new player might obtain the id and send that to a new room before this message gets there
            player.DisconnectOnRoom();

            //this will clean up the player whether or not they actually finished being added.
            lock (_players)
                _players.Remove(player.Id);

            Room.MovePlayerCount(this, player.CurrentRoomGuid, Guid.Empty);

            //todo: anything else? this is run on disconnect

            try
            {
                PlayerRemoved?.Invoke(player);
            }
            catch (Exception e) { Debug.LogException(e); }
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: GeekBrony/LoE-Ghost.Server
        /// <summary>
        /// called by rooms when a player finishes connecting
        /// </summary>
        internal void FinishedRoomSwitch()
        {
#if DEBUG
            Debug.Log($"Finished switching {this}");
#endif
            //update our actual room
            _currentRoom     = _switchingToRoom;
            _switchingToRoom = Guid.Empty;
            Room.MovePlayerCount(Server, _oldRoom, _currentRoom);
            _oldRoom = Guid.Empty;
            //and synchronize data
            SynchNetData();
            FinishedSwitchingRooms?.Invoke(Server.GetRoom(_currentRoom));
        }
コード例 #5
0
        internal void RemovePlayerNoNotify(Player player)
        {
            Debug.Log($"removing {player} from room, without notifying the room");

            if (player.Id == 0)
            {
                return;
            }

            //this will clean up the player whether or not they actually finished being added.
            lock (_players)
                _players.Remove(player.Id);

            Room.MovePlayerCount(this, player.CurrentRoomGuid, Guid.Empty);

            //todo: anything else? this is run on disconnect

            try
            {
                PlayerRemoved?.Invoke(player);
            }
            catch (Exception e) { Debug.LogException(e); }
        }