+ struct Stat {
+ // [0,1], zero being good, one bad
+ double value = 0.0;
+ // static gain per second
+ double gain = 0.0;
+ // adjust value by delta
+ void Add(double delta) noexcept {
+ value = glm::clamp(value + delta, 0.0, 1.0);
+ }
+ bool Empty() const noexcept { return value < 0.000001; }
+ bool Good() const noexcept { return value < 0.25; }
+ bool Okay() const noexcept { return value < 0.5; }
+ bool Bad() const noexcept { return !Okay(); }
+ bool Critical() const noexcept { return value > 0.75; }
+ bool Full() const noexcept { return value > 0.999999; }
+ };
+ struct Stats {
+ Stat stat[7];
+ Stat &Damage() noexcept { return stat[0]; }
+ const Stat &Damage() const noexcept { return stat[0]; }
+ Stat &Breath() noexcept { return stat[1]; }
+ const Stat &Breath() const noexcept { return stat[1]; }
+ Stat &Thirst() noexcept { return stat[2]; }
+ const Stat &Thirst() const noexcept { return stat[2]; }
+ Stat &Hunger() noexcept { return stat[3]; }
+ const Stat &Hunger() const noexcept { return stat[3]; }
+ Stat &Exhaustion() noexcept { return stat[4]; }
+ const Stat &Exhaustion() const noexcept { return stat[4]; }
+ Stat &Fatigue() noexcept { return stat[5]; }
+ const Stat &Fatigue() const noexcept { return stat[5]; }
+ Stat &Boredom() noexcept { return stat[6]; }
+ const Stat &Boredom() const noexcept { return stat[6]; }
+ };
+