本文整理汇总了C++中CGroup::addUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroup::addUnit方法的具体用法?C++ CGroup::addUnit怎么用?C++ CGroup::addUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroup
的用法示例。
在下文中一共展示了CGroup::addUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addUnitOnFinished
void CEconomy::addUnitOnFinished(CUnit &unit) {
LOG_II("CEconomy::addUnitOnFinished " << unit)
unitCategory c = unit.type->cats;
if ((c&BUILDER).any() || ((c&ASSISTER).any() && (c&MOBILE).any())) {
CGroup *group = requestGroup();
group->addUnit(unit);
}
}
示例2: addUnitOnCreated
void CEconomy::addUnitOnCreated(CUnit& unit) {
unitCategory c = unit.type->cats;
if ((c&MEXTRACTOR).any()) {
CGroup *group = requestGroup();
group->addUnit(unit);
takenMexes[group->key] = group->pos();
CUnit *builder = ai->unittable->getUnit(group->firstUnit()->builtBy);
if (builder) {
assert(group->key != builder->group->key);
takenMexes.erase(builder->group->key);
}
}
else if(unit.type->def->needGeo) {
CGroup *group = requestGroup();
group->addUnit(unit);
takenGeo[group->key] = group->pos();
CUnit *builder = ai->unittable->getUnit(group->firstUnit()->builtBy);
if (builder) {
assert(group->key != builder->group->key);
takenGeo.erase(builder->group->key);
}
}
}
示例3: addUnit
bool CMilitary::addUnit(CUnit& unit) {
LOG_II("CMilitary::addUnit " << unit)
assert(unit.group == NULL);
unitCategory c = unit.type->cats;
if ((c&ATTACKER).any() && (c&MOBILE).any() && (c&DEFENSE).none()) {
unitCategory wishedCats = ai->unittable->unitsUnderConstruction[unit.key];
CGroup* group;
if ((c&SCOUTER).any() && wishedCats.any() && (wishedCats&SCOUTER).none())
c &= ~SCOUTER; // scout was not requested
if ((c&SCOUTER).any()) {
group = requestGroup(SCOUT);
}
else if((c&AIR).any() && (c&ARTILLERY).any()) {
group = requestGroup(BOMBER);
}
else if((c&AIR).any() && (c&ASSAULT).none()) {
group = requestGroup(AIRFIGHTER);
}
else {
/* If there is a new factory, or the current group is busy, request
a new group */
std::map<int,CGroup*>::iterator i = assemblingGroups.find(unit.builtBy);
if (i == assemblingGroups.end() || i->second->busy || !i->second->canAdd(&unit)) {
group = requestGroup(ENGAGE);
assemblingGroups[unit.builtBy] = group;
} else {
group = i->second;
}
}
group->addUnit(unit);
return true;
}
return false;
}