Ejemplo n.º 1
0
    private float GetWonderProgress(MajorEmpire empire)
    {
        DepartmentOfTheInterior agency  = empire.GetAgency <DepartmentOfTheInterior>();
        DepartmentOfIndustry    agency2 = empire.GetAgency <DepartmentOfIndustry>();
        float num = 0f;

        for (int i = 0; i < agency.Cities.Count; i++)
        {
            Construction construction = agency2.GetConstructionQueue(agency.Cities[i]).Get((Construction x) => x.ConstructibleElement.SubCategory == "SubCategoryVictory");
            if (construction != null)
            {
                for (int j = 0; j < construction.CurrentConstructionStock.Length; j++)
                {
                    if (construction.CurrentConstructionStock[j].PropertyName == "Production")
                    {
                        float stock = construction.CurrentConstructionStock[j].Stock;
                        if (stock > 0f)
                        {
                            float num2 = stock / DepartmentOfTheTreasury.GetProductionCostWithBonus(agency.Cities[i], construction.ConstructibleElement, "Production");
                            if (num2 > num)
                            {
                                num = num2;
                            }
                        }
                    }
                }
            }
        }
        return(num);
    }
Ejemplo n.º 2
0
    private float ScoreTransferFunctionDelegate(ConstructibleElement constructibleElement, float score)
    {
        EmpirePlanDefinition empirePlanDefinition = constructibleElement as EmpirePlanDefinition;

        Diagnostics.Assert(empirePlanDefinition != null);
        float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);

        return((productionCostWithBonus <= float.Epsilon) ? score : (score / productionCostWithBonus));
    }
Ejemplo n.º 3
0
 public static void ComputeCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, ReadOnlyCollection <Construction> constructibles, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
 {
     PanelFeatureCost.costByResource.Clear();
     for (int i = 0; i < constructibles.Count; i++)
     {
         ConstructibleElement constructibleElement = constructibles[i].ConstructibleElement;
         if (constructibleElement.Costs != null)
         {
             if (constructibleElement is TechnologyDefinition && context.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1) && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock && (constructibleElement as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)
             {
                 costString = string.Empty;
                 turn       = -1;
                 global::Empire empire = context as global::Empire;
                 if (empire == null)
                 {
                     Diagnostics.LogError("Empire is null.");
                     return;
                 }
                 DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();
                 if (agency == null)
                 {
                     Diagnostics.LogError("Department of science is null");
                     return;
                 }
                 float buyOutTechnologyCost = agency.GetBuyOutTechnologyCost(constructibleElement);
                 if (buyOutTechnologyCost != 3.40282347E+38f)
                 {
                     costString = GuiFormater.FormatInstantCost(empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
                     return;
                 }
                 costString = "-";
                 return;
             }
             else
             {
                 for (int j = 0; j < constructibleElement.Costs.Length; j++)
                 {
                     if (constructibleElement.Costs[j] is PopulationConstructionCost)
                     {
                         PopulationConstructionCost populationConstructionCost = constructibleElement.Costs[j] as PopulationConstructionCost;
                         PanelFeatureCost.AppendCost(SimulationProperties.Population, populationConstructionCost.PopulationValue, true);
                     }
                     else
                     {
                         float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(context, constructibleElement, constructibleElement.Costs[j], true);
                         PanelFeatureCost.AppendCost(constructibleElement.Costs[j].ResourceName, productionCostWithBonus, constructibleElement.Costs[j].Instant || constructibleElement.Costs[j].InstantOnCompletion);
                     }
                 }
             }
         }
     }
     PanelFeatureCost.GetCostAndTurn(guiService, departmentOfTheTreasury, context, out costString, out turn);
 }
Ejemplo n.º 4
0
    private SynchronousJobState SynchronousJob_ChangeEmpirePlan()
    {
        if (this.empirePlanClasses == null)
        {
            this.empirePlanMessages.Clear();
            return(SynchronousJobState.Failure);
        }
        float num = 0f;
        AILayer_AccountManager layer = base.AIEntity.GetLayer <AILayer_AccountManager>();

        Diagnostics.Assert(layer != null);
        Account account = layer.TryGetAccount(AILayer_AccountManager.EmpirePlanAccountName);

        if (account == null)
        {
            this.empirePlanMessages.Clear();
            return(SynchronousJobState.Failure);
        }
        if (this.empirePlanMessages.Count != this.empirePlanClasses.Length)
        {
            Diagnostics.LogError("There must be one empire plan evaluable message by empire plan class.");
            this.empirePlanMessages.Clear();
            return(SynchronousJobState.Failure);
        }
        for (int i = 0; i < this.empirePlanMessages.Count; i++)
        {
            EvaluableMessage_EmpirePlan evaluableMessage_EmpirePlan = this.empirePlanMessages[i];
            if (this.departmentOfPlanification.IsEmpirePlanChoiced)
            {
                evaluableMessage_EmpirePlan.SetObtained();
            }
            else
            {
                EmpirePlanDefinition empirePlanDefinition = this.departmentOfPlanification.GetEmpirePlanDefinition(evaluableMessage_EmpirePlan.EmpirePlanClass, evaluableMessage_EmpirePlan.EmpirePlanLevel);
                if (empirePlanDefinition != null)
                {
                    float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
                    if (num + productionCostWithBonus <= account.PromisedAmount)
                    {
                        num += productionCostWithBonus;
                        OrderChangeEmpirePlan order = new OrderChangeEmpirePlan(base.AIEntity.Empire.Index, empirePlanDefinition.EmpirePlanClass, empirePlanDefinition.EmpirePlanLevel);
                        Ticket ticket;
                        base.AIEntity.Empire.PlayerControllers.Client.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderChangeEmpirePlan_TicketRaised));
                    }
                }
            }
        }
        this.empirePlanMessages.Clear();
        return(SynchronousJobState.Success);
    }
