Mass Battle Frameworkv1.20.0

MassBattleAgentCreatorCore.h

C++ Class ×1 Plain C++ Struct ×1

Source/MassBattleEditor/Public/AgentCreator/MassBattleAgentCreatorCore.h

概述Overview

Agent 烘焙的编排层:把「源骨骼网格 / 图集 → 可用的单位资产」这条流程拆成一组静态步骤,全部作用在面板持有的 UMassBattleAgentCreatorState 上。真正干活的是 UMassBattleFuncLibEd 与 ATT 烘焙库(网格转换、材质实例、VAT 像素烘焙、资产复制),本类只负责顺序、门控与状态搬运。面板上的 Generate 按钮就是调用这里的 Generate;日常使用只需在 MassBattle Agent Creator 面板里点按钮、填参数,不需要自己调用本类的任何函数。

The orchestration layer of agent baking: it splits the "source skeletal mesh / atlas → usable unit assets" flow into a set of static steps, all operating on the UMassBattleAgentCreatorState the panel owns. The heavy lifting belongs to UMassBattleFuncLibEd and the ATT bake library (mesh conversion, material instances, VAT pixel baking, asset duplication); this class only owns order, gating and state transport. The panel's Generate button calls Generate here; in day-to-day use you fill in the panel and press the buttons — you never need to call any of these functions yourself.

两个工具模式共用这一层:Standard(单单位:网格档走五步流水线,Sprite 档装配渲染器 → 数据资产 → 材质实例)与 Advanced(把请求转交给 assembly 复合烘焙,见 MassBattleAssemblyCompositeBake.h)。失败不走弹窗:错误写进 creator 日志,同时流进 Generate 打开的进度对话框,最终以红色终态收尾。

Two tool modes share this layer: Standard (single unit: mesh bands run the five-step pipeline, sprite bands assemble the renderer → data asset → material instance) and Advanced (hands the request to the assembly composite bake, see MassBattleAssemblyCompositeBake.h). Failures never pop dialogs: errors go to the creator log and stream into the progress dialog opened by Generate, which ends in a red terminal state.

FMassBattleAgentCreatorParams struct

面板持有的本次烘焙参数:只影响「这一次 Generate 怎么做」的旋钮,与状态对象里那些「生成出什么」的字段分开存放。它是普通 C++ 结构体(非 USTRUCT),由面板构造后按值传给各个步骤;勾选值会被面板存回 Creator Profile,下次打开面板时恢复。除 bShowSubsteps 外,其余字段都被本类的若干步骤读取。

Per-bake parameters owned by the panel: knobs that decide "how this Generate runs", kept separate from the state object's "what gets produced" fields. It is a plain C++ struct (not a USTRUCT); the panel builds it and passes it by value into each step. Checkbox values are saved back into the Creator Profile and restored the next time the panel opens. Every field except bShowSubsteps is read by at least one step of this class.

成员变量Members

