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 | |
---|
19 | void AITeam::process(float dt) |
---|
20 | { |
---|
21 | std::map<int,AISwarm*>::iterator it; |
---|
22 | for (it= swarms.begin(); it!= swarms.end(); it++ ){ |
---|
23 | it->second->setEnemyList(enemyList); |
---|
24 | if(enemyList->size()>0) |
---|
25 | it->second->setDestination(enemyList->at(0)->getAbsCoor()); |
---|
26 | it->second->process(dt); |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | void AITeam::addAI(int swarmNumber, AIModule* aiModule) |
---|
31 | { |
---|
32 | std::pair<std::map<int,AISwarm*>::iterator,bool> p; |
---|
33 | AISwarm* newSwarm=new AISwarm(); |
---|
34 | p=swarms.insert(std::make_pair(swarmNumber,newSwarm)); |
---|
35 | if(!p.second)delete newSwarm; |
---|
36 | p.first->second->addAI(aiModule); |
---|
37 | } |
---|
38 | |
---|
39 | void AITeam::removeAI(int swarmNumber, AIModule* aiModule) |
---|
40 | { |
---|
41 | std::map<int,AISwarm*>::iterator it = swarms.find(swarmNumber); |
---|
42 | if(it==swarms.end())return; |
---|
43 | it->second->removeAI(aiModule); |
---|
44 | if(it->second->getSwarmSize()==0){ |
---|
45 | delete it->second; |
---|
46 | swarms.erase(it); |
---|
47 | } |
---|
48 | } |
---|