mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Move NavMesh out of MapModel.
This commit is contained in:
@@ -21,7 +21,6 @@ from .flightjs import FlightJs
|
||||
from .frontlinejs import FrontLineJs
|
||||
from .groundobjectjs import GroundObjectJs
|
||||
from .mapzonesjs import MapZonesJs
|
||||
from .navmeshjs import NavMeshJs
|
||||
from .supplyroutejs import SupplyRouteJs
|
||||
from .threatzonecontainerjs import ThreatZoneContainerJs
|
||||
from .threatzonesjs import ThreatZonesJs
|
||||
@@ -55,7 +54,6 @@ class MapModel(QObject):
|
||||
flightsChanged = Signal()
|
||||
frontLinesChanged = Signal()
|
||||
threatZonesChanged = Signal()
|
||||
navmeshesChanged = Signal()
|
||||
mapZonesChanged = Signal()
|
||||
unculledZonesChanged = Signal()
|
||||
selectedFlightChanged = Signal(str)
|
||||
@@ -72,7 +70,6 @@ class MapModel(QObject):
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
self._navmeshes = NavMeshJs([], [])
|
||||
self._map_zones = MapZonesJs([], [], [])
|
||||
self._unculled_zones = []
|
||||
self._selected_flight_index: Optional[Tuple[int, int]] = None
|
||||
@@ -102,7 +99,6 @@ class MapModel(QObject):
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
self._navmeshes = NavMeshJs([], [])
|
||||
self._map_zones = MapZonesJs([], [], [])
|
||||
self._unculled_zones = []
|
||||
self.cleared.emit()
|
||||
@@ -168,7 +164,6 @@ class MapModel(QObject):
|
||||
self.reset_atos()
|
||||
self.reset_front_lines()
|
||||
self.reset_threat_zones()
|
||||
self.reset_navmeshes()
|
||||
self.reset_map_zones()
|
||||
self.reset_unculled_zones()
|
||||
|
||||
@@ -302,20 +297,12 @@ class MapModel(QObject):
|
||||
def threatZones(self) -> ThreatZoneContainerJs:
|
||||
return self._threat_zones
|
||||
|
||||
def reset_navmeshes(self) -> None:
|
||||
self._navmeshes = NavMeshJs.from_game(self.game)
|
||||
self.navmeshesChanged.emit()
|
||||
|
||||
@Property(NavMeshJs, notify=navmeshesChanged)
|
||||
def navmeshes(self) -> NavMeshJs:
|
||||
return self._navmeshes
|
||||
|
||||
def reset_map_zones(self) -> None:
|
||||
self._map_zones = MapZonesJs.from_game(self.game)
|
||||
self.mapZonesChanged.emit()
|
||||
|
||||
@Property(MapZonesJs, notify=mapZonesChanged)
|
||||
def mapZones(self) -> NavMeshJs:
|
||||
def mapZones(self) -> MapZonesJs:
|
||||
return self._map_zones
|
||||
|
||||
def on_package_change(self) -> None:
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
|
||||
from game import Game
|
||||
from game.navmesh import NavMesh
|
||||
from game.server.leaflet import LeafletPoly
|
||||
from game.theater import ConflictTheater
|
||||
from .navmeshpolyjs import NavMeshPolyJs
|
||||
|
||||
|
||||
class NavMeshJs(QObject):
|
||||
blueChanged = Signal()
|
||||
redChanged = Signal()
|
||||
|
||||
def __init__(self, blue: list[NavMeshPolyJs], red: list[NavMeshPolyJs]) -> None:
|
||||
super().__init__()
|
||||
self._blue = blue
|
||||
self._red = red
|
||||
# TODO: Boundary markers.
|
||||
# TODO: Numbering.
|
||||
# TODO: Localization debugging.
|
||||
|
||||
@Property(list, notify=blueChanged)
|
||||
def blue(self) -> list[LeafletPoly]:
|
||||
return self._blue
|
||||
|
||||
@Property(list, notify=redChanged)
|
||||
def red(self) -> list[LeafletPoly]:
|
||||
return self._red
|
||||
|
||||
@staticmethod
|
||||
def to_polys(navmesh: NavMesh, theater: ConflictTheater) -> list[NavMeshPolyJs]:
|
||||
polys = []
|
||||
for poly in navmesh.polys:
|
||||
polys.append(NavMeshPolyJs.from_navmesh(poly, theater))
|
||||
return polys
|
||||
|
||||
@classmethod
|
||||
def from_game(cls, game: Game) -> NavMeshJs:
|
||||
return NavMeshJs(
|
||||
cls.to_polys(game.blue.nav_mesh, game.theater),
|
||||
cls.to_polys(game.red.nav_mesh, game.theater),
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
|
||||
from game.navmesh import NavMeshPoly
|
||||
from game.server.leaflet import LeafletPoly, ShapelyUtil
|
||||
from game.theater import ConflictTheater
|
||||
|
||||
|
||||
class NavMeshPolyJs(QObject):
|
||||
polyChanged = Signal()
|
||||
threatenedChanged = Signal()
|
||||
|
||||
def __init__(self, poly: LeafletPoly, threatened: bool) -> None:
|
||||
super().__init__()
|
||||
self._poly = poly
|
||||
self._threatened = threatened
|
||||
|
||||
@Property(list, notify=polyChanged)
|
||||
def poly(self) -> LeafletPoly:
|
||||
return self._poly
|
||||
|
||||
@Property(bool, notify=threatenedChanged)
|
||||
def threatened(self) -> bool:
|
||||
return self._threatened
|
||||
|
||||
@classmethod
|
||||
def from_navmesh(cls, poly: NavMeshPoly, theater: ConflictTheater) -> NavMeshPolyJs:
|
||||
return NavMeshPolyJs(
|
||||
ShapelyUtil.poly_to_leaflet(poly.poly, theater), poly.threatened
|
||||
)
|
||||
Reference in New Issue
Block a user