载入中...
搜索中...
未找到
ActionNotifyRegistry.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
14#include "action/Action.h"
16#include "common/BorrowedRef.h"
17
18#include <map>
19#include <memory>
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace eve::action {
25
26class ActionNotifyRegistry;
27
29enum class ActionNotifyShape : std::uint8_t { Instant, State };
30
33 std::string type;
34 std::string displayName;
35 std::string category;
37 std::vector<std::string> requiredPayloadFields;
38};
39
45 std::optional<ecs::EntityHandle> source;
47 std::vector<ecs::EntityHandle> targets;
54 std::vector<OptionalRef<const IAttachmentPointSource>> targetAttachments;
60 double playbackRate = 1.0;
62 bool preview = false;
64 bool scrubbing = false;
66 bool interrupted = false;
67};
68
76public:
78 virtual ~IActionNotifyHandler() = default;
85 [[nodiscard]] virtual Result<void> handle(const ActionTimelineEvent& event, const ActionNotifyContext& context) = 0;
103 [[nodiscard]] virtual Result<void> sample(const ActionActiveBlock&, const ActionNotifyContext&) const {
105 }
115};
116
125public:
126 static constexpr const char* capabilityName = "eve.action.notify-provider";
128 virtual ~IActionNotifyProvider() = default;
129
136};
137
146public:
148 [[nodiscard]] static Result<ActionNotifyRegistry> withBuiltins();
150 [[nodiscard]] Result<void> registerDescriptor(ActionNotifyDescriptor descriptor);
156 [[nodiscard]] Result<void> registerHandler(std::string_view type, std::shared_ptr<IActionNotifyHandler> handler);
158 [[nodiscard]] Result<void> unregisterHandler(std::string_view type);
160 [[nodiscard]] Result<ActionNotifyDescriptor> descriptor(std::string_view type) const;
162 [[nodiscard]] std::vector<ActionNotifyDescriptor> descriptors() const;
164 [[nodiscard]] bool hasHandler(std::string_view type) const noexcept;
166 [[nodiscard]] Result<void> validate(const ActionTimelineEvent& event) const;
172 [[nodiscard]] Result<void> dispatch(const ActionTimelineEvent& event, const ActionNotifyContext& context);
178 [[nodiscard]] Result<void> dispatchUpdate(const ActionActiveBlock& block, const ActionNotifyContext& context);
184 [[nodiscard]] Result<void> dispatchSample(const ActionActiveBlock& block,
185 const ActionNotifyContext& context) const;
187 [[nodiscard]] Result<void> advanceHandlers(const ActionNotifyContext& context);
188
189private:
190 std::map<std::string, ActionNotifyDescriptor, std::less<>> descriptors_;
191 std::map<std::string, std::shared_ptr<IActionNotifyHandler>, std::less<>> handlers_;
192};
193
194} // 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 eve::script::BindingContractRegistry & registry
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:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
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.