本文整理汇总了C++中HousePtr::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::isValid方法的具体用法?C++ HousePtr::isValid怎么用?C++ HousePtr::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
void Religion::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = ptr_cast<House>( tile->overlay() );
if( house.isValid() )
{
int templeAccess = house->spec().computeReligionLevel( house );
bool oracleAccess = house->hasServiceAccess( Service::oracle );
text = (templeAccess == 5 && oracleAccess )
? "##religion_access_full##"
: utils::format( 0xff, "##religion_access_%d_temple##", templeAccess );
}
}
_setTooltipText( _(text) );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例2: _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;
}
示例3: 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();
}
}
示例4: handleEvent
void MarketAccess::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = tile->overlay<House>();
if( house.isValid() )
{
int accessLevel = house->getServiceValue( Service::market );
accessLevel = math::clamp<int>( accessLevel / maxAccessLevel, 0, maxAccessLevel-1 );
text = marketLevelName[ accessLevel ];
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例5: _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;
}
}
示例6: handleEvent
void Sentiment::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = tile->overlay().as<House>();
if( house.isValid() )
{
int happiness = math::clamp<int>( house->state( pr::happiness ) / maxSentimentLevel, 0, maxSentimentLevel-1 );
text = sentimentLevelName[ happiness ];
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例7: _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 ) );
}
}
示例8: buildingDestroyed
void Peace::buildingDestroyed(gfx::TileOverlayPtr overlay)
{
HousePtr house = ptr_cast<House>( overlay );
if( house.isValid() && house->spec().level() > HouseLevel::tent )
{
_d->significantBuildingsDestroyed = true;
}
else
{
_d->significantBuildingsDestroyed |= !_d->unsignificantBuildings.count( overlay->type() );
}
}
示例9: _reachedPathway
void Emigrant::_reachedPathway()
{
bool gooutCity = true;
Walker::_reachedPathway();
if( pos() == _city()->borderInfo().roadExit )
{
city::MigrationPtr migration;
migration << _city()->findService( city::Migration::defaultName() );
if( migration.isValid() )
{
migration->citizenLeaveCity( this );
}
deleteLater();
return;
}
HousePtr house = ptr_cast<House>( _city()->getOverlay( pos() ) );
if( house.isValid() )
{
_append2house( house );
gooutCity = (_d->peoples.count() > 0);
}
else
{
if( _checkNearestHouse() )
{
return;
}
}
if( gooutCity )
{
Pathway way = _findSomeWay( pos() );
if( way.isValid() )
{
_updatePathway( way );
go();
}
else
{
die();
}
}
else
{
deleteLater();
}
}
示例10: arrivedArea
void Immigrant::_findPath2blankHouse( Tile& startPoint )
{
HousePtr house = _findBlankHouse();
Pathway pathWay;
Tilemap& citymap = _getCity()->getTilemap();
Tile& destTile = house.isValid() ? house->getTile() : citymap.at( _getCity()->getBorderInfo().roadExit );
Size arrivedArea( house.isValid() ? house->getSize() : 1 );
bool pathFound = Pathfinder::getInstance().getPath( startPoint.getIJ(), destTile.getIJ(), pathWay,
false, arrivedArea );
if( pathFound )
{
setPathway( pathWay );
setIJ( startPoint.getIJ() );
go();
}
if( !pathFound )
{
deleteLater();
}
}
示例11: onMidTile
void TaxCollector::onMidTile()
{
ServiceWalker::onMidTile();
ReachedBuildings buildings = getReachedBuildings( getIJ() );
for( ReachedBuildings::iterator it=buildings.begin(); it != buildings.end(); it++ )
{
HousePtr house = (*it).as<House>();
if( house.isValid() )
{
int money = house->collectTaxes();
_d->money += money;
_d->peoplesReached += money > 0 ? house->getNbHabitants() : 0;
}
}
}
示例12: handleEvent
void Unemployed::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = tile->overlay().as<House>();
WorkingBuildingPtr workBuilding = tile->overlay().as<WorkingBuilding>();
if( house.isValid() )
{
int workless = house->getServiceValue( Service::recruter );
if( workless > 0 )
text = utils::format( 0xff, "%s %d %s", _("##this_house_have##"), workless, _("##unemployers##") );
else
text = "##this_house_haveno_unemployers##";
}
else if( workBuilding.isValid() )
{
int need = workBuilding->needWorkers();
if( need > 0 )
text = utils::format( 0xff, "%s %d %s", _("##this_building_need##"), need, _("##workers##") );
else
text = "##this_building_have_all_workers##";
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例13: handleEvent
void Tax::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
BuildingPtr bld = ptr_cast<Building>( tile->overlay() );
if( bld.isNull() )
{
text = "##no_people_in_this_locality##";
}
else
{
HousePtr house = ptr_cast<House>( tile->overlay() );
if( house.isValid() )
{
int taxAccess = house->hasServiceAccess( Service::forum );
if( taxAccess < 25 )
text = "##house_not_registered_for_taxes##";
}
}
}
_setTooltipText( _(text) );
}
break;
default:
break;
}
}
Layer::handleEvent( event );
}
示例14: 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 );
}
}
示例15: mayWalk
void mayWalk( const Tile* tile, bool& ret )
{
HousePtr f = ptr_cast<House>( tile->overlay() );
ret = ( tile->isWalkable( true ) || f.isValid() );
}