1 #ifndef BLANK_AI_AICONTROLLER_HPP_
2 #define BLANK_AI_AICONTROLLER_HPP_
4 #include "../app/IntervalTimer.hpp"
5 #include "../world/EntityController.hpp"
16 : public EntityController {
19 explicit AIController(GaloisLFSR &);
22 void SetState(const AIState &);
24 void Update(Entity &, float dt) override;
26 glm::vec3 ControlForce(const Entity &, const EntityState &) const override;
28 static glm::vec3 Heading(const EntityState &) noexcept;
30 /// schedule a decision in the next minimum ± variance seconds
35 /// check if the scheduled decision is due already
36 bool DecisionDue() const noexcept;
37 /// random choice of 0 to num_choices - 1
38 unsigned int Decide(unsigned int num_choices) noexcept;
40 void EnterHalt(float speed) noexcept;
41 void ExitHalt() noexcept;
42 bool IsHalted() const noexcept;
44 void StartFleeing(const Entity &, float speed) noexcept;
45 void StopFleeing() noexcept;
46 bool IsFleeing() const noexcept;
47 const Entity &GetFleeTarget() const noexcept;
49 void StartSeeking(const Entity &, float speed) noexcept;
50 void StopSeeking() noexcept;
51 bool IsSeeking() const noexcept;
52 const Entity &GetSeekTarget() const noexcept;
54 /// start wandering randomly at given speed
55 /// the trajectory is modified by targetting a blip on a sphere
56 /// in front of the entity which moves randomly
57 /// the displacement is given (roughly) in units per second
60 float distance = 2.0f,
62 float displacement = 1.0f
64 void StopWandering() noexcept;
65 bool IsWandering() const noexcept;
71 FineTimer decision_timer;
76 const Entity *flee_target;
79 const Entity *seek_target;