1 #ifndef BLOBS_CREATURE_GOAL_HPP_
2 #define BLOBS_CREATURE_GOAL_HPP_
24 using Callback = std::function<void(Goal &)>;
27 explicit Goal(Creature &);
28 virtual ~Goal() noexcept;
31 Creature &GetCreature() noexcept { return c; }
32 const Creature &GetCreature() const noexcept { return c; }
33 Situation &GetSituation() noexcept;
34 const Situation &GetSituation() const noexcept;
35 Steering &GetSteering() noexcept;
36 const Steering &GetSteering() const noexcept;
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;