Fixed unit payloads, spread update load from mission update

This commit is contained in:
Pax1601
2023-02-14 22:48:17 +01:00
parent 0564b4b01f
commit 433b4bdf56
13 changed files with 1349 additions and 60 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -12,6 +12,7 @@ var pathIcon = new Icon({
export class Unit {
ID: number = -1;
AI: boolean = false;
formation: string = "";
name: string = "";
unitName: string = "";
@@ -387,6 +388,9 @@ export class Unit {
export class AirUnit extends Unit {
getHidden() {
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
return true
if (this.alive)
{
if (this.flags.user && getVisibilitySettings().user === "hidden")
@@ -421,6 +425,9 @@ export class GroundUnit extends Unit {
}
getHidden() {
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
return true
if (this.alive)
{
if (this.flags.user && getVisibilitySettings().user === "hidden")
@@ -441,6 +448,9 @@ export class NavyUnit extends Unit {
}
getHidden() {
if (this.AI == false && getVisibilitySettings().uncontrolled === "hidden")
return true
if (this.alive)
{
if (this.flags.user && getVisibilitySettings().user === "hidden")

View File

@@ -8,6 +8,7 @@ export interface MarkerOptions {
human: boolean
coalitionID: number
type: any
AI: boolean
}
export interface MarkerData {
@@ -21,6 +22,7 @@ export class UnitMarker extends L.Marker {
#unitName: string
#name: string
#human: boolean
#AI: boolean
#alive: boolean = true
#selected: boolean = false
@@ -29,6 +31,7 @@ export class UnitMarker extends L.Marker {
this.#unitName = options.unitName;
this.#name = options.name;
this.#human = options.human;
this.#AI = options.AI;
var symbol = new Symbol(this.#computeMarkerCode(options), { size: 25 });
var img = symbol.asCanvas().toDataURL('image/png');
@@ -127,6 +130,10 @@ export class UnitMarker extends L.Marker {
return this.#human;
}
getAI() {
return this.#AI;
}
getAlive() {
return this.#alive;
}
@@ -226,7 +233,7 @@ export class AirUnitMarker extends UnitMarker {
else if (!this.getAlive())
return "none";
else
return getVisibilitySettings().ai;
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
}
}
@@ -247,7 +254,7 @@ export class GroundUnitMarker extends UnitMarker {
else if (!this.getAlive())
return "none";
else
return getVisibilitySettings().ai;
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
}
}
@@ -259,7 +266,7 @@ export class NavyUnitMarker extends UnitMarker {
if (!this.getAlive())
return "none";
else
return getVisibilitySettings().ai;
return this.getAI()? getVisibilitySettings().ai: getVisibilitySettings().uncontrolled;
}
}

View File

@@ -39,7 +39,8 @@ export class UnitsManager {
name: data.name,
human: data.human,
coalitionID: data.coalitionID,
type: data.type
type: data.type,
AI: data.AI
}
this.#units[ID] = new constructor(ID, options);
}
@@ -112,10 +113,13 @@ export class UnitsManager {
this.deselectAllUnits();
for (let ID in this.#units)
{
var latlng = new LatLng(this.#units[ID].latitude, this.#units[ID].longitude);
if (bounds.contains(latlng))
if (this.#units[ID].getHidden() == false)
{
this.#units[ID].setSelected(true);
var latlng = new LatLng(this.#units[ID].latitude, this.#units[ID].longitude);
if (bounds.contains(latlng))
{
this.#units[ID].setSelected(true);
}
}
}
}