feat(反射生成 UI): 字段配方落在宿主侧——预制体放零件,配方决定拼哪几块

新增 Recipes/(纯逻辑 + 一个预制体组件):
- FieldRecipeSet / FieldPlan:类型→配方的匹配与合并,逐字段 override 只覆盖写了的项。
  两条规矩:最具体的赢(写命名空间只认该类型,裸名按尾段匹配);没匹配到就说"没有配方",
  绝不回退默认配方。
- FieldLayout:给定计划 + 预制体真实有的槽位/输入元素,算出开哪些关哪些;
  返回值只答"能不能装",缺装饰件照样装但必须进 problems(注释写死这条契约)。
- FieldPartsAssembler:预制体上的槽位(label/required-mark/note/icon/legend/input/error,
  input 之下放各输入元素),Collect() 一次按名字收齐,Apply() 只改激活态。
- FieldRecipeTable:配方表资产。菜单路径集中成 HostMenuRoots(宿主不能反向引用蓝图包的路径表)。

XuiavrgInspectorManager 接入:预制体挑好挂上父级后 ApplyFieldRecipe(entry, instance)。
没指定配方表 → 说一句并按预制体原样;预制体没有槽位组件 → 原样;
匹配失败或装配有问题 → 逐条 LogWarning,点名 Entry、来源配方、缺的是什么。

新增 Tests~/RecipeProbe(dotnet 编两份纯逻辑文件):VERDICT RECIPE-PROBE PASS (19/19)。
判据(主工程根):bash check_flowgraph_extensions.sh
  -> host Lrss3.Xericuiactionvessel sources=209 errors=0 / VERDICT FGEXT-BUILD PASS
This commit is contained in:
2026-11-05 14:10:11 +08:00
parent a311c417be
commit a019183609
8 changed files with 630 additions and 0 deletions
@@ -83,6 +83,15 @@ namespace XericUI.ReflectionUIGenerator
[Tooltip("类型-预制体映射配置 ScriptableObject")]
public AvrgTypePrefabMappingConfig typePrefabMappingConfig;
/// <summary>
/// 可选:字段零件配方表。给了就用它决定"这块预制体上哪几件亮着"(预制体只放零件),
/// 不给就完全按预制体作者摆的样子用——两种情况会在 Console 里分得清。
/// </summary>
[Tooltip("可选:字段配方表(预制体放零件、配方决定拼哪几块)")]
public FieldRecipeTable fieldRecipes;
private bool _warnedNoRecipeTable;
#endregion
#region Unity 生命周期
@@ -340,6 +349,8 @@ namespace XericUI.ReflectionUIGenerator
uiInstance.name = entry.EntryName;
uiInstance.transform.SetParent(parent, false);
ApplyFieldRecipe(entry, uiInstance);
if (uiInstance.GetComponentInChildren<XUIAvrgMDValue>(true) == null)
{
Debug.LogError(
@@ -373,6 +384,40 @@ namespace XericUI.ReflectionUIGenerator
/// 3. defaultPrefab 回退
/// PrefabOverrideName 已移除,由 Tag + 类型匹配替代
/// </summary>
/// <summary>
/// 预制体挑好并挂上父级后,按配方决定"这块上的哪几件亮着"。
/// 没给配方表 / 这块预制体没有零件槽 ⇒ 原样使用,但各自说一句:
/// "我改了配方没生效"和"根本没有配方表"不能长得一样。
/// </summary>
private void ApplyFieldRecipe(IFieldEntry entry, GameObject instance)
{
if (fieldRecipes == null)
{
if (!_warnedNoRecipeTable)
{
_warnedNoRecipeTable = true;
Debug.Log("[Xuiavrg] 未指定 fieldRecipes:零件激活完全按预制体原样,配方表不参与。");
}
return;
}
var assembler = instance.GetComponent<FieldPartsAssembler>();
if (assembler == null) return;
var bindings = entry.Bindings;
var valueType = bindings?.Count > 0 ? bindings[0].MetaData?.ValueType : null;
if (!fieldRecipes.TryPlan(valueType == null ? "" : valueType.FullName, entry.EntryName,
out var plan, out var reason))
{
Debug.LogWarning($"[Xuiavrg] Entry '{entry.EntryName}'(类型 {valueType?.Name ?? "未知"}):{reason}");
return;
}
assembler.Apply(plan, out var problems);
for (var i = 0; i < problems.Count; i++)
Debug.LogWarning($"[Xuiavrg] Entry '{entry.EntryName}' 按 {plan.source} 装配时:{problems[i]}");
}
private GameObject ResolvePrefab(IFieldEntry entry)
{
if (typePrefabMappingConfig == null)