本文整理汇总了C++中CGroup::radius方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroup::radius方法的具体用法?C++ CGroup::radius怎么用?C++ CGroup::radius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroup
的用法示例。
在下文中一共展示了CGroup::radius方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reelectMasterGroup
bool MergeTask::reelectMasterGroup() {
if (groups.size() <= 1)
return false;
bool reelect = true;
if (masterGroup && !isRetreating) {
float threat = masterGroup->getThreat(pos, masterGroup->radius());
// if threat is 2x smaller than group strength then do nothing
if (threat <= EPS || (masterGroup->strength / threat) > 2.0f)
reelect = false;
}
if (reelect) {
float minThreat = std::numeric_limits<float>::max();
float maxDistance = std::numeric_limits<float>::min();
CGroup *bestGroup = NULL;
std::list<CGroup*>::iterator it;
for (it = groups.begin(); it != groups.end(); ++it) {
CGroup *g = *it;
float3 gpos = g->pos();
float threat = g->getThreat(gpos, g->radius());
float distance = ai->defensematrix->distance2D(gpos);
if (distance > maxDistance)
maxDistance = distance;
if (threat < minThreat) {
bestGroup = g;
minThreat = threat;
isRetreating = (distance + EPS) < maxDistance;
}
}
if (bestGroup && (masterGroup == NULL || masterGroup->key != bestGroup->key)) {
masterGroup = bestGroup;
pos = bestGroup->pos(true);
for (it = groups.begin(); it != groups.end(); ++it) {
CGroup *g = *it;
ai->pathfinder->remove(*g);
if (!ai->pathfinder->addGroup(*g))
return false;
}
}
}
return (masterGroup != NULL);
}
示例2: ATask
MergeTask::MergeTask(AIClasses *_ai, std::list<CGroup*>& groups): ATask(_ai) {
t = TASK_MERGE;
isRetreating = false;
range = 0.0f;
masterGroup = NULL;
std::list<CGroup*>::iterator it;
for (it = groups.begin(); it != groups.end(); ++it) {
CGroup *group = *it;
addGroup(*group);
range += group->radius();
}
unitCategory cats = firstGroup()->cats;
if ((cats&AIR).any() && (cats&ASSAULT).none()) {
// FIXME: prefer no hardcoding
range = 1000.0f;
}
else {
range = range + groups.size() * FOOTPRINT2REAL;
}
}