MassBattle Docsv1.19.20

UMassAPISubsystem

UCLASS WorldSubsystem

Source/MassAPI/Public/MassAPISubsystem.h

概述 Overview

MassEntity 框架的便捷 API 子系统(UMassTickableSubsystemBase 派生),包装常见实体操作为统一入口:实体构建/销毁(立即与延迟两条路径)、存在性检查(Tag/Fragment/Chunk/Shared/ConstShared 的模板与非模板版本)、模板数据读写(Has/Get/Set/Add/Remove/Merge/Clone)、查询匹配(composition 与旗标位掩码)与128 位旗标操作(枚举与 FName 双通道)。持有子系统自有的持久命令缓冲 SharedCommandBuffer(仅限 processor 上下文之外使用;processor 内请用 Context.Defer()),每 tick 由 Tick 刷新。实体管理器经 GetEntityManager() 惰性解析并缓存。

Convenience API subsystem for the MassEntity framework (derived from UMassTickableSubsystemBase), wrapping common entity operations into one entry point: entity build/destroy (immediate and deferred paths), presence checks (template and non-template variants for Tag/Fragment/Chunk/Shared/ConstShared), template-data reads/writes (Has/Get/Set/Add/Remove/Merge/Clone), query matching (composition and flag bitmasks) and 128-bit flag operations (both enum and FName channels). It owns a persistent command buffer SharedCommandBuffer (outside processor contexts only; inside processors use Context.Defer()), flushed every tick by Tick. The entity manager is lazily resolved and cached via GetEntityManager().

继承 Inheritance

UMassTickableSubsystemBase → UMassAPISubsystem

公开方法 Public Methods

Initialize virtual void

子系统生命周期入口。实现(MassAPISubsystem.cpp):调用父类、声明 UMassEntitySubsystem 依赖(InitializeDependency)、触发 GetEntityManager() 惰性缓存、创建 SharedCommandBuffer,并输出初始化日志。

Subsystem lifecycle entry. Implementation (MassAPISubsystem.cpp): calls the parent, declares the UMassEntitySubsystem dependency (InitializeDependency), triggers the GetEntityManager() lazy cache, creates SharedCommandBuffer, and logs initialization.

Input
参数 Param类型 Type说明 Description
CollectionFSubsystemCollectionBase&子系统集合,由引擎传入。Subsystem collection provided by the engine.
Output

无返回值。副作用:初始化 EntityManager 缓存与共享命令缓冲。

No return value. Side effects: initializes the EntityManager cache and the shared command buffer.

Deinitialize virtual void

子系统生命周期出口。释放缓冲区前先向 EntityManager FlushCommands 剩余命令,然后重置全部缓存指针并调用父类,输出日志。

Subsystem lifecycle exit. Flushes remaining commands to the EntityManager before releasing the buffer, then resets all cached pointers, calls the parent, and logs.

Input

无参数。

No parameters.

Output

无返回值。副作用:刷新并释放共享命令缓冲,清空 EntityManager/World 缓存。

No return value. Side effects: flushes and releases the shared command buffer, clears the EntityManager/World caches.

Tick virtual void

每帧 tick 入口。实现:TRACE_CPUPROFILER_EVENT_SCOPE_STR("MassAPISubsystemTick");若 EntityManager 可用则调用 FlushCommandBuffer() 刷新共享命令缓冲。

Per-frame tick entry. Implementation: TRACE_CPUPROFILER_EVENT_SCOPE_STR("MassAPISubsystemTick"); flushes the shared command buffer via FlushCommandBuffer() when the EntityManager is available.

Input
参数 Param类型 Type说明 Description
DeltaTimefloat本帧时间步长(秒),当前未被使用。Frame delta time in seconds; currently unused.
Output

无返回值。副作用:刷新共享命令缓冲中的延迟命令。

No return value. Side effect: flushes deferred commands in the shared command buffer.

GetStatId virtual TStatId (const)

UTickableWorldSubsystem 要求的 profiling 统计 ID,RETURN_QUICK_DECLARE_CYCLE_STAT 生成。

The profiling stat ID required by UTickableWorldSubsystem, produced by RETURN_QUICK_DECLARE_CYCLE_STAT.

Input

无参数。

No parameters.

Output

返回 TStatId。

Returns the TStatId.

GetPtr static UMassAPISubsystem* (×2 重载)

静态访问器。无参版本取 GWorld 的子系统;WorldContext 版本经 GEngine->GetWorldFromContextObject 解析世界。世界无效时返回 nullptr(不崩溃)。

Static accessor. The no-arg version fetches the subsystem from GWorld; the WorldContext version resolves the world via GEngine->GetWorldFromContextObject. Returns nullptr when the world is invalid (does not crash).

Input
参数 Param类型 Type说明 Description
WorldContextconst UObject*任意 UObject 世界上下文(可选重载)。Any UObject world context (optional overload).
Output

返回子系统指针;世界不可用时返回 nullptr。

Returns the subsystem pointer, or nullptr when the world is unavailable.

GetRef static UMassAPISubsystem& (×2 重载)

静态访问器的引用版本:失败即 checkf 断言崩溃——用于「子系统必须存在」的不变式场景。

Reference version of the static accessor: fails via checkf assertion — for invariant paths where the subsystem must exist.

Input
参数 Param类型 Type说明 Description
WorldContextconst UObject*任意 UObject 世界上下文(可选重载)。Any UObject world context (optional overload).
Output

返回子系统引用;取不到时触发 checkf 断言。

Returns a subsystem reference; triggers a checkf assertion when unavailable.

GetEntityManager FMassEntityManager* (const)

惰性获取实体管理器,任何函数(含 const)都可安全调用。缓存命中直接返回;否则依次解析 CurrentWorld(GetWorld())→ UMassEntitySubsystem → GetMutableEntityManager(),全部写入 mutable 缓存成员。取不到时返回 nullptr。

Lazily gets the entity manager; safe to call from any function, including const ones. Fast path returns the cache; otherwise resolves CurrentWorld (GetWorld()) → UMassEntitySubsystem → GetMutableEntityManager(), writing all into mutable cache members. Returns nullptr when unavailable.

Input

无参数。

No parameters.

Output

返回 FMassEntityManager*(可能为 nullptr)。副作用:填充三个缓存成员。

Returns the FMassEntityManager* (may be nullptr). Side effect: fills the three cache members.

Defer FORCEINLINE FMassCommandBuffer& (const)

