载入中...
搜索中...
未找到
CombatCharacterPose.cpp
浏览该文件的文档.
2#include <algorithm>
3#include <cmath>
4#include <optional>
5#include <utility>
9#include "combat/CombatLoop.h"
11
12// CombatCharacterPose.cpp
13namespace eve::combat {
14
16 if (!characters_)
18 Diagnostic::error(DiagnosticCode::NotFound, "character pose source has no runtime", "characters"));
19 auto state = characters_->state(subject);
20 if (!state) return Result<MeleePose>::failure(state.status());
22 pose.position = {state.value().position.x, state.value().position.y + chestHeight_, state.value().position.z};
23 pose.yawRadians = std::atan2(-state.value().facing.x, state.value().facing.z);
25}
26
27} // namespace eve::combat
28
29// CombatEnemyAI.cpp
30namespace eve::combat {
31namespace {
32
33double distance3(double ax, double ay, double az, double bx, double by, double bz) {
34 const double dx = ax - bx;
35 const double dy = ay - by;
36 const double dz = az - bz;
37 return std::sqrt(dx * dx + dy * dy + dz * dz);
38}
39
40} // namespace
41
43 if (!subject.isValid())
45 Diagnostic::error(DiagnosticCode::InvalidArgument, "enemy subject is nil", "subject"));
46 if (ownerId.empty())
48 Diagnostic::error(DiagnosticCode::InvalidArgument, "enemy owner id is empty", "ownerId"));
49 if (!std::isfinite(nearRadius) || nearRadius <= 0.0 || !std::isfinite(midRadius) || midRadius < nearRadius)
51 Diagnostic::error(DiagnosticCode::InvalidArgument, "enemy radii are invalid", "radius"));
52 if (attackCooldownTicks == 0)
54 DiagnosticCode::InvalidArgument, "enemy attack cooldown must be positive", "attackCooldownTicks"));
55 return Result<void>::success();
56}
57
59 auto valid = definition.validate();
60 if (!valid) return valid;
61 EnemyState state;
62 state.definition = std::move(definition);
63 enemies_[state.definition.subject.format()] = std::move(state);
65}
66
73
75 if (!subject.isValid())
77 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(z))
79 poses_[subject.format()] = Pose{x, y, z};
81}
82
84 auto found = enemies_.find(subject.format());
85 if (found == enemies_.end())
87 Diagnostic::error(DiagnosticCode::NotFound, "enemy was not found", subject.format()));
88 if (actionId.format().empty())
90 Diagnostic::error(DiagnosticCode::InvalidArgument, "light action id is empty", "actionId"));
91 found->second.lightAction = std::move(actionId);
92 found->second.hasAction = true;
94}
95
97 if (!targets_)
99 Diagnostic::error(DiagnosticCode::NotFound, "enemy target runtime is unavailable", "targets"));
100
101 std::optional<action::AbilityIntent> emitted;
102 for (auto& [key, enemy] : enemies_) {
103 (void)key;
104 if (enemy.phase == CombatEnemyPhase::Recover &&
105 tick.value() >= enemy.phaseStartTick + enemy.definition.recoverTicks)
106 enemy.phase = CombatEnemyPhase::Idle;
107 if (emitted) continue;
108 if (!enemy.hasAction) continue;
109 if (enemy.definition.lightGrant.isZero()) continue;
110
111 const auto emitAttack = [&]() {
113 intent.grantId = enemy.definition.lightGrant;
114 intent.request.actionId = enemy.lightAction;
115 enemy.lastAttackTick = tick.value();
116 enemy.phase = enemy.definition.recoverTicks > 0 ? CombatEnemyPhase::Recover : CombatEnemyPhase::Idle;
117 enemy.phaseStartTick = tick.value();
118 emitted = std::move(intent);
119 };
120
121 if (enemy.phase == CombatEnemyPhase::Telegraph) {
122 if (tick.value() >= enemy.phaseStartTick + enemy.definition.telegraphTicks) emitAttack();
123 continue;
124 }
125 if (enemy.phase == CombatEnemyPhase::Recover) continue;
126
127 const auto selfPose = poses_.find(enemy.definition.subject.format());
128 if (selfPose == poses_.end()) continue;
129 auto lock = targets_->state(enemy.definition.subject);
130 if (!lock || !lock.value().target) continue;
131 const auto targetPose = poses_.find(lock.value().target->format());
132 if (targetPose == poses_.end()) continue;
133 const double dist = distance3(selfPose->second.x, selfPose->second.y, selfPose->second.z, targetPose->second.x,
134 targetPose->second.y, targetPose->second.z);
135 if (dist > enemy.definition.nearRadius) continue;
136 if (enemy.lastAttackTick != 0 && tick.value() < enemy.lastAttackTick + enemy.definition.attackCooldownTicks)
137 continue;
138
139 if (enemy.definition.telegraphTicks > 0) {
140 enemy.phase = CombatEnemyPhase::Telegraph;
141 enemy.phaseStartTick = tick.value();
142 continue;
143 }
144 emitAttack();
145 }
146 return Result<std::optional<action::AbilityIntent>>::success(std::move(emitted));
147}
148
150 if (!targets_)
152 Diagnostic::error(DiagnosticCode::NotFound, "enemy target runtime is unavailable", "targets"));
153
154 std::vector<CombatEnemySteering> result;
155 for (const auto& [key, enemy] : enemies_) {
156 (void)key;
157 if (enemy.phase != CombatEnemyPhase::Idle) continue;
158 const auto selfPose = poses_.find(enemy.definition.subject.format());
159 if (selfPose == poses_.end()) continue;
160 auto lock = targets_->state(enemy.definition.subject);
161 if (!lock || !lock.value().target) continue;
162 const auto targetPose = poses_.find(lock.value().target->format());
163 if (targetPose == poses_.end()) continue;
164 const double dist = distance3(selfPose->second.x, selfPose->second.y, selfPose->second.z, targetPose->second.x,
165 targetPose->second.y, targetPose->second.z);
166 if (dist <= enemy.definition.nearRadius) continue;
167
168 CombatVector3 delta{targetPose->second.x - selfPose->second.x, 0.0, targetPose->second.z - selfPose->second.z};
169 const double magnitude = std::hypot(delta.x, delta.z);
170 if (magnitude <= 1e-6) continue;
171 CombatEnemySteering steering;
172 steering.subject = enemy.definition.subject;
173 steering.moveDirection = {delta.x / magnitude, 0.0, delta.z / magnitude};
174 steering.speedFraction = dist <= enemy.definition.midRadius ? 0.7 : 1.0;
175 result.push_back(steering);
176 }
178}
179
181 const auto found = enemies_.find(subject.format());
182 if (found == enemies_.end() || !targets_) return CombatEnemyBand::Far;
183 const auto selfPose = poses_.find(subject.format());
184 if (selfPose == poses_.end()) return CombatEnemyBand::Far;
185 auto lock = targets_->state(subject);
186 if (!lock || !lock.value().target) return CombatEnemyBand::Far;
187 const auto targetPose = poses_.find(lock.value().target->format());
188 if (targetPose == poses_.end()) return CombatEnemyBand::Far;
189 const double dist = distance3(selfPose->second.x, selfPose->second.y, selfPose->second.z, targetPose->second.x,
190 targetPose->second.y, targetPose->second.z);
191 if (dist <= found->second.definition.nearRadius) return CombatEnemyBand::Near;
192 if (dist <= found->second.definition.midRadius) return CombatEnemyBand::Mid;
194}
195
197 const auto found = enemies_.find(subject.format());
198 if (found == enemies_.end()) return CombatEnemyPhase::Idle;
199 return found->second.phase;
200}
201
206
207} // namespace eve::combat
208
209// CombatLocomotion.cpp
210namespace eve::combat {
211namespace {
212
213bool finite(CombatVector2 value) { return std::isfinite(value.x) && std::isfinite(value.z); }
214
215double length(CombatVector2 value) { return std::hypot(value.x, value.z); }
216
217CombatVector2 normalized(CombatVector2 value) {
218 const double magnitude = length(value);
219 return magnitude > 0.0 ? CombatVector2{value.x / magnitude, value.z / magnitude} : CombatVector2{};
220}
221
222Result<void> validateGoal(const CombatNavigationGoal& goal) {
223 if (!finite(goal.position) || !std::isfinite(goal.acceptanceRadius) || goal.acceptanceRadius < 0.0)
225 Diagnostic::error(DiagnosticCode::InvalidArgument, "navigation goal is invalid", "goal"));
226 return Result<void>::success();
227}
228
229Result<void> validateSteering(const CombatNavigationSteering& steering) {
230 if ((steering.phase != CombatNavigationPhase::Moving && steering.phase != CombatNavigationPhase::Arrived) ||
231 !finite(steering.direction) || !std::isfinite(steering.speedFraction) || steering.speedFraction < 0.0 ||
232 steering.speedFraction > 1.0)
234 "navigation provider returned invalid steering", "steering"));
235 return Result<void>::success();
236}
237
238} // namespace
239
241 if (!subject.isValid())
242 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "subject is nil", "subject"));
243 if (ownerId.empty())
245 Diagnostic::error(DiagnosticCode::InvalidArgument, "owner id is empty", "ownerId"));
246 if (!finite(initialPosition) || !std::isfinite(maximumSpeed) || maximumSpeed <= 0.0 ||
247 !std::isfinite(acceleration) || acceleration <= 0.0)
249 Diagnostic::error(DiagnosticCode::InvalidArgument, "locomotion limits are invalid", "movement"));
250 return Result<void>::success();
251}
252
254 const CombatNavigationGoal& goal,
256 (void)tick;
257 auto valid = validateGoal(goal);
259 const CombatVector2 delta{goal.position.x - state.position.x, goal.position.z - state.position.z};
260 const double distance = length(delta);
261 if (distance <= goal.acceptanceRadius)
264}
265
267 auto valid = definition.validate();
268 if (!valid) return valid;
269 const std::string key = definition.subject.format();
270 if (states_.contains(key))
272 Diagnostic::error(DiagnosticCode::AlreadyExists, "locomotion subject already exists", key));
273 states_.emplace(key, CombatLocomotionState{definition.subject,
274 std::move(definition.ownerId),
275 definition.initialPosition,
276 {},
277 {1.0, 0.0},
278 {},
279 0.0,
280 definition.maximumSpeed,
281 definition.acceleration,
282 std::nullopt});
284}
285
287 if (!subject.isValid())
288 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "subject is nil", "subject"));
289 if (states_.erase(subject.format()) == 0)
291 Diagnostic::error(DiagnosticCode::NotFound, "locomotion subject was not found", subject.format()));
293}
294
296 if (!subject.isValid())
298 Diagnostic::error(DiagnosticCode::InvalidArgument, "subject is nil", "subject"));
299 const auto found = states_.find(subject.format());
300 if (found == states_.end())
302 Diagnostic::error(DiagnosticCode::NotFound, "locomotion subject was not found", subject.format()));
304}
305
307 if (!subject.isValid() || !finite(direction) || !std::isfinite(speedFraction) || speedFraction < 0.0 ||
308 speedFraction > 1.0)
310 Diagnostic::error(DiagnosticCode::InvalidArgument, "movement intent is invalid", "intent"));
311 const auto found = states_.find(subject.format());
312 if (found == states_.end())
314 Diagnostic::error(DiagnosticCode::NotFound, "locomotion subject was not found", subject.format()));
315 found->second.moveDirection = normalized(direction);
316 found->second.moveSpeedFraction = length(direction) > 0.0 ? speedFraction : 0.0;
317 found->second.navigationGoal.reset();
319}
320
322 if (!subject.isValid())
323 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "subject is nil", "subject"));
324 if (!navigation_)
326 Diagnostic::error(DiagnosticCode::Unsupported, "combat navigation provider is unavailable", "navigation"));
327 auto valid = validateGoal(goal);
328 if (!valid) return valid;
329 const auto found = states_.find(subject.format());
330 if (found == states_.end())
332 Diagnostic::error(DiagnosticCode::NotFound, "locomotion subject was not found", subject.format()));
333 found->second.navigationGoal = goal;
335}
336
338 const auto found = states_.find(subject.format());
339 if (!subject.isValid() || found == states_.end())
341 Diagnostic::error(DiagnosticCode::NotFound, "locomotion subject was not found", subject.format()));
342 found->second.moveDirection = {};
343 found->second.moveSpeedFraction = 0.0;
344 found->second.navigationGoal.reset();
346}
347
349 if (step.delta < Duration::zero() || step.tick < lastTick_)
351 DiagnosticCode::InvalidArgument, "locomotion step is negative or moves tick backwards", "step"));
352 auto candidate = states_;
354 result.tick = step.tick;
355 const double seconds = step.delta.seconds();
356 for (auto& [key, state] : candidate) {
357 (void)key;
358 bool arrived = false;
359 std::optional<CombatNavigationGoal> activeGoal = state.navigationGoal;
360 if (state.navigationGoal) {
361 if (!navigation_)
363 Diagnostic::error(DiagnosticCode::Unsupported, "active goal has no combat navigation provider",
364 state.subject.format()));
365 auto steering = navigation_->steer(state, *state.navigationGoal, step.tick);
366 if (!steering) return Result<CombatLocomotionAdvance>::failure(steering.status());
367 auto valid = validateSteering(steering.value());
369 arrived = steering.value().phase == CombatNavigationPhase::Arrived;
370 state.moveDirection = arrived ? CombatVector2{} : normalized(steering.value().direction);
371 state.moveSpeedFraction = arrived ? 0.0 : steering.value().speedFraction;
372 if (arrived) {
373 state.navigationGoal.reset();
374 state.velocity = {};
375 }
376 }
377 const CombatVector2 previous = state.position;
378 const CombatVector2 desired{state.moveDirection.x * state.maximumSpeed * state.moveSpeedFraction,
379 state.moveDirection.z * state.maximumSpeed * state.moveSpeedFraction};
380 const CombatVector2 velocityDelta{desired.x - state.velocity.x, desired.z - state.velocity.z};
381 const double deltaLength = length(velocityDelta);
382 const double maximumDelta = state.acceleration * seconds;
383 const double scale = deltaLength > maximumDelta && deltaLength > 0.0 ? maximumDelta / deltaLength : 1.0;
384 state.velocity.x += velocityDelta.x * scale;
385 state.velocity.z += velocityDelta.z * scale;
386 state.position.x += state.velocity.x * seconds;
387 state.position.z += state.velocity.z * seconds;
388 if (activeGoal && !arrived) {
389 const CombatVector2 before{activeGoal->position.x - previous.x, activeGoal->position.z - previous.z};
390 const CombatVector2 after{activeGoal->position.x - state.position.x,
391 activeGoal->position.z - state.position.z};
392 if (length(after) <= activeGoal->acceptanceRadius || before.x * after.x + before.z * after.z <= 0.0) {
393 state.position = activeGoal->position;
394 state.velocity = {};
395 state.moveDirection = {};
396 state.moveSpeedFraction = 0.0;
397 state.navigationGoal.reset();
398 arrived = true;
399 }
400 }
401 if (length(state.velocity) > 0.0) state.facing = normalized(state.velocity);
402 if (state.position.x != previous.x || state.position.z != previous.z)
403 result.events.push_back(
404 {state.subject, CombatLocomotionEventKind::Moved, previous, state.position, step.tick});
405 if (arrived)
406 result.events.push_back(
407 {state.subject, CombatLocomotionEventKind::Arrived, previous, state.position, step.tick});
408 }
409 states_ = std::move(candidate);
410 lastTick_ = step.tick;
412}
413
414std::vector<CombatLocomotionState> CombatLocomotionRuntime::states() const {
415 std::vector<CombatLocomotionState> result;
416 result.reserve(states_.size());
417 for (const auto& [key, state] : states_) {
418 (void)key;
419 result.push_back(state);
420 }
421 return result;
422}
423
424} // namespace eve::combat
425
426// CombatLoop.cpp
427namespace eve::combat {
428namespace {
429
430bool invulnerable(const CombatActionWindowState* windows, const CombatCharacterRuntime* characters,
432 if (windows && windows->isInvulnerable(subject)) return true;
433 if (!characters) return false;
434 auto state = characters->state(subject);
435 return state && state.value().invulnerable;
436}
437
438bool dodging(const CombatCharacterRuntime* characters, SubjectRef subject) {
439 if (!characters) return false;
440 auto state = characters->state(subject);
441 return state && state.value().mode == CombatCharacterMode::Dodging && state.value().invulnerable;
442}
443
444} // namespace
445
447 if (!characters_ || !melee_)
449 Diagnostic::error(DiagnosticCode::NotFound, "combat loop requires character and melee runtimes", "loop"));
450 if (lastAdvanceTick_.has_value()) {
451 if (step.tick < *lastAdvanceTick_)
453 Diagnostic::error(DiagnosticCode::InvalidArgument, "combat loop tick moved backwards", "tick"));
454 if (step.tick == *lastAdvanceTick_)
456 Diagnostic::error(DiagnosticCode::Conflict, "CombatLoopRuntime already advanced this tick", "tick"));
457 }
458 lastAdvanceTick_ = step.tick;
459
461 frame.tick = step.tick;
462
463 if (enemies_) {
464 for (const auto& state : characters_->states()) {
465 auto posed = enemies_->setPosition(state.subject, state.position.x, state.position.y, state.position.z);
466 if (!posed) return Result<CombatLoopFrame>::failure(posed.status());
467 }
468 auto steering = enemies_->nextSteering(step.tick);
469 if (!steering) return Result<CombatLoopFrame>::failure(steering.status());
470 frame.enemySteering = steering.value();
471 for (const auto& steer : frame.enemySteering) {
472 auto moved = characters_->setMoveIntent(steer.subject, steer.moveDirection, steer.speedFraction);
473 if (!moved) return Result<CombatLoopFrame>::failure(moved.status());
474 }
475 }
476
477 if (cancelResolver_ && cancelSubject_.isValid() && !cancelAbility_.format().empty()) {
479 request.subject = cancelSubject_;
480 request.currentAbility = cancelAbility_;
481 request.tick = step.tick;
482 auto resolved = cancelResolver_->resolve(request);
483 if (resolved)
484 frame.cancels.push_back(std::move(resolved).takeValue());
485 else if (resolved.status().code() != StatusCode::NotFound)
487 }
488
489 if (feel_) {
490 for (const auto& state : characters_->states()) {
491 auto frozen = characters_->setTimeFrozen(state.subject, feel_->isFrozen(state.subject));
492 if (!frozen) return Result<CombatLoopFrame>::failure(frozen.status());
493 }
494 }
495
496 if (targets_) {
497 for (const auto& state : characters_->states()) {
498 if (state.mode != CombatCharacterMode::Attacking) continue;
499 if (feel_ && feel_->isFrozen(state.subject)) continue;
500 auto lock = targets_->state(state.subject);
501 if (!lock || !lock.value().target) continue;
502 auto target = characters_->state(*lock.value().target);
503 if (!target) continue;
505 warp.attacker = state.position;
506 warp.target = target.value().position;
507 warp.attackerFacing = state.facing;
508 warp.desiredDistance = 1.4;
509 warp.maxTranslation = 0.12;
510 warp.remainingBudget = 0.6;
511 auto solved = CombatMotionWarp::solve(warp);
512 if (!solved) {
513 if (solved.status().code() == StatusCode::Conflict) continue;
514 return Result<CombatLoopFrame>::failure(solved.status());
515 }
516 auto faced = characters_->setFacing(state.subject, solved.value().facing);
517 if (!faced) return Result<CombatLoopFrame>::failure(faced.status());
518 if (solved.value().translation.x != 0.0 || solved.value().translation.z != 0.0) {
519 auto applied = characters_->setRootMotionDelta(state.subject, solved.value().translation);
520 if (!applied) return Result<CombatLoopFrame>::failure(applied.status());
521 }
522 }
523 }
524
525 auto locomotion = characters_->advance(step);
526 if (!locomotion) return Result<CombatLoopFrame>::failure(locomotion.status());
527 frame.locomotion = std::move(locomotion).takeValue();
528
529 for (const auto& state : characters_->states()) {
530 auto posed = melee_->setHurtboxPose(state.subject, "torso",
531 {{state.position.x, state.position.y + 1.0, state.position.z}, 0.0});
532 if (!posed && posed.status().code() != StatusCode::NotFound)
533 return Result<CombatLoopFrame>::failure(posed.status());
534 (void)posed;
535 }
536
537 auto melee = melee_->advance(step.tick);
538 if (!melee) return Result<CombatLoopFrame>::failure(melee.status());
539 frame.melee = std::move(melee).takeValue();
540
541 if (states_) {
542 for (const auto& hit : frame.melee.hits) {
543 if (dodging(characters_, hit.target)) {
544 frame.perfectDodges.push_back({hit.target, hit.source, hit.hitboxId});
545 continue;
546 }
547 if (invulnerable(windows_, characters_, hit.target)) continue;
548 DamageRequest request;
549 request.source = hit.source;
550 request.target = hit.target;
551 request.actionExecution = hit.actionExecution;
552 request.damageType = hit.damageType;
553 request.healthDamage = hit.healthDamage;
554 request.poiseDamage = hit.poiseDamage;
555 request.knockback = hit.knockback;
556 if (guards_) {
557 auto guarded = guards_->mitigate(hit.target, request);
558 if (!guarded) return Result<CombatLoopFrame>::failure(guarded.status());
559 frame.guards.push_back(guarded.value());
560 if (guarded.value().result != GuardResult::None) continue;
561 }
562 const auto found = states_->find(hit.target.format());
563 if (found == states_->end())
565 Diagnostic::error(DiagnosticCode::NotFound, "loop damage target missing", hit.target.format()));
566 DamageRuntime damage;
567 auto outcome = damage.apply(found->second, request);
568 if (!outcome) return Result<CombatLoopFrame>::failure(outcome.status());
569 if (feel_) {
570 auto felt = feel_->applyFromOutcome(outcome.value());
571 if (!felt) return Result<CombatLoopFrame>::failure(felt.status());
572 }
573 auto reacted = characters_->applyDamageReaction(
574 hit.target, outcome.value().reaction,
575 feel_ ? feel_->state(hit.target).hitstunRemaining : Duration::zero(), outcome.value().knockback);
576 if (!reacted) return Result<CombatLoopFrame>::failure(reacted.status());
577 frame.outcomes.push_back(std::move(outcome).takeValue());
578 }
579 }
580
581 if (feel_) {
582 auto felt = feel_->advance(step);
583 if (!felt) return Result<CombatLoopFrame>::failure(felt.status());
584 }
585
586 if (cameraFocus_.isValid()) {
587 auto focus = characters_->state(cameraFocus_);
588 if (focus) {
589 CombatCameraFramingRequest framing;
590 framing.player = focus.value().position;
591 framing.playerFacing = focus.value().facing;
592 if (targets_) {
593 auto lock = targets_->state(cameraFocus_);
594 if (lock && lock.value().target) {
595 auto locked = characters_->state(*lock.value().target);
596 if (locked) framing.lockTarget = locked.value().position;
597 }
598 }
599 auto view = CombatCameraFraming::solve(framing);
600 if (!view) return Result<CombatLoopFrame>::failure(view.status());
601 frame.camera = view.value();
602 }
603 }
605}
606
607} // namespace eve::combat
double z
double y
double x
LogicalId target
bool locked
Combat-owned active hitbox and invulnerability projections.
int subject
Definition AnimSmr.cpp:163
eve::EntitySpatialPose pose
Character-runtime pose adapter for melee hitboxes.
Minimal ring-based combat enemy intent source.
Deterministic player/navigation locomotion adapter for combat subjects.
One-frame composition of character, melee, guard, feel and camera.
Bounded attack translation/facing correction toward a lock target.
bool applied
SQObjectPtr key
Definition ECS.cpp:155
float warp
const GltfImportRequest & request
std::int32_t second
float length
std::array< float, 3 > scale
Poco::JSON::Object::Ptr result
bool valid
float distance
ssq::Object frame
glm::dvec3 dx
glm::dvec3 dz
OceanSprayView view
std::shared_ptr< const OceanSprayFrame > previous
bool finite
bool hit
Object::Ptr value
RoadNetwork resolved
RoadLaneDirection direction
bool found
double current
float dy
Definition Shadow.cpp:151
float phase
SimulationTick tick
float step
Definition TreeMesh.cpp:451
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
static constexpr Duration zero() noexcept
Return zero duration.
Definition Time.h:60
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:414
const std::string & format() const noexcept
Returns the canonical namespace:name representation.
Definition Identity.h:439
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
Result< CombatCancelResolution > resolve(const CombatCancelResolveRequest &request)
Expire the buffer, consume the best allowed input, and optionally match the combo graph.
Result< MeleePose > pose(SubjectRef subject, std::string_view hitboxId) const override
Resolve the current world pose for one subject's active hitbox.
Result< void > setFacing(SubjectRef subject, CombatVector3 facing)
Replace planar facing from a finite XZ vector; Y is ignored.
Result< void > setTimeFrozen(SubjectRef subject, bool frozen)
Pause integration for hitstop while retaining the committed pose.
Result< void > setRootMotionDelta(SubjectRef subject, CombatVector3 delta)
Queue one frame of authored root-motion delta consumed by the next advance.
Result< CombatCharacterAdvance > advance(const SimulationStep &step)
Atomically advance every character using only the supplied deterministic step.
std::vector< CombatCharacterState > states() const
Return owning states in stable subject-id order.
Result< CombatCharacterState > state(SubjectRef subject) const
Return an owning state snapshot, or NotFound for a stale subject.
Result< void > setMoveIntent(SubjectRef subject, CombatVector3 direction, double speedFraction)
Set normalized planar movement intent.
bool isPunishable(SubjectRef subject) const
True while the enemy is in Telegraph or Recover.
CombatEnemyBand band(SubjectRef subject) const
Current band for debugging; Far when unknown.
Result< std::vector< CombatEnemySteering > > nextSteering(SimulationTick tick) const
Emit approach steering for Mid/Far enemies that are Idle (not punishing).
Result< std::optional< action::AbilityIntent > > nextIntent(SimulationTick tick) override
Emit at most one attack intent for the supplied tick.
Result< void > registerEnemy(CombatEnemyDefinition definition)
Register or replace one enemy definition after validation.
Result< void > unregisterEnemy(SubjectRef subject)
Remove one enemy.
Result< void > setLightAction(SubjectRef subject, LogicalId actionId)
Set the action id copied into emitted intents.
Result< void > setPosition(SubjectRef subject, double x, double y, double z)
Provide world positions for band checks (enemies and their targets).
CombatEnemyPhase phase(SubjectRef subject) const
Current move-set phase; Idle when the subject is unknown.
Result< void > registerSubject(CombatLocomotionDefinition definition)
Register one unique subject from validated owning definition data.
Result< CombatLocomotionAdvance > advance(const SimulationStep &step)
Atomically advance every subject using only the supplied deterministic step.
Result< void > unregisterSubject(SubjectRef subject)
Remove one subject; missing subjects are rejected.
Result< CombatLocomotionState > state(SubjectRef subject) const
Return an owning state snapshot, or NotFound for a stale subject.
Result< void > stop(SubjectRef subject)
Clear a navigation goal and desired movement for one subject.
Result< void > setMoveIntent(SubjectRef subject, CombatVector2 direction, double speedFraction)
Set normalized player/AI movement and clear any navigation goal.
std::vector< CombatLocomotionState > states() const
Return owning states in stable subject-id order.
Result< void > navigateTo(SubjectRef subject, CombatNavigationGoal goal)
Install a navigation goal after provider and value validation.
Result< CombatLoopFrame > advance(const SimulationStep &step)
Advance every wired runtime with the supplied deterministic step.
static Result< CombatWarpResult > solve(const CombatWarpRequest &request)
Solve one warp step from owning request data.
Result< CombatLockState > state(SubjectRef owner) const
Return owning lock state or NotFound.
Result< CombatNavigationSteering > steer(const CombatLocomotionState &state, const CombatNavigationGoal &goal, SimulationTick tick) override
Resolve steering for one subject without mutating locomotion state.
bool isFrozen(SubjectRef subject) const noexcept
Whether the subject currently has positive hitstop remaining.
Definition HitFeel.cpp:121
virtual Result< CombatNavigationSteering > steer(const CombatLocomotionState &state, const CombatNavigationGoal &goal, SimulationTick tick)=0
Resolve steering for one subject without mutating locomotion state.
Result< void > setHurtboxPose(SubjectRef subject, std::string_view hurtboxId, MeleePose pose)
Update the current world pose of one registered hurtbox.
Definition MeleeHit.cpp:203
CombatEnemyBand
Distance band used by the simple enemy brain.
CombatEnemyPhase
Authored move-set phase; Telegraph and Recover are punish windows.
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Owning request to activate one granted ability.
LogicalId actionId
Definition identity this request intends to execute.
Definition Action.h:158
Inputs for one deterministic cancel/combo resolution.
Owning configuration for one enemy fighter.
Result< void > validate() const
Validate subject, owner and positive radii.
Owning planar steering suggestion for Mid/Far bands.
Complete owning result of one committed locomotion frame.
Immutable registration data for one locomotion subject.
Result< void > validate() const
Validate identity and finite positive movement limits.
Owning read-only projection of one registered combat subject.
Owning audit of one composed combat frame.
Definition CombatLoop.h:34
Owning navigation goal retained by the locomotion authority.
Finite position or direction in the horizontal combat plane.
Finite 3D combat vector.
Input for one deterministic motion-warp solve.
World pose for one shape sample.
Definition MeleeHit.h:46