本文整理汇总了C++中HousePtr::habitants方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::habitants方法的具体用法?C++ HousePtr::habitants怎么用?C++ HousePtr::habitants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::habitants方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _checkNearestHouse
bool Emigrant::_checkNearestHouse()
{
city::Helper helper( _city() );
for( int k=1; k < 3; k++ )
{
TilePos offset( k, k );
HouseList houses = helper.find<House>( building::house, pos()-offset, pos() + offset );
std::map< int, HousePtr > vacantRoomPriority;
foreach( it, houses )
{
HousePtr house = *it;
unsigned int freeRoom = house->maxHabitants() - house->habitants().count();
vacantRoomPriority[ 1000 - freeRoom ] = house;
}
foreach( it, vacantRoomPriority ) //have destination
{
HousePtr house = it->second;
int freeRoom = house->maxHabitants() - house->habitants().count();
if( freeRoom > 0 )
{
Pathway pathway = PathwayHelper::create( pos(), house->pos(), makeDelegate( _d.data(), &Impl::mayWalk ) );
_updatePathway( pathway );
go();
return true;
}
}
示例2: drawTile
void Unemployed::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
WorkingBuildingPtr workBuilding = overlay.as<WorkingBuilding>();
int worklessPercent = 0;
if( _isVisibleObject( overlay->type() ) )
{
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = overlay.as<House>();
int worklessNumber = (int)house->getServiceValue( Service::recruter );
int matureNumber = (int)house->habitants().mature_n();
worklessPercent = math::percentage( worklessNumber, matureNumber );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else if( workBuilding.isValid() )
{
worklessPercent = math::percentage( workBuilding->needWorkers(), workBuilding->maximumWorkers() );
needDrawAnimations = workBuilding->needWorkers() > 0;
if( !needDrawAnimations )
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( worklessPercent > 0 )
{
drawColumn( engine, screenPos, worklessPercent );
}
}
tile.setWasDrawn();
}
示例3: drawTile
void Health::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
int healthLevel = -1;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( _flags.count( overlay->type() ) )
{
needDrawAnimations = true;
//city::Helper helper( _city() );
//drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
else if( overlay->type() == object::house )
{
HousePtr house = ptr_cast<House>( overlay );
healthLevel = _getLevelValue( house );
needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else //other buildings
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( healthLevel > 0 )
{
drawColumn( engine, screenPos, healthLevel );
}
}
tile.setWasDrawn();
}
示例4: drawTile
void Tax::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
engine.draw( tile.picture(), screenPos );
}
else
{
bool needDrawAnimations = false;
TileOverlayPtr overlay = tile.overlay();
int taxLevel = -1;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( overlay->type() == objects::house )
{
HousePtr house = ptr_cast<House>( overlay );
//taxLevel = house->getServiceValue( Service::forum );
taxLevel = math::clamp<int>( house->taxesThisYear(), 0, 100 );
needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());
if( needDrawAnimations )
{
int taxAccess = house->hasServiceAccess( Service::forum );
needDrawAnimations = (taxAccess < 25);
}
if( !needDrawAnimations )
{
city::Helper helper( _city() );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else
{
city::Helper helper( _city() );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( taxLevel > 0 )
{
_addColumn( screenPos, taxLevel );
//drawColumn( engine, screenPos, taxLevel );
}
}
tile.setWasDrawn();
}
示例5: HousePtr
void Emigrant::_append2house( HousePtr house )
{
int freeRoom = house->maxHabitants() - house->habitants().count();
if( freeRoom > 0 )
{
house->addHabitants( _d->peoples );
_lockHouse( HousePtr() );
}
}
示例6: drawTile
void Religion::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
int religionLevel = -1;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = ptr_cast<House>( overlay );
religionLevel = (int) house->getServiceValue(Service::religionMercury);
religionLevel += house->getServiceValue(Service::religionVenus);
religionLevel += house->getServiceValue(Service::religionMars);
religionLevel += house->getServiceValue(Service::religionNeptune);
religionLevel += house->getServiceValue(Service::religionCeres);
religionLevel = math::clamp( religionLevel / (house->spec().minReligionLevel()+1), 0, 100 );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( religionLevel > 0 )
{
drawColumn( engine, screenPos, religionLevel );
}
}
tile.setWasDrawn();
}
示例7: foreach
foreach( it, buildings )
{
if( (*it)->type() == object::house )
{
HousePtr house = it->as<House>();
TilePos pos = house->pos();
int hash = (pos.i() << 8) | pos.i();
_d->servedHouses[ hash ] = house->habitants().count();
}
}
示例8: drawTile
void Fire::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
int fireLevel = 0;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = ptr_cast<House>( overlay );
fireLevel = (int)house->state( pr::fire );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
else //other buildings
{
ConstructionPtr constr = ptr_cast<Construction>( overlay );
if( constr != 0 )
{
fireLevel = (int)constr->state( pr::fire );
}
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( fireLevel >= 0)
{
_addColumn( screenPos, fireLevel );
}
}
tile.setWasDrawn();
}
示例9: drawTile
void Sentiment::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
int sentimentLevel = 0;
if( _isVisibleObject( overlay->type() ) )
{
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = overlay.as<House>();
sentimentLevel = (int)house->state( pr::happiness );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( sentimentLevel > 0 )
{
drawColumn( engine, screenPos, 100 - sentimentLevel );
}
}
tile.setWasDrawn();
}
示例10: drawTile
void LayerEntertainment::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
engine.draw( tile.picture(), screenPos );
}
else
{
bool needDrawAnimations = false;
TileOverlayPtr overlay = tile.overlay();
int entertainmentLevel = -1;
switch( overlay->type() )
{
// Base set of visible objects
case construction::road:
case construction::plaza:
case construction::garden:
case building::burnedRuins:
case building::collapsedRuins:
case building::lowBridge:
case building::highBridge:
case building::elevation:
case building::rift:
needDrawAnimations = true;
break;
case building::theater:
case building::amphitheater:
case building::colloseum:
case building::hippodrome:
case building::lionsNursery:
case building::actorColony:
case building::gladiatorSchool:
needDrawAnimations = _flags.count( overlay->type() ) > 0;
if( !needDrawAnimations )
{
city::Helper helper( _city() );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
//houses
case building::house:
{
HousePtr house = ptr_cast<House>( overlay );
entertainmentLevel = _getLevelValue( house );
needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());
city::Helper helper( _city() );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
break;
//other buildings
default:
{
city::Helper helper( _city() );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( entertainmentLevel > 0 )
{
_addColumn( screenPos, entertainmentLevel );
}
}
tile.setWasDrawn();
}
示例11: timeStep
void Info::timeStep(const unsigned int time )
{
if( !game::Date::isMonthChanged() )
return;
if( game::Date::current().month() != _d->lastDate.month() )
{
bool yearChanged = game::Date::current().year() != _d->lastDate.year();
_d->lastDate = game::Date::current();
_d->lastYearHistory.erase( _d->lastYearHistory.begin() );
_d->lastYearHistory.push_back( Parameters() );
Parameters& last = _d->lastYearHistory.back();
last.date = _d->lastDate;
last[ population ] = _city()->population();
last[ funds ] = _city()->funds().treasury();
last[ taxpayes ] = 0;//_d->city->getLastMonthTaxpayer();
last[ foodStock ] = statistic::getFoodStock( _city() );
last[ foodMontlyConsumption ] = statistic::getFoodMonthlyConsumption( _city() );
last[ monthWithFood ] = last[ foodMontlyConsumption ] > 0 ? (last[ foodStock ] / last[ foodMontlyConsumption ]) : 0;
int foodProducing = statistic::getFoodProducing( _city() );
int yearlyFoodConsumption = last[ foodMontlyConsumption ] * DateTime::monthsInYear;
last[ foodKoeff ] = ( foodProducing - yearlyFoodConsumption > 0 )
? foodProducing / (yearlyFoodConsumption+1)
: -(yearlyFoodConsumption / (foodProducing+1) );
int currentWorkers, rmaxWorkers;
statistic::getWorkersNumber( _city(), currentWorkers, rmaxWorkers );
last[ needWorkers ] = rmaxWorkers - currentWorkers;
last[ maxWorkers ] = rmaxWorkers;
last[ workless ] = statistic::getWorklessPercent( _city() );
last[ payDiff ] = _city()->empire()->workerSalary() - _city()->funds().workerSalary();
last[ tax ] = _city()->funds().taxRate();
last[ cityWages ] = _city()->funds().workerSalary();
last[ romeWages ] = _city()->empire()->workerSalary();
last[ crimeLevel ] = statistic::getCrimeLevel( _city() );
last[ favour ] = _city()->favour();
last[ prosperity ] = _city()->prosperity();
last[ monthWtWar ] = statistic::months2lastAttack( _city() );
last[ peace ] = 0;
PeacePtr peaceSrvc;
peaceSrvc << _city()->findService( Peace::defaultName() );
if( peaceSrvc.isValid() )
{
last[ peace ] = peaceSrvc->value();
}
MilitaryPtr mil;
mil << _city()->findService( Military::defaultName() );
if( mil.isValid() )
{
last[ Info::milthreat ] = mil->threatValue();
}
Helper helper( _city() );
HouseList houses = helper.find<House>( objects::house );
last[ houseNumber ] = 0;
last[ shackNumber ] = 0;
foreach( it, houses )
{
HousePtr h = *it;
if( h->habitants().count() > 0 )
{
int hLvl = h->spec().level();
last[ slumNumber ] += ( hLvl == HouseLevel::hovel || hLvl == HouseLevel::tent ? 1 : 0);
last[ shackNumber ] += ( hLvl >= HouseLevel::shack || hLvl < HouseLevel::hut ? 1 : 0);
last[ houseNumber ]++;
}
}