Use EquipItem in item management and add filters to changed item types.

This commit is contained in:
Ottermandias 2023-06-09 16:10:02 +02:00
parent 5fcb07487e
commit d9c5c053cf
19 changed files with 641 additions and 375 deletions

View file

@ -1,33 +1,19 @@
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;
public static class ChangedItemExtensions
{
public static (ChangedItemType, uint) ChangedItemToTypeAndId( object? item )
public static (ChangedItemType, uint) ChangedItemToTypeAndId(object? item)
{
return item switch
{
null => ( ChangedItemType.None, 0 ),
Item i => ( ChangedItemType.Item, i.RowId ),
Action a => ( ChangedItemType.Action, a.RowId ),
_ => ( ChangedItemType.Customization, 0 ),
null => (ChangedItemType.None, 0),
EquipItem i => (ChangedItemType.Item, i.Id),
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 ),
};
}
}
}