mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-28 05:44:40 -05:00
Translate item kind from FieldItem
only trees and flowers are really necessary (for editing values)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)}, // 広葉樹(成木)
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user