X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FGoal.hpp;h=4d3a17f431382d616a8f4828f7e1f9f3ee64529b;hb=d921cba26f21e4a75b22f5e9d9be988707bf6a8f;hp=d664e6b7815509cdec12037582bdac2a5f7cc78d;hpb=8a3907bb0bed257bf5d6f40f39f15114e8345913;p=blobs.git diff --git a/src/creature/Goal.hpp b/src/creature/Goal.hpp index d664e6b..4d3a17f 100644 --- a/src/creature/Goal.hpp +++ b/src/creature/Goal.hpp @@ -1,18 +1,43 @@ #ifndef BLOBS_CREATURE_GOAL_HPP_ #define BLOBS_CREATURE_GOAL_HPP_ +#include +#include + + namespace blobs { +namespace app { + struct Assets; +} +namespace math { + class GaloisLFSR; +} namespace creature { class Creature; +class Situation; +class Steering; class Goal { public: - Goal(); + using Callback = std::function; + +public: + explicit Goal(Creature &); virtual ~Goal() noexcept; 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; + 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; } @@ -20,14 +45,32 @@ public: void Interruptible(bool i) noexcept { interruptible = i; } bool Complete() const noexcept { return complete; } - void Complete(bool i) noexcept { complete = i; } + void SetComplete(); + void SetForeground(); + void SetBackground(); + /// only supports one callback for now, new one will replace an old + 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 void Enable(Creature &) { } + virtual std::string Describe() const = 0; + virtual void Enable() { } virtual void Tick(double dt) { } - virtual void Action(Creature &) { } + 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;