mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add frozen combat modelling.
This doesn't do anything yet, but sets up the data model handling for frozen combat. The next step is to show combat in the map view, since that will be helpful when debugging the step after that one: resolving frozen combat. This would benefit from caching the Shapely data for SAM threat zones. Right now it's generating them once per tick and the stuttering is visible at max speed. https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
@@ -8,7 +8,7 @@ from typing_extensions import TYPE_CHECKING
|
||||
|
||||
from game.ato import Flight
|
||||
from game.ato.flightstate import (
|
||||
InFlight,
|
||||
Navigating,
|
||||
StartUp,
|
||||
Takeoff,
|
||||
Taxi,
|
||||
@@ -16,8 +16,8 @@ from game.ato.flightstate import (
|
||||
WaitingForStart,
|
||||
)
|
||||
from game.ato.starttype import StartType
|
||||
from game.sim.aircraftengagementzones import AircraftEngagementZones
|
||||
from gen.flights.traveltime import TotEstimator
|
||||
from .combat import CombatInitiator, FrozenCombat
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game import Game
|
||||
@@ -26,6 +26,7 @@ if TYPE_CHECKING:
|
||||
class AircraftSimulation:
|
||||
def __init__(self, game: Game) -> None:
|
||||
self.game = game
|
||||
self.combats: list[FrozenCombat] = []
|
||||
|
||||
def begin_simulation(self) -> None:
|
||||
self.reset()
|
||||
@@ -35,12 +36,9 @@ class AircraftSimulation:
|
||||
for flight in self.iter_flights():
|
||||
flight.on_game_tick(time, duration)
|
||||
|
||||
# Finish updating all flights before computing engagement zones so that the new
|
||||
# Finish updating all flights before checking for combat so that the new
|
||||
# positions are used.
|
||||
blue_a2a = AircraftEngagementZones.from_ato(self.game.blue.ato)
|
||||
red_a2a = AircraftEngagementZones.from_ato(self.game.red.ato)
|
||||
for flight in self.iter_flights():
|
||||
flight.check_for_combat(red_a2a if flight.squadron.player else blue_a2a)
|
||||
CombatInitiator(self.game, self.combats).update_active_combats()
|
||||
|
||||
# After updating all combat states, check for halts.
|
||||
for flight in self.iter_flights():
|
||||
@@ -68,7 +66,7 @@ class AircraftSimulation:
|
||||
elif flight.start_type is StartType.RUNWAY:
|
||||
flight.set_state(Takeoff(flight, self.game.settings, now))
|
||||
elif flight.start_type is StartType.IN_FLIGHT:
|
||||
flight.set_state(InFlight(flight, self.game.settings, waypoint_index=0))
|
||||
flight.set_state(Navigating(flight, self.game.settings, waypoint_index=0))
|
||||
else:
|
||||
raise ValueError(f"Unknown start type {flight.start_type} for {flight}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user