MassBattle Docsv1.19.20

MassBattleBPTaskSnapshot.h

USTRUCT ×2 UENUM ×1

Source/MassBattle/Public/Tasks/MassBattleBPTaskSnapshot.h

概述 Overview

BP 异步任务(AgentsMoveTo / AgentsChaseAttack)的快照记录类型,随 FEntitySnapshotPayload 传输。resync 时旧任务对象被终止,依据这些记录经任务模板重建(UMassBattleBPTaskTemplateBase——TemplateKey 解析模板 BP 类,由模板重新绑定 delegate,BP 事件处理器在 resync 后存活)。只存可同步数据:UObject 引用(actor、FlowField)存路径,恢复时本地 FindObject 解析。无同名 .cpp——纯数据声明,序列化由反射(UPROPERTY)驱动。

Snapshot record types for the BP async tasks (AgentsMoveTo / AgentsChaseAttack), carried in FEntitySnapshotPayload. On resync the old task objects are terminated and rebuilt from these records via the task template (UMassBattleBPTaskTemplateBase — TemplateKey resolves the template BP class, which re-binds the delegates so BP event handlers survive resync). Only sim-syncable data lives here: UObject references (actors, FlowFields) are stored as paths and resolved locally on restore. No same-name .cpp — pure data declarations, serialized by reflection (UPROPERTY).

结构体 Structs

FAgentTaskAgentStateRecord USTRUCT (BlueprintType)

单 agent 的任务运行状态记录:UniqueID(实体 UID,恢复时反解为句柄)承载 MoveTo 的每 agent 运行状态(解析目标 / 目标索引 / 卡住检测 / 挂起 / 自定义路径跟踪);ChaseAttack 复用上方卡住字段(失败语义一致),另有 bWasOnInterruptedTarget(软锁定中断边沿闩)。

Per-agent task runtime-state record: UniqueID (entity UID, re-resolved to a handle on restore) carries the MoveTo per-agent runtime state (resolved goal / goal index / stuck tracking / suspension / custom-path tracking); ChaseAttack reuses the stuck fields above (same fail semantics) plus bWasOnInterruptedTarget (soft-lock interrupt edge latch).

成员变量 Members
名称 Name类型 Type默认值说明 Description
UniqueIDint32-1Agent 实体 UID,恢复时反解为句柄。Agent entity UID, re-resolved to a handle on restore.
ResolvedGoalLocationFVectorZeroVectorMoveTo 解析后的目标位置。MoveTo resolved goal location.
GoalIndexint320目标数组索引。Index into the goal array.
StuckCheckTimerfloat0.0卡住检测累计时长(两任务共用)。Stuck-check accumulated time (shared by both tasks).
StuckCheckStartLocationFVectorZeroVector卡住窗口起点位置。Stuck-window start location.
bStuckCheckStartedboolfalse卡住窗口是否已开启。Whether the stuck window is open.
bIsSuspendedboolfalseMoveTo:是否被行为挂起。MoveTo: whether suspended by a behavior.
CustomPathIndexint320MoveTo 自定义路径索引。MoveTo custom-path index.
CurrentWaypointIndexint320当前航点索引。Current waypoint index.
PathDirectionint321路径方向(+1 正向 / −1 反向,PingPong)。Path direction (+1 forward / −1 reverse, PingPong).
bWasOnInterruptedTargetboolfalseChaseAttack 软锁定:是否曾在非任务目标上(中断边沿闩)。ChaseAttack soft lock: whether on a non-task target (interrupt edge latch).
OriginTaskIDint320手动任务合并(MergeAgentsMoveToTasks)的来源任务 ID——该 agent 最初属于哪个壳任务;执行体按此把每 agent 事件路由回壳。0 = 执行体原生 agent(未合并)。旧快照默认 0。Origin task ID for the manual task merge (MergeAgentsMoveToTasks) — which merged shell task this agent originally came from; the executor routes per-agent events back to it. 0 = native agent of the executor (no merge). Old snapshots default to 0.
FAgentTaskSnapshotRecord USTRUCT (BlueprintType)

任务级快照记录:TaskType(MoveTo / ChaseAttack)选择重建工厂;MyTaskID 必须与服务器存活任务一致(fragment 所有权检测匹配);TemplateKey 是模板 BP 类路径(空 = C++ 直建 → 恢复为无绑定);MoveTo 配置区(目标类型/位置/Actor 路径/实体 UID、导航模式/流场路径/图层/自定义路径/失败条件/可中断)与 ChaseAttack 配置区(目标 UID、可中断,失败条件复用);共享可视化配置;运行状态(跟踪行、累计失败 UID、bSuccessFired 闩)与手动合并区(bMergedShell / ExecutorTaskID,配合每 agent 的 OriginTaskID)。

