Add functions to re-export meta changes to TexTools .meta and .rgsp formats.

This commit is contained in:
Ottermandias 2022-11-26 01:54:09 +01:00
parent 7a09d561e9
commit 3391a8ce71
7 changed files with 383 additions and 24 deletions

View file

@ -1,7 +1,6 @@
using System;
using System.Numerics;
using Newtonsoft.Json;
using OtterGui;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Structs;
using Penumbra.Meta.Manipulations;
@ -14,26 +13,26 @@ public readonly struct ImcEntry : IEquatable< ImcEntry >
{
public byte MaterialId { get; init; }
public byte DecalId { get; init; }
private readonly ushort _attributeAndSound;
public readonly ushort AttributeAndSound;
public byte VfxId { get; init; }
public byte MaterialAnimationId { get; init; }
public ushort AttributeMask
{
get => ( ushort )( _attributeAndSound & 0x3FF );
init => _attributeAndSound = ( ushort )( ( _attributeAndSound & ~0x3FF ) | ( value & 0x3FF ) );
get => ( ushort )( AttributeAndSound & 0x3FF );
init => AttributeAndSound = ( ushort )( ( AttributeAndSound & ~0x3FF ) | ( value & 0x3FF ) );
}
public byte SoundId
{
get => ( byte )( _attributeAndSound >> 10 );
init => _attributeAndSound = ( ushort )( AttributeMask | ( value << 10 ) );
get => ( byte )( AttributeAndSound >> 10 );
init => AttributeAndSound = ( ushort )( AttributeMask | ( value << 10 ) );
}
public bool Equals( ImcEntry other )
=> MaterialId == other.MaterialId
&& DecalId == other.DecalId
&& _attributeAndSound == other._attributeAndSound
&& AttributeAndSound == other.AttributeAndSound
&& VfxId == other.VfxId
&& MaterialAnimationId == other.MaterialAnimationId;
@ -41,14 +40,14 @@ public readonly struct ImcEntry : IEquatable< ImcEntry >
=> obj is ImcEntry other && Equals( other );
public override int GetHashCode()
=> HashCode.Combine( MaterialId, DecalId, _attributeAndSound, VfxId, MaterialAnimationId );
=> HashCode.Combine( MaterialId, DecalId, AttributeAndSound, VfxId, MaterialAnimationId );
[JsonConstructor]
public ImcEntry( byte materialId, byte decalId, ushort attributeMask, byte soundId, byte vfxId, byte materialAnimationId )
{
MaterialId = materialId;
DecalId = decalId;
_attributeAndSound = 0;
AttributeAndSound = 0;
VfxId = vfxId;
MaterialAnimationId = materialAnimationId;
AttributeMask = attributeMask;

View file

@ -232,4 +232,16 @@ public readonly struct MetaManipulation : IEquatable< MetaManipulation >, ICompa
Type.Imc => Imc.ToString(),
_ => throw new ArgumentOutOfRangeException(),
};
public string EntryToString()
=> ManipulationType switch
{
Type.Imc => $"{Imc.Entry.DecalId}-{Imc.Entry.MaterialId}-{Imc.Entry.VfxId}-{Imc.Entry.SoundId}-{Imc.Entry.MaterialAnimationId}-{Imc.Entry.AttributeMask}",
Type.Eqdp => $"{(ushort) Eqdp.Entry:X}",
Type.Eqp => $"{(ulong)Eqp.Entry:X}",
Type.Est => $"{Est.Entry}",
Type.Gmp => $"{Gmp.Entry.Value}",
Type.Rsp => $"{Rsp.Entry}",
_ => string.Empty,
};
}