diff --git a/game/ato/flightplans/escort.py b/game/ato/flightplans/escort.py index 1879c14a..f7066d51 100644 --- a/game/ato/flightplans/escort.py +++ b/game/ato/flightplans/escort.py @@ -12,7 +12,6 @@ from .formationattack import ( ) from .waypointbuilder import WaypointBuilder from .. import FlightType -from ..traveltime import TravelTime, GroundSpeed from ...utils import feet @@ -20,10 +19,9 @@ class EscortFlightPlan(FormationAttackFlightPlan): @property def push_time(self) -> timedelta: hold2join_time = ( - TravelTime.between_points( - self.layout.hold.position, - self.layout.join.position, - GroundSpeed.for_flight(self.flight, self.layout.hold.alt), + self.travel_time_between_waypoints( + self.layout.hold, + self.layout.join, ) if self.layout.hold is not None else timedelta(0) diff --git a/game/ato/flightplans/flightplan.py b/game/ato/flightplans/flightplan.py index 1578d9b0..a3519937 100644 --- a/game/ato/flightplans/flightplan.py +++ b/game/ato/flightplans/flightplan.py @@ -20,7 +20,7 @@ from game.utils import Distance, Speed, meters from .planningerror import PlanningError from ..flightwaypointtype import FlightWaypointType from ..starttype import StartType -from ..traveltime import GroundSpeed, TravelTime +from ..traveltime import GroundSpeed if TYPE_CHECKING: from game.dcs.aircrafttype import FuelConsumption @@ -244,9 +244,10 @@ class FlightPlan(ABC, Generic[LayoutT]): def travel_time_between_waypoints( self, a: FlightWaypoint, b: FlightWaypoint ) -> timedelta: - return TravelTime.between_points( - a.position, b.position, self.speed_between_waypoints(a, b) - ) + error_factor = 1.05 + speed = self.speed_between_waypoints(a, b) + distance = meters(a.position.distance_to_point(b.position)) + return timedelta(hours=distance.nautical_miles / speed.knots * error_factor) def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None: raise NotImplementedError diff --git a/game/ato/flightplans/formation.py b/game/ato/flightplans/formation.py index 0aa4e338..52af636f 100644 --- a/game/ato/flightplans/formation.py +++ b/game/ato/flightplans/formation.py @@ -10,7 +10,6 @@ from game.typeguard import self_type_guard from game.utils import Speed from .flightplan import FlightPlan from .loiter import LoiterFlightPlan, LoiterLayout -from ..traveltime import GroundSpeed, TravelTime if TYPE_CHECKING: from ..flightwaypoint import FlightWaypoint @@ -93,10 +92,8 @@ class FormationFlightPlan(LoiterFlightPlan, ABC): @property def push_time(self) -> timedelta: - return self.join_time - TravelTime.between_points( - self.layout.hold.position, - self.layout.join.position, - GroundSpeed.for_flight(self.flight, self.layout.hold.alt), + return self.join_time - self.travel_time_between_waypoints( + self.layout.hold, self.layout.join ) @property diff --git a/game/ato/flightplans/sweep.py b/game/ato/flightplans/sweep.py index e332dbc0..9778ecb9 100644 --- a/game/ato/flightplans/sweep.py +++ b/game/ato/flightplans/sweep.py @@ -10,7 +10,6 @@ from game.utils import Heading from .ibuilder import IBuilder from .loiter import LoiterFlightPlan, LoiterLayout from .waypointbuilder import WaypointBuilder -from ..traveltime import GroundSpeed, TravelTime from ...flightplan import HoldZoneGeometry if TYPE_CHECKING: @@ -79,10 +78,8 @@ class SweepFlightPlan(LoiterFlightPlan): @property def push_time(self) -> timedelta: - return self.sweep_end_time - TravelTime.between_points( - self.layout.hold.position, - self.layout.sweep_end.position, - GroundSpeed.for_flight(self.flight, self.layout.hold.alt), + return self.sweep_end_time - self.travel_time_between_waypoints( + self.layout.hold, self.layout.sweep_end ) @property diff --git a/game/ato/traveltime.py b/game/ato/traveltime.py index 6f984904..04476dea 100644 --- a/game/ato/traveltime.py +++ b/game/ato/traveltime.py @@ -4,15 +4,7 @@ import math from datetime import timedelta from typing import TYPE_CHECKING -from dcs.mapping import Point - -from game.utils import ( - Distance, - SPEED_OF_SOUND_AT_SEA_LEVEL, - Speed, - mach, - meters, -) +from game.utils import Distance, SPEED_OF_SOUND_AT_SEA_LEVEL, Speed, mach, meters if TYPE_CHECKING: from .flight import Flight @@ -43,14 +35,6 @@ class GroundSpeed: return mach(cruise_mach, altitude if not flight.is_helo else meters(0)) -class TravelTime: - @staticmethod - def between_points(a: Point, b: Point, speed: Speed) -> timedelta: - error_factor = 1.05 - distance = meters(a.distance_to_point(b)) - return timedelta(hours=distance.nautical_miles / speed.knots * error_factor) - - # TODO: Most if not all of this should move into FlightPlan. class TotEstimator: def __init__(self, package: Package) -> None: