7bool handleLess(
const ecs::EntityHandle&
left,
const ecs::EntityHandle&
right) {
8 if (
left.table !=
right.table)
return std::less<ecs::Table*>{}(
left.table,
right.table);
11 return left.generation <
right.generation;
23 std::vector<GroupBinding> staged;
25 if (
group.members.empty() ||
group.members.size() > 1024)
27 auto normalized = goalSet(crowd,
group.targets);
29 std::shared_ptr<const std::vector<crowd::FlowGoal>> goals;
30 const auto priorGroup = std::lower_bound(
31 groups_.begin(), groups_.end(),
group.members.front().unit,
32 [](
const auto& candidate,
const auto&
handle) { return handleLess(candidate.member.unit, handle); });
33 if (priorGroup != groups_.end() && !handleLess(
group.members.front().unit, priorGroup->member.unit) &&
34 priorGroup->owner ==
source.owner && priorGroup->input ==
source.inputRevision &&
35 *priorGroup->goals == normalized.value())
36 goals = priorGroup->goals;
38 goals = std::make_shared<const std::vector<crowd::FlowGoal>>(std::move(normalized).takeValue());
40 if (
member.unit.table ==
nullptr ||
member.unit.generation == 0 ||
member.orderId.empty())
44 const auto& ownedMember =
binding.member;
45 const auto previous = std::lower_bound(
46 groups_.begin(), groups_.end(), ownedMember.unit,
47 [](
const auto& candidate,
const auto&
handle) { return handleLess(candidate.member.unit, handle); });
48 if (
previous != groups_.end() && !handleLess(ownedMember.unit,
previous->member.unit) &&
52 staged.push_back(std::move(
binding));
55 std::sort(staged.begin(), staged.end(),
56 [](
const auto&
left,
const auto&
right) { return handleLess(left.member.unit, right.member.unit); });
57 if (std::adjacent_find(staged.begin(), staged.end(), [](
const auto&
left,
const auto&
right) {
58 return !handleLess(left.member.unit, right.member.unit);
63}
catch (
const std::exception&
error) {
70 auto exact = goalCell(crowd,
target);
76 route.exactGoal_ = exact.value();
78 route.owner_ =
source.owner;
79 route.input_ =
source.inputRevision;
80 auto member = std::lower_bound(groups_.begin(), groups_.end(),
unit, [](
const auto&
binding,
const auto&
handle) {
81 return handleLess(binding.member.unit, handle);
84 const bool matched =
member != groups_.end() && !handleLess(
unit,
member->member.unit) &&
87 std::binary_search(
member->goals->begin(),
member->goals->end(), exact.value());
92 if (!reform) route.sharedGoals_ =
member->goals;
94 const auto goals = route.sharedGoals_ ? std::span<const crowd::FlowGoal>(*route.sharedGoals_)
95 : std::span<const crowd::FlowGoal>(&route.exactGoal_, 1);
96 auto requested = requestGoals(goals,
tick);
98 if (matched)
member->reform = reform;
107 if (
source.owner != route.owner_ ||
source.inputRevision != route.input_)
109 const auto goals = route.sharedGoals_ ? std::span<const crowd::FlowGoal>(*route.sharedGoals_)
110 : std::span<const crowd::FlowGoal>(&route.exactGoal_, 1);
111 return steerGoals(crowd,
position, goals, route.target_,
radius, movement, update);
std::array< float, 3 > position
std::shared_ptr< const OceanSprayFrame > previous
eve::action::ActionVfxBinding binding
AbilityActivationGroup group
float(ui::Theme::* member)[4]
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
static Result success(T value)
Construct a successful result owning value.
static Result failure(Status status)
Construct a failed result from a structured status.
群体行为模块:连续流场寻路 + 海量单位移动/转向/行动 + Boids 鸟群。
FieldObservation getFieldStatus() const noexcept
Observe current field readiness and owner-local revision without rebuilding.
Opaque owning steering selection, valid only for the captured Crowd input epoch.
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< 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 ...
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...
DiagnosticCode
Stable machine-readable diagnostic codes.
Owned changes for one live agent. Absent fields keep their existing values.
Agent-owned selection of a provider-defined movement policy. Zero identity and revision mean compatib...
Two-dimensional deterministic RTS world position.