/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Thomas Fahrni co-programmer: */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI #include "ai_engine.h" #include "debug.h" AIEngine* AIEngine::singletonRef = NULL; void AIEngine::tick(float dt) { std::map::iterator it; for (it= teams.begin(); it!= teams.end(); it++ ) it->second->process(dt); } void AIEngine::addAI(int teamNumber, int swarmNumber, AIModule* aiModule) { std::pair::iterator,bool> p; AITeam* newTeam=new AITeam(); p=teams.insert(std::make_pair(teamNumber,newTeam)); if(!p.second)delete newTeam; p.first->second->addAI(swarmNumber, aiModule); } void AIEngine::removeAI(int teamNumber, int swarmNumber, AIModule* aiModule) { std::map::iterator it = teams.find(swarmNumber); if(it==teams.end())return; it->second->removeAI(swarmNumber,aiModule); if(it->second->getTeamSize()==0){ delete it->second; teams.erase(it); } }