Beispiel #1
0
void Immigrant::onDestination()
{
    bool gooutCity = true;
    if( _d->destination.getI() > 0 && _d->destination.getJ() > 0 )  //have destination
    {
        const Tile& tile = _getCity()->getTilemap().at( _d->destination );

        HousePtr house = tile.getOverlay().as<House>();
        if( house.isValid() )
        {
            int freeRoom = house->getMaxHabitants() - house->getHabitants().count();
            if( freeRoom > 0 )
            {
                house->addHabitants( _d->peoples );
                Walker::onDestination();

                gooutCity = (_d->peoples.count() > 0);
            }
        }
    }

    if( gooutCity )
    {
        _findPath2blankHouse( _getCity()->getTilemap().at( getIJ() ) );
    }
    else
    {
        deleteLater();
    }
}
Beispiel #2
0
void Emigrant::_append2house( HousePtr house )
{
  int freeRoom = house->maxHabitants() - house->habitants().count();
  if( freeRoom > 0 )
  {
    house->addHabitants( _d->peoples );
    _lockHouse( HousePtr() );
  }
}