本文整理汇总了C++中HousePtr::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::pos方法的具体用法?C++ HousePtr::pos怎么用?C++ HousePtr::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::pos方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _centerTile
void TaxCollector::_centerTile()
{
Walker::_centerTile();
int difficulty = SETTINGS_VALUE(difficulty);
float multiply = 1.0f;
switch (difficulty)
{
case 0: multiply = 3.0f; break;
case 1: multiply = 2.0f; break;
case 2: multiply = 1.5f; break;
case 3: multiply = 1.0f; break;
case 4: multiply = 0.75f; break;
}
ReachedBuildings buildings = getReachedBuildings( pos() );
foreach( it, buildings )
{
HousePtr house = ptr_cast<House>( *it );
if( house.isValid() )
{
float tax = house->collectTaxes() * multiply;
_d->money += tax;
house->applyService( this );
std::string posStr = utils::format( 0xff, "%02dx%02d", house->pos().i(), house->pos().j() );
_d->history[ posStr ] += tax;
}
}
示例2: _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;
}
}
示例3: _findSomeWay
Pathway Emigrant::_findSomeWay( TilePos startPoint )
{
HousePtr house = _findBlankHouse();
_d->failedWayCount++;
Pathway pathway;
if( house.isValid() )
{
pathway = PathwayHelper::create( startPoint, house->pos(), PathwayHelper::roadFirst );
if( !pathway.isValid() )
{
pathway = PathwayHelper::create( startPoint, ptr_cast<Construction>(house),
PathwayHelper::roadFirst );
}
if( pathway.isValid() )
{
_lockHouse( house );
}
}
if( !pathway.isValid() || _d->failedWayCount > 10 )
{
pathway = PathwayHelper::create( startPoint,
_city()->borderInfo().roadExit,
PathwayHelper::allTerrain );
}
return pathway;
}
示例4: 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();
}
}
示例5: _lockHouse
void Emigrant::_lockHouse( HousePtr house )
{
if( _d->housePosLock.i() >= 0 )
{
HousePtr oldHouse = ptr_cast<House>( _city()->tilemap().at( _d->housePosLock ).overlay() );
if( oldHouse.isValid() )
{
_d->housePosLock = TilePos( -1, -1 );
oldHouse->setState( House::settleLock, 0 );
}
}
if( house.isValid() )
{
_d->housePosLock = house->pos();
house->setState( House::settleLock, TileHelper::hash( _d->housePosLock ) );
}
}