From 0ae694c1a8e3cc77ff698d17a88192cd3ddb0a0d Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 29 Aug 2023 14:59:23 +0200 Subject: [PATCH] Non visually detected units are now drawn with generic symbol --- client/demo.js | 2 +- client/src/unit/unit.ts | 45 +++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/client/demo.js b/client/demo.js index d7f970df..6530f21b 100644 --- a/client/demo.js +++ b/client/demo.js @@ -15,7 +15,7 @@ const DEMO_UNIT_DATA = { radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 }, generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false }, ammo: [{ quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } ], - contacts: [{ID: 2, detectionMethod: 1}, {ID: 3, detectionMethod: 4}], + contacts: [{ID: 2, detectionMethod: 1}, {ID: 3, detectionMethod: 4}, {ID: 5, detectionMethod: 4}], activePath: [{lat: 38, lng: -115, alt: 0}, {lat: 38, lng: -114, alt: 0}] }, ["2"]:{ category: "Aircraft", alive: true, human: false, controlled: false, coalition: 1, country: 0, name: "FA-18C_hornet", unitName: "Cool guy 1-2", groupName: "Cool group 2", state: 1, task: "Being cool", diff --git a/client/src/unit/unit.ts b/client/src/unit/unit.ts index 8eccce12..badf719e 100644 --- a/client/src/unit/unit.ts +++ b/client/src/unit/unit.ts @@ -438,7 +438,15 @@ export class Unit extends CustomMarker { var unitIcon = document.createElement("div"); unitIcon.classList.add("unit-icon"); var img = document.createElement("img"); - img.src = `/resources/theme/images/units/${this.getMarkerCategory()}.svg`; + var imgSrc; + + /* If a unit does not belong to the commanded coalition or it is not visually detected, show it with the generic aircraft square */ + if (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC].includes(value))) + imgSrc = this.getMarkerCategory(); + else + imgSrc = "aircraft"; + + img.src = `/resources/theme/images/units/${imgSrc}.svg`; img.onload = () => SVGInjector(img); unitIcon.appendChild(img); unitIcon.toggleAttribute("data-rotate-to-heading", iconOptions.rotateToHeading); @@ -1090,16 +1098,17 @@ export class Unit extends CustomMarker { export class AirUnit extends Unit { getIconOptions() { + var belongsToCommandedCoalition = this.belongsToCommandedCoalition(); return { - showState: this.belongsToCommandedCoalition(), - showVvi: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), - showHotgroup: this.belongsToCommandedCoalition(), - showUnitIcon: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), - showShortLabel: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC].includes(value))), - showFuel: this.belongsToCommandedCoalition(), - showAmmo: this.belongsToCommandedCoalition(), - showSummary: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), - showCallsign: this.belongsToCommandedCoalition(), + showState: belongsToCommandedCoalition, + showVvi: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), + showHotgroup: belongsToCommandedCoalition, + showUnitIcon: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), + showShortLabel: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC].includes(value))), + showFuel: belongsToCommandedCoalition, + showAmmo: belongsToCommandedCoalition, + showSummary: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), + showCallsign: belongsToCommandedCoalition, rotateToHeading: false }; } @@ -1131,16 +1140,17 @@ export class GroundUnit extends Unit { } getIconOptions() { + var belongsToCommandedCoalition = this.belongsToCommandedCoalition(); return { - showState: this.belongsToCommandedCoalition(), + showState: belongsToCommandedCoalition, showVvi: false, - showHotgroup: this.belongsToCommandedCoalition(), - showUnitIcon: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), + showHotgroup: belongsToCommandedCoalition, + showUnitIcon: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), showShortLabel: false, showFuel: false, showAmmo: false, showSummary: false, - showCallsign: this.belongsToCommandedCoalition(), + showCallsign: belongsToCommandedCoalition, rotateToHeading: false }; } @@ -1161,16 +1171,17 @@ export class NavyUnit extends Unit { } getIconOptions() { + var belongsToCommandedCoalition = this.belongsToCommandedCoalition(); return { - showState: this.belongsToCommandedCoalition(), + showState: belongsToCommandedCoalition, showVvi: false, showHotgroup: true, - showUnitIcon: (this.belongsToCommandedCoalition() || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), + showUnitIcon: (belongsToCommandedCoalition || this.getDetectionMethods().some(value => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value))), showShortLabel: false, showFuel: false, showAmmo: false, showSummary: false, - showCallsign: this.belongsToCommandedCoalition(), + showCallsign: belongsToCommandedCoalition, rotateToHeading: false }; }