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

@@ -217,7 +217,7 @@ class Game:
naming.namegen = self.name_generator
LuaPluginManager.load_settings(self.settings)
ObjectiveDistanceCache.set_theater(self.theater)
self.compute_unculled_zones()
self.compute_unculled_zones(GameUpdateEvents())
if not game_still_initializing:
# We don't need to push events that happen during load. The UI will fully
# reset when we're done.
@@ -417,7 +417,7 @@ class Game:
# Update cull zones
with logged_duration("Computing culling positions"):
self.compute_unculled_zones()
self.compute_unculled_zones(events)
def message(self, title: str, text: str = "") -> None:
self.informations.append(Information(title, text, turn=self.turn))
@@ -459,7 +459,7 @@ class Game:
def navmesh_for(self, player: bool) -> NavMesh:
return self.coalition_for(player).nav_mesh
def compute_unculled_zones(self) -> None:
def compute_unculled_zones(self, events: GameUpdateEvents) -> None:
"""
Compute the current conflict position(s) used for culling calculation
"""
@@ -514,6 +514,7 @@ class Game:
zones.append(package.target.position)
self.__culling_zones = zones
events.update_unculled_zones()
def add_destroyed_units(self, data: dict[str, Union[float, str]]) -> None:
pos = Point(

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(