forked from noxious/server
Partial fix, still missing functionality (like a lot)
This commit is contained in:
@ -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`)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user