]> git.localhorst.tv Git - blobs.git/blob - src/creature/Goal.hpp
2ec03bf255e7baa23f792e7d52a3188364d2e6f5
[blobs.git] / src / creature / Goal.hpp
1 #ifndef BLOBS_CREATURE_GOAL_HPP_
2 #define BLOBS_CREATURE_GOAL_HPP_
3
4 #include <functional>
5 #include <string>
6
7
8 namespace blobs {
9 namespace creature {
10
11 class Creature;
12 class Situation;
13 class Steering;
14
15 class Goal {
16
17 public:
18         using Callback = std::function<void(Goal &)>;
19
20 public:
21         explicit Goal(Creature &);
22         virtual ~Goal() noexcept;
23
24 public:
25         Creature &GetCreature() noexcept { return c; }
26         const Creature &GetCreature() const noexcept { return c; }
27         Situation &GetSituation() noexcept;
28         const Situation &GetSituation() const noexcept;
29         Steering &GetSteering() noexcept;
30         const Steering &GetSteering() const noexcept;
31
32         double Urgency() const noexcept { return urgency; }
33         void Urgency(double u) noexcept { urgency = u; }
34
35         bool Interruptible() const noexcept { return interruptible; }
36         void Interruptible(bool i) noexcept { interruptible = i; }
37
38         bool Complete() const noexcept { return complete; }
39         void SetComplete() noexcept;
40         /// only supports one callback for now, new one will replace an old
41         void OnComplete(Callback) noexcept;
42
43 public:
44         virtual std::string Describe() const = 0;
45         virtual void Enable() { }
46         virtual void Tick(double dt) { }
47         virtual void Action() { }
48
49 private:
50         Creature &c;
51         Callback on_complete;
52         double urgency;
53         bool interruptible;
54         bool complete;
55
56 };
57
58 }
59 }
60
61 #endif