载入中...
搜索中...
未找到
Growth.cpp
浏览该文件的文档.
15Result<int> Growth::registerSpeciesFromJson(const std::string& json) { return SpeciesRegistry::loadFromJson(json); }
23Result<void> Growth::setDaysPerSeason(int days) { return GrowthWorld::instance().calendar().setDaysPerSeason(days); }
35Result<void> Growth::advanceDays(double days) { return GrowthWorld::instance().advanceDays(days); }
56Result<Organism*> Growth::spawn(const std::string& speciesId) { return Organism::createOrganism(speciesId); }
77 Diagnostic::error(DiagnosticCode::InvalidArgument, "species is not an animal", "growth.spawnAnimal"));
85 Diagnostic::error(DiagnosticCode::InvalidArgument, "breed partners must not be null", "growth.tryBreed"));
93 Diagnostic::error(DiagnosticCode::InvalidArgument, "organism must not be null", "growth.tryReproduce"));
133 table.addClass<Organism>("Organism", std::function<Organism*()>([]() -> Organism* { return nullptr; }), false);
157 organism.addFunc("kindId", [](Organism* self) { return self ? self->kindId() : std::string{}; });
158 organism.addFunc("kindName", [](Organism* self) { return self ? self->kindId() : std::string{}; });
162 organism.addFunc("refillNeed", [vm = organism.getHandle()](Organism* self, const std::string& needId, float amount) {
217 cls.addFunc("registerSpeciesFromJson", [vm = cls.getHandle()](Growth* self, const std::string& json) {
238 cls.addFunc("setSeasonLayoutFromJson", [vm = cls.getHandle()](Growth* self, const std::string& json) {
Stable, structured diagnostics shared by engine modules.
The single Squirrel projection for common Result, Status and Value.
Common time values and an injectable deterministic simulation clock.
Owning, renderer-independent dynamic values.
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< Duration > fromSeconds(double seconds)
Convert finite seconds to the nearest nanosecond.
Definition Time.cpp:17
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
Definition StrongUint64.h:24
Result< void > setSeasonLayoutFromJson(std::string_view json)
Parses [{"id":"bloom","days":40},…] and applies setSeasonLayout. @cost Cheap JSON parse of a small ar...
Definition GrowthCalendar.cpp:39
std::string seasonId() const
Current season id string (never empty when layout is valid).
Definition GrowthCalendar.cpp:117
std::int64_t year() const noexcept
0-based year from dayIndex / yearLength.
Definition GrowthCalendar.cpp:105
Result< void > setDaysPerSeason(int days) noexcept
Sets every slot's day count (keeps current ids). Positive only.
Definition GrowthCalendar.cpp:81
std::int64_t dayIndex() const noexcept
Absolute simulation day index (0-based).
Definition GrowthCalendar.h:56
const GrowthEvent * at(int index) const
Borrowed event at index, or nullptr when out of range. @ownership Borrowed from this log; caller must...
Definition GrowthEvents.cpp:11
static const char * kindName(GrowthEventKind kind) noexcept
Stable English spelling for an event kind.
Definition GrowthEvents.cpp:16
Result< void > advanceDays(double days)
Advances every live organism by simulation days (may be fractional). @cost Linear in organism count ×...
Definition GrowthSystem.cpp:104
static GrowthWorld & instance()
Process-wide world used by Organism helpers and the Growth module.
Definition GrowthSystem.cpp:60
Result< void > setSecondsPerSimDay(double seconds) noexcept
Seconds of SimulationStep.delta that equal one simulation day.
Definition GrowthSystem.cpp:70
Result< void > tryBreed(Organism &carrier, Organism &partner)
Starts pair_gestation on carrier when both partners satisfy the species rules. @cost Cheap validation...
Definition GrowthSystem.cpp:318
Result< void > tryReproduce(Organism &organism)
Triggers a solo reproduction pulse for self_bud / fission / spore_burst.
Definition GrowthSystem.cpp:363
static void resetInstance()
Replaces process instance with a fresh world (tests).
Definition GrowthSystem.cpp:62
void setRngSeed(std::uint64_t seed) noexcept
Deterministic seed for disease / yield hash streams.
Definition GrowthSystem.h:28
Result< void > step(const SimulationStep &step)
Converts a fixed SimulationStep into fractional sim days and advances. @cost Linear in live organism ...
Definition GrowthSystem.cpp:95
Farm growth module facade (eve.Growth): species registry + world step.
Definition Growth.h:19
Result< Organism * > spawn(const std::string &speciesId)
Spawns any registered species (plant, animal, or custom lifeform).
Definition Growth.cpp:56
Result< void > setSecondsPerSimDay(double seconds)
Definition Growth.cpp:29
Result< int > registerSpeciesFromJson(const std::string &json)
Registers species from a JSON object or array.
Definition Growth.cpp:15
std::string eventSpeciesId(int index) const
Definition Growth.cpp:113
Result< Organism * > plant(const std::string &speciesId)
Convenience: spawn when species.kindId == "plant".
Definition Growth.cpp:58
Result< void > tryReproduce(Organism *organism)
Solo reproduction for self_bud / fission / spore_burst species.
Definition Growth.cpp:90
Result< Organism * > spawnAnimal(const std::string &speciesId)
Convenience: spawn when species.kindId == "animal".
Definition Growth.cpp:70
Result< void > setSeasonLayoutFromJson(const std::string &json)
Configures a custom season layout from JSON (alien year cycles). @cost Cheap: parses a small season t...
Definition Growth.cpp:25
std::uint64_t eventOrganismId(int index) const
Definition Growth.cpp:108
Result< void > setDaysPerSeason(int days)
Definition Growth.cpp:23
Result< void > tryBreed(Organism *carrier, Organism *partner)
Definition Growth.cpp:82
static Result< Organism * > createOrganism(const std::string &speciesId)
Creates an organism bound to a registered species.
Definition Organism.cpp:25
static Result< int > loadFromJson(std::string_view json)
Parses a JSON object or array of species and registers each.
Definition Species.cpp:508
Definition Growth.cpp:11
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
@ InvalidArgument