public void SetCleanup()
{
float cleanupNeeded = Waste; //Start with any leftover waste from last turn
float factoriesOperated = TotalPopulation > (Factories / Owner.TechnologyManager.RoboticControls)
? Factories
: (TotalPopulation * Owner.TechnologyManager.RoboticControls);
cleanupNeeded += factoriesOperated * _owner.TechnologyManager.IndustryWasteRate;
if (cleanupNeeded > _populationMax - 10)
{
cleanupNeeded = _populationMax - 10;
}
float amountOfProductionUsed = (cleanupNeeded / (ActualProduction * _owner.TechnologyManager.IndustryCleanupPerBC)) * 100;
int percentage = (int)amountOfProductionUsed + ((amountOfProductionUsed - (int)amountOfProductionUsed) > 0 ? 1 : 0);
//Check if we need to set the minimum environment cleanup
if (EnvironmentAmount < percentage ||
(TotalPopulation >= TotalMaxPopulation &&
((EnvironmentBonus == PLANET_ENVIRONMENT_BONUS.HOSTILE && !_owner.TechnologyManager.HasAtmosphericTerraform) ||
(EnvironmentBonus == PLANET_ENVIRONMENT_BONUS.AVERAGE && !_owner.TechnologyManager.HasSoilEnrichment) ||
(EnvironmentBonus != PLANET_ENVIRONMENT_BONUS.GAIA && EnvironmentBonus != PLANET_ENVIRONMENT_BONUS.HOSTILE && !_owner.TechnologyManager.HasAdvancedSoilEnrichment))))
{
//Only set it if it's below the desired amount
SetOutputAmount(OUTPUT_TYPE.ENVIRONMENT, percentage, true);
}
}