Behavior.h
Source/MassBattle/Public/Fragments/Behavior.h
概述 Overview
行为系统的 fragment 集合:配置 FBehavior 定义六个行为转移点的目标行为(出生、出生结束、睡眠唤醒、巡逻回合结束、丢失目标、回归结束),运行时状态 FBehaving 携带当前互斥行为、请求切换的行为与消费标志。行为处理器消费请求并执行转移。
Behavior fragment collection: config FBehavior defines the target behavior at six transition points (birth, appear finish, sleep wake, patrol round end, target lost, return finish); runtime state FBehaving carries the current mutually-exclusive behavior, the requested switch and the consume flag. The behavior processor consumes requests and executes transitions.
FBehavior USTRUCT
行为配置 fragment(FA_MassBattleBaseFragment 派生)。六个转移点各指定一个 EBehaviorChoice 目标行为,策划在 EntityConfig 中配置,运行时不变。
Behavior config fragment (derived from FA_MassBattleBaseFragment). Each of the six transition points names an EBehaviorChoice target; configured by designers in EntityConfig, constant at runtime.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
OnBirth | EBehaviorChoice | Idle | Agent 出生或激活时选择的行为。Behavior selected when the agent is born or activated. |
OnAppearFinish | EBehaviorChoice | Idle | 出生行为结束后选择的行为。Behavior selected when Appear finishes. |
OnSleepWake | EBehaviorChoice | Idle | 睡眠中受到攻击且 bWakeOnHit 启用时选择的行为。Behavior selected when Sleep is interrupted by a hit while bWakeOnHit is set. |
OnPatrolRoundEnd | EBehaviorChoice | Patrol | 一轮巡逻结束后选择的行为。Behavior selected when a patrol round ends. |
OnLostTarget | EBehaviorChoice | Idle | 追逐或攻击丢失当前目标后选择的行为。Behavior selected when the current target is lost by chase or attack. |
OnReturnFinish | EBehaviorChoice | Idle | 回归结束后选择的行为。Behavior selected when Return finishes. |
FBehaving USTRUCT
行为运行时状态 fragment(FA_MassBattleBaseFragment 派生)。行为处理器逐帧读取 ActiveBehavior;外部(任务节点、事件)写入 RequestedBehavior + bHasSwitchRequest 请求切换,处理器消费后清除。
Behavior runtime state fragment (derived from FA_MassBattleBaseFragment). The behavior processor reads ActiveBehavior each frame; external code (task nodes, events) writes RequestedBehavior + bHasSwitchRequest to request a switch, which the processor consumes and clears.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
ActiveBehavior | EBehaviorState | Idle | 当前激活的互斥行为。Currently active mutually-exclusive behavior. |
RequestedBehavior | EBehaviorState | Idle | 请求的行为切换,由行为处理器消费。Requested behavior switch, consumed by the behavior processor. |
bHasSwitchRequest | bool | false | 本帧是否应消费 RequestedBehavior。Whether RequestedBehavior should be consumed this frame. |
管线角色 Pipeline Role
FBehavior / FBehaving 由行为处理器读取(grep 验证:MassBattleAgentBehaviorProcessor、MassBattleAgentReactionProcessor、MassBattleAgentMoveProcessor / MoveProcessorFP 与行为任务节点)。行为处理器消费 RequestedBehavior 转移点,移动处理器按 ActiveBehavior 分支移动模式。
FBehavior / FBehaving are read by the behavior processors (verified by grep: MassBattleAgentBehaviorProcessor, MassBattleAgentReactionProcessor, MassBattleAgentMoveProcessor / MoveProcessorFP and the behavior task nodes). The behavior processor consumes RequestedBehavior transition points; the movement processors branch movement modes on ActiveBehavior.