mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Move unculled zones out of MapModel.
This commit is contained in:
@@ -23,7 +23,6 @@ from .groundobjectjs import GroundObjectJs
|
||||
from .supplyroutejs import SupplyRouteJs
|
||||
from .threatzonecontainerjs import ThreatZoneContainerJs
|
||||
from .threatzonesjs import ThreatZonesJs
|
||||
from .unculledzonejs import UnculledZone
|
||||
|
||||
|
||||
# **EVERY PROPERTY NEEDS A NOTIFY SIGNAL**
|
||||
@@ -53,7 +52,6 @@ class MapModel(QObject):
|
||||
flightsChanged = Signal()
|
||||
frontLinesChanged = Signal()
|
||||
threatZonesChanged = Signal()
|
||||
unculledZonesChanged = Signal()
|
||||
selectedFlightChanged = Signal(str)
|
||||
|
||||
def __init__(self, game_model: GameModel) -> None:
|
||||
@@ -68,7 +66,6 @@ class MapModel(QObject):
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
self._unculled_zones = []
|
||||
self._selected_flight_index: Optional[Tuple[int, int]] = None
|
||||
|
||||
GameUpdateSignal.get_instance().game_loaded.connect(self.on_game_load)
|
||||
@@ -79,12 +76,6 @@ class MapModel(QObject):
|
||||
GameUpdateSignal.get_instance().flight_selection_changed.connect(
|
||||
self.set_flight_selection
|
||||
)
|
||||
self.game_model.ato_model_for(True).packages_changed.connect(
|
||||
self.on_package_change
|
||||
),
|
||||
self.game_model.ato_model_for(False).packages_changed.connect(
|
||||
self.on_package_change
|
||||
),
|
||||
self.reset()
|
||||
|
||||
def clear(self) -> None:
|
||||
@@ -96,7 +87,6 @@ class MapModel(QObject):
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
self._unculled_zones = []
|
||||
self.cleared.emit()
|
||||
|
||||
def set_package_selection(self, index: int) -> None:
|
||||
@@ -160,7 +150,6 @@ class MapModel(QObject):
|
||||
self.reset_atos()
|
||||
self.reset_front_lines()
|
||||
self.reset_threat_zones()
|
||||
self.reset_unculled_zones()
|
||||
|
||||
def on_game_load(self, game: Optional[Game]) -> None:
|
||||
if game is not None:
|
||||
@@ -292,17 +281,6 @@ class MapModel(QObject):
|
||||
def threatZones(self) -> ThreatZoneContainerJs:
|
||||
return self._threat_zones
|
||||
|
||||
def on_package_change(self) -> None:
|
||||
self.reset_unculled_zones()
|
||||
|
||||
def reset_unculled_zones(self) -> None:
|
||||
self._unculled_zones = list(UnculledZone.each_from_game(self.game))
|
||||
self.unculledZonesChanged.emit()
|
||||
|
||||
@Property(list, notify=unculledZonesChanged)
|
||||
def unculledZones(self) -> list[UnculledZone]:
|
||||
return self._unculled_zones
|
||||
|
||||
@property
|
||||
def game(self) -> Game:
|
||||
if self.game_model.game is None:
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterator
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
|
||||
from game import Game
|
||||
from game.server.leaflet import LeafletLatLon
|
||||
|
||||
|
||||
class UnculledZone(QObject):
|
||||
positionChanged = Signal()
|
||||
radiusChanged = Signal()
|
||||
|
||||
def __init__(self, position: LeafletLatLon, radius: float) -> None:
|
||||
super().__init__()
|
||||
self._position = position
|
||||
self._radius = radius
|
||||
|
||||
@Property(list, notify=positionChanged)
|
||||
def position(self) -> LeafletLatLon:
|
||||
return self._position
|
||||
|
||||
@Property(float, notify=radiusChanged)
|
||||
def radius(self) -> float:
|
||||
return self._radius
|
||||
|
||||
@classmethod
|
||||
def each_from_game(cls, game: Game) -> Iterator[UnculledZone]:
|
||||
for zone in game.get_culling_zones():
|
||||
yield UnculledZone(
|
||||
zone.latlng().as_list(), game.settings.perf_culling_distance * 1000
|
||||
)
|
||||
Reference in New Issue
Block a user