import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('animations')
export class AnimationEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 50 }) category: string;
    @Column({ type: 'varchar', length: 30, unique: true }) command: string;
    @Column({ type: 'varchar', length: 130 }) dict: string;
    @Column({ type: 'varchar', length: 130 }) name: string;
    @Column({ type: 'int', default: 1 }) speed: number;
    @Column({ type: 'int' }) flag: number;
    @Column({ type: 'varchar', length: 100 }) description: string;
    @Column({ type: 'int', default: 0 }) allowed_in_vehicle: number;
    @Column({ type: 'varchar', default: null, nullable: true }) attached_object_model: string;
    @Column({ type: 'int', default: null, nullable: true }) attached_object_bone: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_pos_x: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_pos_y: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_pos_z: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_rot_x: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_rot_y: number;
    @Column({ type: 'float', default: null, nullable: true }) attached_object_rot_z: number;

    get attachedObjectPos(): Vector3 {
        return new mp.Vector3(this.attached_object_pos_x, this.attached_object_pos_y, this.attached_object_pos_z);
    }

    get attachedObjectRot(): Vector3 {
        return new mp.Vector3(this.attached_object_rot_x, this.attached_object_rot_y, this.attached_object_rot_z);
    }
}
