POC working new caching method - moved controllers folder, renamed assets to textures, fixed HTTP bug, formatted code

This commit is contained in:
2025-01-07 03:58:32 +01:00
parent f47023dc81
commit 010454914b
25 changed files with 131 additions and 137 deletions

View File

@ -3,4 +3,36 @@ import { Entity } from '@mikro-orm/core'
import { BaseMap } from '#entities/base/map'
@Entity()
export class Map extends BaseMap {}
export class Map extends BaseMap {
public async cache() {
try {
await this.getPlacedMapObjects().load()
await this.getMapEffects().load()
return {
id: this.getId(),
name: this.getName(),
width: this.getWidth(),
height: this.getHeight(),
tiles: this.getTiles(),
pvp: this.getPvp(),
updatedAt: this.getUpdatedAt(),
placedMapObjects: this.getPlacedMapObjects().map((placedMapObject) => ({
id: placedMapObject.getId(),
mapObject: placedMapObject.getMapObject().getId(),
depth: placedMapObject.getDepth(),
isRotated: placedMapObject.getIsRotated(),
positionX: placedMapObject.getPositionX(),
positionY: placedMapObject.getPositionY()
})),
mapEffects: this.getMapEffects().map((mapEffect) => ({
effect: mapEffect.getEffect(),
strength: mapEffect.getStrength()
}))
}
} catch (error) {
console.error(error)
return {}
}
}
}