2 #include "InhaleNeed.hpp"
3 #include "IngestNeed.hpp"
5 #include "Creature.hpp"
6 #include "LocateResourceGoal.hpp"
7 #include "../world/Planet.hpp"
8 #include "../world/TileType.hpp"
17 void Need::Tick(double dt) noexcept {
21 void Need::Increase(double delta) noexcept {
22 value = std::min(1.0, value + delta);
25 void Need::Decrease(double delta) noexcept {
26 value = std::max(0.0, value - delta);
30 IngestNeed::IngestNeed(int resource, double speed, double damage)
38 IngestNeed::~IngestNeed() {
41 void IngestNeed::ApplyEffect(Creature &c, double dt) {
46 if (c.GetSituation().OnSurface()) {
47 const world::TileType &t = c.GetSituation().GetTileType();
49 for (auto &yield : t.resources) {
50 if (yield.resource == resource) {
52 // TODO: check if not busy with something else
53 Decrease(std::min(yield.ubiquity, speed) * dt);
61 if (!found && !locating) {
62 c.AddGoal(std::unique_ptr<Goal>(new LocateResourceGoal(resource)));
73 InhaleNeed::InhaleNeed(int resource, double speed, double damage)
80 InhaleNeed::~InhaleNeed() {
83 void InhaleNeed::ApplyEffect(Creature &c, double dt) {
88 if (c.GetSituation().OnPlanet() && c.GetSituation().GetPlanet().Atmosphere() == resource) {