Implemented as described in issue

This commit is contained in:
Pax1601
2023-05-01 10:37:40 +02:00
parent ee08d9d48e
commit 640f764354
9 changed files with 59 additions and 234 deletions

View File

@@ -29,11 +29,7 @@ interface MissionData {
}
interface FormationData {
formation: string;
isLeader: boolean;
isWingman: boolean;
leaderID: number;
wingmenIDs: number[];
}
interface TaskData {

View File

@@ -381,57 +381,6 @@ export class HelicopterDatabase extends UnitDatabase {
],
"filename": "ah-1.png"
},
"AH-1W": {
"name": "AH-1W",
"label": "AH-1W Cobra",
"shortLabel": "AH1",
"loadouts": [
{
"fuel": 1,
"items": [
{
"name": "BGM-71 TOW",
"quantity": 8
},
{
"name": "Hydra-70 WP",
"quantity": 38
}
],
"roles": [
"CAS"
],
"code": "8xBGM-71, 38xHYDRA-70 WP",
"name": "TOW / Hydra"
},
{
"fuel": 1,
"items": [
{
"name": "Hydra-70",
"quantity": 76
}
],
"roles": [
"CAS"
],
"code": "76xHYDRA-70",
"name": "Hydra"
},
{
"fuel": 1,
"items": [
],
"roles": [
""
],
"code": "",
"name": "Empty Loadout"
}
],
"filename": "ah-1.png"
},
"Mi-26": {
"name": "Mi-26",
"label": "Mi-26 Halo",

View File

@@ -40,11 +40,7 @@ export class Unit extends Marker {
coalition: "",
},
formationData: {
formation: "",
isLeader: false,
isWingman: false,
leaderID: 0,
wingmenIDs: [],
leaderID: 0
},
taskData: {
currentState: "IDLE",
@@ -315,22 +311,6 @@ export class Unit extends Marker {
return getUnitsManager().getUnitByID(this.getFormationData().leaderID);
}
getFormation() {
return [<Unit>this].concat(this.getWingmen())
}
getWingmen() {
var wingmen: Unit[] = [];
if (this.getFormationData().wingmenIDs != undefined) {
for (let ID of this.getFormationData().wingmenIDs) {
var unit = getUnitsManager().getUnitByID(ID)
if (unit)
wingmen.push(unit);
}
}
return wingmen;
}
attackUnit(targetID: number) {
/* Units can't attack themselves */
if (this.ID != targetID) {

View File

@@ -119,35 +119,7 @@ export class UnitsManager {
this.#units[ID].setSelected(false);
}
}
getSelectedLeaders() {
var leaders: Unit[] = [];
for (let idx in this.getSelectedUnits())
{
var unit = this.getSelectedUnits()[idx];
if (unit.getFormationData().isLeader)
leaders.push(unit);
else if (unit.getFormationData().isWingman)
{
var leader = unit.getLeader();
if (leader && !leaders.includes(leader))
leaders.push(leader);
}
}
return leaders;
}
getSelectedSingletons() {
var singletons: Unit[] = [];
for (let idx in this.getSelectedUnits())
{
var unit = this.getSelectedUnits()[idx];
if (!unit.getFormationData().isLeader && !unit.getFormationData().isWingman)
singletons.push(unit);
}
return singletons;
}
getSelectedUnitsType () {
if (this.getSelectedUnits().length == 0)
return undefined;