public void UpdateProduction()
{
//Take the total trade income, and add them to the planets, proportionally to their percentage of the total production across empire
float totalProduction = 0;
foreach (var planet in PlanetManager.Planets)
{
planet.ProductionFromTrade = 0; //Don't add extra production from last turn, set it to 0 here
totalProduction += planet.TotalProduction;
}
float netExpenses = NetExpenses; //NetExpenses property dynamically calculates the value, so cache it here
//Now that we've added up the total production, distribute the trade so we'd have accurate TotalProduction
foreach (var planet in PlanetManager.Planets)
{
float scale = planet.TotalProduction / totalProduction;
planet.ProductionFromTrade = scale * TradeIncome;
planet.ProductionLostFromExpenses = scale * netExpenses;
planet.SetCleanup();
}
}