本文整理汇总了C++中HousePtr::getMaxHabitants方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::getMaxHabitants方法的具体用法?C++ HousePtr::getMaxHabitants怎么用?C++ HousePtr::getMaxHabitants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::getMaxHabitants方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDestination
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();
}
}
示例2: update
void CityServiceEmigrant::update( const unsigned int time )
{
if( time % 44 != 1 )
return;
unsigned int vacantPop=0;
LandOverlays houses = _d->city->getBuildingList(B_HOUSE);
for( LandOverlays::iterator itHouse = houses.begin(); itHouse != houses.end(); ++itHouse )
{
HousePtr house = (*itHouse).as<House>();
if( house.isValid() && house->getAccessRoads().size() > 0 )
{
vacantPop += math::clamp( house->getMaxHabitants() - house->getNbHabitants(), 0, 0xff );
}
}
if( vacantPop == 0 )
{
return;
}
Walkers walkers = _d->city->getWalkerList( WT_EMIGRANT );
if( vacantPop <= walkers.size() * 5 )
{
return;
}
Tile& roadTile = _d->city->getTilemap().at( _d->city->getRoadEntry() );
EmigrantPtr emigrant = Emigrant::create( _d->city );
if( emigrant.isValid() )
{
emigrant->send2City( roadTile );
}
}