mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Simplify flight startup time calls.
We can always estimate a startup time now. Remove the nullability from the result, cleanup the callsites, and eliminate TotEstimator.mission_start_time since it no longer does anything useful.
This commit is contained in:
@@ -253,8 +253,8 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
||||
def takeoff_time(self) -> timedelta:
|
||||
return self.tot - self._travel_time_to_waypoint(self.tot_waypoint)
|
||||
|
||||
def startup_time(self) -> timedelta | None:
|
||||
start_time: timedelta = (
|
||||
def startup_time(self) -> timedelta:
|
||||
start_time = (
|
||||
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from dcs import Point
|
||||
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from .flightstate import FlightState
|
||||
from ..starttype import StartType
|
||||
|
||||
@@ -36,8 +35,7 @@ class Uninitialized(FlightState):
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
estimator = TotEstimator(self.flight.package)
|
||||
delay = estimator.mission_start_time(self.flight)
|
||||
delay = self.flight.flight_plan.startup_time()
|
||||
if self.flight.start_type is StartType.COLD:
|
||||
action = "Starting up"
|
||||
elif self.flight.start_type is StartType.WARM:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import math
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
@@ -57,15 +56,6 @@ class TotEstimator:
|
||||
def __init__(self, package: Package) -> None:
|
||||
self.package = package
|
||||
|
||||
@staticmethod
|
||||
def mission_start_time(flight: Flight) -> timedelta:
|
||||
startup_time = flight.flight_plan.startup_time()
|
||||
if startup_time is None:
|
||||
# Could not determine takeoff time, probably due to a custom flight
|
||||
# plan. Start immediately.
|
||||
return timedelta()
|
||||
return startup_time
|
||||
|
||||
def earliest_tot(self) -> timedelta:
|
||||
if not self.package.flights:
|
||||
return timedelta(0)
|
||||
@@ -83,9 +73,9 @@ class TotEstimator:
|
||||
|
||||
@staticmethod
|
||||
def earliest_tot_for_flight(flight: Flight) -> timedelta:
|
||||
"""Estimate fastest time from mission start to the target position.
|
||||
"""Estimate the fastest time from mission start to the target position.
|
||||
|
||||
For BARCAP flights, this is time to race track start. This ensures that
|
||||
For BARCAP flights, this is time to the racetrack start. This ensures that
|
||||
they are on station at the same time any other package members reach
|
||||
their ingress point.
|
||||
|
||||
@@ -106,10 +96,4 @@ class TotEstimator:
|
||||
time = flight.flight_plan.startup_time()
|
||||
finally:
|
||||
flight.package.time_over_target = orig_tot
|
||||
|
||||
if time is None:
|
||||
logging.warning(f"Cannot estimate TOT for {flight}")
|
||||
# Return 0 so this flight's travel time does not affect the rest
|
||||
# of the package.
|
||||
return timedelta()
|
||||
return -time
|
||||
|
||||
@@ -16,7 +16,6 @@ from game.ato.flightstate import (
|
||||
WaitingForStart,
|
||||
)
|
||||
from game.ato.starttype import StartType
|
||||
from game.ato.traveltime import TotEstimator
|
||||
from .combat import CombatInitiator, FrozenCombat
|
||||
from .simulationresults import SimulationResults
|
||||
|
||||
@@ -74,8 +73,7 @@ class AircraftSimulation:
|
||||
def set_initial_flight_states(self) -> None:
|
||||
now = self.game.conditions.start_time
|
||||
for flight in self.iter_flights():
|
||||
estimator = TotEstimator(flight.package)
|
||||
start_time = estimator.mission_start_time(flight)
|
||||
start_time = flight.flight_plan.startup_time()
|
||||
if start_time <= timedelta():
|
||||
self.set_active_flight_state(flight, now)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user