MassBattle Docsv1.19.20

Behavior.h

USTRUCT ×2

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
OnBirthEBehaviorChoiceIdleAgent 出生或激活时选择的行为。Behavior selected when the agent is born or activated.
OnAppearFinishEBehaviorChoiceIdle出生行为结束后选择的行为。Behavior selected when Appear finishes.
OnSleepWakeEBehaviorChoiceIdle睡眠中受到攻击且 bWakeOnHit 启用时选择的行为。Behavior selected when Sleep is interrupted by a hit while bWakeOnHit is set.
OnPatrolRoundEndEBehaviorChoicePatrol一轮巡逻结束后选择的行为。Behavior selected when a patrol round ends.
OnLostTargetEBehaviorChoiceIdle追逐或攻击丢失当前目标后选择的行为。Behavior selected when the current target is lost by chase or attack.
OnReturnFinishEBehaviorChoiceIdle回归结束后选择的行为。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
ActiveBehaviorEBehaviorStateIdle当前激活的互斥行为。Currently active mutually-exclusive behavior.
RequestedBehaviorEBehaviorStateIdle请求的行为切换,由行为处理器消费。Requested behavior switch, consumed by the behavior processor.
bHasSwitchRequestboolfalse本帧是否应消费 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.