Rename some collection stuff.

This commit is contained in:
Ottermandias 2022-08-13 21:18:21 +02:00
parent f264725c45
commit 8aefdbd948
9 changed files with 51 additions and 35 deletions

View file

@ -1,13 +1,9 @@
using System;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Util;
namespace Penumbra.GameData.Structs;
public unsafe struct CharacterArmorData
{
public fixed byte Data[40];
}
public readonly unsafe struct CharacterEquip
{
public static readonly CharacterEquip Null = new(null);
@ -26,7 +22,6 @@ public readonly unsafe struct CharacterEquip
public ref CharacterArmor this[ EquipSlot slot ]
=> ref _armor[ IndexOf( slot ) ];
public ref CharacterArmor Head
=> ref _armor[ 0 ];
@ -108,4 +103,12 @@ public readonly unsafe struct CharacterEquip
_ => throw new ArgumentOutOfRangeException( nameof( slot ), slot, null ),
};
}
public void Write( IntPtr target )
{
Functions.MemCpyUnchecked( ( void* )target, _armor, sizeof( CharacterArmor ) * 10 );
}
public bool Equals( CharacterEquip other )
=> Functions.MemCmpUnchecked( ( void* )_armor, ( void* )other._armor, sizeof( CharacterArmor ) * 10 ) == 0;
}

View file

@ -17,7 +17,7 @@ public unsafe struct CustomizeData : IEquatable< CustomizeData >
}
}
public void Write( void* target )
public readonly void Write( void* target )
{
fixed( byte* ptr = Data )
{
@ -25,14 +25,14 @@ public unsafe struct CustomizeData : IEquatable< CustomizeData >
}
}
public CustomizeData Clone()
public readonly CustomizeData Clone()
{
var ret = new CustomizeData();
Write( ret.Data );
return ret;
}
public bool Equals( CustomizeData other )
public readonly bool Equals( CustomizeData other )
{
fixed( byte* ptr = Data )
{
@ -40,6 +40,9 @@ public unsafe struct CustomizeData : IEquatable< CustomizeData >
}
}
public static bool Equals( CustomizeData* lhs, CustomizeData* rhs )
=> Functions.MemCmpUnchecked( lhs, rhs, Size ) == 0;
public override bool Equals( object? obj )
=> obj is CustomizeData other && Equals( other );