载入中...
搜索中...
未找到
CombatCancelResolver.cpp
浏览该文件的文档.
2
3namespace eve::combat {
4
6 if (!buffer_ || !cancels_)
8 DiagnosticCode::NotFound, "cancel resolver requires buffer and cancel windows", "resolver"));
9 if (!request.subject.isValid())
11 Diagnostic::error(DiagnosticCode::InvalidArgument, "cancel subject is nil", "subject"));
12 if (request.currentAbility.format().empty())
14 Diagnostic::error(DiagnosticCode::InvalidArgument, "current ability id is empty", "currentAbility"));
15
16 auto expired = buffer_->expire(request.tick);
17 if (!expired) return Result<CombatCancelResolution>::failure(expired.status());
18
19 const auto allows = cancels_->availableCancels(request.subject);
20 if (allows.empty())
22 Diagnostic::error(DiagnosticCode::NotFound, "no active cancel windows", "cancels"));
23
24 auto consumed = buffer_->consume(request.subject, allows);
26
27 auto cancel = cancels_->match(request.subject, consumed.value().input);
28 if (!cancel) return Result<CombatCancelResolution>::failure(cancel.status());
29
30 CombatCancelResolution resolution;
31 resolution.consumed = std::move(consumed).takeValue();
32 resolution.cancel = cancel.value();
33
34 bool allowCombo = false;
35 if (combos_) {
36 auto combo = combos_->match(request.subject, resolution.consumed.input);
37 if (combo) {
38 resolution.comboWindow = combo.value();
39 allowCombo = true;
40 }
41 }
42
43 if (graph_) {
44 auto matched = graph_->match(request.currentAbility, resolution.consumed.input, true, allowCombo);
45 if (matched)
46 resolution.graph = matched.value();
47 else if (matched.status().code() != StatusCode::NotFound)
48 return Result<CombatCancelResolution>::failure(matched.status());
49 }
51}
52
53} // namespace eve::combat
Cancel buffer + windows + combo graph resolution.
const GltfImportRequest & request
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
std::vector< std::string > availableCancels(SubjectRef subject) const
Return sorted unique allow tags currently active for a subject.
Result< ActionCancelMatch > match(SubjectRef subject, std::string_view input) const
Resolve the highest-priority window that allows the semantic input.
Result< ActionComboMatch > match(SubjectRef subject, std::string_view input) const
Resolve the first deterministic active window accepting an input.
Result< void > expire(SimulationTick now)
Drop entries older than lifetime relative to now.
Result< BufferedInput > consume(SubjectRef subject, const std::vector< std::string > &allows)
Consume the highest-priority buffered input that matches one of the allows.
Result< CombatCancelResolution > resolve(const CombatCancelResolveRequest &request)
Expire the buffer, consume the best allowed input, and optionally match the combo graph.
Result< ComboGraphMatch > match(const LogicalId &from, std::string_view input, bool allowCancel, bool allowCombo) const
Resolve the highest-priority legal transition for a source ability and input.
Owning audit of one resolved cancel or combo transition.
action::input::BufferedInput consumed
std::optional< action::input::ActionComboMatch > comboWindow
action::input::ActionCancelMatch cancel
std::optional< ComboGraphMatch > graph
Inputs for one deterministic cancel/combo resolution.
bool consumed
Definition Graphics.cpp:184