From dfcd372d2d0dfd40cb384aaf67b8786599c31504 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 13 Jul 2021 18:13:20 -0700 Subject: [PATCH] Remove egress points from most flight plans. These don't have any function. Remove them and remove the angled attack heading from the IP. --- game/data/doctrine.py | 21 +++++++++++------- gen/ato.py | 1 - gen/flights/flightplan.py | 40 ++++++---------------------------- gen/flights/waypointbuilder.py | 11 +++------- 4 files changed, 23 insertions(+), 50 deletions(-) diff --git a/game/data/doctrine.py b/game/data/doctrine.py index 3c648259..5fe9617f 100644 --- a/game/data/doctrine.py +++ b/game/data/doctrine.py @@ -1,7 +1,9 @@ from dataclasses import dataclass, field from datetime import timedelta +from typing import Any from game.data.groundunitclass import GroundUnitClass +from game.savecompat import has_save_compat_for from game.utils import Distance, feet, nautical_miles @@ -38,9 +40,8 @@ class Doctrine: push_distance: Distance join_distance: Distance split_distance: Distance - ingress_egress_distance: Distance + ingress_distance: Distance ingress_altitude: Distance - egress_altitude: Distance min_patrol_altitude: Distance max_patrol_altitude: Distance @@ -75,6 +76,13 @@ class Doctrine: mission_ranges: MissionPlannerMaxRanges = field(default=MissionPlannerMaxRanges()) + @has_save_compat_for(5) + def __setstate__(self, state: dict[str, Any]) -> None: + if "ingress_distance" not in state: + state["ingress_distance"] = state["ingress_egress_distance"] + del state["ingress_egress_distance"] + self.__dict__.update(state) + MODERN_DOCTRINE = Doctrine( cap=True, @@ -87,9 +95,8 @@ MODERN_DOCTRINE = Doctrine( push_distance=nautical_miles(20), join_distance=nautical_miles(20), split_distance=nautical_miles(20), - ingress_egress_distance=nautical_miles(45), + ingress_distance=nautical_miles(45), ingress_altitude=feet(20000), - egress_altitude=feet(20000), min_patrol_altitude=feet(15000), max_patrol_altitude=feet(33000), pattern_altitude=feet(5000), @@ -125,9 +132,8 @@ COLDWAR_DOCTRINE = Doctrine( push_distance=nautical_miles(10), join_distance=nautical_miles(10), split_distance=nautical_miles(10), - ingress_egress_distance=nautical_miles(30), + ingress_distance=nautical_miles(30), ingress_altitude=feet(18000), - egress_altitude=feet(18000), min_patrol_altitude=feet(10000), max_patrol_altitude=feet(24000), pattern_altitude=feet(5000), @@ -163,9 +169,8 @@ WWII_DOCTRINE = Doctrine( join_distance=nautical_miles(5), split_distance=nautical_miles(5), rendezvous_altitude=feet(10000), - ingress_egress_distance=nautical_miles(7), + ingress_distance=nautical_miles(7), ingress_altitude=feet(8000), - egress_altitude=feet(8000), min_patrol_altitude=feet(4000), max_patrol_altitude=feet(15000), pattern_altitude=feet(5000), diff --git a/gen/ato.py b/gen/ato.py index da6fbf1c..944cf316 100644 --- a/gen/ato.py +++ b/gen/ato.py @@ -40,7 +40,6 @@ class Task: class PackageWaypoints: join: Point ingress: Point - egress: Point split: Point diff --git a/gen/flights/flightplan.py b/gen/flights/flightplan.py index 0bcdd28c..92a7eb31 100644 --- a/gen/flights/flightplan.py +++ b/gen/flights/flightplan.py @@ -542,7 +542,6 @@ class StrikeFlightPlan(FormationFlightPlan): join: FlightWaypoint ingress: FlightWaypoint targets: List[FlightWaypoint] - egress: FlightWaypoint split: FlightWaypoint nav_from: List[FlightWaypoint] land: FlightWaypoint @@ -557,7 +556,6 @@ class StrikeFlightPlan(FormationFlightPlan): yield self.join yield self.ingress yield from self.targets - yield self.egress yield self.split yield from self.nav_from yield self.land @@ -569,7 +567,6 @@ class StrikeFlightPlan(FormationFlightPlan): def package_speed_waypoints(self) -> Set[FlightWaypoint]: return { self.ingress, - self.egress, self.split, } | set(self.targets) @@ -633,8 +630,8 @@ class StrikeFlightPlan(FormationFlightPlan): @property def split_time(self) -> timedelta: - travel_time = self.travel_time_between_waypoints(self.egress, self.split) - return self.egress_time + travel_time + travel_time = self.travel_time_between_waypoints(self.ingress, self.split) + return self.ingress_time + travel_time @property def ingress_time(self) -> timedelta: @@ -644,19 +641,9 @@ class StrikeFlightPlan(FormationFlightPlan): ) return tot - travel_time - @property - def egress_time(self) -> timedelta: - tot = self.tot - travel_time = self.travel_time_between_waypoints( - self.target_area_waypoint, self.egress - ) - return tot + travel_time - def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]: if waypoint == self.ingress: return self.ingress_time - elif waypoint == self.egress: - return self.egress_time elif waypoint in self.targets: return self.tot return super().tot_for_waypoint(waypoint) @@ -982,7 +969,7 @@ class FlightPlanBuilder: for join_point in self.preferred_join_points(): join_distance = meters(join_point.distance_to_point(target)) - if join_distance > self.doctrine.ingress_egress_distance: + if join_distance > self.doctrine.ingress_distance: break else: # The entire path to the target is threatened. Use the fallback behavior for @@ -995,11 +982,9 @@ class FlightPlanBuilder: # The first case described above. The ingress and join points are placed # reasonably relative to each other. - egress_point = self._egress_point(attack_heading) self.package.waypoints = PackageWaypoints( WaypointBuilder.perturb(join_point), ingress_point, - egress_point, WaypointBuilder.perturb(join_point), ) @@ -1010,13 +995,11 @@ class FlightPlanBuilder: from gen.ato import PackageWaypoints ingress_point = self._ingress_point(self._target_heading_to_package_airfield()) - egress_point = self._egress_point(self._target_heading_to_package_airfield()) join_point = self._rendezvous_point(ingress_point) split_point = self._rendezvous_point(self.package.target.position) self.package.waypoints = PackageWaypoints( join_point, ingress_point, - egress_point, split_point, ) @@ -1535,10 +1518,8 @@ class FlightPlanBuilder: assert self.package.waypoints is not None builder = WaypointBuilder(flight, self.coalition) - ingress, target, egress = builder.escort( - self.package.waypoints.ingress, - self.package.target, - self.package.waypoints.egress, + ingress, target = builder.escort( + self.package.waypoints.ingress, self.package.target ) hold = builder.hold(self._hold_point(flight)) join = builder.join(self.package.waypoints.join) @@ -1556,7 +1537,6 @@ class FlightPlanBuilder: join=join, ingress=ingress, targets=[target], - egress=egress, split=split, nav_from=builder.nav_path( split.position, flight.arrival.position, self.doctrine.ingress_altitude @@ -1804,7 +1784,6 @@ class FlightPlanBuilder: ingress_type, self.package.waypoints.ingress, location ), targets=target_waypoints, - egress=builder.egress(self.package.waypoints.egress, location), split=split, nav_from=builder.nav_path( split.position, flight.arrival.position, self.doctrine.ingress_altitude @@ -1848,7 +1827,7 @@ class FlightPlanBuilder: """Returns the position of the rendezvous point. Args: - attack_transition: The ingress or egress point for this rendezvous. + attack_transition: The ingress or target point for this rendezvous. """ if self._rendezvous_should_retreat(attack_transition): return self._retreating_rendezvous_point(attack_transition) @@ -1856,12 +1835,7 @@ class FlightPlanBuilder: def _ingress_point(self, heading: float) -> Point: return self.package.target.position.point_from_heading( - heading - 180 + 15, self.doctrine.ingress_egress_distance.meters - ) - - def _egress_point(self, heading: float) -> Point: - return self.package.target.position.point_from_heading( - heading - 180 - 15, self.doctrine.ingress_egress_distance.meters + heading - 180, self.doctrine.ingress_distance.meters ) def _target_heading_to_package_airfield(self) -> float: diff --git a/gen/flights/waypointbuilder.py b/gen/flights/waypointbuilder.py index daaea056..05ca1d93 100644 --- a/gen/flights/waypointbuilder.py +++ b/gen/flights/waypointbuilder.py @@ -427,21 +427,18 @@ class WaypointBuilder: self, ingress: Point, target: MissionTarget, - egress: Point, - ) -> Tuple[FlightWaypoint, FlightWaypoint, FlightWaypoint]: + ) -> Tuple[FlightWaypoint, FlightWaypoint]: """Creates the waypoints needed to escort the package. Args: ingress: The package ingress point. target: The mission target. - egress: The package egress point. """ # This would preferably be no points at all, and instead the Escort task # would begin on the join point and end on the split point, however the # escort task does not appear to work properly (see the longer # description in gen.aircraft.JoinPointBuilder), so instead we give - # the escort flights a flight plan including the ingress point, target - # area, and egress point. + # the escort flights a flight plan including the ingress point and target area. ingress_wp = self.ingress(FlightWaypointType.INGRESS_ESCORT, ingress, target) waypoint = FlightWaypoint( @@ -455,9 +452,7 @@ class WaypointBuilder: waypoint.name = "TARGET" waypoint.description = "Escort the package" waypoint.pretty_name = "Target area" - - egress_wp = self.egress(egress, target) - return ingress_wp, waypoint, egress_wp + return ingress_wp, waypoint @staticmethod def pickup(control_point: ControlPoint) -> FlightWaypoint: