1 #ifndef BLOBS_CREATURE_GOAL_HPP_
2 #define BLOBS_CREATURE_GOAL_HPP_
4 #include "Creature.hpp"
22 using Callback = std::function<void(Goal &)>;
25 explicit Goal(Creature &);
26 virtual ~Goal() noexcept;
29 Creature &GetCreature() noexcept { return c; }
30 const Creature &GetCreature() const noexcept { return c; }
31 Creature::Stats &GetStats() noexcept { return c.GetStats(); }
32 const Creature::Stats &GetStats() const noexcept { return c.GetStats(); }
33 Situation &GetSituation() noexcept { return c.GetSituation(); }
34 const Situation &GetSituation() const noexcept { return c.GetSituation(); }
35 Steering &GetSteering() noexcept { return c.GetSteering(); }
36 const Steering &GetSteering() const noexcept { return c.GetSteering(); }
37 app::Assets &Assets() noexcept;
38 const app::Assets &Assets() const noexcept;
39 math::GaloisLFSR &Random() noexcept;
41 double Urgency() const noexcept { return urgency; }
42 void Urgency(double u) noexcept { urgency = u; }
44 bool Interruptible() const noexcept { return interruptible; }
45 void Interruptible(bool i) noexcept { interruptible = i; }
47 bool Complete() const noexcept { return complete; }
51 /// only supports one callback for now, new one will replace an old
52 void WhenComplete(Callback) noexcept;
53 void WhenForeground(Callback) noexcept;
54 /// on background will not be called when the goal is first inserted
55 /// but only after is has been in the foreground once
56 void WhenBackground(Callback) noexcept;
59 virtual std::string Describe() const = 0;
60 virtual void Enable() { }
61 virtual void Tick(double dt) { }
62 virtual void Action() { }
65 virtual void OnComplete() { }
66 virtual void OnForeground() { }
67 virtual void OnBackground() { }
72 Callback on_foreground;
73 Callback on_background;