31 lines
972 B
C#
31 lines
972 B
C#
using System.Collections.Generic;
|
|
|
|
public interface IAsrsPrefabCatalog
|
|
{
|
|
IReadOnlyList<PrefabCatalogItem> GetItems();
|
|
|
|
// 빠른 조회용(선택): prefab id로 PrefabData를 얻고 싶을 때
|
|
bool TryGetById(string prefabId, out PrefabCatalogItem item);
|
|
}
|
|
|
|
public readonly struct PrefabCatalogItem
|
|
{
|
|
public readonly string Id; // initialize.prefab에 저장되는 키
|
|
public readonly PrefabData Data; // 사용자 제공 PrefabData
|
|
|
|
public PrefabCatalogItem(string id, PrefabData data)
|
|
{
|
|
Id = id;
|
|
Data = data;
|
|
}
|
|
|
|
// UI 표시명 우선순위: label > name > id
|
|
public string DisplayName
|
|
=> !string.IsNullOrWhiteSpace(Data?.label) ? Data.label
|
|
: !string.IsNullOrWhiteSpace(Data?.name) ? Data.name
|
|
: Id;
|
|
|
|
public float Cost => Data != null ? Data.cost : 0f;
|
|
public string Color => Data != null ? Data.color : null;
|
|
public IReadOnlyList<PrefabDataTag> Tags => Data?.tags;
|
|
} |