载入中...
搜索中...
未找到
GuardWindowState.cpp
浏览该文件的文档.
14 Diagnostic::error(DiagnosticCode::InvalidArgument, "guard mode must be block or parry", "mode"));
19GuardWindowState::GuardWindowState(GuardSubjectResolver resolver) : resolver_(std::move(resolver)) {}
21GuardWindowState::~GuardWindowState() { cap::removeListener<action::IActionStateWindowSink>(this); }
45 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "combat guard does not own this state-window kind", "kind"));
46 if (!resolver_) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "guard subject resolver is unavailable", "resolver"));
52 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "guard target index is unavailable", "targetIndex"));
57 if (!handle) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "guard window has no source or target", "subject"));
61 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "guard-window subject is nil", "subject"));
66 const bool same = found->second.subject == subject.value() && found->second.mode == mode.value();
68 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Conflict, "guard-window key is already active with different data", "itemId"));
78 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported, "combat guard does not own this state-window kind", "kind"));
83 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Conflict, "guard-window exit kind does not match active key", "kind"));
88Result<GuardEvaluation> GuardWindowState::evaluate(SubjectRef defender, SubjectRef attacker) const {
113Result<GuardEvaluation> GuardWindowState::mitigate(SubjectRef defender, DamageRequest& request) const {
Block and parry windows projected from Montage state.
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
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
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
Result< void > exit(const action::ActionStateWindowBinding &binding, const action::ActionTimelineEvent &event, const action::ActionNotifyContext &context) override
Exit one previously entered window by execution and item identity.
Definition GuardWindowState.cpp:74
std::vector< GuardMode > activeModes(SubjectRef subject) const
Return active guard modes for a subject in key order.
Definition GuardWindowState.cpp:123
Result< void > enter(const action::ActionStateWindowBinding &binding, const action::ActionTimelineEvent &event, const action::ActionNotifyContext &context) override
Enter one validated window or idempotently observe the same active key.
Definition GuardWindowState.cpp:41
Result< GuardEvaluation > evaluate(SubjectRef defender, SubjectRef attacker) const
Evaluate whether a defender currently blocks or parries an attacker.
Definition GuardWindowState.cpp:88
GuardWindowState(GuardSubjectResolver resolver)
Construct with a synchronous subject resolver.
Definition GuardWindowState.cpp:19
bool enabled() const
Return whether this exact owner is registered.
Definition GuardWindowState.cpp:23
void setEnabled(bool enabled)
Opt this owner into or out of Action state-window dispatch.
Definition GuardWindowState.cpp:29
bool supports(action::ActionStateWindowKind kind) const noexcept override
Whether this sink owns the supplied semantic window kind.
Definition GuardWindowState.cpp:37
Result< GuardEvaluation > mitigate(SubjectRef defender, DamageRequest &request) const
Mutate a damage request when guard succeeds.
Definition GuardWindowState.cpp:113
ActionStateWindowKind
Stable semantic kind for one built-in state window.
Definition ActionStateWindowBlock.h:16
Definition ActionDamageSink.cpp:9
std::function< Result< SubjectRef >(ecs::EntityHandle)> GuardSubjectResolver
Resolves an owning stable subject from a generation-qualified ECS handle.
Definition GuardWindowState.h:35
@ Blocked
@ Parried
@ InvalidArgument
@ NotFound
@ Unsupported
@ Conflict
@ NoOp
@ Applied
Definition Container.h:602
Context linking a routed event to its action execution.
Definition ActionNotifyRegistry.h:34
Owning validated state-window request authored on an action timeline.
Definition ActionStateWindowBlock.h:19
Owning event projection returned by the runtime sampler.
Definition ActionTimeline.h:146