85 lines
1.4 KiB
TypeScript
85 lines
1.4 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
import { Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
import type { UUID } from '#application/types'
|
|
import type { Map } from '#entities/map'
|
|
import type { MapEventTileTeleport } from '#entities/mapEventTileTeleport'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
import { MapEventTileType } from '#application/enums'
|
|
|
|
export class BaseMapEventTile extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
map!: Map
|
|
|
|
@Enum(() => MapEventTileType)
|
|
type!: MapEventTileType
|
|
|
|
@Property()
|
|
positionX!: number
|
|
|
|
@Property()
|
|
positionY!: number
|
|
|
|
@OneToOne({ eager: true })
|
|
teleport?: MapEventTileTeleport
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setMap(map: Map) {
|
|
this.map = map
|
|
return this
|
|
}
|
|
|
|
getMap() {
|
|
return this.map
|
|
}
|
|
|
|
setType(type: MapEventTileType) {
|
|
this.type = type
|
|
return this
|
|
}
|
|
|
|
getType() {
|
|
return this.type
|
|
}
|
|
|
|
setPositionX(positionX: number) {
|
|
this.positionX = positionX
|
|
return this
|
|
}
|
|
|
|
getPositionX() {
|
|
return this.positionX
|
|
}
|
|
|
|
setPositionY(positionY: number) {
|
|
this.positionY = positionY
|
|
return this
|
|
}
|
|
|
|
getPositionY() {
|
|
return this.positionY
|
|
}
|
|
|
|
setTeleport(teleport: MapEventTileTeleport) {
|
|
this.teleport = teleport
|
|
return this
|
|
}
|
|
|
|
getTeleport() {
|
|
return this.teleport
|
|
}
|
|
}
|