]> git.localhorst.tv Git - blobs.git/blob - src/creature/Need.hpp
67abe3c496d9ceab645625a986920cdee3a29c84
[blobs.git] / src / creature / Need.hpp
1 #ifndef BLOBS_CREATURE_NEED_HPP_
2 #define BLOBS_CREATURE_NEED_HPP_
3
4 #include <string>
5
6
7 namespace blobs {
8 namespace creature {
9
10 class Creature;
11 class Effect;
12
13 struct Need {
14
15         std::string name;
16
17         double value = 0.0;
18
19         // how fast value grows per second
20         double gain = 0.0;
21         // the value at which this need is no longer satisfied
22         double inconvenient = 0.0;
23         // the value at which this need starts to hurt
24         double critical = 0.0;
25
26         virtual ~Need() noexcept;
27
28         void Tick(double dt) noexcept;
29         void Increase(double) noexcept;
30         void Decrease(double) noexcept;
31
32         bool IsSatisfied() const noexcept { return value < inconvenient; }
33         bool IsInconvenient() const noexcept { return value >= inconvenient && value < critical; }
34         bool IsCritical() const noexcept { return value >= critical; }
35
36         virtual void ApplyEffect(Creature &, double dt) = 0;
37
38 };
39
40 }
41 }
42
43 #endif