forked from noxious/server
Created base entities, extended normal entities with these
This commit is contained in:
@ -1,97 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Entity } from '@mikro-orm/core'
|
||||
|
||||
import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
||||
import { BasePlacedMapObject } from '#entities/base/placedMapObject'
|
||||
|
||||
import { Map } from './map'
|
||||
|
||||
import { BaseEntity } from '#application/base/baseEntity'
|
||||
import { UUID } from '#application/types'
|
||||
import { MapObject } from '#entities/mapObject'
|
||||
|
||||
//@TODO : Rename mapObject
|
||||
@Entity()
|
||||
export class PlacedMapObject extends BaseEntity {
|
||||
@PrimaryKey()
|
||||
id = randomUUID()
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade' })
|
||||
map!: Map
|
||||
|
||||
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
||||
mapObject!: MapObject
|
||||
|
||||
@Property()
|
||||
depth = 0
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
setDepth(depth: number) {
|
||||
this.depth = depth
|
||||
return this
|
||||
}
|
||||
|
||||
getDepth() {
|
||||
return this.depth
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
export class PlacedMapObject extends BasePlacedMapObject {}
|
||||
|
Reference in New Issue
Block a user