取子系统自有的延迟命令缓冲 SharedCommandBuffer。警告(源码注释):仅限 processor 上下文之外使用;processor 内请用 Context.Defer()。未初始化时 checkf 断言。

Returns the subsystem-owned deferred command buffer SharedCommandBuffer. WARNING (source comment): use outside processor contexts only; inside processors use Context.Defer(). Asserts via checkf when not initialized.

Input

无参数。

No parameters.

Output

返回共享命令缓冲引用;由 FlushCommandBuffer() 刷新。

Returns the shared command buffer reference; flushed by FlushCommandBuffer().

GetSharedCommandBuffer TSharedPtr<FMassCommandBuffer> (const)

取 API 拥有的持久命令缓冲的共享指针。

Returns the shared pointer to the API-owned persistent command buffer.

Input

无参数。

No parameters.

Output

返回 TSharedPtr<FMassCommandBuffer>。

Returns the TSharedPtr<FMassCommandBuffer>.

FlushCommandBuffer void

把 API 拥有的命令缓冲刷新到实体管理器。实现:EntityManager 与 SharedCommandBuffer 均可用时调用 EM->FlushCommands(SharedCommandBuffer)。所有 Defer() 操作后应调用它。

Flushes the API-owned command buffer to the entity manager. Implementation: calls EM->FlushCommands(SharedCommandBuffer) when both the EntityManager and SharedCommandBuffer are available. Call it after all Defer() ops for the current phase.

Input

无参数。

No parameters.

Output

无返回值。副作用:执行并清空共享命令缓冲。

No return value. Side effect: executes and clears the shared command buffer.

FlushTickCommands void

FlushCommandBuffer 的废弃别名(源码注释标注),直接委托。

Deprecated alias for FlushCommandBuffer (per source comment); delegates directly.

Input

无参数。

No parameters.

Output

无返回值,副作用同 FlushCommandBuffer。

No return value; same side effects as FlushCommandBuffer.

HasAll / HasAny FORCEINLINE static bool

composition 过滤:HasAll = A 包含 B 的全部;HasAny = A 包含 B 的任一。经 HAS_ALL/ANY_COMPOSITION 版本宏实现。

Composition filters: HasAll = A contains all of B; HasAny = A contains any of B. Implemented via the HAS_ALL/ANY_COMPOSITION version macros.

Input
参数 Param类型 Type说明 Description
ThisCompositionconst FMassArchetypeCompositionDescriptor&被检查的 composition。The composition being inspected.
OtherCompositionconst FMassArchetypeCompositionDescriptor&查询要求的 composition。The query requirement composition.
Output

返回布尔匹配结果。

Returns the boolean match result.

MatchQueryAll / MatchQueryAny / MatchQueryNone / MatchQuery(Composition) FORCEINLINE static bool

按 FEntityQuery 的单个条件匹配 composition:MatchQueryAll 仅 All 条件(列表为空自动通过);MatchQueryAny 仅 Any; MatchQueryNone 仅 None;四参 MatchQuery 为三者 AND 组合。

Matches a composition against a single condition of an FEntityQuery: MatchQueryAll checks All only (empty list auto-passes); MatchQueryAny Any only; MatchQueryNone None only; the four-arg MatchQuery ANDs all three.

Input
参数 Param类型 Type说明 Description
Compositionconst FMassArchetypeCompositionDescriptor&被检查的 composition。The composition being inspected.
Queryconst FEntityQuery&查询规则。The query rules.
Output

返回布尔匹配结果;对应列表为空时该条件自动通过。

Returns the boolean match result; an empty list auto-passes its condition.

MatchQueryComposition FORCEINLINE bool (const)

按实体的 archetype 句柄取 composition,再执行 All/Any/None 三条件 AND 匹配。EntityManager 不可用时 checkf 断言。

Fetches the composition from the entity's archetype handle, then ANDs the All/Any/None conditions. Asserts via checkf when the EntityManager is unavailable.

Input
参数 Param类型 Type说明 Description
ArchetypeHandleconst FMassArchetypeHandle要检查的实体的原型句柄。Archetype handle of the entity to check.
Queryconst FEntityQuery&要匹配的查询。The query to match.
Output

composition 匹配返回 true,否则 false。

Returns true when the composition matches, false otherwise.

MatchQueryFlag FORCEINLINE bool (const)

按实体的 FEntityFlagFragment 匹配查询的旗标条件:六个位掩码缓存全零时直接通过;否则读取实体的低位/高位旗标,All 要求低位与高位都全覆盖、Any 要求任一端命中、None 要求两端全无。实体无旗标 fragment 时按 0 处理。

Matches an entity's flag conditions against its FEntityFlagFragment: passes immediately when all six cached bitmasks are zero; otherwise reads the entity's low/high flags — All requires full coverage on both ends, Any requires a hit on either end, None requires none on either. Entities without the flag fragment are treated as 0.

Input
参数 Param类型 Type说明 Description
EntityHandleFEntityHandle要检查的实体句柄。The entity handle to check.
Queryconst FEntityQuery&要匹配的查询。The query to match.
Output

旗标条件匹配返回 true,否则 false。

Returns true when the flag conditions match, false otherwise.

MatchQuery(EntityHandle) FORCEINLINE bool (const)

完整逐实体匹配(composition + 旗标):先查实体活跃与 archetype 有效,再依次 MatchQueryComposition 与 MatchQueryFlag。

Full per-entity match (composition + flags): first checks the entity is active and its archetype valid, then runs MatchQueryComposition and MatchQueryFlag in order.

Input
参数 Param类型 Type说明 Description
EntityHandleFEntityHandle要检查的实体句柄。The entity handle to check.
Queryconst FEntityQuery&要匹配的查询。The query to match.
Output

完整匹配返回 true;实体不活跃/archetype 无效返回 false。

Returns true on a full match; false for inactive entities or invalid archetypes.

MatchQueryCompositionAndFlags FORCEINLINE bool (const)

逐实体完整 composition + 旗标匹配(All/Any/None)。源码注释说明:聚合级(block/cell)composition 是并集,只能剪掉「必不可能」的单元,永远不能确认实体匹配 All 或按 None 排除,因此必须保留此完整逐实体检查。该版本供 trace 收集热循环使用,有意省略 IsValid(grid 每帧从活实体重建,消费方会重新校验)。

Per-entity FULL composition + flags match (All/Any/None). Source comments explain that aggregation-level (block/cell) composition is a UNION that can only prune "impossible" cells — it can never confirm an entity matches All nor exclude by None, so this full per-entity check is required for correctness. This version is for the trace gather hot loop and intentionally skips IsValid (the grid is rebuilt from live entities every frame; consumers re-validate).

Input
参数 Param类型 Type说明 Description
EntityHandleFEntityHandle要检查的实体句柄。The entity handle to check.
Queryconst FEntityQuery&要匹配的查询。The query to match.
Output

完整匹配返回 true;否则 false。

Returns true on a full match, false otherwise.

IsValid FORCEINLINE bool (const)

运行时实体句柄检查:EntityManager 的 IsEntityValid 且 IsEntityBuilt 同时为真。EntityManager 不可用时 checkf 断言。

Runtime entity handle check: true when the EntityManager reports both IsEntityValid and IsEntityBuilt. Asserts via checkf when the EntityManager is unavailable.

Input
参数 Param类型 Type说明 Description
EntityHandleFEntityHandle要检查的句柄。The handle to check.
Output

有效且已 build 返回 true。

Returns true when valid and built.

ReserveEntity FORCEINLINE FMassEntityHandle (const)

立即预留实体句柄但不创建数据——在实体完全构建前需要一个可引用的句柄时使用。预留实体保持非活跃,直到调用 BuildEntity。EntityManager 不可用时 checkf 断言。

Reserves an entity handle without creating its data immediately — useful when you need a referenceable handle before the entity is fully constructed. The reserved entity stays inactive until BuildEntity is called. Asserts via checkf when the EntityManager is unavailable.

Input

无参数。

No parameters.

Output

返回预留的非活跃 FMassEntityHandle。

Returns a reserved, inactive FMassEntityHandle.

BuildEntities(模板) / BuildEntity(模板) TArray<FMassEntityHandle> / FMassEntityHandle (const)

用模板立即构建实体。实现(MassAPISubsystem.cpp):Quantity <= 0 直接返回空;对模板 Sort() 后 CreateArchetype(失败返回空)、BatchCreateEntities、再批量写入初值——5.6+ 经 BatchSetEntityFragmentValues,≤5.5 经 MassAPIImpl::ApplyInitialFragmentValuesBatch 逐实体结构体拷贝。BuildEntity 委托 BuildEntities(1, …) 取首元素,失败返回默认(空)句柄。

Immediately builds entities from a template. Implementation (MassAPISubsystem.cpp): returns empty for Quantity <= 0; Sort()s the template, CreateArchetypes (empty on failure), BatchCreateEntities, then batched initial-value writes — via BatchSetEntityFragmentValues on 5.6+, or per-entity struct copies through MassAPIImpl::ApplyInitialFragmentValuesBatch on ≤5.5. BuildEntity delegates to BuildEntities(1, …) and takes the first element, returning a default (empty) handle on failure.

Input
参数 Param类型 Type说明 Description
Quantityint32实体数量(≤0 直接返回空)。Number of entities (≤0 returns empty).
TemplateDataFMassEntityTemplateData&定义 archetype 与初值的模板。Template defining the archetype and initial values.
Output

返回已 build 的实体句柄数组(或单个句柄);失败返回空数组 / 空句柄。副作用:创建/复用 archetype、消耗实体槽位。

Returns built entity handles (array or single); empty on failure. Side effects: creates/reuses archetypes, consumes entity slots.

BuildEntities<TArgs...>(variadic) / BuildEntity<TArgs...> template TArray<FMassEntityHandle> / FORCEINLINE FMassEntityHandle (const)

变参立即构建:参数按类型自动分派——Tag 进标签位集;Fragment 进位集并收集初值;SharedFragment / ConstSharedFragment 经 GetOrCreateSharedFragment(值) 去重后进入共享值。随后 CreateArchetype(失败记警告日志并返回空)、BatchCreateEntities、批量写初值。用法:BuildEntities(10, FEnemyTag{}, FHealthFragment{100.0f}, FTeamSharedFragment{1})。不支持的类型触发编译期 static_assert。单实体版本取数组首元素。

Variadic immediate build: arguments auto-dispatch by type — Tags into the tag bit set; Fragments into the bit set with collected initial values; SharedFragment / ConstSharedFragment deduped via GetOrCreateSharedFragment(value) into shared values. Then CreateArchetype (warning log + empty on failure), BatchCreateEntities, and batched initial-value writes. Usage: BuildEntities(10, FEnemyTag{}, FHealthFragment{100.0f}, FTeamSharedFragment{1}). Unsupported types fail a compile-time static_assert. The single-entity version takes the array's first element.

Input
参数 Param类型 Type说明 Description
Quantityint32实体数量(≤0 返回空)。Entity count (≤0 returns empty).
ArgsTArgs&&...混合的 Tag 类型、Fragment 值与 SharedFragment/ConstSharedFragment 值。Mixed tag types, fragment values and shared/const-shared fragment values.
Output

返回已 build 实体句柄数组(或单个);archetype 创建失败返回空数组 / 空句柄。

Returns built handles (array or single); empty on archetype creation failure.

BuildEntitiesDefer(×2 重载) void (const)

延迟批量构建(Context 与 CommandBuffer 两个重载):立即 BatchReserveEntities 并把预留句柄追加进 OutEntities,随后向命令缓冲压入一条 FMassDeferredCreateCommand,刷新时创建 archetype(失败释放全部预留)、BatchCreateReservedEntities 构建、批量写初值。

Deferred batch build (Context and CommandBuffer overloads): immediately BatchReserveEntities and append the reserved handles to OutEntities, then push one FMassDeferredCreateCommand; on flush it creates the archetype (releasing all reservations on failure), BatchCreateReservedEntities, and batched initial-value writes.

Input
参数 Param类型 Type说明 Description
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&命令来源(processor 上下文或裸缓冲)。Command source (processor context or raw buffer).
Quantityint32实体数量。Entity count.
TemplateDataFMassEntityTemplateData&定义 archetype 与初值的模板。Template defining the archetype and initial values.
OutEntitiesTArray<FMassEntityHandle>&追加预留句柄的输出数组。Output array receiving the reserved handles.
Output

无返回值。副作用:OutEntities 被追加;缓冲刷新前实体保持非活跃。

No return value. Side effects: OutEntities appended; entities stay inactive until the buffer flushes.

