X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FNeed.hpp;h=67abe3c496d9ceab645625a986920cdee3a29c84;hb=8a3907bb0bed257bf5d6f40f39f15114e8345913;hp=93d46e84a5ed7dd15631087ccb43743b0d9a3c4d;hpb=343b4f7e7cdd53dc1eab7dc32196ae5fa604ba48;p=blobs.git diff --git a/src/creature/Need.hpp b/src/creature/Need.hpp index 93d46e8..67abe3c 100644 --- a/src/creature/Need.hpp +++ b/src/creature/Need.hpp @@ -1,24 +1,39 @@ #ifndef BLOBS_CREATURE_NEED_HPP_ #define BLOBS_CREATURE_NEED_HPP_ +#include + + namespace blobs { namespace creature { +class Creature; +class Effect; + struct Need { - int resource = -1; + std::string name; + double value = 0.0; // how fast value grows per second double gain = 0.0; // the value at which this need is no longer satisfied + double inconvenient = 0.0; + // the value at which this need starts to hurt double critical = 0.0; - // the price to pay for not satsfying the need - double penalty = 0.0; + + virtual ~Need() noexcept; void Tick(double dt) noexcept; + void Increase(double) noexcept; + void Decrease(double) noexcept; + + bool IsSatisfied() const noexcept { return value < inconvenient; } + bool IsInconvenient() const noexcept { return value >= inconvenient && value < critical; } + bool IsCritical() const noexcept { return value >= critical; } - bool IsSatisfied() const noexcept { return value < critical; } + virtual void ApplyEffect(Creature &, double dt) = 0; };