Map editor teleport enhancements
This commit is contained in:
@ -2,6 +2,7 @@ import { BaseMap } from '@/entities/base/map'
|
||||
import { Entity } from '@mikro-orm/core'
|
||||
|
||||
export type MapCacheT = ReturnType<Map['cache']> | {}
|
||||
export type MapEditorMapT = ReturnType<Map['mapEditorObject']> | {}
|
||||
|
||||
@Entity()
|
||||
export class Map extends BaseMap {
|
||||
@ -35,4 +36,42 @@ export class Map extends BaseMap {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
public async mapEditorObject() {
|
||||
try {
|
||||
await this.getPlacedMapObjects().load()
|
||||
await this.getMapEffects().load()
|
||||
await this.getMapEventTiles().load()
|
||||
|
||||
return {
|
||||
id: this.getId(),
|
||||
name: this.getName(),
|
||||
width: this.getWidth(),
|
||||
height: this.getHeight(),
|
||||
tiles: this.getTiles(),
|
||||
pvp: this.getPvp(),
|
||||
createdAt: this.getCreatedAt(),
|
||||
updatedAt: this.getUpdatedAt(),
|
||||
placedMapObjects: this.getPlacedMapObjects(),
|
||||
mapEffects: this.getMapEffects(),
|
||||
mapEventTiles: this.getMapEventTiles().map((mapEventTile) => ({
|
||||
id: mapEventTile.getId(),
|
||||
type: mapEventTile.getType(),
|
||||
positionX: mapEventTile.getPositionX(),
|
||||
positionY: mapEventTile.getPositionY(),
|
||||
teleport: mapEventTile.getTeleport()
|
||||
? {
|
||||
toMap: mapEventTile.getTeleport()?.getToMap().getId(),
|
||||
toPositionX: mapEventTile.getTeleport()?.getToPositionX(),
|
||||
toPositionY: mapEventTile.getTeleport()?.getToPositionY(),
|
||||
toRotation: mapEventTile.getTeleport()?.getToRotation()
|
||||
}
|
||||
: undefined
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user