#pragma once #include "evo/accounting/ledger.hpp" #include "evo/core/types.hpp" namespace evo::processes { struct CaptureRate { accounting::Picojoules energy; std::uint32_t ticks; }; struct GrowthRate { std::uint64_t units; std::uint32_t ticks; }; struct ProducerConfig { CaptureRate capture; GrowthRate growth; std::uint16_t efficiency_per_thousand; accounting::Picojoules growth_cost; std::array recipe; }; struct ProducerReport { accounting::Picojoules captured; accounting::Picojoules retained; accounting::Picojoules capture_heat; std::uint64_t grown_units; std::uint64_t unmet_growth_units; auto operator<=>(const ProducerReport&) const = default; }; struct ProducerProgress { Tick tick{}; std::uint32_t capture_remainder{}; std::uint32_t growth_remainder{}; std::uint32_t efficiency_remainder{}; auto operator<=>(const ProducerProgress&) const = default; }; enum class ProducerError : std::uint8_t { invalid_config, wrong_tick, tick_exhausted, ledger_failure }; class ProducerProcess { public: [[nodiscard]] static std::expected create(ProducerConfig config, accounting::Picojoules source, std::array nutrients); [[nodiscard]] std::expected advance(Tick target); // Reservoir order: source, nutrients, producer, heat. Valid until mutation. [[nodiscard]] std::span balances() const noexcept { return ledger_.balances(); } [[nodiscard]] ProducerProgress progress() const noexcept { return progress_; } private: friend class FeedingCommunity; ProducerProcess(ProducerConfig config, accounting::Ledger ledger); ProducerConfig config_; accounting::Ledger ledger_; ProducerProgress progress_{}; }; } // namespace evo::processes