MassBattle Docsv1.19.20

Death.h

USTRUCT ×2 Tag ×2

Source/MassBattle/Public/Fragments/Death.h

概述 Overview

死亡流程的 fragment 集合:配置 FDeath(延迟删除、淡出、动画策略、死亡时碰撞/网格参与、自杀特殊规则、死亡生成 Actor/FX/音效/战利品)、运行时状态 FDying(死亡过程计时、致死实体与方向、碰撞禁用倒计时)与两个标记 FDyingTag(死亡中)/ FDestroyingTag(销毁中)。

Death-flow fragments: config FDeath (despawn delay, fade-out, animation policy, dying-time grid/collision participation, suicide special rules, death spawns of Actor/FX/sound/loot), runtime state FDying (death timers, fatal entity and direction, collision-disable countdown) and two tags FDyingTag (dying) / FDestroyingTag (destroying).

FDeath USTRUCT

死亡配置 fragment(FA_MassBattleBaseFragment 派生)。所有字段为策划在 EntityConfig 中可调参数,运行时不变。经 MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE 声明为不可平凡拷贝(含 TArray 成员)。

Death config fragment (derived from FA_MassBattleBaseFragment). All fields are designer-tunable EntityConfig parameters, constant at runtime. Declared via MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE as not-trivially-copyable (contains TArray members).

成员变量 Members

名称 Name类型 Type默认值说明 Description
bEnablebooltrue是否启用死亡逻辑。Whether to enable death logic.
DespawnDelayfloat3.f死亡后删除的延迟时间(秒)。Delay before despawn after death (seconds).
bCanFadeoutbooltrue是否启用淡出效果。Whether to enable the fade-out effect.
FadeOutDelayfloat2.f淡出效果的延迟时间(秒)。Delay for the fade-out effect (seconds).
bCanPlayAnimbooltrue是否播放死亡动画。Whether to play the death animation.
bAnimAsDurationboolfalse勾选后使用死亡动画长度作为死亡行为时长(动画长度定义在 Animation fragment 里)。仅当 bCanPlayAnim 为 true 时可编辑。When enabled, uses the death anim length as the death behavior duration (defined in the Animation fragment). Editable only when bCanPlayAnim is true.
AnimLengthfloat2.f死亡动画长度(秒)。仅当播动画且未用动画时长时可编辑。Death animation length (seconds). Editable only when animation is on and anim-as-duration is off.
LifeSpanfloat-1.f寿命(秒),负值为无限长。Lifespan (seconds); negative for infinite.
bExcludeFromHashGridboolfalse启用时,Agent 死亡时将不会注册到哈希网格。If enabled, the agent will not be registered to the hash grid when dying.
bCanFallDownbooltrue死亡的飞行单位坠落(重力)而非悬停。纯配置方案:坠落在移动处理器的 Z 决策点由已同步状态(DyingFlag)+ 本静态配置推导,Move.Z.bCanFly 不再被运行时改写——旧的死亡入口运行时改写配置 fragment 的做法在快照重建后丢失(FMove 从 DataAsset 模板恢复),导致重建的尸体悬停而服务器尸体坠落 → Z 分叉 → resync 循环(2026-08-15)。Dying flying agents fall to the ground (gravity) instead of hovering. Config-only: the fall is derived at the move processors' Z decision sites from synced state (DyingFlag) plus this static config, and Move.Z.bCanFly is never mutated at runtime — the legacy death-entry runtime write to the config fragment was lost on snapshot rebuild (FMove restores from the DataAsset template), leaving the restored corpse hovering while the server's corpse fell → Z divergence → resync loop (2026-08-15).
bDisableCollisionWithAgentboolfalse启用时,Agent 死亡时将不会与其他 Agent 发生碰撞(禁用 PBD)。If enabled, the agent will not collide with other agents when dying (PBD disabled).
DisableCollisionWithAgentDelayfloat0.f进入死亡状态后多久(秒)禁用与其他 Agent 的碰撞。0 = 立即禁用。仅 bDisableCollisionWithAgent 为 true 时可编辑。Delay (seconds) after entering the dying state before agent-vs-agent collision is disabled. 0 = disable immediately. Editable only when bDisableCollisionWithAgent is true.
bDisableCollisionWithObstboolfalse启用时,Agent 死亡时将不会与障碍物发生碰撞(禁用 PBD)。If enabled, the agent will not collide with obstacles when dying (PBD disabled).
bInstantRemovalOnSuicidebooltrue如果 Agent 死于自杀,则直接移除。If the death cause is suicide, remove the agent at once.
bDisableDeathSpawnOnSuicidebooltrue如果 Agent 死于自杀,不执行死亡生成逻辑。If the death cause is suicide, don't run death spawns.
bForceGroundAlignmentboolfalse启用时,死亡时强制启用地面对齐(俯仰和横滚匹配地面法线),无视 Move.Tilt 的 bAlignToGroundPitch/Roll 设置。If enabled, forces ground alignment (pitch and roll to match the ground normal) when dying, regardless of Move.Tilt's bAlignToGroundPitch/Roll settings.
SpawnActorTArray<FActorSpawnConfig>空死亡时生成的 Actor 配置列表。Actors to spawn on death.
SpawnFxTArray<FFxConfig>空死亡时生成的特效配置列表。Effects to spawn on death.
PlaySoundTArray<FSoundConfig>空死亡时播放的声音配置列表。Sounds to play on death.
SpawnLootTArray<FLootConfig>空死亡时生成的战利品配置列表。Loot to spawn on death.

