mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Save the TOT offset in the flight plan.
Prep work for exposing this to the UI.
This commit is contained in:
parent
5d127744ff
commit
7a57bd3ee0
@ -21,6 +21,7 @@ from .planningerror import PlanningError
|
|||||||
from ..flightwaypointtype import FlightWaypointType
|
from ..flightwaypointtype import FlightWaypointType
|
||||||
from ..starttype import StartType
|
from ..starttype import StartType
|
||||||
from ..traveltime import GroundSpeed, TravelTime
|
from ..traveltime import GroundSpeed, TravelTime
|
||||||
|
from ...savecompat import has_save_compat_for
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game.dcs.aircrafttype import FuelConsumption
|
from game.dcs.aircrafttype import FuelConsumption
|
||||||
@ -65,6 +66,13 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
|||||||
def __init__(self, flight: Flight, layout: LayoutT) -> None:
|
def __init__(self, flight: Flight, layout: LayoutT) -> None:
|
||||||
self.flight = flight
|
self.flight = flight
|
||||||
self.layout = layout
|
self.layout = layout
|
||||||
|
self.tot_offset = self.default_tot_offset()
|
||||||
|
|
||||||
|
@has_save_compat_for(7)
|
||||||
|
def __setstate__(self, state: dict[str, Any]) -> None:
|
||||||
|
if "tot_offset" not in state:
|
||||||
|
state["tot_offset"] = self.default_tot_offset()
|
||||||
|
self.__dict__.update(state)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def package(self) -> Package:
|
def package(self) -> Package:
|
||||||
@ -207,8 +215,7 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
|||||||
[meters(cp.position.distance_to_point(w.position)) for w in self.waypoints]
|
[meters(cp.position.distance_to_point(w.position)) for w in self.waypoints]
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
def default_tot_offset(self) -> timedelta:
|
||||||
def tot_offset(self) -> timedelta:
|
|
||||||
"""This flight's offset from the package's TOT.
|
"""This flight's offset from the package's TOT.
|
||||||
|
|
||||||
Positive values represent later TOTs. An offset of -2 minutes is used
|
Positive values represent later TOTs. An offset of -2 minutes is used
|
||||||
|
|||||||
@ -25,10 +25,6 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class FormationAttackFlightPlan(FormationFlightPlan, ABC):
|
class FormationAttackFlightPlan(FormationFlightPlan, ABC):
|
||||||
@property
|
|
||||||
def lead_time(self) -> timedelta:
|
|
||||||
return timedelta()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||||
return {
|
return {
|
||||||
@ -50,13 +46,6 @@ class FormationAttackFlightPlan(FormationFlightPlan, ABC):
|
|||||||
def tot_waypoint(self) -> FlightWaypoint:
|
def tot_waypoint(self) -> FlightWaypoint:
|
||||||
return self.layout.targets[0]
|
return self.layout.targets[0]
|
||||||
|
|
||||||
@property
|
|
||||||
def tot_offset(self) -> timedelta:
|
|
||||||
try:
|
|
||||||
return -self.lead_time
|
|
||||||
except AttributeError:
|
|
||||||
return timedelta()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_area_waypoint(self) -> FlightWaypoint:
|
def target_area_waypoint(self) -> FlightWaypoint:
|
||||||
return FlightWaypoint(
|
return FlightWaypoint(
|
||||||
|
|||||||
@ -16,9 +16,8 @@ class SeadFlightPlan(FormationAttackFlightPlan):
|
|||||||
def builder_type() -> Type[Builder]:
|
def builder_type() -> Type[Builder]:
|
||||||
return Builder
|
return Builder
|
||||||
|
|
||||||
@property
|
def default_tot_offset(self) -> timedelta:
|
||||||
def lead_time(self) -> timedelta:
|
return -timedelta(minutes=1)
|
||||||
return timedelta(minutes=1)
|
|
||||||
|
|
||||||
|
|
||||||
class Builder(FormationAttackBuilder[SeadFlightPlan, FormationAttackLayout]):
|
class Builder(FormationAttackBuilder[SeadFlightPlan, FormationAttackLayout]):
|
||||||
|
|||||||
@ -38,10 +38,6 @@ class SweepLayout(LoiterLayout):
|
|||||||
|
|
||||||
|
|
||||||
class SweepFlightPlan(LoiterFlightPlan):
|
class SweepFlightPlan(LoiterFlightPlan):
|
||||||
@property
|
|
||||||
def lead_time(self) -> timedelta:
|
|
||||||
return timedelta(minutes=5)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def builder_type() -> Type[Builder]:
|
def builder_type() -> Type[Builder]:
|
||||||
return Builder
|
return Builder
|
||||||
@ -54,9 +50,8 @@ class SweepFlightPlan(LoiterFlightPlan):
|
|||||||
def tot_waypoint(self) -> FlightWaypoint:
|
def tot_waypoint(self) -> FlightWaypoint:
|
||||||
return self.layout.sweep_end
|
return self.layout.sweep_end
|
||||||
|
|
||||||
@property
|
def default_tot_offset(self) -> timedelta:
|
||||||
def tot_offset(self) -> timedelta:
|
return -timedelta(minutes=5)
|
||||||
return -self.lead_time
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sweep_start_time(self) -> timedelta:
|
def sweep_start_time(self) -> timedelta:
|
||||||
|
|||||||
@ -34,10 +34,6 @@ class TarCapLayout(PatrollingLayout):
|
|||||||
|
|
||||||
|
|
||||||
class TarCapFlightPlan(PatrollingFlightPlan[TarCapLayout]):
|
class TarCapFlightPlan(PatrollingFlightPlan[TarCapLayout]):
|
||||||
@property
|
|
||||||
def lead_time(self) -> timedelta:
|
|
||||||
return timedelta(minutes=2)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def patrol_duration(self) -> timedelta:
|
def patrol_duration(self) -> timedelta:
|
||||||
# Note that this duration only has an effect if there are no
|
# Note that this duration only has an effect if there are no
|
||||||
@ -64,9 +60,8 @@ class TarCapFlightPlan(PatrollingFlightPlan[TarCapLayout]):
|
|||||||
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||||
return {self.layout.patrol_start, self.layout.patrol_end}
|
return {self.layout.patrol_start, self.layout.patrol_end}
|
||||||
|
|
||||||
@property
|
def default_tot_offset(self) -> timedelta:
|
||||||
def tot_offset(self) -> timedelta:
|
return -timedelta(minutes=2)
|
||||||
return -self.lead_time
|
|
||||||
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
|
||||||
if waypoint == self.layout.patrol_end:
|
if waypoint == self.layout.patrol_end:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user