载入中...
搜索中...
未找到
RTSEconomy.cpp
浏览该文件的文档.
16 const eve::resource::CostSpec& cost, eve::transaction::ITransactionParticipant& effect, std::string transactionId) {
27 const eve::resource::CostSpec& cost, std::span<eve::transaction::ITransactionParticipant*> effects,
97 return eve::Result<RTSEffectUpdate>::success(std::move(result), eve::Status::success(eve::StatusCode::Applied));
100eve::Result<effects::EffectHandle> RTSEffectAdapter::apply(const RTSEffectDefinition& definition,
104 eve::DiagnosticCode::InvalidArgument, "RTS effect requires an id and valid subject", "effect"));
155 return eve::Result<RTSEffectUpdate>::success(std::move(result), eve::Status::success(eve::StatusCode::Applied));
158RTSEffectSnapshot RTSEffectAdapter::snapshot() const { return {container_.snapshot(), target_}; }
169std::size_t RTSEffectAdapter::count() const noexcept { return static_cast<std::size_t>(container_.effectCount()); }
208 eve::DiagnosticCode::InvalidArgument, "RTS effect component requires a valid subject", "subject"));
217eve::Result<effects::EffectHandle> RTSEffectComponent::apply(const RTSEffectDefinition& definition) {
224eve::Result<void> RTSEffectComponent::remove(effects::EffectHandle handle) { return adapter_.remove(handle); }
RTS composition adapter over the canonical EconomyLedger account.
RTS effect adapter with morale, suppression and production policies.
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 Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
eve::Result< eve::resource::Receipt > credit(const eve::resource::CostSpec &cost) override
Atomically credit all items immediately.
Definition EconomyLedgerResourceAccount.cpp:282
EffectContainer snapshot() const
Capture an independent lifecycle snapshot for staging/restore.
Definition EffectContainer.cpp:138
eve::Result< const EffectInstance * > resolve(EffectHandle handle) const
Resolve a generation-qualified handle for this call.
Definition EffectContainer.cpp:344
eve::Result< void > remove(const std::string &id, const std::string &reason="removed")
Removes one active instance and emits a Removed event.
Definition EffectContainer.cpp:375
EffectContainer clone() const
Create an independent deep copy suitable for ECS staging.
Definition EffectContainer.cpp:136
int effectCount() const
Returns active instance count in deterministic creation order.
Definition EffectContainer.cpp:558
eve::Result< std::string > apply(const EffectDefinition &definition, const std::string &subject, const std::string &source={})
Applies a definition and returns the stable instance identifier.
Definition EffectContainer.cpp:194
eve::Result< void > restore(const EffectContainer &snapshot)
Restore a previously captured snapshot as one observable commit.
Definition EffectContainer.cpp:140
Executes lifecycle time progression for an EffectContainer.
Definition EffectContainer.h:310
eve::Result< EffectUpdateSummary > advance(EffectContainer &container, double dtSeconds) const
Advances one container by a legacy seconds delta.
Definition EffectContainer.cpp:625
void setNumber(const std::string &key, double value)
Sets a JSON number field.
Definition EffectDefinitionRuntime.cpp:332
Provider-neutral resource account contract.
Definition ResourceAccount.h:316
eve::Result< eve::resource::Receipt > credit(const eve::resource::CostSpec &cost)
Credit the ledger through the common account protocol.
Definition RTSEconomy.cpp:22
eve::resource::IResourceAccount & account() noexcept
Return the account view for direct reservation/credit operations.
Definition RTSEconomy.cpp:13
eve::Result< eve::transaction::TransactionReceipt > pay(const eve::resource::CostSpec &cost, eve::transaction::ITransactionParticipant &effect, std::string transactionId={})
Atomically pay an RTS cost and publish its domain effect.
Definition RTSEconomy.cpp:15
RTSEconomyAdapter(eve::economy::EconomyLedger &ledger)
Bind this adapter to a caller-owned RTS economy ledger.
Definition RTSEconomy.cpp:11
RTSEffectSnapshot snapshot() const
Capture effects and domain target state.
Definition RTSEconomy.cpp:158
double multiplier(std::string_view field) const noexcept
Multiply one numeric payload across all active canonical effect instances.
Definition RTSEconomy.cpp:175
eve::Result< const effects::EffectInstance * > resolve(effects::EffectHandle handle) const
Resolve a live handle as a borrowed observation.
Definition RTSEconomy.cpp:171
std::size_t count() const noexcept
Return the number of active effect instances.
Definition RTSEconomy.cpp:169
double additive(std::string_view field) const noexcept
Sum one numeric payload across all active canonical effect instances.
Definition RTSEconomy.cpp:190
eve::Result< RTSEffectUpdate > advance(const eve::SimulationStep &step)
Advance and settle RTS effects atomically.
Definition RTSEconomy.cpp:145
eve::Result< void > restore(const RTSEffectSnapshot &snapshot)
Restore effects and target state, invalidating prior handles.
Definition RTSEconomy.cpp:160
eve::Result< void > remove(effects::EffectHandle handle)
Remove one generation-qualified effect handle.
Definition RTSEconomy.cpp:139
eve::Result< effects::EffectHandle > apply(const RTSEffectDefinition &definition, eve::SubjectRef subject)
Apply one typed effect to a stable subject.
Definition RTSEconomy.cpp:100
eve::Result< effects::EffectHandle > apply(const RTSEffectDefinition &definition)
Apply a typed RTS effect to this entity's canonical lifecycle.
Definition RTSEconomy.cpp:217
eve::Result< void > bindSubject(eve::SubjectRef subject)
Bind the owning entity subject before applying effects.
Definition RTSEconomy.cpp:205
eve::Result< RTSEffectUpdate > advance(const eve::SimulationStep &step)
Advance this entity's effect lifecycle and settle domain state.
Definition RTSEconomy.cpp:226
eve::Result< void > remove(effects::EffectHandle handle)
Remove one generation-qualified effect handle.
Definition RTSEconomy.cpp:224
eve::Result< RTSEffectUpdate > settle(RTSEffectTarget &target, effects::EffectUpdateSummary lifecycle) const
Settle common periodic triggers using RTS-specific policies.
Definition RTSEconomy.cpp:66
eve::Result< void > applyImmediate(RTSEffectTarget &target, const effects::EffectInstance &effect) const
Apply immediate production-lock semantics to a staged target.
Definition RTSEconomy.cpp:58
eve::Result< void > validate(const RTSEffectTarget &target) const
Validate the target state before a staged application.
Definition RTSEconomy.cpp:51
static eve::Result< TransactionReceipt > execute(const TransactionContext &context, std::span< ITransactionParticipant * > participants)
Execute already prepared domain participants as one transaction.
Definition AtomicResourcePayment.cpp:13
Synchronous participant contract for one coordinator transaction.
Definition Transaction.h:129
Immutable context shared by every participant of one transaction.
Definition Transaction.h:31
Definition RTS.cpp:30
@ Morale
@ Suppression
@ ProductionLock
@ InvalidArgument
@ InvariantViolation
@ Conflict
@ Applied
Immutable-by-convention template used to create effect instances.
Definition EffectTypes.h:100
double period
Period in seconds for domain executor settlement; zero disables periodic ticks.
Definition EffectTypes.h:106
eve::Result< void > validate() const
Validates definition fields without changing any state.
Definition EffectDefinitionRuntime.cpp:383
Generation-qualified local reference to a canonical effect instance.
Definition EffectTypes.h:173
Summary returned by the lifecycle executor after one simulation step.
Definition EffectTypes.h:212
Typed RTS definition projected to the common lifecycle schema.
Definition RTSEffects.h:35
Mutable RTS state affected by the domain executor.
Definition RTSEffects.h:27
Result of one RTS lifecycle step and domain settlement.
Definition RTSEffects.h:51
effects::EffectUpdateSummary lifecycle
Definition RTSEffects.h:52