mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge branch 'main' into 343-add-ability-to-select-unit-nation-and-livery
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Marker, LatLng, Polyline, Icon, DivIcon, CircleMarker, Map, Point } from 'leaflet';
|
||||
import { getMap, getMissionHandler, getUnitsManager } from '..';
|
||||
import { getMap, getMissionHandler, getUnitsManager, getWeaponsManager } from '..';
|
||||
import { enumToCoalition, enumToEmissioNCountermeasure, getMarkerCategoryByName, enumToROE, enumToReactionToThreat, enumToState, getUnitDatabaseByCategory, mToFt, msToKnots, rad2deg, bearing, deg2rad } from '../other/utils';
|
||||
import { addDestination, attackUnit, changeAltitude, changeSpeed, createFormation as setLeader, deleteUnit, landAt, setAltitude, setReactionToThreat, setROE, setSpeed, refuel, setAdvacedOptions, followUnit, setEmissionsCountermeasures, setSpeedType, setAltitudeType, setOnOff, setFollowRoads, bombPoint, carpetBomb, bombBuilding, fireAtArea } from '../server/server';
|
||||
import { CustomMarker } from '../map/custommarker';
|
||||
@@ -11,6 +11,7 @@ import { Ammo, Contact, GeneralSettings, Offset, Radio, TACAN, ObjectIconOptions
|
||||
import { DataExtractor } from '../server/dataextractor';
|
||||
import { groundUnitDatabase } from './groundunitdatabase';
|
||||
import { navyUnitDatabase } from './navyunitdatabase';
|
||||
import { Weapon } from '../weapon/weapon';
|
||||
|
||||
var pathIcon = new Icon({
|
||||
iconUrl: '/resources/theme/images/markers/marker-icon.png',
|
||||
@@ -153,7 +154,7 @@ export class Unit extends CustomMarker {
|
||||
this.on('click', (e) => this.#onClick(e));
|
||||
this.on('dblclick', (e) => this.#onDoubleClick(e));
|
||||
this.on('contextmenu', (e) => this.#onContextMenu(e));
|
||||
this.on('mouseover', () => { this.setHighlighted(true); })
|
||||
this.on('mouseover', () => { if (this.belongsToCommandedCoalition()) this.setHighlighted(true); })
|
||||
this.on('mouseout', () => { this.setHighlighted(false); })
|
||||
getMap().on("zoomend", () => {this.#onZoom();})
|
||||
|
||||
@@ -540,7 +541,7 @@ export class Unit extends CustomMarker {
|
||||
/* Force a redraw of the unit to reflect the new status of the detection methods */
|
||||
this.setHidden(true);
|
||||
this.#detectionMethods = newDetectionMethods;
|
||||
this.updateVisibility();
|
||||
this.#updateMarker();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -986,19 +987,25 @@ export class Unit extends CustomMarker {
|
||||
if (getMap().getVisibilityOptions()[SHOW_CONTACT_LINES]) {
|
||||
for (let index in this.#contacts) {
|
||||
var contactData = this.#contacts[index];
|
||||
var contact = getUnitsManager().getUnitByID(contactData.ID);
|
||||
var contact: Unit | Weapon | null;
|
||||
|
||||
if (contactData.ID in getUnitsManager().getUnits())
|
||||
contact = getUnitsManager().getUnitByID(contactData.ID);
|
||||
else
|
||||
contact = getWeaponsManager().getWeaponByID(contactData.ID);
|
||||
|
||||
if (contact != null && contact.getAlive()) {
|
||||
var startLatLng = new LatLng(this.#position.lat, this.#position.lng);
|
||||
var endLatLng: LatLng;
|
||||
if (contactData.detectionMethod === RWR) {
|
||||
var bearingToContact = bearing(this.#position.lat, this.#position.lng, contact.#position.lat, contact.#position.lng);
|
||||
var bearingToContact = bearing(this.#position.lat, this.#position.lng, contact.getPosition().lat, contact.getPosition().lng);
|
||||
var startXY = getMap().latLngToContainerPoint(startLatLng);
|
||||
var endX = startXY.x + 80 * Math.sin(deg2rad(bearingToContact));
|
||||
var endY = startXY.y - 80 * Math.cos(deg2rad(bearingToContact));
|
||||
endLatLng = getMap().containerPointToLatLng(new Point(endX, endY));
|
||||
}
|
||||
else
|
||||
endLatLng = new LatLng(contact.#position.lat, contact.#position.lng);
|
||||
endLatLng = new LatLng(contact.getPosition().lat, contact.getPosition().lng);
|
||||
|
||||
var color;
|
||||
if (contactData.detectionMethod === VISUAL || contactData.detectionMethod === OPTIC)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LatLng, LatLngBounds } from "leaflet";
|
||||
import { getHotgroupPanel, getInfoPopup, getMap, getMissionHandler, getUnitsManager } from "..";
|
||||
import { getHotgroupPanel, getInfoPopup, getMap, getMissionHandler, getUnitsManager, getWeaponsManager } from "..";
|
||||
import { Unit } from "./unit";
|
||||
import { cloneUnit, deleteUnit, refreshAll, spawnAircrafts, spawnGroundUnits, spawnHelicopters, spawnNavyUnits } from "../server/server";
|
||||
import { bearingAndDistanceToLatLng, deg2rad, keyEventWasInInput, latLngToMercator, mToFt, mercatorToLatLng, msToKnots, polyContains, polygonArea, randomPointInPoly, randomUnitBlueprint } from "../other/utils";
|
||||
@@ -36,6 +36,8 @@ export class UnitsManager {
|
||||
document.addEventListener('importFromFile', () => this.importFromFile());
|
||||
document.addEventListener('contactsUpdated', (e: CustomEvent) => {this.#requestDetectionUpdate = true});
|
||||
document.addEventListener('commandModeOptionsChanged', () => {Object.values(this.#units).forEach((unit: Unit) => unit.updateVisibility())});
|
||||
document.addEventListener('selectedUnitsChangeSpeed', (e: any) => {this.selectedUnitsChangeSpeed(e.detail.type)});
|
||||
document.addEventListener('selectedUnitsChangeAltitude', (e: any) => {this.selectedUnitsChangeAltitude(e.detail.type)});
|
||||
}
|
||||
|
||||
getSelectableAircraft() {
|
||||
@@ -95,11 +97,11 @@ export class UnitsManager {
|
||||
if (this.#requestDetectionUpdate && getMissionHandler().getCommandModeOptions().commandMode != GAME_MASTER) {
|
||||
/* Create a dictionary of empty detection methods arrays */
|
||||
var detectionMethods: {[key: string]: number[]} = {};
|
||||
for (let ID in this.#units) {
|
||||
const unit = this.#units[ID];
|
||||
for (let ID in this.#units)
|
||||
detectionMethods[ID] = [];
|
||||
}
|
||||
|
||||
for (let ID in getWeaponsManager().getWeapons())
|
||||
detectionMethods[ID] = [];
|
||||
|
||||
/* Fill the array with the detection methods */
|
||||
for (let ID in this.#units) {
|
||||
const unit = this.#units[ID];
|
||||
@@ -107,7 +109,7 @@ export class UnitsManager {
|
||||
const contacts = unit.getContacts();
|
||||
contacts.forEach((contact: Contact) => {
|
||||
const contactID = contact.ID;
|
||||
if (!(detectionMethods[contactID].includes(contact.detectionMethod)))
|
||||
if (contactID in detectionMethods && !(detectionMethods[contactID].includes(contact.detectionMethod)))
|
||||
detectionMethods[contactID]?.push(contact.detectionMethod);
|
||||
})
|
||||
}
|
||||
@@ -116,7 +118,11 @@ export class UnitsManager {
|
||||
/* Set the detection methods for every unit */
|
||||
for (let ID in this.#units) {
|
||||
const unit = this.#units[ID];
|
||||
unit.setDetectionMethods(detectionMethods[ID]);
|
||||
unit?.setDetectionMethods(detectionMethods[ID]);
|
||||
}
|
||||
for (let ID in getWeaponsManager().getWeapons()) {
|
||||
const weapon = getWeaponsManager().getWeaponByID(parseInt(ID));
|
||||
weapon?.setDetectionMethods(detectionMethods[ID]);
|
||||
}
|
||||
|
||||
this.#requestDetectionUpdate = false;
|
||||
|
||||
Reference in New Issue
Block a user