X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FGoal.hpp;h=1705b15c371e4d92db60a7c485320ec996a71355;hb=refs%2Fheads%2Fmaster;hp=9ffeb0f006878f08e96f044436a8ab6987204130;hpb=42db7d9d2286e50896ad172e2e4a8fbe65c8a4a9;p=blobs.git diff --git a/src/creature/Goal.hpp b/src/creature/Goal.hpp index 9ffeb0f..1705b15 100644 --- a/src/creature/Goal.hpp +++ b/src/creature/Goal.hpp @@ -1,6 +1,8 @@ #ifndef BLOBS_CREATURE_GOAL_HPP_ #define BLOBS_CREATURE_GOAL_HPP_ +#include "Creature.hpp" + #include #include @@ -9,12 +11,11 @@ namespace blobs { namespace app { struct Assets; } +namespace math { + class GaloisLFSR; +} namespace creature { -class Creature; -class Situation; -class Steering; - class Goal { public: @@ -27,12 +28,15 @@ public: public: Creature &GetCreature() noexcept { return c; } const Creature &GetCreature() const noexcept { return c; } - Situation &GetSituation() noexcept; - const Situation &GetSituation() const noexcept; - Steering &GetSteering() noexcept; - const Steering &GetSteering() const noexcept; + Creature::Stats &GetStats() noexcept { return c.GetStats(); } + const Creature::Stats &GetStats() const noexcept { return c.GetStats(); } + Situation &GetSituation() noexcept { return c.GetSituation(); } + const Situation &GetSituation() const noexcept { return c.GetSituation(); } + Steering &GetSteering() noexcept { return c.GetSteering(); } + const Steering &GetSteering() const noexcept { return c.GetSteering(); } app::Assets &Assets() noexcept; const app::Assets &Assets() const noexcept; + math::GaloisLFSR &Random() noexcept; double Urgency() const noexcept { return urgency; } void Urgency(double u) noexcept { urgency = u; } @@ -41,9 +45,15 @@ public: void Interruptible(bool i) noexcept { interruptible = i; } bool Complete() const noexcept { return complete; } - void SetComplete() noexcept; + void SetComplete(); + void SetForeground(); + void SetBackground(); /// only supports one callback for now, new one will replace an old - void OnComplete(Callback) noexcept; + void WhenComplete(Callback) noexcept; + void WhenForeground(Callback) noexcept; + /// on background will not be called when the goal is first inserted + /// but only after is has been in the foreground once + void WhenBackground(Callback) noexcept; public: virtual std::string Describe() const = 0; @@ -51,9 +61,16 @@ public: virtual void Tick(double dt) { } virtual void Action() { } +private: + virtual void OnComplete() { } + virtual void OnForeground() { } + virtual void OnBackground() { } + private: Creature &c; Callback on_complete; + Callback on_foreground; + Callback on_background; double urgency; bool interruptible; bool complete;