npm run frmat

This commit is contained in:
2024-09-20 12:34:34 +02:00
parent 5a40fb4734
commit 2101d20835
6 changed files with 27 additions and 29 deletions

View File

@ -27,16 +27,14 @@ class ZoneManager {
}
public async getZoneAssets(zone: Zone): Promise<ZoneAssets> {
const tiles: string[] = this.getUnique(
(JSON.parse(JSON.stringify(zone.tiles)) as string[][]).reduce((acc, val) => [...acc, ...val])
);
const objects = await zoneRepository.getObjects(zone.id);
const mappedObjects = this.getUnique(objects.map(x => x.objectId));
const tiles: string[] = this.getUnique((JSON.parse(JSON.stringify(zone.tiles)) as string[][]).reduce((acc, val) => [...acc, ...val]))
const objects = await zoneRepository.getObjects(zone.id)
const mappedObjects = this.getUnique(objects.map((x) => x.objectId))
return {
tiles: tiles,
objects: mappedObjects,
} as ZoneAssets;
objects: mappedObjects
} as ZoneAssets
}
private getUnique<T>(array: T[]) {
@ -47,7 +45,7 @@ class ZoneManager {
public async loadZone(zone: Zone) {
const loadedZone = new LoadedZone(zone)
this.loadedZones.push(loadedZone)
await this.getZoneAssets(zone);
await this.getZoneAssets(zone)
logger.info(`Zone ID ${zone.id} loaded`)
}