Example #1
0
        private void HidePlayer(Player player, bool hide)
        {
            Player existingPlayer = _playerEntities.Keys.FirstOrDefault(p => p.Username.Equals(player.Username));
            if (existingPlayer != null)
            {
                Entity entity;
                if (_playerEntities.TryGetValue(existingPlayer, out entity))
                {
                    _playerEntities.Remove(existingPlayer);
                    entity.DespawnEntity();
                }
            }

            Level level = player.Level;
            if (hide)
            {
                player.DespawnFromPlayers(level.GetSpawnedPlayers());
            }
            else
            {
                player.SpawnToPlayers(level.GetSpawnedPlayers());
            }
        }