Mass Battle Frameworkv1.20.0

UMassBattleTagHelpers

静态工具类

Source/MassBattle/Public/FuncLibs/MassBattleTagHelpers.h

概述Overview

队伍(Team)与子类型(SubType)tag 的按索引操作工具类(纯静态函数)。MassBattle 为 0-255 每个索引预生成一个 tag(FTeam0Tag..FTeam255Tag、FSubType0Tag..FSubType255Tag),本类把「索引 → 具体 tag」的 switch 分发集中到一处,提供模板级、实体级、延迟(命令缓冲)级与处理器上下文级四种操作面。越界索引(<0 或 >255)的 switch 落到 default 分支,无操作;每类标签使用相同的模板族(Fragments/Team.h、Fragments/SubType.h)。

Index-based tag operation utility for Team and SubType tags (pure static functions). MassBattle pre-generates one tag per index 0-255 (FTeam0Tag..FTeam255Tag, FSubType0Tag..FSubType255Tag); this class centralizes the "index → concrete tag" switch dispatch and exposes four operation surfaces: template-level, entity-level, deferred (command-buffer), and processor-context-level. Out-of-range indices (<0 or >255) hit the switch's default branch and do nothing; each tag family uses the same template family (Fragments/Team.h, Fragments/SubType.h).

公开方法Public Methods

AddTemplateTeamTagByIndex static void

按索引向实体模板(FMassEntityTemplateData)添加队伍 tag:AddTag<FTeamN>()。索引 0-255 有效,越界无操作。

Adds the team tag to an entity template (FMassEntityTemplateData) by index: AddTag<FTeamN>(). Valid for indices 0-255; out of range is a no-op.

Input
参数Param类型Type说明Description
TemplateDataFMassEntityTemplateData&目标实体模板。Target entity template.
Indexint32队伍索引,合法范围 [0, 255]。Team index, valid range [0, 255].
Output

无返回值。副作用:模板获得对应队伍 tag;越界索引无操作。

No return value. Side effect: the template gains the team tag; out-of-range index is a no-op.

AddEntityTeamTagByIndex static void

按索引立即为实体添加队伍 tag(MA->AddTag<FTeamN>(EntityHandle))。

Immediately adds the team tag to an entity by index (MA->AddTag<FTeamN>(EntityHandle)).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文,解析 UMassAPISubsystem。World context resolving UMassAPISubsystem.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:实体获得队伍 tag(触发 archetype 迁移)。

No return value. Side effect: the entity gains the team tag (archetype migration).

AddEntityTeamTagByIndexDeferred static void

延迟版:经 MA->Defer().AddTag<FTeamN>(EntityHandle) 把添加操作排入命令缓冲,flush 时执行——并行段内安全。

Deferred version: queues the add via MA->Defer().AddTag<FTeamN>(EntityHandle) into the command buffer, executed at flush — safe inside parallel sections.

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:命令缓冲收到添加命令。

No return value. Side effect: the command buffer receives the add command.

AddEntityTeamTagByIndexDeferredContext static void

处理器上下文版:经 Context.Defer().AddTag<FTeamN>(EntityHandle) 延迟添加——供处理器内部使用,无需再解析子系统。

Processor-context version: defers via Context.Defer().AddTag<FTeamN>(EntityHandle) — for use inside processors without re-resolving the subsystem.

Input
参数Param类型Type说明Description
ContextFMassExecutionContext&Mass 执行上下文(提供命令缓冲)。Mass execution context (provides the command buffer).
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:上下文命令缓冲收到添加命令。

No return value. Side effect: the context's command buffer receives the add command.

HasEntityTeamTagByIndex static bool

按索引查询实体是否带对应队伍 tag(MA->HasTag<FTeamN>(EntityHandle),archetype 组合 O(1) 查询)。

Queries whether the entity carries the team tag by index (MA->HasTag<FTeamN>(EntityHandle), an O(1) archetype-composition query).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

返回实体是否带有该队伍 tag;越界索引返回 false(default 分支)。

Returns whether the entity has the team tag; out-of-range indices return false (default branch).

RemoveEntityTeamTagByIndex static void

按索引立即移除实体的队伍 tag(MA->RemoveTag<FTeamN>(EntityHandle))。

Immediately removes the team tag by index (MA->RemoveTag<FTeamN>(EntityHandle)).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:实体失去队伍 tag(触发 archetype 迁移)。

No return value. Side effect: the entity loses the team tag (archetype migration).

RemoveEntityTeamTagByIndexDeferred static void

延迟版:经 MA->Defer().RemoveTag<FTeamN>(EntityHandle) 排入命令缓冲。

Deferred version: queues via MA->Defer().RemoveTag<FTeamN>(EntityHandle).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:命令缓冲收到移除命令。

No return value. Side effect: the command buffer receives the remove command.

RemoveEntityTeamTagByIndexDeferredContext static void

