Add some refactoring of data, Stains and STM files.

This commit is contained in:
Ottermandias 2022-11-09 13:53:52 +01:00
parent 7e167cf0cf
commit 8d11e1075d
11 changed files with 580 additions and 227 deletions

View file

@ -0,0 +1,52 @@
using Dalamud.Utility;
namespace Penumbra.GameData.Structs;
// A wrapper for the clothing dyes the game provides with their RGBA color value, game ID, unmodified color value and name.
public readonly struct Stain
{
// An empty stain with transparent color.
public static readonly Stain None = new("None");
public readonly string Name;
public readonly uint RgbaColor;
public readonly byte RowIndex;
public readonly bool Gloss;
public byte R
=> (byte)(RgbaColor & 0xFF);
public byte G
=> (byte)((RgbaColor >> 8) & 0xFF);
public byte B
=> (byte)((RgbaColor >> 16) & 0xFF);
public byte Intensity
=> (byte)((1 + R + G + B) / 3);
// R and B need to be shuffled and Alpha set to max.
private static uint SeColorToRgba(uint color)
=> ((color & 0xFF) << 16) | ((color >> 16) & 0xFF) | (color & 0xFF00) | 0xFF000000;
public Stain(Lumina.Excel.GeneratedSheets.Stain stain)
: this(stain.Name.ToDalamudString().ToString(), SeColorToRgba(stain.Color), (byte)stain.RowId, stain.Unknown4)
{ }
internal Stain(string name, uint dye, byte index, bool gloss)
{
Name = name;
RowIndex = index;
Gloss = gloss;
RgbaColor = dye;
}
// Only used by None.
private Stain(string name)
{
Name = name;
RowIndex = 0;
RgbaColor = 0;
Gloss = false;
}
}