mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Rather than polling at 60Hz (which may be faster than the tick rate, wasting cycles; and also makes synchronization annoying), collect events during the tick and emit them after (rate limited, pooling events until it is time for another event to send). This can be improved by paying attention to the aircraft update list, which would allow us to avoid updating aircraft that don't have a status change. To do that we need to be able to quickly lookup a FlightJs matching a Flight through, and Flight isn't hashable. We should also be removing dead events and de-duplicating. Currently each flight has an update for every tick, but only the latest one matters. Combat update events also don't matter if the same combat is new in the update. https://github.com/dcs-liberation/dcs_liberation/issues/1680
28 lines
799 B
Python
28 lines
799 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from game.ato import Flight
|
|
from game.sim.combat import FrozenCombat
|
|
|
|
|
|
class GameUpdateEvents:
|
|
def __init__(self) -> None:
|
|
self.simulation_complete = False
|
|
self.new_combats: list[FrozenCombat] = []
|
|
self.updated_combats: list[FrozenCombat] = []
|
|
self.updated_flights: list[Flight] = []
|
|
|
|
def complete_simulation(self) -> None:
|
|
self.simulation_complete = True
|
|
|
|
def new_combat(self, combat: FrozenCombat) -> None:
|
|
self.new_combats.append(combat)
|
|
|
|
def update_combat(self, combat: FrozenCombat) -> None:
|
|
self.updated_combats.append(combat)
|
|
|
|
def update_flight(self, flight: Flight) -> None:
|
|
self.updated_flights.append(flight)
|