diff --git a/Focus.Apps.EasyNpc/Build/Pipeline/NpcFacesTask.cs b/Focus.Apps.EasyNpc/Build/Pipeline/NpcFacesTask.cs index 6ee8a01..8908567 100644 --- a/Focus.Apps.EasyNpc/Build/Pipeline/NpcFacesTask.cs +++ b/Focus.Apps.EasyNpc/Build/Pipeline/NpcFacesTask.cs @@ -87,6 +87,8 @@ protected override Task Run(BuildSettings settings) if (mergedHeadPart.HasValue) record.HeadParts.Add(mergedHeadPart.Value); } + foreach (var headPart in record.HeadParts) + patch.Importer.AddHeadPartRace(headPart, record.Race); log.Debug("Importing hair color from {pluginName}", model.FaceOption.PluginName); record.HairColor.SetTo(patch.Importer.Import(faceNpcRecord.HairColor, x => x.Colors)); log.Debug("Importing face texture from {pluginName}", model.FaceOption.PluginName); diff --git a/Focus.Apps.EasyNpc/Build/Pipeline/RecordImporter.cs b/Focus.Apps.EasyNpc/Build/Pipeline/RecordImporter.cs index dde0079..57663df 100644 --- a/Focus.Apps.EasyNpc/Build/Pipeline/RecordImporter.cs +++ b/Focus.Apps.EasyNpc/Build/Pipeline/RecordImporter.cs @@ -50,6 +50,28 @@ public void AddArmorRace( addon.AdditionalRaces.Add(actualRace.FormKey); } + public void AddFormListKey(IFormLinkGetter formListLink, FormKey itemKey) + { + var formListKey = formListLink.FormKey; + if (formListKey.IsNull || formListKey.ModKey != mergedMod.ModKey) + return; + var formList = GetIfMerged(formListKey); + if (formList is not null && !formList.Items.Contains(itemKey)) + formList.Items.Add(itemKey); + } + + public void AddHeadPartRace(IFormLinkGetter headPartLink, IFormLinkGetter raceLink) + { + if (raceLink.IsNull) + return; + var headPartKey = headPartLink.FormKey; + if (headPartKey.IsNull || headPartKey.ModKey != mergedMod.ModKey) + return; + var headPart = GetIfMerged(headPartKey); + if (headPart is not null) + AddFormListKey(headPart.ValidRaces, raceLink.FormKey); + } + public void AddMaster(string pluginName) { masters.Add(ModKey.FromNameAndExtension(pluginName)); @@ -140,6 +162,11 @@ private void ImportArtObjectDependencies(ArtObject art) log.Information("Finished processing cloned art object {FormKey} '{EditorId}'", art.EditorID, art.FormKey); } + private void ImportEmptyFormList(FormList formList) + { + formList.Items.Clear(); + } + private void ImportHeadPartDependencies(HeadPart headPart) { log.Debug( @@ -148,6 +175,7 @@ private void ImportHeadPartDependencies(HeadPart headPart) headPart.Flags &= ~HeadPart.Flag.Playable; headPart.Color.SetTo(Import(headPart.Color, mergedMod.Colors)); headPart.TextureSet.SetTo(Import(headPart.TextureSet, mergedMod.TextureSets)); + headPart.ValidRaces.SetTo(Import(headPart.ValidRaces, mergedMod.FormLists, ImportEmptyFormList)); ReplaceAlternateTextures(headPart.Model?.AlternateTextures); ReplaceList(headPart.ExtraParts, mergedMod.HeadParts, ImportHeadPartDependencies); log.Information(