forked from noxious/server
81 lines
1.3 KiB
TypeScript
81 lines
1.3 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
import { BaseEntity } from '@/application/base/baseEntity'
|
|
import type { UUID } from '@/application/types'
|
|
import type { Map } from '@/entities/map'
|
|
import type { MapObject } from '@/entities/mapObject'
|
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
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
|
|
}
|
|
}
|