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 { Zone } from './zone'
|
|
import { ZoneEventTileTeleport } from './zoneEventTileTeleport'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
import { ZoneEventTileType } from '#application/enums'
|
|
import { UUID } from '#application/types'
|
|
|
|
@Entity()
|
|
export class ZoneEventTile extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
zone!: Zone
|
|
|
|
@Enum(() => ZoneEventTileType)
|
|
type!: ZoneEventTileType
|
|
|
|
@Property()
|
|
positionX!: number
|
|
|
|
@Property()
|
|
positionY!: number
|
|
|
|
@OneToOne(() => ZoneEventTileTeleport, (teleport) => teleport.zoneEventTile)
|
|
teleport?: ZoneEventTileTeleport
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setZone(zone: Zone) {
|
|
this.zone = zone
|
|
return this
|
|
}
|
|
|
|
getZone() {
|
|
return this.zone
|
|
}
|
|
|
|
setType(type: ZoneEventTileType) {
|
|
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: ZoneEventTileTeleport) {
|
|
this.teleport = teleport
|
|
return this
|
|
}
|
|
|
|
getTeleport() {
|
|
return this.teleport
|
|
}
|
|
}
|