From 32e817d793141a045b6076a0269e8e6e144450cf Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 3 Jul 2022 23:01:38 +0200 Subject: [PATCH] Some glamourer additions. --- OtterGui | 2 +- Penumbra.GameData/Enums/EquipSlot.cs | 316 ++++++++++---------- Penumbra.GameData/Structs/CharacterArmor.cs | 14 +- 3 files changed, 178 insertions(+), 154 deletions(-) diff --git a/OtterGui b/OtterGui index bec5e2b1..fcc5031f 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit bec5e2b1b9c9fa6c32c9e1aa0aec62210261b99d +Subproject commit fcc5031fcf14b54f090d5bb789c580567b3f0023 diff --git a/Penumbra.GameData/Enums/EquipSlot.cs b/Penumbra.GameData/Enums/EquipSlot.cs index 628acad7..67a1da6d 100644 --- a/Penumbra.GameData/Enums/EquipSlot.cs +++ b/Penumbra.GameData/Enums/EquipSlot.cs @@ -2,160 +2,176 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Reflection.Metadata.Ecma335; -namespace Penumbra.GameData.Enums +namespace Penumbra.GameData.Enums; + +public enum EquipSlot : byte { - public enum EquipSlot : byte + Unknown = 0, + MainHand = 1, + OffHand = 2, + Head = 3, + Body = 4, + Hands = 5, + Belt = 6, + Legs = 7, + Feet = 8, + Ears = 9, + Neck = 10, + Wrists = 11, + RFinger = 12, + BothHand = 13, + LFinger = 14, // Not officially existing, means "weapon could be equipped in either hand" for the game. + HeadBody = 15, + BodyHandsLegsFeet = 16, + SoulCrystal = 17, + LegsFeet = 18, + FullBody = 19, + BodyHands = 20, + BodyLegsFeet = 21, + All = 22, // Not officially existing +} + +public static class EquipSlotExtensions +{ + public static EquipSlot ToEquipSlot( this uint value ) + => value switch + { + 0 => EquipSlot.Head, + 1 => EquipSlot.Body, + 2 => EquipSlot.Hands, + 3 => EquipSlot.Legs, + 4 => EquipSlot.Feet, + 5 => EquipSlot.Ears, + 6 => EquipSlot.Neck, + 7 => EquipSlot.Wrists, + 8 => EquipSlot.RFinger, + 9 => EquipSlot.LFinger, + _ => EquipSlot.Unknown, + }; + + public static string ToSuffix( this EquipSlot value ) { - Unknown = 0, - MainHand = 1, - OffHand = 2, - Head = 3, - Body = 4, - Hands = 5, - Belt = 6, - Legs = 7, - Feet = 8, - Ears = 9, - Neck = 10, - Wrists = 11, - RFinger = 12, - BothHand = 13, - LFinger = 14, // Not officially existing, means "weapon could be equipped in either hand" for the game. - HeadBody = 15, - BodyHandsLegsFeet = 16, - SoulCrystal = 17, - LegsFeet = 18, - FullBody = 19, - BodyHands = 20, - BodyLegsFeet = 21, - All = 22, // Not officially existing - } - - public static class EquipSlotExtensions - { - public static string ToSuffix( this EquipSlot value ) + return value switch { - return value switch - { - EquipSlot.Head => "met", - EquipSlot.Hands => "glv", - EquipSlot.Legs => "dwn", - EquipSlot.Feet => "sho", - EquipSlot.Body => "top", - EquipSlot.Ears => "ear", - EquipSlot.Neck => "nek", - EquipSlot.RFinger => "rir", - EquipSlot.LFinger => "ril", - EquipSlot.Wrists => "wrs", - _ => throw new InvalidEnumArgumentException(), - }; - } - - public static EquipSlot ToSlot( this EquipSlot value ) - { - return value switch - { - EquipSlot.MainHand => EquipSlot.MainHand, - EquipSlot.OffHand => EquipSlot.OffHand, - EquipSlot.Head => EquipSlot.Head, - EquipSlot.Body => EquipSlot.Body, - EquipSlot.Hands => EquipSlot.Hands, - EquipSlot.Belt => EquipSlot.Belt, - EquipSlot.Legs => EquipSlot.Legs, - EquipSlot.Feet => EquipSlot.Feet, - EquipSlot.Ears => EquipSlot.Ears, - EquipSlot.Neck => EquipSlot.Neck, - EquipSlot.Wrists => EquipSlot.Wrists, - EquipSlot.RFinger => EquipSlot.RFinger, - EquipSlot.BothHand => EquipSlot.MainHand, - EquipSlot.LFinger => EquipSlot.RFinger, - EquipSlot.HeadBody => EquipSlot.Body, - EquipSlot.BodyHandsLegsFeet => EquipSlot.Body, - EquipSlot.SoulCrystal => EquipSlot.SoulCrystal, - EquipSlot.LegsFeet => EquipSlot.Legs, - EquipSlot.FullBody => EquipSlot.Body, - EquipSlot.BodyHands => EquipSlot.Body, - EquipSlot.BodyLegsFeet => EquipSlot.Body, - _ => throw new InvalidEnumArgumentException(), - }; - } - - public static string ToName( this EquipSlot value ) - { - return value switch - { - EquipSlot.Head => "Head", - EquipSlot.Hands => "Hands", - EquipSlot.Legs => "Legs", - EquipSlot.Feet => "Feet", - EquipSlot.Body => "Body", - EquipSlot.Ears => "Earrings", - EquipSlot.Neck => "Necklace", - EquipSlot.RFinger => "Right Ring", - EquipSlot.LFinger => "Left Ring", - EquipSlot.Wrists => "Bracelets", - EquipSlot.MainHand => "Primary Weapon", - EquipSlot.OffHand => "Secondary Weapon", - EquipSlot.Belt => "Belt", - EquipSlot.BothHand => "Primary Weapon", - EquipSlot.HeadBody => "Head and Body", - EquipSlot.BodyHandsLegsFeet => "Costume", - EquipSlot.SoulCrystal => "Soul Crystal", - EquipSlot.LegsFeet => "Bottom", - EquipSlot.FullBody => "Costume", - EquipSlot.BodyHands => "Top", - EquipSlot.BodyLegsFeet => "Costume", - EquipSlot.All => "Costume", - _ => "Unknown", - }; - } - - public static bool IsEquipment( this EquipSlot value ) - { - return value switch - { - EquipSlot.Head => true, - EquipSlot.Hands => true, - EquipSlot.Legs => true, - EquipSlot.Feet => true, - EquipSlot.Body => true, - _ => false, - }; - } - - public static bool IsAccessory( this EquipSlot value ) - { - return value switch - { - EquipSlot.Ears => true, - EquipSlot.Neck => true, - EquipSlot.RFinger => true, - EquipSlot.LFinger => true, - EquipSlot.Wrists => true, - _ => false, - }; - } - - public static readonly EquipSlot[] EquipmentSlots = Enum.GetValues< EquipSlot >().Where( e => e.IsEquipment() ).ToArray(); - public static readonly EquipSlot[] AccessorySlots = Enum.GetValues< EquipSlot >().Where( e => e.IsAccessory() ).ToArray(); - public static readonly EquipSlot[] EqdpSlots = EquipmentSlots.Concat( AccessorySlots ).ToArray(); - } - - public static partial class Names - { - public static readonly Dictionary< string, EquipSlot > SuffixToEquipSlot = new() - { - { EquipSlot.Head.ToSuffix(), EquipSlot.Head }, - { EquipSlot.Hands.ToSuffix(), EquipSlot.Hands }, - { EquipSlot.Legs.ToSuffix(), EquipSlot.Legs }, - { EquipSlot.Feet.ToSuffix(), EquipSlot.Feet }, - { EquipSlot.Body.ToSuffix(), EquipSlot.Body }, - { EquipSlot.Ears.ToSuffix(), EquipSlot.Ears }, - { EquipSlot.Neck.ToSuffix(), EquipSlot.Neck }, - { EquipSlot.RFinger.ToSuffix(), EquipSlot.RFinger }, - { EquipSlot.LFinger.ToSuffix(), EquipSlot.LFinger }, - { EquipSlot.Wrists.ToSuffix(), EquipSlot.Wrists }, + EquipSlot.Head => "met", + EquipSlot.Hands => "glv", + EquipSlot.Legs => "dwn", + EquipSlot.Feet => "sho", + EquipSlot.Body => "top", + EquipSlot.Ears => "ear", + EquipSlot.Neck => "nek", + EquipSlot.RFinger => "rir", + EquipSlot.LFinger => "ril", + EquipSlot.Wrists => "wrs", + _ => throw new InvalidEnumArgumentException(), }; } + + public static EquipSlot ToSlot( this EquipSlot value ) + { + return value switch + { + EquipSlot.MainHand => EquipSlot.MainHand, + EquipSlot.OffHand => EquipSlot.OffHand, + EquipSlot.Head => EquipSlot.Head, + EquipSlot.Body => EquipSlot.Body, + EquipSlot.Hands => EquipSlot.Hands, + EquipSlot.Belt => EquipSlot.Belt, + EquipSlot.Legs => EquipSlot.Legs, + EquipSlot.Feet => EquipSlot.Feet, + EquipSlot.Ears => EquipSlot.Ears, + EquipSlot.Neck => EquipSlot.Neck, + EquipSlot.Wrists => EquipSlot.Wrists, + EquipSlot.RFinger => EquipSlot.RFinger, + EquipSlot.BothHand => EquipSlot.MainHand, + EquipSlot.LFinger => EquipSlot.RFinger, + EquipSlot.HeadBody => EquipSlot.Body, + EquipSlot.BodyHandsLegsFeet => EquipSlot.Body, + EquipSlot.SoulCrystal => EquipSlot.SoulCrystal, + EquipSlot.LegsFeet => EquipSlot.Legs, + EquipSlot.FullBody => EquipSlot.Body, + EquipSlot.BodyHands => EquipSlot.Body, + EquipSlot.BodyLegsFeet => EquipSlot.Body, + _ => throw new InvalidEnumArgumentException(), + }; + } + + public static string ToName( this EquipSlot value ) + { + return value switch + { + EquipSlot.Head => "Head", + EquipSlot.Hands => "Hands", + EquipSlot.Legs => "Legs", + EquipSlot.Feet => "Feet", + EquipSlot.Body => "Body", + EquipSlot.Ears => "Earrings", + EquipSlot.Neck => "Necklace", + EquipSlot.RFinger => "Right Ring", + EquipSlot.LFinger => "Left Ring", + EquipSlot.Wrists => "Bracelets", + EquipSlot.MainHand => "Primary Weapon", + EquipSlot.OffHand => "Secondary Weapon", + EquipSlot.Belt => "Belt", + EquipSlot.BothHand => "Primary Weapon", + EquipSlot.HeadBody => "Head and Body", + EquipSlot.BodyHandsLegsFeet => "Costume", + EquipSlot.SoulCrystal => "Soul Crystal", + EquipSlot.LegsFeet => "Bottom", + EquipSlot.FullBody => "Costume", + EquipSlot.BodyHands => "Top", + EquipSlot.BodyLegsFeet => "Costume", + EquipSlot.All => "Costume", + _ => "Unknown", + }; + } + + public static bool IsEquipment( this EquipSlot value ) + { + return value switch + { + EquipSlot.Head => true, + EquipSlot.Hands => true, + EquipSlot.Legs => true, + EquipSlot.Feet => true, + EquipSlot.Body => true, + _ => false, + }; + } + + public static bool IsAccessory( this EquipSlot value ) + { + return value switch + { + EquipSlot.Ears => true, + EquipSlot.Neck => true, + EquipSlot.RFinger => true, + EquipSlot.LFinger => true, + EquipSlot.Wrists => true, + _ => false, + }; + } + + public static readonly EquipSlot[] EquipmentSlots = Enum.GetValues< EquipSlot >().Where( e => e.IsEquipment() ).ToArray(); + public static readonly EquipSlot[] AccessorySlots = Enum.GetValues< EquipSlot >().Where( e => e.IsAccessory() ).ToArray(); + public static readonly EquipSlot[] EqdpSlots = EquipmentSlots.Concat( AccessorySlots ).ToArray(); +} + +public static partial class Names +{ + public static readonly Dictionary< string, EquipSlot > SuffixToEquipSlot = new() + { + { EquipSlot.Head.ToSuffix(), EquipSlot.Head }, + { EquipSlot.Hands.ToSuffix(), EquipSlot.Hands }, + { EquipSlot.Legs.ToSuffix(), EquipSlot.Legs }, + { EquipSlot.Feet.ToSuffix(), EquipSlot.Feet }, + { EquipSlot.Body.ToSuffix(), EquipSlot.Body }, + { EquipSlot.Ears.ToSuffix(), EquipSlot.Ears }, + { EquipSlot.Neck.ToSuffix(), EquipSlot.Neck }, + { EquipSlot.RFinger.ToSuffix(), EquipSlot.RFinger }, + { EquipSlot.LFinger.ToSuffix(), EquipSlot.LFinger }, + { EquipSlot.Wrists.ToSuffix(), EquipSlot.Wrists }, + }; } \ No newline at end of file diff --git a/Penumbra.GameData/Structs/CharacterArmor.cs b/Penumbra.GameData/Structs/CharacterArmor.cs index 6b3f60a8..ffe421cf 100644 --- a/Penumbra.GameData/Structs/CharacterArmor.cs +++ b/Penumbra.GameData/Structs/CharacterArmor.cs @@ -2,13 +2,21 @@ using System.Runtime.InteropServices; namespace Penumbra.GameData.Structs; -[StructLayout( LayoutKind.Sequential, Pack = 1 )] +[StructLayout( LayoutKind.Explicit, Pack = 1 )] public readonly struct CharacterArmor { - public readonly SetId Set; - public readonly byte Variant; + [FieldOffset( 0 )] + public readonly SetId Set; + + [FieldOffset( 2 )] + public readonly byte Variant; + + [FieldOffset( 3 )] public readonly StainId Stain; + [FieldOffset( 0 )] + public readonly uint Value; + public override string ToString() => $"{Set},{Variant},{Stain}"; } \ No newline at end of file