本文整理汇总了C++中CSelectedUnits::find方法的典型用法代码示例。如果您正苦于以下问题:C++ CSelectedUnits::find方法的具体用法?C++ CSelectedUnits::find怎么用?C++ CSelectedUnits::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSelectedUnits
的用法示例。
在下文中一共展示了CSelectedUnits::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PossibleCommandChange
void CSelectedUnits::PossibleCommandChange(CUnit* sender)
{
GML_RECMUTEX_LOCK(sel); // PossibleCommandChange
if (sender == NULL || selectedUnits.find(sender) != selectedUnits.end())
possibleCommandsChanged = true;
}
示例2: HandleSingleUnitClickSelection
void CSelectedUnits::HandleSingleUnitClickSelection(CUnit* unit, bool doInViewTest)
{
GML_RECMUTEX_LOCK(sel); // SelectUnits
//FIXME make modular?
const CMouseHandler::ButtonPressEvt& bp = mouse->buttons[SDL_BUTTON_LEFT];
if (unit == NULL)
return;
if (unit->team != gu->myTeam && !gu->spectatingFullSelect && !gs->godMode)
return;
if (bp.lastRelease < (gu->gameTime - mouse->doubleClickTime)) {
if (keyInput->IsKeyPressed(SDLK_LCTRL) && (selectedUnits.find(unit) != selectedUnits.end())) {
RemoveUnit(unit);
} else {
AddUnit(unit);
}
} else {
//double click, select all units of same type (on screen, unless CTRL is pressed)
int team, lastTeam;
if (gu->spectatingFullSelect || gs->godMode) {
team = 0;
lastTeam = teamHandler->ActiveTeams() - 1;
} else {
team = gu->myTeam;
lastTeam = gu->myTeam;
}
for (; team <= lastTeam; team++) {
CUnitSet::iterator ui;
CUnitSet& teamUnits = teamHandler->Team(team)->units;
for (ui = teamUnits.begin(); ui != teamUnits.end(); ++ui) {
if ((*ui)->unitDef->id == unit->unitDef->id) {
if (!doInViewTest || keyInput->IsKeyPressed(SDLK_LCTRL) || camera->InView((*ui)->midPos)) {
AddUnit(*ui);
}
}
}
}
}
#if (PLAY_SOUNDS == 1)
Channels::UnitReply.PlayRandomSample(unit->unitDef->sounds.select, unit);
#endif
}
示例3: HandleUnitBoxSelection
void CSelectedUnits::HandleUnitBoxSelection(const float4& planeRight, const float4& planeLeft, const float4& planeTop, const float4& planeBottom)
{
GML_RECMUTEX_LOCK(sel); // SelectUnits
CUnit* unit = NULL;
int addedunits = 0;
int team, lastTeam;
if (gu->spectatingFullSelect || gs->godMode) {
// any team's units can be *selected*
// (whether they can be given orders
// depends on our ability to play god)
team = 0;
lastTeam = teamHandler->ActiveTeams() - 1;
} else {
team = gu->myTeam;
lastTeam = gu->myTeam;
}
for (; team <= lastTeam; team++) {
CUnitSet& teamUnits = teamHandler->Team(team)->units;
for (CUnitSet::iterator ui = teamUnits.begin(); ui != teamUnits.end(); ++ui) {
const float4 vec((*ui)->midPos, 1.0f);
if (vec.dot4(planeRight) < 0.0f && vec.dot4(planeLeft) < 0.0f && vec.dot4(planeTop) < 0.0f && vec.dot4(planeBottom) < 0.0f) {
if (keyInput->IsKeyPressed(SDLK_LCTRL) && (selectedUnits.find(*ui) != selectedUnits.end())) {
RemoveUnit(*ui);
} else {
AddUnit(*ui);
unit = *ui;
addedunits++;
}
}
}
}
#if (PLAY_SOUNDS == 1)
if (addedunits >= 2) {
Channels::UserInterface.PlaySample(soundMultiselID);
}
else if (addedunits == 1) {
Channels::UnitReply.PlayRandomSample(unit->unitDef->sounds.select, unit);
}
#endif
}
示例4: PossibleCommandChange
void CSelectedUnits::PossibleCommandChange(CUnit* sender)
{
if(sender==0 || selectedUnits.find(sender)!=selectedUnits.end())
possibleCommandsChanged=true;
}
示例5: IsUnitSelected
bool CSelectedUnits::IsUnitSelected(const CUnit* unit) const
{
return (selectedUnits.find(const_cast<CUnit*>(unit)) != selectedUnits.end());
}