本文整理汇总了C++中CSystem::EnumObjectsInBoxStart方法的典型用法代码示例。如果您正苦于以下问题:C++ CSystem::EnumObjectsInBoxStart方法的具体用法?C++ CSystem::EnumObjectsInBoxStart怎么用?C++ CSystem::EnumObjectsInBoxStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSystem
的用法示例。
在下文中一共展示了CSystem::EnumObjectsInBoxStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InRangeOfThreat
bool CFerianShipAI::InRangeOfThreat (CSpaceObject **retpThreat)
// InRangeOfThreat
//
// Returns the nearest threat
{
if (m_pShip->IsDestinyTime(19))
{
CSystem *pSystem = m_pShip->GetSystem();
int iDestiny = m_pShip->GetDestiny();
// Get the list of objects that intersect the object
SSpaceObjectGridEnumerator i;
pSystem->EnumObjectsInBoxStart(i, m_pShip->GetPos(), MAX_THREAT_DIST);
// Loop over all objects
Metric rNearestDist2 = MAX_THREAT_DIST * MAX_THREAT_DIST2;
CSpaceObject *pNearestObj = NULL;
while (pSystem->EnumObjectsInBoxHasMore(i))
{
CSpaceObject *pObj = pSystem->EnumObjectsInBoxGetNext(i);
// If the object is in the bounding box then remember
// it so that we can do a more accurate calculation.
if (pObj->GetCategory() == CSpaceObject::catShip
&& (!m_pShip->IsFriend(pObj) || pObj->GetDestiny() < iDestiny)
&& pObj->CanAttack())
{
Metric rDist2 = m_pShip->GetDistance2(pObj);
if (rDist2 < rNearestDist2)
{
pNearestObj = pObj;
rNearestDist2 = rDist2;
}
}
}
// Done
if (pNearestObj)
{
*retpThreat = pNearestObj;
return true;
}
}
return false;
}