载入中...
搜索中...
未找到
RTSCrowdMotion.cpp
浏览该文件的文档.
25Result<std::size_t> CrowdMotionSystem::stepInternal(const SimulationStep& step, crowd::Crowd& crowd,
58 auto view = ecs::View<Unit, Unit::Identity, Unit::Motion, Unit::Navigation, Unit::Orders, Unit::Crowd, Unit::Combat,
61 auto [identity, motion, navigation, orders, settings, combat, containment, supply, morale, tactics, command,
72 {unit, motion, navigation, settings, combat, supply, morale, tactics, command, effects, &orders->values});
74 // Logical-name admission happens only when a binding changes. Ordinary ticks use numeric references.
80 if (std::adjacent_find(keys.begin(), keys.end(), [](const auto* a, const auto* b) { return *a == *b; }) !=
83 Diagnostic::error(DiagnosticCode::Conflict, "RTS crowd agent keys must be unique", "unit.crowd.link"));
131 const int agent = crowd.addNamedAgent(key, entry.motion->x, entry.motion->y, entry.settings->heading,
152 entry.command->requiresCommand && !entry.command->inCommand ? entry.command->outOfCommandSpeedFactor : 1.0f;
153 const float effectFactor = static_cast<float>(entry.effects->values.multiplier("speedMultiplier"));
155 entry.motion->speed * speedFactor * commandFactor * effectFactor * entry.navigation->formationSpeedFactor;
164 attackMoveEngaged = engaged && distanceSquared(entry.motion->x, entry.motion->y, engaged->x, engaged->y) <=
212 auto steered = flowNavigation->steerRoute(crowd, {before.value().x, before.value().y}, assignment.route,
216 entry.navigation->unreachable = steered.value() == CrowdFlowNavigation::DriveState::Unreachable ||
233 Diagnostic::error(DiagnosticCode::Failed, "Cannot prepare RTS Crowd output frame", "rts.crowd.frame"));
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
Definition PixelWorld.cpp:53
#define EV_PROFILE_MODULE(module, name)
Profile the enclosing scope, tagged with a module for grouping.
Definition Profile.h:158
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
Result< AgentState > readAgent(AgentRef reference) const
Read an owning state snapshot by owner-qualified identity.
Definition CrowdRegistry.cpp:126
Result< StepReport > advance(float dt)
Advance using bounded simultaneous integration and contact projection.
Definition CrowdAdvance.cpp:60
int addNamedAgent(const std::string &stableId, float x, float y, float heading, float radius)
Add an agent with an editor/game-stable logical identifier.
Definition Crowd.cpp:150
Result< void > checkAdvanceClock(const CrowdStep &step) const
Validate external clock admission before a consumer publishes its input batch.
Definition CrowdAdvance.cpp:79
Result< AgentRef > agentRef(int slot) const
Resolve a compatibility dense slot to an owning identity value.
Definition CrowdRegistry.cpp:113
Result< AgentBatchReceipt > updateAgents(const AgentUpdateBatch &batch)
Compatibility-only one-call facade over canonical prepareAgentUpdates/commitAgentUpdates....
Definition CrowdBatch.cpp:42
Result< AgentUpdatePlan > prepareAgentUpdates(const AgentUpdateBatch &batch) const
Canonically validate and own a batch before a later nonallocating commit. @ownership Copies values; r...
Definition CrowdUpdatePlan.cpp:13
Result< AgentRef > resolveNamedAgent(const std::string &stableId) const
Resolve a logical name once at binding boundaries, without rebuilding any state.
Definition CrowdRegistry.cpp:120
Result< AgentBatchReceipt > commitAgentUpdates(AgentUpdatePlan &&plan, std::span< const std::uint8_t > selection)
Validate all identities then apply selected prepared updates without allocating success-path workspac...
Definition CrowdUpdatePlan.cpp:43
bool isAgentAlive(AgentRef reference) const noexcept
Whether the owner and generation still identify a live agent. @thread Simulation thread only; the cal...
Definition CrowdRegistry.cpp:124
Result< AgentBatchReceipt > removeAgents(const AgentRemovalBatch &batch)
Atomically remove live references; every reference is checked before any removal. @ownership Borrows ...
Definition CrowdBatch.cpp:70
Result< AgentBatchReceipt > copyAgentStates(std::span< const AgentRef > references, AgentFrame &destination) const
Copy a selected owning frame in request order; stale input preserves the destination....
Definition CrowdBatch.cpp:108
static Result< std::size_t > stepSharedFlow(const SimulationStep &step, crowd::Crowd &crowd, CrowdFlowNavigation &navigation)
Consume shared static-goal fields through a known owner-thread flow service.
Definition RTSCrowdMotion.cpp:21
static Result< std::size_t > step(const SimulationStep &step, crowd::Crowd &crowd)
Push ECS targets into Crowd, advance it once, and project positions back to Unit::Motion.
Definition RTSCrowdMotion.cpp:18
void keys(const Value &value, std::initializer_list< const char * > names)
Definition OceanCodecInternal.h:8
WorldPosition movementGoal(Unit &unit, const OrderRecord &order)
Resolve the current canonical movement goal without retaining entity pointers. @ownership Returns a w...
Definition RTSSystemMovementInternal.h:100
float interactionArrivalRadius(Unit &unit, const OrderRecord &order)
Definition RTSSystemMovementInternal.h:75
float distanceSquared(float ax, float ay, float bx, float by)
Definition RTSSystemMovementInternal.h:27
Result< std::optional< OrderRecord > > readCurrent(OrderComponent &orders)
Definition RTSSystemMovementInternal.h:115
bool isMovementOrder(OrderKind kind)
Definition RTSSystemMovementInternal.h:47
std::optional< WorldPosition > entityPosition(const ecs::EntityHandle &handle)
Definition RTSSystemMovementInternal.h:89
bool isSharedFlowOrder(Unit &unit, const OrderRecord &order)
Whether motion uses a shared field instead of a radius-clear moving slot.
Definition RTSSystemMovementInternal.h:42
Definition RTS.cpp:30
@ HoldPosition
@ AttackMove
@ Attack
@ SupplyRelay
@ Resupply
@ InvalidArgument
@ Failed
@ Conflict
@ NoOp
@ Applied
Explicit owner step; positive duration consumes the next contiguous tick. Zero reconciles current tic...
Definition Crowd.h:88