Rev | Line | |
---|
[10029] | 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: |
---|
[10137] | 12 | main-programmer: Thomas Fahrni |
---|
[10029] | 13 | co-programmer: |
---|
| 14 | */ |
---|
[10040] | 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI |
---|
[10029] | 16 | #include "ai_engine.h" |
---|
[10040] | 17 | #include "debug.h" |
---|
[10029] | 18 | |
---|
[10040] | 19 | AIEngine* AIEngine::singletonRef = NULL; |
---|
[10029] | 20 | |
---|
[10137] | 21 | void AIEngine::tick(float dt) |
---|
[10135] | 22 | { |
---|
[10137] | 23 | std::map<int,AITeam*>::iterator it; |
---|
| 24 | for (it= teams.begin(); it!= teams.end(); it++ ) |
---|
| 25 | it->second->process(dt); |
---|
[10135] | 26 | } |
---|
[10029] | 27 | |
---|
[10137] | 28 | void AIEngine::addAI(int teamNumber, int swarmNumber, AIModule* aiModule) |
---|
[10135] | 29 | { |
---|
[10137] | 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); |
---|
[10135] | 35 | } |
---|
[10040] | 36 | |
---|
[10137] | 37 | void AIEngine::removeAI(int teamNumber, int swarmNumber, AIModule* aiModule) |
---|
[10135] | 38 | { |
---|
[10137] | 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 | } |
---|
[10135] | 46 | } |
---|
[10041] | 47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.