Fix changed item event.

This commit is contained in:
Ottermandias 2023-06-09 18:13:52 +02:00
parent e72479c046
commit 387b6da4d5

View file

@ -1,5 +1,7 @@
using System;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using Penumbra.Api.Enums;
using Penumbra.GameData.Structs;
using Action = Lumina.Excel.GeneratedSheets.Action;
namespace Penumbra.GameData.Enums;
@ -11,9 +13,21 @@ public static class ChangedItemExtensions
return item switch
{
null => (ChangedItemType.None, 0),
EquipItem i => (ChangedItemType.Item, i.Id),
Item i => (ChangedItemType.Item, i.RowId),
Action a => (ChangedItemType.Action, a.RowId),
_ => (ChangedItemType.Customization, 0),
};
}
public static object? GetObject(this ChangedItemType type, DataManager manager, uint id)
{
return type switch
{
ChangedItemType.None => null,
ChangedItemType.Item => manager.GetExcelSheet<Item>()?.GetRow(id),
ChangedItemType.Action => manager.GetExcelSheet<Action>()?.GetRow(id),
ChangedItemType.Customization => null,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};
}
}