1
0
forked from noxious/server

Partial fix, still missing functionality (like a lot)

This commit is contained in:
Zaxiure
2024-09-16 20:35:09 +02:00
parent 7fb52732ab
commit fce5c8dad0
2 changed files with 53 additions and 6 deletions

View File

@ -25,19 +25,26 @@ class ZoneManager {
}
// For now only current zone.
public async getAssetsNeeded(zone: Zone) {
zone.tiles
const tiles = JSON.parse(zone.tiles as string) as string[][];
public async getNeededAssets(zone: Zone) {
const tiles = this.getUnique((JSON.parse(JSON.stringify(zone.tiles)) as string[][]).reduce((acc, val) => [...acc, ...val]));
const objects = await zoneRepository.getObjects(zone.id);
console.log(tiles);
console.log(objects);
let mappedObjects = this.getUnique(objects.map(x => x.objectId));
return {
tiles,
objects: mappedObjects
};
}
private getUnique<T>(array: T[]) {
return [...new Set<T>(array)]
}
// Method to handle individual zoneEditor loading
public async loadZone(zone: Zone) {
const loadedZone = new LoadedZone(zone)
this.loadedZones.push(loadedZone)
await this.getAssetsNeeded(zone);
await this.getNeededAssets(zone);
logger.info(`Zone ID ${zone.id} loaded`)
}