mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
During package planning we don't care about the details of the flight plan, just the layout (to check if the layout is threatened and we need escorts). Splitting these will allow us to reduce the amount of work that must be done in each loop of the planning phase, potentially caching attempted flight plans between loops.
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass
|
|
from datetime import timedelta
|
|
from typing import Any, TYPE_CHECKING, TypeGuard
|
|
|
|
from game.typeguard import self_type_guard
|
|
from .flightplan import FlightPlan
|
|
from .standard import StandardFlightPlan, StandardLayout
|
|
|
|
if TYPE_CHECKING:
|
|
from ..flightwaypoint import FlightWaypoint
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class LoiterLayout(StandardLayout, ABC):
|
|
hold: FlightWaypoint
|
|
|
|
|
|
class LoiterFlightPlan(StandardFlightPlan[Any], ABC):
|
|
@property
|
|
def hold_duration(self) -> timedelta:
|
|
return timedelta(minutes=5)
|
|
|
|
@property
|
|
@abstractmethod
|
|
def push_time(self) -> timedelta:
|
|
...
|
|
|
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
|
|
if waypoint == self.layout.hold:
|
|
return self.push_time
|
|
return None
|
|
|
|
def travel_time_between_waypoints(
|
|
self, a: FlightWaypoint, b: FlightWaypoint
|
|
) -> timedelta:
|
|
travel_time = super().travel_time_between_waypoints(a, b)
|
|
if a != self.layout.hold:
|
|
return travel_time
|
|
return travel_time + self.hold_duration
|
|
|
|
@self_type_guard
|
|
def is_loiter(self, flight_plan: FlightPlan[Any]) -> TypeGuard[LoiterFlightPlan]:
|
|
return True
|