Some character equip changes.

This commit is contained in:
Ottermandias 2022-07-27 13:04:57 +02:00
parent 7a7093369f
commit ee48c7803c

View file

@ -1,105 +1,111 @@
using System; using System;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Structs;
namespace Glamourer;
public unsafe struct CharacterArmorData
public readonly unsafe struct CharacterEquip {
{ public fixed byte Data[40];
public static readonly CharacterEquip Null = new(null); }
private readonly CharacterArmor* _armor; public readonly unsafe struct CharacterEquip
{
public IntPtr Address public static readonly CharacterEquip Null = new(null);
=> (IntPtr)_armor;
private readonly CharacterArmor* _armor;
public ref CharacterArmor this[int idx]
=> ref _armor[idx]; public IntPtr Address
=> ( IntPtr )_armor;
public ref CharacterArmor this[uint idx]
=> ref _armor[idx]; public ref CharacterArmor this[ int idx ]
=> ref _armor[ idx ];
public ref CharacterArmor this[EquipSlot slot]
=> ref _armor[IndexOf(slot)]; public ref CharacterArmor this[ uint idx ]
=> ref _armor[ idx ];
public ref CharacterArmor Head public ref CharacterArmor this[ EquipSlot slot ]
=> ref _armor[0]; => ref _armor[ IndexOf( slot ) ];
public ref CharacterArmor Body
=> ref _armor[1]; public ref CharacterArmor Head
=> ref _armor[ 0 ];
public ref CharacterArmor Hands
=> ref _armor[2]; public ref CharacterArmor Body
=> ref _armor[ 1 ];
public ref CharacterArmor Legs
=> ref _armor[3]; public ref CharacterArmor Hands
=> ref _armor[ 2 ];
public ref CharacterArmor Feet
=> ref _armor[4]; public ref CharacterArmor Legs
=> ref _armor[ 3 ];
public ref CharacterArmor Ears
=> ref _armor[5]; public ref CharacterArmor Feet
=> ref _armor[ 4 ];
public ref CharacterArmor Neck
=> ref _armor[6]; public ref CharacterArmor Ears
=> ref _armor[ 5 ];
public ref CharacterArmor Wrists
=> ref _armor[7]; public ref CharacterArmor Neck
=> ref _armor[ 6 ];
public ref CharacterArmor RFinger
=> ref _armor[8]; public ref CharacterArmor Wrists
=> ref _armor[ 7 ];
public ref CharacterArmor LFinger
=> ref _armor[9]; public ref CharacterArmor RFinger
=> ref _armor[ 8 ];
public CharacterEquip(CharacterArmor* val)
=> _armor = val; public ref CharacterArmor LFinger
=> ref _armor[ 9 ];
public static implicit operator CharacterEquip(CharacterArmor* val)
=> new(val); public CharacterEquip( CharacterArmor* val )
=> _armor = val;
public static implicit operator CharacterEquip(IntPtr val)
=> new((CharacterArmor*)val); public static implicit operator CharacterEquip( CharacterArmor* val )
=> new(val);
public static implicit operator CharacterEquip(ReadOnlySpan<CharacterArmor> val)
{ public static implicit operator CharacterEquip( IntPtr val )
if (val.Length != 10) => new(( CharacterArmor* )val);
throw new ArgumentException("Invalid number of equipment pieces in span.");
public static implicit operator CharacterEquip( ReadOnlySpan< CharacterArmor > val )
fixed (CharacterArmor* ptr = val) {
{ if( val.Length != 10 )
return new CharacterEquip(ptr); {
} throw new ArgumentException( "Invalid number of equipment pieces in span." );
} }
public static implicit operator bool(CharacterEquip equip) fixed( CharacterArmor* ptr = val )
=> equip._armor != null; {
return new CharacterEquip( ptr );
public static bool operator true(CharacterEquip equip) }
=> equip._armor != null; }
public static bool operator false(CharacterEquip equip) public static implicit operator bool( CharacterEquip equip )
=> equip._armor == null; => equip._armor != null;
public static bool operator !(CharacterEquip equip) public static bool operator true( CharacterEquip equip )
=> equip._armor == null; => equip._armor != null;
private static int IndexOf(EquipSlot slot) public static bool operator false( CharacterEquip equip )
{ => equip._armor == null;
return slot switch
{ public static bool operator !( CharacterEquip equip )
EquipSlot.Head => 0, => equip._armor == null;
EquipSlot.Body => 1,
EquipSlot.Hands => 2, private static int IndexOf( EquipSlot slot )
EquipSlot.Legs => 3, {
EquipSlot.Feet => 4, return slot switch
EquipSlot.Ears => 5, {
EquipSlot.Neck => 6, EquipSlot.Head => 0,
EquipSlot.Wrists => 7, EquipSlot.Body => 1,
EquipSlot.RFinger => 8, EquipSlot.Hands => 2,
EquipSlot.LFinger => 9, EquipSlot.Legs => 3,
_ => throw new ArgumentOutOfRangeException(nameof(slot), slot, null), EquipSlot.Feet => 4,
}; EquipSlot.Ears => 5,
} EquipSlot.Neck => 6,
} EquipSlot.Wrists => 7,
EquipSlot.RFinger => 8,
EquipSlot.LFinger => 9,
_ => throw new ArgumentOutOfRangeException( nameof( slot ), slot, null ),
};
}
}