BuildEntityDefer(×4 重载) FORCEINLINE FMassEntityHandle (const)

延迟构建单实体。模板版本:立即 ReserveEntity,快照 composition/初值后压入 FMassDeferredCreateCommand(刷新时创建 archetype、失败 ReleaseReservedEntity、BuildEntity、写初值),返回预留句柄。变参版本:先构建临时 FMassEntityTemplateData(Tag 用 AddTag,Fragment 用 AddFragment 值),再委托模板版本——使全部 fragment+tag 合并为一条原子创建命令。Context 版本委托 Context.Defer()。

Deferred single-entity build. Template versions: immediately ReserveEntity, snapshot composition/initial values, push a FMassDeferredCreateCommand (on flush: create archetype, ReleaseReservedEntity on failure, BuildEntity, write initial values), return the reserved handle. The variadic version builds a temporary FMassEntityTemplateData first (Tags via AddTag, Fragments via AddFragment value), then delegates to the template version — so ALL fragments+tags land in ONE atomic create command. The Context version delegates via Context.Defer().

Input
参数 Param类型 Type说明 Description
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&命令来源。Command source.
TemplateDataFMassEntityTemplateData&模板(可选,变参版本无)。Template (optional; absent in the variadic version).
ArgsTArgs&&...变参版本:fragment 实例与/或 tag 类型。Variadic version: fragment instances and/or tag types.
Output

返回预留的 FMassEntityHandle;缓冲刷新前实体不活跃。

Returns the reserved FMassEntityHandle; the entity is inactive until the buffer flushes.

DestroyEntity / DestroyEntityDefer(×2) FORCEINLINE void (const)

立即销毁(DestroyEntity):实体不活跃则直接返回,否则 Manager->DestroyEntity。延迟版本把 DestroyEntity 命令压入 Context/CommandBuffer,刷新时执行。

Immediate destroy (DestroyEntity): returns when the entity is inactive, otherwise Manager->DestroyEntity. The deferred versions push a DestroyEntity command into the Context/CommandBuffer, executed on flush.

Input
参数 Param类型 Type说明 Description
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&延迟版本的命令来源。Deferred versions' command source.
EntityHandleFMassEntityHandle要销毁的实体。The entity to destroy.
Output

无返回值。副作用:实体被销毁(立即或延迟)。

No return value. Side effect: the entity is destroyed (immediately or deferred).

FindConstSharedFragmentInTemplate / FindSharedFragmentInTemplate template static const T* / T*

从 FMassEntityTemplateData 的共享值中按类型取回常量共享 / 可变共享 fragment 指针。用于 spawn 时缓存模板中的值,而不经过逐实体 fragment 槽(如注册为 const-shared 且故意无逐实体对应物的 fragment)。未找到返回 nullptr。

Pulls a const-shared / mutable shared fragment pointer of type T back out of a FMassEntityTemplateData's shared values. Useful when caching values from a template at spawn-time without going through the per-agent fragment slot (e.g. fragments registered as const-shared with no per-agent counterpart). Returns nullptr when absent.

Input
参数 Param类型 Type说明 Description
Tmplconst FMassEntityTemplateData&要查找的模板数据。Template data to search.
Output

返回类型 T 的值指针;模板不携带该类型时返回 nullptr。

Returns a pointer to the stored value, or nullptr when the template carries no T.

ReplaceConstSharedFragmentInTemplate template static void

在 FMassEntityTemplateData 内替换(或新增)类型 T 的 const-shared fragment:从零重建模板,复制全部 tag/fragment/共享值(跳过既有 T),再经 EntityManager 的 const-shared 去重存储加入新值。用于每次 spawn 需要微调(如把 ScaleMult 烘焙进 RenderShared.Transform)且后续 spawn 管线仍从该 SharedTemplate 副本读取的场景。保留模板名以维持调试一致性。

Replaces (or adds) a const-shared fragment of type T inside a FMassEntityTemplateData: rebuilds the template from scratch, copying every tag/fragment/shared value except any pre-existing T, then dedupes the new value through the entity manager's const-shared store. For per-spawn tweaks (e.g. ScaleMult baked into RenderShared.Transform) that must land on a SharedTemplate copy the rest of the spawn pipeline still reads from. Carries over the template name for debug parity.

Input
参数 Param类型 Type说明 Description
TemplateFMassEntityTemplateData&被修改的模板(原地覆写为重建结果)。Template being modified (overwritten in place with the rebuilt result).
NewValueconst T&新 const-shared 值。The new const-shared value.
EntityManagerFMassEntityManager&用于 const-shared 去重存储。Provides the const-shared dedup store.
Output

无返回值。副作用:模板被整体重建,原模板数据被移动替换。

No return value. Side effect: the template is fully rebuilt and move-replaced.

HasTag / HasFragment / HasChunkFragment / HasSharedFragment / HasConstSharedFragment FORCEINLINE bool (const, 模板与非模板 ×2)

存在性检查家族:模板版本要求 static_assert 类型正确(CTag/CFragment/CChunkFragment/CSharedFragment/CConstSharedFragment);非模板版本接受 const UScriptStruct*(可为 null,蓝图中类型为变量时使用)。实现均取实体 archetype 的 composition,经 CONTAINS_* 版本宏检查对应位集;archetype 无效返回 false。所有版本在 EntityManager 不可用时 checkf 断言。

Presence-check family: template versions static_assert the type (CTag/CFragment/CChunkFragment/CSharedFragment/CConstSharedFragment); non-template versions take a const UScriptStruct* (nullable; for when the type is a variable, e.g. from Blueprints). Implementations fetch the entity's archetype composition and check the matching bit set via the CONTAINS_* version macros; invalid archetypes return false. All versions checkf-assert when the EntityManager is unavailable.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要检查的实体。The entity to check.
TagType / FragmentType / …const UScriptStruct* 或模板参数要检查的类型(非模板版本)。The type to check (non-template versions).
Output

实体包含该类型返回 true,否则 false(archetype 无效亦为 false)。

Returns true when the entity has the type, false otherwise (invalid archetype included).

GetFragment / GetFragmentPtr / GetFragmentRef template FORCEINLINE T / T* / T& (const)

按值拷贝 / 指针 / 引用三种取 fragment 的方式。值与引用版本在实体缺该 fragment 时 checkf 断言;指针版本未找到返回 nullptr。全部经 Manager->GetFragmentDataPtr<T>。

