mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
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.
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Type
|
|
|
|
from game.theater.theatergroundobject import (
|
|
EwrGroundObject,
|
|
SamGroundObject,
|
|
)
|
|
from .formationattack import (
|
|
FormationAttackBuilder,
|
|
FormationAttackFlightPlan,
|
|
FormationAttackLayout,
|
|
)
|
|
from .invalidobjectivelocation import InvalidObjectiveLocation
|
|
from ..flightwaypointtype import FlightWaypointType
|
|
|
|
|
|
class DeadFlightPlan(FormationAttackFlightPlan):
|
|
@staticmethod
|
|
def builder_type() -> Type[Builder]:
|
|
return Builder
|
|
|
|
|
|
class Builder(FormationAttackBuilder[DeadFlightPlan, FormationAttackLayout]):
|
|
def layout(self) -> FormationAttackLayout:
|
|
location = self.package.target
|
|
|
|
is_ewr = isinstance(location, EwrGroundObject)
|
|
is_sam = isinstance(location, SamGroundObject)
|
|
if not is_ewr and not is_sam:
|
|
logging.exception(
|
|
f"Invalid Objective Location for DEAD flight {self.flight=} at "
|
|
f"{location=}"
|
|
)
|
|
raise InvalidObjectiveLocation(self.flight.flight_type, location)
|
|
|
|
return self._build(FlightWaypointType.INGRESS_DEAD)
|
|
|
|
def build(self) -> DeadFlightPlan:
|
|
return DeadFlightPlan(self.flight, self.layout())
|