载入中...
搜索中...
未找到
RTSCrowdFlowNavigationInternal.h
浏览该文件的文档.
1#pragma once
2#include <optional>
3#include "crowd/Crowd.h"
4#include "rts/RTS.h"
5namespace eve::rts {
8public:
9 enum class InputChange { Unchanged, Changed };
12 struct GroupMember {
13 ecs::EntityHandle unit;
14 std::string orderId;
15 };
17 struct GroupInput {
18 std::vector<GroupMember> members;
19 std::vector<WorldPosition> targets;
20 };
22 class Route {
23 friend class CrowdFlowNavigation;
24 std::shared_ptr<const std::vector<crowd::FlowGoal>> sharedGoals_;
25 crowd::FlowGoal exactGoal_;
26 WorldPosition target_;
27 std::uint64_t owner_ = 0, input_ = 0;
28 };
34 [[nodiscard]] EVENGINE_API_DOMAINS Result<void> replaceGroups(crowd::Crowd& crowd, std::vector<GroupInput> groups);
40 [[nodiscard]] EVENGINE_API_DOMAINS Result<Route> requestRoute(crowd::Crowd& crowd, ecs::EntityHandle unit,
41 std::string_view orderId, WorldPosition position,
48 const Route& route, float radius,
50 crowd::AgentUpdate& update);
54 [[nodiscard]] bool enabled() const noexcept { return enabled_; }
63 EVENGINE_API_DOMAINS void disable() noexcept;
65 [[nodiscard]] EVENGINE_API_DOMAINS Result<InputChange> begin(crowd::Crowd& crowd, const SimulationStep& step);
66 [[nodiscard]] EVENGINE_API_DOMAINS Result<void> request(crowd::Crowd& crowd, WorldPosition target,
68 [[nodiscard]] EVENGINE_API_DOMAINS Result<void> pump(crowd::Crowd& crowd, const SimulationStep& step);
69 [[nodiscard]] EVENGINE_API_DOMAINS Result<DriveState> steer(crowd::Crowd& crowd, WorldPosition position,
71 crowd::MovementBinding movement,
72 crowd::AgentUpdate& update);
77 [[nodiscard]] EVENGINE_API_DOMAINS Result<void> request(crowd::Crowd& crowd, std::span<const WorldPosition> targets,
84 [[nodiscard]] EVENGINE_API_DOMAINS Result<DriveState> steer(crowd::Crowd& crowd, WorldPosition position,
85 std::span<const WorldPosition> targets,
86 WorldPosition exactTarget, float radius,
87 crowd::MovementBinding movement,
88 crowd::AgentUpdate& update);
92 struct Notice {
93 ecs::EntityHandle unit;
95 };
97 void queueNotice(ecs::EntityHandle unit, const OrderRecord& order) { notices_.push_back({unit, order}); }
102 [[nodiscard]] std::vector<Notice> takeNotices() { return std::exchange(notices_, {}); }
103
104
105private:
106 struct GroupBinding {
107 GroupMember member;
108 std::shared_ptr<const std::vector<crowd::FlowGoal>> goals;
109 bool reform = false;
110 std::uint64_t owner = 0, input = 0;
111 };
112 std::vector<GroupBinding> groups_;
113 struct Job {
114 std::uint64_t sequence = 0;
115 std::vector<crowd::FlowGoal> goals;
119 };
120 [[nodiscard]] EVENGINE_API_DOMAINS Result<crowd::FlowGoal> goalCell(crowd::Crowd& crowd,
121 WorldPosition target) const;
126 [[nodiscard]] EVENGINE_API_DOMAINS Result<std::vector<crowd::FlowGoal>> goalSet(
127 crowd::Crowd& crowd, std::span<const WorldPosition> targets) const;
128 [[nodiscard]] EVENGINE_API_DOMAINS Result<void> requestGoals(std::span<const crowd::FlowGoal> goals,
130 [[nodiscard]] EVENGINE_API_DOMAINS Result<DriveState> steerGoals(crowd::Crowd& crowd, WorldPosition position,
131 std::span<const crowd::FlowGoal> goals,
132 WorldPosition target, float radius,
133 crowd::MovementBinding movement,
134 crowd::AgentUpdate& update);
135 CrowdFlowNavigationSettings settings_;
136 bool enabled_ = true;
137 std::vector<Job> jobs_;
138 std::vector<Notice> notices_;
139 std::optional<SimulationTick> frame_, pumped_;
140 std::uint64_t owner_ = 0, input_ = 0;
141 std::uint64_t nextSequence_ = 1, workAfter_ = 0, roundThrough_ = 0;
142 CrowdFlowNavigationObservation stats_;
143};
144} // namespace eve::rts
LogicalId target
EvpackChunkInput input
Definition Evpack.cpp:170
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::vector< FieldTarget > targets
const GltfImportRequest & request
std::array< float, 3 > position
uint64_t used
double radius
Definition MeleeHit.cpp:42
std::vector< std::int32_t > order
OceanWakeSettings settings
std::shared_ptr< OceanGpuSpectrum > owner
uint32_t groups
Definition OnnxGpgpu.cpp:39
std::unique_ptr< gpgpu::Sequence > sequence
Definition OnnxGpgpu.cpp:43
PrefabLease lease
RTS module owner and phase-one composition profile entry point.
size_t begin
TacticalUnit * unit
SimulationTick tick
float step
Definition TreeMesh.cpp:451
float(ui::Theme::* member)[4]
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Move-only navigation workstate; contains no borrowed provider pointers.
Definition Crowd.h:309
群体行为模块:连续流场寻路 + 海量单位移动/转向/行动 + Boids 鸟群。
Definition Crowd.h:266
Owning immutable field lease; copies pin storage, never the Crowd provider. @thread Copy/release/quer...
Definition CrowdTypes.h:48
Opaque owning steering selection, valid only for the captured Crowd input epoch.
Owner-thread derived shared static-goal navigation service; retains no ECS pointers.
EVENGINE_API_DOMAINS Result< void > replaceGroups(crowd::Crowd &crowd, std::vector< GroupInput > groups)
Atomically replace derived group bindings after validating the complete projection....
EVENGINE_API_DOMAINS Result< void > configure(CrowdFlowNavigationSettings settings) noexcept
Change cheap quotas without losing jobs or the owner/tick spending latch. @ownership Stores values on...
EVENGINE_API_DOMAINS Result< void > pump(crowd::Crowd &crowd, const SimulationStep &step)
EVENGINE_API_DOMAINS void disable() noexcept
Disable policy and release jobs/leases while retaining the current spending boundary....
void queueNotice(ecs::EntityHandle unit, const OrderRecord &order)
Append an owning post-commit event; failure leaves this notice unpublished.
CrowdFlowNavigation(CrowdFlowNavigationSettings settings)
Store cheap owning quotas without preparing graph work.
bool enabled() const noexcept
Observe policy enablement; owner thread, no callbacks or provider access.
EVENGINE_API_DOMAINS CrowdFlowNavigationObservation observation() const noexcept
Observe bounded work metadata without field copies; owner thread only.
EVENGINE_API_DOMAINS Result< DriveState > steer(crowd::Crowd &crowd, WorldPosition position, WorldPosition target, float radius, crowd::MovementBinding movement, crowd::AgentUpdate &update)
EVENGINE_API_DOMAINS Result< DriveState > steerRoute(crowd::Crowd &crowd, WorldPosition position, const Route &route, float radius, crowd::MovementBinding movement, crowd::AgentUpdate &update)
Steer a previously collected route without repeating target-set conversion. @ownership Borrows route ...
std::vector< Notice > takeNotices()
Transfer committed notices to caller before invoking unknown callbacks. @ownership Caller owns moved ...
EVENGINE_API_DOMAINS Result< Route > requestRoute(crowd::Crowd &crowd, ecs::EntityHandle unit, std::string_view orderId, WorldPosition position, WorldPosition target, SimulationTick tick)
Collect the applicable group or exact-terminal request for one current order. @ownership Borrows inpu...
detail::StrongUint64< detail::SimulationTickTag > SimulationTick
Deterministic simulation time step; it is not wall-clock time.
Definition Time.h:31
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Owned changes for one live agent. Absent fields keep their existing values.
Definition Crowd.h:161
Logical grid destination; canonical request sets sort lexicographically and remove duplicates.
Definition CrowdTypes.h:12
Agent-owned selection of a provider-defined movement policy. Zero identity and revision mean compatib...
Definition CrowdTypes.h:27
Owning shared-flow work observation, independent of render timing.
Definition RTS.h:58
Explicit shared-goal work quotas, consumed once per positive simulation tick.
Definition RTS.h:54
Owning group projection prepared once before the motion phase.
Transient group member binding; RTS remains the membership authority.
Owning deferred notification; stale handles are resolved at delivery.
Owning projection of the active generic order used by RTS systems.
Definition RTSTypes.h:122
Two-dimensional deterministic RTS world position.
Definition RTSTypes.h:53