Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ai/src/ai/ai_team.cc @ 10137

Last change on this file since 10137 was 10137, checked in by tfahrni, 17 years ago

discoverd std::map and std::set

File size: 1.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Thomas Fahrni
13   co-programmer:
14*/
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
16#include "ai_team.h"
17#include "debug.h"
18
19void AITeam::process(float dt)
20{
21        std::map<int,AISwarm*>::iterator it;
22        for (it= swarms.begin(); it!= swarms.end(); it++ )
23                it->second->process(dt);
24}
25
26void AITeam::addAI(int swarmNumber, AIModule* aiModule)
27{
28        std::pair<std::map<int,AISwarm*>::iterator,bool> p;
29        AISwarm* newSwarm=new AISwarm();
30        p=swarms.insert(std::make_pair(swarmNumber,newSwarm));
31        if(!p.second)delete newSwarm;
32        p.first->second->addAI(aiModule);
33}
34
35void AITeam::removeAI(int swarmNumber, AIModule* aiModule)
36{
37        std::map<int,AISwarm*>::iterator it = swarms.find(swarmNumber);
38        if(it==swarms.end())return;
39        it->second->removeAI(aiModule);
40        if(it->second->getSwarmSize()==0){
41                delete it->second;
42                swarms.erase(it);
43        }
44}
45
46int AITeam::getTeamSize()
47{
48        return swarms.size();
49}
Note: See TracBrowser for help on using the repository browser.