bool Fortification::build( const city::AreaInfo& info ) { // we can't build if already have wall here WallPtr wall = info.city->getOverlay( info.pos ).as<Wall>(); if( wall.isValid() ) { return false; } Pathway way2border = PathwayHelper::create( info.pos, info.city->borderInfo().roadEntry, PathwayHelper::allTerrain ); if( !way2border.isValid() ) { events::GameEventPtr event = events::WarningMessage::create( "##walls_need_a_gatehouse##", 1 ); event->dispatch(); } Building::build( info ); FortificationList fortifications = info.city->statistic().objects.find<Fortification>( object::fortification ); for( auto fort : fortifications ) { fort->updatePicture( info.city ); } TowerList towers = info.city->statistic().objects.find<Tower>( object::tower ); for( auto tower : towers ) { tower->resetPatroling(); } updatePicture( info.city ); return true; }
void Wall::destroy() { Construction::destroy(); if( _city().isValid() ) { TilesArea area( _city()->tilemap(), pos() - TilePos( 2, 2), Size( 5 ) ); foreach( tile, area ) { WallPtr wall = ptr_cast<Wall>( (*tile)->overlay() ); if( wall.isValid() ) { wall->updatePicture( _city() ); } }
void RobotWorld::deleteWall( WallPtr aWall, bool aNotifyObservers /*= true*/) { auto i = std::find_if( walls.begin(), walls.end(), [aWall]( WallPtr w) { return aWall->getPoint1() == w->getPoint1() && aWall->getPoint2() == w->getPoint2(); }); if (i != walls.end()) { walls.erase( i); if (aNotifyObservers == true) { notifyObservers(); } } }
bool Wall::build( const city::AreaInfo& info ) { Tilemap& tilemap = info.city->tilemap(); Tile& terrain = tilemap.at( info.pos ); // we can't build if already have wall here WallPtr wall = ptr_cast<Wall>( terrain.overlay() ); if( wall.isValid() ) { return false; } Construction::build( info ); WallList walls = city::statistic::getObjects<Wall>( info.city, object::wall ); foreach( wall, walls ) { (*wall)->updatePicture( info.city ); }
bool Wall::build( const city::AreaInfo& info ) { Tilemap& tilemap = info.city->tilemap(); Tile& terrain = tilemap.at( info.pos ); // we can't build if already have wall here WallPtr wall = ptr_cast<Wall>( terrain.overlay() ); if( wall.isValid() ) { return false; } Construction::build( info ); WallList walls = info.city->statistic().objects.find<Wall>( object::wall ); for( auto wall : walls ) { wall->updatePicture( info.city ); } updatePicture( info.city ); return true; }