本文整理汇总了C++中Propagator::getReachedBuildings方法的典型用法代码示例。如果您正苦于以下问题:C++ Propagator::getReachedBuildings方法的具体用法?C++ Propagator::getReachedBuildings怎么用?C++ Propagator::getReachedBuildings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propagator
的用法示例。
在下文中一共展示了Propagator::getReachedBuildings方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWalkerDestination_granary
BuildingPtr CartPusher::getWalkerDestination_granary(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
GoodType goodType = _d->stock._goodType;
if (!(goodType == G_WHEAT || goodType == G_FISH || goodType == G_MEAT || goodType == G_FRUIT || goodType == G_VEGETABLE))
{
// this good cannot be stored in a granary
return NULL;
}
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings( B_GRANARY, pathWayList);
// find a granary with enough storage
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every granary within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Granary> granary= building.as<Granary>();
_d->reservationID = granary->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = granary.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例2: getWalkerDestination_warehouse
BuildingPtr CartPusher::getWalkerDestination_warehouse(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(B_WAREHOUSE, pathWayList);
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every warehouse within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Warehouse> warehouse= building.as<Warehouse>();
_d->reservationID = warehouse->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = warehouse.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例3: getWalkerDestination_factory
BuildingPtr CartPusher::getWalkerDestination_factory(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
GoodType goodType = _d->stock._goodType;
BuildingType buildingType = BuildingDataHolder::instance().getBuildingTypeByInGood(goodType);
if (buildingType == B_NONE)
{
// no factory can use this good
return NULL;
}
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(buildingType, pathWayList);
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every factory within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Factory> factory = building.as<Factory>();
_d->reservationID = factory->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = factory.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例4: checkDestination
void TraineeWalker::checkDestination(const BuildingType buildingType, Propagator &pathPropagator)
{
std::map<Building*, PathWay> pathWayList;
pathPropagator.getReachedBuildings(buildingType, pathWayList);
for (std::map<Building*, PathWay>::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every building within range
Building& building = *(pathWayIt->first);
float need = building.evaluateTrainee(_traineeType);
if (need > _maxNeed)
{
_maxNeed = need;
_destinationBuilding = &building;
}
}
}
示例5: checkDestination
void TraineeWalker::checkDestination(const BuildingType buildingType, Propagator &pathPropagator)
{
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(buildingType, pathWayList);
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin();
pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every building within range
BuildingPtr building = pathWayIt->first;
float need = building->evaluateTrainee(_traineeType);
if (need > _maxNeed)
{
_maxNeed = need;
_destinationBuilding = building;
}
}
}
示例6: getSupplierDestination2
TilePos getSupplierDestination2( Propagator &pathPropagator, const BuildingType type,
const GoodType what, const int needQty,
PathWay &oPathWay, long& reservId )
{
SmartPtr< T > res;
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(type, pathWayList);
int max_qty = 0;
// select the warehouse with the max quantity of requested goods
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin();
pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every warehouse within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr< T > destBuilding = building.as< T >();
int qty = destBuilding->getGoodStore().getMaxRetrieve( what );
if( qty > max_qty )
{
res = destBuilding;
oPathWay = pathWay;
max_qty = qty;
}
}
if( res.isValid() )
{
// a warehouse/granary has been found!
// reserve some goods from that warehouse/granary
int qty = math::clamp( needQty, 0, max_qty );
GoodStock tmpStock( what, qty, qty);
reservId = res->getGoodStore().reserveRetrieval( tmpStock );
return res->getTilePos();
}
else
{
return TilePos( -1, -1 );
}
}