Updated landAtPoint logic

This commit is contained in:
PeekabooSteam 2023-11-03 18:28:05 +00:00
parent 31405119f0
commit 7106646042
2 changed files with 8 additions and 4 deletions

View File

@ -613,16 +613,16 @@ export class Map extends L.Map {
const selectedUnitTypes = getApp().getUnitsManager().getSelectedUnitsCategories();
if (selectedUnitTypes.length === 1 && ["Aircraft", "Helicopter"].includes(selectedUnitTypes[0])) {
if (selectedUnitTypes[0] === "Helicopter") {
if (selectedUnits.every((unit: Unit) => { return unit.canLandAtPoint()}))
options["land-at-point"] = { text: "Land here", tooltip: "Land at this precise location" };
}
if (selectedUnits.every((unit: Unit) => { return unit.canTargetPoint()})) {
options["bomb"] = { text: "Precision bombing", tooltip: "Precision bombing of a specific point" };
options["carpet-bomb"] = { text: "Carpet bombing", tooltip: "Carpet bombing close to a point" };
} else if (selectedUnitTypes[0] !== "Helicopter") {
}
if (Object.keys(options).length === 0)
(getApp().getPopupsManager().get("infoPopup") as Popup).setText(`Selected units can not perform point actions.`);
}
}
else if (selectedUnitTypes.length === 1 && ["GroundUnit", "NavyUnit"].includes(selectedUnitTypes[0])) {
if (selectedUnits.every((unit: Unit) => { return unit.canTargetPoint() })) {

View File

@ -636,6 +636,10 @@ export class Unit extends CustomMarker {
return getApp().getMap().getBounds().contains(this.getPosition());
}
canLandAtPoint() {
return this.getCategory() === "Helicopter"; // Only choppers can do this currently
}
canTargetPoint() {
return this.getDatabase()?.getByName(this.#name)?.canTargetPoint === true;
}