X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FNeed.hpp;h=295b00f7161448490a06088d7b2ba6fd6075e6a2;hb=e99964b46daba40b1fad1224a42f5ea9f18d1642;hp=93d46e84a5ed7dd15631087ccb43743b0d9a3c4d;hpb=343b4f7e7cdd53dc1eab7dc32196ae5fa604ba48;p=blobs.git diff --git a/src/creature/Need.hpp b/src/creature/Need.hpp index 93d46e8..295b00f 100644 --- a/src/creature/Need.hpp +++ b/src/creature/Need.hpp @@ -1,24 +1,41 @@ #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; + // factor of the intake that may stay in the body + double growth = 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; };