Loot.h
Source/MassBattle/Public/Fragments/Loot.h
概述 Overview
战利品实体的 fragment 集合,按「配置/运行时」与「移动模型」组织:核心配置 FLootParams(拾取/寿命/分数/碰撞/地面检测)与运行时状态 FLootParamsRT(生成者/收集者/状态机/流场/池化锁存);两种移动模型——弹道(FLootMove_Ballistic / FLootMoving_Ballistic,抛物线+反弹)与插值飞行(FLootMove_Interped_Spawn / FLootMoving_Interped_Spawn 生成路径、FLootMove_Interped_Gather / FLootMoving_Interped_Gather 收集路径——两组配置字段完全相同,仅运行时注释语境不同);乘数(FLootMultipliers 聚合弹道与插值乘数)。
Loot entity fragment set, organized as config/runtime pairs and movement models: core config FLootParams (pickup/lifespan/score/collision/ground detection) and runtime state FLootParamsRT (spawner/collector/state machine/flow field/pool latches); two movement models — ballistic (FLootMove_Ballistic / FLootMoving_Ballistic, parabola + bounce) and interped flight (FLootMove_Interped_Spawn / FLootMoving_Interped_Spawn for spawn paths, FLootMove_Interped_Gather / FLootMoving_Interped_Gather for gather paths — the two groups have identical config fields, differing only in runtime semantics); multipliers (FLootMultipliers aggregating ballistic and interped multipliers).
FLootParams USTRUCT
战利品配置 fragment,派生自 FA_MassBattleBaseFragment。所有字段为策划可调参数,运行时不变。
Loot config fragment derived from FA_MassBattleBaseFragment. All fields are designer-tunable and constant at runtime.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
PickupRadius | float | 100.0f | 拾取半径。Pickup radius. |
LifeSpan | float | 10.0f | 寿命秒数(0 = 无限)。Lifespan in seconds (0 = infinite). |
ScoreValue | int32 | 10 | 分数值。Score value. |
bCanCollect | bool | true | 能否被收集。Can be collected? |
CollectDelay | float | 0.5f | 成为可收集前的延迟(秒)。Delay (seconds) before becoming collectible. |
bDrawDebugShape | bool | false | 绘制调试形状。Draw debug shapes. |
bRotationFollowVelocity | bool | true | 旋转跟随速度。Rotation follows velocity. |
InterpParams | FInterpParams | — | 附着 FX 平滑插值参数。Interpolation parameters for attached FX smoothing. |
bCollideWithObstacles | bool | true | 启用与障碍物实体的碰撞(HashGrid 中的动态障碍物)。Enable collision with obstacle entities (dynamic obstacles in the HashGrid). |
CollisionRadius | float | 30.0f | 障碍物实体碰撞半径。Collision radius for obstacle entity collision. |
bDoSceneTrace | bool | false | 启用场景追踪以与静态几何体碰撞。Enable scene trace for collision with static geometry. |
SceneTraceChannel | TEnumAsByte<ECollisionChannel> | ECC_WorldStatic | 场景碰撞检测的追踪通道。仅 bDoSceneTrace 为 true 时可编辑。Trace channel for scene collision detection. Editable only when bDoSceneTrace is true. |
GroundSource | EGroundSource | FlowField | 地面高度检测策略(Raycast / FlowField 混合 / FlowField_Strict),枚举定义于 MassBattleEnums.h。Ground height detection strategy (Raycast / FlowField hybrid / FlowField_Strict); enum defined in MassBattleEnums.h. |
GroundTraceChannel | TEnumAsByte<ECollisionChannel> | ECC_WorldStatic | 地面检测的追踪通道(射线/混合模式)。仅 GroundSource != FlowField_Strict 时可编辑。Trace channel for ground detection (raycast/hybrid mode). Editable only when GroundSource != FlowField_Strict. |
FLootParamsRT USTRUCT
战利品运行时状态 fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝(含软引用)。bBornFired 为逐实体 OnBirth 锁存器——旧设计用一次性 archetype Tag(FLootBornTag)导致池复用后静默跳过 OnBirth;改用普通 bool(非位域——位域 pad 位不确定会导致 hash 折叠假失步,且非 UPROPERTY 位域无法被 FindFProperty 找到)。PoolDataAsset 记录按原型池路由。
Loot runtime state fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable (contains soft references). bBornFired is a per-entity OnBirth latch — the old one-way archetype tag (FLootBornTag) made pool-reused loot silently skip OnBirth; a plain bool is used instead (not a bitfield — pad bits are indeterminate, causing false desync in hash folding, and non-UPROPERTY bitfields can't be found by FindFProperty). PoolDataAsset records per-archetype pool routing.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Spawner | FEntityHandle | — | 生成此战利品的实体。Entity that spawned this loot. |
Collector | FEntityHandle | — | 收集此战利品的实体。Entity collecting this loot. |
State | ELootState | Spawning | 当前状态(Spawning/Ready/BeingCollected/Collected/Expired),枚举定义于 MassBattleEnums.h。Current state (Spawning/Ready/BeingCollected/Collected/Expired); enum defined in MassBattleEnums.h. |
CollectDelayTimeLeft | float | 0.0f | 可收集前的剩余时间。Time left before collectible. |
FlowFieldPtr | TObjectPtr<AFlowField> | nullptr | 用于地面检测的流场 Actor。Flow field actor for ground detection. |
FlowFieldSoftPtr | TSoftObjectPtr<AFlowField> | nullptr | 流场软引用快照来源——恢复后解析为 FlowFieldPtr。Flow field soft source for snapshot restore — resolves to FlowFieldPtr after restore. |
PoolDataAsset | TObjectPtr<UMassBattleLootConfigDataAsset> | nullptr | 按原型池路由:激活时设为生成该战利品所用的 DA;销毁时读取,将实体推入 LootPoolsByDataAsset[DA] 而非直接销毁。Per-archetype pool routing: set during activation to the DA used to spawn this loot; read at despawn to push the entity onto LootPoolsByDataAsset[DA] instead of destroying. |
bBornFired | bool | false | 逐实体 OnBirth 锁存器,保证池复用安全。在 ProcessHostOpsQueues 激活时复位为 false。快照注册表字段。Per-entity OnBirth latch for pool-reuse correctness. Reset to false at activation in ProcessHostOpsQueues. Snapshot registry field. |
PoolCountdown | float | 0.f | 逐实体池闲置倒计时。池中休眠时 TickEntityPoolCooldowns 每 MassBattle tick 递减;归零即无条件销毁(无保留下限——按原型桶可缩至 0)。每次入池(回收)复位为统一的 PoolIdleLifeSpan(UMassBattleHostSubsystem 的 ini 配置项,默认 15 秒,所有 MassBattle 池共用)。Per-entity pool idle countdown. While pooled (dormant), TickEntityPoolCooldowns decrements it each MassBattle tick; at zero the entity is destroyed unconditionally (no min floor — the per-archetype bucket can shrink to 0). Reset to the unified PoolIdleLifeSpan (an ini-config property on UMassBattleHostSubsystem, default 15 s, shared by all MassBattle pools) on every push (recycle). |
FLootMove_Ballistic USTRUCT
弹道移动配置 fragment,派生自 FA_MassBattleBaseFragment。速度以范围给出,生成时随机取。
Ballistic movement config fragment derived from FA_MassBattleBaseFragment. Velocities are given as ranges, randomized at spawn.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
InitialVelocityXY | FVector2f | (200, 400) | 初始 XY 速度范围(最小, 最大)。Initial XY velocity range (min, max). |
InitialVelocityZ | FVector2f | (300, 600) | 初始 Z 速度范围(最小, 最大)。Initial Z velocity range (min, max). |
Gravity | float | 980.0f | 重力加速度。Gravity acceleration. |
BounceDamping | float | 0.5f | 反弹速度衰减因子。Bounce velocity damping factor. |
MinBounceVelocity | float | 50.0f | 继续反弹的最小速度——低于该值停止反弹。Minimum bounce velocity to continue bouncing. |
FLootMoving_Ballistic USTRUCT
弹道移动运行时状态 fragment,派生自 FA_MassBattleBaseFragment。bHasSettled 为普通 bool(非位域),每 tick 门控 Spawning→Ready 转换。
Ballistic movement runtime state fragment derived from FA_MassBattleBaseFragment. bHasSettled is a plain bool (not a bitfield) gating the Spawning→Ready transition each tick.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Velocity | FVector3f | (0,0,0) | 当前速度。Current velocity. |
BirthTime | float | 0.0f | 出生时间。Birth time. |
bHasSettled | bool | false | 是否已落地。快照注册表字段。Has settled on the ground. Snapshot registry field. |
FLootMove_Interped_Spawn USTRUCT
插值飞行移动配置(生成路径) fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝(含曲线)。偏移 = 曲线 × 距离映射 × 随机乘数。
Interped flight movement config (spawn path) fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable (contains curves). Offset = curve × dist_remap × random_mult.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Speed | float | 1000.0f | 飞行速度。Flight speed. |
XOffset | FRuntimeFloatCurve | — | X 偏移曲线。X offset curve. |
YOffset | FRuntimeFloatCurve | — | Y 偏移曲线。Y offset curve. |
ZOffset | FRuntimeFloatCurve | — | Z 偏移曲线。Z offset curve. |
XOffsetMult | FVector2f | (1, 1) | X 偏移乘数范围(最小, 最大)。X offset multiplier range (min, max). |
YOffsetMult | FVector2f | (1, 1) | Y 偏移乘数范围。Y offset multiplier range. |
ZOffsetMult | FVector2f | (1, 1) | Z 偏移乘数范围。Z offset multiplier range. |
XOffsetRangeMap | FVector4f | (0,1,10000,1) | X 偏移-距离映射乘数(DistMin, MultAtMin, DistMax, MultAtMax)。X offset distance mapping multiplier (DistMin, MultAtMin, DistMax, MultAtMax). |
YOffsetRangeMap | FVector4f | (0,1,10000,1) | Y 偏移-距离映射乘数。Y offset distance mapping multiplier. |
ZOffsetRangeMap | FVector4f | (0,1,10000,1) | Z 偏移-距离映射乘数。Z offset distance mapping multiplier. |
FLootMoving_Interped_Spawn USTRUCT
插值飞行移动运行时状态(生成路径) fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝(含句柄)。
Interped flight movement runtime state (spawn path) fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable (contains a handle).
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
FromPoint | FVector | (0,0,0) | 起点。Start point. |
ToPoint | FVector | (0,0,0) | 终点。End point. |
Target | FEntityHandle | — | 目标实体。Target entity. |
StartTime | float | 0.0f | 开始时间。Start time. |
OffsetMultipliers | FVector3f | (1,1,1) | 偏移乘数(曲线 × 距离映射 × 随机乘数)。Offset multipliers (curve × dist_remap × random_mult). |
InitialDistance | float | 0.0f | 开始移动时到目标的初始距离。Initial distance to the target when movement started. |
LerpProgress | float | 0.0f | 当前插值进度(0–1)。Current lerp progress (0–1). |
FLootMove_Interped_Gather USTRUCT
插值飞行移动配置(收集路径) fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝。字段与 FLootMove_Interped_Spawn 完全相同——两条路径复用同一组配置参数。
Interped flight movement config (gather path) fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable. Fields are identical to FLootMove_Interped_Spawn — both paths share the same config parameters.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Speed | float | 1000.0f | 飞行速度。Flight speed. |
XOffset | FRuntimeFloatCurve | — | X 偏移曲线。X offset curve. |
YOffset | FRuntimeFloatCurve | — | Y 偏移曲线。Y offset curve. |
ZOffset | FRuntimeFloatCurve | — | Z 偏移曲线。Z offset curve. |
XOffsetMult | FVector2f | (1, 1) | X 偏移乘数范围。X offset multiplier range. |
YOffsetMult | FVector2f | (1, 1) | Y 偏移乘数范围。Y offset multiplier range. |
ZOffsetMult | FVector2f | (1, 1) | Z 偏移乘数范围。Z offset multiplier range. |
XOffsetRangeMap | FVector4f | (0,1,10000,1) | X 偏移-距离映射乘数。X offset distance mapping multiplier. |
YOffsetRangeMap | FVector4f | (0,1,10000,1) | Y 偏移-距离映射乘数。Y offset distance mapping multiplier. |
ZOffsetRangeMap | FVector4f | (0,1,10000,1) | Z 偏移-距离映射乘数。Z offset distance mapping multiplier. |
FLootMoving_Interped_Gather USTRUCT
插值飞行移动运行时状态(收集路径) fragment,派生自 FA_MassBattleBaseFragment,声明为不可平凡拷贝。字段与 FLootMoving_Interped_Spawn 相同,语义为收集阶段。
Interped flight movement runtime state (gather path) fragment derived from FA_MassBattleBaseFragment, declared not-trivially-copyable. Fields match FLootMoving_Interped_Spawn, with gather-phase semantics.
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
FromPoint | FVector | (0,0,0) | 起点(开始收集时的初始位置)。Start point (initial position when collection started). |
ToPoint | FVector | (0,0,0) | 终点(目标位置)。End point (target position). |
Target | FEntityHandle | — | 目标实体。Target entity. |
StartTime | float | 0.0f | 开始时间。Start time. |
OffsetMultipliers | FVector3f | (1,1,1) | 偏移乘数(曲线 × 距离映射 × 随机乘数)。Offset multipliers (curve × dist_remap × random_mult). |
InitialDistance | float | 0.0f | 开始收集时到目标的初始距离。Initial distance to the target when collection started. |
LerpProgress | float | 0.0f | 当前插值进度(0–1)。Current lerp progress (0–1). |
FLootMultipliers(与两个子结构) USTRUCT ×3
战利品参数乘数聚合(普通 USTRUCT,非 fragment):FLootMultipliers 聚合两种移动模型的乘数——Ballistic(缩放/分数/速度/重力)与 Interped(缩放/分数/速度)。全部默认 1(不变)。
Loot parameter multiplier aggregation (plain USTRUCTs, not fragments): FLootMultipliers aggregates multipliers of the two movement models — Ballistic (scale/score/velocity/gravity) and Interped (scale/score/speed). All default to 1 (identity).
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Ballistic | FLootMultipliers_Ballistic | — | 抛物线乘数(ScaleMult / ScoreMult / VelocityMult / GravityMult)。Ballistic multipliers (ScaleMult / ScoreMult / VelocityMult / GravityMult). |
Interped | FLootMultipliers_Interped | — | 插值乘数(ScaleMult / ScoreMult / SpeedMult)。Interped multipliers (ScaleMult / ScoreMult / SpeedMult). |
管线角色 Pipeline Role
grep 验证:FLootParamsRT / FLootMoving_* 被 MassBattleLootMonoProcessor(状态机推进:出生→可收集→收集中→收集完成,弹道/插值移动积分)、MassBattleGridUpdateProcessor(网格注册/拾取半径)、MassBattleHostMonoProcessor(宿主生命周期)、MassBattleNetworkProcessor(快照注册)、MassBattleAgentReactionProcessor / MassBattleAgentTraceProcessor(Agent 侧收集检测)与 MassBattleHostSubsystem / MassBattleLootComponent 引用。
Verified by grep: FLootParamsRT / FLootMoving_* are referenced by MassBattleLootMonoProcessor (state machine: born→ready→collecting→collected; ballistic/interped integration), MassBattleGridUpdateProcessor (grid registration/pickup radius), MassBattleHostMonoProcessor (host lifecycle), MassBattleNetworkProcessor (snapshot registration), MassBattleAgentReactionProcessor / MassBattleAgentTraceProcessor (agent-side collection detection) and MassBattleHostSubsystem / MassBattleLootComponent.