当前位置: 首页>>代码示例>>C++>>正文


C++ CSelectedUnits::find方法代码示例

本文整理汇总了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;
}
开发者ID:Gepard,项目名称:spring,代码行数:7,代码来源:SelectedUnits.cpp

示例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
}
开发者ID:atamanokuklu,项目名称:spring,代码行数:46,代码来源:SelectedUnits.cpp

示例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
}
开发者ID:atamanokuklu,项目名称:spring,代码行数:44,代码来源:SelectedUnits.cpp

示例4: PossibleCommandChange

void CSelectedUnits::PossibleCommandChange(CUnit* sender)
{
	if(sender==0 || selectedUnits.find(sender)!=selectedUnits.end())
		possibleCommandsChanged=true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:5,代码来源:SelectedUnits.cpp

示例5: IsUnitSelected

bool CSelectedUnits::IsUnitSelected(const CUnit* unit) const
{
	return (selectedUnits.find(const_cast<CUnit*>(unit)) != selectedUnits.end());
}
开发者ID:atamanokuklu,项目名称:spring,代码行数:4,代码来源:SelectedUnits.cpp


注:本文中的CSelectedUnits::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。