Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
fighttask.h
1 #pragma once
2 
3 #include <vector>
4 #include <glm/glm.hpp>
5 
6 #include "ai/aitask.h"
7 
8 #include "utils/handle/handle.h"
9 
10 
11 class Ship;
12 class WorldObject;
13 
14 class FightTask : public AiTask {
15 public:
16  FightTask(BoardComputer* boardComputer, const std::vector<Handle<WorldObject>>& targets);
17 
18  virtual void update(float deltaSec);
19 
20  std::vector<Handle<WorldObject>>& targets();
21  virtual void addTarget(const Handle<WorldObject>& targets);
22  virtual void setTargets(const std::vector<Handle<WorldObject>>& targets);
23 
24  virtual bool isFinished();
25 
26 protected:
27  enum class State {
28  IDLE,
29  APPROACH,
30  ENGAGE,
31  EVADE
32  };
33 
34  std::vector<Handle<WorldObject>> m_targets;
35  WorldObject* m_primaryTarget;
36  void updateTargets();
37  void updateState();
38  void setState(State newState);
39 
40  glm::vec3 findRandomEvasionPoint();
41  float targetDistance();
42  float pointDistance(glm::vec3 point);
43  float angleToTarget();
44 
45  State m_state;
46  bool m_stateChanged;
47  float m_maxFireDistance, m_maxRocketDistance, m_minEnemyDistance;
48  glm::vec3 m_positionBehindTarget;
49 };
50 
Definition: aitask.h:15
Definition: worldobject.h:43
Definition: state.h:14
Definition: fighttask.h:14
Definition: boardcomputer.h:19
Definition: ship.h:23