]> git.localhorst.tv Git - blank.git/blob - src/ai/AIController.hpp
AI state machine
[blank.git] / src / ai / AIController.hpp
1 #ifndef BLANK_AI_AICONTROLLER_HPP_
2 #define BLANK_AI_AICONTROLLER_HPP_
3
4 #include "../world/EntityController.hpp"
5
6 #include <glm/glm.hpp>
7
8
9 namespace blank {
10
11 class AIState;
12 class GaloisLFSR;
13
14 class AIController
15 : public EntityController {
16
17 public:
18         explicit AIController(GaloisLFSR &);
19         ~AIController();
20
21         void SetState(const AIState &);
22
23         void Update(Entity &, float dt) override;
24
25         glm::vec3 ControlForce(const EntityState &) const override;
26
27         static glm::vec3 Heading(const EntityState &) noexcept;
28
29         void StartFleeing(const Entity &, float speed) noexcept;
30         void StopFleeing() noexcept;
31         bool IsFleeing() const noexcept;
32         const Entity &GetFleeTarget() const noexcept;
33
34         void StartSeeking(const Entity &, float speed) noexcept;
35         void StopSeeking() noexcept;
36         bool IsSeeking() const noexcept;
37         const Entity &GetSeekTarget() const noexcept;
38
39         void StartWandering() noexcept;
40         void StopWandering() noexcept;
41
42 private:
43         GaloisLFSR &random;
44         const AIState *state;
45
46         const Entity *flee_target;
47         float flee_speed;
48
49         const Entity *seek_target;
50         float seek_speed;
51
52         bool wandering;
53         glm::vec3 wander_pos;
54         float wander_dist;
55         float wander_radius;
56         float wander_disp;
57         float wander_speed;
58
59 };
60
61 }
62
63 #endif