载入中...
搜索中...
未找到
CombatCarrier.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
17#include "common/ECS.h"
18#include "common/Identity.h"
19#include "common/Result.h"
20#include "common/Time.h"
22
23#include <cstdint>
24#include <optional>
25#include <string>
26#include <vector>
27
28namespace eve::weapon {
29
40
42enum class CarrierTriggerKind : std::uint8_t {
43 OnExpire,
44 OnFuse,
46 OnHit,
48};
49
51enum class CarrierImpactKind : std::uint8_t {
52 EmitHit,
53 Splash,
54 Pierce,
55 Bounce,
56 Release,
58};
59
77
85
99
110 double speed = 0.0;
111 std::vector<CarrierMotionOp> motionOps;
112 std::vector<CarrierTrigger> triggers;
113 std::vector<CarrierImpact> impacts;
114
116 [[nodiscard]] Result<void> validate() const;
117};
118
121 std::uint32_t slot = 0;
122 std::uint32_t generation = 0;
123
125 friend bool operator==(const CarrierHandle&, const CarrierHandle&) = default;
126};
127
132 std::optional<ecs::EntityHandle> target;
133 ecs::EntityHandle source{};
134};
135
137enum class CarrierVolleyPattern : std::uint8_t {
138 Fan,
139 Ring
140};
141
153
159
172
188
195
198 std::vector<CarrierHandle> advanced;
199 std::vector<CarrierHandle> released;
200 std::vector<CarrierEvent> events;
201 std::vector<CarrierChildSpawn> childSpawns;
202};
203
206 std::uint32_t generation = 0;
207 std::optional<CarrierState> state;
208};
209
212 std::vector<CarrierSlotSnapshot> slots;
213};
214
223public:
225 virtual ~ICarrierHitProbe() = default;
226
228 struct Contact {
229 ecs::EntityHandle target{};
231 ProjectileVector normal{0.0, 1.0, 0.0};
232 };
233
239 const CarrierMotion& previous,
240 const CarrierMotion& current) const = 0;
241};
242
256
264public:
266 virtual ~ICarrierBodyDefenseProvider() = default;
267
273 CarrierHandle handle, ecs::EntityHandle target, const CarrierMotion& motion) const = 0;
274};
275
284 const ProjectileDefinition& definition, double damage = 0.0);
285
294public:
297
299 [[nodiscard]] Result<void> configurePool(std::uint32_t capacity);
300
305 [[nodiscard]] Result<void> registerRecipe(const CarrierRecipe& recipe);
306
308 [[nodiscard]] std::optional<CarrierRecipe> findRecipe(const LogicalId& id) const;
309
311 [[nodiscard]] Result<CarrierHandle> spawn(const LogicalId& recipeId, const CarrierSpawnRequest& request);
312
314 [[nodiscard]] Result<CarrierHandle> spawn(const CarrierRecipe& recipe, const CarrierSpawnRequest& request);
315
323 [[nodiscard]] Result<std::vector<CarrierHandle>> spawnVolley(const LogicalId& recipeId,
327 [[nodiscard]] Result<std::vector<CarrierHandle>> spawnVolley(const CarrierRecipe& recipe,
330
337 [[nodiscard]] Result<CarrierFrame> update(Duration delta,
338 const IProjectileTargetProvider* targets = nullptr,
339 const ICarrierHitProbe* hits = nullptr,
340 const ICarrierBodyDefenseProvider* bodies = nullptr);
341
344
346 [[nodiscard]] std::optional<CarrierState> find(CarrierHandle handle) const;
347
349 [[nodiscard]] std::vector<CarrierState> states() const;
350
352 [[nodiscard]] CarrierRuntimeSnapshot snapshot() const;
353
355 [[nodiscard]] Result<void> restore(const CarrierRuntimeSnapshot& snapshot);
356
358 [[nodiscard]] std::size_t activeCount() const noexcept { return activeCount_; }
359
361 [[nodiscard]] std::size_t capacity() const noexcept { return slots_.size(); }
362
363private:
364 struct Slot {
365 std::uint32_t generation = 0;
366 std::optional<CarrierState> state;
367 };
368
369 struct LiveRecipe {
370 CarrierRecipe recipe;
371 int initialPierce = 0;
372 int initialBounce = 0;
373 bool needsHoming = false;
374 bool needsHit = false;
375 bool needsProximity = false;
376 bool needsBodyAvoid = false;
377 };
378
379 [[nodiscard]] Result<CarrierHandle> spawnPrepared(const LiveRecipe& live,
380 const CarrierSpawnRequest& request);
381 [[nodiscard]] static Result<LiveRecipe> prepareRecipe(const CarrierRecipe& recipe);
382 [[nodiscard]] static Result<void> validateSpawn(const CarrierRecipe& recipe,
383 const CarrierSpawnRequest& request);
384
385 std::vector<Slot> slots_;
386 std::vector<LiveRecipe> recipes_;
387 std::size_t activeCount_ = 0;
388};
389
390} // namespace eve::weapon
LogicalId target
#define EVENGINE_API_WORLD
Definition Export.h:109
const GltfImportRequest & request
std::uint32_t capacity
Strong identity values shared by persistence, content and logical-name APIs.
graphics::Canvas * previous
std::uint32_t generation
PrimitiveHandle handle
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
Deterministic pooled projectile simulation.
Move-only, checked operation results for the common layer.
double current
std::optional< CarrierVolleySpec > volley
Common time values and an injectable deterministic simulation clock.
Signed, fixed-resolution simulation duration in nanoseconds.
Definition Time.h:43
static constexpr Duration zero() noexcept
Return zero duration.
Definition Time.h:60
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:411
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Owner-thread deterministic carrier simulator with composable behaviors.
std::size_t capacity() const noexcept
Current fixed pool capacity.
std::size_t activeCount() const noexcept
Number of live carriers.
Optional body/shield boundary for SteerAvoidBody.
virtual Result< std::vector< CarrierBodyDefenseSample > > sample(CarrierHandle handle, ecs::EntityHandle target, const CarrierMotion &motion) const =0
Sample body/shield volumes relevant to one carrier step.
virtual ~ICarrierBodyDefenseProvider()=default
Releases ICarrierBodyDefenseProvider resources.
Optional swept-hit boundary used only by OnHit triggers.
virtual Result< std::vector< Contact > > query(CarrierHandle handle, const CarrierMotion &previous, const CarrierMotion &current) const =0
Query contacts for one candidate step.
virtual ~ICarrierHitProbe()=default
Releases ICarrierHitProbe resources.
Optional target-position boundary used only by homing projectiles.
载具模块入口(eve.Vehicle):定义注册 / 实体工厂 / RTS 命令 / 帧调度。 设计文档:docs/dev/通用载具系统设计.md
CarrierImpactKind
What happens when a matching trigger fires.
CarrierMotionOpKind
Ordered ballistic operators applied each simulation step.
Result< CarrierRecipe > carrierRecipeFromProjectile(const ProjectileDefinition &definition, double damage)
Build a default recipe matching a classic ProjectileDefinition mode.
CarrierTriggerKind
When an impact may fire.
CarrierVolleyPattern
Multi-projectile aim pattern for one salvo.
One body/shield sample used by SteerAvoidBody to curve around defenses.
Deferred child spawn recorded during update.
Owning event emitted by an impact.
ecs::EntityHandle target
ecs::EntityHandle source
CarrierTriggerKind trigger
CarrierImpactKind impact
Owning result of one atomic carrier simulation step.
std::vector< CarrierEvent > events
std::vector< CarrierHandle > released
std::vector< CarrierChildSpawn > childSpawns
std::vector< CarrierHandle > advanced
Generation-qualified reference to one pooled carrier slot.
friend bool operator==(const CarrierHandle &, const CarrierHandle &)=default
Operator ==.
One impact bound to a trigger kind.
CarrierTriggerKind on
One ballistic operator plus its parameters.
double curveAmplitude
CurveSway/CurveHelix: lateral amplitude in meters (helix radius).
double avoidLookAhead
SteerAvoidBody: meters ahead at which a body counts as blocking.
double avoidRadiusPadding
SteerAvoidBody: extra meters added to each body radius.
double avoidStrength
SteerAvoidBody: blend weight of avoidance versus current velocity (≥0).
double curveFrequencyHz
CurveSway/CurveHelix: oscillation frequency in Hz (>0).
CarrierMotionOpKind kind
Live motion snapshot for one carrier.
Data-driven composition recipe for one carrier family.
std::vector< CarrierTrigger > triggers
Result< void > validate() const
Validate finite parameters and composition constraints.
std::vector< CarrierMotionOp > motionOps
std::vector< CarrierImpact > impacts
Complete deterministic carrier-pool state for rollback/save.
std::vector< CarrierSlotSnapshot > slots
One pool slot including generation, retained while empty.
std::optional< CarrierState > state
std::optional< ecs::EntityHandle > target
Owning observable state for one live carrier.
std::optional< ecs::EntityHandle > target
ecs::EntityHandle source
One trigger specification.
CarrierTriggerKind kind
Deterministic multi-direction spawn descriptor.
CarrierVolleyPattern pattern
Owning contact reported between previous and current motion.
Data-driven trajectory and lifetime definition.
Owning point in projectile simulation space.
Owning velocity or direction vector in projectile simulation space.