import { randomUUID } from 'node:crypto' import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core' import { Sprite } from './sprite' import { BaseEntity } from '#application/base/baseEntity' import { UUID } from '#application/types' @Entity() export class SpriteAction extends BaseEntity { @PrimaryKey() id = randomUUID() @ManyToOne({ deleteRule: 'cascade' }) sprite!: Sprite @Property() action!: string @Property({ type: 'json', nullable: true }) sprites?: string[] @Property() originX = 0 @Property() originY = 0 @Property() isAnimated = false @Property() isLooping = false @Property() frameWidth = 0 @Property() frameHeight = 0 @Property() frameRate = 0 setId(id: UUID) { this.id = id return this } getId() { return this.id } setSprite(sprite: Sprite) { this.sprite = sprite return this } getSprite() { return this.sprite } setAction(action: string) { this.action = action return this } getAction() { return this.action } setSprites(sprites: string[]) { this.sprites = sprites return this } getSprites() { return this.sprites } setOriginX(originX: number) { this.originX = originX return this } getOriginX() { return this.originX } setOriginY(originY: number) { this.originY = originY return this } getOriginY() { return this.originY } setIsAnimated(isAnimated: boolean) { this.isAnimated = isAnimated return this } getIsAnimated() { return this.isAnimated } setIsLooping(isLooping: boolean) { this.isLooping = isLooping return this } getIsLooping() { return this.isLooping } setFrameWidth(frameWidth: number) { this.frameWidth = frameWidth return this } getFrameWidth() { return this.frameWidth } setFrameHeight(frameHeight: number) { this.frameHeight = frameHeight return this } getFrameHeight() { return this.frameHeight } setFrameRate(frameRate: number) { this.frameRate = frameRate return this } getFrameRate() { return this.frameRate } }