载入中...
搜索中...
未找到
ActionGameplayEventBlock.cpp
浏览该文件的文档.
2
3#include "tags/GameplayTag.h"
4
5#include <limits>
6#include <utility>
7
8namespace eve::action {
9namespace {
10
11} // namespace
12
15 const auto foundTag = payload.find("tag");
16 const auto* tag = foundTag == payload.end() ? nullptr : foundTag->second.getIf<std::string>();
19 Diagnostic::error(DiagnosticCode::InvalidArgument, "gameplay event tag must be canonical", "tag"));
20 candidate.tag = *tag;
21
22 if (const auto foundTarget = payload.find("targetIndex"); foundTarget != payload.end()) {
23 const auto* target = foundTarget->second.getIf<std::int64_t>();
24 if (!target || *target < 0 || static_cast<std::uint64_t>(*target) > std::numeric_limits<std::uint32_t>::max())
27 "gameplay event target index must be an unsigned 32-bit integer", "targetIndex"));
28 candidate.targetIndex = static_cast<std::size_t>(*target);
29 }
30 if (const auto foundData = payload.find("data"); foundData != payload.end()) candidate.data = foundData->second;
31 return Result<ActionGameplayEventBinding>::success(std::move(candidate));
32}
33
34} // namespace eve::action
Typed instantaneous gameplay-event action contract.
LogicalId target
Value::Object payload
Stable hierarchical gameplay-tag definitions and registry.
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
std::map< std::string, Value > Object
Definition Value.h:34
bool isValidGameplayTagName(std::string_view name) noexcept
Returns whether a name is a canonical dot-separated gameplay tag.
Owning validated event request authored on an action timeline.
std::optional< std::size_t > targetIndex
Optional target index; absence routes the event to the source subject.
Value data
Owning schema-neutral domain payload retained by the target event adapter.
static Result< ActionGameplayEventBinding > fromPayload(const Value::Object &payload)
Decode and validate an event payload without emitting it.
std::string tag
Canonical gameplay-tag event topic.