Push full navmesh/threatzone info in the event stream.

https://github.com/dcs-liberation/dcs_liberation/issues/2253
https://github.com/dcs-liberation/dcs_liberation/issues/2263
This commit is contained in:
Raffson
2022-07-06 22:27:06 +02:00
committed by GitHub
parent a20b95bb26
commit 9823f7b96f
6 changed files with 59 additions and 41 deletions

View File

@@ -11,6 +11,8 @@ from game.server.flights.models import FlightJs
from game.server.frontlines.models import FrontLineJs
from game.server.iadsnetwork.models import IadsConnectionJs
from game.server.leaflet import LeafletPoint
from game.server.mapzones.models import ThreatZonesJs
from game.server.navmesh.models import NavMeshJs
from game.server.tgos.models import TgoJs
from game.server.mapzones.models import UnculledZoneJs
@@ -24,9 +26,9 @@ class GameUpdateEventsJs(BaseModel):
new_combats: list[FrozenCombatJs]
updated_combats: list[FrozenCombatJs]
ended_combats: list[UUID]
navmesh_updates: set[bool]
navmesh_updates: dict[bool, NavMeshJs]
updated_unculled_zones: list[UnculledZoneJs]
threat_zones_updated: bool
threat_zones_updated: dict[bool, ThreatZonesJs]
new_flights: list[FlightJs]
updated_flights: list[FlightJs]
deleted_flights: set[UUID]
@@ -51,6 +53,8 @@ class GameUpdateEventsJs(BaseModel):
# because we need to send the unload event.
new_combats = []
updated_combats = []
updated_navmeshes = {}
updated_threat_zones = {}
updated_unculled_zones = []
updated_iads = []
if game is not None:
@@ -61,6 +65,14 @@ class GameUpdateEventsJs(BaseModel):
FrozenCombatJs.for_combat(c, game.theater)
for c in events.updated_combats
]
updated_navmeshes = {
player: NavMeshJs.from_navmesh(mesh, game)
for player, mesh in events.navmesh_updates.items()
}
updated_threat_zones = {
player: ThreatZonesJs.from_zones(zones, game.theater)
for player, zones in events.threat_zones_updated.items()
}
updated_unculled_zones = UnculledZoneJs.from_game(game)
for node in events.updated_iads:
updated_iads.extend(IadsConnectionJs.connections_for_node(node))
@@ -72,9 +84,9 @@ class GameUpdateEventsJs(BaseModel):
new_combats=new_combats,
updated_combats=updated_combats,
ended_combats=[c.id for c in events.ended_combats],
navmesh_updates=events.navmesh_updates,
navmesh_updates=updated_navmeshes,
updated_unculled_zones=updated_unculled_zones,
threat_zones_updated=events.threat_zones_updated,
threat_zones_updated=updated_threat_zones,
new_flights=[
FlightJs.for_flight(f, with_waypoints=True) for f in events.new_flights
],