载入中...
搜索中...
未找到
ActionNotifyRegistry.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7#include "action/Action.h"
10
11#include <map>
12#include <memory>
13#include <string>
14#include <string_view>
15#include <vector>
16
17namespace eve::action {
18
19class ActionNotifyRegistry;
20
22enum class ActionNotifyShape : std::uint8_t { Instant, State };
23
26 std::string type;
27 std::string displayName;
28 std::string category;
30 std::vector<std::string> requiredPayloadFields;
31};
32
38 std::optional<ecs::EntityHandle> source;
40 std::vector<ecs::EntityHandle> targets;
47 std::vector<OptionalRef<const IAttachmentPointSource>> targetAttachments;
53 double playbackRate = 1.0;
55 bool preview = false;
57 bool scrubbing = false;
59 bool interrupted = false;
60};
61
69public:
71 virtual ~IActionNotifyHandler() = default;
78 [[nodiscard]] virtual Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) = 0;
108};
109
118public:
119 static constexpr const char* capabilityName = "eve.action.notify-provider";
121 virtual ~IActionNotifyProvider() = default;
122
128 [[nodiscard]] virtual Result<void> install(ActionNotifyRegistry& registry) = 0;
129};
130
139public:
141 [[nodiscard]] static Result<ActionNotifyRegistry> withBuiltins();
143 [[nodiscard]] Result<void> registerDescriptor(ActionNotifyDescriptor descriptor);
149 [[nodiscard]] Result<void> registerHandler(std::string_view type, std::shared_ptr<IActionNotifyHandler> handler);
151 [[nodiscard]] Result<void> unregisterHandler(std::string_view type);
153 [[nodiscard]] Result<ActionNotifyDescriptor> descriptor(std::string_view type) const;
155 [[nodiscard]] std::vector<ActionNotifyDescriptor> descriptors() const;
157 [[nodiscard]] bool hasHandler(std::string_view type) const noexcept;
159 [[nodiscard]] Result<void> validate(const ActionTimelineEvent& event) const;
165 [[nodiscard]] Result<void> dispatch(const ActionTimelineEvent& event, const ActionNotifyContext& context);
171 [[nodiscard]] Result<void> dispatchUpdate(const ActionActiveBlock& block, const ActionNotifyContext& context);
177 [[nodiscard]] Result<void> dispatchSample(const ActionActiveBlock& block,
178 const ActionNotifyContext& context) const;
180 [[nodiscard]] Result<void> advanceHandlers(const ActionNotifyContext& context);
181
182private:
183 std::map<std::string, ActionNotifyDescriptor, std::less<>> descriptors_;
184 std::map<std::string, std::shared_ptr<IActionNotifyHandler>, std::less<>> handlers_;
185};
186
187} // namespace eve::action
Renderer- and ruleset-neutral gameplay action pipeline.
std::string descriptor
Vocabulary aliases for nullable and checked borrowed references.
#define EVENGINE_API_PLATFORM
Definition Export.h:107
HSQOBJECT handler
const VegetationPresetContext & context
Signed, fixed-resolution simulation duration in nanoseconds.
Definition Time.h:43
static constexpr Duration zero() noexcept
Return zero duration.
Definition Time.h:60
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 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.
Consumer-owned handler for one registered notify type.
virtual Result< void > handle(const ActionTimelineEvent &event, const ActionNotifyContext &context)=0
Consume one already validated event.
virtual ~IActionNotifyHandler()=default
Releases IActionNotifyHandler resources.
virtual Result< void > update(const ActionActiveBlock &, const ActionNotifyContext &)
Update one active state block after its boundary events were delivered.
virtual Result< void > sample(const ActionActiveBlock &, const ActionNotifyContext &) const
Evaluate one preview sample without creating persistent side effects.
virtual Result< void > advance(const ActionNotifyContext &)
Advance handler-owned transient instances after events and state updates.
Optional module provider that installs handlers into a new registry.
virtual ~IActionNotifyProvider()=default
Releases IActionNotifyProvider resources.
virtual Result< void > install(ActionNotifyRegistry &registry)=0
Install provider-owned handler instances for known descriptors.
static constexpr const char * capabilityName
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
ActionNotifyShape
Declares whether a notify is instantaneous or an enter/exit state.
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
Owning per-step sample of one currently active timeline state.
Context linking a routed event to its action execution.
double playbackRate
Finite positive host playback multiplier used by synchronized presentation blocks.
bool scrubbing
Whether preview time was positioned discontinuously.
std::optional< ecs::EntityHandle > source
Optional source entity; resolved by consumers at call time.
bool interrupted
Whether state exits are being synthesized because the execution was interrupted.
OptionalRef< const IAttachmentPointSource > sourceAttachment
Optional borrowed animated attachment source corresponding to source.
Duration time
Authoritative timeline time associated with this dispatch.
bool preview
Whether the callback is an editor/runtime preview projection.
std::vector< OptionalRef< const IAttachmentPointSource > > targetAttachments
Borrowed animated attachment sources indexed like targets; empty entries are valid.
std::vector< ecs::EntityHandle > targets
Owning target handle list for this synchronous dispatch.
SimulationTick tick
Deterministic simulation tick associated with this dispatch, when available.
ActionExecutionId executionId
Execution whose lifecycle is being routed.
Owning editor/runtime contract for one notify type.
std::vector< std::string > requiredPayloadFields
Owning event projection returned by the runtime sampler.