Avoid refuel waypoint if air wing can't plan refuel flight

This commit is contained in:
Raffson 2023-09-23 17:25:12 +02:00
parent b870198281
commit ea74471307
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 20 additions and 25 deletions

View File

@ -86,32 +86,20 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]):
else ingress_alt,
)
refuel = None
if not self.flight.is_helo:
refuel = builder.refuel(self.package.waypoints.refuel)
refuel = self._build_refuel(builder)
departure = builder.takeoff(self.flight.departure)
if hold:
nav_to = builder.nav_path(
hold.position, join.position, self.doctrine.ingress_altitude
)
else:
nav_to = builder.nav_path(
departure.position, join.position, self.doctrine.ingress_altitude
)
nav_to = builder.nav_path(
hold.position if hold else departure.position,
join.position,
self.doctrine.ingress_altitude,
)
if refuel:
nav_from = builder.nav_path(
refuel.position,
self.flight.arrival.position,
self.doctrine.ingress_altitude,
)
else:
nav_from = builder.nav_path(
split.position,
self.flight.arrival.position,
self.doctrine.ingress_altitude,
)
nav_from = builder.nav_path(
refuel.position if refuel else split.position,
self.flight.arrival.position,
self.doctrine.ingress_altitude,
)
return FormationAttackLayout(
departure=departure,

View File

@ -191,7 +191,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
hold = builder.hold(self._hold_point())
join = builder.join(self.package.waypoints.join)
split = builder.split(self.package.waypoints.split)
refuel = builder.refuel(self.package.waypoints.refuel)
refuel = self._build_refuel(builder)
ingress = builder.ingress(
ingress_type, self.package.waypoints.ingress, self.package.target
@ -225,7 +225,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
split=split,
refuel=refuel,
nav_from=builder.nav_path(
refuel.position,
refuel.position if refuel else split.position,
self.flight.arrival.position,
self.doctrine.ingress_altitude,
),
@ -234,6 +234,13 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
bullseye=builder.bullseye(),
)
def _build_refuel(self, builder: WaypointBuilder) -> Optional[FlightWaypoint]:
refuel: Optional[FlightWaypoint] = None
can_plan = self.flight.coalition.air_wing.can_auto_plan(FlightType.REFUELING)
if not self.flight.is_helo and can_plan and self.package.waypoints:
refuel = builder.refuel(self.package.waypoints.refuel)
return refuel
@property
def primary_flight_is_air_assault(self) -> bool:
if self.flight is self.package.primary_flight: