private void GetPotentialCapturePlanets(WorldSide localSide) { Galaxy galaxy = Engine_AIW2.Instance.NonSim_GetGalaxyBeingCurrentlyViewed(); for (int i = 0; i < galaxy.Planets.Count; i++) { Planet planet = galaxy.Planets[i]; if (!planet.HumansHaveBasicIntel) { continue; } if (localSide.GetIsFriendlyTowards(planet.GetControllingSide())) { continue; } bool foundEligibleSelfOrNeighbor = false; if (planet.Combat.GetSideForWorldSide(localSide).Entities.GetNumberIn(EntityRollupType.KingUnits) > 0) { foundEligibleSelfOrNeighbor = true; } else { planet.DoForLinkedNeighbors(delegate(Planet neighbor) { if (localSide.GetIsFriendlyTowards(neighbor.GetControllingSide())) { foundEligibleSelfOrNeighbor = true; return(DelReturn.Break); } else if (neighbor.Combat.GetSideForWorldSide(localSide).Entities.GetNumberIn(EntityRollupType.KingUnits) > 0) { foundEligibleSelfOrNeighbor = true; return(DelReturn.Break); } return(DelReturn.Continue); }); } if (!foundEligibleSelfOrNeighbor) { continue; } this.RelatedPlanets.Add(planet); } }
public void DoPerSimStepLogic(WorldSide side, ArcenSimContext Context) { bool haveHumanOccupiers = false; bool haveAIOccupiers = false; 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)) { return(DelReturn.Continue); } if (planet.GetIsControlledBySideType(WorldSideType.Player)) { haveHumanOccupiers = true; } if (planet.GetIsControlledBySideType(WorldSideType.AI)) { haveAIOccupiers = true; } return(DelReturn.Continue); }); if (haveHumanOccupiers) { World_AIW2.Instance.DoForSides(delegate(WorldSide otherSide) { if (side == otherSide) { return(DelReturn.Continue); } switch (otherSide.Type) { case WorldSideType.NaturalObject: break; case WorldSideType.AI: if (side.GetIsFriendlyTowards(otherSide)) { break; } side.MakeFriendlyTo(otherSide); otherSide.MakeFriendlyTo(side); break; default: if (side.GetIsHostileTowards(otherSide)) { break; } side.MakeHostileTo(otherSide); otherSide.MakeHostileTo(side); break; } return(DelReturn.Continue); }); } else if (!haveAIOccupiers) { World_AIW2.Instance.DoForSides(delegate(WorldSide otherSide) { if (side == otherSide) { return(DelReturn.Continue); } switch (otherSide.Type) { case WorldSideType.NaturalObject: break; case WorldSideType.Player: if (side.GetIsFriendlyTowards(otherSide)) { break; } side.MakeFriendlyTo(otherSide); otherSide.MakeFriendlyTo(side); break; default: if (side.GetIsHostileTowards(otherSide)) { break; } side.MakeHostileTo(otherSide); otherSide.MakeHostileTo(side); break; } return(DelReturn.Continue); }); } else { World_AIW2.Instance.DoForSides(delegate(WorldSide otherSide) { if (side == otherSide) { return(DelReturn.Continue); } if (otherSide.Type == WorldSideType.NaturalObject) { return(DelReturn.Continue); } if (side.GetIsHostileTowards(otherSide)) { return(DelReturn.Continue); } side.MakeHostileTo(otherSide); otherSide.MakeHostileTo(side); return(DelReturn.Continue); }); } }