private void RefreshPopulationGrowth() { float propertyValue = this.City.GetPropertyValue(SimulationProperties.Population); float propertyValue2 = this.City.GetPropertyValue(SimulationProperties.CityGrowthStock); float propertyValue3 = this.City.GetPropertyValue(SimulationProperties.NetCityGrowth); DepartmentOfTheInterior agency = this.City.Empire.GetAgency <DepartmentOfTheInterior>(); float num; float num2; agency.GetGrowthLimits(propertyValue, out num, out num2); this.GaugePopulation.PercentRight = Mathf.Clamp((propertyValue2 - num) / (num2 - num) * 100f, 0f, 100f); float num3 = Mathf.Round(100f * propertyValue3 / (num2 - num)); if (num3 > 0f) { this.GaugeProgress.Visible = true; this.GaugeProgress.GetComponent <AgePrimitiveImage>().TintColor = this.GrowingPopulationColor; this.GaugeProgress.PercentLeft = this.GaugePopulation.PercentRight; this.GaugeProgress.PercentRight = Mathf.Min(100f, this.GaugeProgress.PercentLeft + num3); this.NextPopulationTurns.Text = GuiFormater.FormatGui((float)Mathf.Max(1, Mathf.CeilToInt((num2 - propertyValue2) / propertyValue3)), false, true, false, 1); } else if (num3 < 0f) { this.GaugeProgress.Visible = true; this.GaugeProgress.GetComponent <AgePrimitiveImage>().TintColor = this.LosingPopulationColor; this.GaugeProgress.PercentRight = this.GaugePopulation.PercentRight; this.GaugeProgress.PercentLeft = Mathf.Max(0f, this.GaugeProgress.PercentRight + num3); this.NextPopulationTurns.Text = GuiFormater.FormatGui((float)Mathf.Max(1, Mathf.CeilToInt((propertyValue2 - num) / -propertyValue3)), false, true, false, 1); } else { this.GaugeProgress.Visible = false; this.NextPopulationTurns.Text = "-"; } }
public static void RefreshPopulationBuyoutButton(Amplitude.Unity.Game.Empire observer, City city, AgeControlButton populationBuyoutButton) { if (observer != city.Empire) { populationBuyoutButton.AgeTransform.Enable = false; return; } float propertyValue = city.GetPropertyValue(SimulationProperties.CityGrowthStock); float propertyValue2 = city.GetPropertyValue(SimulationProperties.NetCityGrowth); float propertyValue3 = city.GetPropertyValue(SimulationProperties.Population); DepartmentOfTheInterior agency = city.Empire.GetAgency <DepartmentOfTheInterior>(); float num; float num2; agency.GetGrowthLimits(propertyValue3, out num, out num2); if (propertyValue + propertyValue2 >= num2) { populationBuyoutButton.AgeTransform.Enable = false; populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationNotNeededDescription"); return; } float propertyValue4 = city.Empire.GetPropertyValue(SimulationProperties.PopulationBuyoutCooldown); if (propertyValue4 > 0f) { populationBuyoutButton.AgeTransform.Enable = false; populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationCooldownDescription").Replace("$Cooldown", propertyValue4.ToString()); return; } float num3 = -DepartmentOfTheTreasury.GetPopulationBuyOutCost(city); ResourceDefinition resourceDefinition = ResourceDefinition.GetResourceDefinition(DepartmentOfTheTreasury.Resources.PopulationBuyout); string newValue = GuiFormater.FormatInstantCost(city.Empire, -num3, resourceDefinition.GetName(city.Empire), true, 0); DepartmentOfTheTreasury agency2 = city.Empire.GetAgency <DepartmentOfTheTreasury>(); if (agency2.IsTransferOfResourcePossible(city.Empire, DepartmentOfTheTreasury.Resources.PopulationBuyout, ref num3)) { populationBuyoutButton.AgeTransform.Enable = CityInfoPanel.interactionsAllowed; populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityBuyoutPopulationDescription").Replace("$Cost", newValue); } else { populationBuyoutButton.AgeTransform.Enable = false; populationBuyoutButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityCannotBuyoutPopulationDescription").Replace("$Cost", newValue); } }