mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Revert use of ABC in FlightPlan.
Mypy can't handle ABC dataclasses: https://github.com/python/mypy/issues/5374
This commit is contained in:
parent
1944a172a3
commit
8fe805bc68
@ -10,7 +10,6 @@ from __future__ import annotations
|
||||
import logging
|
||||
import math
|
||||
import random
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import timedelta
|
||||
from functools import cached_property
|
||||
@ -76,7 +75,7 @@ class InvalidObjectiveLocation(PlanningError):
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FlightPlan(ABC):
|
||||
class FlightPlan:
|
||||
package: Package
|
||||
flight: Flight
|
||||
|
||||
@ -85,10 +84,9 @@ class FlightPlan(ABC):
|
||||
"""A list of all waypoints in the flight plan, in order."""
|
||||
return list(self.iter_waypoints())
|
||||
|
||||
@abstractmethod
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
"""Iterates over all waypoints in the flight plan, in order."""
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
def edges(
|
||||
self, until: Optional[FlightWaypoint] = None
|
||||
@ -153,7 +151,6 @@ class FlightPlan(ABC):
|
||||
return self.flight.unit_type.fuel_consumption.cruise
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||
"""The waypoint that is associated with the package TOT, or None.
|
||||
|
||||
@ -161,7 +158,7 @@ class FlightPlan(ABC):
|
||||
user-planned missions without any useful waypoints and flight plans that
|
||||
failed to generate. Nevertheless, we have to defend against it.
|
||||
"""
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def tot(self) -> timedelta:
|
||||
@ -239,13 +236,11 @@ class FlightPlan(ABC):
|
||||
a.position, b.position, self.speed_between_waypoints(a, b)
|
||||
)
|
||||
|
||||
@abstractmethod
|
||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
||||
return None
|
||||
@ -321,10 +316,9 @@ class FlightPlan(ABC):
|
||||
return timedelta(minutes=8)
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def mission_departure_time(self) -> timedelta:
|
||||
"""The time that the mission is complete and the flight RTBs."""
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -332,23 +326,19 @@ class LoiterFlightPlan(FlightPlan):
|
||||
hold: FlightWaypoint
|
||||
hold_duration: timedelta
|
||||
|
||||
@abstractmethod
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def push_time(self) -> timedelta:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||
if waypoint == self.hold:
|
||||
@ -364,9 +354,8 @@ class LoiterFlightPlan(FlightPlan):
|
||||
return travel_time + self.hold_duration
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def mission_departure_time(self) -> timedelta:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -374,23 +363,20 @@ class FormationFlightPlan(LoiterFlightPlan):
|
||||
join: FlightWaypoint
|
||||
split: FlightWaypoint
|
||||
|
||||
@abstractmethod
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||
return self.package_speed_waypoints
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
||||
return self.join
|
||||
@ -429,14 +415,12 @@ class FormationFlightPlan(LoiterFlightPlan):
|
||||
return self._travel_time_to_waypoint(self.join)
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def join_time(self) -> timedelta:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def split_time(self) -> timedelta:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||
if waypoint == self.join:
|
||||
@ -498,9 +482,8 @@ class PatrollingFlightPlan(FlightPlan):
|
||||
return self.patrol_end_time
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||
...
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def package_speed_waypoints(self) -> Set[FlightWaypoint]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user