Added scatter and intensity selectors in UI

This commit is contained in:
Pax1601
2023-10-30 12:46:49 +01:00
parent 88844db23a
commit c0f3f3a40a
16 changed files with 374 additions and 6 deletions

View File

@@ -78,6 +78,8 @@ export class Unit extends CustomMarker {
#activePath: LatLng[] = [];
#isLeader: boolean = false;
#operateAs: string = "blue";
#shotsScatter: number = 2;
#shotsIntensity: number = 2;
#selectable: boolean;
#selected: boolean = false;
@@ -134,6 +136,8 @@ export class Unit extends CustomMarker {
getActivePath() { return this.#activePath };
getIsLeader() { return this.#isLeader };
getOperateAs() { return this.#operateAs };
getShotsScatter() { return this.#shotsScatter};
getShotsIntensity() { return this.#shotsIntensity};
static getConstructor(type: string) {
if (type === "GroundUnit") return GroundUnit;
@@ -245,6 +249,8 @@ export class Unit extends CustomMarker {
case DataIndexes.activePath: this.#activePath = dataExtractor.extractActivePath(); break;
case DataIndexes.isLeader: this.#isLeader = dataExtractor.extractBool(); updateMarker = true; break;
case DataIndexes.operateAs: this.#operateAs = enumToCoalition(dataExtractor.extractUInt8()); break;
case DataIndexes.shotsScatter: this.#shotsScatter = dataExtractor.extractUInt8(); break;
case DataIndexes.shotsIntensity: this.#shotsIntensity = dataExtractor.extractUInt8(); break;
}
}
@@ -308,7 +314,9 @@ export class Unit extends CustomMarker {
contacts: this.#contacts,
activePath: this.#activePath,
isLeader: this.#isLeader,
operateAs: this.#operateAs
operateAs: this.#operateAs,
shotsScatter: this.#shotsScatter,
shotsIntensity: this.#shotsIntensity
}
}
@@ -813,6 +821,16 @@ export class Unit extends CustomMarker {
getApp().getServerManager().landAtPoint(this.ID, latlng);
}
setShotsScatter(shotsScatter: number) {
if (!this.#human)
getApp().getServerManager().setShotsScatter(this.ID, shotsScatter);
}
setShotsIntensity(shotsIntensity: number) {
if (!this.#human)
getApp().getServerManager().setShotsIntensity(this.ID, shotsIntensity);
}
/***********************************************/
getActions(): { [key: string]: { text: string, tooltip: string, type: string } } {
/* To be implemented by child classes */ // TODO make Unit an abstract class

View File

@@ -687,6 +687,30 @@ export class UnitsManager {
this.#showActionMessage(selectedUnits, `unit simulating fire fight`);
}
/** Set a specific shots scatter to all the selected units
*
* @param shotsScatter Value to set
*/
selectedUnitsSetShotsScatter(shotsScatter: number) {
var selectedUnits = this.getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true });
for (let idx in selectedUnits) {
selectedUnits[idx].setShotsScatter(shotsScatter);
}
this.#showActionMessage(selectedUnits, `shots scatter set to ${shotsScatter}`);
}
/** Set a specific shots intensity to all the selected units
*
* @param shotsScatter Value to set
*/
selectedUnitsSetShotsIntensity(shotsIntensity: number) {
var selectedUnits = this.getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true });
for (let idx in selectedUnits) {
selectedUnits[idx].setShotsIntensity(shotsIntensity);
}
this.#showActionMessage(selectedUnits, `shots intensity set to ${shotsIntensity}`);
}
/*********************** Control operations on selected units ************************/
/** See getUnitsCategories for more info
*