X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2FGoal.hpp;h=4d3a17f431382d616a8f4828f7e1f9f3ee64529b;hp=9ffeb0f006878f08e96f044436a8ab6987204130;hb=75398ab9230c15215e7a378a26d2d55de67b47f0;hpb=cd80d7cfcac3c58d601db2ab4e0381dd77c06f44 diff --git a/src/creature/Goal.hpp b/src/creature/Goal.hpp index 9ffeb0f..4d3a17f 100644 --- a/src/creature/Goal.hpp +++ b/src/creature/Goal.hpp @@ -9,6 +9,9 @@ namespace blobs { namespace app { struct Assets; } +namespace math { + class GaloisLFSR; +} namespace creature { class Creature; @@ -33,6 +36,7 @@ public: const Steering &GetSteering() const noexcept; 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;