1 | |
---|
2 | #ifndef _SWARM_MODULE_H |
---|
3 | #define _SWARM_MODULE_H |
---|
4 | #include "world_entity.h" |
---|
5 | #include "ai_module.h" |
---|
6 | |
---|
7 | class SwarmModule { |
---|
8 | public: |
---|
9 | inline SwarmModule(){taskComplete=false;} |
---|
10 | virtual ~SwarmModule(){} |
---|
11 | virtual void process(float dt){} |
---|
12 | |
---|
13 | void addAI(WorldEntity*, float maxSpeed, float attackDistance); |
---|
14 | void removeAI(WorldEntity*); |
---|
15 | void getAttributesFrom(SwarmModule* oldModule); |
---|
16 | virtual void initialize(){} |
---|
17 | inline bool taskDone(){return taskComplete;} |
---|
18 | |
---|
19 | inline void setEnemyList(std::vector<WorldEntity*>* enemys){this->enemys=enemys;} |
---|
20 | |
---|
21 | inline void newOrder(){this->taskComplete=false;} |
---|
22 | inline void orderRelPos(Vector taskRelPos){this->taskRelPos=taskRelPos;} |
---|
23 | inline void orderAbsPos(Vector taskAbsPos){this->taskAbsPos=taskAbsPos;} |
---|
24 | inline void orderView(Vector taskView){this->taskView=taskView;} |
---|
25 | inline void orderSpeed(float taskSpeed){this->taskSpeed=taskSpeed;} |
---|
26 | inline void orderRelObject(WorldEntity* taskRelObject){if (taskRelObject) this->taskRelObjectName=taskRelObject->getName(); else taskRelObjectName = ""; } |
---|
27 | inline void orderMaxTime(float taskMaxTime){this->taskMaxTime=taskMaxTime;} |
---|
28 | |
---|
29 | Vector getSwarmPosition(); |
---|
30 | inline Vector getPosition(){return position;} |
---|
31 | inline float getSpeed(){return speed;} |
---|
32 | inline Vector getView(){return view;} |
---|
33 | inline int getSwarmSize(){return members.size();} |
---|
34 | inline std::vector<WorldEntity*>* getEnemyList(){return enemys;} |
---|
35 | inline std::map<WorldEntity*,AIModule*> getMembers(){return members;} |
---|
36 | inline float getMaxSpeed(){return maxSpeed;} |
---|
37 | inline float getAttackDistance(){return attackDistance;} |
---|
38 | |
---|
39 | protected: |
---|
40 | float getRadius(WorldEntity* object); |
---|
41 | void changeAIModule(std::map<WorldEntity*,AIModule*>::iterator it,AIModule* newAI); |
---|
42 | Vector taskRelPos; |
---|
43 | Vector taskAbsPos; |
---|
44 | Vector taskView; |
---|
45 | float taskSpeed; |
---|
46 | std::string taskRelObjectName; |
---|
47 | bool taskComplete; |
---|
48 | float taskMaxTime; |
---|
49 | |
---|
50 | Vector view; |
---|
51 | Vector position; |
---|
52 | float speed; |
---|
53 | |
---|
54 | float maxSpeed; |
---|
55 | float attackDistance; |
---|
56 | |
---|
57 | std::map<WorldEntity*,AIModule*> members; |
---|
58 | std::vector<WorldEntity*>* enemys; |
---|
59 | }; |
---|
60 | |
---|
61 | |
---|
62 | #endif /* _SWARM_MODULE_H */ |
---|