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