Refactor flight plan generation.

This commit is contained in:
Dan Albert
2020-09-29 00:58:19 -07:00
parent 8b717c4f4c
commit cc7c2cc707
8 changed files with 433 additions and 359 deletions

View File

@@ -5,6 +5,7 @@ from game.inventory import GlobalAircraftInventory
from game.models.game_stats import GameStats
from gen.ato import AirTaskingOrder
from gen.flights.ai_flight_planner import CoalitionMissionPlanner
from gen.flights.closestairfields import ObjectiveDistanceCache
from gen.ground_forces.ai_ground_planner import GroundPlanner
from .event import *
from .settings import Settings
@@ -204,6 +205,7 @@ class Game:
return event and event.name and event.name == self.player_name
def pass_turn(self, no_action=False, ignored_cps: typing.Collection[ControlPoint] = None):
ObjectiveDistanceCache.set_theater(self.theater)
logging.info("Pass turn")
self.informations.append(Information("End of turn #" + str(self.turn), "-" * 40, 0))

View File

@@ -185,20 +185,16 @@ class Operation:
self.airsupportgen.generate(self.is_awacs_enabled)
# Generate Activity on the map
for cp in self.game.theater.controlpoints:
side = cp.captured
if side:
country = self.current_mission.country(self.game.player_country)
ato = self.game.blue_ato
else:
country = self.current_mission.country(self.game.enemy_country)
ato = self.game.red_ato
self.airgen.generate_flights(
cp,
country,
ato,
self.groundobjectgen.runways
)
self.airgen.generate_flights(
self.current_mission.country(self.game.player_country),
self.game.blue_ato,
self.groundobjectgen.runways
)
self.airgen.generate_flights(
self.current_mission.country(self.game.enemy_country),
self.game.red_ato,
self.groundobjectgen.runways
)
# Generate ground units on frontline everywhere
jtacs: List[JtacInfo] = []