载入中...
搜索中...
未找到
Organism.cpp
浏览该文件的文档.
96double Organism::needPermille(const std::string& needId) { return meterOrZero(*vitalNeeds(), needId); }
111 Diagnostic::error(DiagnosticCode::PreconditionViolation, "organism is dead", "growth.organism.refillNeed"));
115 DiagnosticCode::InvalidArgument, "need amount must be finite and >= 0", "growth.organism.refillNeed"));
126 GrowthWorld::instance().emit(GrowthEventKind::Watered, *this, needId + ":" + std::to_string(permille));
140 Diagnostic::error(DiagnosticCode::PreconditionViolation, "organism is dead", "growth.organism.harvest"));
148 DiagnosticCode::PreconditionViolation, "organism already harvested", "growth.organism.harvest"));
167 GrowthWorld::instance().emit(GrowthEventKind::Harvested, *this, std::to_string(static_cast<int>(yields.size())));
Stable, structured diagnostics shared by engine modules.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static GrowthWorld & instance()
Process-wide world used by Organism helpers and the Growth module.
Definition GrowthSystem.cpp:60
Result< std::vector< YieldReceipt > > harvest()
Harvests once when mature and harvestYield is non-empty (any lifeform). @cost Moderate: copies yield ...
Definition Organism.cpp:137
static const std::vector< Organism * > & liveOrganisms()
Live organisms currently visible to Growth views.
Definition Organism.cpp:52
Result< void > waterBy(double permille)
Adds water when the species declares a water need. @cost Cheap: O(1) meter write + optional event.
Definition Organism.cpp:131
Result< void > feed(double permille)
Adds food when the species declares a food need. @cost Cheap: O(1) meter write + optional event.
Definition Organism.cpp:133
Result< void > fertilize(double permille)
Adds fertility when the species declares a fertility need. @cost Cheap: O(1) meter write + optional e...
Definition Organism.cpp:135
static Result< Organism * > createOrganism(const std::string &speciesId)
Creates an organism bound to a registered species.
Definition Organism.cpp:25
double needPermille(const std::string &needId)
Generic meter read; missing need returns 0.
Definition Organism.cpp:96
std::uint64_t stableId() const noexcept
Stable ECS id for event correlation.
Definition Organism.cpp:171
double waterPermille()
Convenience meters when the species declares water/food/fertility needs.
Definition Organism.cpp:90
Result< void > refillNeed(const std::string &needId, double permille)
Refills a named need declared by the species. @cost Cheap: O(1) meter write + optional event.
Definition Organism.cpp:98
static const SpeciesDef * find(const std::string &id)
Looks up a species; nullptr when missing. @ownership Borrowed from the process-wide registry; caller ...
Definition Species.cpp:540
Definition Growth.cpp:11
@ Fertilized
@ Harvested
OrganismKind
Optional Earth-biology label; custom lifeforms use Custom + free-form kindId.
Definition Species.h:18
@ InvalidArgument
@ NotFound
@ PreconditionViolation
Named vital meter (water, radiation, ether, …) — not fixed to Earth biology.
Definition Species.h:35
Static species definition — fully data-driven life cycle.
Definition Species.h:81
OrganismKind kind
Convenience label derived from kindId when plant/animal; else Custom.
Definition Species.h:87
bool hasNeed(std::string_view needId) const
True when the species declares a need meter with this id.
Definition Species.h:112
One harvested or produced item line (no inventory dependency).
Definition Organism.h:18