forked from noxious/server
86 lines
1.5 KiB
TypeScript
86 lines
1.5 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
import { Entity, Enum, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
import { Map } from './map'
|
|
import { MapEventTileTeleport } from './mapEventTileTeleport'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
import { MapEventTileType } from '#application/enums'
|
|
import { UUID } from '#application/types'
|
|
|
|
@Entity()
|
|
export class MapEventTile extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
map!: Map
|
|
|
|
@Enum(() => MapEventTileType)
|
|
type!: MapEventTileType
|
|
|
|
@Property()
|
|
positionX!: number
|
|
|
|
@Property()
|
|
positionY!: number
|
|
|
|
@OneToOne(() => MapEventTileTeleport, (teleport) => teleport.mapEventTile, { 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
|
|
}
|
|
}
|