mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Squashing 8 commits by DanAlbert: - Track theater in ControlPoint. Simplifies finding the owning theater of a control point. Not used yet. - Clean some cruft out of FlightPlanBuilder. - Clean up silly some exception handling. - Move FlightPlan instantiation into the builder. I'm working on moving the builder to be owned by the Flight, which will simplify callers that need to create (or recreate) flight plans for a flight. - Simplify IBuilder constructor. We have access to the theater via the flight's departure airbase now. - Move FlightPlan creation into Flight. For now this is just a callsite cleanup. Later, this will make it easier to separate unscheduled and scheduled flights into different classes without complicating the layout/scheduling. - Remove superfluous constructors. - Remove unused Package field.
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Type
|
|
|
|
from .formationattack import (
|
|
FormationAttackBuilder,
|
|
FormationAttackFlightPlan,
|
|
FormationAttackLayout,
|
|
)
|
|
from .waypointbuilder import WaypointBuilder
|
|
|
|
|
|
class EscortFlightPlan(FormationAttackFlightPlan):
|
|
@staticmethod
|
|
def builder_type() -> Type[Builder]:
|
|
return Builder
|
|
|
|
|
|
class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]):
|
|
def layout(self) -> FormationAttackLayout:
|
|
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 FormationAttackLayout(
|
|
departure=builder.takeoff(self.flight.departure),
|
|
hold=hold,
|
|
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(),
|
|
)
|
|
|
|
def build(self) -> EscortFlightPlan:
|
|
return EscortFlightPlan(self.flight, self.layout())
|