载入中...
搜索中...
未找到
CombatCharacter.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
6#include "combat/Damage.h"
7#include "common/Result.h"
8#include "common/SubjectRef.h"
9#include "common/Time.h"
10
11#include <cstdint>
12#include <map>
13#include <optional>
14#include <string>
15#include <vector>
16
17namespace eve::combat {
18
21 double x = 0.0;
22 double y = 0.0;
23 double z = 0.0;
24};
25
28
30enum class CombatDodgeRelative : std::uint8_t { Forward, Back, Left, Right };
31
35 std::string ownerId;
37 double maximumSpeed = 5.0;
38 double acceleration = 18.0;
39 double jumpSpeed = 6.0;
40 double gravity = 20.0;
41 double dodgeSpeed = 10.0;
42 double dodgeDuration = 0.28;
43 std::uint32_t maxAirJumps = 1;
44 double capsuleRadius = 0.35;
45
47 [[nodiscard]] Result<void> validate() const;
48};
49
53 std::string ownerId;
56 CombatVector3 facing{1.0, 0.0, 0.0};
58 double moveSpeedFraction = 0.0;
59 double maximumSpeed = 0.0;
60 double acceleration = 0.0;
61 double jumpSpeed = 0.0;
62 double gravity = 0.0;
63 double dodgeSpeed = 0.0;
64 double dodgeDuration = 0.0;
65 double capsuleRadius = 0.35;
66 std::uint32_t maxAirJumps = 0;
67 std::uint32_t airJumpsUsed = 0;
69 double modeTimeRemaining = 0.0;
70 bool invulnerable = false;
71 bool timeFrozen = false;
72 std::optional<CombatVector3> rootMotionDelta;
73};
74
77
86
90 std::vector<CombatCharacterEvent> events;
91};
92
100public:
102 virtual ~ICombatGroundProvider() = default;
104 [[nodiscard]] virtual Result<double> sampleHeight(double x, double z) const = 0;
105};
106
113public:
115 virtual ~ICombatMoveProbe() = default;
122 [[nodiscard]] virtual Result<CombatVector3> resolve(const CombatVector3& from, const CombatVector3& to,
123 double radius) const = 0;
124};
125
135public:
137 [[nodiscard]] Result<void> registerSubject(CombatCharacterDefinition definition);
139 [[nodiscard]] Result<void> unregisterSubject(SubjectRef subject);
142
148 [[nodiscard]] Result<void> setMoveIntent(SubjectRef subject, CombatVector3 direction, double speedFraction);
150 [[nodiscard]] Result<void> jump(SubjectRef subject);
155 [[nodiscard]] Result<void> dodge(SubjectRef subject, std::optional<CombatVector3> direction = std::nullopt);
161 [[nodiscard]] Result<void> dodgeRelative(SubjectRef subject, CombatVector3 lockTarget,
164 [[nodiscard]] Result<void> beginAttack(SubjectRef subject);
166 [[nodiscard]] Result<void> endAttack(SubjectRef subject);
168 [[nodiscard]] Result<void> applyStun(SubjectRef subject, Duration duration);
173 [[nodiscard]] Result<void> applyImpulse(SubjectRef subject, CombatVector3 impulse);
178 [[nodiscard]] Result<void> applyDamageReaction(SubjectRef subject, HitReaction reaction, Duration stunDuration,
179 Impulse3 knockback);
181 [[nodiscard]] Result<void> kill(SubjectRef subject);
186 [[nodiscard]] Result<void> setRootMotionDelta(SubjectRef subject, CombatVector3 delta);
191 [[nodiscard]] Result<void> setFacing(SubjectRef subject, CombatVector3 facing);
196 [[nodiscard]] Result<void> setTimeFrozen(SubjectRef subject, bool frozen);
198 void setGroundProvider(ICombatGroundProvider& provider) noexcept { ground_ = &provider; }
200 void clearGroundProvider() noexcept { ground_ = nullptr; }
202 void setMoveProbe(ICombatMoveProbe& probe) noexcept { probe_ = &probe; }
204 void clearMoveProbe() noexcept { probe_ = nullptr; }
206 [[nodiscard]] Result<CombatCharacterAdvance> advance(const SimulationStep& step);
208 [[nodiscard]] std::vector<CombatCharacterState> states() const;
209
210private:
211 std::map<std::string, CombatCharacterState, std::less<>> states_;
212 ICombatGroundProvider* ground_ = nullptr;
213 ICombatMoveProbe* probe_ = nullptr;
214 SimulationTick lastTick_ = SimulationTick::zero();
215};
216
217} // namespace eve::combat
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
float duration
Vec3 relative
Definition AnimSmr.cpp:164
int subject
Definition AnimSmr.cpp:163
std::string from
Deterministic damage, poise, hit-reaction and knockback resolution.
#define EVENGINE_API_BACKENDS
Definition Export.h:108
HexCoordinates to
Cell the unit walks towards on this segment.
Definition HexUnits.cpp:64
ModuleFacing facing
float radius
Move-only, checked operation results for the common layer.
RoadLaneDirection direction
Stable reference to a runtime gameplay subject.
LogicalId definition
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:314
Signed, fixed-resolution simulation duration in nanoseconds.
Definition Time.h:43
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
Owner-thread 3D character authority for action combat.
void clearMoveProbe() noexcept
Clears move probe.
void setGroundProvider(ICombatGroundProvider &provider) noexcept
Borrow a ground sampler; must outlive this runtime or be cleared.
void clearGroundProvider() noexcept
Clears ground provider.
void setMoveProbe(ICombatMoveProbe &probe) noexcept
Borrow a capsule move probe; must outlive this runtime or be cleared.
Optional ground-height sampler consumed by the character controller.
virtual ~ICombatGroundProvider()=default
Releases ICombatGroundProvider resources.
virtual Result< double > sampleHeight(double x, double z) const =0
Return finite ground height at the supplied world XZ.
Optional capsule move resolver for walls and overlapping bodies.
virtual ~ICombatMoveProbe()=default
Releases ICombatMoveProbe resources.
virtual Result< CombatVector3 > resolve(const CombatVector3 &from, const CombatVector3 &to, double radius) const =0
Resolve a candidate translation for one capsule.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
CombatCharacterMode
High-level locomotion mode owned by the character controller.
CombatCharacterEventKind
Observable character event after a committed frame.
CombatDodgeRelative
Lock-relative dodge direction on the XZ plane.
HitReaction
Typed reaction selected after health and poise are resolved.
Definition Damage.h:26
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Complete owning result of one character advance.
std::vector< CombatCharacterEvent > events
Immutable registration for one action-combat character.
Result< void > validate() const
Validate identity and finite positive movement limits.
Owning event emitted by the character controller.
CombatCharacterEventKind kind
Owning read-only projection of one character.
std::optional< CombatVector3 > rootMotionDelta
Finite 3D combat vector.
Renderer/physics-neutral knockback impulse authored in world units.
Definition Damage.h:19