mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
There are some TODOs here but th behavior is flagged off by default. The biggest TODO here is that the time spent frozen is not simulated, so flights that are engaged by SAMs will unfreeze, move slightly, then re- freeze. https://github.com/dcs-liberation/dcs_liberation/issues/1680
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from abc import ABC, abstractmethod
|
|
from collections.abc import Iterator
|
|
from datetime import timedelta
|
|
from typing import TYPE_CHECKING
|
|
|
|
from game.ato.flightstate import InCombat, InFlight
|
|
|
|
if TYPE_CHECKING:
|
|
from game.ato import Flight
|
|
from ..simulationresults import SimulationResults
|
|
|
|
|
|
class FrozenCombat(ABC):
|
|
def __init__(self, freeze_duration: timedelta) -> None:
|
|
self.id = uuid.uuid4()
|
|
self.freeze_duration = freeze_duration
|
|
self.elapsed_time = timedelta()
|
|
|
|
def on_game_tick(self, duration: timedelta, results: SimulationResults) -> bool:
|
|
self.elapsed_time += duration
|
|
if self.elapsed_time >= self.freeze_duration:
|
|
self.resolve(results)
|
|
return True
|
|
return False
|
|
|
|
@abstractmethod
|
|
def resolve(self, results: SimulationResults) -> None:
|
|
...
|
|
|
|
@abstractmethod
|
|
def because(self) -> str:
|
|
...
|
|
|
|
@abstractmethod
|
|
def describe(self) -> str:
|
|
...
|
|
|
|
@abstractmethod
|
|
def iter_flights(self) -> Iterator[Flight]:
|
|
...
|
|
|
|
def update_flight_states(self) -> None:
|
|
for flight in self.iter_flights():
|
|
if not isinstance(flight.state, InFlight):
|
|
raise RuntimeError(
|
|
f"Found non in-flight aircraft engaged in combat: {flight}"
|
|
)
|
|
flight.set_state(InCombat(flight.state, self))
|