Add culling exclusion zones display to the new map.

https://github.com/dcs-liberation/dcs_liberation/issues/2158
This commit is contained in:
Raffson
2022-06-15 03:57:04 +02:00
committed by GitHub
parent c5ff8777be
commit ad7032064d
12 changed files with 123 additions and 11 deletions

View File

@@ -8,7 +8,7 @@ from game.server.controlpoints.models import ControlPointJs
from game.server.flights.models import FlightJs
from game.server.frontlines.models import FrontLineJs
from game.server.leaflet import LeafletPoint
from game.server.mapzones.models import ThreatZoneContainerJs
from game.server.mapzones.models import ThreatZoneContainerJs, UnculledZoneJs
from game.server.navmesh.models import NavMeshesJs
from game.server.supplyroutes.models import SupplyRouteJs
from game.server.tgos.models import TgoJs
@@ -28,6 +28,7 @@ class GameJs(BaseModel):
threat_zones: ThreatZoneContainerJs
navmeshes: NavMeshesJs
map_center: LeafletPoint | None
unculled_zones: list[UnculledZoneJs]
class Config:
title = "Game"
@@ -44,4 +45,5 @@ class GameJs(BaseModel):
threat_zones=ThreatZoneContainerJs.for_game(game),
navmeshes=NavMeshesJs.from_game(game),
map_center=game.theater.terrain.map_view_default.position.latlng(),
unculled_zones=UnculledZoneJs.from_game(game),
)

View File

@@ -28,6 +28,16 @@ class UnculledZoneJs(BaseModel):
class Config:
title = "UnculledZone"
@staticmethod
def from_game(game: Game) -> list[UnculledZoneJs]:
return [
UnculledZoneJs(
position=zone.latlng(),
radius=game.settings.perf_culling_distance * 1000,
)
for zone in game.get_culling_zones()
]
class ThreatZonesJs(BaseModel):
full: list[LeafletPoly]

View File

@@ -27,12 +27,7 @@ def get_terrain(game: Game = Depends(GameContext.require)) -> MapZonesJs:
def get_unculled_zones(
game: Game = Depends(GameContext.require),
) -> list[UnculledZoneJs]:
return [
UnculledZoneJs(
position=zone.latlng(), radius=game.settings.perf_culling_distance * 1000
)
for zone in game.get_culling_zones()
]
return UnculledZoneJs.from_game(game)
@router.get(