From f9442067c8288515bb0d2452dafd042077061c41 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 29 Jan 2022 15:44:03 +0100 Subject: [PATCH] Allow for unlockable facepaints. --- .../Customization/CustomizationOptions.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Glamourer.GameData/Customization/CustomizationOptions.cs b/Glamourer.GameData/Customization/CustomizationOptions.cs index 6cc6529..a4e9212 100644 --- a/Glamourer.GameData/Customization/CustomizationOptions.cs +++ b/Glamourer.GameData/Customization/CustomizationOptions.cs @@ -102,10 +102,27 @@ namespace Glamourer.Customization return menu?.Size ?? 0; } - private Customization[] GetFacePaints(CharaMakeParams row) - => row.Menus.Cast().FirstOrDefault(m => m!.Value.Customization == CustomizationId.FacePaint)?.Values - .Select((v, i) => FromValueAndIndex(CustomizationId.FacePaint, v, i)).ToArray() - ?? Array.Empty(); + private Customization[] GetFacePaints(SubRace race, Gender gender) + { + var row = _hairSheet.GetRow(((uint)race - 1) * 2 - 1 + (uint)gender)!; + var paintList = new List(row.Unknown37); + for (var i = 0; i < row.Unknown37; ++i) + { + var name = $"Unknown{73 + i * 9}"; + var customizeIdx = + (uint?)row.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance)?.GetValue(row) + ?? uint.MaxValue; + if (customizeIdx == uint.MaxValue) + continue; + + var paintRow = _customizeSheet.GetRow(customizeIdx); + paintList.Add(paintRow != null + ? new Customization(CustomizationId.FacePaint, paintRow.FeatureID, paintRow.Icon, (ushort)paintRow.RowId) + : new Customization(CustomizationId.FacePaint, (byte)i, customizeIdx, 0)); + } + + return paintList.ToArray(); + } private Customization[] GetTailEarShapes(CharaMakeParams row) => row.Menus.Cast().FirstOrDefault(m => m!.Value.Customization == CustomizationId.TailEarShape)?.Values @@ -149,7 +166,7 @@ namespace Glamourer.Customization NumNoseShapes = GetListSize(row, CustomizationId.Nose), NumJawShapes = GetListSize(row, CustomizationId.Jaw), NumMouthShapes = GetListSize(row, CustomizationId.Mouth), - FacePaints = GetFacePaints(row), + FacePaints = GetFacePaints(race, gender), TailEarShapes = GetTailEarShapes(row), };