Example #1
0
        public void DoLongRangePlanning(WorldSide side, ArcenLongTermPlanningContext Context)
        {
            Galaxy galaxy = World_AIW2.Instance.SetOfGalaxies.Galaxies[0];

            side.Entities.DoForEntities(GameEntityCategory.Ship, delegate(GameEntity entity)
            {
                if (entity.LongRangePlanningData == null)
                {
                    return(DelReturn.Continue); // if created after the start of this planning cycle, skip
                }
                if (!entity.TypeData.GetHasTag(DEVOURER_TAG))
                {
                    return(DelReturn.Continue); // if not the Big D, skip (shouldn't happen, but if somebody mods in a reclamator gun for the thing, etc)
                }
                if (entity.LongRangePlanningData.FinalDestinationPlanetIndex != -1 &&
                    entity.LongRangePlanningData.FinalDestinationPlanetIndex != entity.LongRangePlanningData.CurrentPlanetIndex)
                {
                    return(DelReturn.Continue); // if heading somewhere else, skip
                }
                Planet planet = World_AIW2.Instance.GetPlanetByIndex(entity.LongRangePlanningData.CurrentPlanetIndex);

                List <GameEntity> threatShipsNotAssignedElsewhere = new List <GameEntity>();
                threatShipsNotAssignedElsewhere.Add(entity);
                FactionUtilityMethods.Helper_SendThreatOnRaid(threatShipsNotAssignedElsewhere, side, galaxy, planet, true, Context);

                return(DelReturn.Continue);
            });
        }
        public void DoLongRangePlanning(WorldSide side, ArcenLongTermPlanningContext Context)
        {
            ArcenSparseLookup <Planet, List <GameEntity> > unassignedThreatShipsByPlanet = new ArcenSparseLookup <Planet, List <GameEntity> >();

            side.Entities.DoForEntities(GameEntityCategory.Ship, delegate(GameEntity entity)
            {
                if (entity.LongRangePlanningData == null)
                {
                    return(DelReturn.Continue); // if created after the start of this planning cycle, skip
                }
                Planet planet = World_AIW2.Instance.GetPlanetByIndex(entity.LongRangePlanningData.CurrentPlanetIndex);
                if (entity.TypeData.GetHasTag(DYSON_SPHERE_TAG))
                {
                    // the sphere itself
                }
                else
                {
                    // something the sphere spawned

                    if (entity.LongRangePlanningData.FinalDestinationPlanetIndex != -1 &&
                        entity.LongRangePlanningData.FinalDestinationPlanetIndex != entity.LongRangePlanningData.CurrentPlanetIndex)
                    {
                        return(DelReturn.Continue); // if heading somewhere else, skip
                    }
                    if (!unassignedThreatShipsByPlanet.GetHasKey(planet))
                    {
                        unassignedThreatShipsByPlanet[planet] = new List <GameEntity>();
                    }
                    unassignedThreatShipsByPlanet[planet].Add(entity);
                }
                return(DelReturn.Continue);
            });

            int pairCount = unassignedThreatShipsByPlanet.GetPairCount();

            for (int i = 0; i < pairCount; i++)
            {
                ArcenSparseLookupPair <Planet, List <GameEntity> > pair = unassignedThreatShipsByPlanet.GetPairByIndex(i);

                FactionUtilityMethods.Helper_SendThreatOnRaid(pair.Value, side, World_AIW2.Instance.SetOfGalaxies.Galaxies[0], pair.Key, false, Context);
            }
        }