Three ways to fetch a fragment: by value, by pointer, by reference. The value and reference versions checkf-assert when the entity lacks the fragment; the pointer version returns nullptr. All go through Manager->GetFragmentDataPtr<T>.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要读取的实体。The entity to read from.
Output

值版本返回拷贝(断言存在);指针版本返回指针或 nullptr;引用版本返回引用(断言存在)。

Value returns a copy (asserts existence); pointer returns a pointer or nullptr; reference returns a reference (asserts existence).

GetSharedFragment / GetSharedFragmentPtr / GetSharedFragmentRef template FORCEINLINE T / T* / T& (const)

可变共享 fragment 的取值三件套,经 Manager->GetSharedFragmentDataPtr<T>;值/引用版本缺失时 checkf 断言,指针版本返回 nullptr。

Value/pointer/reference fetch trio for mutable shared fragments via Manager->GetSharedFragmentDataPtr<T>; value/reference assert on absence, pointer returns nullptr.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要读取的实体。The entity to read from.
Output

同 fragment 版本语义(拷贝 / 指针或 nullptr / 引用)。

Same semantics as the fragment versions (copy / pointer or nullptr / reference).

GetConstSharedFragment / GetConstSharedFragmentPtr / GetConstSharedFragmentRef template FORCEINLINE T / const T* / const T& (const)

常量共享 fragment 的取值三件套,经 Manager->GetConstSharedFragmentDataPtr<T>;值/引用版本缺失时 checkf 断言,指针版本返回 nullptr。

Value/pointer/reference fetch trio for const-shared fragments via Manager->GetConstSharedFragmentDataPtr<T>; value/reference assert on absence, pointer returns nullptr.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要读取的实体。The entity to read from.
Output

同 fragment 版本语义。

Same semantics as the fragment versions.

AddTag(×3 重载) template FORCEINLINE void (const)

向实体添加 tag:立即版本 Manager->AddTagToEntity;Context 版本压入 Context.Defer().AddTag<T>;CommandBuffer 版本 CommandBuffer.AddTag<T>。processor 内使用安全。

Adds a tag to an entity: immediate via Manager->AddTagToEntity; Context version pushes Context.Defer().AddTag<T>; CommandBuffer version CommandBuffer.AddTag<T>. Safe inside processors.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&延迟版本的命令来源。Deferred versions' command source.
Output

无返回值。副作用:实体获得 tag(立即或刷新时生效)。

No return value. Side effect: the entity gains the tag (immediately or on flush).

AddFragment(×5 重载) template FORCEINLINE void (const)

向实体添加 fragment:立即版本经 AddFragmentInstanceListToEntity(FInstancedStruct 或值两种签名;已有该 fragment 时引擎记警告并忽略,原值不变);延迟版本 Context/CommandBuffer 各带默认值或指定值两种——带值版本压入 FMassCommandAddFragmentInstances。

Adds a fragment to an entity: immediate versions via AddFragmentInstanceListToEntity (taking either an FInstancedStruct or a value; when the entity already has the fragment the engine logs a warning and ignores, keeping the old value); deferred versions on Context/CommandBuffer with default or explicit value — the value versions push FMassCommandAddFragmentInstances.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
FragmentStruct / FragmentValueconst FInstancedStruct& / const T&fragment 类型与初值。Fragment type and initial value.
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&延迟版本的命令来源。Deferred versions' command source.
Output

无返回值。副作用:实体获得 fragment(重复添加被忽略并记警告)。

No return value. Side effect: the entity gains the fragment (duplicates ignored with a warning).

AddSharedFragment / AddConstSharedFragment template FORCEINLINE bool (const)

立即添加共享/常量共享 fragment:先经 MASSAPI_GET_OR_CREATE_SHARED 版本宏去重,再 AddSharedFragmentToEntity(或 const 版本)。返回引擎的添加结果——实体已持有不同值的同类 fragment 时返回 false。版本差异:5.6+ 走引擎实体级添加 API;≤5.5 引擎无实体级共享片段添加,AddSharedFragment 记警告日志(共享片段须在 build/模板时提供)并返回 false,AddConstSharedFragment 同样返回 false;后者整个函数在 UE 5.4 被编出(5.5+ 守卫)。

Immediately adds a shared / const-shared fragment: dedupes via the MASSAPI_GET_OR_CREATE_SHARED version macro, then AddSharedFragmentToEntity (or the const version). Returns the engine's add result — false when the entity already holds the same kind with a different value. Version notes: 5.6+ uses the engine's entity-level add APIs; on ≤5.5 the engine has no entity-level shared-fragment addition — AddSharedFragment logs a warning (shared fragments must be provided at build/template time) and returns false, and AddConstSharedFragment likewise returns false; the latter is compiled out entirely on UE 5.4 (5.5+ guard).

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
SharedFragmentValue / ConstSharedFragmentValueconst T&共享 fragment 值。The shared fragment value.
Output

返回是否成功添加(实体已持有不同值时为 false)。

Returns whether the add succeeded (false when the entity already holds a different value).

RemoveTag(×3 重载) template FORCEINLINE void (const)

从实体移除 tag:立即版本 Manager->RemoveTagFromEntity;Context / CommandBuffer 版本压入延迟命令。

Removes a tag from an entity: immediate via Manager->RemoveTagFromEntity; Context / CommandBuffer versions push deferred commands.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&延迟版本的命令来源。Deferred versions' command source.
Output

无返回值。副作用:实体失去 tag。

No return value. Side effect: the entity loses the tag.

RemoveFragment(×4 重载) FORCEINLINE void / bool (const)

从实体移除 fragment:模板立即版本 Manager->RemoveFragmentFromEntity;非模板立即版本(供 BP)先校验类型非空且是 FMassFragment 派生,非法返回 false,合法调用后返回 true;两个延迟版本压入命令。

Removes a fragment from an entity: template immediate via Manager->RemoveFragmentFromEntity; non-template immediate (for BP) validates the type is non-null and derived from FMassFragment, returning false when invalid; the two deferred versions push commands.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
FragmentTypeUScriptStruct*非模板版本的 fragment 类型。Fragment type for the non-template version.
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&延迟版本的命令来源。Deferred versions' command source.
Output

模板与延迟版本无返回值;非模板版本返回是否已调用移除。

Template and deferred versions return void; the non-template version returns whether removal was invoked.

RemoveSharedFragment / RemoveConstSharedFragment(各 ×2 重载) FORCEINLINE bool (const)

