mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Color navmesh zones based on threat.
This commit is contained in:
parent
5f8be5fa91
commit
a1910f49a8
@ -12,7 +12,7 @@ from shapely.geometry import LineString, Point as ShapelyPoint, Polygon, MultiPo
|
||||
|
||||
from game import Game
|
||||
from game.dcs.groundunittype import GroundUnitType
|
||||
from game.navmesh import NavMesh
|
||||
from game.navmesh import NavMesh, NavMeshPoly
|
||||
from game.profiling import logged_duration
|
||||
from game.theater import (
|
||||
ConflictTheater,
|
||||
@ -646,11 +646,35 @@ class ThreatZoneContainerJs(QObject):
|
||||
return self._red
|
||||
|
||||
|
||||
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(
|
||||
shapely_poly_to_leaflet_points(poly.poly, theater), poly.threatened
|
||||
)
|
||||
|
||||
|
||||
class NavMeshJs(QObject):
|
||||
blueChanged = Signal()
|
||||
redChanged = Signal()
|
||||
|
||||
def __init__(self, blue: list[LeafletPoly], red: list[LeafletPoly]) -> None:
|
||||
def __init__(self, blue: list[NavMeshPolyJs], red: list[NavMeshPolyJs]) -> None:
|
||||
super().__init__()
|
||||
self._blue = blue
|
||||
self._red = red
|
||||
@ -667,10 +691,10 @@ class NavMeshJs(QObject):
|
||||
return self._red
|
||||
|
||||
@staticmethod
|
||||
def to_polys(navmesh: NavMesh, theater: ConflictTheater) -> list[LeafletPoly]:
|
||||
def to_polys(navmesh: NavMesh, theater: ConflictTheater) -> list[NavMeshPolyJs]:
|
||||
polys = []
|
||||
for poly in navmesh.polys:
|
||||
polys.append(shapely_poly_to_leaflet_points(poly.poly, theater))
|
||||
polys.append(NavMeshPolyJs.from_navmesh(poly, theater))
|
||||
return polys
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -904,10 +904,13 @@ function drawThreatZones() {
|
||||
|
||||
function drawNavmesh(zones, layer) {
|
||||
for (const zone of zones) {
|
||||
L.polyline(zone, {
|
||||
L.polyline(zone.poly, {
|
||||
color: "#000000",
|
||||
weight: 1,
|
||||
fill: false,
|
||||
fillColor: zone.threatened ? "#ff0000" : "#00ff00",
|
||||
fill: true,
|
||||
fillOpacity: 0.1,
|
||||
noClip: true,
|
||||
interactive: false,
|
||||
}).addTo(layer);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user