UMassBattleAgentBehaviorProcessor
Source/MassBattle/Public/Processors/MassBattleAgentBehaviorProcessor.h
概述Overview
行为状态机处理器:驱动睡眠、巡逻、追击、攻击、增援、返回等行为决策的逐帧推进。它由插件在每帧模拟的固定阶段自动调度,你不需要(也不能)手动调用或配置它;行为的具体表现全部由兵种 DataAsset 里的行为面板(Appear/Sleep/Patrol/Chase/Attack/Reinforce 等)决定。
The behavior state-machine processor: drives the per-frame progression of sleep, patrol, chase, attack, reinforce and return decisions. The plugin schedules it automatically at a fixed point in each simulation frame — you never call or configure it directly; what the behaviors do is decided entirely by the behavior panels (Appear/Sleep/Patrol/Chase/Attack/Reinforce…) on the unit DataAsset.
一帧内对单个智能体的处理是一趟按固定顺序推进的分段遍历:每个状态段依次做进入/退出判定,段序本身表达优先级——攻击段先于追击段,且攻击回合进行中追击不会重新进入;返回只在空闲时触发。
Within one frame, a single agent is processed as one ordered pass of sections: each state section runs its entry/exit checks in sequence, and the order itself carries precedence — attack runs before chase, chase cannot re-enter while an attack round is running, and return only triggers while the agent is idle.
继承Inheritance
静态辅助函数Static Helpers
三个公开静态函数把几何与冲量运算开放给同一管线里的其它系统:移动层与攻击段读同一把胶囊测距尺,行为切换路径与外部请求路径应用同一个起跳冲量,所以两条路径不会给出不同的结论或不同的跳跃物理。
Three public static functions expose geometry and impulse math to the rest of the pipeline: the move layer and the attack section read one capsule-range ruler, and the behavior-switch path and the external request path apply one jump impulse, so neither pair can disagree.
两条有限线段之间的最近距离平方。用夹紧参数解求最近点对,两个参数都限制在 [0,1];任一线段退化为点(或两者都退化)时改按点-线、点-点处理,调用方不必预先筛掉退化输入。胶囊测距以它为线段级基准。
Squared closest distance between two finite line segments. Finds the closest point pair with both parameters clamped to [0,1]; a segment that degenerates to a point (or both of them) is handled as point-to-segment or point-to-point, so callers need not pre-filter degenerate input. It is the segment-level basis of the capsule range.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
P0 | const FVector& | 第一条线段的起点。Start point of the first segment. |
P1 | const FVector& | 第一条线段的终点。End point of the first segment. |
Q0 | const FVector& | 第二条线段的起点。Start point of the second segment. |
Q1 | const FVector& | 第二条线段的终点。End point of the second segment. |
Output
返回最近距离的平方(非负)。无副作用。
Returns the squared closest distance (non-negative). No side effects.
两个胶囊之间的表面最近距离:先求两条轴线段之间的距离,再减去两个半径,表面相交时夹到 0。它是同一把交战距离尺——攻击段用它判定开火距离,移动处理器用同一个函数判定冷却期间是否仍在交战中,所以两处不会一边认为够得着、一边认为不够。
Closest distance between the surfaces of two capsules: the distance between the two axis segments minus both radii, clamped to 0 when the surfaces overlap. It is one engagement-range ruler — the attack section uses it for the firing-range test and the move processors use the same function to decide whether a cooling unit is still in range, so the two can never disagree on reachability.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
CenterA | const FVector& | 第一个胶囊轴线的中点。Midpoint of the first capsule's axis. |
AxisA | const FVector& | 第一个胶囊的轴线方向(单位向量)。Axis direction of the first capsule (unit vector). |
ShaftHalfLenA | float | 第一个胶囊轴线段的一半长度。Half length of the first capsule's shaft segment. |
RadiusA | float | 第一个胶囊的半径。Radius of the first capsule. |
CenterB | const FVector& | 第二个胶囊轴线的中点。Midpoint of the second capsule's axis. |
AxisB | const FVector& | 第二个胶囊的轴线方向(单位向量)。Axis direction of the second capsule (unit vector). |
ShaftHalfLenB | float | 第二个胶囊轴线段的一半长度。Half length of the second capsule's shaft segment. |
RadiusB | float | 第二个胶囊的半径。Radius of the second capsule. |
Output
返回两个胶囊表面的最近距离;表面相交或贴合时为 0。无副作用。
Returns the closest distance between the two capsule surfaces, or 0 when they overlap or touch. No side effects.
起跳冲量的唯一实现:竖直速度抬到至少 Jump.ZSpeed(不会压低更大的上抛速度),沿朝向的水平方向叠加 Jump.ForwardSpeed,并把跳跃冷却计时器置为 Jump.Cooldown、滞空时间清零。行为切换路径与外部请求路径都调用它,所以同一次跳跃无论由谁发起,物理结果一致。
The single implementation of the takeoff impulse: raises vertical speed to at least Jump.ZSpeed (never lowering a larger upward velocity), adds Jump.ForwardSpeed along the facing direction, sets the jump cooldown timer to Jump.Cooldown and clears the air time. Both the behavior-switch path and the external request path call it, so a jump is physically identical whichever way it was requested.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Jump | const FJump& | 跳跃配置:竖直初速、水平初速与冷却时长。Jump config: vertical speed, forward speed and cooldown duration. |
Rotating | const FRotating& | 朝向来源;Direction 的水平归一化分量决定前冲方向。Facing source; the 2D-normalized Direction sets the forward direction. |
Moving | FMoving& | 移动状态,函数写入 CurrentVelocity。Move state; the function writes CurrentVelocity. |
Jumping | FJumping& | 跳跃运行时状态,函数写入冷却计时器与滞空时间。Jump runtime state; the function writes the cooldown timer and air time. |
Output
无返回值。副作用:修改 Moving.CurrentVelocity 的 Z(取较大值)与 X/Y(叠加前冲),写入 Jumping.CooldownTimer 并把 Jumping.AirTime 清零。是否允许起跳(冷却、已在空中)由调用方判断。
No return value. Side effects: raises the Z of Moving.CurrentVelocity (keeps the larger value), adds the forward push to X/Y, writes Jumping.CooldownTimer and zeroes Jumping.AirTime. Whether a jump is allowed (cooldown, already airborne) is the caller's decision.
类方法Class Methods
构造函数只做三件事:关闭处理阶段的自动注册、要求游戏线程执行、把执行域设为 Standalone / Server / Client。查询不在这里构建(见 ConfigureQueries);每一帧的驱动来自插件固定的子帧调度,而不是引擎处理阶段的自动注册。
The constructor only does three things: turns off auto-registration with the engine processing phases, requires game-thread execution, and sets the execution flags to Standalone / Server / Client. Queries are not built here (see ConfigureQueries); per-frame driving comes from the plugin's fixed sub-frame schedule, not from engine phase auto-registration.
Input
无参数。
No parameters.
Output
无返回值。副作用:写入 bAutoRegisterWithProcessingPhases(false)、bRequiresGameThreadExecution(true)与 ExecutionFlags。
No return value. Side effects: writes bAutoRegisterWithProcessingPhases (false), bRequiresGameThreadExecution (true) and ExecutionFlags.
初始化 EntityQuery 并一次性声明匹配集合:必需只读片段 28 个(含 FAgentTag)、必需读写片段 23 个、可选 FNotifyShared 一个。通知表按模板共享,而出生的与攻击的动画时钟都在本处理器推进,所以到期的通知行在这里收集。最后把查询注册到本处理器,整趟执行都用这一个查询。
Initializes EntityQuery and declares the match set in one place: 28 required read-only fragments (including FAgentTag), 23 required read-write fragments, and one optional FNotifyShared. The notify table is shared per template, and this processor advances both the appear and the attack animation clocks, so due notify rows are collected here. The query is then registered with the processor, and the whole pass runs on that one query.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
EntityManager | const TSharedRef<FMassEntityManager>& | 实体管理器,查询由它初始化。Entity manager the query is initialized from. |
Output
无返回值。副作用:初始化 EntityQuery、声明匹配集合,并把查询注册到本处理器。
No return value. Side effects: initializes EntityQuery, declares the match set and registers the query with this processor.
每帧入口。先做三道早退:没有 MassBattle 子系统、当前子帧不是 Subtick1、没有宿主子系统时直接返回;步长取子系统计算出的步长,不用引擎传入的增量。随后按 AutoBalance 并行遍历查询的每个 chunk,逐智能体跳过待销毁与未激活者,先解算本帧的瞄准与视线,再按固定顺序跑各状态段;chunk 结束把本地事件并入各事件队列,整趟结束把统计计数与指挥中心快照写回子系统。
Per-frame entry. Three early-outs come first: no MassBattle subsystem, the current sub-frame is not Subtick1, or no host subsystem — then it returns immediately; step time comes from the subsystem's calculated step, not the delta passed by the engine. It then iterates every query chunk in parallel with AutoBalance, skips pending-destroy and non-activated agents, solves this frame's aim and look before running the fixed-order state sections, and after each chunk appends its local events to the event queues; when the pass ends it writes the stat counters and commander snapshots back to the subsystem.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
EntityManager | FMassEntityManager& | 引擎传入的实体管理器。Entity manager supplied by the engine. |
Context | FMassExecutionContext& | 执行上下文;按此遍历 EntityQuery 的 chunk。Execution context; the EntityQuery chunks are iterated through it. |
Output
无返回值。副作用:写 MB.AgentCount 与四个行为计数(出生中/睡眠中/巡逻中/攻击中),把死亡、出生、攻击、睡眠、巡逻、追击、增援事件与增援报告并入子系统队列,并按确定性顺序重建 CommanderSnapshots。
No return value. Side effects: writes MB.AgentCount and four behavior counters (appearing, sleeping, patrolling, attacking), appends death, appear, attack, sleep, patrol, chase, reinforce events and reinforce reports to the subsystem queues, and rebuilds CommanderSnapshots in a deterministic order.
常量Constants
全部是 static constexpr EEntityFlags,作为 EBattleFlags 对应枚举值的缓存别名,省去逐帧 HasFlag / SetFlag / ClearFlag 时的枚举转换。它们只是本处理器内部使用的具名常量,不是可配置项。
Every entry is a static constexpr EEntityFlags alias of the matching EBattleFlags enumerator, saving the enum conversion on the per-frame HasFlag / SetFlag / ClearFlag calls. They are named constants internal to this processor, not settings.
| 名称Name | 值Value | 说明Description |
|---|---|---|
DyingFlag | EBattleFlags::Dying | 死亡已开始:大多数状态段在它置位时整体跳过,瞄准解算也不再为它申请姿态。Death has begun: most state sections are skipped entirely while it is set, and the aim solve no longer requests a pose for it. |
AppearingFlag | EBattleFlags::Appearing | 出生段活跃标记;Section 1 只在它置位时推进出生逻辑,结束时清除并按 OnAppearFinish 切换。Appear-section active flag; Section 1 advances appear logic only while it is set, clears it at the end and switches by OnAppearFinish. |
SleepingFlag | EBattleFlags::Sleeping | 睡眠段活跃标记;Section 2 只在该标志置位时检查唤醒条件。Sleep-section active flag; Section 2 checks the wake conditions only while it is set. |
PatrollingFlag | EBattleFlags::Patrolling | 巡逻段活跃标记;Section 3 的到达、等待与换点逻辑都在其下推进。Patrol-section active flag; arrival, waiting and goal-reselection in Section 3 all run under it. |
AttackingFlag | EBattleFlags::Attacking | 攻击回合活跃标记:整个回合(对齐、前摇、后摇、冷却)期间保持置位,同时把智能体排除在追击段的进入条件之外。Attack-round active flag: stays set through the whole round (aligning, wind-up, follow-through, cooling) and keeps the agent out of the chase section's entry condition. |
AimingFlag | EBattleFlags::Aiming | 攻击回合进入对齐阶段时置位,把智能体标记为已驻停/交战中,使移动层与外部查询不把它当空闲;对齐完成或超时后清除。Set when the attack round enters its aligning phase; marks the agent as planted/in combat so the move layer and external queries do not read it as idle. Cleared on alignment or aim timeout. |
ChasingFlag | EBattleFlags::Chasing | 追击段活跃标记;Section 5 按进入/退出前后该标志的变化产生 Chase 进入与退出事件。Chase-section active flag; Section 5 emits chase enter/exit events from the change of this flag across the section. |
ReinforcingFlag | EBattleFlags::Reinforcing | 增援段活跃标记,表示智能体正前往指挥中心共享的目标;丢失目标或卡住超时后退出。Reinforce-section active flag, meaning the agent is moving to a target shared by its command center; exits when the target is lost or the stuck timeout fires. |
AppearAnimFlag | EBattleFlags::AppearAnim | 出生动画进行中;Section 1 用它驱动动画时钟,达到实际出生时长后清除。Appear animation running; Section 1 drives the animation clock with it and clears it once the real appear duration is reached. |
AppearDissolveFlag | EBattleFlags::AppearDissolve | 溶解淡入进行中;Section 1 沿溶解曲线推进溶解量,曲线走完即清除。Dissolve-in running; Section 1 advances the dissolve amount along the dissolve curve and clears the flag when the curve ends. |
PlayerDrivenFlag | EBattleFlags::PlayerDriven | 对应枚举值的缓存别名,供本处理器逐帧标志判定使用;语义由 EBattleFlags 定义。Cached alias of the matching enumerator used for per-frame flag tests in this processor; its meaning is defined by EBattleFlags. |
BeingHitFlag | EBattleFlags::BeingHit | 受击反应标记;睡眠段在它置位且 Sleep.bWakeOnHit 打开时按 OnSleepWake 唤醒,调试标签也读它区分并发的受击反应。Hit-reaction flag; the sleep section wakes by OnSleepWake when it is set and Sleep.bWakeOnHit is on, and the debug labels read it to show the concurrent hit reaction. |
PendingDestroyFlag | EBattleFlags::PendingDestroy | 待销毁:逐智能体循环在它置位时直接跳过,不再推进任何行为。Pending destroy: the per-agent loop skips the agent outright while it is set, advancing no behavior. |
ActivatedFlag | EBattleFlags::Activated | 已激活:未激活的智能体在逐智能体循环中被跳过。Activated: agents without this flag are skipped by the per-agent loop. |
SlowingFlag | EBattleFlags::Slowing | 带减速效果;攻击段只在该标志置位时读取减速来源并拉长攻击时间轴。Slowed; the attack section reads the slow sources and stretches the attack timeline only while it is set. |
AttackAnimFlag | EBattleFlags::AttackAnim | 攻击动画进行中;进入冷却时清除,用来停止攻击动画。Attack animation running; cleared when the round enters cooling, which stops the attack animation. |
PauseAnimChangeFlag | EBattleFlags::PauseAnimChange | 回合结束的下一帧暂停动画切换,避免循环中的攻击动画立刻被替换。Pauses animation switching for the tick after a round ends, so a looping attack animation is not replaced immediately. |
SelectedFlag | EBattleFlags::Selected | 已被选中;调试标签据此显示 Selected。Selected; the debug label shows Selected from it. |
BeingSelectFlag | EBattleFlags::BeingSelect | 选择中;调试标签据此显示 Being Select。Being selected; the debug label shows Being Select from it. |
ReturningFlag | EBattleFlags::Returning | 归位进行中;触发与超时门在本处理器,走回家的位移由移动层的该标志分支执行。Returning home; the trigger and timeout gate live in this processor, while the walk-home displacement runs in the move layer's branch for this flag. |
IdleFlag | EBattleFlags::Idle | 空闲:只由 Section 8 在帧末写入,是互斥行为标志全清后的最终结果。Idle: written only by Section 8 at the end of the frame, as the result of every exclusive behavior flag being clear. |
JumpingFlag | EBattleFlags::Jumping | 跳跃中;跳跃切换会拒绝已处于该状态的请求,落地或滞空超时后按 OnJumpFinish 退出。Jumping; the jump switch refuses a request already in this state, and the agent exits by OnJumpFinish on landing or air-time timeout. |
FallingFlag | EBattleFlags::Falling | 下落中;属于并行反应层,跳跃切换在它置位时拒绝新的跳跃请求。Falling; a concurrent reaction layer flag, and the jump switch refuses a new jump while it is set. |
LaunchingFlag | EBattleFlags::Launching | 被击飞中;同样让跳跃切换拒绝新的跳跃请求。Launched; it likewise makes the jump switch refuse a new jump request. |
BPTaskMoveToFlag | EBattleFlags::BPTask_MoveTo | 外部行为树任务接管移动;归位触发必须尊重的移动所有权标记之一。An external behavior-tree task owns movement; one of the movement-ownership flags the return trigger must respect. |
AStarMovingToFlag | EBattleFlags::AStarMovingTo | A* 路径移动接管中;归位触发同样尊重该所有权。A* path movement owns the agent; the return trigger respects that ownership too. |
成员变量Members
| 名称Name | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
EntityQuery | FMassEntityQuery | — | 处理器唯一的查询:ConfigureQueries 初始化并注册,Execute 用它取匹配实体数并做 chunk 级并行遍历。私有成员。The processor's only query: initialized and registered in ConfigureQueries, used by Execute for the match count and the chunk-level parallel pass. Private member. |
私有辅助方法Private Helpers
两个私有辅助方法只服务本处理器内部:一个重建巡逻的计时与原点,一个为巡逻挑选可达的随机目标。
Two private helpers serve this processor only: one resets patrol timing and origin, the other picks a reachable random patrol goal.
| 名称Name | 签名Signature | 说明Description |
|---|---|---|
ResetPatrol | static FORCEINLINE void ResetPatrol(FPatrol&, FPatrolling&, const FLocating&) | 把移动剩余时间重置为 Patrol.MaxMovingTime、等待剩余时间重置为 Patrol.CoolDown,并按 EPatrolOriginMode 重取原点(Previous = 当前位置,Initial = 初始位置)。巡逻进入、换点与超时重选都走它。Resets the move time left to Patrol.MaxMovingTime and the wait time left to Patrol.CoolDown, and re-picks the origin by EPatrolOriginMode (Previous = current location, Initial = initial location). Patrol entry, goal reselection and timeout recovery all go through it. |
FindRandomReachableGoal | bool FindRandomReachableGoal(const FPatrol&, const FLocating&, const FNavigating&, FRandomStream&, FVector&, const FMove&, const FMoving&, const FCollider&, const FScaling&, const FVector3f&) | 在 Patrol.Origin 周围的随机环内取点,最多尝试 Patrol.MaxPickAttempts 次,优先接受 flow field 单元拟合或导航网格投影的落点;全部失败则退回原始环点。它总是返回 true,让巡逻不会卡在反复等待里,可达性交给移动层的导航与移动超时处理。飞行单位把 Moving.FlyingHeight 叠到投影地面上。Picks random ring points around Patrol.Origin, up to Patrol.MaxPickAttempts attempts, preferring a point that fits the flow-field cell grid or projects onto the navmesh. It falls back to the raw ring point and always returns true, so patrol cannot deadlock in a wait/retry loop; reachability is left to the move layer's navigation and move timeout. Flying agents add Moving.FlyingHeight above the projected ground. |
管线角色Pipeline Role
执行时机:构造函数关闭处理阶段的自动注册并要求游戏线程执行,执行域为 Standalone / Server / Client;真正的调度来自插件固定的子帧链——Execute 首部检查当前子帧是否为 Subtick1,不是就整趟跳过。按源码内注释,它在 Subtick1 头部运行:使用同一 tick 内 Subtick0 的 Trace 结果,并在移动分区 1 之前完成,因此本帧的击退收集能喂给同 tick 的移动,伤害也能被同 tick 的投射物与反应逻辑消费。
Timing: the constructor turns off processing-phase auto-registration and requires game-thread execution, with the execution flags set to Standalone / Server / Client; actual scheduling comes from the plugin's fixed sub-frame chain — Execute checks whether the current sub-frame is Subtick1 and skips the whole pass otherwise. Per the code's own comments it runs at the head of Subtick1: it uses the same tick's Subtick0 trace results and completes before move partition 1, so this frame's knockback collection feeds same-tick movement and damage is consumed by the same tick's projectile and reaction logic.
并行与收尾:chunk 在 AutoBalance 策略下并行处理,事件先收进 chunk 局部数组,chunk 末统一并入死亡/出生/攻击/睡眠/巡逻/追击/增援事件队列与增援报告收集器;四个行为计数用原子量汇总后写回子系统。增援报告合并后重建指挥中心快照,确定性开关打开时先按 UniqueID 排序——实体句柄的下标是进程本地的,不能当排序键。
Parallelism and drain: chunks run in parallel under AutoBalance; events are collected into chunk-local arrays and appended at chunk end to the death/appear/attack/sleep/patrol/chase/reinforce event queues and the reinforce report gatherer, and the four behavior counters are summed through atomics and written back to the subsystem. Reinforce reports are merged into the commander snapshots, sorted by UniqueID first when determinism is on — entity handle indices are process-local and cannot serve as a sort key.
段序即优先级:状态互斥由切换函数保证——每次切换清空全部行为标志,再按目标状态置位一个,所以同一时刻只有一个行为段真正推进。顺序上,攻击在追击之前,追击段又显式排除攻击回合进行中的智能体;返回是最后考虑的行为,只在空闲时触发,空闲标志则固定在 Section 8 的帧末写入。
Section order is precedence: the switch function keeps states exclusive by clearing every behavior flag and then setting the one for the target state, so only one behavior section actually advances at a time. In order, attack precedes chase and the chase section explicitly excludes agents inside an attack round; return is the last behavior considered and triggers only while idle, and the idle flag is written at the end of the frame in Section 8.
| 顺序Order | 段Section | 职责Responsibility |
|---|---|---|
1 | Section 1 · 出生Section 1 · Appear | 推进出生:解析或抽取出生剪辑、推进动画与溶解时钟、收集出生事件;时长走完时按 OnAppearFinish 切换行为。Advances appear: resolves or picks the appear clip, drives the animation and dissolve clocks and collects appear events; switches by OnAppearFinish once the duration elapses. |
2 | Section 2 · 睡眠Section 2 · Sleep | 睡眠唤醒只有三个出口:配置关闭、发现有效目标、受击且 Sleep.bWakeOnHit 打开;后两者分别去空闲或 OnSleepWake。Sleep has three wake exits: the config is disabled, a valid target appears, or the agent is hit with Sleep.bWakeOnHit enabled; the last two go to idle or OnSleepWake. |
3 | Section 2.5 · 跳跃Section 2.5 · Jump | 推进滞空时间与全局跳跃冷却;落地或超过 MaxAirTime 时按 OnJumpFinish 退出。Advances air time and the global jump cooldown; exits by OnJumpFinish on landing or when MaxAirTime is exceeded. |
4 | Section 3 · 巡逻Section 3 · Patrol | 到达判定、等待与换点、移动超时重选;巡逻关闭或目标可被追击与攻击消费时退出。Arrival test, waiting and goal reselection, and move-timeout recovery; exits when patrol is disabled or the target can be consumed by chase or attack. |
5 | Section 4 · 攻击Section 4 · Attack | 用胶囊表面距离、射界与底盘动用权判定开火请求,推进对齐阶段与逐段攻击时钟,处理冷却与结束事件。Decides the firing request from capsule surface distance, aim gates and chassis permission, advances the aligning phase and the staged attack clock, and handles cooling and end events. |
6 | Section 5 · 追击Section 5 · Chase | 目标有效且未超过 MaxChaseDistance 时进入并保持目标点;攻击回合进行中不接管。Enters and keeps the goal while the target is valid and within MaxChaseDistance; does not take over while an attack round is running. |
7 | Section 6 · 增援Section 6 · Reinforce | 向指挥中心查询最近的共享目标并前往;丢失或卡住超时后重查,无目标则按 OnLostTarget 退出。Asks the command center for the nearest shared target and moves to it; re-queries after a loss or stuck timeout, and exits by OnLostTarget when none remains. |
8 | Section 7 · 返回(仅完成事件)Section 7 · Return (completion only) | 只消费移动层给出的归位完成信号 Returning.bJustFinished,并应用 OnReturnFinish。Only consumes the completion signal Returning.bJustFinished written by the move layer and applies OnReturnFinish. |
9 | Section 8 · 空闲Section 8 · Idle | 空闲标志的唯一写入点:行为标志全清时置位,否则清除。The only write site for the idle flag: set when every behavior flag is clear, cleared otherwise. |
10 | Section 8.5 · 返回(触发与状态)Section 8.5 · Return (trigger and state) | 归位触发、目标空间检查与超时门;归位位移由移动层执行。刻意排在 Section 8 之后,使触发当帧仍保持空闲标志。The return trigger, goal-space admission and timeout gate; the walk-home displacement runs in the move layer. Deliberately after Section 8 so the trigger frame keeps the idle flag. |
归位分工:本处理器只负责触发归位、写目标点与计时器、置位与清除标志;走回家的路径由移动层的归位分支执行。瞄准解算与视线更新在状态段之前逐智能体完成,视线只影响表现、不写模拟输入。
Division of labour for return: this processor only triggers the return, writes the goal and timers, and sets or clears flags; the walk-home path runs in the move layer's return branch. The aim solve and look update run per agent before the state sections, and look only affects presentation — it writes no simulation input.
补充说明Notes
① 互斥是切换函数的责任:同一时刻只有一个行为标志活跃——切换函数清空全部行为标志,再按目标状态置位一个;攻击回合的进度在切换时被冻结而非重置,冷却保留已经走过的部分,已经执行过的施法段不会重跑。
② 跳过规则:待销毁与未激活的智能体不进入任何状态段;移动锁 Moving.bMoveToLocked 抑制大多数状态段,但攻击段仍会运行,由底盘动用权决定它能拿什么、能否开火。
③ 归位依赖邻居哈希格:取不到网格时只跳过归位,其余状态段照常完成。
④ 调试标签的兜底:行为标签按标志逐个匹配;若所有行为标志都未置位而空闲标志也没有置位,标签显示问号——它存在的意义就是让这种漏写肉眼可见,而不是被静默归入空闲。
① Exclusivity belongs to the switch function: only one behavior flag is live at a time — the switch clears every behavior flag and then sets the one for the target state; attack-round progress is frozen rather than reset on a switch, so cooling keeps the elapsed part and an already-executed cast section does not run again.
② Skip rules: pending-destroy and non-activated agents enter no state section; the move lock Moving.bMoveToLocked suppresses most sections, but the attack section still runs, and the chassis permission decides what it may take and whether it may fire.
③ Return needs the neighbour hash grid: when the grid is unavailable only the return step is skipped and every other state section still completes.
④ Debug-label fallback: the behavior label matches flags one by one; if no behavior flag and no idle flag is set, the label shows a question mark — its purpose is to make such a missing write visible rather than silently labelled idle.