mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Use EquipItem in item management and add filters to changed item types.
This commit is contained in:
parent
5fcb07487e
commit
d9c5c053cf
19 changed files with 641 additions and 375 deletions
|
|
@ -9,7 +9,7 @@ using Penumbra.GameData.Structs;
|
|||
|
||||
namespace Penumbra.GameData.Data;
|
||||
|
||||
internal sealed class WeaponIdentificationList : KeyList<Item>
|
||||
internal sealed class WeaponIdentificationList : KeyList<EquipItem>
|
||||
{
|
||||
private const string Tag = "WeaponIdentification";
|
||||
private const int Version = 1;
|
||||
|
|
@ -18,10 +18,10 @@ internal sealed class WeaponIdentificationList : KeyList<Item>
|
|||
: base(pi, Tag, language, Version, CreateWeaponList(gameData, language))
|
||||
{ }
|
||||
|
||||
public IEnumerable<Item> Between(SetId modelId)
|
||||
public IEnumerable<EquipItem> Between(SetId modelId)
|
||||
=> Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF));
|
||||
|
||||
public IEnumerable<Item> Between(SetId modelId, WeaponType type, byte variant = 0)
|
||||
public IEnumerable<EquipItem> Between(SetId modelId, WeaponType type, byte variant = 0)
|
||||
{
|
||||
if (type == 0)
|
||||
return Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF));
|
||||
|
|
@ -37,38 +37,31 @@ internal sealed class WeaponIdentificationList : KeyList<Item>
|
|||
public static ulong ToKey(SetId modelId, WeaponType type, byte variant)
|
||||
=> ((ulong)modelId << 32) | ((ulong)type << 16) | variant;
|
||||
|
||||
public static ulong ToKey(Item i, bool offhand)
|
||||
{
|
||||
var quad = offhand ? (Lumina.Data.Parsing.Quad)i.ModelSub : (Lumina.Data.Parsing.Quad)i.ModelMain;
|
||||
return ToKey(quad.A, quad.B, (byte)quad.C);
|
||||
}
|
||||
public static ulong ToKey(EquipItem i)
|
||||
=> ToKey(i.ModelId, i.WeaponType, i.Variant);
|
||||
|
||||
protected override IEnumerable<ulong> ToKeys(Item i)
|
||||
protected override IEnumerable<ulong> ToKeys(EquipItem data)
|
||||
{
|
||||
var key1 = 0ul;
|
||||
if (i.ModelMain != 0)
|
||||
{
|
||||
key1 = ToKey(i, false);
|
||||
yield return key1;
|
||||
}
|
||||
|
||||
if (i.ModelSub != 0)
|
||||
{
|
||||
var key2 = ToKey(i, true);
|
||||
if (key1 != key2)
|
||||
yield return key2;
|
||||
}
|
||||
yield return ToKey(data);
|
||||
}
|
||||
|
||||
protected override bool ValidKey(ulong key)
|
||||
=> key != 0;
|
||||
|
||||
protected override int ValueKeySelector(Item data)
|
||||
=> (int)data.RowId;
|
||||
protected override int ValueKeySelector(EquipItem data)
|
||||
=> (int)data.Id;
|
||||
|
||||
private static IEnumerable<Item> CreateWeaponList(DataManager gameData, ClientLanguage language)
|
||||
private static IEnumerable<EquipItem> CreateWeaponList(DataManager gameData, ClientLanguage language)
|
||||
=> gameData.GetExcelSheet<Item>(language)!.SelectMany(ToEquipItems);
|
||||
|
||||
private static IEnumerable<EquipItem> ToEquipItems(Item item)
|
||||
{
|
||||
var items = gameData.GetExcelSheet<Item>(language)!;
|
||||
return items.Where(i => (EquipSlot)i.EquipSlotCategory.Row is EquipSlot.MainHand or EquipSlot.OffHand or EquipSlot.BothHand);
|
||||
if ((EquipSlot)item.EquipSlotCategory.Row is not (EquipSlot.MainHand or EquipSlot.OffHand or EquipSlot.BothHand))
|
||||
yield break;
|
||||
|
||||
if (item.ModelMain != 0)
|
||||
yield return EquipItem.FromMainhand(item);
|
||||
if (item.ModelSub != 0)
|
||||
yield return EquipItem.FromOffhand(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue