- 统一 ItemDescForm/RewardItem/GoodsItem 的描述格式
- 减少组件属性的 Clone 数量,目前只在合并仓库、组装防御塔时才进行复制
- 删除先前留下的冗余 fallback 代码
This commit is contained in:
SepComet
2026-03-12 15:58:14 +08:00
parent 9e59865368
commit 4962b98714
20 changed files with 263 additions and 435 deletions
@@ -5,7 +5,6 @@ namespace GeometryTD.UI
{
public class RewardSelectItemRawData
{
public long RewardId;
public TowerCompSlotType SlotType;
public string Title;
public string TypeText;
@@ -13,8 +12,6 @@ namespace GeometryTD.UI
public RarityType Rarity;
public TagType[] Tags;
public Sprite Icon;
public bool IsSelectable = true;
public TowerCompItemData SourceItem;
public object UserData;
}
}
@@ -0,0 +1,56 @@
using System;
using GeometryTD.CustomUtility;
using GeometryTD.Definition;
namespace GeometryTD.UI
{
public static class RewardSelectItemRawDataBuilder
{
public static RewardSelectItemRawData Build(TowerCompItemData item)
{
return new RewardSelectItemRawData
{
SlotType = item.SlotType,
Title = item.Name,
TypeText = BuildTypeText(item.SlotType),
Description = BuildDescription(item),
Rarity = item.Rarity,
Tags = item.Tags != null ? (TagType[])item.Tags.Clone() : Array.Empty<TagType>(),
Icon = null,
SourceItem = item
};
}
private static string BuildTypeText(TowerCompSlotType slotType)
{
return slotType switch
{
TowerCompSlotType.Muzzle => "Muzzle Component",
TowerCompSlotType.Bearing => "Bearing Component",
TowerCompSlotType.Base => "Base Component",
TowerCompSlotType.Accessory => "Accessory",
_ => "Component"
};
}
private static string BuildDescription(TowerCompItemData item)
{
if (item is MuzzleCompItemData muzzle)
{
return ItemDescUtility.BuildMuzzleDesc(muzzle);
}
if (item is BearingCompItemData bearing)
{
return ItemDescUtility.BuildBearingDesc(bearing);
}
if (item is BaseCompItemData baseComp)
{
return ItemDescUtility.BuildBaseDesc(baseComp);
}
return string.Empty;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51c6fdd5a34ab044d96fd416188e7a9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: