载入中...
搜索中...
未找到
PrefabAttackVfx.cpp
浏览该文件的文档.
1#include "common/Capability.h"
3
4#include <cstdint>
5#include <string>
6#include <unordered_map>
7#include <utility>
8
9namespace eve::stylize_action {
10namespace {
11
18class PrefabAttackVfxExecutor final : public eve::stylize::IAttackVfxLayerExecutor {
19public:
20 eve::stylize::AttackVfxLayerRole role() const noexcept override {
22 }
23
26 if (!request.layer)
28 eve::DiagnosticCode::InvalidArgument, "AttackVfx prefab layer is null", "layer"));
29 if (request.layer->uri.empty())
31 eve::DiagnosticCode::InvalidArgument, "AttackVfx prefab layer uri is empty", "uri"));
32
33 Live live;
34 live.uri = request.layer->uri;
35 if (request.playRequest) {
36 live.sourceId = request.playRequest->sourceId;
37 live.targetId = request.playRequest->targetId;
38 }
39 const auto id = ++nextId_;
40 live_.emplace(id, std::move(live));
43 }
44
47 if (!live_.contains(handle.id))
49 eve::DiagnosticCode::StaleHandle, "prefab AttackVfx layer handle is stale", "handle"));
51 }
52
55 if (!live_.erase(handle.id))
57 eve::DiagnosticCode::StaleHandle, "prefab AttackVfx layer handle is stale", "handle"));
59 }
60
61private:
62 struct Live {
63 std::string uri;
64 std::uint32_t sourceId = 0;
65 std::uint32_t targetId = 0;
66 };
67
68 std::uint64_t nextId_ = 1;
69 std::unordered_map<std::uint64_t, Live> live_;
70};
71
72PrefabAttackVfxExecutor& prefabExecutor() {
73 static PrefabAttackVfxExecutor instance;
74 return instance;
75}
76
77bool gPrefabRegistered = false;
78
79} // namespace
80
82 if (gPrefabRegistered) return;
83 eve::cap::addListener<eve::stylize::IAttackVfxLayerExecutor>(&prefabExecutor());
84 gPrefabRegistered = true;
85}
86
88 if (!gPrefabRegistered) return;
89 eve::cap::removeListener<eve::stylize::IAttackVfxLayerExecutor>(&prefabExecutor());
90 gPrefabRegistered = false;
91}
92
93} // namespace eve::stylize_action
Duration start
Pluggable AttackVfx layer backends registered via capability listeners.
std::uint64_t sourceId
const GltfImportRequest & request
std::string uri
std::uint32_t targetId
PrimitiveHandle handle
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
Optional open backend for one AttackVfxLayerRole.
void unregisterPrefabAttackVfxExecutor()
AttackVfxLayerRole
Which existing presentation backend a layer binds to.
AttackVfxStopBehavior
Exit policy when a phase or instance stops.
Opaque executor-owned layer instance identity.
Borrowed start context for one layer inside an entering phase.