名称Name类型Type默认值说明Description
VATUVChannelint321VAT 采样使用的 UV 通道号,有效范围 0–3(面板的数字框按此范围钳制);写入 AnimToTex 数据资产的 UVChannel。UV channel used for VAT sampling, valid range 0–3 (the panel's numeric box clamps to it); written into the AnimToTex data asset's UVChannel.
LightMapUVChannelint322转静态网格时生成光照贴图 UV 的目标通道号,随转换调用一起传给 FuncLibEd。Target channel for the lightmap UVs generated during the static-mesh conversion; passed to FuncLibEd with the conversion call.
VATSampleRatedouble30.0VAT 每秒采样帧数(面板输入范围 1–120);写入数据资产的 SampleRate,决定烘焙出的动画帧密度。VAT samples per second (panel range 1–120); written into the data asset's SampleRate and determines the baked frame density.
SpriteFPSdouble12.0Sprite 图集的播放帧率(面板输入范围 0–120)。每个动画槽写入的时长 = 帧数 / 本值,因此播放速率与片段自身采样率无关,恰好是此帧率。Sprite atlas playback frame rate (panel range 0–120). Each anim slot's written length is frame count / this value, so playback advances at exactly this rate regardless of the sequence's own sample rate.
bCreateAnimToTexDAbooltrue本次烘焙是否创建 DA_<名>(AnimToTex 数据资产)。关闭时不新建,但仍会配置已存在的那个。Whether this bake creates DA_<name> (the AnimToTex data asset). When off it is not created, but an already existing one is still configured.
bCreateAgentConfigDAbooltrue本次烘焙是否创建 AgentConfig_<名>(单位类型数据资产);关闭时不新建,已存在的仍会被配置。Whether this bake creates AgentConfig_<name> (the unit-type data asset); when off nothing is created, but an existing one is still configured.
bRenameMeshbooltrue批量重命名时是否包含源骨骼网格本身。只作用于源资产,不作用于生成物。Whether Batch Rename includes the source skeletal mesh itself. Affects source assets only, never generated ones.
bRenameTexbooltrue批量重命名时是否包含查找到的原始贴图。Whether Batch Rename includes the original textures the auto-fill found.
bRenameAnimbooltrue批量重命名时是否包含查找到的动画序列。Whether Batch Rename includes the found animation sequences.
bShowSubstepsboolfalse面板子步骤按钮的显隐开关(勾选后显示自动填充、逐步执行与重命名按钮)。本类不读取它——纯 UI 状态,随 Profile 持久化。Visibility switch for the panel's sub-step buttons (turning it on reveals the auto-fill, per-step and rename buttons). This class never reads it — it is pure UI state persisted with the Profile.

自动填充链Auto-fill Chain

选定源网格后的一次性准备:从源资产反推名称与目录,再按命名关键词扫出 LOD、贴图与动画,最后裁掉超出槽位的动画。面板在源网格变化时一次性连跑这五步。

One-time preparation after picking a source mesh: derive the name and folders from the source asset, scan for LODs, textures and animations by naming keywords, then trim animations to the available slots. The panel runs all five in sequence when the source mesh changes.

ExtractMeshNameAndPath static bool

从源骨骼网格的资产路径反推三个路径字段:目录写入 SearchPath、文件名写入 AssetName、GeneratePath 为「目录/Gen_文件名」。三段都经过 SanitizeForPath 净化。没有源网格时记一条日志并返回失败,其余字段保持原样。

Derives three path fields from the source skeletal mesh's asset path: the directory into SearchPath, the file name into AssetName, and GeneratePath as "directory/Gen_filename". All three are sanitized through SanitizeForPath. With no source mesh it logs a line and reports failure, leaving the fields untouched.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&待填充的面板状态;读取 SkeletalMesh,写入三个路径字段。Panel state to fill; reads SkeletalMesh and writes the three path fields.
Output

返回是否推导成功。会覆盖面板上原有的搜索路径、资产名与生成路径——手填值在这一步之后不再保留。

Returns whether the derivation succeeded. It overwrites the existing search path, asset name and generate path — hand-typed values do not survive this step.

FindAndFillLOD static void

请 UMassBattleFuncLibEd::FindAndFillLODSettings 按源网格的 LOD 数与已有设置补齐逐 LOD 烘焙项,结果整体写回 LODSettings。面板上手动改过的屏幕尺寸/混合级别会被同长度的旧值保留,长度不足的项按网格补齐。

Asks UMassBattleFuncLibEd::FindAndFillLODSettings to complete the per-LOD bake entries from the source mesh's LOD count and the existing settings, writing the result back into LODSettings. Hand-edited screen sizes / blend levels are kept for as many entries as existed; missing entries are filled from the mesh.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取 SkeletalMesh 与现有 LODSettings,写回 LODSettings。Reads SkeletalMesh and the current LODSettings, writes LODSettings back.
Output

无返回值。副作用:仅替换 LODSettings 数组,不创建任何资产。

No return value. Side effect: replaces the LODSettings array only; creates no assets.

FindAndFillTex static void

以 SearchPath 为范围、按材质槽名关键词查找贴图,结果写入 OriginalTextures(每槽一条,含 ARM 合一贴图的自动识别)。这一步只做查找,不改名、不复制。

Searches SearchPath for textures by material-slot naming keywords and writes them into OriginalTextures (one entry per slot, including automatic detection of an ARM combined texture). This step only looks things up — it never renames or duplicates.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取 SkeletalMesh、SearchPath 与现有 OriginalTextures,写回后者。Reads SkeletalMesh, SearchPath and the current OriginalTextures; writes the latter back.
Output

无返回值。副作用:仅更新状态里的贴图表;资源库与此步骤无关。

No return value. Side effect: updates the texture table in the state only; the asset registry is not touched here.

FindAndFillAnim static void

把状态里八个动画桶打包成 FFoundAnimSequences,交给 FuncLibEd 按命名关键词在 SearchPath 内补全(待机/移动/坠落/出场/攻击/受击/死亡/其它),再整体写回八个数组。

Packs the state's eight animation buckets into FFoundAnimSequences, lets FuncLibEd complete them by naming keywords inside SearchPath (idle/move/fall/appear/attack/hit/death/other), then writes all eight arrays back.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取源网格、搜索路径与八个动画数组,写回八个数组。Reads the source mesh, search path and the eight animation arrays; writes the eight arrays back.
Output

无返回值。副作用:仅更新状态;不移动、不重命名任何资产。

No return value. Side effect: updates the state only; no asset is moved or renamed.

ValidateAnim static void

请 ValidateAnimSequences 校验八个动画桶:剔除空引用并把每类裁到可承载的槽位数(超出部分被丢弃而不是报错),结果写回状态。

Runs ValidateAnimSequences over the eight buckets: drops null references and trims each category to the number of slots it can carry (surplus entries are discarded rather than reported), writing the result back.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取并写回八个动画数组。Reads and writes back the eight animation arrays.
Output

无返回值。副作用:仅收敛八个数组;被裁掉的序列不会进入后续烘焙与重命名。

No return value. Side effect: only trims the eight arrays; discarded sequences do not reach the later bake or rename passes.

流水线步骤Pipeline Steps

五个可单独执行的步骤,合起来就是 Standard 的 Generate。每一步都以 ValidateAssetNameAndPath 开场,校验失败即静默退出(日志里能看到原因),不会留下半成品。另有清空与重命名两个维护动作。

Five individually runnable steps that together form the Standard Generate. Each starts with ValidateAssetNameAndPath and exits quietly on failure (the reason lands in the log) rather than leaving half-built assets. Two maintenance actions — clear and rename — sit alongside them.

CreateStaticMeshAndMat static void

把源骨骼网格转成静态网格(命名 SM_<名>,写入 LightMapUVChannel 指定的光照贴图 UV),再按 OriginalTextures 与 Creator Profile 的母材质为每个材质槽建材质实例。没有 Profile 时只记日志并返回——母材质挂在 Profile 上。生成物落在部件子目录(quickpath 为 P0)。

Converts the source skeletal mesh into a static mesh (named SM_<name>, with lightmap UVs in the channel named by LightMapUVChannel), then builds a material instance per material slot from OriginalTextures and the Creator Profile's master material. With no Profile it just logs and returns — the master material lives on the Profile. Products land in the part subfolder (P0 on the quickpath).

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取源网格、名称/路径、贴图表与 Profile;写入 StaticMesh。Reads the source mesh, name/paths, texture table and Profile; writes StaticMesh.
Pconst FMassBattleAgentCreatorParams&仅使用 LightMapUVChannel。Only LightMapUVChannel is used.
Output

无返回值。副作用:在磁盘上创建静态网格与材质实例,并写入 S.StaticMesh;转换失败时记日志、状态保持空。

No return value. Side effects: creates the static mesh and material instances on disk and writes S.StaticMesh; on conversion failure it logs and leaves the slot empty.

CreateRenderer static void

生成 NS_<名> 与 Renderer_<名> 两件核心资产。NS 由 Profile 的模板复制而来;若同名 NS 已存在则先删除再复制,保住正名(否则复制会自动加后缀、留下孤儿资产)。随后把槽 0 的网格 renderer 填成单条目(网格 + 逐粒子 LOD + 逐 section 材质覆盖,参数名 BoneMaterial_P0_V0_S<i>),移除多余的槽位 renderer 与所有非槽位网格 renderer(它们会在槽位路径之上叠画),再为本 NS 安装自包含的槽位桥接。渲染器蓝图优先原位复用同名类(场景里已摆放的实例会即时跟随新烘焙),否则从 Profile 模板复制;CDO 写入 K=1 的平凡配方后再统一设默认属性。

Produces the two core assets NS_<name> and Renderer_<name>. The NS is duplicated from the Profile's template; if an NS with that name already exists it is deleted first so the canonical name survives (otherwise the duplicate silently takes a suffix and orphans the old asset). Slot 0's mesh renderer is then filled with a single entry (mesh + per-particle LOD + per-section material overrides named BoneMaterial_P0_V0_S<i>); surplus slot renderers and all non-slot mesh renderers are removed (they would double-draw on top of the slot path), and a self-contained slot bridge is installed into the NS. The renderer Blueprint prefers reusing the same-named class in place (already placed instances follow the new bake immediately), otherwise it is duplicated from the Profile template; the CDO gets the trivial K=1 recipe before the class defaults are applied.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径、Profile、StaticMesh;写入 NSAsset 与 RendererInstance。Reads name/paths, Profile and StaticMesh; writes NSAsset and RendererInstance.
Output

无返回值。副作用:创建/覆盖 NS 与渲染器蓝图、改写 NS 的 emitter 与 renderer 结构、重编译渲染器蓝图;没有 Profile 或没有静态网格时只记日志。

No return value. Side effects: creates/overwrites the NS and renderer Blueprint, rewrites the NS's emitter/renderer structure and recompiles the renderer Blueprint; with no Profile or no static mesh it only logs.

CreateDataAsset static void

按两个开关分别创建/复用 DA_<名>(AnimToTex)与 AgentConfig_<名>,然后整批赋值:AnimToTex 侧写入两个网格、UV 通道、16 位精度、上限尺寸、采样率,并把八个动画桶去重后填成烘焙输入表;AgentConfig 侧写入渲染器类、由动画桶推出的播放开关,以及由 LOD 设置转换来的渲染 LOD 表。两个资产都原位复用同名对象,不产生带后缀的分叉件。

Creates or reuses DA_<name> (AnimToTex) and AgentConfig_<name> according to the two switches, then assigns wholesale: the AnimToTex side gets both meshes, the UV channel, 16-bit precision, size caps and sample rate, plus the eight animation buckets deduplicated into the bake input list; the AgentConfig side gets the renderer class, the playback flags derived from the animation buckets, and the render LOD table converted from the LOD settings. Both assets are reused in place — no suffixed forks are produced.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径、Profile、网格、动画桶与 LOD 设置;写入两个数据资产字段。Reads name/paths, Profile, meshes, animation buckets and LOD settings; writes the two data-asset fields.
Pconst FMassBattleAgentCreatorParams&使用两个 bCreate*DA 开关与 VATUVChannel / VATSampleRate。Uses the two bCreate*DA switches plus VATUVChannel / VATSampleRate.
Output

无返回值。副作用:创建或改写两个数据资产并标脏(不在此保存)。没有可用动画时记一条 "No animations",动画输入表保持为空。

No return value. Side effects: creates or rewrites the two data assets and marks them dirty (not saved here). With no usable animation it logs "No animations" and leaves the bake input list empty.

CreateVATTextures static void

按 LODSettings 逐 LOD 建立占位 VAT 纹理组:位置纹理,旋转/法线纹理,骨骼模式再加一张骨骼权重纹理。实际像素由下一步的烘焙写入。骨骼模式的位置/旋转纹理先按短名在已有纹理中查找,找到就跨 LOD 复用(骨骼库每骨架一份),找不到才新建。

Builds one placeholder VAT texture group per entry in LODSettings: a position texture, a rotation/normal texture, plus a bone-weight texture in bone mode. The pixels are written by the next step's bake. In bone mode the position/rotation textures are first looked up by short name among existing textures and reused across LODs when found (the bone library is one per skeleton); only a miss creates a new texture.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径与 LOD 设置;重置并重填 VATTextures。Reads name/paths and LOD settings; resets and refills VATTextures.
Output

无返回值。副作用:先清空 VATTextures 再逐 LOD 追加,因此已有引用会失效;创建出的纹理资产落盘路径与网格同级。

No return value. Side effect: clears VATTextures first and then appends per LOD, so pre-existing references are dropped; created textures sit next to the mesh on disk.

AnimToTextures static void

逐 LOD 执行像素烘焙:设置数据资产的 LOD 号与骨骼/顶点模式,解析本轮要用的纹理槽,调用烘焙库把动画写进纹理;随后给该 LOD 的每个材质实例写入 VAT 参数并设置混合/骨骼模式等静态开关(Layer 与 Global 两种关联同时写,层栈母材质与函数化母材质都能吃到)。全部 LOD 跑完后每次烘焙只做一份动画区间纹理(放在 VATTextures 下标 0)并把动画数据写进 AgentConfig;若本轮产出过骨骼模式材质实例,再把烘焙数据资产、基础材质与逐 section 材质表写进渲染器 CDO 并重编译。

Runs the pixel bake per LOD: sets the data asset's LOD index and bone/vertex mode, resolves the texture slots for this pass and calls the bake library to write the animations into the textures; every material instance of that LOD then receives the VAT parameters plus static switches such as bone mode and blend level (both Layer and Global associations are written, so layered and function-based masters both work). After all LODs it builds the animation-range texture once per bake (at VATTextures index 0) and writes the animation data into the AgentConfig; if a bone-mode material instance was produced, the bake data asset, base material and per-section material table are written into the renderer CDO and the Blueprint is recompiled.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取两个数据资产、静态网格、LOD 设置与动画桶;写纹理、材质实例参数、AgentConfig 与渲染器 CDO。Reads both data assets, the static mesh, LOD settings and animation buckets; writes textures, material-instance parameters, the AgentConfig and the renderer CDO.
Output

无返回值。副作用:改写纹理内容、材质实例、AgentConfig 与渲染器 CDO,并把渲染器蓝图重新编译。某个 LOD 烘焙失败只记一行日志、继续下一个 LOD;没有 AnimToTex 数据资产时直接返回。

No return value. Side effects: rewrites texture contents, material instances, the AgentConfig and the renderer CDO, and recompiles the renderer Blueprint. A failed LOD logs one line and the loop continues with the next; with no AnimToTex data asset it returns immediately.

ClearAll static void

把状态复位到「未选源网格」:清空两个网格、两个数据资产、NS、渲染器、名称与三个路径、LOD 与贴图表、VAT 纹理、八个动画桶;Sprite 侧同时清空图集、把行列数复位为 8 并清空帧区间。只动状态字段,不删除磁盘上的任何资产。工具模式由模型源推导(Standard / Advanced),不单独存储。

Resets the state to "no source mesh picked": clears both meshes, both data assets, the NS, the renderer, the name and three paths, LOD and texture tables, VAT textures and the eight animation buckets; the sprite side also clears the atlas, resets rows/columns to 8 and drops the frame ranges. It touches state fields only and deletes nothing on disk. The tool mode is derived from the model source (Standard or Advanced) and is not stored separately.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&被复位的状态。The state to reset.
Output

无返回值。副作用:仅清空状态字段;已生成的资产仍在磁盘上,需要删除请使用内容浏览器。

No return value. Side effect: clears state fields only; generated assets remain on disk — delete them through the Content Browser.

RenameAll static void

按当前名称批量重命名源资产。Sprite 档只把三个生成物(AgentConfig、材质实例、NS)重命名到当前名称/路径,图集本身永不触碰;网格档分别按三个开关重命名骨骼网格、原始贴图与动画序列。任一开关打开且有动作时记一行 "Rename pass complete"。

Batch-renames source assets to the current name. For sprite bands it only renames the three generated artifacts (AgentConfig, material instance, NS) to the current name/path and never touches the atlas itself; for mesh bands it renames the skeletal mesh, the original textures and the animation sequences according to the three switches. When any switch is on and something ran, it logs "Rename pass complete".

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径、工具模式与源资产引用。Reads name/paths, tool mode and source-asset references.
Pconst FMassBattleAgentCreatorParams&使用三个 bRename* 开关(Sprite 档忽略)。Uses the three bRename* switches (ignored for sprite bands).
Output

无返回值。副作用:就地改名源资产及其引用,磁盘路径随之变化;名称或路径非法时静默返回。

No return value. Side effect: renames in place, changing the source assets' on-disk paths and their references; an invalid name or path makes it return silently.

Sprite 图集管线Sprite Pipeline

图集路线不做像素烘焙:美术已经画好一张图集,工具只负责校验帧区间、装配三个生成物(渲染器蓝图与 NS、AgentConfig、材质实例),并通过材质参数把帧号映射到格子。因此这一组函数里没有 VAT 数据资产,也没有纹理输出。

The atlas route performs no pixel baking: the artist already painted the atlas, so the tool validates the frame ranges and assembles three artifacts (renderer Blueprint plus NS, AgentConfig, material instance), letting material parameters map a frame index to a cell. This group therefore has no VAT data asset and produces no textures.

ValidateSpriteMeta static bool

图集路线的总门禁:要求已设图集、行列数 ≥1;名称/路径为空时从图集资产路径播种(只填空字段,手输值优先);再校验每个已填槽的帧区间都落在「列×行」的格数内,且至少填了一个槽。返回失败时相应原因已写进日志。

The atlas route's gate: requires an atlas and rows/columns ≥ 1; seeds name/paths from the atlas asset path when empty (empty fields only — typed values win); then checks that every filled slot's frame range fits inside the columns × rows cell count and that at least one slot is filled. On failure the reason is already in the log.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取图集、行列数、帧区间与名称/路径;可能写入三个路径字段。Reads the atlas, grid dimensions, frame ranges and name/paths; may write the three path fields.
Output

返回是否通过。通过时可能已就地把空的名称/搜索路径/生成路径播种成图集派生的值。

Returns whether it passed. On success it may already have seeded empty name / search path / generate path with atlas-derived values.

CreateSpriteDataAsset static void

先跑 ValidateSpriteMeta,再在开关打开且状态里还没有 AgentConfig 时新建 AgentConfig_<名> 并写入:渲染器类、由帧区间推出的播放开关、单条常显的 sprite LOD 带,以及八个动画桶的帧区间元组(下标、时长=帧数/SpriteFPS、起始帧、结束帧)。材质据此由帧号反算格子。

Runs ValidateSpriteMeta first, then creates AgentConfig_<name> when the switch is on and the state holds none, writing: the renderer class, playback flags derived from the frame ranges, a single always-on sprite LOD band, and the frame-range tuples for the eight buckets (index, length = frames / SpriteFPS, start frame, end frame). The material derives the cell from the frame index.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取图集元数据、帧区间与渲染器类;写入 AgentConfigDataAsset。Reads atlas metadata, frame ranges and the renderer class; writes AgentConfigDataAsset.
Pconst FMassBattleAgentCreatorParams&使用 bCreateAgentConfigDA 与 SpriteFPS。Uses bCreateAgentConfigDA and SpriteFPS.
Output

无返回值。副作用:创建或改写 AgentConfig 并标脏;元数据校验失败时什么都不做。

No return value. Side effect: creates or rewrites the AgentConfig and marks it dirty; with failed metadata validation it does nothing.

CreateSpriteMaterial static void

以 Profile 的母材质为父创建 MI_<名>,写入三个约定参数:AtlasTexture(图集)、AtlasCols / AtlasRows(网格数)。没有母材质时记一行日志并跳过——母材质是与 VAT 路线共用的渲染线依赖。

Creates MI_<name> parented to the Profile's master material and writes the three contract parameters: AtlasTexture (the atlas) and AtlasCols / AtlasRows (grid dimensions). Without a master material it logs a line and skips — that material is the rendering-line dependency shared with the VAT route.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径、Profile、图集与行列数;写入 SpriteMaterialInstance。Reads name/paths, Profile, atlas and grid dimensions; writes SpriteMaterialInstance.
Output

无返回值。副作用:创建材质实例资产并写入三个参数;创建失败只记日志,状态字段保持空。

No return value. Side effects: creates the material-instance asset and writes the three parameters; on failure it only logs and leaves the state field empty.

CreateSpriteRenderer static void

复制 Profile 的 NS 模板为 NS_<名>,再从渲染器模板复制出 Renderer_<名> 并把两者绑定,网格槽留空——sprite 档没有静态网格。模板槽为空时记日志:NS 或渲染器缺任一个,配置都无法完成。

Duplicates the Profile's NS template into NS_<name>, duplicates the renderer template into Renderer_<name>, binds the two and leaves the mesh slot empty — the sprite tier has no static mesh. Empty template slots are logged: without either the NS or the renderer the configuration cannot complete.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取名称/路径与 Profile;写入 NSAsset 与 RendererInstance。Reads name/paths and Profile; writes NSAsset and RendererInstance.
Output

无返回值。副作用:创建 NS 与渲染器蓝图(不覆盖同名旧件——重复执行会得到带后缀的新资产),并把渲染器 CDO 与 NS 绑定。

No return value. Side effects: creates the NS and renderer Blueprint (no in-place overwrite — a repeat run yields suffixed new assets) and binds the renderer CDO to the NS.

Generate 入口Generate Entry Points

两个按钮级入口。Generate 是面板 Generate 实际调用的那个:它先做覆盖预检,再按工具模式分派——Advanced 走复合烘焙,Standard 走五步流水线(其中的 Sprite 档改为三步装配)。GenerateSprite 只跑 sprite 的三步装配,供需要绕过 Generate 的模式分派时直接使用。

Two button-level entry points. Generate is what the panel's Generate actually calls: it runs the overwrite pre-flight, then dispatches by tool mode — Advanced to the composite bake, Standard to the five-step pipeline (whose sprite bands run the three-step assembly instead). GenerateSprite runs only the three sprite assembly steps, for callers that need to bypass Generate's mode dispatch.

Generate static void

一次完整烘焙。① 覆盖预检:递归扫描 GeneratePath 下名字带生成物前缀的资产,若存在则弹一次确认窗按类分组列出,取消则分毫不动、首烘直通。② 模式分派:Advanced → 解析模板类并交给复合烘焙(槽里不是模板蓝图时只记日志);Standard → 先提示残留的模板值被忽略,再按档位表执行——网格档走五个步骤、Sprite 档走渲染器 / 数据资产 / 材质三步,部件级产物路由进 P0。③ 进度与结果:整个过程被一个进度对话框覆盖(五步序列逐步推进,烘焙步骤内部再报逐 LOD 子进度),结束按「五件产物是否齐全」给出成功/失败终态。同一时刻只允许一个 Generate——对话框已开着时直接记日志返回。

One complete bake. ① Overwrite pre-flight: recursively scans GeneratePath for assets carrying the generated-name prefixes; if any exist, one confirmation dialog lists them grouped by class — cancel leaves everything untouched, and a first bake goes straight through. ② Mode dispatch: Advanced → resolve the template class and hand off to the composite bake (a slot that does not hold a template Blueprint only logs); Standard → warn that a leftover template value is ignored, then work from the band table — mesh bands run the five steps, sprite bands run the renderer/data/material steps — routing part-level products into P0. ③ Progress and outcome: the whole run is covered by a progress dialog (the five steps advance one by one, and the bake step reports per-LOD sub-progress), finishing with a success/failure state based on whether all five artifacts are present. Only one Generate can run at a time — with the dialog already open it logs and returns.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&全部输入与输出都在这里:工具模式、Profile、源网格/图集、名称与路径,以及装配出的五件产物。All inputs and outputs live here: tool mode, Profile, source mesh/atlas, name and paths, plus the five assembled artifacts.
Pconst FMassBattleAgentCreatorParams&本次烘焙参数,透传给各步骤。This bake's parameters, passed through to the steps.
Output

无返回值。副作用:创建/覆盖 NS、渲染器蓝图、数据资产、材质实例与纹理;成功与否写进进度对话框终态与 creator 日志。不会替你保存未标脏的包——需要落盘请用编辑器的保存。

No return value. Side effects: creates/overwrites the NS, renderer Blueprint, data assets, material instances and textures; the outcome lands in the dialog's terminal state and the creator log. It does not save packages on your behalf — use the editor's save to persist.

GenerateSprite static void

只跑 sprite 的三步装配,顺序固定为渲染器 → 数据资产 → 材质实例:数据资产要引用渲染器类,而材质实例只依赖图集,所以这个顺序不能调换。它不开进度对话框、不做覆盖预检——这两件事由 Generate 负责。

Runs only the three sprite assembly steps, in the fixed order renderer → data asset → material instance: the data asset references the renderer class, while the material instance only needs the atlas, so the order cannot be swapped. It opens no progress dialog and performs no overwrite pre-flight — Generate owns both.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取图集、帧区间与 Profile;写入三个 sprite 产物。Reads the atlas, frame ranges and Profile; writes the three sprite artifacts.
Pconst FMassBattleAgentCreatorParams&使用 bCreateAgentConfigDA 与 SpriteFPS。Uses bCreateAgentConfigDA and SpriteFPS.
Output

无返回值。副作用:创建三个 sprite 产物并记 "Sprite generate complete";任一步的前置缺失(无图集、无 Profile 母材质等)会让该步只记日志,后续步骤照常尝试。

No return value. Side effects: creates the three sprite artifacts and logs "Sprite generate complete"; a missing precondition in any step (no atlas, no Profile master material, etc.) only logs there, and later steps still run.

辅助函数Helpers

面板与各步骤共用的状态搬运/查找小工具。它们不创建资产,只读写状态或做纯查询。

Small state-transport and lookup helpers shared by the panel and the steps. They create no assets — they read/write state or answer pure queries.

MakeAnimStruct / SetAnimSequences static FFoundAnimSequences / static void

状态与 FFoundAnimSequences 之间的双向搬运:MakeAnimStruct 把八个动画数组打包成结构体(供 FuncLibEd 与重命名使用),SetAnimSequences 把结构体拆回八个数组(用于接收查找/校验结果)。

Two-way transport between the state and FFoundAnimSequences: MakeAnimStruct packs the eight arrays into the struct (for FuncLibEd and the rename pass), and SetAnimSequences unpacks the struct back into the eight arrays (to receive find/validate results).

Input
参数Param类型Type说明Description
Sconst UMassBattleAgentCreatorState& / UMassBattleAgentCreatorState&前者只读,后者被写入。The former is read-only; the latter is written.
Foundconst FFoundAnimSequences&仅 SetAnimSequences:要拆回状态的八个数组。SetAnimSequences only: the eight arrays to unpack into the state.
Output

MakeAnimStruct 返回打包好的结构体;SetAnimSequences 无返回值,只覆盖状态里的八个数组。

MakeAnimStruct returns the packed struct; SetAnimSequences returns nothing and only overwrites the eight arrays in the state.

HasValidAnimSequence static bool

判断一个动画数组里是否至少有一个有效引用。用于把「填了动画」翻成数据资产上的播放开关(出场/受击/死亡/攻击/坠落)。

Reports whether an animation array holds at least one valid reference. Used to turn "has animations" into the data asset's playback flags (appear/hit/death/attack/fall).

Input
参数Param类型Type说明Description
AnimSequencesconst TArray<TObjectPtr<UAnimSequence>>&待检查的动画数组(如状态的 Attack 桶)。The array to inspect (e.g. the state's Attack bucket).
Output

有空/全部无效时返回 false;无副作用。

Returns false when empty or all references are invalid; no side effects.

FindTextureByName static UTexture2D*

在 VATTextures 的全部条目里做子串搜索(忽略大小写),命中的第一个纹理即返回。烘焙前的复用判断、烘焙后的逐 LOD 纹理解析都走它,因此命名规则(如 VAT_<名>_BonePosition、..._LOD<i>)就是实际的契约。

Substring search across every entry of VATTextures (case-insensitive) returning the first hit. Both the pre-bake reuse check and the post-bake per-LOD texture resolution go through it, so the naming rules (VAT_<name>_BonePosition, ..._LOD<i>, …) are the real contract.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&搜索范围:状态里的 VAT 纹理组。Search scope: the VAT texture groups in the state.
InNameconst FString&要匹配的名称片段。Name fragment to match.
Output

返回命中的纹理;没有命中返回 nullptr。无副作用。

Returns the matching texture, or nullptr when nothing matches. No side effects.

ValidateAssetNameAndPath static bool

生成资产前的共享校验:就地净化 AssetName 与 GeneratePath(去掉路径非法字符),再要求两者非空且拼出的包路径合法。失败时记一行 "Invalid Asset Name or GenerateToPath"。所有创建类步骤都以它开场。

The shared pre-creation check: sanitizes AssetName and GeneratePath in place (stripping characters illegal in paths), then requires both to be non-empty and the resulting package path to be valid. On failure it logs "Invalid Asset Name or GenerateToPath". Every creating step starts with it.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&读取并被就地改写的名称与生成路径。The name and generate path, read and rewritten in place.
Output

返回是否可继续创建。副作用:会改写状态里的名称与路径(净化后的值即面板显示的值)。

Returns whether creation may proceed. Side effect: it rewrites the name and path in the state — the sanitized values are what the panel then shows.

Log static void

统一的日志出口:追加到面板日志、同时写一份到引擎日志,并在烘焙进度对话框开着时把这行流进对话框。面板日志只保留最近 200 行(与图集烘焙器一致),所以长烘焙的早期输出以引擎日志为准。

The single logging sink: appends to the panel log, mirrors the line to the engine log, and streams it into the bake progress dialog while one is open. The panel log keeps only the latest 200 lines (matching the atlas baker), so early output of a long bake is best read from the engine log.

Input
参数Param类型Type说明Description
SUMassBattleAgentCreatorState&接收日志行的状态。The state receiving the line.
Lineconst FString&一条日志文本(多数来源自带中英双语)。One log line (most call sites carry both languages).
Output

无返回值。副作用:追加/裁剪面板日志、写引擎日志、可能写入进度对话框。

No return value. Side effects: appends/trims the panel log, writes the engine log, and may write into the progress dialog.

管线角色Pipeline Role

调用方只有一处:SMassBattleAgentCreatorPanel 的 Generate 按钮调用 Generate,各子步骤按钮直接调用对应的单个函数,自动填充链在源网格变化时连跑五步。Generate 自身再分派:Advanced 模式经 FMassBattleAssemblyCompositeBake::ResolveTemplateClass 校验后交给 复合烘焙;后者的逐版本烘焙反过来复用本类的 FindAndFillLOD / FindAndFillTex / CreateStaticMeshAndMat / CreateDataAsset / CreateVATTextures / AnimToTextures,因此两条路线产出的资产结构一致。CreateRenderer 通过 MassBattleAssemblySlotBridge 的 EnsureSlotRenderers / Install / EnsureMaterialParamsGrouped 把 NS 变成槽位驱动且自包含的结构,与复合烘焙殊途同归。所有产物最终落进 AgentConfig_<名>,由单位数据资产在运行时消费。

There is exactly one caller: the Generate button of SMassBattleAgentCreatorPanel calls Generate; the sub-step buttons call the individual functions directly, and the auto-fill chain runs all five when the source mesh changes. Generate then dispatches: in Advanced mode it validates through FMassBattleAssemblyCompositeBake::ResolveTemplateClass and hands over to the composite bake; that bake's per-version passes reuse this class's FindAndFillLOD / FindAndFillTex / CreateStaticMeshAndMat / CreateDataAsset / CreateVATTextures / AnimToTextures, which is why both routes produce the same asset structure. CreateRenderer uses MassBattleAssemblySlotBridge's EnsureSlotRenderers / Install / EnsureMaterialParamsGrouped to turn the NS into a slot-driven, self-contained structure — the same destination as the composite bake by a different road. Everything finally lands in AgentConfig_<name>, consumed at runtime through the unit data asset.

补充说明Notes

① 重烘即原位覆盖:数据资产、NS、渲染器蓝图、贴图与纹理都优先复用同名对象,名字不变、引用不漂移;因此重复烘焙一个已存在的单位不会让场景里的单位换资产。② 顺序有硬约束:渲染器先于数据资产(数据资产要引用渲染器类),渲染器与桥接先于烘焙(烘焙要往已填好的 renderer 里写参数),烘焙先于动画区间纹理(纹理要等动画帧区间落进数据资产后才存在)。③ 资产名与路径会被净化:非法字符被就地剥离,写路径前先看面板显示的值。④ 一条 Generate 一个对话框:重复点击会被告知已在运行,不会并发写同一批资产。

① A re-bake overwrites in place: data assets, the NS, the renderer Blueprint and all textures prefer the same-named object, so names stay stable and references do not drift — re-baking an existing unit never swaps the asset out from under placed units. ② Order is constrained: renderer before data asset (the data asset references the renderer class), renderer and bridge before the bake (the bake writes parameters into the already-filled renderer), and bake before the animation-range texture (that texture cannot exist until the frame ranges land in the data asset). ③ Names and paths are sanitized: illegal characters are stripped in place — check what the panel shows before relying on a path. ④ One dialog per Generate: a second click reports that a run is already in progress instead of writing the same assets concurrently.