diff --git a/ImperatorToCK3/CK3/Characters/Character.cs b/ImperatorToCK3/CK3/Characters/Character.cs index b225d300c..cab8b5f21 100644 --- a/ImperatorToCK3/CK3/Characters/Character.cs +++ b/ImperatorToCK3/CK3/Characters/Character.cs @@ -156,7 +156,7 @@ public string? DeathReason { public IDictionary PrisonerIds { get; } = new Dictionary(); // - public DNA? DNA { get; private set; } + public DNA? DNA { get; set; } public Imperator.Characters.Character? ImperatorCharacter { get; set; } @@ -406,10 +406,6 @@ ISet unlocalizedImperatorNames } Female = ImperatorCharacter.Female; - - if (ImperatorCharacter.PortraitData is not null) { - DNA = dnaFactory.GenerateDNA(ImperatorCharacter, ImperatorCharacter.PortraitData); - } // Determine valid (not dropped in province mappings) "source I:R province" and "source CK3 province" // to be used by religion mapper. Don't give up without a fight. diff --git a/ImperatorToCK3/CK3/Characters/CharacterCollection.cs b/ImperatorToCK3/CK3/Characters/CharacterCollection.cs index 5299c7991..a10516557 100644 --- a/ImperatorToCK3/CK3/Characters/CharacterCollection.cs +++ b/ImperatorToCK3/CK3/Characters/CharacterCollection.cs @@ -8,6 +8,7 @@ using ImperatorToCK3.CommonUtils; using ImperatorToCK3.CommonUtils.Map; using ImperatorToCK3.Imperator.Armies; +using ImperatorToCK3.Imperator.Characters; using ImperatorToCK3.Mappers.Culture; using ImperatorToCK3.Mappers.DeathReason; using ImperatorToCK3.Mappers.Nickname; @@ -667,4 +668,18 @@ Configuration config Logger.IncrementProgress(); } + + public void ConvertImperatorCharacterDNA(DNAFactory dnaFactory) { + Logger.Info("Converting Imperator character DNA to CK3..."); + foreach (var character in this) { + if (character.ImperatorCharacter is null) { + continue; + } + + PortraitData? portraitData = character.ImperatorCharacter.PortraitData; + if (portraitData is not null) { + character.DNA = dnaFactory.GenerateDNA(character.ImperatorCharacter, portraitData); + } + } + } } \ No newline at end of file diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index 41d6549f6..77a1ad6e0 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -337,6 +337,9 @@ public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtrac Characters.RemoveEmployerIdFromLandedCharacters(LandedTitles, CorrectedDate); Characters.PurgeUnneededCharacters(LandedTitles, Dynasties, DynastyHouses, config.CK3BookmarkDate); + // We could convert Imperator character DNA while importing the characters. + // But that'd be wasteful, because some of them are purged. So, we do it now. + Characters.ConvertImperatorCharacterDNA(dnaFactory); // After the purging of unneeded characters, we should clean up the title history. LandedTitles.CleanUpHistory(Characters, config.CK3BookmarkDate);