本文整理汇总了C++中CvUnit::canLoadYield方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::canLoadYield方法的具体用法?C++ CvUnit::canLoadYield怎么用?C++ CvUnit::canLoadYield使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::canLoadYield方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI_tradeRoutes
//.........这里部分代码省略.........
if ((pPlotCity == pSourceCity))
{
// transport feeder - start - Nightinggale
//int iAmount = pSourceCity->getYieldStored(eYield) - pSourceCity->getMaintainLevel(eYield);
int iAmount = pSourceCity->getYieldStored(eYield) - pSourceCity->getAutoMaintainThreshold(eYield);
// transport feeder - end - Nightinggale
if (iAmount > 0)
{
int iExportValue = kOwner.AI_transferYieldValue(routes[i]->getSourceCity(), routes[i]->getYield(), -iAmount);
int iImportValue = kOwner.AI_transferYieldValue(routes[i]->getDestinationCity(), routes[i]->getYield(), iAmount);
int iRouteValue = (iExportValue + iImportValue + 2 * std::min(iExportValue, iImportValue)) / 4;
if (iRouteValue > iBestRouteValue)
{
iBestRouteValue = iRouteValue;
iBestRoute = i;
}
}
}
}
}
if (iBestRouteValue > 0)
{
CLLNode<IDInfo>* pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (pLoopUnit != NULL)
{
if (pLoopUnit->canLoadYield(plot(), routes[iBestRoute]->getYield(), false))
{
pLoopUnit->loadYield(routes[iBestRoute]->getYield(), false);
break;
}
}
}
}
else
{
break;
}
}
//XXX fill hold.
}
if ((kBestDestination.eOwner == NO_PLAYER) && hasCargo())
{
// Transport group is full and can't find any destination
CvCity* pCity = kOwner.AI_findBestPort();
if (pCity != NULL && !atPlot(pCity->plot()))
{
kBestDestination = pCity->getIDInfo();
}
}
//As a final step, we could consider loading yields which would be useful as parts of delivery runs...
if (kBestDestination != kEurope)
{
CvCity* pBestDestinationCity = ::getCity(kBestDestination);
if (pBestDestinationCity != NULL)
{
FAssert(!atPlot(pBestDestinationCity->plot()));