mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Show the status of each flight in the UI.
https://github.com/dcs-liberation/dcs_liberation/issues/1704
This commit is contained in:
@@ -16,3 +16,7 @@ class Completed(FlightState):
|
||||
def spawn_type(self) -> StartType:
|
||||
# TODO: May want to do something different to make these uncontrolled?
|
||||
return StartType.COLD
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Completed"
|
||||
|
||||
@@ -43,3 +43,9 @@ class FlightState(ABC):
|
||||
if (max_takeoff_fuel := self.flight.max_takeoff_fuel()) is not None:
|
||||
return max_takeoff_fuel
|
||||
return self.flight.unit_type.dcs_unit_type.fuel_max
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def description(self) -> str:
|
||||
"""Describes the current flight state."""
|
||||
...
|
||||
|
||||
@@ -170,3 +170,7 @@ class InFlight(FlightState):
|
||||
@property
|
||||
def spawn_type(self) -> StartType:
|
||||
return StartType.IN_FLIGHT
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return f"Flying to {self.next_waypoint.name}"
|
||||
|
||||
@@ -40,3 +40,7 @@ class Loiter(InFlight):
|
||||
|
||||
def travel_time_between_waypoints(self) -> timedelta:
|
||||
return self.hold_duration
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return f"Loitering for {self.hold_duration - self.elapsed_time}"
|
||||
|
||||
@@ -51,3 +51,7 @@ class RaceTrack(InFlight):
|
||||
if self.flight.flight_type in {FlightType.BARCAP, FlightType.TARCAP}:
|
||||
return self.commit_region
|
||||
return None
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return f"Patrolling for {self.patrol_duration - self.elapsed_time}"
|
||||
|
||||
@@ -43,3 +43,7 @@ class StartUp(FlightState):
|
||||
)
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Starting up"
|
||||
|
||||
@@ -51,3 +51,7 @@ class Takeoff(FlightState):
|
||||
)
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Taking off"
|
||||
|
||||
@@ -43,3 +43,7 @@ class Taxi(FlightState):
|
||||
)
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Taxiing"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from gen.flights.traveltime import TotEstimator
|
||||
from .flightstate import FlightState
|
||||
from ..starttype import StartType
|
||||
|
||||
@@ -15,3 +16,9 @@ class Uninitialized(FlightState):
|
||||
@property
|
||||
def spawn_type(self) -> StartType:
|
||||
raise RuntimeError("Attempted to simulate flight that is not fully initialized")
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
estimator = TotEstimator(self.flight.package)
|
||||
delay = estimator.mission_start_time(self.flight)
|
||||
return f"Starting in {delay}"
|
||||
|
||||
@@ -54,3 +54,7 @@ class WaitingForStart(FlightState):
|
||||
@property
|
||||
def spawn_type(self) -> StartType:
|
||||
return self.flight.start_type
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return f"Waiting for startup at {self.start_time:%H:%M:%S}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Callable, TYPE_CHECKING
|
||||
|
||||
@@ -27,6 +27,10 @@ class GameLoop:
|
||||
def current_time_in_sim(self) -> datetime:
|
||||
return self.sim.time
|
||||
|
||||
@property
|
||||
def elapsed_time(self) -> timedelta:
|
||||
return self.sim.time - self.game.conditions.start_time
|
||||
|
||||
def start(self) -> None:
|
||||
if self.started:
|
||||
raise RuntimeError("Cannot start game loop because it has already started")
|
||||
|
||||
Reference in New Issue
Block a user