从实体移除共享/常量共享 fragment,经 ENTITY_MANAGER_REMOVE_SHARED / REMOVE_CONST_SHARED 版本宏调用引擎 API。非模板版本校验类型非空且派生正确,非法返回 false。≤5.5 引擎无实体级共享片段移除 API,宏退化为「未移除」(false);RemoveConstSharedFragment 整体为 5.5+(UE 5.4 编出)。

Removes shared / const-shared fragments via the ENTITY_MANAGER_REMOVE_SHARED / REMOVE_CONST_SHARED version macros. Non-template versions validate the type is non-null and properly derived, returning false when invalid. On ≤5.5 the engine has no entity-level shared-fragment removal API, so the macros degrade to "not removed" (false); RemoveConstSharedFragment as a whole is 5.5+ (compiled out on UE 5.4).

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
SharedFragmentType / ConstSharedFragmentTypeconst UScriptStruct*非模板版本的类型。Type for the non-template version.
Output

返回引擎移除结果(实体无该类型或非法输入为 false)。

Returns the engine removal result (false when the entity lacks the type or input is invalid).

SwapTags(×2 重载) template FORCEINLINE void (const)

延迟交换 tag:Context / CommandBuffer 版本分别 Context.Defer().SwapTags<TOld, TNew> 与 CommandBuffer.SwapTags<TOld, TNew>。两个模板参数均 static_assert 必须是 tag。

Deferred tag swap: Context / CommandBuffer versions call Context.Defer().SwapTags<TOld, TNew> and CommandBuffer.SwapTags<TOld, TNew> respectively. Both template parameters are static_asserted to be tags.

Input
参数 Param类型 Type说明 Description
Context 或 CommandBufferFMassExecutionContext& / FMassCommandBuffer&命令来源。Command source.
EntityHandleFMassEntityHandle目标实体。Target entity.
Output

无返回值。副作用:刷新时旧 tag 移除、新 tag 添加。

No return value. Side effect: old tag removed and new tag added on flush.

Has* (Template 数据, static ×5) template FORCEINLINE static bool

模板数据存在性检查:HasTag 遍历 GetTags().ExportTypes 比对;其余四个(HasFragment / HasChunkFragment / HasSharedFragment / HasConstSharedFragment)经 CONTAINS_T_* 版本宏检查模板 composition。

Template-data presence checks: HasTag walks GetTags().ExportTypes comparing types; the other four (HasFragment / HasChunkFragment / HasSharedFragment / HasConstSharedFragment) check the template composition via the CONTAINS_T_* version macros.

Input
参数 Param类型 Type说明 Description
Tmplconst FMassEntityTemplateData&要检查的模板。Template to check.
Output

模板包含该类型返回 true。

Returns true when the template contains the type.

Get* (Template 数据, static ×6) template FORCEINLINE static T / T* / T& / const T*

模板取值家族:GetFragment 在初值列表中按类型查找并拷贝,缺失 checkf 断言(提示先 HasFragment 或改用指针版本);GetFragmentPtr / GetFragmentRef 经 GetMutableFragment<T>(指针缺失返回 nullptr,引用缺失断言);GetSharedFragment / GetConstSharedFragment 经模板查找函数,缺失断言;两个 Ptr 版本缺失返回 nullptr。

Template value family: GetFragment finds the type in the initial values and copies, checkf-asserting on absence (hinting to use HasFragment first or the pointer version); GetFragmentPtr / GetFragmentRef go through GetMutableFragment<T> (pointer returns nullptr, reference asserts); GetSharedFragment / GetConstSharedFragment use the template lookup helpers, asserting on absence; the two Ptr versions return nullptr.

Input
参数 Param类型 Type说明 Description
Tmplconst FMassEntityTemplateData& / FMassEntityTemplateData&要读取的模板(指针/引用版本需要可变)。Template to read (mutable for pointer/reference versions).
Output

值版本返回拷贝(缺失断言);指针版本返回指针或 nullptr;引用版本返回引用(缺失断言)。

Value versions return copies (assert on absence); pointer versions return pointers or nullptr; the reference version returns a reference (asserts on absence).

SetFragment / SetSharedFragment / SetConstSharedFragment (Template, static ×3) template FORCEINLINE static void

模板写值家族:SetFragment 存在则覆写、不存在则 AddFragment 添加;SetSharedFragment / SetConstSharedFragment 为写时复制——从零重建模板、跳过旧 T、经 Manager 去重后添加新值,再整体移动替换。

Template value-write family: SetFragment overwrites when present, adds via AddFragment otherwise; SetSharedFragment / SetConstSharedFragment are copy-on-write — rebuild the template from scratch, skip the old T, add the new value deduped through the Manager, then move-replace the whole template.

Input
参数 Param类型 Type说明 Description
TmplFMassEntityTemplateData&被修改的模板。Template being modified.
Valueconst T&要写入的值。Value to write.
MgrFMassEntityManager&共享版本的去重存储。Dedup store for the shared versions.
Output

无返回值。副作用:模板被修改(共享版本整体重建)。

No return value. Side effects: the template is modified (shared versions fully rebuilt).

Add* (Template, static ×5) template FORCEINLINE static void

模板追加家族:AddTag 仅类型;AddFragment 默认值或带值两种;AddSharedFragment / AddConstSharedFragment 经 Manager 去重后添加。已存在时按引擎语义处理。

Template append family: AddTag type only; AddFragment with default or explicit value; AddSharedFragment / AddConstSharedFragment dedupe through the Manager before adding.

Input
参数 Param类型 Type说明 Description
TmplFMassEntityTemplateData&被修改的模板。Template being modified.
Valueconst T&带值版本的初值。Initial value for the value versions.
MgrFMassEntityManager&共享版本的去重存储。Dedup store for the shared versions.
Output

无返回值。副作用:模板获得该元素。

No return value. Side effect: the template gains the element.

Remove* (Template, static ×5) template FORCEINLINE static void

模板移除家族,全部写时复制:从零重建并跳过目标类型。Tag 版本跳过 GetTags 中匹配项;Fragment 版本跳过 composition 与初值中的匹配项;共享版本跳过共享值中的匹配项。

Template removal family, all copy-on-write: rebuild from scratch skipping the target type. The tag version skips matching entries in GetTags; the fragment version skips matches in both composition and initial values; the shared versions skip matches in the shared values.