Ejemplo n.º 5
0
 protected override void EvaluateNeeds(StaticString context, StaticString pass)
 {
     base.EvaluateNeeds(context, pass);
     Diagnostics.Assert(this.empirePlanMessages != null && this.empirePlanMessages.Count == 0);
     if (!this.departmentOfPlanification.IsEmpirePlanChoiceTurn)
     {
         return;
     }
     this.empirePlanMessages.AddRange(base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_EmpirePlan>(BlackboardLayerID.Empire, (EvaluableMessage_EmpirePlan match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending));
     this.empirePlanMessages.Sort((EvaluableMessage_EmpirePlan left, EvaluableMessage_EmpirePlan right) => - 1 * left.Interest.CompareTo(right.Interest));
     for (int i = 0; i < this.empirePlanMessages.Count; i++)
     {
         EvaluableMessage_EmpirePlan evaluableMessage_EmpirePlan = this.empirePlanMessages[i];
         EmpirePlanDefinition        empirePlanDefinition        = this.departmentOfPlanification.GetEmpirePlanDefinition(evaluableMessage_EmpirePlan.EmpirePlanClass, evaluableMessage_EmpirePlan.EmpirePlanLevel);
         float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
         evaluableMessage_EmpirePlan.UpdateBuyEvaluation("EmpirePlan", 0UL, productionCostWithBonus, 2, 0f, 0UL);
     }
 }
Ejemplo n.º 6
0
    protected override void ComputeInitValue()
    {
        base.ComputeInitValue();
        Diagnostics.Assert(this.contextSimulationObject != null);
        float propertyValue = this.contextSimulationObject.GetPropertyValue(SimulationProperties.NetCityProduction);

        Diagnostics.Assert(this.constructionQueue != null);
        Construction         construction         = this.constructionQueue.Peek();
        ConstructibleElement constructibleElement = (construction == null) ? null : construction.ConstructibleElement;

        this.currentCostWithReduction = ((constructibleElement == null) ? 0f : DepartmentOfTheTreasury.GetProductionCostWithBonus(this.contextSimulationObject, constructibleElement, DepartmentOfTheTreasury.Resources.Production));
        this.currentProductionStress  = 1f;
        UnitDesign unitDesign = constructibleElement as UnitDesign;

        if (unitDesign != null)
        {
            this.currentProductionStress = 0f;
            bool flag = false;
            IEnumerable <EvaluableMessageWithUnitDesign> messages = this.aiPlayer.Blackboard.GetMessages <EvaluableMessageWithUnitDesign>(BlackboardLayerID.Empire, (EvaluableMessageWithUnitDesign match) => match.UnitDesign != null && match.UnitDesign.Model == unitDesign.Model);
            foreach (EvaluableMessageWithUnitDesign evaluableMessageWithUnitDesign in messages)
            {
                if (float.IsNaN(evaluableMessageWithUnitDesign.Interest))
                {
                    Diagnostics.LogWarning("Unit request interest is at value NaN, it will be skipped.");
                }
                else
                {
                    this.currentProductionStress = Mathf.Max(this.currentProductionStress, evaluableMessageWithUnitDesign.Interest);
                    flag = true;
                }
            }
            if (!flag)
            {
                this.currentProductionStress = 1f;
            }
        }
        this.currentProductionStress = Mathf.Clamp01(this.currentProductionStress);
        float num  = this.currentCostWithReduction * this.currentProductionStress;
        float num2 = (propertyValue <= 0f) ? this.maximumTurnCount : (num / propertyValue);

        base.ValueInit = ((this.maximumTurnCount <= 0f) ? base.ValueMax : Mathf.Clamp(Mathf.Max(num2 - 1f, 0f) / Mathf.Max(1f, this.maximumTurnCount - 1f), base.ValueMin, base.ValueMax));
    }
    protected internal override void CreateLocals()
    {
        base.CreateLocals();
        float propertyValue = base.AIEntity.Empire.GetPropertyValue(SimulationProperties.LavapoolStock);

        if (3f - propertyValue > 0f)
        {
            this.decisionResults.Clear();
            this.decisionMaker.EvaluateDecisions(this.boosterDefinitions, ref this.decisionResults);
            for (int i = 0; i < this.decisionResults.Count; i++)
            {
                BoosterDefinition boosterDefinition = this.decisionResults[i].Element as BoosterDefinition;
                if (boosterDefinition != null)
                {
                    float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.Empire, boosterDefinition, boosterDefinition.Costs[0].ResourceName);
                    if (base.DepartmentOfTheTreasury.CanAfford(productionCostWithBonus, boosterDefinition.Costs[0].ResourceName))
                    {
                        this.CreateChosenBoosterNeedMessage(boosterDefinition);
                        return;
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        base.Empire.Refresh(false);
        DepartmentOfScience     agency  = base.Empire.GetAgency <DepartmentOfScience>();
        DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>();

        this.ComputeCurrentEraNumber();
        this.CurrentEraNumber.Text = AgeUtils.ToRoman(this.currentEraNumber);
        this.ResearchErasTable.RefreshChildrenIList <ResearchEraFrame.TechnologyEra>(this.eras, this.refreshEraDelegate, true, false);
        Construction construction = agency.ResearchQueue.Peek();
        bool         flag         = construction != null;
        float        quantity;

        if (flag)
        {
            quantity = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.Empire.SimulationObject, construction.ConstructibleElement, DepartmentOfTheTreasury.Resources.EmpireResearch);
        }
        else
        {
            quantity = agency.GetResearchPropertyValue(SimulationProperties.TechnologyCost);
        }
        this.TechnologyCostValue.Text = GuiFormater.FormatQuantity(quantity, SimulationProperties.EmpireResearch, 1);
        float quantity2;

        agency2.TryGetNetResourceValue(base.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireResearch, out quantity2, false);
        this.EmpireOutputValue.Text = GuiFormater.FormatQuantity(quantity2, SimulationProperties.EmpireResearch, 0);
        if (flag)
        {
            float num = agency2.ComputeConstructionProgress(base.Empire, construction);
            this.ResearchProgress.Text = Mathf.RoundToInt(num * 100f).ToString() + "%";
            int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction);
            num2 = Mathf.Max(num2, 1);
            if (num2 == 2147483647)
            {
                this.ResearchTurns.Text = GuiFormater.Infinite.ToString();
            }
            else
            {
                this.ResearchTurns.Text = num2.ToString();
            }
            TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition;
            if (technologyDefinition != null)
            {
                this.TechnologyName.Text   = DepartmentOfScience.GetTechnologyTitle(technologyDefinition);
                this.TechnologyImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, GuiPanel.IconSize.Small);
            }
            DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.TechnologyName.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
        }
        else
        {
            this.TechnologyName.Text   = "%ResearchNoneTitle";
            this.TechnologyImage.Image = null;
            this.ResearchProgress.Text = "%ResearchVoidSymbol";
            this.ResearchTurns.Text    = "%ResearchVoidSymbol";
            if (this.TechnologyName.AgeTransform.AgeTooltip != null)
            {
                this.TechnologyName.AgeTransform.AgeTooltip.Class      = string.Empty;
                this.TechnologyName.AgeTransform.AgeTooltip.Content    = string.Empty;
                this.TechnologyName.AgeTransform.AgeTooltip.ClientData = null;
            }
            if (this.TechnologyImage.AgeTransform.AgeTooltip != null)
            {
                this.TechnologyImage.AgeTransform.AgeTooltip.Class      = string.Empty;
                this.TechnologyImage.AgeTransform.AgeTooltip.Content    = string.Empty;
                this.TechnologyImage.AgeTransform.AgeTooltip.ClientData = null;
            }
        }
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1))
        {
            this.TechnologyStatsGroup.Visible = false;
            this.ResearchBuyoutButton.AgeTransform.Visible = true;
            this.ResearchCompletionGroup.Visible           = false;
            this.RefreshBuyout(this.ResearchBuyoutButton);
            return;
        }
        this.TechnologyStatsGroup.Visible = true;
        this.ResearchBuyoutButton.AgeTransform.Visible = false;
        this.ResearchCompletionGroup.Visible           = true;
    }
