(WiP) Unit spawn menu

This commit is contained in:
dpassoni
2023-03-09 17:55:35 +01:00
parent 70c73aa3a9
commit 406e515fa6
14 changed files with 707 additions and 408 deletions

View File

@@ -290,7 +290,7 @@ export class Unit extends Marker {
'Attack',
'Follow'
]
getMap().showContextMenu(e.originalEvent, "Action: " + this.getData().unitName, options.map((option: string) => {return {tooltip: option, src: "", callback: (action: string) => this.#executeAction(action)}}));
//getMap().showContextMenu(e.originalEvent, "Action: " + this.getData().unitName, options.map((option: string) => {return {tooltip: option, src: "", callback: (action: string) => this.#executeAction(action)}}));
}
#executeAction(action: string) {

View File

@@ -6,6 +6,24 @@ export class UnitDatabase {
}
getRoles()
{
var roles: string[] = [];
for (let unit in this.units)
{
for (let loadout of this.units[unit].loadouts)
{
for (let role of loadout.roles)
{
role = role.toUpperCase();
if (role !== "" && !roles.includes(role))
roles.push(role);
}
}
}
return roles;
}
getLabelsByRole(role: string)
{
var units = [];
@@ -13,7 +31,7 @@ export class UnitDatabase {
{
for (let loadout of this.units[unit].loadouts)
{
if (loadout.roles.includes(role))
if (loadout.roles.includes(role) || loadout.roles.includes(role.toLowerCase()))
{
units.push(this.units[unit].label)
break;
@@ -28,7 +46,7 @@ export class UnitDatabase {
var loadouts = [];
for (let loadout of this.units[unit].loadouts)
{
if (loadout.roles.includes(role) || loadout.roles.includes(""))
if (loadout.roles.includes(role) || loadout.roles.includes(role.toLowerCase()) || loadout.roles.includes(""))
{
loadouts.push(loadout.name)
}