本文整理汇总了C++中CGroup::ClearUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroup::ClearUnits方法的具体用法?C++ CGroup::ClearUnits怎么用?C++ CGroup::ClearUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroup
的用法示例。
在下文中一共展示了CGroup::ClearUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GroupCommand
void CGroupHandler::GroupCommand(int num, const std::string& cmd)
{
GML_RECMUTEX_LOCK(grpsel); // GroupCommand
CGroup* group = groups[num];
if ((cmd == "set") || (cmd == "add")) {
if (cmd == "set") {
group->ClearUnits();
}
const CUnitSet& selUnits = selectedUnits.selectedUnits;
CUnitSet::const_iterator ui;
for(ui = selUnits.begin(); ui != selUnits.end(); ++ui) {
(*ui)->SetGroup(group);
}
}
else if (cmd == "selectadd") {
// do not select the group, just add its members to the current selection
CUnitSet::const_iterator ui;
for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
selectedUnits.AddUnit(*ui);
}
return;
}
else if (cmd == "selectclear") {
// do not select the group, just remove its members from the current selection
CUnitSet::const_iterator ui;
for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
selectedUnits.RemoveUnit(*ui);
}
return;
}
else if (cmd == "selecttoggle") {
// do not select the group, just toggle its members with the current selection
const CUnitSet& selUnits = selectedUnits.selectedUnits;
CUnitSet::const_iterator ui;
for (ui = group->units.begin(); ui != group->units.end(); ++ui) {
if (selUnits.find(*ui) == selUnits.end()) {
selectedUnits.AddUnit(*ui);
} else {
selectedUnits.RemoveUnit(*ui);
}
}
return;
}
if ((selectedUnits.selectedGroup == num) && !group->units.empty()) {
const float3 groupCenter = group->CalculateCenter();
camHandler->GetCurrentController().SetPos(groupCenter);
}
selectedUnits.SelectGroup(num);
}