本文整理汇总了C++中HousePtr::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::deleteLater方法的具体用法?C++ HousePtr::deleteLater怎么用?C++ HousePtr::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::deleteLater方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMidTile
void WalkerPrefect::onMidTile()
{
ReachedBuildings reachedBuildings;
TilePos firePos;
bool haveBurningRuinsNear = _looks4Fire( reachedBuildings, firePos );
bool isDestination = _getPathway().isDestination();
switch( _d->action )
{
case Impl::doNothing:
break;
case Impl::patrol:
{
if( haveBurningRuinsNear )
{
//tell our prefecture that need send prefect with water to fight with fire
//on next deliverService
//found fire, no water, go prefecture
getBase().as<Prefecture>()->fireDetect( firePos );
_back2Prefecture();
Walker::onNewDirection();
}
else
{
foreach( BuildingPtr building, reachedBuildings )
{
building->applyService( ServiceWalkerPtr( this ) );
HousePtr house = building.as<House>();
if( house.isValid() && house->getHealthLevel() < 1 )
{
house->deleteLater();
GameEventMgr::append( DisasterEvent::create( house->getTilePos(), DisasterEvent::plague ) );
}
}
}
if( isDestination )
{
_back2Prefecture();
}
Walker::onMidTile();
}
break;
case Impl::back2Prefecture:
{
if( haveBurningRuinsNear )
{
//tell our prefecture that need send prefect with water to fight with fire
//on next deliverService
getBase().as<Prefecture>()->fireDetect( firePos );
}
if( isDestination )
{
deleteLater();
_d->action = Impl::doNothing;
}
Walker::onMidTile();
}
break;
case Impl::gotoFire:
{
if( _getPathway().getDestination().getIJ().distanceFrom( getIJ() ) < 1.5f )
{
LandOverlayPtr overlay = _getPathway().getDestination().getOverlay();
if( overlay.isValid() && overlay->getType() == B_BURNING_RUINS )
{
_d->action = Impl::fightFire;
_setGraphic( WG_PREFECT_FIGHTS_FIRE );
Walker::onNewDirection();
isDestination = false;
}
}
if( isDestination )
{
if( !haveBurningRuinsNear || _d->water == 0 )
{
_back2Prefecture();
}
else
{
_setGraphic( WG_PREFECT_DRAG_WATER );
_d->action = Impl::gotoFire;
_checkPath2NearestFire( reachedBuildings );
Walker::onNewDirection();
}
}
Walker::onMidTile();
//.........这里部分代码省略.........
示例2: getTile
void House::_tryUpdate_1_to_11_lvl( int level4grow, int startSmallPic, int startBigPic, const char desirability )
{
if( getSize() == 1 )
{
Tilemap& tmap = _getCity()->getTilemap();
TilemapTiles area = tmap.getFilledRectangle( getTile().getIJ(), Size(2) );
bool mayGrow = true;
foreach( Tile* tile, area )
{
if( tile == NULL )
{
mayGrow = false; //some broken, can't grow
break;
}
HousePtr house = tile->getOverlay().as<House>();
if( house != NULL && house->getLevelSpec().getHouseLevel() == level4grow )
{
if( house->getSize().getWidth() > 1 ) //bigger house near, can't grow
{
mayGrow = false;
break;
}
}
else
{
mayGrow = false; //no house near, can't grow
break;
}
}
if( mayGrow )
{
int sumHabitants = getNbHabitants();
int sumFreeWorkers = _d->freeWorkersCount;
TilemapTiles::iterator delIt=area.begin();
HousePtr selfHouse = (*delIt)->getOverlay().as<House>();
delIt++; //don't remove himself
for( ; delIt != area.end(); delIt++ )
{
HousePtr house = (*delIt)->getOverlay().as<House>();
if( house.isValid() )
{
house->deleteLater();
house->_d->currentHabitants = 0;
sumHabitants += house->getNbHabitants();
sumFreeWorkers += house->_d->freeWorkersCount;
selfHouse->getGoodStore().storeAll( house->getGoodStore() );
}
}
_d->currentHabitants = sumHabitants;
_d->freeWorkersCount = sumFreeWorkers;
_d->houseLevelSpec = HouseSpecHelper::getInstance().getHouseLevelSpec(_d->houseLevel);
_d->nextHouseLevelSpec = _d->houseLevelSpec.next();
_update();
_updateDesirabilityInfluence( Construction::duNegative );
setSize( getSize() + Size(1) );
build( _getCity(), getTile().getIJ() );
}
}
示例3: getTile
void House::_tryUpdate_1_to_11_lvl( int level4grow, int startSmallPic, int startBigPic, const char desirability )
{
if( getSize() == 1 )
{
CityPtr city = Scenario::instance().getCity();
Tilemap& tmap = city->getTilemap();
PtrTilesList tiles = tmap.getFilledRectangle( getTile().getIJ(), Size(2) );
bool mayGrow = true;
for( PtrTilesList::iterator it=tiles.begin(); it != tiles.end(); it++ )
{
if( *it == NULL )
{
mayGrow = false; //some broken, can't grow
break;
}
HousePtr house = (*it)->getTerrain().getOverlay().as<House>();
if( house != NULL && house->getLevelSpec().getHouseLevel() == level4grow )
{
if( house->getSize().getWidth() > 1 ) //bigger house near, can't grow
{
mayGrow = false;
break;
}
}
else
{
mayGrow = false; //no house near, can't grow
break;
}
}
if( mayGrow )
{
int sumHabitants = getNbHabitants();
int sumFreeWorkers = _d->freeWorkersCount;
PtrTilesList::iterator delIt=tiles.begin();
delIt++; //don't remove himself
for( ; delIt != tiles.end(); delIt++ )
{
HousePtr house = (*delIt)->getTerrain().getOverlay().as<House>();
if( house.isValid() )
{
house->deleteLater();
house->_d->currentHabitants = 0;
sumHabitants += house->getNbHabitants();
sumFreeWorkers += house->_d->freeWorkersCount;
}
}
_d->currentHabitants = sumHabitants;
_d->freeWorkersCount = sumFreeWorkers;
_d->houseLevelSpec = HouseSpecHelper::getInstance().getHouseLevelSpec(_d->houseLevel);
_d->nextHouseLevelSpec = _d->houseLevelSpec.next();
_update();
_updateDesirabilityInfluence( Construction::duNegative );
setSize( getSize() + Size(1) );
build( getTile().getIJ() );
}
}
_updateDesirabilityInfluence( Construction::duNegative );
_d->desirability = desirability;
_updateDesirabilityInfluence( Construction::duPositive );
bool bigSize = getSize().getWidth() > 1;
_d->houseId = bigSize ? startBigPic : startSmallPic;
_d->picIdOffset = bigSize ? 0 : ( (rand() % 10 > 6) ? 1 : 0 );
}