Move NavMesh out of MapModel.

This commit is contained in:
Dan Albert
2022-02-22 18:47:51 -08:00
parent 1a9930b93a
commit 0e6a303c17
15 changed files with 108 additions and 127 deletions

View File

@@ -384,7 +384,6 @@ new QWebChannel(qt.webChannelTransport, function (channel) {
game.frontLinesChanged.connect(drawFrontLines);
game.flightsChanged.connect(drawAircraft);
game.threatZonesChanged.connect(drawThreatZones);
game.navmeshesChanged.connect(drawNavmeshes);
game.mapZonesChanged.connect(drawMapZones);
game.unculledZonesChanged.connect(drawUnculledZones);
game.selectedFlightChanged.connect(updateSelectedFlight);
@@ -400,6 +399,9 @@ function handleStreamedEvents(events) {
for (const combat of events.updated_combats) {
redrawCombat(combat);
}
for (const player of events.navmesh_updates) {
drawNavmesh(player);
}
}
function recenterMap(center) {
@@ -1094,26 +1096,27 @@ function drawThreatZones() {
);
}
function drawNavmesh(zones, layer) {
for (const zone of zones) {
L.polyline(zone.poly, {
color: "#000000",
weight: 1,
fillColor: zone.threatened ? "#ff0000" : "#00ff00",
fill: true,
fillOpacity: 0.1,
noClip: true,
interactive: false,
}).addTo(layer);
}
function drawNavmesh(player) {
const layer = player ? blueNavmesh : redNavmesh;
layer.clearLayers();
getJson(`/navmesh?for_player=${player}`).then((zones) => {
for (const zone of zones) {
L.polyline(zone.poly, {
color: "#000000",
weight: 1,
fillColor: zone.threatened ? "#ff0000" : "#00ff00",
fill: true,
fillOpacity: 0.1,
noClip: true,
interactive: false,
}).addTo(layer);
}
});
}
function drawNavmeshes() {
blueNavmesh.clearLayers();
redNavmesh.clearLayers();
drawNavmesh(game.navmeshes.blue, blueNavmesh);
drawNavmesh(game.navmeshes.red, redNavmesh);
drawNavmesh(true);
drawNavmesh(false);
}
function drawMapZones() {