Mass Battle Frameworkv1.20.0

UMassBattleLootMonoProcessor

UCLASS Processor AUTO-DRIVEN · NO SETUP

Source/MassBattle/Public/Processors/MassBattleLootMonoProcessor.h

概述Overview

掉落处理器:死亡掉落的生成、弹道/插值下落与拾取入账。由插件自动调度;掉落表、价值与拾取参数在掉落 DataAsset 与 Gather 配置上。

The loot processor: spawns death drops, advances their ballistic / interped fall, and credits pickups. Auto-scheduled; drop tables, values and pickup parameters live on the loot DataAsset and the Gather config.

继承Inheritance

UMassProcessor → UMassBattleLootMonoProcessor

结构体 FLootScratchContextStruct FLootScratchContext

FLootScratchContext

私有的分块临时上下文,每个分块一份,用来承载该分块内的临时数据并提供集中复位。当前只声明一个掉落网格数据数组,Reset() 清空它;结构本身不跨分块保留。

Private per-chunk scratch context, one instance per chunk, holding that chunk's temporary data and offering a single reset point. It currently declares one loot grid-data array, and Reset() clears it; the context is not kept across chunks.

成员变量Members
名称Name类型Type默认值Default说明Description
LootGridDataArrayTArray<FLootGridData>—分块内的临时网格数据缓冲区,只由 Reset() 清空。Temporary grid-data buffer for the chunk; cleared only by Reset().
方法Methods
名称Name说明Description
Reset清空 LootGridDataArray,无参数、无返回值。Clears LootGridDataArray; no parameters, no return value.

结构体 FLootScoreDeltaStruct FLootScoreDelta

FLootScoreDelta

拾取计分增量:并行分块遍历中,当一件掉落抵达收集者时记录一条,由 Execute 的串行尾段排空。排序键是 (CollectorUID, LootUID),每个收集者每 tick 只产生一个统计事件。

Pickup score delta: one record per loot reaching its collector during the parallel chunk walk, drained by the serial tail of Execute. The sort key is (CollectorUID, LootUID), and each collector emits exactly one statistics event per tick.

成员变量Members
名称Name类型Type默认值Default说明Description
CollectorFEntityHandle—收集者(agent)实体句柄,排空时据此写 FStatistics。Collector (agent) entity handle; the drain writes FStatistics through it.
CollectorUIDint32-1收集者的确定性 UID,排序元组第一键;用 UID 而非句柄下标排序,双端顺序才一致。Deterministic UID of the collector, first sort key; sorting on UIDs rather than handle indices keeps the order identical across peers.
LootUIDint32-1掉落实体的 UID,排序元组第二键。UID of the loot entity, second sort key.
ScoreDeltaint320本次拾取为收集者增加的分数。Score added to the collector by this pickup.

方法Methods

UMassBattleLootMonoProcessor UMassBattleLootMonoProcessor()

构造函数。把处理器从 Mass 自动处理阶段注册中摘出,要求游戏线程执行,并把执行环境打开为 Standalone / Server / Client。

Constructor. Removes the processor from the automatic Mass processing-phase registration, requires game-thread execution, and enables the Standalone / Server / Client execution environments.

Input

无参数。

No parameters.

Output

无返回值。副作用:写入 bAutoRegisterWithProcessingPhases = false、bRequiresGameThreadExecution = true 与三端 ExecutionFlags,供调度层读取。

No return value. Side effect: sets bAutoRegisterWithProcessingPhases = false, bRequiresGameThreadExecution = true and the three-environment ExecutionFlags for the scheduler to read.

ConfigureQueries virtual void (override)

初始化并注册掉落实体查询。FLootTag、一组状态、参数、位置、旋转、确定性与表现 fragment(读写),以及拾取段插值移动的一组 fragment 是硬性要求(其中移动配置只读、运行时状态读写);生成内容、弹道下落与出生段插值下落用可选声明——实体按运行时状态携带其中一组,不同移动形态的掉落仍落在同一条查询里。

Initializes and registers the loot entity query. FLootTag, a set of state, parameter, location, rotation, determinism and visualising fragments (read-write), and the gather-stage interped movement group are required (the movement config read-only, the runtime state read-write); spawn content, ballistic fall and spawn-stage interped fall are optional — an entity carries the group matching its runtime state, so loot with different movement forms stays in the same query.

Input
参数Param类型Type说明Description
EntityManagerconst TSharedRef<FMassEntityManager>&实体管理器,查询以它初始化。Entity manager the query initializes against.
Output

无返回值。副作用:查询向本处理器注册(RegisterWithProcessor),此后随处理器的每一次 Execute 生效。

No return value. Side effect: the query is registered with this processor (RegisterWithProcessor) and takes effect on every subsequent Execute.

Execute virtual void (override)

每帧入口。门检查依次确认战斗子系统存在、ESubFrame::Subtick3 被调度,以及宿主、Mass API、掉落三个子系统可用,再取步长与模拟时间进入分块遍历。每个实体先过 PendingDestroy / Activated 标志门,随后按阶段推进:FSubType.Index 变化时用延迟命令换原型标签;未出生的一次性执行 OnBirth 内容并收集掉落生成事件;再按 ELootState 推进状态机——Spawning 阶段走弹道(重力、地面扫掠、反弹与沉降)或插值下落,Ready 等待收集者认领,BeingCollected 沿插值轨迹飞向收集者并在抵达时入账,Expired 与 Collected 执行销毁/拾取内容、发事件,并把实体送进回收池或销毁队列。分块遍历结束后在游戏线程做一次串行排空:确定性模式下把计分增量按 (CollectorUID, LootUID) 排序、按收集者合并且每个收集者只发一个统计事件;非确定性模式下直接在锁内累加,只补发事件。

