Make ASAP a checkbox and maintain ASAP on changes.

Fixes https://github.com/Khopa/dcs_liberation/issues/642
This commit is contained in:
Dan Albert
2021-01-30 13:33:39 -08:00
parent 768d239840
commit 5047b535c4
12 changed files with 92 additions and 62 deletions

View File

@@ -20,6 +20,7 @@ from game.theater.missiontarget import MissionTarget
from game.utils import Speed
from .flights.flight import Flight, FlightType
from .flights.flightplan import FormationFlightPlan
from .flights.traveltime import TotEstimator
@dataclass(frozen=True)
@@ -54,6 +55,11 @@ class Package:
delay: int = field(default=0)
#: True if the package ToT should be reset to ASAP whenever the player makes
#: a change. This is really a UI property rather than a game property, but
#: we want it to persist in the save.
auto_asap: bool = field(default=False)
#: Desired TOT as an offset from mission start.
time_over_target: timedelta = field(default=timedelta())
@@ -127,6 +133,9 @@ class Package:
return max(times)
return None
def set_tot_asap(self) -> None:
self.time_over_target = TotEstimator(self).earliest_tot()
def add_flight(self, flight: Flight) -> None:
"""Adds a flight to the package."""
self.flights.append(flight)