载入中...
搜索中...
未找到
EntitySpatialResolver.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
4
5#include <optional>
6
7namespace eve {
8
9Result<EntitySpatialPose> resolveEntitySpatialPose(ecs::EntityHandle entity, std::string_view bone) {
10 std::optional<EntitySpatialPose> pose;
11 std::optional<Status> failure;
12 cap::forEachUntil<IEntitySpatialProvider>([&](IEntitySpatialProvider* provider) {
13 auto resolved = provider->resolve(entity, bone);
14 if (resolved) {
15 pose = std::move(resolved).takeValue();
16 return true;
17 }
18 if (resolved.status().code() != StatusCode::NotFound) {
19 failure = resolved.status();
20 return true;
21 }
22 return false;
23 });
24 if (pose) return Result<EntitySpatialPose>::success(std::move(*pose));
25 if (failure) return Result<EntitySpatialPose>::failure(std::move(*failure));
27 Diagnostic::error(DiagnosticCode::NotFound, "no spatial provider owns the entity", "entity"));
28}
29
30} // namespace eve
eve::EntitySpatialPose pose
Optional ECS-entity to world-pose capability.
std::uint32_t bone
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
One optional domain provider capable of resolving selected ECS entities.
virtual Result< EntitySpatialPose > resolve(ecs::EntityHandle entity, std::string_view bone) const =0
Resolve a current world pose, optionally at a named bone/socket.
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
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Result< EntitySpatialPose > resolveEntitySpatialPose(ecs::EntityHandle entity, std::string_view bone)
Resolve through registered providers in deterministic registration order.