public override void Reset()
    {
        base.Reset();
        if (!base.Enable)
        {
            return;
        }
        if (this.departmentOfTheInterior == null)
        {
            Diagnostics.LogError("The agent {0} can't get the department of interior.", new object[]
            {
                base.Name
            });
            base.Enable = false;
            return;
        }
        Agent[] validatedAgents = new AgentGroupPath("ResourceEvaluationAmas/CityAgentGroup").GetValidatedAgents(base.ParentGroup, "NetCityMoney");
        SimulationNormalizedAgent[] array;
        if (validatedAgents != null)
        {
            array = Array.ConvertAll <Agent, SimulationNormalizedAgent>(validatedAgents, (Agent agent) => agent as SimulationNormalizedAgent);
        }
        else
        {
            array = new SimulationNormalizedAgent[0];
        }
        this.netCityMoneyAgents = array;
        Diagnostics.Assert(this.netCityMoneyAgents != null);
        AIEntity_Empire entity = (base.ContextObject as AIPlayer_MajorEmpire).GetEntity <AIEntity_Empire>();

        this.aILayer_Victory = entity.GetLayer <AILayer_Victory>();
    }
    protected override void ComputeValue()
    {
        base.ComputeValue();
        Diagnostics.Assert(this.netCityMoneyAgents != null);
        float num = 0f;

        for (int i = 0; i < this.netCityMoneyAgents.Length; i++)
        {
            SimulationNormalizedAgent simulationNormalizedAgent = this.netCityMoneyAgents[i];
            Diagnostics.Assert(simulationNormalizedAgent != null);
            City city = simulationNormalizedAgent.ContextObject as City;
            Diagnostics.Assert(city != null);
            float propertyValue = city.GetPropertyValue(SimulationProperties.NetCityMoney);
            num += simulationNormalizedAgent.UnnormalizedValue - propertyValue;
        }
        float num2           = this.empire.GetPropertyValue(SimulationProperties.NetEmpireMoney) + num;
        float propertyValue2 = this.empire.GetPropertyValue(SimulationProperties.EmpireMoneyUpkeep);
        float propertyValue3 = this.empire.GetPropertyValue(SimulationProperties.BankAccount);
        float b    = propertyValue2 * this.moneyStockToMaintainUpkeepTurnCount;
        float num3 = Mathf.Max((num2 >= 0f) ? 0f : (-num2 * this.moneyStockToMaintainUpkeepTurnCount), b);
        float num4 = this.moneyIncomeGrowthPercent * propertyValue3;
        float num5 = (propertyValue3 <= 0f) ? 0f : (propertyValue3 / num3);
        float num6 = (num2 <= 0f) ? 0f : (num2 / num4);
        float num7 = (num5 + num6) / 2f;

        if (this.aILayer_Victory.CurrentFocusEnum == AILayer_Victory.VictoryFocus.Economy)
        {
            num7 = Math.Max(0.5f, num7 * 1.5f);
        }
        base.Value = Math.Max(base.ValueMin, Math.Min(num7, base.ValueMax));
    }
Exemplo n.º 3
0
    protected override void ComputeValue()
    {
        base.ComputeValue();
        Diagnostics.Assert(this.departmentOfScience != null);
        Diagnostics.Assert(this.netCityResearchAgents != null);
        float num  = (float)this.game.Turn;
        float num2 = 0f;

        for (int i = 0; i < this.netCityResearchAgents.Length; i++)
        {
            SimulationNormalizedAgent simulationNormalizedAgent = this.netCityResearchAgents[i];
            Diagnostics.Assert(simulationNormalizedAgent != null);
            City city = simulationNormalizedAgent.ContextObject as City;
            Diagnostics.Assert(city != null);
            float propertyValue = city.GetPropertyValue(SimulationProperties.NetCityResearch);
            num2 += simulationNormalizedAgent.UnnormalizedValue - propertyValue;
        }
        float        num3 = this.empire.GetPropertyValue(SimulationProperties.NetEmpireResearch) + num2;
        float        researchPropertyValue = this.departmentOfScience.GetResearchPropertyValue("UnlockedTechnologyCount");
        float        num4         = 0f;
        int          num5         = 0;
        Construction construction = this.departmentOfScience.ResearchQueue.Peek();

        if (construction != null)
        {
            num5 = 1;
            float num6 = this.departmentOfTheTreasury.ComputeConstructionRemainingCost(this.empire, construction, DepartmentOfTheTreasury.Resources.EmpireResearch);
            num4 = ((num3 <= 0f) ? float.MaxValue : (num6 / num3));
        }
        float num7  = researchPropertyValue + (float)num5;
        float num8  = num + num4;
        float num9  = num7 * this.idealTechnologyUnlockPeriod;
        float num10 = (num8 - num9) / this.maximumPeriodGap;

        if (this.aILayer_Victory.CurrentFocusEnum == AILayer_Victory.VictoryFocus.Economy)
        {
            num10 = Math.Max(0.2f, num10 * 1.2f);
        }
        else if (this.aILayer_Victory.CurrentFocusEnum == AILayer_Victory.VictoryFocus.MostTechnologiesDiscovered)
        {
            num10 = Math.Max(0.5f, num10 * 1.5f);
        }
        base.Value = Math.Max(base.ValueMin, Math.Min(num10, base.ValueMax));
    }