Task-level snapshot record: TaskType (MoveTo / ChaseAttack) selects the rebuild factory; MyTaskID must equal the surviving server task's (fragment ownership checks match); TemplateKey is the template BP class path (empty = C++ direct creation → restored unbound); the MoveTo config section (goal type/locations/actor paths/entity UIDs, nav mode/flow-field path/layer/custom paths/fail conditions/can-interrupt) and ChaseAttack config section (target UID, can-interrupt; fail conditions shared); shared visualization config; runtime state (tracking rows, accumulated failed UIDs, the bSuccessFired latch) plus the manual-merge section (bMergedShell / ExecutorTaskID, paired with the per-agent OriginTaskID).

成员变量 Members
名称 Name类型 Type默认值说明 Description
TaskTypeEBPTaskSnapshotTypeMoveTo任务类型。Task kind.
MyTaskIDint320确定性任务 ID,必须与服务器存活任务一致。Deterministic task ID, must match the surviving server task.
TemplateKeyFName—模板 BP 类路径(UMassBattleBPTaskTemplateBase 子类);空 = 恢复为无绑定。Template BP class path (UMassBattleBPTaskTemplateBase subclass); empty = restored unbound.
GoalTypeint320EMBMoveGoalType 以 int32 存储(0=Location 1=Actor 2=Entity)。EMBMoveGoalType as int32 (0=Location 1=Actor 2=Entity).
LocationsTArray<FVector>空目标位置数组(常规 Activate 后为空,重建时从 per-agent 值回填)。Goal locations (empty after normal Activate; refilled from per-agent values on rebuild).
GoalActorPathsTArray<FString>空目标 Actor 路径,恢复时本地 FindObject 解析。Goal actor paths, resolved locally via FindObject on restore.
GoalEntityUIDsTArray<int32>空目标实体 UID 数组。Goal entity UID array.
NavigationModeint320ENavMode 以 int32 存储。ENavMode as int32.
FlowFieldPathFString空流场路径,恢复时本地解析。FlowField path, resolved locally on restore.
FlowFieldLayerFFlowFieldLayerHandle—流场图层句柄。Flow-field layer handle.
CustomPathsTArray<FMBCustomPath>空自定义路径数组。Custom path array.
CustomPathModeint320ECustomPathMode 以 int32 存储。ECustomPathMode as int32.
FailConditionsFMBMoveFailCondition—失败条件(两任务共用,语义一致)。Fail conditions (shared by both tasks, same semantics).
bCanInterruptboolfalseMoveTo:行为是否可中断。MoveTo: whether behaviors can interrupt.
TargetUIDint32-1ChaseAttack 目标 UID。ChaseAttack target UID.
bBehaviorsCanInterruptboolfalseChaseAttack 锁定模式(false = 硬锁,true = 软锁)。ChaseAttack lock mode (false = HARD, true = SOFT).
VisualizationFAgentTaskVisualizationConfig—共享可视化配置。Shared visualization config.
TrackedAgentsTArray<FAgentTaskAgentStateRecord>空每 agent 运行状态。Per-agent runtime state.
AccumulatedFailedUIDsTArray<int32>空累计失败 UID。Accumulated failed UIDs.
bSuccessFiredboolfalse成功已触发闩(保证 OnAgentSuccess 至多一次)。Success-fired latch (guarantees OnAgentSuccess fires at most once).
bMergedShellboolfalse手动合并(MergeAgentsMoveToTasks):true = 本记录是休眠合并壳——只持有委托 + 自己的失败累积,其 agent 存于执行体记录中(以 OriginTaskID 标记)。Manual merge (MergeAgentsMoveToTasks): true = this record is a dormant merged shell — it holds delegates + its own fail accumulator; its agents live in the executor's record (tagged with OriginTaskID).
ExecutorTaskIDint320壳的 agent 被并入的执行体任务 ID(仅 bMergedShell 时有效;恢复时 RebuildTasksFromSnapshot 据此把壳重绑到存活的执行体)。The executor task this shell's agents were merged into (valid only when bMergedShell; on restore RebuildTasksFromSnapshot uses it to re-bind the shell to the surviving executor).

EBPTaskSnapshotType UENUM

任务快照类型,重建时选择对应工厂。

Task snapshot kind, selecting the rebuild factory.

值 Value说明 Description
MoveToAgentsMoveTo 任务。AgentsMoveTo task.
ChaseAttackAgentsChaseAttack 任务。AgentsChaseAttack task.

管线角色 Pipeline Role

纯数据声明,无同名 .cpp。消费方:UMassBattleSubsystem::CaptureTaskRecords(经任务的 CaptureSnapshot 填充)与 RebuildTasksFromSnapshot(按 TaskType 调 CreateMoveToTaskFromSnapshot / CreateChaseAttackTaskFromSnapshot);记录随 FEntitySnapshotPayload 跨端传输,由快照注册表驱动序列化。

Pure data declarations with no same-name .cpp. Consumers: UMassBattleSubsystem::CaptureTaskRecords (filled via the tasks' CaptureSnapshot) and RebuildTasksFromSnapshot (dispatches to CreateMoveToTaskFromSnapshot / CreateChaseAttackTaskFromSnapshot by TaskType); records travel cross-peer inside FEntitySnapshotPayload, serialized by the snapshot registry.