X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fai%2FAIController.hpp;h=6d40ded362b083780c54aa2f38aa09523d464d5b;hb=dcd54cacda98c2c0f7cf0c7a9131fb858d8ee10a;hp=cda3e8a08086465f694b020f6615c4c58ebd1271;hpb=8e9e2bb4b2dd5a4100f4531628ab58002fe253c1;p=blank.git diff --git a/src/ai/AIController.hpp b/src/ai/AIController.hpp index cda3e8a..6d40ded 100644 --- a/src/ai/AIController.hpp +++ b/src/ai/AIController.hpp @@ -2,32 +2,33 @@ #define BLANK_AI_AICONTROLLER_HPP_ #include "../app/IntervalTimer.hpp" +#include "../geometry/primitive.hpp" +#include "../graphics/glm.hpp" #include "../world/EntityController.hpp" -#include - namespace blank { class AIState; class Entity; -class GaloisLFSR; class Player; class World; +// TODO: AI and entities are tightly coupled, maybe AIcontroller should +// be part of Entity. In that case, players could either be separated +// from other entities use function as a degenerate AI which blindly +// executes whatever its human tell it to. class AIController : public EntityController { public: - AIController(World &, GaloisLFSR &); + AIController(World &, Entity &); ~AIController(); - void SetState(const AIState &); + void SetState(const AIState &, Entity &); void Update(Entity &, float dt) override; - glm::vec3 ControlForce(const Entity &, const EntityState &) const override; - /// get the closest player that given entity can see /// returns nullptr if none are in sight Player *ClosestVisiblePlayer(const Entity &) noexcept; @@ -48,67 +49,8 @@ public: /// random choice of 0 to num_choices - 1 unsigned int Decide(unsigned int num_choices) noexcept; - void EnterHalt() noexcept; - void ExitHalt() noexcept; - bool IsHalted() const noexcept; - void SetHaltSpeed(float) noexcept; - glm::vec3 GetHaltForce(const Entity &, const EntityState &) const noexcept; - - void StartFleeing() noexcept; - void StopFleeing() noexcept; - bool IsFleeing() const noexcept; - void SetFleeTarget(Entity &) noexcept; - void SetFleeSpeed(float) noexcept; - Entity &GetFleeTarget() noexcept; - const Entity &GetFleeTarget() const noexcept; - glm::vec3 GetFleeForce(const Entity &, const EntityState &) const noexcept; - - void StartSeeking() noexcept; - void StopSeeking() noexcept; - bool IsSeeking() const noexcept; - void SetSeekTarget(Entity &) noexcept; - void SetSeekSpeed(float) noexcept; - Entity &GetSeekTarget() noexcept; - const Entity &GetSeekTarget() const noexcept; - glm::vec3 GetSeekForce(const Entity &, const EntityState &) const noexcept; - - void StartEvading() noexcept; - void StopEvading() noexcept; - bool IsEvading() const noexcept; - void SetEvadeTarget(Entity &) noexcept; - void SetEvadeSpeed(float) noexcept; - Entity &GetEvadeTarget() noexcept; - const Entity &GetEvadeTarget() const noexcept; - glm::vec3 GetEvadeForce(const Entity &, const EntityState &) const noexcept; - - void StartPursuing() noexcept; - void StopPursuing() noexcept; - bool IsPursuing() const noexcept; - void SetPursuitTarget(Entity &) noexcept; - void SetPursuitSpeed(float) noexcept; - Entity &GetPursuitTarget() noexcept; - const Entity &GetPursuitTarget() const noexcept; - glm::vec3 GetPursuitForce(const Entity &, const EntityState &) const noexcept; - - /// start wandering randomly - void StartWandering() noexcept; - void StopWandering() noexcept; - bool IsWandering() const noexcept; - /// change how wandering is performed - /// 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 SetWanderParams( - float speed, - float distance = 2.0f, - float radius = 1.0f, - float displacement = 1.0f - ) noexcept; - glm::vec3 GetWanderForce(const Entity &, const EntityState &) const noexcept; - private: World &world; - GaloisLFSR &random; const AIState *state; /// how far controlled entities can see @@ -119,32 +61,6 @@ private: FineTimer think_timer; FineTimer decision_timer; - bool halted; - float halt_speed; - - bool fleeing; - Entity *flee_target; - float flee_speed; - - bool seeking; - Entity *seek_target; - float seek_speed; - - bool evading; - Entity *evade_target; - float evade_speed; - - bool pursuing; - Entity *pursuit_target; - float pursuit_speed; - - bool wandering; - glm::vec3 wander_pos; - float wander_speed; - float wander_dist; - float wander_radius; - float wander_disp; - }; }