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_engine.h" |
---|
17 | #include "debug.h" |
---|
18 | |
---|
19 | AIEngine* AIEngine::singletonRef = NULL; |
---|
20 | |
---|
21 | void AIEngine::tick(float dt) |
---|
22 | { |
---|
23 | std::map<int,AITeam*>::iterator it; |
---|
24 | for (it= teams.begin(); it!= teams.end(); it++ ) |
---|
25 | it->second->process(dt); |
---|
26 | } |
---|
27 | |
---|
28 | void AIEngine::addAI(int teamNumber, int swarmNumber, AIModule* aiModule) |
---|
29 | { |
---|
30 | std::pair<std::map<int,AITeam*>::iterator,bool> p; |
---|
31 | AITeam* newTeam=new AITeam(); |
---|
32 | p=teams.insert(std::make_pair(teamNumber,newTeam)); |
---|
33 | if(!p.second)delete newTeam; |
---|
34 | p.first->second->addAI(swarmNumber, aiModule); |
---|
35 | } |
---|
36 | |
---|
37 | void AIEngine::removeAI(int teamNumber, int swarmNumber, AIModule* aiModule) |
---|
38 | { |
---|
39 | std::map<int,AITeam*>::iterator it = teams.find(swarmNumber); |
---|
40 | if(it==teams.end())return; |
---|
41 | it->second->removeAI(swarmNumber,aiModule); |
---|
42 | if(it->second->getTeamSize()==0){ |
---|
43 | delete it->second; |
---|
44 | teams.erase(it); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|