Example #1
0
 private void RemoveSettlerResponse(object sender, TicketRaisedEventArgs args)
 {
     if (args.Result == PostOrderResponse.Processed)
     {
         City  city           = this.departmentOfTheInterior.Cities[this.cityWithRemovedSettlerIndex];
         float propertyValue  = city.GetPropertyValue(SimulationProperties.Population);
         float propertyValue2 = city.GetPropertyValue(SimulationProperties.CityGrowthStock);
         float num            = DepartmentOfTheInterior.ComputeGrowthLimit(city.Empire.SimulationObject, propertyValue);
         float num2           = DepartmentOfTheInterior.ComputeGrowthLimit(city.Empire.SimulationObject, propertyValue + 1f);
         float num3           = propertyValue2 / num;
         num3  = num2 * num3;
         num3 -= propertyValue2;
         if (num3 > 0f)
         {
             Diagnostics.Log("ELCP {0} Disbanded Settler in {1}, tranfering {2} food ({3} -> {4})", new object[]
             {
                 city.Empire,
                 city.LocalizedName,
                 num3,
                 propertyValue2,
                 propertyValue2 + num3
             });
             OrderTransferResources order = new OrderTransferResources(base.AIEntity.Empire.Index, DepartmentOfTheTreasury.Resources.CityGrowth, num3, city.GUID);
             base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order);
         }
     }
     this.cityWithRemovedSettlerIndex = -1;
 }
    private void OrderAssignPopulation_TicketRaised(object sender, TicketRaisedEventArgs e)
    {
        for (int i = 0; i < AILayer_Population.PopulationResource.Length; i++)
        {
            this.resourceScore[i] = this.aiEntityCity.City.GetPropertyValue(AILayer_Population.PopulationResource[i]);
        }
        float propertyValue = this.aiEntityCity.City.GetPropertyValue(SimulationProperties.NetCityGrowth);

        if (propertyValue < 0f)
        {
            float propertyValue2 = this.aiEntityCity.City.GetPropertyValue(SimulationProperties.Population);
            float num            = DepartmentOfTheInterior.ComputeGrowthLimit(this.Empire.SimulationObject, propertyValue2);
            if (this.aiEntityCity.City.GetPropertyValue(SimulationProperties.CityGrowthStock) + propertyValue < num)
            {
                foreach (int num2 in AILayer_Population.NonFoodPopPriority)
                {
                    if (this.resourceScore[num2] >= 1f)
                    {
                        this.resourceScore[num2]       -= 1f;
                        this.resourceScore[0]          += 1f;
                        this.assignedPopulationThisTurn = false;
                        AIScheduler.Services.GetService <ISynchronousJobRepositoryAIHelper>().RegisterSynchronousJob(new SynchronousJob(this.SynchronousJob_AssignPopulation));
                        return;
                    }
                }
            }
        }
        this.assignedPopulationThisTurn = true;
    }