X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2Fgoal.cpp;h=f3e0891c1e1ca5cf7e6b98846f4ed43aca0688f2;hp=06a689f2e0d6d1cebbe29e3c75c7224470bed6ab;hb=392826deaf802ac0960ed3924a3f98b9d18d381b;hpb=b4deadd9f4e399207e2530ea39a447c0d9d260a3 diff --git a/src/creature/goal.cpp b/src/creature/goal.cpp index 06a689f..f3e0891 100644 --- a/src/creature/goal.cpp +++ b/src/creature/goal.cpp @@ -37,8 +37,16 @@ std::string BlobBackgroundTask::Describe() const { void BlobBackgroundTask::Tick(double dt) { if (breathing) { // TODO: derive breathing ability + int gas = Assets().data.resources["air"].id; + // TODO: check if in compatible atmosphere double amount = GetCreature().GetStats().Breath().gain * -(1.5 + 0.5 * GetCreature().ExhaustionFactor()); GetCreature().GetStats().Breath().Add(amount * dt); + // maintain ~2.5% gas composition + double gas_amount = GetCreature().GetComposition().Get(gas); + if (gas_amount < GetCreature().GetComposition().TotalMass() * 0.025) { + double add = std::min(GetCreature().GetComposition().TotalMass() * 0.025 - gas_amount, -amount * dt); + GetCreature().Ingest(gas, add); + } if (GetCreature().GetStats().Breath().Empty()) { breathing = false; }