private void killDiseasedOrganisms2()
{
Hashtable plantsToKill = null;
Hashtable animalsToKill = null;
ArrayList deadAnimals = new ArrayList();
if (_plantCount > MaxPlants)
{
plantsToKill = new Hashtable();
}
if (AnimalCount > MaxAnimals)
{
animalsToKill = new Hashtable();
}
if (plantsToKill == null && animalsToKill == null)
{
return;
}
sortOrganismsForDisease(plantsToKill, animalsToKill, deadAnimals);
killOrganisms(plantsToKill, _plantCount - MaxPlants, _plantCount, false);
killOrganisms(animalsToKill, AnimalCount - MaxAnimals - deadAnimals.Count, MaxAnimals - deadAnimals.Count,
true);
// Next remove enough previously rotted animals to get us as close to the right level as possible
// Make sure dead animals only represent 1/3 of our maximum
// Leave around some corpses if possible so that carnivores can eat
int corpseRemoveCount = deadAnimals.Count - (MaxAnimals/3);
if (corpseRemoveCount <= 0) return;
foreach (AnimalState state in deadAnimals)
{
// Don't ever remove animals that were killed, because it will affect
// the carnivore population since we're removing their source of food
if (state.DeathReason == PopulationChangeReason.Killed)
{
continue;
}
removeOrganism(new KilledOrganism(state));
corpseRemoveCount--;
if (corpseRemoveCount == 0)
{
break;
}
}
}