Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

startet to implement swarming

File size: 1.3 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->setEnemyList(enemyList);
24                if(enemyList->size()>0)
25                        it->second->setDestination(enemyList->at(0)->getAbsCoor());
26                it->second->process(dt);
27        }
28}
29
30void 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
39void 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}
Note: See TracBrowser for help on using the repository browser.