public void ManageAOsORIG() { List<AO> ToRemove = new List<AO>(); foreach (AO area in this.AreasOfOperations) { area.ThreatLevel = 0; if (area.GetPlanet().Owner != this.empire) { ToRemove.Add(area); } foreach (Empire e in EmpireManager.EmpireList) { if (e == this.empire || e.data.Defeated || !this.empire.GetRelations()[e].AtWar) { continue; } foreach (AO theirAO in e.GetGSAI().AreasOfOperations) { if (Vector2.Distance(area.Position, theirAO.Position) >= area.Radius * 2f) { continue; } AO threatLevel = area; threatLevel.ThreatLevel = threatLevel.ThreatLevel + 1; } } } foreach (AO toremove in ToRemove) { this.AreasOfOperations.Remove(toremove); } List<Planet> PotentialCores = new List<Planet>(); foreach (Planet p in this.empire.GetPlanets()) { if (p.GetMaxProductionPotential() <= 5f || !p.HasShipyard) { continue; } bool AlreadyExists = false; foreach (AO area in this.AreasOfOperations) { if (area.GetPlanet() != p) { continue; } AlreadyExists = true; break; } if (AlreadyExists) { continue; } PotentialCores.Add(p); } if (PotentialCores.Count == 0) { return; } IOrderedEnumerable<Planet> sortedList = from planet in PotentialCores orderby planet.GetMaxProductionPotential() descending select planet; foreach (Planet p in sortedList) { bool FarEnough = true; foreach (AO area in this.AreasOfOperations) { if (Vector2.Distance(area.GetPlanet().Position, p.Position) >= 1500000f) { continue; } FarEnough = false; break; } if (!FarEnough) { continue; } AO area0 = new AO(p, 1500000f); this.AreasOfOperations.Add(area0); } }
//addedby gremlin manageAOs public void ManageAOs() { //Vector2 empireCenter =this.empire.GetWeightedCenter(); List<AO> aOs = new List<AO>(); float empireStr = this.empire.currentMilitaryStrength / (this.AreasOfOperations.Count*2+1); foreach (AO areasOfOperation in this.AreasOfOperations) { areasOfOperation.ThreatLevel = 0; if (areasOfOperation.GetPlanet().Owner != this.empire) { aOs.Add(areasOfOperation); } this.empire.KnownShips.thisLock.EnterReadLock(); foreach (Ship ship in this.empire.KnownShips) { if (ship.loyalty == this.empire || Vector2.Distance(areasOfOperation.GetPlanet().Position, ship.Center) > areasOfOperation.Radius) continue; areasOfOperation.ThreatLevel += (int)ship.GetStrength(); } this.empire.KnownShips.thisLock.ExitReadLock(); int min = (int)(empireStr * (this.DefensiveCoordinator.GetDefensiveThreatFromPlanets(areasOfOperation.GetPlanets())*.1f)); if (areasOfOperation.ThreatLevel < min) areasOfOperation.ThreatLevel = min; //foreach (Empire empireList in EmpireManager.EmpireList) //{ // if (empireList == this.empire || empireList.data.Defeated || !this.empire.GetRelations()[empireList].AtWar) // { // continue; // } // foreach (AO aO in empireList.GetGSAI().AreasOfOperations) // { // if (Vector2.Distance(areasOfOperation.Position, aO.Position) >= areasOfOperation.Radius * 2f) // { // continue; // } // AO threatLevel = areasOfOperation; //try to make threatlevel usefull. still not very usefull // threatLevel.ThreatLevel = threatLevel.ThreatLevel + aO // } //} } foreach (AO aO1 in aOs) { this.AreasOfOperations.Remove(aO1); } List<Planet> planets = new List<Planet>(); foreach (Planet planet1 in this.empire.GetPlanets()) { if (planet1.GetMaxProductionPotential() <= 5f || !planet1.HasShipyard) { continue; } bool flag = false; foreach (AO areasOfOperation1 in this.AreasOfOperations) { if (areasOfOperation1.GetPlanet() != planet1) { continue; } flag = true; break; } if (flag) { continue; } planets.Add(planet1); } if (planets.Count == 0) { return; } IOrderedEnumerable<Planet> maxProductionPotential = from planet in planets orderby planet.GetMaxProductionPotential() descending select planet; foreach (Planet planet2 in maxProductionPotential) { float aoSize = 0; foreach (SolarSystem system in planet2.system.FiveClosestSystems) { //if (system.OwnerList.Contains(this.empire)) // continue; if (aoSize < Vector2.Distance(planet2.Position, system.Position)) aoSize = Vector2.Distance(planet2.Position, system.Position); } float aomax = Empire.universeScreen.Size.X * .2f; if (aoSize > aomax) aoSize = aomax; bool flag1 = true; foreach (AO areasOfOperation2 in this.AreasOfOperations) { if (Vector2.Distance(areasOfOperation2.GetPlanet().Position, planet2.Position) >= aoSize) { continue; } flag1 = false; break; } if (!flag1) { continue; } AO aO2 = new AO(planet2, aoSize); this.AreasOfOperations.Add(aO2); } }