From 9251520ebc75ce22fa38ede4d9664bed0be0e184 Mon Sep 17 00:00:00 2001 From: Piranha91 Date: Fri, 3 Feb 2023 23:55:20 -0800 Subject: [PATCH] Fixed unique NPC linker for replacers and mix ins Bug introduced during asset distribution refactor --- .../Patcher/Asset Patching/AssetSelector.cs | 25 ++++++++++++++++--- .../Shared/AssetAndBodyShapeSelector.cs | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/SynthEBD/Patcher/Asset Patching/AssetSelector.cs b/SynthEBD/Patcher/Asset Patching/AssetSelector.cs index bd8c5785..fb044944 100644 --- a/SynthEBD/Patcher/Asset Patching/AssetSelector.cs +++ b/SynthEBD/Patcher/Asset Patching/AssetSelector.cs @@ -69,7 +69,7 @@ public SubgroupCombination AssignAssets(NPCInfo npcInfo, AssetPackAssignmentMode } else if (_patcherState.GeneralSettings.bLinkNPCsWithSameName && npcInfo.IsValidLinkedUnique) { - chosenCombination = GetCombinationFromSameNameNPC(npcInfo, mode); + chosenCombination = GetCombinationFromSameNameNPC(npcInfo, mode, availableAssetPacks); } if (chosenCombination == null) @@ -174,9 +174,28 @@ public SubgroupCombination GetCombinationFromLinkedNPCGroup(NPCInfo npcInfo, Ass return linkedCombination; } - public SubgroupCombination GetCombinationFromSameNameNPC(NPCInfo npcInfo, AssetPackAssignmentMode mode) + public SubgroupCombination GetCombinationFromSameNameNPC(NPCInfo npcInfo, AssetPackAssignmentMode mode, HashSet availableAssetPacks) { - SubgroupCombination linkedCombination = UniqueNPCData.GetUniqueNPCTrackerData(npcInfo, AssignmentType.PrimaryAssets) ?? null; + SubgroupCombination linkedCombination = null; + switch(mode) + { + case AssetPackAssignmentMode.Primary: linkedCombination = UniqueNPCData.GetUniqueNPCTrackerData(npcInfo, AssignmentType.PrimaryAssets); break; + case AssetPackAssignmentMode.MixIn: + Dictionary linkedCombinationDict = UniqueNPCData.GetUniqueNPCTrackerData(npcInfo, AssignmentType.MixInAssets); + if (linkedCombinationDict.ContainsKey(availableAssetPacks.First().GroupName)) // availableAssetPacks only contains the current Mix-in + { + linkedCombination = linkedCombinationDict[availableAssetPacks.First().GroupName]; + } + break; + case AssetPackAssignmentMode.ReplacerVirtual: + List linkedReplacerCombinations = UniqueNPCData.GetUniqueNPCTrackerData(npcInfo, AssignmentType.ReplacerAssets); + if (linkedReplacerCombinations != null) + { + var linkedAssignmentGroup = linkedReplacerCombinations.Where(x => x.ReplacerName == availableAssetPacks.First().GroupName).FirstOrDefault(); // availableAssetPacks only contains the current replacer + if (linkedAssignmentGroup != null) { linkedCombination = linkedAssignmentGroup.AssignedReplacerCombination; } + } + break; + } if (linkedCombination != null && CombinationAllowedBySpecificNPCAssignment(npcInfo.SpecificNPCAssignment, linkedCombination, mode)) { diff --git a/SynthEBD/Patcher/Shared/AssetAndBodyShapeSelector.cs b/SynthEBD/Patcher/Shared/AssetAndBodyShapeSelector.cs index 4898a787..58fd2034 100644 --- a/SynthEBD/Patcher/Shared/AssetAndBodyShapeSelector.cs +++ b/SynthEBD/Patcher/Shared/AssetAndBodyShapeSelector.cs @@ -76,7 +76,7 @@ public AssetAndBodyShapeAssignment ChooseCombinationAndBodyShape(out bool assets #region Get Assignments from Same-Name Unique NPC else if (_patcherState.GeneralSettings.bLinkNPCsWithSameName && npcInfo.IsValidLinkedUnique) { - var linkedCombination = _assetSelector.GetCombinationFromSameNameNPC(npcInfo, mode); + var linkedCombination = _assetSelector.GetCombinationFromSameNameNPC(npcInfo, mode, availableAssetPacks); if (linkedCombination != null) { selectedFromLinkedNPC = true;