载入中...
搜索中...
未找到
ProjectileRuntime.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7#include "common/ECS.h"
8#include "common/Identity.h"
9#include "common/Result.h"
10#include "common/Time.h"
11
12#include <cstdint>
13#include <optional>
14#include <vector>
15
16namespace eve::weapon {
17
19enum class ProjectileMode : std::uint8_t { Linear, Ballistic, Homing };
20
23 double x = 0.0;
24 double y = 0.0;
25 double z = 0.0;
26
28 friend bool operator==(const ProjectilePoint&, const ProjectilePoint&) = default;
29};
30
33 double x = 0.0;
34 double y = 0.0;
35 double z = 0.0;
36
38 friend bool operator==(const ProjectileVector&, const ProjectileVector&) = default;
39};
40
43 std::uint32_t slot = 0;
44 std::uint32_t generation = 0;
45
47 friend bool operator==(const ProjectileHandle&, const ProjectileHandle&) = default;
48};
49
62
69
83
86 std::vector<ProjectileHandle> advanced;
87 std::vector<ProjectileHandle> released;
88};
89
92 std::uint32_t generation = 0;
93 std::optional<ProjectileState> state;
94};
95
98 std::vector<ProjectileSlotSnapshot> slots;
99};
100
103public:
105 virtual ~IProjectileTargetProvider() = default;
107 [[nodiscard]] virtual Result<ProjectilePoint> position(ecs::EntityHandle target) const = 0;
108};
109
119public:
122
124 [[nodiscard]] Result<void> configurePool(std::uint32_t capacity);
129 [[nodiscard]] Result<ProjectileUpdate> update(Duration delta, const IProjectileTargetProvider* targets = nullptr);
133 [[nodiscard]] std::optional<ProjectileState> find(ProjectileHandle handle) const;
135 [[nodiscard]] std::vector<ProjectileState> states() const;
137 [[nodiscard]] ProjectileRuntimeSnapshot snapshot() const;
139 [[nodiscard]] Result<void> restore(const ProjectileRuntimeSnapshot& snapshot);
141 [[nodiscard]] std::size_t activeCount() const noexcept { return activeCount_; }
143 [[nodiscard]] std::size_t capacity() const noexcept { return slots_.size(); }
144
145private:
146 struct Slot {
147 std::uint32_t generation = 0;
148 std::optional<ProjectileState> state;
149 };
150
151 [[nodiscard]] static Result<void> validateSpawn(const ProjectileDefinition& definition,
152 const ProjectileSpawnRequest& request);
153
154 std::vector<Slot> slots_;
155 std::size_t activeCount_ = 0;
156};
157
158} // 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.
std::uint32_t generation
PrimitiveHandle handle
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
Move-only, checked operation results for the common layer.
LogicalId definition
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
Optional target-position boundary used only by homing projectiles.
virtual ~IProjectileTargetProvider()=default
Releases IProjectileTargetProvider resources.
virtual Result< ProjectilePoint > position(ecs::EntityHandle target) const =0
Resolve one generation-checked target to an owning simulation-space position.
Owner-thread deterministic projectile simulator with a bounded reusable pool.
std::size_t activeCount() const noexcept
Number of live projectiles.
std::size_t capacity() const noexcept
Current fixed pool capacity.
载具模块入口(eve.Vehicle):定义注册 / 实体工厂 / RTS 命令 / 帧调度。 设计文档:docs/dev/通用载具系统设计.md
ProjectileMode
Built-in trajectory integration mode.
Data-driven trajectory and lifetime definition.
Result< void > validate() const
Validate finite, non-negative trajectory parameters and mode-specific requirements.
Generation-qualified reference to one pooled projectile slot.
friend bool operator==(const ProjectileHandle &, const ProjectileHandle &)=default
Operator ==.
Owning point in projectile simulation space.
friend bool operator==(const ProjectilePoint &, const ProjectilePoint &)=default
Operator ==.
Complete deterministic projectile-pool state for rollback and save games.
std::vector< ProjectileSlotSnapshot > slots
One pool slot including its generation, retained even while empty.
std::optional< ProjectileState > state
Owning spawn request; homing requests require a generation-checked target.
std::optional< ecs::EntityHandle > target
Owning observable state for one live projectile.
std::optional< ecs::EntityHandle > target
Owning result of one atomic projectile simulation step.
std::vector< ProjectileHandle > released
std::vector< ProjectileHandle > advanced
Owning velocity or direction vector in projectile simulation space.
friend bool operator==(const ProjectileVector &, const ProjectileVector &)=default
Operator ==.