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