本文整理汇总了C++中Propagator::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Propagator::init方法的具体用法?C++ Propagator::init怎么用?C++ Propagator::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propagator
的用法示例。
在下文中一共展示了Propagator::init方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeWalkerPath
void TraineeWalker::computeWalkerPath()
{
_maxNeed = 0; // need of this trainee in buildings
Propagator pathPropagator;
pathPropagator.init( *_originBuilding.object() );
pathPropagator.propagate(_maxDistance);
for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
{
BuildingType buildingType = *itType;
checkDestination(buildingType, pathPropagator);
}
if( _destinationBuilding != NULL )
{
// some building needs that trainee!
// std::cout << "trainee sent!" << std::endl;
PathWay pathWay;
pathPropagator.getPath( _destinationBuilding, pathWay);
setPathWay( pathWay );
setIJ( _pathWay.getOrigin().getIJ() );
}
else
{
// nobody needs him...
// std::cout << "trainee suicide!" << std::endl;
deleteLater();
}
}
示例2: computeWalkerPath
void TraineeWalker::computeWalkerPath()
{
_maxNeed = 0; // need of this trainee in buildings
Propagator pathPropagator;
pathPropagator.init(*_originBuilding);
pathPropagator.propagate(_maxDistance);
for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
{
BuildingType buildingType = *itType;
checkDestination(buildingType, pathPropagator);
}
if (_destinationBuilding != NULL)
{
// some building needs that trainee!
// std::cout << "trainee sent!" << std::endl;
PathWay pathWay;
pathPropagator.getPath(*_destinationBuilding, pathWay);
setPathWay(pathWay);
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
Scenario::instance().getCity().getWalkerList().push_back(this);
_destinationBuilding->reserveTrainee(_traineeType);
}
else
{
// nobody needs him...
// std::cout << "trainee suicide!" << std::endl;
_isDeleted = true;
}
}
示例3: assignPath
void Emigrant::assignPath( const Road& startPoint )
{
std::list<PathWay> pathWayList;
std::list<LandOverlay*> houses = Scenario::instance().getCity().getBuildingList(B_HOUSE);
House* blankHouse = 0;
for( std::list<LandOverlay*>::iterator itHouse = houses.begin(); itHouse != houses.end(); ++itHouse )
{
if( House* house = dynamic_cast<House*>(*itHouse) )
{
if( house->getNbHabitants() < house->getMaxHabitants() )
{
blankHouse = house;
_d->destination = house->getTile().getIJ();
break;
}
}
}
Propagator pathfinder;
PathWay pathWay;
pathfinder.init( const_cast< Road& >( startPoint ) );
bool findPath = pathfinder.getPath( *blankHouse, pathWay );
if( findPath )
{
setPathWay( pathWay );
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
}
}
示例4:
void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
propagator.init( info.first );
PathwayList pathWayList = propagator.getWays( info.second );
for( auto& path : pathWayList )
{
RoadList roads = path->allTiles().overlays<Road>();
for( auto road : roads )
road->appendPaved( paved.increase );
}
}
示例5:
void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
propagator.init( info.first );
PathwayList pathWayList = propagator.getWays( info.second );
for( auto&& path : pathWayList )
{
const TilesArray& tiles = path->allTiles();
for( auto tile : tiles )
{
RoadPtr road = tile->overlay().as<Road>();
if( road.isValid() )
{
road->appendPaved( defaultIncreasePaved );
}
}
}
}
示例6: computeWalkerDestination
void CartPusher::computeWalkerDestination()
{
// get the list of buildings within reach
PathWay pathWay;
Propagator pathPropagator;
_d->consumerBuilding = 0;
pathPropagator.init( *_d->producerBuilding.object() );
pathPropagator.propagate(_d->maxDistance);
BuildingPtr destBuilding;
if (destBuilding == NULL)
{
// try send that good to a factory
destBuilding = getWalkerDestination_factory(pathPropagator, pathWay);
}
if (destBuilding == NULL)
{
// try send that good to a granary
destBuilding = getWalkerDestination_granary(pathPropagator, pathWay);
}
if (destBuilding == NULL)
{
// try send that good to a warehouse
destBuilding = getWalkerDestination_warehouse( pathPropagator, pathWay );
}
if( destBuilding != NULL)
{
//_isDeleted = true; // no destination!
setConsumerBuilding( destBuilding );
setPathWay( pathWay );
setIJ( _pathWay.getOrigin().getIJ() );
setSpeed( 1 );
}
else
{
_action._direction = D_NORTH;
setSpeed( 0 );
setIJ( _d->producerBuilding->getAccessRoads().front()->getIJ() );
walk();
}
}
示例7: assignPath
void Immigrant::assignPath( const Building& home )
{
City& city = Scenario::instance().getCity();
Tile& exitTile = city.getTilemap().at( city.getRoadExitI(), city.getRoadExitJ() );
Road* exitRoad = dynamic_cast< Road* >( exitTile.get_terrain().getOverlay() );
if( exitRoad )
{
Propagator pathfinder;
PathWay pathWay;
pathfinder.init( const_cast< Building& >( home ) );
bool findPath = pathfinder.getPath( *exitRoad, pathWay );
if( findPath )
{
setPathWay( pathWay );
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
}
}
else
_isDeleted = true;
}