本文整理汇总了C++中boost::thread_specific_ptr::buildBoat方法的典型用法代码示例。如果您正苦于以下问题:C++ thread_specific_ptr::buildBoat方法的具体用法?C++ thread_specific_ptr::buildBoat怎么用?C++ thread_specific_ptr::buildBoat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::thread_specific_ptr
的用法示例。
在下文中一共展示了thread_specific_ptr::buildBoat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
void BuildBoat::accept(VCAI * ai)
{
TResources boatCost;
shipyard->getBoatCost(boatCost);
if(!cb->getResourceAmount().canAfford(boatCost))
{
throw cannotFulfillGoalException("Can not afford boat");
}
if(cb->getPlayerRelations(ai->playerID, shipyard->o->tempOwner) == PlayerRelations::ENEMIES)
{
throw cannotFulfillGoalException("Can not build boat in enemy shipyard");
}
if(shipyard->shipyardStatus() != IShipyard::GOOD)
{
throw cannotFulfillGoalException("Shipyard is busy.");
}
logAi->trace(
"Building boat at shipyard %s located at %s, estimated boat position %s",
shipyard->o->getObjectName(),
shipyard->o->visitablePos().toString(),
shipyard->bestLocation().toString());
cb->buildBoat(shipyard);
throw goalFulfilledException(sptr(*this));
}
示例2: firstTileToGet
//.........这里部分代码省略.........
if (t && t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::BOAT)
{
if (retrieveTile(pos) == sectorToReach->id)
return true;
}
return false;
});
if (firstEP != src->embarkmentPoints.end())
{
return *firstEP;
}
else
{
//we need to find a shipyard with an access to the desired sector's EP
//TODO what about Summon Boat spell?
std::vector<const IShipyard *> shipyards;
for (const CGTownInstance * t : cb->getTownsInfo())
{
if (t->hasBuilt(BuildingID::SHIPYARD))
shipyards.push_back(t);
}
for (const CGObjectInstance * obj : ai->getFlaggedObjects())
{
if (obj->ID != Obj::TOWN) //towns were handled in the previous loop
{
if (const IShipyard * shipyard = IShipyard::castFrom(obj))
shipyards.push_back(shipyard);
}
}
shipyards.erase(boost::remove_if(shipyards, [=](const IShipyard * shipyard) -> bool
{
return shipyard->shipyardStatus() != 0 || retrieveTile(shipyard->bestLocation()) != sectorToReach->id;
}), shipyards.end());
if (!shipyards.size())
{
//TODO consider possibility of building shipyard in a town
return ret;
//throw cannotFulfillGoalException("There is no known shipyard!");
}
//we have only shipyards that possibly can build ships onto the appropriate EP
auto ownedGoodShipyard = boost::find_if(shipyards, [](const IShipyard * s) -> bool
{
return s->o->tempOwner == ai->playerID;
});
if (ownedGoodShipyard != shipyards.end())
{
const IShipyard * s = *ownedGoodShipyard;
TResources shipCost;
s->getBoatCost(shipCost);
if (cb->getResourceAmount().canAfford(shipCost))
{
int3 ret = s->bestLocation();
cb->buildBoat(s); //TODO: move actions elsewhere
return ret;
}
else
{
//TODO gather res
return ret;
//throw cannotFulfillGoalException("Not enough resources to build a boat");
}
}
else
{
//TODO pick best shipyard to take over
return shipyards.front()->o->visitablePos();
}
}
}
else if (src->water && !sectorToReach->water)
{
//TODO
//disembark
return ret;
}
else //use subterranean gates - not needed since gates are now handled via Pathfinder
{
return ret;
//throw cannotFulfillGoalException("Land-land and water-water inter-sector transitions are not implemented!");
}
}
else
{
return ret;
//throw cannotFulfillGoalException("Inter-sector route detection failed: not connected sectors?");
}
}
else //tiles are in same sector
{
return findFirstVisitableTile(h, dst);
}
}