mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Make equipitems sharable again.
This commit is contained in:
parent
323b4d6f21
commit
8436455936
9 changed files with 146 additions and 52 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using Dalamud.Utility;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Penumbra.GameData.Enums;
|
||||
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
|
||||
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
|
|
@ -15,7 +16,6 @@ public readonly struct EquipItem
|
|||
public readonly WeaponType WeaponType;
|
||||
public readonly byte Variant;
|
||||
public readonly FullEquipType Type;
|
||||
public readonly EquipSlot Slot;
|
||||
|
||||
public bool Valid
|
||||
=> Type != FullEquipType.Unknown;
|
||||
|
|
@ -35,8 +35,7 @@ public readonly struct EquipItem
|
|||
public EquipItem()
|
||||
=> Name = string.Empty;
|
||||
|
||||
public EquipItem(string name, uint id, ushort iconId, SetId modelId, WeaponType weaponType, byte variant, FullEquipType type,
|
||||
EquipSlot slot)
|
||||
public EquipItem(string name, uint id, ushort iconId, SetId modelId, WeaponType weaponType, byte variant, FullEquipType type)
|
||||
{
|
||||
Name = string.Intern(name);
|
||||
Id = id;
|
||||
|
|
@ -45,20 +44,24 @@ public readonly struct EquipItem
|
|||
WeaponType = weaponType;
|
||||
Variant = variant;
|
||||
Type = type;
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
public static implicit operator EquipItem(PseudoEquipItem it)
|
||||
=> new(it.Item1, it.Item2, it.Item3, it.Item4, it.Item5, it.Item6, (FullEquipType)it.Item7);
|
||||
|
||||
public static explicit operator PseudoEquipItem(EquipItem it)
|
||||
=> (it.Name, it.Id, it.IconId, (ushort)it.ModelId, (ushort)it.WeaponType, it.Variant, (byte)it.Type);
|
||||
|
||||
public static EquipItem FromArmor(Item item)
|
||||
{
|
||||
var type = item.ToEquipType();
|
||||
var slot = type.ToSlot();
|
||||
var name = item.Name.ToDalamudString().TextValue;
|
||||
var id = item.RowId;
|
||||
var icon = item.Icon;
|
||||
var model = (SetId)item.ModelMain;
|
||||
var weapon = (WeaponType)0;
|
||||
var variant = (byte)(item.ModelMain >> 16);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type, slot);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type);
|
||||
}
|
||||
|
||||
public static EquipItem FromMainhand(Item item)
|
||||
|
|
@ -70,7 +73,7 @@ public readonly struct EquipItem
|
|||
var model = (SetId)item.ModelMain;
|
||||
var weapon = (WeaponType)(item.ModelMain >> 16);
|
||||
var variant = (byte)(item.ModelMain >> 32);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type, EquipSlot.MainHand);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type);
|
||||
}
|
||||
|
||||
public static EquipItem FromOffhand(Item item)
|
||||
|
|
@ -82,6 +85,6 @@ public readonly struct EquipItem
|
|||
var model = (SetId)item.ModelSub;
|
||||
var weapon = (WeaponType)(item.ModelSub >> 16);
|
||||
var variant = (byte)(item.ModelSub >> 32);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type, EquipSlot.OffHand);
|
||||
return new EquipItem(name, id, icon, model, weapon, variant, type);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue