@@ -277,12 +277,24 @@ private static void ApplySpeciesObjectsToCollection(CreatureCollection cc)
277
277
/// Calculates the top-stats in each species, sets the top-stat-flags in the creatures
278
278
/// </summary>
279
279
/// <param name="creatures">creatures to consider</param>
280
- private void CalculateTopStats ( List < Creature > creatures )
280
+ /// <param name="onlySpecies">If not null, it's assumed only creatures of this species are recalculated</param>
281
+ private void CalculateTopStats ( List < Creature > creatures , Species onlySpecies = null )
281
282
{
282
- _highestSpeciesLevels . Clear ( ) ;
283
- _lowestSpeciesLevels . Clear ( ) ;
284
- _highestSpeciesMutationLevels . Clear ( ) ;
285
- _lowestSpeciesMutationLevels . Clear ( ) ;
283
+ if ( onlySpecies == null )
284
+ {
285
+ // if all creatures are recalculated, clear all
286
+ _highestSpeciesLevels . Clear ( ) ;
287
+ _lowestSpeciesLevels . Clear ( ) ;
288
+ _highestSpeciesMutationLevels . Clear ( ) ;
289
+ _lowestSpeciesMutationLevels . Clear ( ) ;
290
+ }
291
+ else
292
+ {
293
+ _highestSpeciesLevels . Remove ( onlySpecies ) ;
294
+ _lowestSpeciesLevels . Remove ( onlySpecies ) ;
295
+ _highestSpeciesMutationLevels . Remove ( onlySpecies ) ;
296
+ _lowestSpeciesMutationLevels . Remove ( onlySpecies ) ;
297
+ }
286
298
287
299
var filteredCreaturesHash = Properties . Settings . Default . useFiltersInTopStatCalculation ? new HashSet < Creature > ( ApplyLibraryFilterSettings ( creatures ) ) : null ;
288
300
@@ -929,7 +941,7 @@ private void UpdateDisplayedCreatureValues(Creature cr, bool creatureStatusChang
929
941
// if creatureStatus (available/dead) changed, recalculate topStats (dead creatures are not considered there)
930
942
if ( creatureStatusChanged )
931
943
{
932
- CalculateTopStats ( _creatureCollection . creatures . Where ( c => c . Species == cr . Species ) . ToList ( ) ) ;
944
+ CalculateTopStats ( _creatureCollection . creatures . Where ( c => c . Species == cr . Species ) . ToList ( ) , cr . Species ) ;
933
945
FilterLibRecalculate ( ) ;
934
946
UpdateStatusBar ( ) ;
935
947
}
0 commit comments