载入中...
搜索中...
未找到
ActionBlockRuntime.cpp
浏览该文件的文档.
2
3#include <utility>
4
5namespace eve::action {
6namespace {
7
8} // namespace
9
12 "Action block context does not match advance", "executionId"));
13 context.time = advance.totalElapsed;
14 for (const auto& event : advance.timelineEvents) {
15 auto dispatched = registry_.dispatch(event, context);
16 if (!dispatched) return dispatched;
17 }
18 for (const auto& block : advance.activeBlocks) {
19 auto updated = registry_.dispatchUpdate(block, context);
20 if (!updated) return updated;
21 }
22 auto maintained = registry_.advanceHandlers(context);
23 if (!maintained) return maintained;
24 if (advance.activeBlocks.empty())
25 active_.erase(advance.id);
26 else
27 active_[advance.id] = advance.activeBlocks;
29}
30
32 const auto found = active_.find(context.executionId);
33 if (found == active_.end()) return Result<void>::success(Status::success(StatusCode::NoOp));
34 context.interrupted = true;
35 auto& blocks = found->second;
36 while (!blocks.empty()) {
37 const auto& block = blocks.front();
38 ActionTimelineEvent event{ActionTimelineEventKind::StateExit, block.trackId, block.itemId, block.type,
39 context.time, block.payload};
40 auto dispatched = registry_.dispatch(event, context);
41 if (!dispatched) return dispatched;
42 blocks.erase(blocks.begin());
43 }
44 active_.erase(found);
46}
47
48Result<void> ActionBlockRuntime::sample(const std::vector<ActionActiveBlock>& blocks, ActionNotifyContext context) const {
49 context.preview = true;
50 context.scrubbing = true;
51 for (const auto& block : blocks) {
52 auto sampled = registry_.dispatchSample(block, context);
53 if (!sampled) return sampled;
54 }
56}
57
58} // namespace eve::action
Deterministic notify-state lifecycle routing.
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
bool found
const VegetationPresetContext & context
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Result< void > apply(const ActionAdvance &advance, ActionNotifyContext context)
Deliver boundaries and active updates from one authoritative advance.
Result< void > interrupt(ActionNotifyContext context)
Emit paired exits for all blocks retained for one interrupted execution.
Result< void > sample(const std::vector< ActionActiveBlock > &blocks, ActionNotifyContext context) const
Evaluate active blocks for editor scrubbing without retaining lifecycle state.
Result< void > dispatchSample(const ActionActiveBlock &block, const ActionNotifyContext &context) const
Route one side-effect-free preview sample to its registered handler.
Result< void > dispatchUpdate(const ActionActiveBlock &block, const ActionNotifyContext &context)
Route one authoritative active-state update to its registered handler.
Result< void > advanceHandlers(const ActionNotifyContext &context)
Advance each unique registered handler once in lexical type order.
Result< void > dispatch(const ActionTimelineEvent &event, const ActionNotifyContext &context)
Validate and route an event, failing observably when no handler is present.
Result payload for one deterministic advance call.
Definition Action.h:175
Duration totalElapsed
Total simulation duration consumed by the execution.
Definition Action.h:185
std::vector< ActionTimelineEvent > timelineEvents
Owning timeline boundaries crossed by this advance.
Definition Action.h:187
std::vector< ActionActiveBlock > activeBlocks
Owning samples of timeline states active after this advance.
Definition Action.h:189
ActionExecutionId id
Execution advanced by this call.
Definition Action.h:177
Context linking a routed event to its action execution.
Owning event projection returned by the runtime sampler.