Input
参数 Param类型 Type说明 Description
TmplFMassEntityTemplateData&被修改的模板。Template being modified.
Output

无返回值。副作用:模板被整体重建并失去该元素。

No return value. Side effect: the template is rebuilt without the element.

MergeTemplate template FORCEINLINE static void

把额外的 tag/fragment 合并进模板数据:Tag 走 AddTag,Fragment 走带值 AddFragment;共享 fragment 需 EntityManager,不支持——源码注释说明请直接用 AddSharedFragment。其它类型触发 static_assert。

Merges additional tags/fragments into template data: Tags via AddTag, Fragments via value AddFragment; shared fragments need an EntityManager and are unsupported — use AddSharedFragment directly per the source comment. Other types fail a static_assert.

Input
参数 Param类型 Type说明 Description
TmplFMassEntityTemplateData&被合并的模板。Template being merged into.
ArgsTArgs&&...tag 类型与 fragment 值。Tag types and fragment values.
Output

无返回值。副作用:模板获得全部参数元素。

No return value. Side effect: the template gains all argument elements.

CloneTemplate FORCEINLINE static FMassEntityTemplateData

模板深拷贝:重建新模板并复制全部 tag、fragment(类型+初值)、共享与常量共享值。

Deep copy of template data: rebuilds a new template copying all tags, fragments (type + initial values), shared and const-shared values.

Input
参数 Param类型 Type说明 Description
Sourceconst FMassEntityTemplateData&要拷贝的模板。Template to copy.
Output

返回内容等价的独立 FMassEntityTemplateData。

Returns an independent FMassEntityTemplateData with equivalent content.

GetEntityFlags / GetEntityFlagsHigh int64 (const)

读取实体的低位(0–63)或高位(64–127)旗标掩码。实现(MassAPISubsystem.cpp):实体无效返回 0;实体缺 FEntityFlagFragment 时记警告日志并返回 0。

Reads an entity's low (0–63) or high (64–127) flag bitmask. Implementation (MassAPISubsystem.cpp): returns 0 for invalid entities; logs a warning and returns 0 when the entity lacks FEntityFlagFragment.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要读取的实体。The entity to read.
Output

返回 64 位旗标掩码;实体无效或缺 fragment 返回 0。

Returns the 64-bit flag mask; 0 for invalid entities or missing fragments.

HasEntityFlag / SetEntityFlag / ClearEntityFlag bool (const)

按 EEntityFlags 的实体旗标三件套。实现:越界(>= EEntityFlags_MAX)或实体无效直接返回 false;缺 FEntityFlagFragment 时——读返回 false,写记警告日志并返回 false;写成功返回 true(已置位/已清除也返回 true)。

Entity flag trio by EEntityFlags. Implementation: out-of-range (>= EEntityFlags_MAX) or invalid entities return false directly; when FEntityFlagFragment is missing — reads return false, writes log a warning and return false; successful writes return true (including already-set / already-clear states).

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要操作的实体。The entity to operate on.
FlagToTest / FlagToSet / FlagToClearEEntityFlags目标旗标。The target flag.
Output

HasEntityFlag 返回是否置位;两个写操作返回是否成功(失败含越界/无效实体/缺 fragment)。

HasEntityFlag returns whether the flag is set; the writers return success (failure covers out-of-range, invalid entities, missing fragment).

SetEntityFlagDefer / ClearEntityFlagDefer(各 ×2 重载) FORCEINLINE void (const)

延迟旗标写操作:越界直接返回;否则向命令缓冲压入 FMassDeferredSetCommand 闭包,刷新时校验实体有效且含 FEntityFlagFragment 后调用 SetFlag/ClearFlag。Context 重载委托 Context.Defer()。

Deferred flag writes: out-of-range returns immediately; otherwise pushes an FMassDeferredSetCommand closure that, on flush, validates the entity and its FEntityFlagFragment before calling SetFlag/ClearFlag. The Context overload delegates via Context.Defer().

Input
参数 Param类型 Type说明 Description
CommandBuffer 或 ContextFMassCommandBuffer& / FMassExecutionContext&命令来源。Command source.
EntityHandleFMassEntityHandle目标实体。Target entity.
FlagToSet / FlagToClearEEntityFlags目标旗标。Target flag.
Output

无返回值。副作用:刷新时旗标被修改。

No return value. Side effect: the flag mutates on flush.

HasFlag / SetFlag / ClearFlag 简写家族(EEntityFlags 与 FName) FORCEINLINE bool / void (const)

短名简写:枚举版本委托 HasEntityFlag/SetEntityFlag/ClearEntityFlag 及其 Defer 版本;FName 版本先经 UMassAPIFlagSettings::ResolveFlag 解析,未注册(EEntityFlags_MAX)时读返回 false、写静默跳过。

Short-name shorthands: enum versions delegate to HasEntityFlag/SetEntityFlag/ClearEntityFlag and their Defer versions; FName versions resolve via UMassAPIFlagSettings::ResolveFlag first — reads return false and writes silently skip when unregistered (EEntityFlags_MAX).

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle目标实体。Target entity.
Flag / FlagNameEEntityFlags / FName目标旗标(枚举或注册名)。Target flag (enum or registered name).
B / C(Defer 版本)FMassCommandBuffer& / FMassExecutionContext&命令来源。Command source.
Output

读返回布尔;写返回委托结果(Defer 版本为 void)。

Reads return bool; writes return the delegate result (Defer versions return void).

CheckIfEntityIsActive FORCEINLINE void (const, protected)

受保护的诊断助手:校验实体句柄活跃,经 EntityManager 的 CheckIfEntityIsActive 触发断言。

Protected diagnostic helper: validates that an entity handle is active, asserting via the EntityManager's CheckIfEntityIsActive.

Input
参数 Param类型 Type说明 Description
EntityHandleFMassEntityHandle要校验的实体。The entity to validate.
Output

无返回值;实体不活跃时触发断言。

No return value; asserts when the entity is inactive.

成员变量 Members

EntityForEachStates TMap<int32, FEntityForEachState> (public)

活跃 ForEach 游标表,以不透明 IterId 为键——支持嵌套遍历。由 UMassAPIFuncLib 的 Begin/Advance 系列读写(游标状态本身定义于本文件顶部的 FEntityForEachState:实体数组 + 当前索引)。

Active ForEach cursors keyed by opaque IterId — supports nested iteration. Read/written by UMassAPIFuncLib's Begin/Advance family (cursor state itself is the file-top FEntityForEachState: an entity array plus current index).

NextForEachId int32 (public)

单调递增的游标 ID 分配器。

Monotonically increasing cursor ID allocator.

SharedCommandBuffer TSharedPtr<FMassCommandBuffer> (private)

API 拥有的持久命令缓冲,Initialize 创建、Deinitialize 刷新后释放、每 tick 刷新。

The API-owned persistent command buffer; created in Initialize, flushed then released in Deinitialize, flushed every tick.

CurrentWorld mutable TObjectPtr<UWorld> (private, UPROPERTY)

GetEntityManager() 惰性缓存的世界指针。

World pointer cached lazily by GetEntityManager().

MassEntitySubsystem mutable TObjectPtr<UMassEntitySubsystem> (private, UPROPERTY)

GetEntityManager() 惰性缓存的 Mass 实体子系统。

Mass entity subsystem cached lazily by GetEntityManager().

EntityManager mutable FMassEntityManager* (private)

实体管理器原始指针缓存(取自 MassEntitySubsystem->GetMutableEntityManager())。

Raw entity-manager pointer cache (from MassEntitySubsystem->GetMutableEntityManager()).

管线角色 Pipeline Role

作为世界子系统,UMassAPISubsystem 每 tick 由引擎驱动(统计 ID 归 STATGROUP_Tickables),在 tick 中刷新自有的 SharedCommandBuffer。它被 UMassAPIFuncLib 的全部 Blueprint 函数(经 GetPtr(WorldContext))以及 MassBattle 模块的业务代码(如 UMassBattleDebuffSubsystem 的 GetMassAPISubsystem 惰性缓存)作为实体操作入口调用。ForEach 游标状态存放在本子系统上,由 UMassAPIFuncLib::BeginEntityForEach / AdvanceEntityForEach / BeginEntityHandleArrayForEach / AdvanceEntityHandleArrayForEach 读写(MassAPIFuncLib.cpp 尾部注释说明)。

As a world subsystem, UMassAPISubsystem is ticked by the engine every frame (stat under STATGROUP_Tickables), flushing its own SharedCommandBuffer in the tick. It is the entity-operation entry point for all of UMassAPIFuncLib's Blueprint functions (via GetPtr(WorldContext)) and for MassBattle business code (e.g. UMassBattleDebuffSubsystem's lazily-cached GetMassAPISubsystem). ForEach cursor state lives on this subsystem, read/written by UMassAPIFuncLib::BeginEntityForEach / AdvanceEntityForEach / BeginEntityHandleArrayForEach / AdvanceEntityHandleArrayForEach (per the trailing comment in MassAPIFuncLib.cpp).

补充说明 Notes

UE 5.4/5.5 版本移植层:全部常量共享 API(实体侧 HasConstSharedFragment、GetConstSharedFragment*、AddConstSharedFragment、RemoveConstSharedFragment,模板侧 FindConstSharedFragmentInTemplate、ReplaceConstSharedFragmentInTemplate 与模板 Has/Get/Set/Add/Remove 的 const-shared 版本)由 MASSAPI_ENGINE_AT_LEAST(5,5) 守卫,在 UE 5.4 整体编出(源码注释:「5.4 无引擎常量共享 API——函数编出」);≤5.5 的实体级共享添加/移除退化为警告 + false / false(见对应方法卡)。变参 BuildEntities 内部的共享片段去重与共享值追加、模板重建中的 ExportTypes 遍历,分别经 MassAPIVersion.h 的 MASSAPI_GET_OR_CREATE_SHARED / MASSAPI_SHARED_VALUES_ADD_* 宏与 MassAPIStructs.h 的 MassAPIImpl::ExportTypes 跨版本封装完成。

UE 5.4/5.5 portability layer: the entire const-shared API family (entity-side HasConstSharedFragment, GetConstSharedFragment*, AddConstSharedFragment, RemoveConstSharedFragment; template-side FindConstSharedFragmentInTemplate, ReplaceConstSharedFragmentInTemplate and the const-shared variants of the template Has/Get/Set/Add/Remove family) is guarded by MASSAPI_ENGINE_AT_LEAST(5,5) and compiled out on UE 5.4 (source comment: "UE 5.4: engine const-shared API unavailable — function compiled out"); entity-level shared add/remove on ≤5.5 degrade to warning + false / false (see the method cards). The shared-fragment dedup and shared-value append inside variadic BuildEntities, and the ExportTypes walks of the template rebuilds, go through the cross-version wrappers MASSAPI_GET_OR_CREATE_SHARED / MASSAPI_SHARED_VALUES_ADD_* (MassAPIVersion.h) and MassAPIImpl::ExportTypes (MassAPIStructs.h).

文件顶部的 MassAPIImpl 命名空间提供初值应用与匹配枚举的跨版本助手:ApplyInitialFragmentValues / ApplyInitialFragmentValuesBatch(5.6+ 用 SetEntityFragmentValues / BatchSetEntityFragmentValues;≤5.5 经公共 GetFragmentDataStruct 路径逐片段结构体拷贝),由 MassAPISubsystem.cpp 的立即/延迟构建路径与 MassAPIFuncLib.cpp 调用;CollectMatchingHandles(5.6+ 用 Query.GetMatchingEntityHandles();≤5.5 经本地执行上下文遍历查询块)与 GetNumMatchingEntities(5.6+ 无参重载,≤5.5 带 Manager 形式)由 MassAPIFuncLib.cpp 的匹配/计数函数(MatchEntitiesQuery / GetMatchingEntities / GetNumMatchingEntities)调用。

The MassAPIImpl namespace at the top of the file provides version-portable initial-value application and matching enumeration: ApplyInitialFragmentValues / ApplyInitialFragmentValuesBatch (5.6+ via SetEntityFragmentValues / BatchSetEntityFragmentValues; ≤5.5 per-fragment struct copies through the public GetFragmentDataStruct path), called from the immediate/deferred build paths in MassAPISubsystem.cpp and from MassAPIFuncLib.cpp; CollectMatchingHandles (5.6+ via Query.GetMatchingEntityHandles(); ≤5.5 walks the query's chunks through a local execution context) and GetNumMatchingEntities (parameterless overload on 5.6+, Manager-taking form on ≤5.5), called by the match/count functions in MassAPIFuncLib.cpp (MatchEntitiesQuery / GetMatchingEntities / GetNumMatchingEntities).