mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Started units spawn functions and major refactoring
This commit is contained in:
@@ -17,15 +17,12 @@ class Unit
|
||||
this.coalitionID = undefined;
|
||||
this.country = undefined;
|
||||
this.activePath = undefined;
|
||||
this.alive = undefined;
|
||||
this.type = undefined;
|
||||
|
||||
this._pathMarkers = [];
|
||||
|
||||
this._pathPolyline = new L.Polyline([], {
|
||||
color: '#2d3e50',
|
||||
weight: 3,
|
||||
opacity: 0.5,
|
||||
smoothFactor: 1
|
||||
});
|
||||
this._pathPolyline = new L.Polyline([], {color: '#2d3e50', weight: 3, opacity: 0.5, smoothFactor: 1});
|
||||
this._pathPolyline.addTo(map.getMap());
|
||||
}
|
||||
|
||||
@@ -38,7 +35,9 @@ class Unit
|
||||
this.longitude = response["longitude"];
|
||||
this.altitude = response["altitude"];
|
||||
this.heading = response["heading"];
|
||||
this.coalitionID = response["coalitionID"]
|
||||
this.coalitionID = response["coalitionID"];
|
||||
this.alive = response["alive"];
|
||||
this.type = response["type"];
|
||||
|
||||
/* Only present if an active path is available */
|
||||
if ("activePath" in response)
|
||||
@@ -46,6 +45,11 @@ class Unit
|
||||
|
||||
this.drawMarker();
|
||||
|
||||
if (!this.alive)
|
||||
{
|
||||
this.setSelected(false);
|
||||
}
|
||||
|
||||
if (this._selected && this.activePath != undefined)
|
||||
{
|
||||
this.drawPath();
|
||||
@@ -58,9 +62,13 @@ class Unit
|
||||
|
||||
setSelected(selected)
|
||||
{
|
||||
this._selected = selected;
|
||||
this.marker.setSelected(selected);
|
||||
unitsFactory.onUnitSelection();
|
||||
/* Only alive units can be selected */
|
||||
if (this.alive || !selected)
|
||||
{
|
||||
this._selected = selected;
|
||||
this.marker.setSelected(selected);
|
||||
unitsFactory.onUnitSelection();
|
||||
}
|
||||
}
|
||||
|
||||
getSelected()
|
||||
@@ -72,12 +80,10 @@ class Unit
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", RESTaddress);
|
||||
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
console.log(this.unitName + " add destination to (" + latlng.lat + ", " + latlng.lng + ")")
|
||||
console.log(this.unitName + " add destination to " + ConvertDDToDMS(latlng.lat, false) + " " + ConvertDDToDMS(latlng.lng, true))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,7 +111,6 @@ class Unit
|
||||
|
||||
onClick(e)
|
||||
{
|
||||
// TODO if ctrl is pressed, don't deselect the other units
|
||||
if (!e.originalEvent.ctrlKey)
|
||||
{
|
||||
unitsFactory.deselectAllUnits();
|
||||
@@ -117,10 +122,12 @@ class Unit
|
||||
{
|
||||
var zIndex = this.marker.getZIndex();
|
||||
var newLatLng = new L.LatLng(this.latitude, this.longitude);
|
||||
this.marker.setCoalitionID(this.coalitionID);
|
||||
this.marker.setLatLng(newLatLng);
|
||||
this.marker.setUnitName(this.unitName);
|
||||
this.marker.setAngle(this.heading);
|
||||
this.marker.setZIndex(zIndex);
|
||||
this.marker.setAlive(this.alive);
|
||||
}
|
||||
|
||||
drawPath()
|
||||
|
||||
Reference in New Issue
Block a user