Per-frame entry. The gates confirm the battle subsystem, a scheduled ESubFrame::Subtick3 and the host, Mass API and loot subsystems, then the step and simulation time are taken and the chunk walk begins. Each entity passes the PendingDestroy / Activated flag gate and then advances through the phases: a changed FSubType.Index swaps the archetype tag through deferred commands; an unborn entity runs its OnBirth content once and collects the loot-spawn event; the ELootState machine then runs — Spawning moves by ballistic fall (gravity, ground sweep, bounce and settle) or interped fall, Ready waits for a collector to claim, BeingCollected flies along the interp track and credits the score on arrival, and Expired and Collected run the destroy/pickup content, fire events and route the entity to a recycle pool or the destroy queue. After the walk a serial drain runs on the game thread: in deterministic mode the score deltas are sorted by (CollectorUID, LootUID), grouped per collector and reported as one statistics event per collector; in non-deterministic mode the values are accumulated directly under the lock and only the events are emitted.

Input
参数Param类型Type说明Description
EntityManagerFMassEntityManager&实体管理器。Entity manager.
ContextFMassExecutionContext&本帧执行上下文;分块遍历与延迟命令都经由它。Execution context for this frame; the chunk walk and deferred commands go through it.
Output

无返回值。副作用:推进掉落实体的位置、旋转与状态;通过宿主子系统批量生成 Actor/特效/音效;把生成、拾取、销毁三类事件追加进子系统队列;把计分写进收集者的 FStatistics 并按需发统计事件;到期与拾取完成的实体置 PendingDestroy 并清 Activated,随后进入掉落回收队列或销毁队列。

No return value. Side effects: it advances loot location, rotation and state; batch-spawns actors, FX and sounds through the host subsystem; appends spawn, collect and destroy events to the subsystem queues; writes the score into the collector's FStatistics and emits statistics events where enabled; and expired or collected entities are marked PendingDestroy with Activated cleared before entering the loot recycle queue or the destroy queue.

常量Constants

两个 static constexpr 私有缓存值,把战斗标志枚举预先转换成 EEntityFlags,省去每帧重复转换。它们不对外暴露,也没有配置项。

Two private static constexpr cached values that convert the battle flag enumerators to EEntityFlags ahead of time, saving the per-frame conversion. They are not exposed and have no configuration.

名称Name值Value说明Description
ActivatedFlagstatic_cast<EEntityFlags>(EBattleFlags::Activated)掉落是否处于激活状态;未激活的实体在本帧被直接跳过,不推进状态机。Whether the loot is active; inactive entities are skipped for the frame and the state machine does not advance.
PendingDestroyFlagstatic_cast<EEntityFlags>(EBattleFlags::PendingDestroy)已排队销毁/回收的实体,本帧剩余时间里不再处理。Entities already queued for destruction or recycling are ignored for the rest of the frame.

成员变量Members

名称Name类型Type说明Description
EntityQueryFMassEntityQuery私有。唯一的掉落实体查询,涵盖三种移动形态。Private. The single loot query, covering all three movement forms.
LootScoreGathererFParallelGatherer<FLootScoreDelta>私有。并行段投递的计分增量,每帧自排空并复位,不跨 tick 保留状态。Private. Score deltas pushed from the parallel pass; drained and reset every frame, with no state carried across ticks.
LootScoreTouchedCollectorsFParallelGatherer<FEntityHandle>私有。非确定性直写路径下,收集者本 tick 首次被写分时登记一次,尾段据此补发一个统计事件。Private. On the non-deterministic direct-write path, a collector is registered the first time it receives score this tick so the tail can emit one statistics event for it.

管线角色Pipeline Role

构造函数关闭 Mass 自动处理阶段注册,执行被限定在游戏线程,实际运行的帧只有 ESubFrame::Subtick3 被调度的那些;分块遍历本身是并行的自动负载均衡通道。它依赖宿主、Mass API 与掉落三个子系统:位置求解与插值轨迹来自掉落子系统,批量生成与回收请求投给宿主子系统,计分写进收集者的统计 fragment。跨实体与 UObject 相关的工作被推到分块之后:三类事件并入子系统队列,计分增量在串行尾段合并排序后落地——这正是「每个收集者每 tick 一个统计事件」得以成立的原因。

The constructor disables automatic Mass processing-phase registration, execution is limited to the game thread, and the processor only runs on frames where ESubFrame::Subtick3 is scheduled; the chunk walk itself is a parallel auto-balanced pass. It depends on three subsystems: the loot subsystem supplies position solving and interp tracks, the host subsystem receives batch spawn and recycle requests, and the score lands in the collector's statistics fragment. Cross-entity and UObject work is pushed past the chunk walk: the three event kinds are appended to subsystem queues, and score deltas are merged and sorted in the serial tail — that is what makes "one statistics event per collector per tick" hold.

补充说明Notes

① 出生内容由 FLootParamsRT.bBornFired 逐实体门控;该布尔在生成管线激活时复位,因此池化复用后的掉落会重新执行一次 OnBirth。
② 掉落拾取与到期都发销毁事件,由 FLootDestroyData.bExpired 区分原因;三类事件是否产生,取决于 FLootEvent 上对应的开关。
③ FSubType 是面向使用者的过滤器:运行时改它的 Index,原型标签会在同一 tick 内通过延迟命令跟上。

① OnBirth content is gated per entity by FLootParamsRT.bBornFired; the flag is reset when the spawn pipeline activates the entity, so pooled loot runs OnBirth again on reuse.
② Both pickup and expiry fire a destroy event, and FLootDestroyData.bExpired distinguishes the cause; whether each of the three event kinds is produced depends on the corresponding switch on FLootEvent.
③ FSubType is the user-facing filter: changing its Index at runtime makes the archetype tag follow within the same tick through deferred commands.