Dan Albert fa8c0d9660 Clean up flight plan code.
Split the oversized file into one per plan type. This also moves the
layout responsibility out of the oversized FlightPlanBuilder and into
each flight plan type file.
2022-03-09 02:15:07 -08:00

53 lines
1.8 KiB
Python

from __future__ import annotations
from datetime import timedelta
from typing import Type
from .formationattack import FormationAttackBuilder, FormationAttackFlightPlan
from .waypointbuilder import WaypointBuilder
class EscortFlightPlan(FormationAttackFlightPlan):
@staticmethod
def builder_type() -> Type[Builder]:
return Builder
class Builder(FormationAttackBuilder[EscortFlightPlan]):
def build(self) -> FormationAttackFlightPlan:
assert self.package.waypoints is not None
builder = WaypointBuilder(self.flight, self.coalition)
ingress, target = builder.escort(
self.package.waypoints.ingress, self.package.target
)
hold = builder.hold(self._hold_point())
join = builder.join(self.package.waypoints.join)
split = builder.split(self.package.waypoints.split)
refuel = None
if self.package.waypoints.refuel is not None:
refuel = builder.refuel(self.package.waypoints.refuel)
return EscortFlightPlan(
flight=self.flight,
departure=builder.takeoff(self.flight.departure),
hold=hold,
hold_duration=timedelta(minutes=5),
nav_to=builder.nav_path(
hold.position, join.position, self.doctrine.ingress_altitude
),
join=join,
ingress=ingress,
targets=[target],
split=split,
refuel=refuel,
nav_from=builder.nav_path(
split.position,
self.flight.arrival.position,
self.doctrine.ingress_altitude,
),
arrival=builder.land(self.flight.arrival),
divert=builder.divert(self.flight.divert),
bullseye=builder.bullseye(),
)