server/src/entities/base/placedMapObject.ts

85 lines
1.4 KiB
TypeScript

import { randomUUID } from 'node:crypto'
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { BaseEntity } from '#application/base/baseEntity'
import { UUID } from '#application/types'
import { Map } from '#entities/map'
import { MapObject } from '#entities/mapObject'
//@TODO : Rename mapObject
export class BasePlacedMapObject extends BaseEntity {
@PrimaryKey()
id = randomUUID()
@ManyToOne({ deleteRule: 'cascade' })
map!: Map
@ManyToOne({ deleteRule: 'cascade', eager: true })
mapObject!: MapObject
@Property()
isRotated = false
@Property()
positionX = 0
@Property()
positionY = 0
setId(id: UUID) {
this.id = id
return this
}
getId() {
return this.id
}
setMap(map: Map) {
this.map = map
return this
}
getMap() {
return this.map
}
setMapObject(mapObject: MapObject) {
this.mapObject = mapObject
return this
}
getMapObject() {
return this.mapObject
}
setIsRotated(isRotated: boolean) {
this.isRotated = isRotated
return this
}
getIsRotated() {
return this.isRotated
}
setPositionX(positionX: number) {
this.positionX = positionX
return this
}
getPositionX() {
return this.positionX
}
setPositionY(positionY: number) {
this.positionY = positionY
return this
}
getPositionY() {
return this.positionY
}
}