public void BuyShip(PlayerShip player, ShipType shipType, SpaceStation atStation)
    {
        var shipForSale = GetShipForSale(shipType);
        var oldShip = player.Ship;

        //check price
        Debug.Assert(player.Money >= shipForSale.Price, 
            "player can't afford to buy ship");

        var passengers = oldShip.GetPassengers();
        var captain = oldShip.GetCaptain();

        //check crew space
        Debug.Assert(shipForSale.ShipType.Stats.PassengerCapacity < passengers.Count(),
            "ship being bought doesn't have enough room for existing passengers");

        var newShip = shipType.CreateShip(player.transform.position, player.transform.rotation);
        
        //copy player
        var newPlayer = newShip.gameObject.AddComponent<PlayerShip>();
        newPlayer.AddMoney(player.Money - shipForSale.Price);

        //copy crew
        captain.Assign(newShip, CrewAssignment.Captain);
        foreach (var passenger in passengers)
        {
            passenger.Assign(newShip, CrewAssignment.Passenger);
        }
            
        Destroy(player.gameObject);
        SpaceTraderConfig.LocalPlayer = newPlayer;
    }