X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fai%2FAIController.hpp;h=8e5073364ac22f9f2da21841cccadc0937b002a5;hb=0ab149c70b3f984b2cc0c7a122b4aa347bc5fd79;hp=53bdc827a5b3bc8df5b99b4c88553e6dfd5a5361;hpb=150d065f431d665326fd8028748c48a74ad956bb;p=blank.git diff --git a/src/ai/AIController.hpp b/src/ai/AIController.hpp index 53bdc82..8e50733 100644 --- a/src/ai/AIController.hpp +++ b/src/ai/AIController.hpp @@ -8,6 +8,7 @@ namespace blank { +class AIState; class GaloisLFSR; class AIController @@ -17,25 +18,52 @@ public: explicit AIController(GaloisLFSR &); ~AIController(); + void SetState(const AIState &); + void Update(Entity &, float dt) override; - glm::vec3 ControlForce(const EntityState &) const override; + glm::vec3 ControlForce(const Entity &, const EntityState &) const override; static glm::vec3 Heading(const EntityState &) noexcept; + void StartFleeing(const Entity &, float speed) noexcept; + void StopFleeing() noexcept; + bool IsFleeing() const noexcept; + const Entity &GetFleeTarget() const noexcept; + + void StartSeeking(const Entity &, float speed) noexcept; + void StopSeeking() noexcept; + bool IsSeeking() const noexcept; + const Entity &GetSeekTarget() const noexcept; + + /// start wandering randomly at given speed + /// the trajectory is modified by targetting a blip on a sphere + /// in front of the entity which moves randomly + /// the displacement is given (roughly) in units per second + void StartWandering( + float speed, + float distance = 2.0f, + float radius = 1.0f, + float displacement = 1.0f + ) noexcept; + void StopWandering() noexcept; + private: GaloisLFSR &random; + const AIState *state; - float chase_speed; + const Entity *flee_target; float flee_speed; - float stop_dist; - float flee_dist; + const Entity *seek_target; + float seek_speed; + + bool wandering; glm::vec3 wander_pos; + float wander_speed; float wander_dist; float wander_radius; float wander_disp; - float wander_speed; };