public static void RefreshPopulationSacrificeButton(Amplitude.Unity.Game.Empire observer, City city, AgeControlButton populationSacrificeButton) { if (DepartmentOfTheInterior.CanSacrificePopulation(city) && observer == city.Empire) { populationSacrificeButton.AgeTransform.Enable = CityInfoPanel.interactionsAllowed; populationSacrificeButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityPopulationSacrificeDescription"); populationSacrificeButton.AgeTransform.AgeTooltip.Content = populationSacrificeButton.AgeTransform.AgeTooltip.Content.Replace("1 \\7708\\", ((int)(city.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier) * 2f)).ToString() + " \\7708\\"); return; } populationSacrificeButton.AgeTransform.Enable = false; populationSacrificeButton.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%CityCannotSacrificePopulationDescription"); }
private SynchronousJobState SynchronousJob_SacrificePopulation() { if (this.aiEntityCity == null || this.aiEntityCity.City == null) { return(SynchronousJobState.Failure); } if (!DepartmentOfTheInterior.CanSacrificePopulation(this.aiEntityCity.City)) { return(SynchronousJobState.Failure); } OrderSacrificePopulation order = new OrderSacrificePopulation(this.Empire.Index, this.aiEntityCity.City.GUID); this.Empire.PlayerControllers.AI.PostOrder(order); Diagnostics.Log("ELCP {0}/{1} sacrificing pops", new object[] { base.AIEntity.Empire, this.aiEntityCity.City.LocalizedName }); return(SynchronousJobState.Success); }
private void ExecutePopulationSacrifice() { if (!DepartmentOfTheInterior.CanSacrificePopulation(this.aiEntityCity.City)) { return; } if (this.aiEntityCity.City.GetPropertyValue(SimulationProperties.Population) < this.populationThresholdForSacrifice) { return; } if (this.aiEntityCity.City.GetPropertyValue(SimulationProperties.NetCityApproval) > this.approvalThresholdForSacrifice) { return; } Booster[] activeBoosters = this.Empire.GetAgency <DepartmentOfPlanificationAndDevelopment>().GetActiveBoosters(); for (int i = 0; i < activeBoosters.Length; i++) { if (activeBoosters[i].TargetGUID == this.aiEntityCity.City.GUID && activeBoosters[i].BoosterDefinition.Name == "BoosterSacrificePopulation" && activeBoosters[i].RemainingTime > 1) { return; } } AIScheduler.Services.GetService <ISynchronousJobRepositoryAIHelper>().RegisterSynchronousJob(new SynchronousJob(this.SynchronousJob_SacrificePopulation)); }