mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
This is the first step in a larger project to add play/pause buttons to the Liberation UI so the mission can be generated at any point. docs/design/turnless.md describes the plan. This adds an option to fast forward the turn to first contact before generating the mission. None of that is reflected in the UI (for now), but the miz will be generated with many flights in the air. For now "first contact" means as soon as any flight reaches its IP. I'll follow up to add threat checking so that air-to-air combat also triggers this, as will entering a SAM's threat zone. This also includes an option to halt fast-forward whenever a player flight reaches a certain mission-prep phase. This can be used to avoid fast forwarding past the player's startup time, taxi time, or takeoff time. By default this option is disabled so player aircraft may start in the air (possibly even at their IP if they're the first mission to reach IP). Fuel states do not currently account for distance traveled during fast forward. That will come later. https://github.com/dcs-liberation/dcs_liberation/issues/1681
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timedelta
|
|
from typing import TYPE_CHECKING
|
|
|
|
from game.ato.starttype import StartType
|
|
from .flightstate import FlightState
|
|
from .inflight import InFlight
|
|
from .startup import StartUp
|
|
from .takeoff import Takeoff
|
|
from .taxi import Taxi
|
|
|
|
if TYPE_CHECKING:
|
|
from game.ato.flight import Flight
|
|
from game.settings import Settings
|
|
|
|
|
|
class WaitingForStart(FlightState):
|
|
def __init__(
|
|
self,
|
|
flight: Flight,
|
|
settings: Settings,
|
|
start_time: datetime,
|
|
) -> None:
|
|
super().__init__(flight, settings)
|
|
self.start_time = start_time
|
|
|
|
@property
|
|
def start_type(self) -> StartType:
|
|
return self.flight.start_type
|
|
|
|
def on_game_tick(self, time: datetime, duration: timedelta) -> None:
|
|
if time < self.start_time:
|
|
return
|
|
|
|
new_state: FlightState
|
|
if self.start_type is StartType.COLD:
|
|
new_state = StartUp(self.flight, self.settings, time)
|
|
elif self.start_type is StartType.WARM:
|
|
new_state = Taxi(self.flight, self.settings, time)
|
|
elif self.start_type is StartType.RUNWAY:
|
|
new_state = Takeoff(self.flight, self.settings, time)
|
|
else:
|
|
new_state = InFlight(self.flight, self.settings)
|
|
self.flight.set_state(new_state)
|
|
|
|
@property
|
|
def is_waiting_for_start(self) -> bool:
|
|
return True
|
|
|
|
def time_remaining(self, time: datetime) -> timedelta:
|
|
return self.start_time - time
|
|
|
|
@property
|
|
def spawn_type(self) -> StartType:
|
|
return self.flight.start_type
|