TextPop.h
Source/MassBattle/Public/Fragments/TextPop.h
概述 Overview
伤害弹字(文本弹出)fragment FTextPop——配置与运行时缓冲合一:配置 段(启用开关、白字 / 橙字显示阈值、文本大小)与运行时 段(原 FPoppingText:位置数组 + 值 / 样式 / 缩放 / 偏移打包数组,带自旋锁供并行段写入)。伤害应用处理器把弹字请求推入缓冲,渲染层经文本数据通道(FTextRenderData)弹出。
Damage-popup (text pop) fragment FTextPop — config and runtime buffer in one: a config section (enable toggle, white/orange text display thresholds, text scale) and a runtime section (formerly FPoppingText: a location array plus a packed value/style/scale/offset array, spin-locked for parallel-section writes). Damage processors push popup requests into the buffer; the render layer pops them via the text data channel (FTextRenderData).
FTextPop USTRUCT
弹字 fragment(FA_MassBattleBaseFragment 派生)。配置字段策划在 EntityConfig 中可调;运行时数组由伤害处理器写入、渲染处理器读取。含自旋锁与 TInlineAllocator<1> 内联缓冲(单条弹字无堆分配),经 MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE 声明。拷贝构造 / 赋值复制配置与数组(不复制锁)。
Popup fragment (derived from FA_MassBattleBaseFragment). Config fields are designer-tunable in EntityConfig; the runtime arrays are written by damage processors and read by the render processor. Contains a spin lock and TInlineAllocator<1> inline buffers (single popup without heap allocation); declared via MASS_FRAGMENT_ACCEPT_NOT_TRIVIALLY_COPYABLE. Copy constructor / assignment copy the config and arrays (not the lock).
成员变量 Members
| 名称 Name | 类型 Type | 默认值 | 说明 Description |
|---|---|---|---|
Enable | bool | true | 是否启用文本弹出效果。Whether to enable the text pop effect. |
WhiteTextBelowPercent | float | 0.333f | 白色文本显示的百分比阈值(低于此值时显示白色文本)。Percentage threshold for white text display (show white text when below this value). |
OrangeTextAbovePercent | float | 0.667f | 橙色文本显示的百分比阈值(高于此值时显示橙色文本)。Percentage threshold for orange text display (show orange text when above this value). |
TextScale | float | 300 | 文本大小。Text size. |
CullDistance | float | 0.f | 飘字剔除的相机距离(0 = 不剔除):渲染处理器在收集时按端本地相机距离判断,超出的弹字直接丢弃——不收集进渲染批次、不写入 NDC、不发送给 NS(端本地渲染层决策,不写任何同步状态)。Camera distance beyond which text pops are culled (0 = never cull): at collection time the render processor checks the peer-local camera distance and drops pops beyond it — never collected into the render batch, the NDC write, or the NS (a peer-local render-layer decision; no synced state is written). |
TextLocationArray | TArray<FVector, TInlineAllocator<1>> | 空 | 弹字世界位置缓冲(运行时)。Popup world-location buffer (runtime). |
Text_Value_Style_Scale_Offset_Array | TArray<FVector4f, TInlineAllocator<1>> | 空 | 弹字打包缓冲(值、样式、缩放、偏移,运行时)。Packed popup buffer (value, style, scale, offset; runtime). |
LockFlag | std::atomic<bool> (private) | false | 私有自旋锁标志,保护运行时数组的并行写入。Private spin-lock flag protecting parallel writes to the runtime arrays. |
方法 Methods
自旋获取锁:对 LockFlag 做 acquire 语义的 exchange,占用中则忙等。
Spins to acquire the lock: exchange on LockFlag with acquire semantics, busy-waiting while held.
Input
无参数。
No parameters.
Output
无返回值。副作用:锁被当前线程占用。
No return value. Side effect: the lock is held by the calling thread.
释放锁:以 release 语义把 LockFlag 存回 false。
Releases the lock: stores false into LockFlag with release semantics.
Input
无参数。
No parameters.
Output
无返回值。副作用:锁释放,其它线程可获取。
No return value. Side effect: the lock is released for other threads.
管线角色 Pipeline Role
FTextPop 在 MassBattle 管线中的位置:弹字请求由 MassBattleAgentReactionProcessor(伤害结算)在并行段加锁写入;MassBattleAgentRenderProcessor 读取并汇入批次文本数据(FTextRenderData)推送;MassBattleAgentSubsystem / MassBattleSubsystem 亦引用(配置注入)。
Position of FTextPop in the MassBattle pipeline: popup requests are written under lock from the parallel section of MassBattleAgentReactionProcessor (damage settlement); MassBattleAgentRenderProcessor reads them and merges into the batch text data (FTextRenderData) for push; MassBattleAgentSubsystem / MassBattleSubsystem also reference it (config injection).