Ejemplo n.º 9
0
    protected override void CreateLocalNeeds(StaticString context, StaticString pass)
    {
        base.CreateLocalNeeds(context, pass);
        Account account = this.aiLayerAccountManager.TryGetAccount(AILayer_AccountManager.EmpirePlanAccountName);

        if (account == null)
        {
            AILayer.LogError("Can't retrieve the empire plan account.");
            return;
        }
        Diagnostics.Assert(this.empirePlanClasses != null);
        Diagnostics.Assert(this.wantedEmpirePlan != null);
        for (int i = 0; i < this.empirePlanClasses.Length; i++)
        {
            this.wantedEmpirePlan.SubmitPlan(this.departmentOfPlanification.GetEmpirePlanDefinition(this.empirePlanClasses[i], 0));
        }
        Diagnostics.Assert(this.availableEmpirePlans != null);
        this.availableEmpirePlans.Clear();
        for (int j = 0; j < this.empirePlanClasses.Length; j++)
        {
            int empirePlanAvailableLevel = this.departmentOfPlanification.GetEmpirePlanAvailableLevel(this.empirePlanClasses[j]);
            for (int k = 1; k <= empirePlanAvailableLevel; k++)
            {
                this.availableEmpirePlans.Add(this.departmentOfPlanification.GetEmpirePlanDefinition(this.empirePlanClasses[j], k));
            }
        }
        Diagnostics.Assert(this.decisionMaker != null);
        base.AIEntity.Context.InitializeDecisionMaker <ConstructibleElement>(AILayer_Strategy.EmpirePlanParameterModifier, this.decisionMaker);
        this.decisionMaker.ClearAIParametersOverrides();
        this.FillDecisionMakerVariables();
        Diagnostics.Assert(this.decisionResults != null);
        this.decisionResults.Clear();
        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
        {
            DecisionMakerEvaluationData <ConstructibleElement, InterpreterContext> decisionMakerEvaluationData;
            this.decisionMaker.EvaluateDecisions(this.availableEmpirePlans, ref this.decisionResults, out decisionMakerEvaluationData);
            IGameService service = Services.GetService <IGameService>();
            decisionMakerEvaluationData.Turn = (service.Game as global::Game).Turn;
            this.DecisionMakerEvaluationDataHistoric.Add(decisionMakerEvaluationData);
        }
        else
        {
            this.decisionMaker.EvaluateDecisions(this.availableEmpirePlans, ref this.decisionResults);
        }
        IPersonalityAIHelper service2 = AIScheduler.Services.GetService <IPersonalityAIHelper>();
        float registryValue           = service2.GetRegistryValue <float>(base.AIEntity.Empire, "AI/MajorEmpire/AIEntity_Empire/AILayer_EmpirePlan/MaximumPopulationPercentToReachObjective", 0f);

        Diagnostics.Assert(this.wantedEmpirePlan != null);
        float num  = 0f;
        float num2 = float.MaxValue;
        float num3 = float.MinValue;

        for (int l = 0; l < this.decisionResults.Count; l++)
        {
            DecisionResult decisionResult = this.decisionResults[l];
            if (decisionResult.Score < 0.05f)
            {
                break;
            }
            EmpirePlanDefinition empirePlanDefinition = decisionResult.Element as EmpirePlanDefinition;
            num2 = Mathf.Min(num2, decisionResult.Score);
            num3 = Mathf.Max(num3, decisionResult.Score);
            EmpirePlanDefinition currentEmpirePlanDefinition = this.wantedEmpirePlan.GetCurrentEmpirePlanDefinition(empirePlanDefinition.EmpirePlanClass);
            if (currentEmpirePlanDefinition == null || empirePlanDefinition.EmpirePlanLevel > currentEmpirePlanDefinition.EmpirePlanLevel)
            {
                float num4 = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
                if (currentEmpirePlanDefinition != null)
                {
                    float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, currentEmpirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
                    num4 -= productionCostWithBonus;
                }
                float empirePointProductionStress = this.GetEmpirePointProductionStress(num + num4, account, this.departmentOfPlanification.EmpirePlanChoiceRemainingTurn);
                if (empirePointProductionStress <= registryValue)
                {
                    num += num4;
                    this.wantedEmpirePlan.SubmitPlan(empirePlanDefinition);
                }
            }
        }
        Diagnostics.Assert(this.empirePlanClasses != null);
        Diagnostics.Assert(this.wantedEmpirePlan != null);
        for (int m = 0; m < this.empirePlanClasses.Length; m++)
        {
            EmpirePlanDefinition empirePlan = this.wantedEmpirePlan.GetCurrentEmpirePlanDefinition(this.empirePlanClasses[m]);
            float localOpportunity          = 0f;
            if (empirePlan.EmpirePlanLevel > 0)
            {
                float score = this.decisionResults.Find((DecisionResult match) => match.Element == empirePlan).Score;
                localOpportunity = ((num3 - num2 <= float.Epsilon) ? 0f : ((score - num2) / (num3 - num2)));
            }
            EvaluableMessage_EmpirePlan evaluableMessage_EmpirePlan = base.AIEntity.AIPlayer.Blackboard.FindFirst <EvaluableMessage_EmpirePlan>(BlackboardLayerID.Empire, (EvaluableMessage_EmpirePlan match) => match.State == BlackboardMessage.StateValue.Message_InProgress && match.EmpirePlanClass == empirePlan.EmpirePlanClass);
            if (evaluableMessage_EmpirePlan != null)
            {
                evaluableMessage_EmpirePlan.EmpirePlanLevel = empirePlan.EmpirePlanLevel;
                evaluableMessage_EmpirePlan.SetInterest(1f, localOpportunity);
            }
            else
            {
                evaluableMessage_EmpirePlan = new EvaluableMessage_EmpirePlan(empirePlan.EmpirePlanClass, empirePlan.EmpirePlanLevel, this.departmentOfPlanification.EmpirePlanChoiceRemainingTurn, AILayer_AccountManager.EmpirePlanAccountName);
                evaluableMessage_EmpirePlan.SetInterest(1f, localOpportunity);
                base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_EmpirePlan);
            }
        }
    }
