@@ -156,6 +156,8 @@ internal DNA GenerateDNA(Imperator.Characters.Character irCharacter, PortraitDat
156
156
}
157
157
158
158
// Convert eye accessories.
159
+ const string blindfoldGeneId = "special_headgear_blindfold" ;
160
+ const string blindfoldTemplateId = "blindfold" ;
159
161
var irEyeAccessoryGeneTemplateName = irPortraitData . AccessoryGenesDict [ "eye_accessory" ] . GeneTemplate ;
160
162
switch ( irEyeAccessoryGeneTemplateName ) {
161
163
case "normal_eyes" :
@@ -171,11 +173,18 @@ internal DNA GenerateDNA(Imperator.Characters.Character irCharacter, PortraitDat
171
173
172
174
break ;
173
175
case "blindfold_1" : // TODO: check if this is correctly added to portrait modifiers if needed
174
- var blindfoldTemplate = ck3GenesDB . SpecialAccessoryGenes [ "special_headgear_blindfold" ]
175
- . GeneTemplates [ "blindfold" ] ;
176
+ if ( ! ck3GenesDB . SpecialAccessoryGenes . TryGetValue ( blindfoldGeneId , out var blindfoldGene ) ) {
177
+ Logger . Warn ( $ "{ blindfoldGeneId } not found in CK3 special accessory genes!") ;
178
+ break ;
179
+ }
180
+ if ( ! blindfoldGene . GeneTemplates . TryGetValue ( blindfoldTemplateId , out var blindfoldTemplate ) ) {
181
+ Logger . Warn ( $ "{ blindfoldTemplateId } not found in CK3 special accessory genes!") ;
182
+ break ;
183
+ }
184
+
176
185
if ( blindfoldTemplate . AgeSexWeightBlocks . TryGetValue ( irCharacter . AgeSex , out WeightBlock ? blindfoldWeightBlock ) ) {
177
186
var blindfoldObjectName = blindfoldWeightBlock . GetMatchingObject ( 1 ) ?? blindfoldWeightBlock . ObjectNames . Last ( ) ;
178
- accessoryDNAValues [ "special_headgear_blindfold" ] = new ( blindfoldTemplate . Id , blindfoldObjectName , blindfoldWeightBlock ) ;
187
+ accessoryDNAValues [ blindfoldGeneId ] = new ( blindfoldTemplate . Id , blindfoldObjectName , blindfoldWeightBlock ) ;
179
188
}
180
189
181
190
break ;
@@ -206,12 +215,14 @@ internal DNA GenerateDNA(Imperator.Characters.Character irCharacter, PortraitDat
206
215
var blindEyesObjectName = blindEyesWeighBlock . GetMatchingObject ( 1 ) ?? blindEyesWeighBlock . ObjectNames . Last ( ) ;
207
216
accessoryDNAValues [ "eye_accessory" ] = new ( blindEyesTemplate . Id , blindEyesObjectName , blindEyesWeighBlock ) ; // TODO: check if this is correctly added to portrait modifiers if needed
208
217
}
209
-
210
- var blindfoldTemplate = ck3GenesDB . SpecialAccessoryGenes [ "special_headgear_blindfold" ]
211
- . GeneTemplates [ "blindfold" ] ;
212
- if ( blindfoldTemplate . AgeSexWeightBlocks . TryGetValue ( irCharacter . AgeSex , out WeightBlock ? blindfoldWeighBlock ) ) {
218
+
219
+ if ( ! ck3GenesDB . SpecialAccessoryGenes . TryGetValue ( blindfoldGeneId , out var blindfoldGene ) ) {
220
+ Logger . Warn ( $ "{ blindfoldGeneId } not found in CK3 special accessory genes!") ;
221
+ } else if ( ! blindfoldGene . GeneTemplates . TryGetValue ( blindfoldTemplateId , out var blindfoldTemplate ) ) {
222
+ Logger . Warn ( $ "{ blindfoldTemplateId } not found in CK3 special accessory genes!") ;
223
+ } else if ( blindfoldTemplate . AgeSexWeightBlocks . TryGetValue ( irCharacter . AgeSex , out WeightBlock ? blindfoldWeighBlock ) ) {
213
224
var blindfoldObjectName = blindfoldWeighBlock . GetMatchingObject ( 1 ) ?? blindfoldWeighBlock . ObjectNames . Last ( ) ;
214
- accessoryDNAValues [ "special_headgear_blindfold" ] = new ( blindfoldTemplate . Id , blindfoldObjectName , blindfoldWeighBlock ) ; // TODO: check if this is correctly added to portrait modifiers if needed
225
+ accessoryDNAValues [ blindfoldGeneId ] = new ( blindfoldTemplate . Id , blindfoldObjectName , blindfoldWeighBlock ) ; // TODO: check if this is correctly added to portrait modifiers if needed
215
226
}
216
227
} else if ( irCharacter . Traits . Contains ( "one_eyed" ) ) {
217
228
var eyePatchTemplate = ck3GenesDB . SpecialAccessoryGenes [ "special_headgear_eye_patch" ]
0 commit comments