コード例 #1
0
    private void ComputeObjectivePriority()
    {
        bool flag = false;

        if (this.departmentOfForeignAffairs.IsInWarWithSomeone())
        {
            flag = true;
        }
        else
        {
            foreach (City city in this.departmentOfTheInterior.Cities)
            {
                if (!this.worldAtlasAIHelper.IsRegionPacified(base.AIEntity.Empire, city.Region) || city.BesiegingEmpireIndex >= 0)
                {
                    flag = true;
                    break;
                }
            }
        }
        base.GlobalPriority.Reset();
        base.GlobalPriority.Add(0.1f, "(constant)", new object[0]);
        AILayer_Colonization layer = base.AIEntity.GetLayer <AILayer_Colonization>();

        for (int i = 0; i < this.globalObjectiveMessages.Count; i++)
        {
            GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages[i];
            HeuristicValue         heuristicValue         = new HeuristicValue(0f);
            heuristicValue.Add(layer.GetColonizationInterest(globalObjectiveMessage.RegionIndex), "Region colo interest", new object[0]);
            if (this.departmentOfCreepingNodes != null)
            {
                if (this.departmentOfCreepingNodes.Nodes.Any((CreepingNode CN) => CN.Region.Index == globalObjectiveMessage.RegionIndex))
                {
                    heuristicValue.Boost(1f, "bloom in region", new object[0]);
                }
                else if (this.departmentOfCreepingNodes.Nodes.Count > 0)
                {
                    heuristicValue.Max(0.5f, "bloom in region", new object[0]);
                }
            }
            heuristicValue.Multiply(0.1f, "(constant)", new object[0]);
            globalObjectiveMessage.LocalPriority  = heuristicValue;
            globalObjectiveMessage.GlobalPriority = base.GlobalPriority;
            if (i < 1 && !flag && base.AIEntity.Empire.GetAgency <DepartmentOfDefense>().Armies.Count > 2)
            {
                globalObjectiveMessage.LocalPriority.Boost(0.75f, "(constant)", new object[0]);
                globalObjectiveMessage.GlobalPriority.Boost(0.75f, "(constant)", new object[0]);
            }
            globalObjectiveMessage.TimeOut = 1;
        }
    }