Tweaks and implemented workaround to MIST bug

This commit is contained in:
Pax1601
2023-07-12 17:01:03 +02:00
parent b78cd27e4e
commit a949a9bf22
27 changed files with 453 additions and 135 deletions

View File

@@ -1,3 +1,6 @@
import { LatLng } from "leaflet";
import { getUnitsManager } from "..";
export class UnitDatabase {
blueprints: { [key: string]: UnitBlueprint } = {};
@@ -5,6 +8,10 @@ export class UnitDatabase {
}
getCategory() {
return "";
}
getBlueprints() {
return this.blueprints;
}
@@ -143,4 +150,16 @@ export class UnitDatabase {
}
return null;
}
generateTestGrid(initialPosition: LatLng) {
const step = 0.01;
var nUnits = Object.values(this.blueprints).length;
var gridSize = Math.ceil(Math.sqrt(nUnits));
Object.values(this.blueprints).forEach((unitBlueprint: UnitBlueprint, idx: number) => {
var row = Math.floor(idx / gridSize);
var col = idx - row * gridSize;
var location = new LatLng(initialPosition.lat + col * step, initialPosition.lng + row * step)
getUnitsManager().spawnUnit(this.getCategory(), [{unitType: unitBlueprint.name, location: location, altitude: 1000, loadout: ""}]);
})
}
}