载入中...
搜索中...
未找到
MeleeHit.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
6#include "action/Action.h"
7#include "combat/Damage.h"
8#include "common/Result.h"
9#include "common/SubjectRef.h"
10#include "common/Time.h"
11
12#include <cstdint>
13#include <map>
14#include <optional>
15#include <string>
16#include <vector>
17
18namespace eve::combat {
19
22 double x = 0.0;
23 double y = 0.0;
24 double z = 0.0;
25};
26
28enum class MeleeShapeKind : std::uint8_t { Sphere, Capsule };
29
36struct MeleeShape {
38 double radius = 0.0;
39 double halfHeight = 0.0;
40
42 [[nodiscard]] Result<void> validate() const;
43};
44
46struct MeleePose {
49 double yawRadians = 0.0;
50
52 [[nodiscard]] Result<void> validate() const;
53};
54
58 std::string hurtboxId;
59 std::string bodyPart;
61
63 [[nodiscard]] Result<void> validate() const;
64};
65
68 std::string hitboxId;
72 double healthDamage = 0.0;
73 double poiseDamage = 0.0;
74 std::string damageType = "Damage.Physical.Slash";
76 double knockbackSpeed = 0.0;
78 double knockbackLift = 0.0;
79
81 [[nodiscard]] Result<void> validate() const;
82};
83
88 std::string hitboxId;
89 std::string hurtboxId;
90 std::string bodyPart;
93 double healthDamage = 0.0;
94 double poiseDamage = 0.0;
95 std::string damageType;
97 std::optional<action::ActionExecutionId> actionExecution;
98};
99
103 std::vector<MeleeHitEvent> hits;
104};
105
113public:
115 virtual ~IMeleePoseSource() = default;
121 [[nodiscard]] virtual Result<MeleePose> pose(SubjectRef subject, std::string_view hitboxId) const = 0;
122};
123
133public:
135 void setPoseSource(IMeleePoseSource& source) noexcept { poses_ = &source; }
137 void clearPoseSource() noexcept { poses_ = nullptr; }
138
140 [[nodiscard]] Result<void> registerHitbox(MeleeHitboxDefinition definition);
142 [[nodiscard]] Result<void> registerHurtbox(MeleeHurtboxDefinition definition);
144 [[nodiscard]] Result<void> clearHurtboxes(SubjectRef subject);
146 [[nodiscard]] Result<void> setHurtboxPose(SubjectRef subject, std::string_view hurtboxId, MeleePose pose);
147
152 [[nodiscard]] Result<void> armHitbox(SubjectRef subject, std::string_view hitboxId,
153 action::ActionExecutionId execution);
155 [[nodiscard]] Result<void> disarmHitbox(SubjectRef subject, std::string_view hitboxId,
156 action::ActionExecutionId execution);
157
162 [[nodiscard]] Result<MeleeHitFrame> advance(SimulationTick tick);
163
165 [[nodiscard]] Result<std::vector<DamageOutcome>> applyHits(
166 DamageRuntime& damage, std::map<std::string, CombatState, std::less<>>& states,
167 const std::vector<MeleeHitEvent>& hits,
168 const std::map<std::string, double, std::less<>>& bodyPartMultipliers = {}) const;
169
171 [[nodiscard]] std::size_t armedCount() const noexcept { return armed_.size(); }
173 [[nodiscard]] std::size_t hurtboxCount() const noexcept { return hurtboxes_.size(); }
174
175private:
176 struct HurtboxState {
179 bool hasPose = false;
180 };
181 struct ArmedHitbox {
183 std::string hitboxId;
185 MeleePose previous;
186 MeleePose current;
187 bool hasPose = false;
188 };
189 using ArmedKey = std::tuple<std::string, std::string, std::uint64_t>;
190 using HitMemoryKey = std::tuple<std::uint64_t, std::string, std::string, std::string>;
191
192 std::map<std::string, MeleeHitboxDefinition, std::less<>> hitboxes_;
193 std::map<std::string, HurtboxState, std::less<>> hurtboxes_;
194 std::map<ArmedKey, ArmedHitbox> armed_;
195 std::map<HitMemoryKey, bool> hitMemory_;
196 IMeleePoseSource* poses_ = nullptr;
197 SimulationTick lastTick_ = SimulationTick::zero();
198};
199
200} // namespace eve::combat
Renderer- and ruleset-neutral gameplay action pipeline.
int subject
Definition AnimSmr.cpp:163
eve::EntitySpatialPose pose
Deterministic damage, poise, hit-reaction and knockback resolution.
#define EVENGINE_API_BACKENDS
Definition Export.h:108
graphics::Canvas * previous
Move-only, checked operation results for the common layer.
double current
Stable reference to a runtime gameplay subject.
LogicalId definition
SimulationTick tick
Common time values and an injectable deterministic simulation clock.
const UnitySourceAsset & source
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 deterministic damage coordinator.
Definition Damage.h:125
Optional pose resolver for active hitbox ids.
Definition MeleeHit.h:112
virtual ~IMeleePoseSource()=default
Releases IMeleePoseSource resources.
virtual Result< MeleePose > pose(SubjectRef subject, std::string_view hitboxId) const =0
Resolve the current world pose for one subject's active hitbox.
Owner-thread authority for hurtboxes, hitbox catalogs and sweep hits.
Definition MeleeHit.h:132
void clearPoseSource() noexcept
Remove the borrowed pose source.
Definition MeleeHit.h:137
std::size_t hurtboxCount() const noexcept
Number of registered hurtboxes.
Definition MeleeHit.h:173
void setPoseSource(IMeleePoseSource &source) noexcept
Install a borrowed pose source that must outlive this runtime or be cleared.
Definition MeleeHit.h:135
std::size_t armedCount() const noexcept
Number of armed hitbox windows.
Definition MeleeHit.h:171
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
MeleeShapeKind
Primitive shape used by hitboxes and hurtboxes.
Definition MeleeHit.h:28
Mutable combat state owned by the gameplay domain for one subject.
Definition Damage.h:37
Renderer/physics-neutral knockback impulse authored in world units.
Definition Damage.h:19
One confirmed contact produced by a sweep frame.
Definition MeleeHit.h:85
std::optional< action::ActionExecutionId > actionExecution
Definition MeleeHit.h:97
Complete owning result of one melee advance.
Definition MeleeHit.h:101
std::vector< MeleeHitEvent > hits
Definition MeleeHit.h:103
Catalog entry that maps a timeline hitbox resource id onto geometry.
Definition MeleeHit.h:67
double knockbackLift
Upward impulse added on hit; independent of the contact normal.
Definition MeleeHit.h:78
MeleePoint3 localOffset
Local offset from the pose provided by the pose source.
Definition MeleeHit.h:71
Result< void > validate() const
Validate id, shape and finite damage.
Definition MeleeHit.cpp:153
double knockbackSpeed
Horizontal impulse magnitude along the contact normal (attacker → target).
Definition MeleeHit.h:76
Body-part tag used for multipliers and debugging.
Definition MeleeHit.h:56
Result< void > validate() const
Validate identity and shape.
Definition MeleeHit.cpp:143
Finite world-space point used by melee geometry.
Definition MeleeHit.h:21
World pose for one shape sample.
Definition MeleeHit.h:46
double yawRadians
Yaw radians around world +Y; pitch/roll are unused for v1 capsules.
Definition MeleeHit.h:49
Result< void > validate() const
Reject non-finite pose values.
Definition MeleeHit.cpp:137
MeleePoint3 position
Definition MeleeHit.h:47
Owning geometry definition referenced by a stable hitbox or hurtbox id.
Definition MeleeHit.h:36
Result< void > validate() const
Reject non-finite or non-positive dimensions.
Definition MeleeHit.cpp:125
MeleeShapeKind kind
Definition MeleeHit.h:37