mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Support display of dead flights.
This commit is contained in:
@@ -10,6 +10,7 @@ from dcs.planes import C_101CC, C_101EB, Su_33
|
||||
from game.savecompat import has_save_compat_for
|
||||
from .flightroster import FlightRoster
|
||||
from .flightstate import FlightState, Uninitialized
|
||||
from .flightstate.killed import Killed
|
||||
from .loadouts import Loadout
|
||||
from ..sidc import (
|
||||
AirEntity,
|
||||
@@ -117,7 +118,7 @@ class Flight(SidcDescribable):
|
||||
|
||||
@property
|
||||
def sidc_status(self) -> Status:
|
||||
return Status.PRESENT
|
||||
return Status.PRESENT if self.alive else Status.PRESENT_DESTROYED
|
||||
|
||||
@property
|
||||
def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]:
|
||||
@@ -202,7 +203,11 @@ class Flight(SidcDescribable):
|
||||
def should_halt_sim(self) -> bool:
|
||||
return self.state.should_halt_sim()
|
||||
|
||||
def kill(self, results: SimulationResults) -> None:
|
||||
@property
|
||||
def alive(self) -> bool:
|
||||
return self.state.alive
|
||||
|
||||
def kill(self, results: SimulationResults, events: GameUpdateEvents) -> None:
|
||||
# This is a bit messy while we're in transition from turn-based to turnless
|
||||
# because we want the simulation to have minimal impact on the save game while
|
||||
# turns exist so that loading a game is essentially a way to reset the
|
||||
@@ -211,17 +216,17 @@ class Flight(SidcDescribable):
|
||||
# the UI to reflect that aircraft were lost and avoid generating those flights
|
||||
# when the mission is generated.
|
||||
#
|
||||
# For now we do this by removing the flight from the ATO and logging the kill in
|
||||
# the SimulationResults, which is similar to the Debriefing. If a flight is
|
||||
# killed and the player saves and reloads, those pilots/aircraft will be
|
||||
# unusable until the next turn, but otherwise will survive.
|
||||
#
|
||||
# This is going to be extremely temporary since the solution for other killable
|
||||
# game objects (killed SAMs, sinking carriers, bombed out runways) will not be
|
||||
# so easily worked around.
|
||||
# For now we do this by logging the kill in the SimulationResults, which is
|
||||
# similar to the Debriefing. We also set the flight's state to Killed, which
|
||||
# will prevent it from being spawned in the mission and updates the SIDC.
|
||||
# This does leave an opportunity for players to cheat since the UI won't stop
|
||||
# them from cancelling a dead flight, returning the aircraft to the pool. Not a
|
||||
# big deal for now.
|
||||
# TODO: Support partial kills.
|
||||
# TODO: Remove empty packages from the ATO?
|
||||
self.package.remove_flight(self)
|
||||
self.set_state(
|
||||
Killed(self.state.estimate_position(), self, self.squadron.settings)
|
||||
)
|
||||
events.update_flight(self)
|
||||
for pilot in self.roster.pilots:
|
||||
if pilot is not None:
|
||||
results.kill_pilot(self, pilot)
|
||||
|
||||
@@ -20,6 +20,10 @@ class FlightState(ABC):
|
||||
self.flight = flight
|
||||
self.settings = settings
|
||||
|
||||
@property
|
||||
def alive(self) -> bool:
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def on_game_tick(
|
||||
self, events: GameUpdateEvents, time: datetime, duration: timedelta
|
||||
|
||||
@@ -5,14 +5,26 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from dcs import Point
|
||||
|
||||
from game.settings import Settings
|
||||
from .flightstate import FlightState
|
||||
from ..starttype import StartType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Flight
|
||||
from game.sim.gameupdateevents import GameUpdateEvents
|
||||
|
||||
|
||||
class Completed(FlightState):
|
||||
class Killed(FlightState):
|
||||
def __init__(
|
||||
self, last_position: Point, flight: Flight, settings: Settings
|
||||
) -> None:
|
||||
super().__init__(flight, settings)
|
||||
self.last_position = last_position
|
||||
|
||||
@property
|
||||
def alive(self) -> bool:
|
||||
return False
|
||||
|
||||
def on_game_tick(
|
||||
self, events: GameUpdateEvents, time: datetime, duration: timedelta
|
||||
) -> None:
|
||||
@@ -23,12 +35,11 @@ class Completed(FlightState):
|
||||
return False
|
||||
|
||||
def estimate_position(self) -> Point:
|
||||
return self.flight.arrival.position
|
||||
return self.last_position
|
||||
|
||||
@property
|
||||
def spawn_type(self) -> StartType:
|
||||
# TODO: May want to do something different to make these uncontrolled?
|
||||
return StartType.COLD
|
||||
raise RuntimeError("Attempted to spawn a dead flight")
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user