FDying USTRUCT

死亡运行时状态 fragment(FA_MassBattleBaseFragment 派生)。由死亡相关处理器逐帧推进:Time 累计死亡过程时间、DeathDissolveTime 累计消融时间、DeathAnimTime 累计动画时间;位域标志 bInitialized / bIsSuicide 标记流程阶段。默认构造器将三个位域显式清零。

Death runtime state fragment (derived from FA_MassBattleBaseFragment), advanced per frame by the death processors: Time accumulates the death process, DeathDissolveTime the dissolve time, DeathAnimTime the animation time; the bitfield flags bInitialized / bIsSuicide mark the flow stage. The default constructor zeroes all three bitfields explicitly.

成员变量 Members

名称 Name类型 Type默认值说明 Description
bInitializeduint8 : 10死亡过程已初始化标志。Death process initialized flag.
bIsSuicideuint8 : 10是否为自杀。Whether the death was a suicide.
Durationfloat0.0f死亡过程持续时间(进入时按配置初始化)。Duration of the death process (seeded at entry from config).
Timefloat0.0f当前死亡过程已持续时间。Current elapsed time of the death process.
DeathDissolveTimefloat0.0f当前死亡消融时间。Current death dissolve time.
DeathAnimTimefloat0.0f当前死亡动画时间。Current death animation time.
InstigatorFEntityHandle—造成死亡的实体。The entity that caused the death.
HitDirectionFVector3fZeroVector致命打击的方向。Direction of the fatal hit.
DisableCollisionWithAgentTimerfloat0.f死亡期间禁用与其他 Agent 碰撞前的剩余倒计时(秒)。死亡进入时由 Death.DisableCollisionWithAgentDelay 初始化,ReactionProcessor 中递减;>0 表示碰撞仍生效。Countdown (seconds) before agent-vs-agent collision is disabled while dying; seeded on dying entry from Death.DisableCollisionWithAgentDelay, ticked down in the ReactionProcessor; >0 means collision is still active.

方法 Methods

FDying (constructor) FDying(bool, float, float, float, float, const FEntityHandle&, const FVector3f&, bool)

带参构造:初始化标志、持续时间、消融/动画时间、致死实体与方向;注意 Time 恒被置 0.0f(无论传入的 InTime 参数如何——参数名与赋值不一致,源码如此)。

Parameterized constructor: initializes flags, duration, dissolve/anim times, instigator and hit direction; note Time is always set to 0.0f regardless of the passed InTime parameter (parameter name vs assignment mismatch — as in the source).

Input
参数 Param类型 Type说明 Description
InInitialzedbool是否已初始化(写入 bInitialized)。Whether initialized (written to bInitialized).
InDurationfloat死亡过程持续时间。Death process duration.
InTimefloat传入但未使用——Time 恒置 0.0f。Passed but unused — Time is always set to 0.0f.
InDeathDissolveTimefloat死亡消融时间。Death dissolve time.
InDeathAnimTimefloat死亡动画时间。Death animation time.
InInstigatorconst FEntityHandle&致死实体句柄。Fatal entity handle.
InHitDirectionconst FVector3f&致命打击方向。Fatal hit direction.
InIsSuicidebool是否自杀(写入 bIsSuicide)。Whether suicide (written to bIsSuicide).
Output

无返回值。副作用:全字段初始化。

No return value. Side effect: all fields initialized.

标记 Tags

FDyingTag

死亡中标记(FA_MassBattleBaseTag 派生)。附着在死亡流程进行中的实体上。

Dying marker (derived from FA_MassBattleBaseTag). Attached to entities currently in the death flow.

FDestroyingTag

销毁中标记(FA_MassBattleBaseTag 派生)。附着在进入销毁阶段的实体上。

Destroying marker (derived from FA_MassBattleBaseTag). Attached to entities entering the destroy stage.

管线角色 Pipeline Role

FDeath / FDying 由行为/反应/移动处理器读取(grep 验证:MassBattleAgentBehaviorProcessor、MassBattleAgentReactionProcessor、MassBattleAgentMoveProcessor / MoveProcessorFP、MassBattleAgentSubsystem)。行为处理器推进死亡状态机并执行死亡生成(自杀路径按 bInstantRemovalOnSuicide / bDisableDeathSpawnOnSuicide 分支);DisableCollisionWithAgentTimer 在 ReactionProcessor 中递减(头注释声明)。

FDeath / FDying are read by behavior / reaction / movement processors (verified by grep: MassBattleAgentBehaviorProcessor, MassBattleAgentReactionProcessor, MassBattleAgentMoveProcessor / MoveProcessorFP, MassBattleAgentSubsystem). The behavior processor advances the death state machine and runs death spawns (suicide paths branch on bInstantRemovalOnSuicide / bDisableDeathSpawnOnSuicide); DisableCollisionWithAgentTimer is ticked in the ReactionProcessor (per the header comment).

补充说明 Notes

文件末尾的 FDisableDeathTag 为注释掉的预留 Tag 定义,当前未启用。

The commented-out FDisableDeathTag at the end of the file is a reserved tag definition, currently disabled.