mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-06 01:40:27 -05:00
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
namespace NHSE.Core
|
|
{
|
|
/// <summary>
|
|
/// Fetching metadata about an <see cref="Item"/>
|
|
/// </summary>
|
|
public static class ItemInfo
|
|
{
|
|
// derived from bcsv; only some data is needed for our logic
|
|
private static readonly byte[] ItemKinds = ResourceUtil.GetBinaryResource("item_kind.bin");
|
|
private static readonly byte[] ItemSizes = ResourceUtil.GetBinaryResource("item_size.bin");
|
|
private static readonly ushort[] ItemMenuIcons = ResourceUtil.GetBinaryResourceAsUshort("item_menuicon.bin");
|
|
|
|
public static ItemKind GetItemKind(Item item) => GetItemKind(item.DisplayItemId);
|
|
|
|
public static ItemKind GetItemKind(ushort id)
|
|
{
|
|
if (id > ItemKinds.Length)
|
|
return FieldItemList.GetFieldItemKind(id);
|
|
return (ItemKind) ItemKinds[id];
|
|
}
|
|
|
|
public static ItemSizeType GetItemSize(Item item)
|
|
{
|
|
if (item.IsBuried || item.IsDropped)
|
|
return ItemSizeType.S_1_0x1_0;
|
|
|
|
return GetItemSize(item.DisplayItemId);
|
|
}
|
|
|
|
public static ItemSizeType GetItemSize(ushort id)
|
|
{
|
|
if (id > ItemSizes.Length)
|
|
return ItemSizeType.Unknown;
|
|
return (ItemSizeType)ItemSizes[id];
|
|
}
|
|
|
|
public static ItemMenuIconType GetMenuIcon(ushort id)
|
|
{
|
|
if (id > ItemMenuIcons.Length)
|
|
return ItemMenuIconType.Unknown;
|
|
return (ItemMenuIconType)ItemMenuIcons[id];
|
|
}
|
|
}
|
|
}
|