载入中...
搜索中...
未找到
TargetingPipeline.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
14#include "sensing/Sensing.h"
15#include "sensing/Targeting.h"
16
17#include <cstdint>
18#include <limits>
19#include <map>
20#include <memory>
21#include <string>
22#include <string_view>
23#include <vector>
24
25namespace eve::sensing {
26
28enum class TargetingTaskKind : std::uint8_t {
29 Select,
30 Filter,
31 Sort,
32};
33
41 std::string taskId;
43 float coneHalfAngle = 0.f;
44 float coneRange = 0.f;
45 std::uint32_t truncateCount = std::numeric_limits<std::uint32_t>::max();
46};
47
50 std::string id;
51 std::vector<TargetingTaskStep> steps;
52};
53
61 SensingWorld* world = nullptr;
63 float dirX = 1.f;
64 float dirY = 0.f;
65 bool usedSpatial = false;
66 std::uint32_t scanned = 0;
67};
68
76public:
78 virtual ~ITargetingTask() = default;
79
81 [[nodiscard]] virtual std::string_view id() const noexcept = 0;
83 [[nodiscard]] virtual TargetingTaskKind kind() const noexcept = 0;
88 [[nodiscard]] virtual Result<void> execute(TargetingSourceContext& context, std::vector<RankedCandidate>& inout,
89 const TargetingTaskStep& step) const = 0;
90};
91
98public:
103
104private:
105 friend class TargetingPipeline;
106 TargetingPlan() = default;
107 bool hasSort_ = false;
108 struct Step {
109 std::shared_ptr<const ITargetingTask> task;
111 };
112 std::vector<Step> steps_;
113 std::uint32_t minCount_ = 0;
114 std::uint32_t maxCount_ = std::numeric_limits<std::uint32_t>::max();
115};
116
124public:
126 TargetingPipeline() = default;
127 // Class-level dllexport instantiates every member; `tasks_` is a map of
128 // unique_ptr, so the implicit copy assignment would be a hard C2280.
135
137 [[nodiscard]] static TargetingPipeline withBuiltins();
138
143 [[nodiscard]] static TargetingPipeline& sharedBuiltins();
144
146 [[nodiscard]] Result<void> registerTask(std::unique_ptr<ITargetingTask> task);
150 [[nodiscard]] Result<TargetingPlan> compile(const TargetingPreset& preset) const;
152 [[nodiscard]] Result<void> registerPreset(TargetingPreset preset);
154 [[nodiscard]] bool hasPreset(std::string_view presetId) const noexcept;
155
161 const TargetingPreset& preset) const;
167 std::string_view presetId) const;
168
169private:
170 std::map<std::string, std::shared_ptr<const ITargetingTask>, std::less<>> tasks_;
171 std::map<std::string, TargetingPlan, std::less<>> presets_;
172};
173
174} // namespace eve::sensing
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::array< uint32_t, 9 > parameters
Coordinate-safe targeting protocol shared by sensing and gameplay adapters.
float step
Definition TreeMesh.cpp:451
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Pluggable Select/Filter/Sort task.
virtual ~ITargetingTask()=default
Releases ITargetingTask resources.
virtual Result< void > execute(TargetingSourceContext &context, std::vector< RankedCandidate > &inout, const TargetingTaskStep &step) const =0
Runs the task against the working candidate list.
virtual TargetingTaskKind kind() const noexcept=0
Task kind used for diagnostics.
virtual std::string_view id() const noexcept=0
Stable task id used by presets (e.g. "sensing.filter.cone").
Mirrored world positions and query composition; consumers decide gameplay actions from results.
Definition Sensing.h:197
In-memory task + preset registry and synchronous executor.
TargetingPipeline()=default
Creates an empty pipeline.
TargetingPipeline(const TargetingPipeline &)=delete
TargetingPipeline & operator=(const TargetingPipeline &)=delete
TargetingPipeline(TargetingPipeline &&)=default
Targeting pipeline.
TargetingPipeline & operator=(TargetingPipeline &&)=default
Operator =.
Immutable resolved legacy plan; owns tasks independently of its registry. @ownership Shared immutable...
TargetingTaskKind
Task role inside a TargetingPreset.
World origin used for range tests, distance sorting and LOS.
Definition Sensing.h:150
Configurable candidate query against SensingWorld.
Definition Sensing.h:128
One ranked candidate produced by SensingWorld::query.
Definition Sensing.h:159
Named ordered list of targeting tasks.
std::vector< TargetingTaskStep > steps
Runtime source for one pipeline execution.
Per-step parameters for a preset entry.