处理器上下文版:经 Context.Defer().RemoveTag<FTeamN>(EntityHandle) 延迟移除。

Processor-context version: defers the remove via Context.Defer().RemoveTag<FTeamN>(EntityHandle).

Input
参数Param类型Type说明Description
ContextFMassExecutionContext&Mass 执行上下文。Mass execution context.
Indexint32队伍索引 [0, 255]。Team index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:上下文命令缓冲收到移除命令。

No return value. Side effect: the context's command buffer receives the remove command.

AddTemplateSubTypeTagByIndex static void

按索引向实体模板添加子类型 tag:AddTag<FSubTypeN>()。与队伍版本行为一致,仅 tag 家族不同。

Adds the subtype tag to an entity template by index: AddTag<FSubTypeN>(). Behavior matches the team version; only the tag family differs.

Input
参数Param类型Type说明Description
TemplateDataFMassEntityTemplateData&目标实体模板。Target entity template.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
Output

无返回值。副作用:模板获得对应子类型 tag;越界无操作。

No return value. Side effect: the template gains the subtype tag; out-of-range is a no-op.

AddEntitySubTypeTagByIndex static void

按索引立即为实体添加子类型 tag(MA->AddTag<FSubTypeN>(EntityHandle))。

Immediately adds the subtype tag by index (MA->AddTag<FSubTypeN>(EntityHandle)).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:实体获得子类型 tag(触发 archetype 迁移)。

No return value. Side effect: the entity gains the subtype tag (archetype migration).

AddEntitySubTypeTagByIndexDeferred static void

延迟版:经 MA->Defer().AddTag<FSubTypeN>(EntityHandle) 排入命令缓冲。

Deferred version: queues via MA->Defer().AddTag<FSubTypeN>(EntityHandle).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:命令缓冲收到添加命令。

No return value. Side effect: the command buffer receives the add command.

AddEntitySubTypeTagByIndexDeferredContext static void

处理器上下文版:经 Context.Defer().AddTag<FSubTypeN>(EntityHandle) 延迟添加。

Processor-context version: defers via Context.Defer().AddTag<FSubTypeN>(EntityHandle).

Input
参数Param类型Type说明Description
ContextFMassExecutionContext&Mass 执行上下文。Mass execution context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:上下文命令缓冲收到添加命令。

No return value. Side effect: the context's command buffer receives the add command.

HasEntitySubTypeTagByIndex static bool

按索引查询实体是否带对应子类型 tag。

Queries whether the entity carries the subtype tag by index.

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

返回实体是否带有该子类型 tag;越界索引返回 false。

Returns whether the entity has the subtype tag; out-of-range indices return false.

RemoveEntitySubTypeTagByIndex static void

按索引立即移除实体的子类型 tag。

Immediately removes the subtype tag by index.

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:实体失去子类型 tag(触发 archetype 迁移)。

No return value. Side effect: the entity loses the subtype tag (archetype migration).

RemoveEntitySubTypeTagByIndexDeferred static void

延迟版:经 MA->Defer().RemoveTag<FSubTypeN>(EntityHandle) 排入命令缓冲。

Deferred version: queues via MA->Defer().RemoveTag<FSubTypeN>(EntityHandle).

Input
参数Param类型Type说明Description
WorldContextconst UObject*世界上下文。World context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:命令缓冲收到移除命令。

No return value. Side effect: the command buffer receives the remove command.

RemoveEntitySubTypeTagByIndexDeferredContext static void

处理器上下文版:经 Context.Defer().RemoveTag<FSubTypeN>(EntityHandle) 延迟移除。

Processor-context version: defers the remove via Context.Defer().RemoveTag<FSubTypeN>(EntityHandle).

Input
参数Param类型Type说明Description
ContextFMassExecutionContext&Mass 执行上下文。Mass execution context.
Indexint32子类型索引 [0, 255]。Subtype index [0, 255].
EntityHandleFEntityHandle目标实体。Target entity.
Output

无返回值。副作用:上下文命令缓冲收到移除命令。

No return value. Side effect: the context's command buffer receives the remove command.

管线角色Pipeline Role

本类不持有状态,由各调用方直接使用:Fragments/Team.h 与 Fragments/SubType.h 定义了 tag 模板族(0-255);FMassBattleFuncLib::SetAgentTeam / SetAgentSubType 使用同族 tag(经 FTeam.index / FSubType.Index fragment 交换)。处理器内部如需按索引操作 tag,应使用 *DeferredContext 变体(直接使用当前执行上下文的命令缓冲,零解析开销)。

This class holds no state and is used directly by callers: Fragments/Team.h and Fragments/SubType.h define the tag template families (0-255); FMassBattleFuncLib::SetAgentTeam / SetAgentSubType use the same tag family (swapped via the FTeam.index / FSubType.Index fragments). Processors that need index-based tag operations inside a section should use the *DeferredContext variants (which use the current execution context's command buffer directly, zero resolution overhead).