Translate item kind from FieldItem

only trees and flowers are really necessary (for editing values)
This commit is contained in:
Kurt 2020-05-08 13:24:13 -07:00
parent 973ca2ddac
commit a6f88a048b
4 changed files with 20 additions and 3 deletions

View File

@ -69,5 +69,14 @@ public static class FieldItemKindExtensions
public static bool IsFlower(this FieldItemKind type) => PltFlwAnemone <= type && type <= PltFlwYuri;
public static bool IsTree(this FieldItemKind type) => PltTreeBamboo <= type && type <= PltTreePalm;
public static bool IsStone(this FieldItemKind type) => StoneA <= type && type <= StoneE;
public static ItemKind ToItemKind(this FieldItemKind type)
{
if (type.IsTree())
return ItemKind.Kind_Tree;
if (type.IsFlower())
return ItemKind.Kind_Flower;
return ItemKind.Unknown;
}
}
}

View File

@ -4,6 +4,14 @@ namespace NHSE.Core
{
public static class FieldItemList
{
public static ItemKind GetFieldItemKind(ushort id)
{
if (!Items.TryGetValue(id, out var definition))
return ItemKind.Unknown;
return definition.Kind.ToItemKind();
}
public static readonly IReadOnlyDictionary<ushort, FieldItemDefinition> Items = new Dictionary<ushort, FieldItemDefinition>
{
{0xEA60, new FieldItemDefinition(0xEA60, "PltTreeOak4", FieldItemKind.PltTreeOak)}, // 広葉樹(成木)

View File

@ -10,7 +10,7 @@ public static class ItemInfo
public static ItemKind GetItemKind(ushort id)
{
if (id > ItemKinds.Length)
return ItemKind.Unknown;
return FieldItemList.GetFieldItemKind(id);
return (ItemKind) ItemKinds[id];
}

View File

@ -9,9 +9,9 @@ public static class FieldItemColor
{
public static Color GetItemColor(Item item)
{
var kind = ItemInfo.GetItemKind(item);
if (kind == ItemKind.Unknown)
if (item.DisplayItemId > 60000)
return GetItemColor60000(item);
var kind = ItemInfo.GetItemKind(item);
return Colors[(int)kind];
}