예제 #1
0
void BuildingFountain::deliverService()
{
  ServiceWalkerPtr walker = ServiceWalker::create( BuildingPtr( this ), getService());
  ServiceWalker::ReachedBuildings reachedBuildings = walker->getReachedBuildings( getTile().getIJ() );
  for( ServiceWalker::ReachedBuildings::iterator itBuilding = reachedBuildings.begin(); itBuilding != reachedBuildings.end(); ++itBuilding)
  {
    (*itBuilding)->applyService( walker );
  }
}
  std::set< SmartPtr< T > > getReachedBuildings( const TilePos& pos )
  {
    ServiceWalker::ReachedBuildings buildings = _walker.getReachedBuildings( pos );

    std::set< SmartPtr< T > > ret;        
    for( ServiceWalker::ReachedBuildings::iterator it=buildings.begin(); it != buildings.end(); it++ )
    {
      SmartPtr< T > building = (*it).as<T>();
      if( building.isValid() )
      {
        ret.insert( building );
      }
    }

    return ret;
  }
예제 #3
0
bool WalkerPrefect::_looks4Fire( ServiceWalker::ReachedBuildings& buildings, TilePos& pos )
{
  buildings = getReachedBuildings( getIJ() );

  for( ServiceWalker::ReachedBuildings::const_iterator itBuilding = buildings.begin(); 
    itBuilding != buildings.end(); ++itBuilding)
  {
    SmartPtr< BurningRuins > bruins = ( *itBuilding ).as<BurningRuins>();
    if( bruins.isValid() )
    {
      pos = bruins->getTile().getIJ();
      return true;
    }
  }

  return false;
}
  ServiceWalker::ReachedBuildings getReachedBuildings( const TilePos& pos, const TileOverlay::Type type )
  {
    ServiceWalker::ReachedBuildings res = _walker.getReachedBuildings( pos );

    ServiceWalker::ReachedBuildings::iterator it=res.begin();
    while( it != res.end() )
    {
      if( (*it)->getType() != type )
      {
        res.erase( it++ );
      }
      else
      {
        it++;
      }
    }

    return res;
  }