mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Make equipitems sharable again.
This commit is contained in:
parent
323b4d6f21
commit
8436455936
9 changed files with 146 additions and 52 deletions
|
|
@ -6,10 +6,11 @@ using Dalamud.Plugin;
|
|||
using Lumina.Excel.GeneratedSheets;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
|
||||
|
||||
namespace Penumbra.GameData.Data;
|
||||
|
||||
internal sealed class WeaponIdentificationList : KeyList<EquipItem>
|
||||
internal sealed class WeaponIdentificationList : KeyList<PseudoEquipItem>
|
||||
{
|
||||
private const string Tag = "WeaponIdentification";
|
||||
private const int Version = 1;
|
||||
|
|
@ -19,16 +20,16 @@ internal sealed class WeaponIdentificationList : KeyList<EquipItem>
|
|||
{ }
|
||||
|
||||
public IEnumerable<EquipItem> Between(SetId modelId)
|
||||
=> Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF));
|
||||
=> Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF)).Select(e => (EquipItem)e);
|
||||
|
||||
public IEnumerable<EquipItem> Between(SetId modelId, WeaponType type, byte variant = 0)
|
||||
{
|
||||
if (type == 0)
|
||||
return Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF));
|
||||
return Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF)).Select(e => (EquipItem)e);
|
||||
if (variant == 0)
|
||||
return Between(ToKey(modelId, type, 0), ToKey(modelId, type, 0xFF));
|
||||
return Between(ToKey(modelId, type, 0), ToKey(modelId, type, 0xFF)).Select(e => (EquipItem)e);
|
||||
|
||||
return Between(ToKey(modelId, type, variant), ToKey(modelId, type, variant));
|
||||
return Between(ToKey(modelId, type, variant), ToKey(modelId, type, variant)).Select(e => (EquipItem)e);
|
||||
}
|
||||
|
||||
public void Dispose(DalamudPluginInterface pi, ClientLanguage language)
|
||||
|
|
@ -40,7 +41,7 @@ internal sealed class WeaponIdentificationList : KeyList<EquipItem>
|
|||
public static ulong ToKey(EquipItem i)
|
||||
=> ToKey(i.ModelId, i.WeaponType, i.Variant);
|
||||
|
||||
protected override IEnumerable<ulong> ToKeys(EquipItem data)
|
||||
protected override IEnumerable<ulong> ToKeys(PseudoEquipItem data)
|
||||
{
|
||||
yield return ToKey(data);
|
||||
}
|
||||
|
|
@ -48,20 +49,20 @@ internal sealed class WeaponIdentificationList : KeyList<EquipItem>
|
|||
protected override bool ValidKey(ulong key)
|
||||
=> key != 0;
|
||||
|
||||
protected override int ValueKeySelector(EquipItem data)
|
||||
=> (int)data.Id;
|
||||
protected override int ValueKeySelector(PseudoEquipItem data)
|
||||
=> (int)data.Item2;
|
||||
|
||||
private static IEnumerable<EquipItem> CreateWeaponList(DataManager gameData, ClientLanguage language)
|
||||
private static IEnumerable<PseudoEquipItem> CreateWeaponList(DataManager gameData, ClientLanguage language)
|
||||
=> gameData.GetExcelSheet<Item>(language)!.SelectMany(ToEquipItems);
|
||||
|
||||
private static IEnumerable<EquipItem> ToEquipItems(Item item)
|
||||
private static IEnumerable<PseudoEquipItem> ToEquipItems(Item item)
|
||||
{
|
||||
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);
|
||||
yield return (PseudoEquipItem)EquipItem.FromMainhand(item);
|
||||
if (item.ModelSub != 0)
|
||||
yield return EquipItem.FromOffhand(item);
|
||||
yield return (PseudoEquipItem)EquipItem.FromOffhand(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue