示例#1
0
    private void UpdateLists(AIRegionData regionData)
    {
        for (int i = 0; i < regionData.Region.PointOfInterests.Length; i++)
        {
            PointOfInterest pointOfInterest = regionData.Region.PointOfInterests[i];
            if (pointOfInterest.Type == "ResourceDeposit")
            {
                string technologyName;
                if (pointOfInterest.PointOfInterestImprovement == null && pointOfInterest.PointOfInterestDefinition.TryGetValue("VisibilityTechnology", out technologyName) && this.departmentOfScience.GetTechnologyState(technologyName) == DepartmentOfScience.ConstructibleElement.State.Researched && this.CanStopThere(pointOfInterest.WorldPosition))
                {
                    this.Resources.Add(pointOfInterest);
                }
            }
            else if (pointOfInterest.Type == ELCPUtilities.QuestLocation && (pointOfInterest.Interaction.Bits & this.owner.Bits) != this.owner.Bits && this.CanStopThere(pointOfInterest.WorldPosition))
            {
                this.Ruins.Add(pointOfInterest);
            }
        }
        IWorldPositionningService service = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>();
        IOrbAIHelper service2             = AIScheduler.Services.GetService <IOrbAIHelper>();

        for (int j = 0; j < service2.OrbSpawns.Count; j++)
        {
            if (service2.OrbSpawns[j].CurrentOrbCount != 0f && (int)service.GetRegionIndex(service2.OrbSpawns[j].WorldPosition) == regionData.RegionIndex && this.CanStopThere(service2.OrbSpawns[j].WorldPosition))
            {
                this.Orbs.Add(service2.OrbSpawns[j]);
            }
        }
    }
示例#2
0
    protected bool HasSecondaryTarget(BaseNavyArmy army)
    {
        NavyArmy navyArmy = army as NavyArmy;

        if (navyArmy == null)
        {
            return(false);
        }
        if (navyArmy.SecondaryTarget == null)
        {
            return(false);
        }
        if (navyArmy.SecondaryTarget.Type == BehaviorOpportunity.OpportunityType.Ruin)
        {
            PointOfInterest pointOfInterest = this.worldPositionService.GetPointOfInterest(navyArmy.SecondaryTarget.OpportunityPosition);
            if (!this.CouldSearch(army, pointOfInterest))
            {
                navyArmy.SecondaryTarget = null;
            }
        }
        else if (navyArmy.SecondaryTarget.Type == BehaviorOpportunity.OpportunityType.Orbs)
        {
            IOrbAIHelper service = AIScheduler.Services.GetService <IOrbAIHelper>();
            OrbSpawnInfo orbSpawnInfo;
            if (!service.TryGetOrbSpawnInfoAt(navyArmy.SecondaryTarget.OpportunityPosition, out orbSpawnInfo) || orbSpawnInfo.CurrentOrbCount == 0f)
            {
                navyArmy.SecondaryTarget = null;
            }
        }
        else if (navyArmy.SecondaryTarget.Score <= 0.1f)
        {
            navyArmy.SecondaryTarget = null;
        }
        return(navyArmy.SecondaryTarget != null);
    }
示例#3
0
    public void RemoveRegion(AIRegionData regionData)
    {
        for (int i = 0; i < regionData.Region.PointOfInterests.Length; i++)
        {
            PointOfInterest pointOfInterest = regionData.Region.PointOfInterests[i];
            if (pointOfInterest.Type == "ResourceDeposit")
            {
                this.Resources.Remove(pointOfInterest);
            }
            else if (pointOfInterest.Type == ELCPUtilities.QuestLocation)
            {
                this.Ruins.Remove(pointOfInterest);
            }
        }
        IWorldPositionningService service = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>();
        IOrbAIHelper service2             = AIScheduler.Services.GetService <IOrbAIHelper>();

        for (int j = 0; j < service2.OrbSpawns.Count; j++)
        {
            if ((int)service.GetRegionIndex(service2.OrbSpawns[j].WorldPosition) == regionData.RegionIndex)
            {
                this.Orbs.Remove(service2.OrbSpawns[j]);
            }
        }
        this.Regions.Remove(regionData);
    }
示例#4
0
    private void ComputeOpportunityScore_Orbs(BaseNavyArmy army)
    {
        NavyArmy navyArmy = army as NavyArmy;

        if (navyArmy == null)
        {
            return;
        }
        IOrbAIHelper service = AIScheduler.Services.GetService <IOrbAIHelper>();

        for (int i = 0; i < service.OrbSpawns.Count; i++)
        {
            OrbSpawnInfo orbSpawnInfo = service.OrbSpawns[i];
            if (orbSpawnInfo != null && orbSpawnInfo.CurrentOrbCount != 0f)
            {
                HeuristicValue heuristicValue = orbSpawnInfo.EmpireNeedModifier[army.Garrison.Empire.Index];
                if (heuristicValue > 0f)
                {
                    float num = this.ComputeOpportunityTurnOverhead(army, orbSpawnInfo.WorldPosition);
                    if ((army.CurrentMainTask == null || this.IsDetourWorthChecking(army, num)) && this.worldPositionService.IsOceanTile(orbSpawnInfo.WorldPosition) && this.IsCloseEnoughToOrigin(army, orbSpawnInfo.WorldPosition, 1f))
                    {
                        HeuristicValue heuristicValue2 = new HeuristicValue(0f);
                        heuristicValue2.Add(heuristicValue, "Orb position eval", new object[0]);
                        float          orbDistanceExponent = service.GetOrbDistanceExponent(army.Garrison.Empire);
                        HeuristicValue heuristicValue3     = new HeuristicValue(0f);
                        heuristicValue3.Add(num, "Nb turn added by opportunity", new object[0]);
                        heuristicValue3.Power(orbDistanceExponent, "From xml registry", new object[0]);
                        heuristicValue3.Add(1f, "avoid divide by 0", new object[0]);
                        heuristicValue2.Divide(heuristicValue3, "DistanceFactor", new object[0]);
                        navyArmy.Opportunities.Add(new BehaviorOpportunity
                        {
                            OpportunityPosition = orbSpawnInfo.WorldPosition,
                            Score = heuristicValue2,
                            Type  = BehaviorOpportunity.OpportunityType.Orbs
                        });
                    }
                }
            }
        }
    }