mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove useless TravelTime class.
This is only called for real in one spot. The other callers should have been deferring to the one real caller.
This commit is contained in:
parent
dcaee350cf
commit
14d3e743d4
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user