Ejemplo n.º 10
0
    private float GenerateMessageScoreForIndustry()
    {
        float result = 0f;

        if (!AILayer_Colonization.IsAbleToColonize(base.AIEntity.Empire))
        {
            result = 1f;
        }
        else if (this.aiEntityCity.City.BesiegingEmpire == null && this.constructionQueue.PendingConstructions.Count > 0)
        {
            ConstructibleElement constructibleElement = this.constructionQueue.Peek().ConstructibleElement;
            if (constructibleElement != null && (constructibleElement.SubCategory == "SubCategoryWonder" || constructibleElement.SubCategory == "SubCategoryVictory"))
            {
                return(1f);
            }
        }
        else
        {
            float num = 0f;
            float num2;
            for (int i = 0; i < this.departmentOfTheInterior.Cities.Count; i++)
            {
                num2 = (float)this.departmentOfTheInterior.Cities[i].CityImprovements.Count;
                if (num2 > num)
                {
                    num = num2;
                }
            }
            num2 = (float)this.aiEntityCity.City.CityImprovements.Count;
            float num3 = 1f - num2 / num;
            float num4 = 0f;
            if (!this.departmentOfTheTreasury.TryGetNetResourceValue(this.aiEntityCity.City, "Production", out num4, false))
            {
                num4 = 0f;
            }
            if (num4 == 0f)
            {
                num4 = 1f;
            }
            bool  flag  = false;
            bool  flag2 = false;
            float num5  = 0f;
            if (!this.departmentOfTheTreasury.TryGetResourceStockValue(this.aiEntityCity.City, DepartmentOfTheTreasury.Resources.Production, out num5, false))
            {
                num5 = 0f;
            }
            num5 += this.aiEntityCity.City.GetPropertyValue(SimulationProperties.NetCityProduction);
            num5  = Math.Max(1f, num5);
            for (int j = 0; j < this.constructionQueue.Length; j++)
            {
                Construction construction = this.constructionQueue.PeekAt(j);
                if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.aiEntityCity.City, construction.ConstructibleElement, new string[]
                {
                    ConstructionFlags.Prerequisite
                }))
                {
                    if (!flag2)
                    {
                        float num6 = 0f;
                        for (int k = 0; k < construction.CurrentConstructionStock.Length; k++)
                        {
                            if (construction.CurrentConstructionStock[k].PropertyName == "Production")
                            {
                                num6 += construction.CurrentConstructionStock[k].Stock;
                                if (construction.IsBuyout)
                                {
                                    num6 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production");
                                }
                            }
                        }
                        float num7 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production") - num6;
                        num5 -= num7;
                        if (num5 < 0f && !construction.ConstructibleElementName.ToString().Contains("BoosterGenerator"))
                        {
                            flag  = true;
                            flag2 = true;
                        }
                        if (construction.ConstructibleElementName.ToString().Contains("BoosterGenerator"))
                        {
                            flag2 = true;
                        }
                    }
                    float num8 = 0f;
                    for (int l = 0; l < construction.CurrentConstructionStock.Length; l++)
                    {
                        if (construction.CurrentConstructionStock[l].PropertyName == "Production")
                        {
                            num8 += construction.CurrentConstructionStock[l].Stock;
                        }
                    }
                    float num9 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production") - num8;
                    num3 = AILayer.Boost(num3, this.ComputeCostBoost(num9 / num4));
                }
            }
            if (this.aiEntityCity.City.BesiegingEmpire != null)
            {
                num3 = AILayer.Boost(num3, 0.5f);
            }
            if (!flag && !flag2)
            {
                flag = true;
            }
            if (!flag)
            {
                num3 = 0f;
            }
            result = num3;
        }
        return(result);
    }