本文整理汇总了C++中CSelectedUnits::end方法的典型用法代码示例。如果您正苦于以下问题:C++ CSelectedUnits::end方法的具体用法?C++ CSelectedUnits::end怎么用?C++ CSelectedUnits::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSelectedUnits
的用法示例。
在下文中一共展示了CSelectedUnits::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void CSelectedUnits::Draw()
{
glDisable(GL_DEPTH_TEST );
//glEnable(GL_BLEND);
//glColor4f(0,0.8f,0,0.4f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0,1.0f,0);
set<CUnit*>::iterator ui;
glBegin(GL_QUADS);
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
float3 pos((*ui)->pos+(*ui)->speed*gu->timeOffset);
glVertexf3(pos+float3((*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,(*ui)->ysize*4));
glVertexf3(pos+float3(-(*ui)->xsize*4,0,-(*ui)->ysize*4));
glVertexf3(pos+float3((*ui)->xsize*4,0,-(*ui)->ysize*4));
}
}
glEnd();
glEnable(GL_DEPTH_TEST );
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glDisable(GL_BLEND);
}
示例2: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
lineDrawer.Configure(cmdColors.UseColorRestarts(),
cmdColors.UseRestartColor(),
cmdColors.restart,
cmdColors.RestartAlpha());
glBlendFunc((GLenum)cmdColors.QueuedBlendSrc(),
(GLenum)cmdColors.QueuedBlendDst());
glEnable(GL_BLEND);
glLineWidth(cmdColors.QueuedLineWidth());
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
}
示例3: PossibleCommandChange
void CSelectedUnits::PossibleCommandChange(CUnit* sender)
{
GML_RECMUTEX_LOCK(sel); // PossibleCommandChange
if (sender == NULL || selectedUnits.find(sender) != selectedUnits.end())
possibleCommandsChanged = true;
}
示例4: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
GML_RECMUTEX_LOCK(sel); // SetCommandPage - called from CGame::Draw --> RunLayoutCommand --> LayoutIcons --> RevertToCmdDesc
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例5: GetTooltip
std::string CSelectedUnits::GetTooltip(void)
{
std::string s;
if(selectedGroup!=-1 && grouphandler->groups[selectedGroup]->ai){
s="Group selected";
} else if(!selectedUnits.empty()){
// show the player name instead of unit name if it has FBI tag showPlayerName
if((*selectedUnits.begin())->unitDef->showPlayerName)
{
s=gs->players[gs->Team((*selectedUnits.begin())->team)->leader]->playerName.c_str();
} else {
s=(*selectedUnits.begin())->tooltip;
}
}
if(selectedUnits.empty()){
return s;
}
char tmp[500];
float maxHealth=0,curHealth=0,cost=0,exp=0,range=0,metalMake=0,metalUse=0,energyMake=0,energyUse=0,maxfuel=0,curfuel=0,numfuel=0;
for(set<CUnit*>::iterator ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
maxHealth+=(*ui)->maxHealth;
curHealth+=(*ui)->health;
exp+=(*ui)->experience;
cost+=(*ui)->metalCost+(*ui)->energyCost/60;
range+=(*ui)->maxRange;
metalMake+=(*ui)->metalMake;
metalUse+=(*ui)->metalUse;
energyMake+=(*ui)->energyMake;
energyUse+=(*ui)->energyUse;
maxfuel+=(*ui)->unitDef->maxFuel;
curfuel+=(*ui)->currentFuel;
if((*ui)->unitDef->maxFuel > 0)
numfuel++;
}
float num=selectedUnits.size();
sprintf(tmp,"\nHealth %.0f/%.0f",curHealth,maxHealth);
s+=tmp;
if(maxfuel>0){
sprintf(tmp," Fuel %.0f/%.0f",curfuel/numfuel,maxfuel/numfuel);
s+=tmp;
}
sprintf(tmp,"\nExperience %.2f Cost %.0f Range %.0f \n\xff\xd3\xdb\xffMetal: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f\xff\xd3\xdb\xff Energy: \xff\x50\xff\x50%.1f\xff\x90\x90\x90/\xff\xff\x50\x01-%.1f",
exp/num,cost,range/num, metalMake, metalUse, energyMake, energyUse);
s += tmp;
if (gs->cheatEnabled && (selectedUnits.size() == 1)) {
CUnit* unit = *selectedUnits.begin();
SNPRINTF(tmp, sizeof(tmp), "\xff\xc0\xc0\xff [TechLevel %i]",
unit->unitDef->techLevel);
s += tmp;
}
return s;
}
示例6: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
CUnitSet::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->Send(CBaseNetProtocol::Get().SendSelect(gu->myPlayerNum, selectedUnitIDs));
selectionChanged=false;
}
示例7: SendSelection
void CSelectedUnits::SendSelection(void)
{
// first, convert CUnit* to unit IDs.
std::vector<short> selectedUnitIDs(selectedUnits.size());
std::vector<short>::iterator i = selectedUnitIDs.begin();
std::set<CUnit*>::const_iterator ui = selectedUnits.begin();
for(; ui != selectedUnits.end(); ++i, ++ui) *i = (*ui)->id;
net->SendSTLData<unsigned char, std::vector<short> >(NETMSG_SELECT, gu->myPlayerNum, selectedUnitIDs);
selectionChanged=false;
}
示例8: SetCommandPage
void CSelectedUnits::SetCommandPage(int page)
{
if(selectedGroup!=-1 && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai){
grouphandlers[gu->myTeam]->groups[selectedGroup]->lastCommandPage=page;
}
CUnitSet::iterator ui;
for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
(*ui)->commandAI->lastSelectedCommandPage = page;
}
}
示例9: GetDefaultCmd
int CSelectedUnits::GetDefaultCmd(CUnit* unit, CFeature* feature)
{
// NOTE: the unitDef->aihint value is being ignored
int luaCmd;
if (eventHandler.DefaultCommand(unit, feature, luaCmd)) {
return luaCmd;
}
if ((selectedGroup != -1) && grouphandlers[gu->myTeam]->groups[selectedGroup]->ai) {
return grouphandlers[gu->myTeam]->groups[selectedGroup]->GetDefaultCmd(unit, feature);
}
// return the default if there are no units selected
CUnitSet::const_iterator ui = selectedUnits.begin();
if (ui == selectedUnits.end()) {
return CMD_STOP;
}
// setup the locals for IsBetterLeader()
targetUnit = unit;
targetFeature = feature;
if (targetUnit) {
targetIsEnemy = !gs->Ally(gu->myAllyTeam, targetUnit->allyteam);
}
// find the best leader to pick the command
const CUnit* leaderUnit = *ui;
const UnitDef* leaderDef = leaderUnit->unitDef;
for (++ui; ui != selectedUnits.end(); ++ui) {
const CUnit* testUnit = *ui;
const UnitDef* testDef = testUnit->unitDef;
if (testDef != leaderDef) {
if (IsBetterLeader(testDef, leaderDef)) {
leaderDef = testDef;
leaderUnit = testUnit;
}
}
}
return (leaderUnit->commandAI->GetDefaultCmd(unit, feature));
}
示例10: GetDefaultCmd
// CALLINFO:
// DrawMapStuff --> CGuiHandler::GetDefaultCommand --> GetDefaultCmd
// CMouseHandler::DrawCursor --> DrawCentroidCursor --> CGuiHandler::GetDefaultCommand --> GetDefaultCmd
// LuaUnsyncedRead::GetDefaultCommand --> CGuiHandler::GetDefaultCommand --> GetDefaultCmd
int CSelectedUnits::GetDefaultCmd(const CUnit* unit, const CFeature* feature)
{
int luaCmd;
if (eventHandler.DefaultCommand(unit, feature, luaCmd)) {
return luaCmd;
}
GML_RECMUTEX_LOCK(sel); // GetDefaultCmd
// return the default if there are no units selected
CUnitSet::const_iterator ui = selectedUnits.begin();
if (ui == selectedUnits.end()) {
return CMD_STOP;
}
// setup the locals for IsBetterLeader()
targetUnit = unit;
targetFeature = feature;
if (targetUnit) {
targetIsEnemy = !teamHandler->Ally(gu->myAllyTeam, targetUnit->allyteam);
}
// find the best leader to pick the command
const CUnit* leaderUnit = *ui;
const UnitDef* leaderDef = leaderUnit->unitDef;
for (++ui; ui != selectedUnits.end(); ++ui) {
const CUnit* testUnit = *ui;
const UnitDef* testDef = testUnit->unitDef;
if (testDef != leaderDef) {
if (IsBetterLeader(testDef, leaderDef)) {
leaderDef = testDef;
leaderUnit = testUnit;
}
}
}
return (leaderUnit->commandAI->GetDefaultCmd(unit, feature));
}
示例11: ClearSelected
void CSelectedUnits::ClearSelected()
{
GML_RECMUTEX_LOCK(sel); // ClearSelected
CUnitSet::iterator ui;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例12: ClearSelected
void CSelectedUnits::ClearSelected()
{
set<CUnit*>::iterator ui;
ENTER_MIXED;
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->selected=false;
DeleteDeathDependence(*ui);
}
ENTER_UNSYNCED;
selectedUnits.clear();
selectionChanged=true;
possibleCommandsChanged=true;
selectedGroup=-1;
}
示例13: DrawCommands
void CSelectedUnits::DrawCommands(void)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
set<CUnit*>::iterator ui;
if(selectedGroup!=-1){
for(ui=grouphandler->groups[selectedGroup]->units.begin();ui!=grouphandler->groups[selectedGroup]->units.end();++ui){
(*ui)->commandAI->DrawCommands();
}
} else {
for(ui=selectedUnits.begin();ui!=selectedUnits.end();++ui){
(*ui)->commandAI->DrawCommands();
}
}
glEnable(GL_DEPTH_TEST);
}
示例14: 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
}
示例15: 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
}