import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { RoadblockSceneEntity } from './roadblock-scene.entity';

@Entity('roadblocks')
export class RoadblockEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 128 }) model: string;
    @Column({ type: 'varchar', length: 128 }) name: string;
    @Column() roadblock_scene_id: number;
    @Column({ type: 'float' }) x: number;
    @Column({ type: 'float' }) y: number;
    @Column({ type: 'float' }) z: number;
    @Column({ type: 'float' }) rx: number;
    @Column({ type: 'float' }) ry: number;
    @Column({ type: 'float' }) rz: number;
    @Column() dimension: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'varchar', length: 128 }) created_by: string;
    @Column() created_by_character_id: number;

    @ManyToOne(() => RoadblockSceneEntity, (rbse) => rbse.roadblocks)
    @JoinColumn({ name: 'roadblock_scene_id' })
    scene: RoadblockSceneEntity;

    get position(): Vector3 {
        return new mp.Vector3(this.x, this.y, this.z);
    }

    get rotation(): Vector3 {
        return new mp.Vector3(this.rx, this.ry, this.rz);
    }

    object?: ObjectMp;
}
