mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
When a new flight is added to a package, if the TOT is early enough the new flight might have a startup time in the past. Clamp the TOT when adding new flights to the package to avoid this. https://github.com/dcs-liberation/dcs_liberation/issues/1680
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timedelta
|
|
from typing import TYPE_CHECKING
|
|
|
|
from dcs import Point
|
|
|
|
from .flightstate import FlightState
|
|
from ..starttype import StartType
|
|
|
|
if TYPE_CHECKING:
|
|
from game.sim.gameupdateevents import GameUpdateEvents
|
|
|
|
|
|
class Uninitialized(FlightState):
|
|
@property
|
|
def cancelable(self) -> bool:
|
|
return True
|
|
|
|
def on_game_tick(
|
|
self, events: GameUpdateEvents, time: datetime, duration: timedelta
|
|
) -> None:
|
|
self.reinitialize(time)
|
|
self.flight.state.on_game_tick(events, time, duration)
|
|
|
|
@property
|
|
def is_waiting_for_start(self) -> bool:
|
|
return True
|
|
|
|
def estimate_position(self) -> Point:
|
|
raise RuntimeError("Attempted to simulate flight that is not fully initialized")
|
|
|
|
@property
|
|
def spawn_type(self) -> StartType:
|
|
raise RuntimeError("Attempted to simulate flight that is not fully initialized")
|
|
|
|
@property
|
|
def description(self) -> str:
|
|
if self.flight.start_type is StartType.COLD:
|
|
action = "Starting up"
|
|
elif self.flight.start_type is StartType.WARM:
|
|
action = "Taxiing"
|
|
elif self.flight.start_type is StartType.RUNWAY:
|
|
action = "Taking off"
|
|
elif self.flight.start_type is StartType.IN_FLIGHT:
|
|
action = "In flight"
|
|
else:
|
|
raise ValueError(f"Unhandled StartType: {self.flight.start_type}")
|
|
return f"{action} at {self.flight.flight_plan.startup_time():%H:%M:%S}"
|