mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Some early glamourer changes.
This commit is contained in:
parent
c2bc8252f1
commit
9dee0862cc
17 changed files with 192 additions and 840 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Penumbra.GameData.Enums;
|
||||
|
||||
|
|
@ -51,6 +52,22 @@ public static class EquipSlotExtensions
|
|||
_ => EquipSlot.Unknown,
|
||||
};
|
||||
|
||||
public static uint ToIndex( this EquipSlot slot )
|
||||
=> slot switch
|
||||
{
|
||||
EquipSlot.Head => 0,
|
||||
EquipSlot.Body => 1,
|
||||
EquipSlot.Hands => 2,
|
||||
EquipSlot.Legs => 3,
|
||||
EquipSlot.Feet => 4,
|
||||
EquipSlot.Ears => 5,
|
||||
EquipSlot.Neck => 6,
|
||||
EquipSlot.Wrists => 7,
|
||||
EquipSlot.RFinger => 8,
|
||||
EquipSlot.LFinger => 9,
|
||||
_ => uint.MaxValue,
|
||||
};
|
||||
|
||||
public static string ToSuffix( this EquipSlot value )
|
||||
{
|
||||
return value switch
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit, Pack = 1 )]
|
||||
public readonly struct CharacterArmor
|
||||
public readonly struct CharacterArmor : IEquatable< CharacterArmor >
|
||||
{
|
||||
[FieldOffset( 0 )]
|
||||
public readonly uint Value;
|
||||
|
||||
[FieldOffset( 0 )]
|
||||
public readonly SetId Set;
|
||||
|
||||
|
|
@ -14,9 +18,31 @@ public readonly struct CharacterArmor
|
|||
[FieldOffset( 3 )]
|
||||
public readonly StainId Stain;
|
||||
|
||||
[FieldOffset( 0 )]
|
||||
public readonly uint Value;
|
||||
public CharacterArmor( SetId set, byte variant, StainId stain )
|
||||
{
|
||||
Value = 0;
|
||||
Set = set;
|
||||
Variant = variant;
|
||||
Stain = stain;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Set},{Variant},{Stain}";
|
||||
|
||||
public static readonly CharacterArmor Empty;
|
||||
|
||||
public bool Equals( CharacterArmor other )
|
||||
=> Value == other.Value;
|
||||
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is CharacterArmor other && Equals( other );
|
||||
|
||||
public override int GetHashCode()
|
||||
=> ( int )Value;
|
||||
|
||||
public static bool operator ==( CharacterArmor left, CharacterArmor right )
|
||||
=> left.Value == right.Value;
|
||||
|
||||
public static bool operator !=( CharacterArmor left, CharacterArmor right )
|
||||
=> left.Value != right.Value;
|
||||
}
|
||||
|
|
@ -1,16 +1,51 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Penumbra.GameData.Structs
|
||||
{
|
||||
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
|
||||
public readonly struct CharacterWeapon
|
||||
{
|
||||
public readonly SetId Set;
|
||||
public readonly WeaponType Type;
|
||||
public readonly ushort Variant;
|
||||
public readonly StainId Stain;
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Set},{Type},{Variant},{Stain}";
|
||||
[StructLayout( LayoutKind.Explicit, Pack = 1, Size = 7 )]
|
||||
public readonly struct CharacterWeapon : IEquatable< CharacterWeapon >
|
||||
{
|
||||
[FieldOffset( 0 )]
|
||||
public readonly SetId Set;
|
||||
|
||||
[FieldOffset( 2 )]
|
||||
public readonly WeaponType Type;
|
||||
|
||||
[FieldOffset( 4 )]
|
||||
public readonly ushort Variant;
|
||||
|
||||
[FieldOffset( 6 )]
|
||||
public readonly StainId Stain;
|
||||
|
||||
public ulong Value
|
||||
=> ( ulong )Set | ( ( ulong )Type << 16 ) | ( ( ulong )Variant << 32 ) | ( ( ulong )Stain << 48 );
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Set},{Type},{Variant},{Stain}";
|
||||
|
||||
public CharacterWeapon( SetId set, WeaponType type, ushort variant, StainId stain )
|
||||
{
|
||||
Set = set;
|
||||
Type = type;
|
||||
Variant = variant;
|
||||
Stain = stain;
|
||||
}
|
||||
|
||||
public static readonly CharacterWeapon Empty = new(0, 0, 0, 0);
|
||||
|
||||
public bool Equals( CharacterWeapon other )
|
||||
=> Value == other.Value;
|
||||
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is CharacterWeapon other && Equals( other );
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Value.GetHashCode();
|
||||
|
||||
public static bool operator ==( CharacterWeapon left, CharacterWeapon right )
|
||||
=> left.Value == right.Value;
|
||||
|
||||
public static bool operator !=( CharacterWeapon left, CharacterWeapon right )
|
||||
=> left.Value != right.Value;
|
||||
}
|
||||
|
|
@ -200,12 +200,12 @@ public static class Eqp
|
|||
EqpEntry.HeadShowVieraHat => EquipSlot.Head,
|
||||
|
||||
// Currently unused.
|
||||
EqpEntry._58 => EquipSlot.Unknown,
|
||||
EqpEntry._59 => EquipSlot.Unknown,
|
||||
EqpEntry._60 => EquipSlot.Unknown,
|
||||
EqpEntry._61 => EquipSlot.Unknown,
|
||||
EqpEntry._62 => EquipSlot.Unknown,
|
||||
EqpEntry._63 => EquipSlot.Unknown,
|
||||
EqpEntry._58 => EquipSlot.Unknown,
|
||||
EqpEntry._59 => EquipSlot.Unknown,
|
||||
EqpEntry._60 => EquipSlot.Unknown,
|
||||
EqpEntry._61 => EquipSlot.Unknown,
|
||||
EqpEntry._62 => EquipSlot.Unknown,
|
||||
EqpEntry._63 => EquipSlot.Unknown,
|
||||
|
||||
_ => EquipSlot.Unknown,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,55 +4,54 @@ using System.IO;
|
|||
using System.Runtime.InteropServices;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
||||
namespace Penumbra.GameData.Structs
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
|
||||
public readonly struct RspEntry
|
||||
{
|
||||
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
|
||||
public readonly struct RspEntry
|
||||
public const int ByteSize = ( int )RspAttribute.NumAttributes * 4;
|
||||
|
||||
private readonly float[] Attributes;
|
||||
|
||||
public RspEntry( RspEntry copy )
|
||||
=> Attributes = ( float[] )copy.Attributes.Clone();
|
||||
|
||||
public RspEntry( byte[] bytes, int offset )
|
||||
{
|
||||
public const int ByteSize = ( int )RspAttribute.NumAttributes * 4;
|
||||
|
||||
private readonly float[] Attributes;
|
||||
|
||||
public RspEntry( RspEntry copy )
|
||||
=> Attributes = ( float[] )copy.Attributes.Clone();
|
||||
|
||||
public RspEntry( byte[] bytes, int offset )
|
||||
if( offset < 0 || offset + ByteSize > bytes.Length )
|
||||
{
|
||||
if( offset < 0 || offset + ByteSize > bytes.Length )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
Attributes = new float[( int )RspAttribute.NumAttributes];
|
||||
using MemoryStream s = new( bytes ) { Position = offset };
|
||||
using BinaryReader br = new( s );
|
||||
for( var i = 0; i < ( int )RspAttribute.NumAttributes; ++i )
|
||||
{
|
||||
Attributes[ i ] = br.ReadSingle();
|
||||
}
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
private static int ToIndex( RspAttribute attribute )
|
||||
=> attribute < RspAttribute.NumAttributes && attribute >= 0
|
||||
? ( int )attribute
|
||||
: throw new InvalidEnumArgumentException();
|
||||
|
||||
public float this[ RspAttribute attribute ]
|
||||
Attributes = new float[( int )RspAttribute.NumAttributes];
|
||||
using MemoryStream s = new(bytes) { Position = offset };
|
||||
using BinaryReader br = new(s);
|
||||
for( var i = 0; i < ( int )RspAttribute.NumAttributes; ++i )
|
||||
{
|
||||
get => Attributes[ ToIndex( attribute ) ];
|
||||
set => Attributes[ ToIndex( attribute ) ] = value;
|
||||
}
|
||||
|
||||
public byte[] ToBytes()
|
||||
{
|
||||
using var s = new MemoryStream( ByteSize );
|
||||
using var bw = new BinaryWriter( s );
|
||||
foreach( var attribute in Attributes )
|
||||
{
|
||||
bw.Write( attribute );
|
||||
}
|
||||
|
||||
return s.ToArray();
|
||||
Attributes[ i ] = br.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
private static int ToIndex( RspAttribute attribute )
|
||||
=> attribute < RspAttribute.NumAttributes && attribute >= 0
|
||||
? ( int )attribute
|
||||
: throw new InvalidEnumArgumentException();
|
||||
|
||||
public float this[ RspAttribute attribute ]
|
||||
{
|
||||
get => Attributes[ ToIndex( attribute ) ];
|
||||
set => Attributes[ ToIndex( attribute ) ] = value;
|
||||
}
|
||||
|
||||
public byte[] ToBytes()
|
||||
{
|
||||
using var s = new MemoryStream( ByteSize );
|
||||
using var bw = new BinaryWriter( s );
|
||||
foreach( var attribute in Attributes )
|
||||
{
|
||||
bw.Write( attribute );
|
||||
}
|
||||
|
||||
return s.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace Penumbra.GameData.Structs
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
public readonly struct SetId : IComparable< SetId >
|
||||
{
|
||||
public readonly struct SetId : IComparable< SetId >
|
||||
{
|
||||
public readonly ushort Value;
|
||||
public readonly ushort Value;
|
||||
|
||||
public SetId( ushort value )
|
||||
=> Value = value;
|
||||
public SetId( ushort value )
|
||||
=> Value = value;
|
||||
|
||||
public static implicit operator SetId( ushort id )
|
||||
=> new( id );
|
||||
public static implicit operator SetId( ushort id )
|
||||
=> new(id);
|
||||
|
||||
public static explicit operator ushort( SetId id )
|
||||
=> id.Value;
|
||||
public static explicit operator ushort( SetId id )
|
||||
=> id.Value;
|
||||
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
|
||||
public int CompareTo( SetId other )
|
||||
=> Value.CompareTo( other.Value );
|
||||
}
|
||||
public int CompareTo( SetId other )
|
||||
=> Value.CompareTo( other.Value );
|
||||
}
|
||||
|
|
@ -1,30 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace Penumbra.GameData.Structs
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
public readonly struct StainId : IEquatable< StainId >
|
||||
{
|
||||
public readonly struct StainId : IEquatable< StainId >
|
||||
{
|
||||
public readonly byte Value;
|
||||
public readonly byte Value;
|
||||
|
||||
public StainId( byte value )
|
||||
=> Value = value;
|
||||
public StainId( byte value )
|
||||
=> Value = value;
|
||||
|
||||
public static implicit operator StainId( byte id )
|
||||
=> new( id );
|
||||
public static implicit operator StainId( byte id )
|
||||
=> new(id);
|
||||
|
||||
public static explicit operator byte( StainId id )
|
||||
=> id.Value;
|
||||
public static explicit operator byte( StainId id )
|
||||
=> id.Value;
|
||||
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
|
||||
public bool Equals( StainId other )
|
||||
=> Value == other.Value;
|
||||
public bool Equals( StainId other )
|
||||
=> Value == other.Value;
|
||||
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is StainId other && Equals( other );
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is StainId other && Equals( other );
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Value.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode()
|
||||
=> Value.GetHashCode();
|
||||
}
|
||||
|
|
@ -1,30 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace Penumbra.GameData.Structs
|
||||
namespace Penumbra.GameData.Structs;
|
||||
|
||||
public readonly struct WeaponType : IEquatable< WeaponType >
|
||||
{
|
||||
public readonly struct WeaponType : IEquatable< WeaponType >
|
||||
{
|
||||
public readonly ushort Value;
|
||||
public readonly ushort Value;
|
||||
|
||||
public WeaponType( ushort value )
|
||||
=> Value = value;
|
||||
public WeaponType( ushort value )
|
||||
=> Value = value;
|
||||
|
||||
public static implicit operator WeaponType( ushort id )
|
||||
=> new( id );
|
||||
public static implicit operator WeaponType( ushort id )
|
||||
=> new(id);
|
||||
|
||||
public static explicit operator ushort( WeaponType id )
|
||||
=> id.Value;
|
||||
public static explicit operator ushort( WeaponType id )
|
||||
=> id.Value;
|
||||
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
public override string ToString()
|
||||
=> Value.ToString();
|
||||
|
||||
public bool Equals( WeaponType other )
|
||||
=> Value == other.Value;
|
||||
public bool Equals( WeaponType other )
|
||||
=> Value == other.Value;
|
||||
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is WeaponType other && Equals( other );
|
||||
public override bool Equals( object? obj )
|
||||
=> obj is WeaponType other && Equals( other );
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Value.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode()
|
||||
=> Value.GetHashCode();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue