UMassBattleFuncLib
Source/MassBattle/Public/FuncLibs/MassBattleFuncLib.h
概述 Overview
MassBattle 对蓝图的主要入口(UBlueprintFunctionLibrary 派生,100+ 静态函数)。绝大多数函数是薄封装:解析世界上下文 → 取对应子系统(UMassBattleAgentSubsystem / UMassBattleHashGridSubsystem / UMassBattleProjectileSubsystem / UMassBattleSubsystem / UMassBattleNetworkSubsystem)→ 转发;子系统不可用时返回「零值」结果(空数组 / false / 无效句柄)而非崩溃。按功能分组:转换连接器(自动 cast)、flag 操作、追踪、投射物生成与弹道解算、伤害与 debuff、模拟配置与暂停、agent 生成器(矩形/圆形 × 模板/配置 × 立即/延迟)、锁步指令与负载编解码、模板注册表、阵型生成、网络辅助与 UniqueID 转换、重叠检测、wildcard 数组工具;另有流场托管层节点(共享集合点流场层的 get-or-create)与调试计数节点(全局实体计数 / 池状态快照)。少数函数自带实现:AppendUnique / RemoveItems(哈希加速的 wildcard 数组操作)、ProcessOverlap_*(并行集合差)、SetAgentTeam / SetAgentSubType(tag 交换 + archetype 迁移)、DelayMassBattleTicks(潜伏动作)。
The primary Blueprint entry point of MassBattle (derived from UBlueprintFunctionLibrary, 100+ static functions). Most are thin wrappers: resolve the world context → fetch the matching subsystem (UMassBattleAgentSubsystem / UMassBattleHashGridSubsystem / UMassBattleProjectileSubsystem / UMassBattleSubsystem / UMassBattleNetworkSubsystem) → forward; when the subsystem is unavailable they return "zero" results (empty arrays / false / invalid handles) rather than crashing. Grouped by purpose: conversion connectors (autocast), flag operations, traces, projectile spawning and trajectory solving, damage and debuffs, sim config and pause, agent spawners (rectangular/circular × template/config × immediate/deferred), lockstep commands and payload codecs, template registry, formation generation, network helpers and UniqueID conversion, overlap detection, wildcard array utilities; plus a managed flow-field layer node (get-or-create of shared rally-point layers) and debug counter nodes (global entity counts / pool-state snapshot). A few functions carry their own implementations: AppendUnique / RemoveItems (hash-accelerated wildcard array ops), ProcessOverlap_* (parallel set difference), SetAgentTeam / SetAgentSubType (tag swap + archetype migration), DelayMassBattleTicks (latent action).
结构体 Structs
GetGlobalEntityCounts 返回的全局计数快照。实体计数覆盖活跃 + 池内(池内实体保留 tag,故按 tag 查询两者皆计);UObject 计数覆盖活跃持有者 + MassBattle 侧池——已释放回引擎池的 FX 组件不在此统计。全部字段 BlueprintReadOnly,默认 0。
Global counter snapshot returned by GetGlobalEntityCounts. Entity counts cover active + pooled (pooled entities keep their tags, so a tag query counts both); UObject counts cover active holders + the MassBattle-side pools — FX components released back to the ENGINE pool are not visible here. All fields are BlueprintReadOnly, default 0.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
TotalEntity | int32 | 0 | 世界全部 Mass 实体(所有类别,空查询计数)。Every Mass entity in the world, all categories (empty-query count). |
Agent / AgentHost | int32 | 0 | agent 实体数(FAgentTag)与 agent 宿主数。Agent entity count (FAgentTag) and agent host count. |
Projectile / ProjectileHost | int32 | 0 | 投射物实体数(FProjectileTag)与投射物宿主数。Projectile entity count (FProjectileTag) and projectile host count. |
Loot / LootHost | int32 | 0 | 战利品实体数(FLootTag)与战利品宿主数。Loot entity count (FLootTag) and loot host count. |
SoundComponent / SoundHost | int32 | 0 | 池内音频组件 + 活跃 Sound 宿主持有的组件数;Sound 宿主数。Pooled UAudioComponents + active ones held by live sound hosts; sound host count. |
FxEntity / FxComponent / FxHost | int32 | 0 | FX 实体数(FBatchedFxTag)、活跃 fx 宿主持有的 Niagara/Cascade 组件数、fx 宿主数。FX entity count (FBatchedFxTag), active Niagara/Cascade components held by live fx hosts, fx host count. |
Actor / ActorHost | int32 | 0 | 活跃 Actor 宿主生成的 AActor 数与 Actor 宿主数。Active spawned AActors held by live actor hosts, and the actor host count. |
GetPoolStates 返回的单池状态。Size = 当前池内休眠数;Spawns / FromPool / Fresh = 本 tick 计数器(每 UMassBattleHostSubsystem::ExecuteTick 重置——须在 tick 后读取)。全部字段 BlueprintReadOnly。
Per-pool state returned by GetPoolStates. Size = dormant entries right now; Spawns / FromPool / Fresh = this tick's counters (reset every UMassBattleHostSubsystem::ExecuteTick — read after the tick). All fields are BlueprintReadOnly.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Name | FString | — | 池显示名("ActorHost"、"FxCPUHost"、"ProjectileEntity" 等)。Pool display name ("ActorHost", "FxCPUHost", "ProjectileEntity", etc.). |
Size | int32 | 0 | 当前池内休眠条目数。Dormant entries in the pool right now. |
Spawns | int32 | 0 | 本 tick 生成总数 = FromPool + Fresh。Total spawns this tick = FromPool + Fresh. |
FromPool | int32 | 0 | 本 tick 从池中复用的数量。Entries reused from the pool this tick. |
Fresh | int32 | 0 | 本 tick 新建的数量。Freshly created entries this tick. |
流场托管层 FlowField Managed Layers
为一组目标坐标获取或创建托管(自动回收)流场层——任务合并的 layer 级孪生:相同目标反复调用复用同一存活层(按确定性目标哈希匹配,-0.0 规范化;复用层还可被本次获取「救活」,冲刷时复查 UserCount);无存活匹配则创建并同步计算。层按 MoveTo 任务引用计数(任务激活时获取、结束时释放),无任务使用时在串行 tick 窗口自动销毁。与 AgentsMoveTo 同锁步门控:必须在 ExecuteNetCommand 内调用,保证层 ID 与内容双端一致——锁步外调用、流场无效 / 目标为空、或任务重建窗口(IsTaskRebuildInProgress)期间调用均记日志并返回无效句柄。返回的句柄须连同同一个 FlowField actor 一起传给 AgentsMoveTo / CreateAgentsMoveToTask(FlowField 模式);任务带 layer 必须带 FlowField,否则被任务拒绝。
Get-or-create a managed (auto-released) flow-field layer for a set of goal locations — the layer-level twin of task merging: repeated calls with the same goals reuse the SAME live layer (matched by a deterministic goal hash with -0.0 canonicalized; a reused pending-destroy layer is revived by the acquire, UserCount re-checked at flush); no live match → create + compute synchronously. The layer is reference-counted per MoveTo task (the task acquires on activate, releases on end) and destroys itself in the serial tick window once no task uses it. Lockstep-gated like AgentsMoveTo: must be called inside ExecuteNetCommand so layer IDs and content stay identical on both peers — off-lockstep calls, a null FlowField / empty goals, or the task-rebuild window (IsTaskRebuildInProgress) log and return an invalid handle. Pass the returned handle into AgentsMoveTo / CreateAgentsMoveToTask (FlowField mode) together with the SAME FlowField actor; a layer handle without a task FlowField is rejected by the task.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | UObject* | 世界上下文。World context. |
FlowField | AFlowField* | 承载层的流场 actor(一个 actor 承载多个集合点层);无效时记 Warning 并返回无效句柄。The flow-field actor hosting the layer (one actor hosts many rally layers); null logs a Warning and returns an invalid handle. |
GoalLocations | const TArray<FVector>& | 目标世界坐标(集合点等);为空时记 Warning 并返回无效句柄。Goal world locations (rally point etc.); empty logs a Warning and returns an invalid handle. |
bUpdateIfGoalsChanged | bool | 为 true 时复用层若目标有位级差异则重算(默认 true)。True: a reused layer whose goals differ bitwise is recomputed (default true). |
LayerName | FName | 可选层名;为 None 时由目标哈希自动派生。Optional layer name; None auto-derives from the goal hash. |
Output
返回获取到的层句柄(FFlowFieldLayerHandle,LayerID 有效);输入非法 / 锁步外 / 重建窗口时返回无效句柄(LayerID = INDEX_NONE)。副作用:命中复用路径时增加该层的用户计数,必要时重算层目标;未命中时创建新托管层(消耗层 ID)并同步计算。
Returns the acquired layer handle (FFlowFieldLayerHandle, valid LayerID); an invalid handle (LayerID = INDEX_NONE) on bad input / off-lockstep / rebuild window. Side effects: on the reuse path increments the layer's user count and recomputes its goals when needed; otherwise creates a new managed layer (consuming a layer ID) and computes it synchronously.
转换连接器 Connector / Adapter Nodes
蓝图自动转换节点(BlueprintAutocast),在伤害/追踪结果与实体句柄/实体数组之间转换。
Blueprint autocast nodes converting between damage/trace results and entity handles/arrays.
把伤害结果列表转实体句柄数组:每个结果的 DamagedEntity 必加;InstigatorEntity 仅在当前 play world 的 UMassAPISubsystem 判定有效时加入。
Converts damage results to an entity-handle array: every DamagedEntity is added; InstigatorEntity is added only when valid per the current play world's UMassAPISubsystem.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
DmgResults | const TArray<FDmgResult>& | 伤害结果列表。Damage result list. |
Output
返回实体句柄数组(受击 + 有效发起者)。
Returns the entity-handle array (damaged + valid instigators).
把追踪结果列表转实体句柄数组:每个结果的 Entity 依序加入。
Converts trace results to an entity-handle array: each result's Entity in order.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
TraceResults | const TArray<FTraceResult>& | 追踪结果列表。Trace result list. |
Output
返回实体句柄数组。
Returns the entity-handle array.
伤害结果 → FEntityArray(仅 DamagedEntity)。
Damage results → FEntityArray (only DamagedEntity).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
DmgResults | const TArray<FDmgResult>& | 伤害结果列表。Damage result list. |
Output
返回 FEntityArray。
Returns the FEntityArray.
追踪结果 → FEntityArray(每个结果的 Entity)。
Trace results → FEntityArray (each result's Entity).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
TraceResults | const TArray<FTraceResult>& | 追踪结果列表。Trace result list. |
Output
返回 FEntityArray。
Returns the FEntityArray.
句柄数组(或单个句柄)包装成 FEntityArray。
Wraps a handle array (or a single handle) into an FEntityArray.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
EntityHandles / EntityHandle | TArray<FEntityHandle> / FEntityHandle | 输入句柄。Input handles. |
Output
返回包装后的 FEntityArray。
Returns the wrapped FEntityArray.
从 UMassBattleAgentComponent 取其实体句柄;组件为空返回无效句柄。
Gets the entity handle from a UMassBattleAgentComponent; returns an invalid handle when the component is null.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
AgentComponent | const UMassBattleAgentComponent* | agent 组件。Agent component. |
Output
返回实体句柄;组件为空时返回无效句柄。
Returns the entity handle, or an invalid handle when the component is null.
EBattleFlags ↔ EEntityFlags 直接转换(两个枚举的 uint8 数值匹配)。已弃用——改用 FName 旗标注册表。
Direct EBattleFlags ↔ EEntityFlags conversion (the two enums share matching uint8 values). Deprecated — use the FName-based flag registry instead.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
BattleFlag / EntityFlag | EBattleFlags / EEntityFlags | 源枚举值。Source enum value. |
Output
返回转换后的枚举值。
Returns the converted enum value.
数组版 flag 转换,逐元素 static_cast。
Array version of the flag conversion, element-wise static_cast.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
BattleFlags / EntityFlags | TArray<EBattleFlags> / TArray<EEntityFlags> | 源枚举数组。Source enum array. |
Output
返回转换后的数组。
Returns the converted array.
把 flag 数组转 FName 数组:经 UMassAPIFlagSettings::FlagRegistry 反向查找,找不到时回退为枚举成员名字符串。Battle 版本跳过 ≥ EBattleFlags_MAX 的条目。
Converts flag arrays to FName arrays: reverse lookup in UMassAPIFlagSettings::FlagRegistry, falling back to the enum member name string. The Battle version skips entries at or beyond EBattleFlags_MAX.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
EntityFlags / BattleFlags | TArray<EEntityFlags> / TArray<EBattleFlags> | 源 flag 数组。Source flag array. |
Output
返回 FName 数组。
Returns the FName array.
委托 FMassBattleQuery::ToEntityQuery() 转换(flag 经注册表反查为 FName 列表;忽略障碍物与优先级)。
Delegates to FMassBattleQuery::ToEntityQuery() (flags reverse-looked-up to FName lists; obstacles and priorities ignored).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
BattleQuery | const FMassBattleQuery& | 战斗查询。Battle query. |
Output
返回 FEntityQuery。
Returns the FEntityQuery.
反方向转换:复制组合列表;FName flag 经注册表正查为 EBattleFlags(未找到或越界 → EBattleFlags_MAX,跳过);ObstacleList 保持默认(空);结果 MarkCacheDirty()。
Reverse conversion: copies the composition lists; FName flags are forward-looked-up to EBattleFlags (not found or out of range → EBattleFlags_MAX, skipped); ObstacleList stays default (empty); the result calls MarkCacheDirty().
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
EntityQuery | const FEntityQuery& | 实体查询。Entity query. |
Output
返回 FMassBattleQuery。
Returns the FMassBattleQuery.
复制 Tags / Fragments / MutableSharedFragments / ConstSharedFragments,BattleFlags 逐元素 static_cast 到 Flags。
Copies Tags / Fragments / MutableSharedFragments / ConstSharedFragments; BattleFlags cast element-wise into Flags.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
BattleTemplate | const FMassBattleTemplate& | 战斗模板。Battle template. |
Output
返回 FEntityTemplate。
Returns the FEntityTemplate.
反方向转换:Flags 中值小于 EBattleFlags_MAX 的条目转回 BattleFlags,越界丢弃。
Reverse conversion: Flags entries below EBattleFlags_MAX convert back to BattleFlags; out-of-range entries are dropped.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
EntityTemplate | const FEntityTemplate& | 实体模板。Entity template. |
Output
返回 FMassBattleTemplate。
Returns the FMassBattleTemplate.
数组工具 Array Utilities
把 SourceArray 中目标数组不存在的元素追加到 TargetArray(按 Identical 判定重复)。快速路径:元素类型支持哈希(CPF_HasGetValueTypeHash,含 FEntityHandle)时构建哈希 → 索引多重映射,把 O(N×M) 线性扫描降到期望 O(N+M);慢速回退:不可哈希类型走 O(N×M) Identical 扫描。
Appends elements of SourceArray not already present in the target (duplicates judged by Identical). Fast path: when the element type supports hashing (CPF_HasGetValueTypeHash, including FEntityHandle), builds a hash → index multimap, dropping the O(N×M) linear scan to expected O(N+M); slow fallback: non-hashable types use the O(N×M) Identical scan.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
TargetArray | TArray<int32>(占位,运行时为任意类型)TArray<int32> (placeholder; arbitrary type at runtime) | 目标数组,原地修改。Target array, modified in place. |
SourceArray | TArray<int32>(占位,类型跟随 TargetArray)TArray<int32> (placeholder; type follows TargetArray) | 源数组。Source array. |
Output
无返回值。副作用:目标数组获得去重追加的元素。
No return value. Side effect: the target array gains de-duplicated appended elements.
从 TargetArray 移除 ItemsToRemove 中出现的所有元素。快速路径:哈希标记 + 单趟原地稳定压缩(CopyCompleteValue 处理复杂类型);慢速回退:从尾到头逐元素 O(N×M) 扫描。
Removes all elements of TargetArray that appear in ItemsToRemove. Fast path: hash marking + a single in-place stable compaction walk (CopyCompleteValue handles complex types); slow fallback: tail-to-head O(N×M) scan.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
TargetArray | TArray<int32>(占位)TArray<int32> (placeholder) | 目标数组,原地修改。Target array, modified in place. |
ItemsToRemove | TArray<int32>(占位)TArray<int32> (placeholder) | 要移除的元素列表。Elements to remove. |
Output
无返回值。副作用:目标数组失去匹配元素(顺序保持)。
No return value. Side effect: matching elements removed from the target (order preserved).
按闭区间 [StartIndex, EndIndex](含两端)裁切 wildcard 数组,输出类型跟随输入。非法范围(负数、倒置或越界)输出 Error 日志与空数组。逐字节拷贝——两个数组共享同一元素类型与布局。
Trims a wildcard array by the closed range [StartIndex, EndIndex] (inclusive); the output type follows the input. Invalid ranges (negative, inverted, or out of bounds) log an Error and output an empty array. Byte-wise copy — both arrays share the same element type and layout.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
TargetArray | TArray<int32>(占位)TArray<int32> (placeholder) | 输入数组。Input array. |
StartIndex / EndIndex | int32 | 闭区间边界。Closed-range bounds. |
OutArray | TArray<int32>&(占位)TArray<int32>& (placeholder) | 输出数组。Output array. |
Output
无返回值。副作用:填充 OutArray;非法范围输出空数组并记 Error 日志。
No return value. Side effect: fills OutArray; invalid ranges yield an empty array plus an Error log.
Flag 操作 Battle Flag Operations
已弃用的 flag 三件套:枚举转换后转发到 UMassAPIFuncLib::HasFlag_Entity / SetFlag_Entity / ClearFlag_Entity。FlagToTest >= EBattleFlags_MAX 时直接返回 false(不调用 API)。改用 SetMassFlag / ClearMassFlag 节点。
Deprecated flag trio: converts the enum and forwards to UMassAPIFuncLib::HasFlag_Entity / SetFlag_Entity / ClearFlag_Entity. Returns false without calling the API when FlagToTest >= EBattleFlags_MAX. Use the SetMassFlag / ClearMassFlag nodes instead.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
EntityHandle | const FEntityHandle& | 目标实体。Target entity. |
FlagToTest/Set/Clear | EBattleFlags | 操作的目标 flag。Target flag. |
Output
Has 返回是否置位;Set/Clear 返回 API 调用结果;越界 flag 返回 false。
Has returns the flag state; Set/Clear return the API result; out-of-range flags return false.
选中 agent,转发到 UMassBattleAgentSubsystem::SelectAgents。网络模式下为端侧本地操作:锁步外执行(即时本地反馈——无服务器往返)、设置本地 Selected/BeingSelect flag(快照恢复时剥离、resync 后由 LocalVisualRegistry 重放)、生成本地视觉宿主(UID=-1、无 FNetworkTag——永不进快照/hash/网络池)。权威游戏效果(移动/攻击等任务)请把选中的 agent UID 走锁步命令路径(ExecuteNetCommand)发送。
Selects agents, forwarded to UMassBattleAgentSubsystem::SelectAgents. In networked mode this is a peer-local operation: runs off-lockstep (instant local feedback — no server round-trip), sets the local-only Selected/BeingSelect flags (stripped from snapshot restore, replayed from LocalVisualRegistry after resync), and spawns local-only visual hosts (UID=-1, no FNetworkTag — never in snapshot/hash/network pools). For authoritative gameplay effects (move/attack tasks), send the selected agent UIDs through the lockstep command path (ExecuteNetCommand).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Agents | const TArray<FEntityHandle>& | 要选中的实体。Entities to select. |
State | ESelectState | 选中状态(默认 Selected)。Selection state (default Selected). |
Query | const FMassBattleQuery& | 附加过滤查询(默认空 = 不过滤)。Extra filter query (default empty = no filter). |
Output
无返回值。副作用:设置选中 flag 并生成本地视觉宿主;子系统不可用时无操作。
No return value. Side effects: sets selection flags and spawns local visual hosts; no-op when the subsystem is unavailable.
取消选中,转发到 UMassBattleAgentSubsystem::DeselectAgents;语义与 SelectAgents 相同(端侧本地)。
Deselects agents, forwarded to UMassBattleAgentSubsystem::DeselectAgents; semantics match SelectAgents (peer-local).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Agents | const TArray<FEntityHandle>& | 要取消选中的实体。Entities to deselect. |
State | ESelectState | 取消的状态(默认 All = 全部状态)。State to clear (default All). |
Query | const FMassBattleQuery& | 附加过滤查询。Extra filter query. |
Output
无返回值。副作用:清除选中 flag 并回收本地视觉宿主。
No return value. Side effects: clears selection flags and reclaims local visual hosts.
Agent 查询与设置 Agent Get / Set
以下函数全部为 UMassBattleAgentSubsystem 的薄封装:子系统不可用时返回零值(ZeroVector / Identity / 无操作),可用时读取/写入对应 fragment。
All of the following are thin wrappers over UMassBattleAgentSubsystem: zero values returned (ZeroVector / Identity / no-op) when the subsystem is unavailable, fragment reads/writes otherwise.
为实体播放指定索引的动作蒙太奇(转发到 Agent 子系统):把 FAnimating fragment 切换到 Montage 状态。AnimIndex 为 255(INVALID)时从共享 OtherAnimData 随机选槽(RNG 在模拟侧消耗,保持确定性并进入网络快照)。实体缺少 FAnimating 时忽略。
Plays the montage at the given animation index on the entity (forwarded to the Agent subsystem): switches the FAnimating fragment to the Montage state. AnimIndex 255 (INVALID) picks a random slot from the shared OtherAnimData (the RNG is consumed on the sim side so it stays deterministic and enters the network snapshot). Ignored when the entity lacks FAnimating.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
EntityHandle | const FEntityHandle& | 目标实体。Target entity. |
AnimIndex | int32 | 动画索引。Animation index. |
PlayRate | float | 播放速率(默认 1)。Play rate (default 1). |
bLooping | bool | 是否循环(默认 false)。Whether looping (default false). |
Output
无返回值。
No return value.
把 agent / actor / Niagara 系统 / Cascade 粒子附着到目标实体(被附着对象的视觉以 RelativeTransform 跟随 AttachToEntity;经 FAgentHostConfig / FActorSpawnConfig / FFxConfig 配置宿主生命周期与视觉设置),转发到 Agent 子系统。网络语义:AttachAgentToAgent 的宿主是模拟实体——必须在锁步命令路径内调用(锁步外生成会导致 hash 发散);AttachActorToAgent 锁步外调用安全(actor 宿主纯本地生成,UID=-1、无 FNetworkTag,并登记供 resync 重链);AttachNiagara/Cascade 自动分流——锁步窗口内生成同步 FX 宿主,锁步外(BP 直调)纯本地,FX 永不破坏确定性。
Attaches an agent / actor / Niagara system / Cascade particle to the target entity (the attached visual follows AttachToEntity at RelativeTransform; host lifetime and visual settings via FAgentHostConfig / FActorSpawnConfig / FFxConfig), forwarded to the Agent subsystem. Network semantics: the agent host of AttachAgentToAgent is a simulation entity — it MUST be called inside the lockstep command path (an off-lockstep agent host would diverge the hash); AttachActorToAgent is safe off-lockstep (the actor host spawns local-only, UID=-1, no FNetworkTag, registered for resync re-link); AttachNiagara/Cascade auto-split — a synchronized FX host inside the lockstep window, local-only off-lockstep (BP direct call), so FX never corrupts determinism.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
AgentToAttach / ActorToAttach / NiagaraAsset / CascadeAsset | FEntityHandle / AActor* / UNiagaraSystem* / UParticleSystem* | 被附着的对象。Object being attached. |
AttachToEntity | const FEntityHandle& | 宿主实体。Host entity. |
RelativeTransform | const FTransform& | 相对宿主变换。Transform relative to the host. |
Config | const FAgentHostConfig& 等const FAgentHostConfig& etc. | 宿主配置(默认构造)。Host config (default-constructed). |
Output
无返回值。
No return value.
读取实体位置(FLocating):当前 / 上一帧 / 初始三个位置同时输出。
Reads the entity location (FLocating): current / previous / initial locations out together.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
EntityHandle | const FEntityHandle& | 目标实体。Target entity. |
Location / PreviousLocation / InitialLocation | FVector& | 输出位置。Output locations. |
Output
无返回值;三个输出参数被填充。
No return value; the three out-params are filled.
返回多个实体的平均位置;子系统不可用返回 ZeroVector。
Returns the average location of the entities; ZeroVector when the subsystem is unavailable.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
EntityHandles | const TArray<FEntityHandle>& | 实体列表。Entity list. |
Output
返回平均位置。
Returns the average location.
读取实体旋转:欧拉角 / 四元数 / 前向方向三个输出。
Reads the entity rotation: rotator / quat / forward direction outputs.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / EntityHandle | const UObject* / const FEntityHandle& | 上下文与实体。Context and entity. |
Rotation / RotationQuat / Direction | FRotator& / FQuat& / FVector& | 输出旋转。Rotation outputs. |
Output
无返回值;三个输出被填充。
No return value; the three outputs are filled.
读取实体缩放:标量 / 渲染缩放 / 抖动乘数三个输出。
Reads the entity scale: scalar / render scale / jiggle multiplier outputs.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / EntityHandle | const UObject* / const FEntityHandle& | 上下文与实体。Context and entity. |
Scale / RenderScale / JiggleMultiplier | float& / FVector& / FVector& | 缩放输出。Scale outputs. |
Output
无返回值;三个输出被填充。
No return value; the three outputs are filled.
读取实体完整变换;子系统不可用返回 Identity。
Reads the entity's full transform; Identity when the subsystem is unavailable.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / EntityHandle | const UObject* / const FEntityHandle& | 上下文与实体。Context and entity. |
Output
返回变换。
Returns the transform.
读取实体的前向 / 上 / 右方向向量与速度;子系统不可用返回 ZeroVector。
Reads the entity's forward / up / right vectors and velocity; ZeroVector when the subsystem is unavailable.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / EntityHandle | const UObject* / const FEntityHandle& | 上下文与实体。Context and entity. |
Output
返回对应向量。
Returns the vector.
写入实体的位置 / 旋转 / 缩放 / 线速度 / 角速度(转发到 Agent 子系统,写入对应 fragment)。
Writes the entity's location / rotation / scale / linear velocity / angular velocity (forwarded to the Agent subsystem, writing the matching fragments).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / EntityHandle | const UObject* / const FEntityHandle& | 上下文与实体。Context and entity. |
NewLocation / NewRotation / NewScale / NewVelocity / NewAngularVelocity | FVector / FRotator / float / FVector / float | 新值。New value. |
Output
无返回值。副作用:修改实体 fragment 状态。
No return value. Side effect: mutates entity fragment state.
设置 agent 队伍:更新 FTeam.index 并交换队伍 tag(FTeam0Tag..FTeam255Tag,触发 archetype 迁移),同步 PreviousIndex。失败(MA 缺失 / 句柄无效 / 索引越界 [0,255] / 缺 FTeam fragment)记录 Warning 并返回,不触发 OnFinished;状态已一致时直接触发 OnFinished 完成(无迁移)。bDeferred 为 true 时把整个操作经命令缓冲延迟到 flush 执行(flush 时重新校验)。
Sets the agent's team: updates FTeam.index and swaps the team tag (FTeam0Tag..FTeam255Tag, triggering archetype migration), keeping PreviousIndex in sync. On failure (MA missing / invalid handle / index out of range [0,255] / missing FTeam fragment) logs a Warning and returns without firing OnFinished; when the state is already consistent, fires OnFinished immediately (no migration). With bDeferred true, the whole operation is queued via the command buffer and runs at flush (validations re-run at flush).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
AgentHandle | const FEntityHandle& | agent 实体句柄。Agent entity handle. |
TeamIndex | int32 | 新队伍索引,合法范围 [0, 255]。New team index, valid range [0, 255]. |
bDeferred | const bool | true 时经命令缓冲延迟执行。Queues via the command buffer when true. |
OnFinished | const FOnMassDeferredFinished& | 变更完成时回调句柄。Fired with the handle when the change completes. |
Output
无返回值。副作用:更新 FTeam、交换 tag(archetype 迁移)、触发 OnFinished;失败时记 Warning 且不触发回调。
No return value. Side effects: updates FTeam, swaps the tag (archetype migration), fires OnFinished; on failure logs a Warning and skips the callback.
设置 agent 子类别:更新 FSubType.Index 并交换子类别 tag(FSubType0Tag..FSubType255Tag,触发 archetype 迁移)。失败与延迟语义与 SetAgentTeam 完全一致。
Sets the agent's subtype: updates FSubType.Index and swaps the subtype tag (FSubType0Tag..FSubType255Tag, triggering archetype migration). Failure and deferred semantics identical to SetAgentTeam.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
AgentHandle | const FEntityHandle& | agent 实体句柄。Agent entity handle. |
SubTypeIndex | int32 | 新子类别索引,合法范围 [0, 255]。New subtype index, valid range [0, 255]. |
bDeferred | const bool | true 时经命令缓冲延迟执行。Queues via the command buffer when true. |
OnFinished | const FOnMassDeferredFinished& | 变更完成时回调句柄。Fired with the handle when the change completes. |
Output
无返回值。副作用:更新 FSubType、交换 tag(archetype 迁移)、触发 OnFinished;失败时记 Warning 且不触发回调。
No return value. Side effects: updates FSubType, swaps the tag (archetype migration), fires OnFinished; on failure logs a Warning and skips the callback.
追踪 Trace Nodes
九个追踪节点(球 / 球扫掠 / 扇形 / 盒 / 盒扫掠 / 胶囊 / 胶囊扫掠 / 视锥 / 锥体)+ 排序工具,全部转发到 UMassBattleHashGridSubsystem。公共参数语义:KeepCount(-1 = 不限;0 = 无;NearToFar/FarToNear 排序时单趟堆保留最优 N 个)、bCheckObstacle + CheckOrigin/CheckRadius(视线遮挡排除,需 Query.ObstacleList;CheckRadius > 0 沿射线做球体 sweep,否则用线检测)、SortMode + SortOrigin(结果排序,距离相同按 UniqueID 决胜)、IgnoreEntities(排除集)、Query(组合/flag 过滤)、DrawDebugConfig(仅编辑器生效的调试绘制)。形状半径均另加 agent 碰撞体半径(胶囊体感知)。
Nine trace nodes (sphere / sphere sweep / sector / box / box sweep / capsule / capsule sweep / view frustum / cone) plus a sort utility, all forwarded to UMassBattleHashGridSubsystem. Shared parameter semantics: KeepCount (-1 = unlimited; 0 = none; with NearToFar/FarToNear a one-pass heap keeps the N best), bCheckObstacle + CheckOrigin/CheckRadius (line-of-sight exclusion via visibility rays, needs Query.ObstacleList; CheckRadius > 0 sweeps a sphere along the ray, otherwise a plain line trace), SortMode + SortOrigin (result ordering, distance ties break by UniqueID), IgnoreEntities (exclusion set), Query (composition/flag filter), DrawDebugConfig (editor-only debug drawing). Shape radii have the agent collider radius added (capsule-aware).
以 Origin 为球心、Radius 为半径的球形索敌(区域内 agent 集合)。
Sphere targeting centered at Origin with Radius (the set of agents inside the volume).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出:是否命中与结果列表。Outputs: hit flag and result list. |
Origin | const FVector& | 球心(默认 Zero)。Sphere center (default Zero). |
Radius | const float | 球半径(默认 300)。Sphere radius (default 300). |
KeepCount | int32 | 最多保留的结果数;-1 = 不限(默认),0 = 无。Max results to keep; -1 = unlimited (default), 0 = none. |
bCheckObstacle / CheckOrigin / CheckRadius | bool / FVector / float | 额外障碍检查(默认关)。Extra obstacle check (default off). |
SortMode / SortOrigin | ESortMode / FVector | 排序模式与参考点(默认 NearToFar / Zero)。Sort mode and reference (default NearToFar / Zero). |
IgnoreEntities | const FEntityArray& | 排除实体。Entities to ignore. |
Query | const FMassBattleQuery& | 过滤查询。Filter query. |
DrawDebugConfig | const FTraceDrawDebugConfig& | 调试绘制配置。Debug-draw config. |
Output
无返回值;填充 Hit 与 Results。子系统不可用时 Hit=false、Results 为空。
No return value; fills Hit and Results. Hit=false with empty Results when the subsystem is unavailable.
从 Start 到 End 的球体扫掠索敌(扫掠路径上的 agent 集合)。
Sphere sweep targeting from Start to End (agents along the swept path).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
Start / End | const FVector& | 扫掠起点/终点。Sweep start/end. |
Radius | const float | 球半径(默认 300)。Sphere radius (default 300). |
| 其余参数 | 同上 | 与 SphereTrace 相同(KeepCount / 障碍检查 / 排序 / 忽略 / 查询 / 调试)。Same as SphereTrace (KeepCount / obstacle / sort / ignore / query / debug). |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
扇形索敌:Origin + Direction 定向、Radius 半径、Height 高度、Angle 张开角(度,默认 360 = 全向)。
Sector targeting: Origin + Direction orientation, Radius, Height, and Angle opening angle in degrees (default 360 = omnidirectional).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
Origin | const FVector& | 扇形原点。Sector origin. |
Radius / Height | const float | 半径与高度(默认 300)。Radius and height (default 300). |
Direction | const FVector& | 朝向(默认 Forward)。Direction (default Forward). |
Angle | const float | 张开角度(度,默认 360)。Opening angle in degrees (default 360). |
| 其余参数 | 同上 | 与 SphereTrace 相同。Same as SphereTrace. |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
盒形索敌(Trace 静态盒 / Sweep 扫掠盒):Range3D 半范围 + Orientation 朝向。
Box targeting (static box / swept box): Range3D half-extents + Orientation.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
Origin(Trace) / Start,End(Sweep) | const FVector& | 盒位置或扫掠端点。Box origin or sweep endpoints. |
Range3D | const FVector& | 半范围。Half-extents. |
Orientation | const FRotator& | 朝向(默认 Zero)。Orientation (default Zero). |
| 其余参数 | 同上 | 与 SphereTrace 相同。Same as SphereTrace. |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
胶囊索敌(Trace 静态胶囊 / Sweep 扫掠胶囊):查询以 Origin 为中心、半径 Radius、轴杆半高 HalfHeight、轴向沿 Orientation 朝上的胶囊(Trace),或该胶囊自 Start 扫掠至 End 覆盖的体积(Sweep)。命中判定为精确测试:agent 碰撞体胶囊与查询胶囊(静态:两轴段距离 ≤ Radius + agent 碰撞体半径;扫掠:胶囊轴与扫掠段的精确闵可夫斯基和,再膨胀 agent 碰撞体半径)相交。零长度扫掠(Start == End)退化为静态胶囊检测。用于竖立光柱、站桩 AoE 体积、竖向光束检测(Trace)与冲刺、冲锋、大幅竖向挥砍走廊(Sweep)。
Capsule targeting (Trace = static capsule / Sweep = swept capsule): queries a capsule centered at Origin with radius Radius, shaft half-height HalfHeight, axis along Orientation's up (Trace), or the volume covered by sweeping that capsule from Start to End (Sweep). Hits use an exact test: the agent's collider capsule must intersect the query capsule (Trace: axis-segment distance ≤ Radius + agent collider radius; Sweep: the exact Minkowski sum of the capsule axis and the sweep segment, inflated by the agent's collider radius). Zero-length sweeps (Start == End) degenerate to the static capsule test. Use Trace for upright light pillars, standing AoE volumes and vertical beam checks; Sweep for lunge, charge and wide vertical swing corridors.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
Origin(Trace) / Start,End(Sweep) | const FVector& | 胶囊中心或扫掠端点。Capsule center or sweep endpoints. |
Radius | const float | 胶囊半径(默认 300;另加 agent 碰撞体半径)。Capsule radius (default 300; agent collider radius added). |
HalfHeight | const float | 沿 Orientation 朝向上的轴杆半高(默认 150)。Shaft half-height along Orientation's up (default 150). |
Orientation | const FRotator& | 胶囊轴向(up 即胶囊轴,默认 ZeroRotator)。Capsule axis orientation (up = capsule axis, default ZeroRotator). |
| 其余参数 | 同上 | 与 SphereTrace 相同(KeepCount / 障碍检查 / 排序 / 忽略 / 查询 / 调试)。Same as SphereTrace (KeepCount / obstacle / sort / ignore / query / debug). |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
视野追踪:输入 FViewTracePoints(起始位置 + 选择点集),对点集构建视野体积索敌。
View trace: takes FViewTracePoints (start location + selection points) and targets agents inside the view volume built from the points.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
TracePoints | const FViewTracePoints& | 视野追踪点集。View-trace points. |
| 其余参数 | 同上 | 与 SphereTrace 相同(无 Origin/Radius)。Same as SphereTrace (no Origin/Radius). |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
锥形索敌:Origin + Direction、Length 长度、Angle 半角(度)。
Cone targeting: Origin + Direction, Length, and Angle half-angle in degrees.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Hit / Results | bool& / TArray<FTraceResult>& | 输出。Outputs. |
Origin / Direction | const FVector& | 锥顶与朝向。Apex and direction. |
Length | float | 锥长(默认 1000)。Cone length (default 1000). |
Angle | float | 半角(度,默认 45)。Half-angle in degrees (default 45). |
| 其余参数 | 同上 | 与 SphereTrace 相同。Same as SphereTrace. |
Output
无返回值;填充 Hit 与 Results。
No return value; fills Hit and Results.
按 SortMode 与 SortOrigin 原地排序实体句柄数组(转发到 HashGrid 子系统)。
Sorts the entity-handle array in place by SortMode and SortOrigin (forwarded to the HashGrid subsystem).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Entities | TArray<FEntityHandle>& | 要排序的数组(原地修改)。Array to sort (modified in place). |
SortMode | ESortMode | 排序模式(默认 NearToFar)。Sort mode (default NearToFar). |
SortOrigin | const FVector& | 排序参考点。Sort reference point. |
Output
无返回值。副作用:原地重排 Entities。
No return value. Side effect: reorders Entities in place.
特效与投射物 FX & Projectiles
在指定位置生成合批视觉特效("Batched" 指以 SubType 为键的 Niagara 合批渲染系统)。AttachToEntity 有效时附着到实体(覆盖 SpawnLocation/Rotation);OwnerEntity 为可选归属实体。网络模式下锁步外的 BP 调用会以纯本地方式生成 FX 宿主(视觉不破坏确定性)并登记供 resync 重链。
Spawns batched visual effects at the given location ("Batched" refers to the batched rendering system keyed by SubType for Niagara batching). When AttachToEntity is valid the FX attaches to it (overriding SpawnLocation/Rotation); OwnerEntity is an optional owning entity. In networked mode an off-lockstep BP call spawns the FX host local-only (visuals never corrupt determinism) and registers it for resync re-link.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
FxConfig | const FFxConfig& | 特效配置(资产 / SubType 等)。FX config (asset / SubType, etc.). |
SpawnLocation / SpawnRotation | const FVector& / const FRotator& | 生成位置/旋转。Spawn location/rotation. |
OwnerEntity / AttachToEntity | const FEntityHandle& | 归属实体 / 附着实体。Owner / attach entity. |
Output
无返回值。
No return value.
四种运动模式的投射物生成(转发到 UMassBattleProjectileSubsystem):Static(停留在 FromPoint 不飞行——地雷 / 陷阱 / 炮台锚点)、Interped(位置随时间由 FromPoint 插值至 ToPoint/ToTarget,并由配置的逐轴偏移曲线塑形)、Ballistic(按 FromPitch 或 FromSpeed 模式解算发射初速、利用 TargetVelocity 做预测迭代,使抛物线落在目标)、Tracking(沿 Direction 发射后以速度 / 前向加速度 / 横向转向加速度追踪 ToTarget,可选移动预测)。资产的 MovementMode 必须与节点模式匹配,否则生成失败。FromPoint 为发射点,Instigator 为发起者,IgnoreEntities 为碰撞排除集。网络模式下锁步外调用会被拦截——请走锁步命令路径生成。
Projectile spawning in four motion modes (forwarded to UMassBattleProjectileSubsystem): Static (stays at FromPoint with no flight — mine / trap / turret anchor), Interped (position interpolated from FromPoint toward ToPoint/ToTarget over time, shaped by the config's per-axis offset curves), Ballistic (launch velocity solved in FromPitch or FromSpeed mode with TargetVelocity prediction iterations so the free-fall arc lands on the target), Tracking (launches along Direction, then homes in on ToTarget with speed / forward acceleration / lateral turn acceleration and optional movement prediction). The asset's MovementMode must match the node's mode or the spawn fails. FromPoint is the launch point, Instigator the launcher, IgnoreEntities the collision exclusion set. In networked mode off-lockstep calls are blocked — spawn through the lockstep command path.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Successful / ProjectileHandle | bool& / FEntityHandle& | 输出:是否成功与新实体句柄。Outputs: success and the new entity handle. |
ProjectileConfigDataAsset | UMassBattleProjectileConfigDataAsset* | 投射物配置资产。Projectile config asset. |
Multipliers | FProjectileMultipliers | 投射物乘数。Projectile multipliers. |
FromPoint | FVector | 发射点。Launch point. |
ToPoint / ToTarget / TargetVelocity / Direction | 按模式 | 模式相关目标参数。Mode-specific target params. |
Instigator / IgnoreEntities | FEntityHandle / FEntityArray | 发起者与排除集。Instigator and exclusion set. |
Output
无返回值;填充 Successful 与 ProjectileHandle(失败或子系统缺失时 Successful=false)。
No return value; fills Successful and ProjectileHandle (Successful=false on failure or missing subsystem).
弹道速度解算(转发到 Projectile 子系统;1.19.20 起 C++/BP 节点名首字母改为小写 solve…):给定发射点 / 目标点 / 重力,由俯仰角(PitchAngle 叠加到直视仰角,钳制 ±89.9°)或固定初速度(可带 bFavorHighArc 选高抛解,垂直特例直接处理)解出 LaunchVelocity——无实数解 / 判别式为负时 Succeed=false 且不写 LaunchVelocity;WithPrediction 版本每轮迭代重新瞄准 ToPoint + TargetVelocity × 飞行时间 补偿目标运动,任一轮无解即失败。
Trajectory solving (forwarded to the Projectile subsystem; as of 1.19.20 the C++/BP node names start lowercase, solve…): given launch point / target / gravity, solves LaunchVelocity from a pitch angle (PitchAngle added to the look-at pitch, clamped to ±89.9°) or a fixed speed (with bFavorHighArc selecting the high-arc solution; vertical special cases handled directly) — when no real solution exists / the discriminant is negative, Succeed=false and LaunchVelocity is left untouched; the WithPrediction variants re-aim at ToPoint + TargetVelocity × flight time each iteration to compensate target motion, failing when any iteration has no solution.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Succeed / LaunchVelocity | bool& / FVector& | 输出:是否可解与初速度。Outputs: solvable flag and launch velocity. |
FromPoint / ToPoint | FVector | 发射/目标点。Launch/target points. |
Gravity | float | 重力。Gravity. |
PitchAngle / Speed / bFavorHighArc | float / float / bool | 求解约束。Solving constraints. |
TargetVelocity / Iterations | FVector / int32 | 预测版本:目标速度与迭代次数。Prediction variants: target velocity and iterations. |
Output
无返回值;填充 Succeed 与 LaunchVelocity。
No return value; fills Succeed and LaunchVelocity.
四种模式的模板版投射物生成:以 TemplateData(预构建的 FEntityTemplateData,来自 MakeProjectileTemplateFromDataAsset 或注册表)替代配置资产。
Template-based projectile spawning in the four modes: replaces the config asset with a prebuilt TemplateData (from MakeProjectileTemplateFromDataAsset or the registry).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Successful / ProjectileHandle | bool& / FEntityHandle& | 输出。Outputs. |
TemplateData | const FEntityTemplateData& | 实体模板数据。Entity template data. |
| 其余参数 | 同上 | 与配置资产版相同。Same as the config-asset versions. |
Output
无返回值;填充 Successful 与 ProjectileHandle。
No return value; fills Successful and ProjectileHandle.
伤害与 Debuff Damage & Debuff
对 Entities 列表施加点伤害 + debuff(转发到 UMassBattleSubsystem):DmgInstigator(引发者)/ DmgCauser(致害者)/ HitFromLocation(击打方向来源)与 FDamage_Point / FDebuff_Point 配置;结果写入 DamageResults。
Applies point damage + debuff to the Entities list (forwarded to UMassBattleSubsystem): DmgInstigator / DmgCauser / HitFromLocation plus FDamage_Point / FDebuff_Point configs; results go into DamageResults.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DamageResults | TArray<FDmgResult>& | 输出:伤害结果列表。Output: damage result list. |
Entities / IgnoreEntities | const FEntityArray& | 目标列表与排除列表。Target list and exclusion list. |
DmgInstigator / DmgCauser | const FEntityHandle | 引发者与致害者。Instigator and causer. |
HitFromLocation | const FVector& | 击打方向来源位置。Hit-direction source location. |
Damage / Debuff | const FDamage_Point& / const FDebuff_Point& | 伤害与 debuff 配置。Damage and debuff configs. |
Output
无返回值;填充 DamageResults。
No return value; fills DamageResults.
以 Origin 为球心的范围伤害 + debuff:FDamage_Radial / FDebuff_Radial 内含半径、衰减等;KeepCount 限制结果数量。
Radial damage + debuff centered at Origin: FDamage_Radial / FDebuff_Radial carry radius, falloff, etc.; KeepCount limits the result count.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DamageResults | TArray<FDmgResult>& | 输出结果。Output results. |
KeepCount | int32 | 保留数量(-1 = 全部)。Keep count (-1 = all). |
Origin / IgnoreEntities | const FVector& / const FEntityArray& | 爆炸中心与排除集。Explosion center and exclusion set. |
| 其余参数 | 同上 | 与 Point 版相同(伤害类型为 FDamage_Radial / FDebuff_Radial)。Same as the Point version (types FDamage_Radial / FDebuff_Radial). |
Output
无返回值;填充 DamageResults。
No return value; fills DamageResults.
线段扫掠伤害 + debuff:StartLocation → EndLocation,FDamage_Beam / FDebuff_Beam。
Beam (segment sweep) damage + debuff: StartLocation → EndLocation with FDamage_Beam / FDebuff_Beam.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DamageResults | TArray<FDmgResult>& | 输出结果。Output results. |
KeepCount | int32 | 保留数量。Keep count. |
StartLocation / EndLocation | const FVector& | 光束端点。Beam endpoints. |
| 其余参数 | 同上 | 与 Point 版相同(类型 FDamage_Beam / FDebuff_Beam)。Same as the Point version (types FDamage_Beam / FDebuff_Beam). |
Output
无返回值;填充 DamageResults。
No return value; fills DamageResults.
模拟配置与游戏控制 Sim Config & Game Control
清空已注册资产缓存(转发到 UMassBattleSubsystem)。
Clears the registered-asset cache (forwarded to UMassBattleSubsystem).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
无返回值。
No return value.
已弃用——用 SetSimConfig 替代。设置步长 / 安全步长 / 帧分摊 / 确定性,转发到 UMassBattleSubsystem::SetTimingConfig。
Deprecated — use SetSimConfig instead. Sets step time / safe step time / frame spreading / determinism, forwarded to UMassBattleSubsystem::SetTimingConfig.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
InStepTime / InSafeStepTime | float | 模拟步长与安全步长(秒)。Sim step time and safe step time (seconds). |
bInFrameSpreading / bInDeterministic | bool | 帧分摊与确定性开关。Frame-spreading and determinism toggles. |
Output
无返回值。副作用:修改模拟配置。
No return value. Side effect: mutates the sim config.
设置模拟配置(转发到 UMassBattleSubsystem::SetSimConfig):步长 / 安全步长 / 帧分摊 / 确定性。请在生成 agent 之前设置——游戏中途修改影响后续 tick。定点数学开关(MoveProcessorFP)属 WIP 功能,不在此暴露——由子系统 bUseFixPointMath 属性控制(仅 C++,对 BP 隐藏);旧版此处的 bInFixPointMath 参数已移除。
Sets the sim config (forwarded to UMassBattleSubsystem::SetSimConfig): step time / safe step time / frame spreading / determinism. Apply before spawning agents — changing mid-game affects subsequent ticks. The fixed-point math switch (MoveProcessorFP) is a WIP feature and is NOT exposed here — it is controlled by the subsystem's bUseFixPointMath property (C++ only, hidden from BP); the former bInFixPointMath parameter has been removed.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
InStepTime / InSafeStepTime | float | 目标模拟步长与每步安全上限(秒)。Target sim step time and per-step safety bound (seconds). |
bInFrameSpreading / bInDeterministic | bool | 帧分摊与确定性(固定种子、定序)开关。Frame-spreading and deterministic (seeded, ordered) toggles. |
Output
无返回值。副作用:修改模拟配置。
No return value. Side effect: mutates the sim config.
暂停 / 恢复游戏逻辑 tick(转发到 UMassBattleSubsystem::PauseGame / ResumeGame)。暂停期间逻辑 tick 停止推进——agent、投射物与锁步指令冻结;引擎时间不暂停。恢复时逻辑 tick 从冻结处继续;未处于用户暂停时 Resume 为无操作(不会清除网络失步恢复类暂停)。
Pauses / resumes the game logic tick (forwarded to UMassBattleSubsystem::PauseGame / ResumeGame). While paused the logic tick stops advancing — agents, projectiles and lockstep commands freeze; engine time is not paused. Resuming advances the logic tick from where it froze; Resume is a no-op when the game was not user-paused (does not clear network-desync recovery pauses).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
无返回值。副作用:冻结/解冻逻辑 tick。
No return value. Side effect: freezes/unfreezes the logic tick.
综合暂停判定——只要逻辑 tick 冻结不推进即返回 true(用户暂停 / 网络失步恢复 / 等待服务器追帧);子系统缺失返回 false。
Composite pause check — true whenever the logic tick is frozen for ANY reason (user pause, network desync recovery pause, server catch-up wait); false when the subsystem is missing.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
返回是否处于综合暂停。
Returns whether the game is composite-paused.
注入式手动 resync 触发——强制本地/服务器快照 resync + 快进(FF),绕过自然失步检测,用于测试/调试(转发到 UMassBattleNetworkSubsystem::TriggerLocalResync / TriggerServerResync)。
Injection-style manual resync triggers — force a local/server snapshot resync + fast-forward, bypassing natural desync detection, for testing/debugging (forwarded to UMassBattleNetworkSubsystem::TriggerLocalResync / TriggerServerResync).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
Local 返回是否成功触发;Server 无返回值。副作用:发起一次快照 resync。
Local returns whether the trigger succeeded; Server has no return value. Side effect: initiates a snapshot resync.
设置确定性校验的目标 tick 列表与日志开关(位置 / 旋转 / 追踪结果),用于对比双端状态。
Sets the determinism-verification target tick list and log toggles (location / rotation / trace result) for cross-peer state comparison.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
TargetTicks | const TArray<int32>& | 要校验的 tick 列表。Ticks to verify. |
bLogLocation / bLogRotation / bLogTraceResult | bool | 各类状态的日志开关。Per-kind log toggles. |
Output
无返回值。副作用:配置校验 tick。
No return value. Side effect: configures verification ticks.
把 DeltaTime 追加进 DeltaTimeBuffer,对 Duration 秒窗口求平均 FPS(UMassBattleSubsystem::CalculateAverageFPS 静态实现)。
Appends DeltaTime into DeltaTimeBuffer and computes the average FPS over the Duration-second window (static UMassBattleSubsystem::CalculateAverageFPS).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
DeltaTimeBuffer | TArray<float>& | 帧间隔缓冲(原地追加)。Delta-time buffer (appended in place). |
DeltaTime | float | 本帧间隔。Current frame delta. |
Duration | float | 统计窗口(秒)。Statistics window (seconds). |
Output
返回窗口内平均 FPS。副作用:缓冲被追加/修剪。
Returns the average FPS over the window. Side effect: the buffer is appended/trimmed.
返回全局实体与池化对象计数快照(结构见 FMassBattleGlobalCounts):实体计数按 tag 空查询 / FAgentTag / FProjectileTag / FLootTag / FBatchedFxTag 统计(池内实体保留 tag,故两者皆计);宿主与组件计数经单次遍历 FHostControllerTag 查询按 config fragment 分型得出,音频组件另加宿主子系统的池内数量。每次调用遍历 EntityManager——按 UI 频率调用,勿每模拟 tick 调用。
Returns a snapshot of global entity and pooled-object counters (see FMassBattleGlobalCounts): entity counts come from tag queries — empty / FAgentTag / FProjectileTag / FLootTag / FBatchedFxTag (pooled entities keep their tags, so both are counted); host and component counts come from a single walk over the FHostControllerTag query dispatched by config fragment, with pooled audio components added from the host subsystem. Each call walks the EntityManager — call at UI cadence, not per simulation tick.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文;无效或 UMassAPISubsystem 缺失时返回全零计数。World context; returns zeroed counts when invalid or UMassAPISubsystem is missing. |
Output
返回按类别(agent、投射物、宿主……)的计数快照。无副作用(只读查询)。
Returns the counter snapshot by category (agents, projectiles, hosts, ...). No side effects (read-only queries).
返回各池状态快照(结构见 FMassBattlePoolState):全部 7 个宿主池(含 FxCPU——LogPoolStats 不打印它)+ 投射物 / 战利品实体池 + 音频组件池。开销极低——仅 volatile 读计数器,不遍历 EntityManager(允许滞后一 tick)。Spawns / FromPool / Fresh 每 HostSubsystem::ExecuteTick 重置。
Returns a per-pool state snapshot (see FMassBattlePoolState): all 7 host pools (FxCPU included — LogPoolStats misses it) + the projectile / loot entity pools + the audio component pool. Very cheap — direct volatile counter reads, no EntityManager walk (may be one tick stale). Spawns / FromPool / Fresh reset every HostSubsystem::ExecuteTick.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文;无世界或 UMassBattleHostSubsystem 缺失时返回空数组。World context; empty array when there is no world or UMassBattleHostSubsystem is missing. |
Output
返回各池状态(名称、池内数、本 tick 计数)。无副作用(只读计数器)。
Returns per-pool states (name, size, this-tick counters). No side effects (counter reads only).
打印各对象池统计(九个池开关:actor/fx/sound/projectile/agent/loot 宿主池 + projectile/loot 实体池 + audio 组件池)。
Logs pool statistics (nine pool toggles: actor/fx/sound/projectile/agent/loot host pools + projectile/loot entity pools + audio component pool).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
bActorHostPool 等 9 个 | bool | 各池的日志开关(默认全开)。Per-pool log toggles (all on by default). |
Output
无返回值。副作用:输出日志。
No return value. Side effect: emits logs.
模板构建与快照注册表 Template Building & Snapshot Registry
已弃用——BP 用户请用 MakeTemplateDataFromDataAsset(按资产类型自动分发)。C++ 内部生成路径继续直接使用。从 agent 配置资产构建 FEntityTemplateData。
Deprecated — BP users should call MakeTemplateDataFromDataAsset (auto-dispatches by asset type). C++ internal spawn paths keep using this directly. Builds FEntityTemplateData from an agent config asset.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DataAsset | const UMassBattleAgentConfigDataAsset* | agent 配置资产。Agent config asset. |
Output
返回模板数据;子系统缺失返回空模板。
Returns the template data; empty template when the subsystem is missing.
按资产类型自动分发:UMassBattleAgentConfigDataAsset → agent 模板;UMassBattleProjectileConfigDataAsset → 投射物模板;UMassBattleLootConfigDataAsset → 战利品模板;未知类型记 Warning 并返回空模板。资产无效直接返回空模板。
Auto-dispatches by asset type: UMassBattleAgentConfigDataAsset → agent template; UMassBattleProjectileConfigDataAsset → projectile template; UMassBattleLootConfigDataAsset → loot template; unknown types log a Warning and return an empty template. Invalid assets return an empty template directly.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DataAsset | const UMassBattleDataAssetBase* | 任意 MassBattle 配置资产。Any MassBattle config asset. |
Output
返回模板数据;无效资产或未知类型返回空模板。
Returns the template data; empty template for invalid assets or unknown types.
把模板数据注册进网络快照注册表(转发到 UMassBattleNetworkSubsystem::RegisterNetworkTemplateData),返回实际 Key(Key 为空时自动生成)。
Registers template data into the network snapshot registry (forwarded to UMassBattleNetworkSubsystem::RegisterNetworkTemplateData), returning the actual key (auto-generated when Key is empty).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
TemplateData | const FEntityTemplateData& | 要注册的模板。Template to register. |
OutRegisteredTemplateData | FEntityTemplateData& | 输出:注册后的模板(含规范化 Key)。Output: the registered template (with normalized key). |
Key | FName | 期望 Key(NAME_None = 自动生成)。Desired key (NAME_None = auto). |
Output
返回注册 Key;子系统缺失返回 NAME_None。
Returns the registration key; NAME_None when the subsystem is missing.
按 Key 获取已注册快照模板;Key 未注册时 bFound=false 并返回空模板。
Gets a registered snapshot template by key; bFound=false with an empty template when the key is not registered.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Key | FName | 模板 Key。Template key. |
bFound | bool& | 输出:是否找到。Output: found flag. |
Output
返回模板数据;未找到时 bFound=false 且返回空模板。
Returns the template data; bFound=false with an empty template when missing.
按 Key 注销快照模板(转发到网络子系统)。
Unregisters a snapshot template by key (forwarded to the network subsystem).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Key | FName | 模板 Key。Template key. |
Output
无返回值。
No return value.
已弃用(同 agent 版理由)。从投射物配置资产构建模板。
Deprecated (same rationale as the agent version). Builds a template from a projectile config asset.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DataAsset | const UMassBattleProjectileConfigDataAsset* | 投射物配置资产。Projectile config asset. |
Output
返回模板数据;子系统缺失返回空模板。
Returns the template data; empty template when the subsystem is missing.
锁步指令 Lockstep Commands
向服务器发送锁步指令(客户端侧)。自动分流:大负载(≥ MassBattle.AutoFloodSwitchBytes,默认 16KB)透明切到 TCP 块 + UDP 引用命令;小负载走 UDP RPC。薄封装:从 WorldContext 解析第一个 PlayerController 并转发到 AMassBattleNetworkPlayerControllerBase::SendLockstepCommandToServer。ExtraDeferTicks 把执行推迟到基准 + K 缓冲之外(ExecuteTick = 基准 + K + ExtraDeferTicks)。
Sends a lockstep command to the server (client side). Auto-flood: large payloads (≥ MassBattle.AutoFloodSwitchBytes, default 16KB) transparently switch to a TCP block + UDP reference command; small payloads use a UDP RPC. Thin wrapper: resolves the first PlayerController from the WorldContext and forwards to AMassBattleNetworkPlayerControllerBase::SendLockstepCommandToServer. ExtraDeferTicks defers execution beyond the K-buffer (ExecuteTick = base + K + ExtraDeferTicks).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Success | bool& | 输出:是否成功发送。Output: send success. |
CommandTag | FName | 路由标签。Route tag. |
NamePayload / IntPayload / FloatPayload | const TArray<...>& | 指令负载。Command payloads. |
ExtraDeferTicks | int32 | 额外推迟的 tick 数(默认 0)。Extra defer ticks (default 0). |
Output
无返回值;填充 Success。失败分支:世界无效 / DedicatedServer / 无 PlayerController / 非 MassBattle 网络 PC 时 Success=false。
No return value; fills Success. Failure branches (invalid world / DedicatedServer / no PlayerController / non-MassBattle network PC) set Success=false.
向所有客户端广播锁步指令(服务器侧)。自动分流语义同 SendLockstepCommandToServer;从 WorldContext 解析 GameMode 并转发到 AMassBattleNetworkGameModeBase::SendLockstepCommandToClients。
Broadcasts a lockstep command to all clients (server side). Auto-flood semantics identical to SendLockstepCommandToServer; resolves the GameMode from the WorldContext and forwards to AMassBattleNetworkGameModeBase::SendLockstepCommandToClients.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Success | bool& | 输出。Output. |
CommandTag / 三个 Payload | 同上 | 指令内容。Command content. |
ExtraDeferTicks | int32 | 额外推迟 tick(默认 0)。Extra defer ticks (default 0). |
Output
无返回值;填充 Success。失败分支:世界无效 / 无 AuthGameMode / 非 MassBattle 网络 GM 时 Success=false。
No return value; fills Success. Failure branches (invalid world / no AuthGameMode / non-MassBattle network GM) set Success=false.
【NavMesh-A* 失步修复】导出流场基底(场自身数据结构——Grid 格子 / NavMesh 图,紧凑量化)并锁步广播到全端:全端(含服务器)导入同一份字节并本地计算路径——引擎 navmesh 查询链彻底退出锁步路径。仅服务器端可用(从 WorldContext 解析 GameMode,转发到 AMassBattleNetworkGameModeBase::SendLockstepCommandToClients_RebuildFlowField);服务器构建流场后调用,重建后再次调用。晚加入者自动补发;补发幂等。
[NavMesh-A* desync fix] Exports a flow field's substrate (its own data structure — Grid cells / NavMesh graph, compactly quantized) and lockstep-broadcasts it to every peer: every peer (server included) imports the SAME bytes and computes paths locally — the engine navmesh query chain leaves the lockstep path entirely. Server-side only (resolves the GameMode from the world context and forwards to AMassBattleNetworkGameModeBase::SendLockstepCommandToClients_RebuildFlowField); call after the server builds the field and again after any rebuild. Late joiners are re-fed automatically; re-delivery is idempotent.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Success | bool& | 输出:已导出并派发时为 true;世界 / Field / GameMode 无效时为 false。Output: true when exported and dispatched; false on invalid world / Field / GameMode. |
Field | AFlowField* | 要同步的(服务器已构建的)流场。The server-built flow field to sync. |
ExtraDeferTicks | int32 | MB 级 TCP 块的额外传输余量(默认 120)。Extra transit headroom for the MB-size TCP block (default 120). |
SyncMode | EFFSubstrateSyncMode | 全量:恒发整个基底;增量:优先差分流(变更格子 / tile + 目标集,无可用基准自动回退全量);Auto(默认):服务器择小发送——首次必全量,局部变化的重发走微型差分(差分达到 MassBattle.FF.DeltaToFullRatio × 全量即弃用)。Full: always send the entire substrate; Incremental: prefer a delta stream (changed cells / tiles + goals, auto-falling back to full when no usable base); Auto (default): the server sends whichever is smaller — first send always full, re-sends with minor changes ride a tiny delta (delta dropped once it reaches MassBattle.FF.DeltaToFullRatio × full). |
Output
无返回值;填充 Success。副作用:向全部客户端派发一次基底同步锁步指令。
No return value; fills Success. Side effect: dispatches one substrate-sync lockstep command to all clients.
调试用网络环境模拟——一次调用同时损伤两条路径:UE 的 UDP RPC 流量(设置 net.PktLag / net.PktLagVariance / net.PktLoss / net.PktDuplicate 引擎 cvar,进程级)与自定义 TCP 快照 / 锁步块路径(FMassBattleSnapshotTcpTransport 的到期队列 + 逐帧丢弃 + 令牌桶限速,进程级静态)。TCP 控制帧(认证 / 心跳)永远直发;TCP 侧刻意无重复 / 乱序旋钮(TCP 设计上去重且保序)。PIE 单进程一次调用即覆盖两条路径的双方向;独立多进程:在想受影响的进程上各调用。启用时记一条响亮 Warning;全零设置或 Clear 关闭(Clear 同时把 net.PktLag 系列归零);Get 读取当前生效的 TCP 路径设置。仅 TCP 路径的镜像 cvar:MassBattle.NetEmulation.*。
Debug network-environment emulation — one call impairs BOTH paths at once: UE's UDP RPC traffic (sets the net.PktLag / net.PktLagVariance / net.PktLoss / net.PktDuplicate engine cvars, process-wide) and the custom TCP snapshot / lockstep-block path (due-time queue + per-frame drop + token-bucket throttle inside FMassBattleSnapshotTcpTransport, process-global statics). TCP control frames (auth / heartbeat) always bypass; the TCP side deliberately has no duplicate/reorder knobs (TCP dedupes and preserves order by design). In PIE one call covers both directions of both paths (single process); standalone multi-process: call on each process you want impaired. Enabling logs a loud Warning; all-zero settings or Clear disable (Clear also resets the net.PktLag family to 0); Get reads the currently effective TCP-path settings. Mirror cvars for the TCP path alone: MassBattle.NetEmulation.*.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext(Set / Clear) | const UObject* | 世界上下文。World context. |
Settings(Set) | const FMassBattleNetEmulationSettings& | 延迟 / 抖动 / 丢包(LossMode 语义)/ 重复 / 带宽上限 / 随机种子设置(定义于 MassBattleStructs.h)。Latency / jitter / drop (LossMode semantics) / duplicate / bandwidth-cap / seed settings (defined in MassBattleStructs.h). |
Output
Set / Clear 无返回值。副作用:写进程级静态与引擎 cvar 并记 Warning;Get 返回生效中的模拟设置(关闭时全零)。
Set / Clear return nothing. Side effects: write process-global statics and engine cvars plus a Warning log; Get returns the active emulation settings (zeroed when disabled).
大世界坐标编码/解码:把 64 位 double FVector 拆成三个 int32 格子坐标 + 三个 float 偏移,在锁步负载中保留 float 精度(int32 格子精确保存大数,float 偏移只带格子内余量)。GridSize 写死 10000,两端必须一致。仅当远离世界原点时才有必要——靠近原点直接 float 转换已足够精确。输出可直接接入 SendLockstepCommand 的 IntPayload/FloatPayload。解码输入不足 3 项时记 Error 并返回 ZeroVector。
Large-world-coordinate codec: splits a 64-bit double FVector into three int32 grid coords plus three float offsets, preserving float precision in the lockstep payload (int32 cells hold the magnitude exactly, float offsets carry only the sub-cell remainder). GridSize is hard-coded to 10000 and must match on both ends. Only necessary far from the world origin — near it, a plain float cast is precise enough. Outputs plug directly into SendLockstepCommand's IntPayload/FloatPayload. Decoding with fewer than 3 entries logs an Error and returns ZeroVector.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldLocation(编码) | const FVector& | 世界坐标。World location. |
OutGridCoords / OutOffsets(编码) | TArray<int32>& / TArray<float>& | 输出三个格子坐标与三个偏移。Output three grid coords and three offsets. |
GridCoords / Offsets(解码) | const TArray<int32>& / const TArray<float>& | 输入编码。Input encoding. |
Output
编码无返回值(填充两个输出数组);解码返回还原的世界坐标。
Encode: no return (fills the two out-arrays); decode: returns the restored world location.
批量版本:编码 N 个坐标为 3*N int32 + 3*N float(X,Y,Z 每坐标交错);解码 3*N 对还原 N 个坐标。解码时 int/float 数量不等记 Error 并取最小值组数。
Batch variants: encode N locations into 3*N int32 + 3*N float (X,Y,Z interleaved per location); decode 3*N pairs back to N locations. Decoding with mismatched int/float counts logs an Error and decodes the min group count.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldLocations(编码) | const TArray<FVector>& | 世界坐标数组。World location array. |
OutGridCoords / OutOffsets(编码) | TArray<int32>& / TArray<float>& | 输出交错数组。Output interleaved arrays. |
GridCoords / Offsets(解码) | const TArray<int32>& / const TArray<float>& | 输入编码。Input encoding. |
Output
编码无返回值;解码返回坐标数组。
Encode: no return; decode: returns the location array.
Agent 生成器 Agent Spawners
八个生成入口(矩形/圆形 × 模板/配置 × 立即/延迟)全部转发到 UMassBattleAgentSubsystem。公共参数:Quantity(数量)、Team(队伍)、Origin(中心)、ShapeData(形状,含地面/障碍验证)、LaunchVelocity(出生速度)、InitialRotation(面朝玩家 0 或自定义)、CustomRotation、Multipliers(FSpawnerMult 乘数)、bAutoActivated(默认 true)。延迟版额外带 Substeps(0 = 单 tick 全部生成;>0 = 分摊到 Substeps+1 个 tick)与 OnFinished(全部完成回调,携带生成的句柄)。
Eight spawn entries (rectangular/circular × template/config × immediate/deferred), all forwarded to UMassBattleAgentSubsystem. Shared params: Quantity, Team, Origin (center), ShapeData (shape incl. ground/obstacle validation), LaunchVelocity (spawn velocity), InitialRotation (face player 0 or custom), CustomRotation, Multipliers (FSpawnerMult), bAutoActivated (default true). The deferred versions add Substeps (0 = all spawns in one tick; >0 = spread across Substeps+1 ticks) and OnFinished (fired when all spawning completes, with the spawned handles).
立即生成:以预构建模板(BaseTemplate)在矩形/圆形区域生成 agent,返回实体句柄数组。
Immediate spawn: generates agents in a rectangular/circular region from a prebuilt template (BaseTemplate), returning the entity-handle array.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
BaseTemplate | const FEntityTemplateData& | 实体模板。Entity template. |
Quantity / Team | int32 | 数量与队伍(默认 1 / 0)。Quantity and team (default 1 / 0). |
Origin / ShapeData | FVector / 形状数据FVector / shape data | 中心与形状参数。Center and shape data. |
LaunchVelocity | const FVector2D& | 出生速度范围。Spawn velocity. |
InitialRotation / CustomRotation | EInitialRotation / FRotator | 初始朝向。Initial rotation. |
Multipliers / bAutoActivated | FSpawnerMult / bool | 乘数与自动激活。Multipliers and auto-activation. |
Output
返回生成的实体句柄数组;子系统缺失返回空数组。
Returns the spawned entity-handle array; empty when the subsystem is missing.
立即生成:以配置资产(DataAsset)构建模板后在矩形/圆形区域生成。
Immediate spawn: builds the template from a config asset (DataAsset), then generates in a rectangular/circular region.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
DataAsset | const UMassBattleAgentConfigDataAsset* | agent 配置资产。Agent config asset. |
| 其余参数 | 同上 | 与模板版相同。Same as the template versions. |
Output
返回生成的实体句柄数组。
Returns the spawned entity-handle array.
延迟版:把生成请求排队,由 UMassBattleAgentSubsystem::ExecuteTick 批量处理。Substeps 控制分摊(0 = 单 tick 全部生成;>0 = 分摊到 Substeps+1 个 tick);OnFinished 在所有生成完成后触发并携带句柄。
Deferred versions: queue the spawn request for batch processing in UMassBattleAgentSubsystem::ExecuteTick. Substeps controls spreading (0 = all spawns in one tick; >0 = spread across Substeps+1 ticks); OnFinished fires when all spawning completes with the handles.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
BaseTemplate / DataAsset | 同上 | 模板或配置资产。Template or config asset. |
Quantity / Team / Origin / ShapeData / LaunchVelocity / InitialRotation / CustomRotation / Multipliers / bAutoActivated | 同上 | 生成参数(无默认值)。Spawn params (no defaults). |
Substeps | int32 | 生成分摊的 tick 数。Spawn spreading ticks. |
OnFinished | const FOnAgentSpawnFinished& | 完成回调。Completion callback. |
Output
无返回值。副作用:排队生成请求,后续 tick 消费并触发 OnFinished。
No return value. Side effect: queues the spawn request, consumed over subsequent ticks, firing OnFinished.
设置生成器随机种子(转发到 Agent 子系统)——决定出生随机性(乘数范围 / 形状随机偏移)的确定性来源。
Sets the spawner random seed (forwarded to the Agent subsystem) — the determinism source for spawn randomness (multiplier ranges / shape random offsets).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
NewSeed | int32 | 新种子。New seed. |
Output
无返回值。
No return value.
激活/停用单个或多个 agent:设置/清除 ActivatedFlag。轻量操作——不触发 archetype 迁移。
Activates/deactivates one or more agents by setting/clearing the ActivatedFlag. Lightweight — no archetype migration.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
AgentHandle / AgentHandles | FEntityHandle / TArray<FEntityHandle> | 目标 agent。Target agents. |
bActivated | bool | true = 置标志,false = 清标志(默认 true)。true sets the flag, false clears it (default true). |
Output
无返回值。副作用:设置/清除 ActivatedFlag。
No return value. Side effect: sets/clears the ActivatedFlag.
重叠检测 Overlap Detection
用实体句柄数组做重叠检测:把 Current 与 Accumulated 转 TSet 后并行(MBParallelFor)求差——新增(在 Current 不在 Accumulated)写入 BeginOverlaps,离开(反之)写入 EndOverlaps;然后原地稳定移除 EndOverlaps 并把 BeginOverlaps 追加进 Accumulated。确定性保证:TSet 只用 Contains()(与桶布局无关),并行写互斥槽位,输出按输入索引序生成——输入有序则输出确定。
Overlap detection on entity-handle arrays: converts Current and Accumulated to TSets and computes the difference in parallel (MBParallelFor) — newcomers (in Current, not in Accumulated) go to BeginOverlaps, leavers (the reverse) to EndOverlaps; then removes EndOverlaps in-place stably and appends BeginOverlaps into Accumulated. Determinism: TSet is only queried via Contains() (bucket layout irrelevant), the parallel pass writes disjoint per-index slots, and all output loops walk inputs in index order — deterministic inputs yield deterministic outputs.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
Current | const TArray<FEntityHandle>& | 本帧在区域内的实体。Entities currently in the area. |
Accumulated | TArray<FEntityHandle>& | 累计集合(原地修改)。Accumulated set (modified in place). |
BeginOverlaps / EndOverlaps | TArray<FEntityHandle>& | 输出:新增 / 离开。Outputs: newcomers / leavers. |
Output
无返回值。副作用:重写 Accumulated(去掉离开者、追加新增者),填充两个输出数组。
No return value. Side effects: rewrites Accumulated (leavers removed, newcomers appended) and fills the two output arrays.
同 ProcessOverlap_EntityArray,但输入为 FTraceResult 数组——身份只按 Entity 判定(TSet 存句柄而非完整结果),其余流程一致。
Same as ProcessOverlap_EntityArray but on FTraceResult arrays — identity is judged by Entity only (the TSet stores handles, not full results); the rest of the flow is identical.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
Current | const TArray<FTraceResult>& | 本帧追踪结果。Current frame's trace results. |
Accumulated | TArray<FTraceResult>& | 累计结果(原地修改)。Accumulated results (modified in place). |
BeginOverlaps / EndOverlaps | TArray<FTraceResult>& | 输出。Outputs. |
Output
无返回值。副作用:重写 Accumulated 并填充输出。
No return value. Side effects: rewrites Accumulated and fills the outputs.
阵型与移动 Formation & Movement
对 agents 设置 bStopActiveMovement,使 MoveProcessor 把它们减速到零。不清除目标或 MoveTo 标志。
Sets bStopActiveMovement on the agents, causing the MoveProcessor to decelerate them to zero. Does not clear goals or MoveTo flags.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / Agents | UObject* / const TArray<FEntityHandle>& | 上下文与 agent 列表。Context and agent list. |
Output
无返回值。
No return value.
立即停止 agents 的全部移动:速度清零、清除目标、清除 MoveTo 标志、重置寻路状态。
Immediately stops all movement on the agents: zeros velocity, clears goals, clears MoveTo flags, and resets pathfinding state.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / Agents | UObject* / const TArray<FEntityHandle>& | 上下文与 agent 列表。Context and agent list. |
Output
无返回值。副作用:修改移动相关 fragment 状态。
No return value. Side effect: mutates movement fragment state.
立即切换 agent 的活跃行为(EBehaviorState,转发到 Agent 子系统):清除全部行为旗标,重置各行为 fragment(巡逻 / 攻击 / 增援 / 返回)与移动目标,然后激活目标状态。配置 fragment 未启用的行为(以及 Return 请求)降级为 Idle。无效句柄、濒死 agent 或移动锁定的 agent(目标非 Idle 时)返回 false。
Immediately switches an agent's active behavior (EBehaviorState, forwarded to the Agent subsystem): clears every behavior flag, resets the per-behavior fragments (patrol/attack/reinforce/return) and movement-to-goal, then activates the target state. Behaviors whose config fragment is disabled (and Return requests) degrade to Idle. Returns false for invalid handles, dying agents, or MoveTo-locked agents (unless switching to Idle).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / Agent | const UObject* / const FEntityHandle& | 上下文与 agent。Context and agent. |
TargetBehavior | EBehaviorState | 目标行为。Target behavior. |
Output
返回切换是否成功;子系统缺失返回 false。
Returns whether the switch succeeded; false when the subsystem is missing.
生成矩形网格阵型的逐 agent 目标位置。内部:清空输出 → 校验 MA/World/agents → 委托 UMassBattleFormationAlgorithms::GenerateGridFormationImpl。agent 按当前空间位置(读 FLocating.Location)分配槽位以保持相对顺序、避免交叉路径;分配模式 KeepFormation(保持空间排列)或 ReformTheLine(就近分配槽位);可视化经 LineBatchComponent,Shipping 可见。
Generates per-agent goal locations arranged in a rectangular grid formation. Internally: resets the output → validates MA/World/agents → delegates to UMassBattleFormationAlgorithms::GenerateGridFormationImpl. Agents are assigned to grid slots based on their current spatial position (reads FLocating.Location) to preserve relative ordering and avoid crossing paths; KeepFormation preserves spatial arrangement, ReformTheLine assigns nearest slots; visualization renders via LineBatchComponent, visible in Shipping.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | UObject* | 世界上下文。World context. |
Agents | const TArray<FEntityHandle>& | agent 实体列表。Agent entity list. |
CenterLocation | FVector | 阵型中心。Formation center. |
ShapeData | const FAgentSpawnRectangleShapeData& | 矩形形状参数(Region / Spacing / ShapeDirection)。Rectangle shape params (Region / Spacing / ShapeDirection). |
AssignmentMode | EFormationAssignmentMode | 分配模式。Assignment mode. |
OutLocations | TArray<FVector>& | 输出:逐 agent 目标位置(与 Agents 同序)。Output: per-agent goal positions (same order as Agents). |
AgentBoundMode / SizeMultiplier / VisualizationConfig | 见前 | 半径来源 / 尺寸乘数 / 可视化。Radius source / size multiplier / visualization. |
Output
无返回值;填充 OutLocations(MA/World 缺失或 agents 为空时为空数组)。
No return value; fills OutLocations (empty when MA/World missing or no agents).
生成圆形/多边形阵型的逐 agent 目标位置(极坐标网格模式)。内部结构同 GenerateGridFormation,委托 GenerateCircularFormationImpl。
Generates per-agent goal locations in a circular/polygonal formation (polar-grid mode). Internal structure mirrors GenerateGridFormation, delegating to GenerateCircularFormationImpl.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | UObject* | 世界上下文。World context. |
Agents | const TArray<FEntityHandle>& | agent 实体列表。Agent entity list. |
CenterLocation | FVector | 阵型中心。Formation center. |
ShapeData | const FAgentSpawnPolygonShapeData& | 多边形形状参数(OuterRadius / InnerRadius / Spacing / Segments 等)。Polygon shape params (OuterRadius / InnerRadius / Spacing / Segments, etc.). |
AssignmentMode / OutLocations / AgentBoundMode / SizeMultiplier / VisualizationConfig | 见前 | 与网格版相同。Same as the grid version. |
Output
无返回值;填充 OutLocations。
No return value; fills OutLocations.
生成三角(楔形)阵型的逐 agent 目标位置:与 agent 生成系统共用同一形状数据结构(FAgentSpawnTriangleShapeData,定义于 MassBattleStructs.h——行自 1 槽顶点沿 ShapeDirection 递增到底边)。agent 按当前空间位置(读 FLocating.Location)分配阵型槽位以保持相对排列、避免路径交叉。内部结构同 GenerateGridFormation,委托 UMassBattleFormationAlgorithms::GenerateTriangleFormationImpl。
Generates per-agent goal locations arranged in a triangular (wedge) formation: uses the same shape-data struct family as the agent spawning system (FAgentSpawnTriangleShapeData, defined in MassBattleStructs.h — rows grow from a 1-slot apex along ShapeDirection to the base). Agents are assigned to formation slots based on their current spatial position (reads FLocating.Location) to preserve relative ordering and avoid crossing paths. Internal structure mirrors GenerateGridFormation, delegating to UMassBattleFormationAlgorithms::GenerateTriangleFormationImpl.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | UObject* | 世界上下文。World context. |
Agents | const TArray<FEntityHandle>& | agent 实体列表。Agent entity list. |
CenterLocation | FVector | 阵型中心。Formation center. |
ShapeData | const FAgentSpawnTriangleShapeData& | 三角形状参数(Region / Spacing / ShapeDirection——顶点朝向 ShapeDirection)。Triangle shape params (Region / Spacing / ShapeDirection — the apex points along ShapeDirection). |
AssignmentMode / OutLocations / AgentBoundMode / SizeMultiplier / VisualizationConfig | 见前 | 与网格版相同。Same as the grid version. |
Output
无返回值;填充 OutLocations(与 Agents 同序)。
No return value; fills OutLocations (same order as Agents).
潜伏动作:延迟到给定数量的 MassBattle 模拟 tick 过去后继续。同一节点重复触发(仍在计数中)被忽略(与引擎 Delay 一致)。NumTicks <= 0 时下一个 MassBattle tick 即完成。实现:经 FLatentActionManager 注册 FMassBattleDelayTicksLatentAction,每帧用 UMassBattleSubsystem::GetTickCount() 比较目标值。
Latent action: delays until the given number of MassBattle simulation ticks have elapsed. Re-triggering the same node while it is already counting is ignored (matches engine Delay). NumTicks <= 0 completes on the next MassBattle tick. Implementation: registers FMassBattleDelayTicksLatentAction via FLatentActionManager, comparing against UMassBattleSubsystem::GetTickCount() each frame.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
NumTicks | int32 | 要延迟的 tick 数(内部 max(1, NumTicks))。Ticks to delay (internally max(1, NumTicks)). |
LatentInfo | FLatentActionInfo | 潜伏动作信息。Latent action info. |
Output
无返回值。副作用:注册一个潜伏动作,到期后继续执行流。
No return value. Side effect: registers a latent action that resumes the flow when done.
设置/查询 agent 控制模式:AI(恢复寻路/行为)或 PlayerDriven。查询失败返回 AI。
Sets/queries the agent control mode: AI (resume pathfinding/behavior) or PlayerDriven. The query returns AI on failure.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / Agent | const UObject* / FEntityHandle | 上下文与 agent。Context and agent. |
Mode(设置) | EAgentControlMode | 目标模式。Target mode. |
Output
Set 无返回值;Get 返回当前模式(失败返回 AI)。
Set: no return; Get: returns the current mode (AI on failure).
向 agent 添加移动输入,镜像 UPawnMovementComponent::AddMovementInput:每帧累积,由移动处理器消费。Scale 缩放方向向量;bForce 强制添加。
Adds movement input to an agent, mirroring UPawnMovementComponent::AddMovementInput: accumulates input per frame, consumed by the move processor. Scale scales the direction; bForce forces the addition.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / Agent | const UObject* / FEntityHandle | 上下文与 agent。Context and agent. |
WorldDirection | FVector | 世界空间方向。World-space direction. |
Scale | float | 缩放(默认 1)。Scale (default 1). |
bForce | bool | 强制添加(默认 false)。Force the addition (default false). |
Output
无返回值。副作用:累积到移动输入,由移动处理器消费。
No return value. Side effect: accumulates into movement input, consumed by the move processor.
网络辅助 Network Helpers
经共享注册表把锁步 NetID 解析为绑定宿主(agent/projectile/loot 组件,或 replicated actor)。返回 UObject 需自行 Cast;bFound=false 当 ID 未知或宿主已注销。
Resolves a lockstep NetID to its bound host (agent/projectile/loot component, or a replicated actor) via the shared registry. Cast the returned UObject yourself; bFound=false when the ID is unknown or the host is gone.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
LockstepNetID | int32 | 锁步网络 ID。Lockstep NetID. |
bFound | bool& | 输出:是否找到。Output: found flag. |
Output
返回宿主 UObject;未找到返回 nullptr。
Returns the host UObject, or nullptr when not found.
检查是否启用了网络模式(UMassBattleSubsystem::bNetworkedMode);子系统缺失返回 false。
Checks whether networked mode is enabled (UMassBattleSubsystem::bNetworkedMode); false when the subsystem is missing.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
返回是否网络模式。
Returns whether networked mode is on.
获取目标执行 tick(CurrentTick + InputBufferTicks);子系统缺失返回 0。
Gets the target execution tick (CurrentTick + InputBufferTicks); 0 when the subsystem is missing.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
返回目标执行 tick。
Returns the target execution tick.
把 FEntityHandle 转 UniqueID:经 UMassBattleSubsystem::FindUIDByEntity 反查;无效/不可解析 → -1 且 bFound=false。
Converts an FEntityHandle to its UniqueID via UMassBattleSubsystem::FindUIDByEntity; invalid/unresolvable → -1 with bFound=false.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Handle | const FEntityHandle& | 实体句柄。Entity handle. |
bFound | bool& | 输出。Output. |
Output
返回 UniqueID(无效为 -1)。
Returns the UniqueID (-1 when invalid).
批量版:逐个转换,无效/不可解析句柄输出 -1 占位——输出长度与输入对齐。可直接接入 SendLockstepCommand 的 IntPayload。
Batch version: converts each handle; invalid/unresolvable handles become -1 placeholders so the output stays length-aligned with the input. Plugs directly into SendLockstepCommand's IntPayload.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Entities | const TArray<FEntityHandle>& | 句柄数组。Handle array. |
Output
返回 UID 数组(长度与输入对齐)。
Returns the UID array (length-aligned with the input).
把 UniqueID 转 FEntityHandle:经 UMassBattleSubsystem::FindEntityByUID 正查;不可解析 → 无效句柄且 bFound=false。
Converts a UniqueID to its FEntityHandle via UMassBattleSubsystem::FindEntityByUID; unresolvable → an invalid handle with bFound=false.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
UniqueID | int32 | 实体 UID。Entity UID. |
bFound | bool& | 输出。Output. |
Output
返回实体句柄(不可解析为无效句柄)。
Returns the entity handle (invalid when unresolvable).
批量版:经网络子系统的 ResolveUniqueIDs 逐个解析;不可解析的 ID 输出无效句柄占位,长度与输入对齐。
Batch version: resolves each ID via the network subsystem's ResolveUniqueIDs; unresolvable IDs become invalid-handle placeholders, length-aligned with the input.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
UniqueIDs | const TArray<int32>& | UID 数组。UID array. |
Output
返回句柄数组(长度与输入对齐)。
Returns the handle array (length-aligned with the input).
检查玩家是否已完成 late-join 并完全进入游戏(转发到网络子系统)。
Checks whether a player has completed late-join and is fully in the game (forwarded to the network subsystem).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / PlayerId | const UObject* / int32 | 上下文与玩家 ID。Context and player ID. |
Output
返回玩家是否已加入。
Returns whether the player has joined.
获取当前网络诊断统计(FMassBattleNetworkStats,转发到网络子系统);缺失返回默认结构。
Gets the current network diagnostic stats (FMassBattleNetworkStats, forwarded to the network subsystem); default struct when missing.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
Output
返回网络统计。
Returns the network stats.
获取指定客户端的延迟(毫秒);子系统缺失返回 0。
Gets the ping for a specific client (milliseconds); 0 when the subsystem is missing.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / PlayerIndex | const UObject* / int32 | 上下文与玩家索引。Context and player index. |
Output
返回 ping(毫秒)。
Returns the ping in milliseconds.
记录逐实体失步诊断(仅编辑/开发,转发到网络子系统)。
Logs detailed per-entity desync diagnostics (editor/dev only, forwarded to the network subsystem).
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext / TickCount | const UObject* / int32 | 上下文与要诊断的 tick。Context and tick to diagnose. |
Output
无返回值。副作用:输出日志。
No return value. Side effect: emits logs.
其它 Miscellaneous
把屏幕矩形(Start + WidthHeight)的四个角反投影到 Distance 处的世界点。先归一化矩形边界(与 WidthHeight 符号无关),按相机视角逆时针输出四角(供视野追踪构建法线向内的视锥平面);任一角的反投影失败返回 false。无世界或 PlayerController 返回 false。
Deprojects the four corners of a screen rect (Start + WidthHeight) to world points at Distance. Normalizes the rect bounds first (sign-independent of WidthHeight), outputs the four corners counter-clockwise from the camera's view (so view-trace frustum planes get inward-facing normals); returns false if any corner deprojects fail. False without a world or PlayerController.
Input
| 参数 Param | 类型 Type | 说明 Description |
|---|---|---|
WorldContext | const UObject* | 世界上下文。World context. |
OutPoints | TArray<FVector>& | 输出:4 个世界点。Output: 4 world points. |
Start / WidthHeight | const FVector2D& | 屏幕矩形起点与宽高。Screen rect start and width/height. |
Distance | float | 反投影距离。Deprojection distance. |
Output
返回是否成功;成功时 OutPoints 含 4 个点。
Returns success; on success OutPoints holds 4 points.
管线角色 Pipeline Role
蓝图侧对 MassBattle 的统一入口:所有生成、追踪、伤害、移动、阵型、网络指令都由本库的函数发起并转发到对应子系统。关键内部调用:Generate*Formation → UMassBattleFormationAlgorithms::Generate*FormationImpl(见 FuncLibs/MassBattleFormationAlgorithms.html);SelectAgents / DeselectAgents 走端侧本地视觉路径(锁步外);SendLockstepCommandTo* 是唯一写入锁步指令流的入口(经 ExecuteNetCommand 通道);RegisterNetworkTemplateData 供快照模板注册表使用。延迟生成请求由 UMassBattleAgentSubsystem::ExecuteTick 每 tick 排空。GetOrAcquireFlowFieldLayer 经 AFlowField 的 FindManagedLayerByGoalHash / CreateManagedLayer / AcquireLayerUser 获取或创建托管层,返回句柄由 MoveTo 任务(MassBattleBPTaskAgentsMoveTo 的 FlowFieldLayer)按任务引用计数;SendLockstepCommandToClients_RebuildFlowField 转发到 AMassBattleNetworkGameModeBase 向全端派发流场基底。
The Blueprint-side unified entry point to MassBattle: all spawning, tracing, damage, movement, formation, and network commands originate here and forward to the matching subsystems. Key internal calls: Generate*Formation → UMassBattleFormationAlgorithms::Generate*FormationImpl (see FuncLibs/MassBattleFormationAlgorithms.html); SelectAgents / DeselectAgents take the peer-local visual path (off-lockstep); SendLockstepCommandTo* is the sole entry into the lockstep command stream (via the ExecuteNetCommand channel); RegisterNetworkTemplateData feeds the snapshot template registry. Deferred spawn requests are drained each tick by UMassBattleAgentSubsystem::ExecuteTick. GetOrAcquireFlowFieldLayer gets-or-creates a managed layer through AFlowField's FindManagedLayerByGoalHash / CreateManagedLayer / AcquireLayerUser; the returned handle is reference-counted per MoveTo task (the FlowFieldLayer of MassBattleBPTaskAgentsMoveTo); SendLockstepCommandToClients_RebuildFlowField forwards to AMassBattleNetworkGameModeBase to dispatch the flow-field substrate to all peers.