载入中...
搜索中...
未找到
ActionNotifyRegistry.cpp
浏览该文件的文档.
27 Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) override {
29 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "camera cue must be instantaneous", "event.kind"));
39 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "no camera sink accepts the action cue", binding.value().cue.format()));
45 Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) override {
47 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "damage block must be instantaneous", "event.kind"));
51 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "damage target index is unavailable", "targetIndex"));
59 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "no damage sink accepts the action target", "target"));
65 Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) override {
67 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "gameplay event block must be instantaneous", "event.kind"));
76 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "no gameplay event sink is registered", binding.value().tag));
82 Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) override {
83 if (event.kind != ActionTimelineEventKind::StateEnter && event.kind != ActionTimelineEventKind::StateExit)
84 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "state window requires enter or exit", "event.kind"));
96 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "no state-window sink accepts the action block", event.type.format()));
102 Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) override {
109 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "parameter curve requires state boundaries", "event.kind"));
122 Result<void> update(const ActionActiveBlock& block, const ActionNotifyContext& context) override {
126 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "parameter curve block duration must be positive", "duration"));
127 const double progress = std::clamp(block.localTime.seconds() / block.duration.seconds(), 0.0, 1.0);
131 const auto phase = found == active_.end() ? ActionParameterPhase::Begin : ActionParameterPhase::Update;
140 Result<void> sample(const ActionActiveBlock& block, const ActionNotifyContext&) const override {
144 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "parameter curve block duration must be positive", "duration"));
164 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "no parameter sink accepts the action target", sample.target.format()));
176 {"combat:damage", "Apply Damage", "Combat", ActionNotifyShape::Instant, {"damageType", "amount"}},
177 {"presentation:vfx", "Spawn VFX", "Presentation", ActionNotifyShape::Instant, {"uri", "lifetimeSeconds"}},
179 {"presentation:attack-vfx", "Attack VFX", "Presentation", ActionNotifyShape::Instant, {"lifetimeSeconds"}},
180 {"presentation:attack-vfx-state", "Attack VFX State", "Presentation", ActionNotifyShape::State, {}},
186 {"combat:invulnerability-window", "Invulnerability Window", "Combat", ActionNotifyShape::State, {}},
190 {"collision:ignore-window", "Collision Ignore", "Collision", ActionNotifyShape::State, {"channel"}},
202 auto cameraHandler = registry.registerHandler("presentation:camera", std::make_shared<ActionCameraCueHandler>());
204 auto damageHandler = registry.registerHandler("combat:damage", std::make_shared<ActionDamageHandler>());
208 if (!gameplayEventHandler) return Result<ActionNotifyRegistry>::failure(gameplayEventHandler.status());
210 for (const char* type : {"collision:ignore-window", "combat:hitbox-window", "combat:invulnerability-window",
228 if (!validType(descriptor.type)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Notify type is invalid", "type"));
230 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Notify display name is empty", "displayName"));
232 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Notify category is empty", "category"));
235 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Required payload field is empty", "requiredPayloadFields"));
238 return Result<void>::failure(Diagnostic::error(DiagnosticCode::AlreadyExists, "Notify descriptor is already registered", key));
246 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "Notify descriptor is not registered", std::string(type)));
247 if (!handler) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Notify handler is null", "handler"));
249 return Result<void>::failure(Diagnostic::error(DiagnosticCode::AlreadyExists, "Notify handler is already registered", std::string(type)));
257 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "Notify handler is not registered", std::string(type)));
266 Diagnostic::error(DiagnosticCode::NotFound, "Notify descriptor is not registered", std::string(type)));
277bool ActionNotifyRegistry::hasHandler(std::string_view type) const noexcept { return handlers_.contains(type); }
282 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "Timeline event notify type is not registered", event.type.format()));
285 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Timeline event boundary does not match notify shape", event.type.format()));
288 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Timeline event is missing required payload field", field));
293 if (event.type.format() == "presentation:audio" || event.type.format() == "presentation:audio-state") {
299 if (event.type.format() == "presentation:vfx" || event.type.format() == "presentation:vfx-state") {
307 const auto shape = event.kind == ActionTimelineEventKind::Notify ? ActionAttackVfxShape::Instant
328 if (event.type.format() == "collision:ignore-window" || event.type.format() == "combat:hitbox-window" ||
337Result<void> ActionNotifyRegistry::dispatch(const ActionTimelineEvent& event, const ActionNotifyContext& context) {
342 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "No runtime handler is registered for notify type", event.type.format()));
346Result<void> ActionNotifyRegistry::dispatchUpdate(const ActionActiveBlock& block, const ActionNotifyContext& context) {
347 ActionTimelineEvent event{ActionTimelineEventKind::StateEnter, block.trackId, block.itemId, block.type,
353 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "No runtime handler is registered for notify type", block.type.format()));
359 ActionTimelineEvent event{ActionTimelineEventKind::StateEnter, block.trackId, block.itemId, block.type,
365 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "No preview handler is registered for notify type", block.type.format()));
Typed AttackVfx action-block payload contract.
Typed audio action-block payload contract.
Typed camera-cue action block contract.
Typed instantaneous combat-damage action contract.
Typed instantaneous gameplay-event action contract.
Extensible notify descriptors, validation and runtime routing.
Typed continuous parameter-curve action block.
Typed payload contract for prefab-spawn action states.
Typed combat/input/collision action-state window contracts.
Typed VFX action-block payload contract.
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
const std::string & format() const noexcept
Returns the canonical namespace:name representation.
Definition Identity.h:436
static std::optional< LogicalId > parse(std::string_view text)
Parses a scoped logical name.
Definition Identity.cpp:36
const Status & status() const noexcept
Inspect the structured operation status.
Definition Result.h:269
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
Canonical notify descriptor owner and runtime handler router.
Definition ActionNotifyRegistry.h:138
Result< void > registerHandler(std::string_view type, std::shared_ptr< IActionNotifyHandler > handler)
Register an owning handler for an existing descriptor.
Definition ActionNotifyRegistry.cpp:243
Result< void > unregisterHandler(std::string_view type)
Remove a handler while retaining its descriptor for authoring.
Definition ActionNotifyRegistry.cpp:254
Result< void > dispatchSample(const ActionActiveBlock &block, const ActionNotifyContext &context) const
Route one side-effect-free preview sample to its registered handler.
Definition ActionNotifyRegistry.cpp:357
bool hasHandler(std::string_view type) const noexcept
Return whether this registry has a runtime handler for the exact canonical type.
Definition ActionNotifyRegistry.cpp:277
Result< void > validate(const ActionTimelineEvent &event) const
Validate type, shape and required payload fields.
Definition ActionNotifyRegistry.cpp:279
std::vector< ActionNotifyDescriptor > descriptors() const
Return descriptors in lexical type order.
Definition ActionNotifyRegistry.cpp:270
Result< void > dispatchUpdate(const ActionActiveBlock &block, const ActionNotifyContext &context)
Route one authoritative active-state update to its registered handler.
Definition ActionNotifyRegistry.cpp:346
Result< void > registerDescriptor(ActionNotifyDescriptor descriptor)
Register a unique descriptor after validating its canonical type.
Definition ActionNotifyRegistry.cpp:227
Result< void > advanceHandlers(const ActionNotifyContext &context)
Advance each unique registered handler once in lexical type order.
Definition ActionNotifyRegistry.cpp:369
Result< void > dispatch(const ActionTimelineEvent &event, const ActionNotifyContext &context)
Validate and route an event, failing observably when no handler is present.
Definition ActionNotifyRegistry.cpp:337
static Result< ActionNotifyRegistry > withBuiltins()
Build a registry containing the engine's standard semantic notify types.
Definition ActionNotifyRegistry.cpp:172
Result< ActionNotifyDescriptor > descriptor(std::string_view type) const
Find an owning descriptor copy.
Definition ActionNotifyRegistry.cpp:262
Optional module provider that installs handlers into a new registry.
Definition ActionNotifyRegistry.h:117
virtual Result< void > install(ActionNotifyRegistry ®istry)=0
Install provider-owned handler instances for known descriptors.
Definition AbilityAsset.cpp:9
@ Instant
@ StateEnter
ActionParameterOperation
Composition operation applied by a target-specific parameter sink.
Definition ActionParameterCurve.h:21
Result< T > applied(T value, std::vector< Diagnostic > diagnostics={})
Construct an Applied result with an owning payload and optional diagnostics.
Definition EditingResult.h:43
WidgetDesc progress(float fraction, std::string id, std::string overlay)
Progress bar; fraction is clamped to [0,1].
Definition Widget.cpp:395
@ InvalidArgument
@ NotFound
@ AlreadyExists
@ NoOp
@ Applied
Owning per-step sample of one currently active timeline state.
Definition ActionTimeline.h:159
static Result< ActionAttackVfxBinding > fromPayload(const Value::Object &payload, ActionAttackVfxShape shape)
Decode one dynamic AttackVfx payload transactionally.
Definition ActionAttackVfxBlock.cpp:30
static Result< ActionAudioBinding > fromPayload(const Value::Object &payload, ActionAudioShape shape)
Decode an audio payload transactionally.
Definition ActionAudioBlock.cpp:30
static Result< ActionCameraCueBinding > fromPayload(const Value::Object &payload)
Decode a camera cue transactionally.
Definition ActionCameraBlock.cpp:30
static Result< ActionDamageBinding > fromPayload(const Value::Object &payload)
Decode and validate a damage payload without mutating combat state.
Definition ActionDamageBlock.cpp:35
static Result< ActionGameplayEventBinding > fromPayload(const Value::Object &payload)
Decode and validate an event payload without emitting it.
Definition ActionGameplayEventBlock.cpp:13
Context linking a routed event to its action execution.
Definition ActionNotifyRegistry.h:34
Owning editor/runtime contract for one notify type.
Definition ActionNotifyRegistry.h:25
static Result< ActionParameterCurveBinding > fromPayload(const Value::Object &payload)
Decode and validate target, operation and normalized ordered keys.
Definition ActionParameterCurve.cpp:65
static Result< ActionPrefabSpawnBinding > fromPayload(const Value::Object &payload)
Decode a prefab-spawn payload without mutating runtime state.
Definition ActionPrefabBlock.cpp:48
static Result< ActionStateWindowBinding > fromPayload(std::string_view type, const Value::Object &payload)
Decode one known state-window payload without mutating domain state.
Definition ActionStateWindowBlock.cpp:31
Owning event projection returned by the runtime sampler.
Definition ActionTimeline.h:146
static Result< ActionVfxBinding > fromPayload(const Value::Object &payload, ActionVfxShape shape)
Decode one dynamic VFX payload transactionally.
Definition ActionVfxBlock.cpp:29