Glamourer changes

This commit is contained in:
Ottermandias 2023-01-25 09:57:24 +01:00
parent 5f63d4de38
commit 0239c2f60b
3 changed files with 28 additions and 29 deletions

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
namespace Penumbra.GameData.Enums; namespace Penumbra.GameData.Enums;

View file

@ -4,19 +4,19 @@ using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs; namespace Penumbra.GameData.Structs;
[StructLayout( LayoutKind.Explicit, Pack = 1 )] [StructLayout( LayoutKind.Explicit, Pack = 1 )]
public readonly struct CharacterArmor : IEquatable< CharacterArmor > public struct CharacterArmor : IEquatable< CharacterArmor >
{ {
[FieldOffset( 0 )] [FieldOffset( 0 )]
public readonly uint Value; public uint Value;
[FieldOffset( 0 )] [FieldOffset( 0 )]
public readonly SetId Set; public SetId Set;
[FieldOffset( 2 )] [FieldOffset( 2 )]
public readonly byte Variant; public byte Variant;
[FieldOffset( 3 )] [FieldOffset( 3 )]
public readonly StainId Stain; public StainId Stain;
public CharacterArmor( SetId set, byte variant, StainId stain ) public CharacterArmor( SetId set, byte variant, StainId stain )
{ {

View file

@ -3,28 +3,28 @@ using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs; namespace Penumbra.GameData.Structs;
[StructLayout( LayoutKind.Explicit, Pack = 1, Size = 7 )] [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 7)]
public readonly struct CharacterWeapon : IEquatable< CharacterWeapon > public struct CharacterWeapon : IEquatable<CharacterWeapon>
{ {
[FieldOffset( 0 )] [FieldOffset(0)]
public readonly SetId Set; public SetId Set;
[FieldOffset( 2 )] [FieldOffset(2)]
public readonly WeaponType Type; public WeaponType Type;
[FieldOffset( 4 )] [FieldOffset(4)]
public readonly ushort Variant; public ushort Variant;
[FieldOffset( 6 )] [FieldOffset(6)]
public readonly StainId Stain; public StainId Stain;
public ulong Value public ulong Value
=> ( ulong )Set | ( ( ulong )Type << 16 ) | ( ( ulong )Variant << 32 ) | ( ( ulong )Stain << 48 ); => (ulong)Set | ((ulong)Type << 16) | ((ulong)Variant << 32) | ((ulong)Stain << 48);
public override string ToString() public override string ToString()
=> $"{Set},{Type},{Variant},{Stain}"; => $"{Set},{Type},{Variant},{Stain}";
public CharacterWeapon( SetId set, WeaponType type, ushort variant, StainId stain ) public CharacterWeapon(SetId set, WeaponType type, ushort variant, StainId stain)
{ {
Set = set; Set = set;
Type = type; Type = type;
@ -32,28 +32,28 @@ public readonly struct CharacterWeapon : IEquatable< CharacterWeapon >
Stain = stain; Stain = stain;
} }
public CharacterWeapon( ulong value ) public CharacterWeapon(ulong value)
{ {
Set = ( SetId )value; Set = (SetId)value;
Type = ( WeaponType )( value >> 16 ); Type = (WeaponType)(value >> 16);
Variant = ( ushort )( value >> 32 ); Variant = (ushort)(value >> 32);
Stain = ( StainId )( value >> 48 ); Stain = (StainId)(value >> 48);
} }
public static readonly CharacterWeapon Empty = new(0, 0, 0, 0); public static readonly CharacterWeapon Empty = new(0, 0, 0, 0);
public bool Equals( CharacterWeapon other ) public bool Equals(CharacterWeapon other)
=> Value == other.Value; => Value == other.Value;
public override bool Equals( object? obj ) public override bool Equals(object? obj)
=> obj is CharacterWeapon other && Equals( other ); => obj is CharacterWeapon other && Equals(other);
public override int GetHashCode() public override int GetHashCode()
=> Value.GetHashCode(); => Value.GetHashCode();
public static bool operator ==( CharacterWeapon left, CharacterWeapon right ) public static bool operator ==(CharacterWeapon left, CharacterWeapon right)
=> left.Value == right.Value; => left.Value == right.Value;
public static bool operator !=( CharacterWeapon left, CharacterWeapon right ) public static bool operator !=(CharacterWeapon left, CharacterWeapon right)
=> left.Value != right.Value; => left.Value != right.Value;
} }