Adjust flightplans for escorts

This commit is contained in:
Raffson
2022-11-12 23:13:23 +01:00
parent 3f79fa5b9d
commit 2270300177
4 changed files with 52 additions and 6 deletions

View File

@@ -4,13 +4,13 @@ from abc import ABC
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from typing import TYPE_CHECKING, TypeVar
from typing import TYPE_CHECKING, TypeVar, Optional
from dcs import Point
from game.flightplan import HoldZoneGeometry
from game.theater import MissionTarget
from game.utils import Speed, meters
from game.utils import Speed, meters, Distance
from .flightplan import FlightPlan
from .formation import FormationFlightPlan, FormationLayout
from .ibuilder import IBuilder
@@ -134,6 +134,7 @@ class FormationAttackFlightPlan(FormationFlightPlan, ABC):
class FormationAttackLayout(FormationLayout):
ingress: FlightWaypoint
targets: list[FlightWaypoint]
initial: Optional[FlightWaypoint] = None
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
yield self.departure
@@ -141,6 +142,8 @@ class FormationAttackLayout(FormationLayout):
yield from self.nav_to
yield self.join
yield self.ingress
if self.initial is not None:
yield self.initial
yield from self.targets
yield self.split
if self.refuel is not None:
@@ -185,6 +188,16 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
if self.package.waypoints.refuel is not None:
refuel = builder.refuel(self.package.waypoints.refuel)
ingress = builder.ingress(
ingress_type, self.package.waypoints.ingress, self.package.target
)
initial = None
if self.package.primary_task == FlightType.STRIKE:
ingress = builder.nav(self.package.waypoints.ingress, Distance.from_feet(20000))
initial = builder.ingress(
ingress_type, self.package.waypoints.initial, self.package.target
)
return FormationAttackLayout(
departure=builder.takeoff(self.flight.departure),
hold=hold,
@@ -192,9 +205,8 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
hold.position, join.position, self.doctrine.ingress_altitude
),
join=join,
ingress=builder.ingress(
ingress_type, self.package.waypoints.ingress, self.package.target
),
ingress=ingress,
initial=initial,
targets=target_waypoints,
split=split,
refuel=refuel,