本文整理汇总了C++中PlayerCityPtr::overlays方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerCityPtr::overlays方法的具体用法?C++ PlayerCityPtr::overlays怎么用?C++ PlayerCityPtr::overlays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerCityPtr
的用法示例。
在下文中一共展示了PlayerCityPtr::overlays方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _removeGoodFrom
void _removeGoodFrom( PlayerCityPtr city, objects::Type btype, good::Product what, int& qty )
{
SmartList<T> bList;
#ifdef CAESARIA_PLATFORM_HAIKU
bList << city->overlays();
#else
city::Helper helper( city );
bList = helper.find<T>( btype );
#endif
foreach( it, bList )
{
if( qty <= 0 )
break;
good::Store& store = (*it)->store();
int maxQty = std::min( store.getMaxRetrieve( what ), qty );
if( maxQty > 0 )
{
good::Stock stock( what, maxQty );
store.retrieve( stock, maxQty );
qty -= maxQty;
}
}
}
示例2: _decreaseHousesHealth
void _decreaseHousesHealth( object::Type btype, PlayerCityPtr city, int value )
{
TilePos offset( 2, 2 );
const OverlayList& buildings = city->overlays();
foreach( itB, buildings )
{
if( (*itB)->type() != btype )
continue;
HouseList houses = city::statistic::getObjects<House>( city, object::house, (*itB)->pos() - offset, (*itB)->pos() + offset );
foreach( itHouse, houses )
{
(*itHouse)->updateState( pr::health, value );
}
}
示例3: decodeTerrain
void LoaderHelper::decodeTerrain( Tile &oTile, PlayerCityPtr city, unsigned int forceId )
{
unsigned int imgId = oTile.originalImgId();
TileOverlay::Type ovType = construction::unknown;
if( oTile.getFlag( Tile::tlRoad ) ) // road
{
ovType = construction::road;
Picture pic = Picture::load( ResourceGroup::land1a, 230 + math::random( 59) );
oTile.setPicture( pic );
oTile.setOriginalImgId( TileHelper::convPicName2Id( pic.name() ) );
}
else if( (imgId >= 372 && imgId <= 427) )
{
oTile.setFlag( Tile::tlCoast, true );
if( imgId >= 388 )
oTile.setFlag( Tile::tlRubble, true );
}
else /*if( oTile.getFlag( Tile::tlBuilding ) )*/
{
unsigned id = forceId > 0 ? forceId : oTile.originalImgId();
ovType = convImgId2ovrType( id );
}
if( ovType == construction::unknown )
return;
TileOverlayPtr overlay; // This is the overlay object, if any
overlay = TileOverlayFactory::instance().create( ovType );
if( ovType == building::elevation )
{
std::string elevationPicName = TileHelper::convId2PicName( oTile.originalImgId() );
overlay->setPicture( Picture::load( elevationPicName ) );
}
if( overlay != NULL )
{
//Logger::warning( "Building at ( %d, %d ) with ID: %x", oTile.i(), oTile.j(), oTile.originalImgId() );
if( oTile.overlay().isValid() )
return;
overlay->build( city, oTile.pos() );
city->overlays().push_back( overlay );
}
}
示例4: _findFreeEmblem
static LegionEmblem _findFreeEmblem( PlayerCityPtr city )
{
FortList forts;
forts << city->overlays();
std::vector<LegionEmblem> availableEmblems;
VariantMap emblemsModel = config::load( SETTINGS_RC_PATH( emblemsModel ) );
foreach( it, emblemsModel )
{
VariantMap vm_emblem = it->second.toMap();
LegionEmblem newEmblem;
newEmblem.name = vm_emblem[ lc_name ].toString();
newEmblem.pic = Picture::load( vm_emblem[ lc_img ].toString() );
if( !newEmblem.name.empty() && newEmblem.pic.isValid() )
{
availableEmblems.push_back( newEmblem );
}
}
示例5: __createRivers
static void __createRivers(Game& game )
{
PlayerCityPtr oCity = game.city();
Tilemap& oTilemap = oCity->tilemap();
TerrainGeneratorHelper tgHelper;
Pathfinder& pathfinder = Pathfinder::instance();
pathfinder.setCondition( makeDelegate( &tgHelper, &TerrainGeneratorHelper::canBuildRiver ) );
TilesArray terrainTiles = oTilemap.getArea( TilePos(0,0), Size( oTilemap.size() ) );
for( TilesArray::iterator it=terrainTiles.begin(); it != terrainTiles.end(); )
{
Tile* tile = *it;
if( tile->isWalkable( true ) || tile->getFlag( Tile::tlTree ) ) { ++it; }
else { it = terrainTiles.erase( it ); }
}
int riverCount = 0;
for( int tryCount=0; tryCount < 20; tryCount++ )
{
if( riverCount++ > oTilemap.size() / 60 )
break;
Tile* centertile = terrainTiles.random();
Pathway way;
for( int range=0; range < 99; range++ )
{
TilesArray perimeter = oTilemap.getRectangle( range, centertile->pos() );
foreach( it, perimeter )
{
Tile* currentTile = *it;
if( currentTile->getFlag( Tile::tlWater ) )
{
way = pathfinder.getPath( *centertile, *currentTile, Pathfinder::customCondition | Pathfinder::fourDirection );
if( way.isValid() )
{
break;
}
}
}
if( way.isValid() )
break;
}
if( way.isValid() )
{
TilesArray wayTiles = way.allTiles();
foreach( it, wayTiles )
{
TileOverlayPtr overlay = TileOverlayFactory::instance().create( constants::objects::river );
//Picture pic = Picture::load( ResourceGroup::land1a, 62 + math::random( 57 ) );
(*it)->setPicture( Picture::getInvalid() );
//(*it)->setOriginalImgId( TileHelper::convPicName2Id( pic.name() ) );
(*it)->setOriginalImgId( 0 );
bool isWater = (*it)->getFlag( Tile::tlWater );
CityAreaInfo info = { oCity, (*it)->pos(), TilesArray() };
overlay->build( info );
oCity->overlays().push_back( overlay );
if( isWater )
break;
}