import { Vec3, v3 } from "cc";
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
import { VehicleType } from "./VehicleEnum";
import { SingletonModuleComp } from "../../common/SingletonModuleComp";


export enum VehicleState {
    Normal,
    Wait,
    Station,
    Leave
}

@ecs.register('VehicleModel')
export class VehicleModelComp extends ecs.Comp {


    private vm: any = {};

    private _color: string = "";
    private _type: string = 'car'
    private _path: string = ""
    private _capcity: number = 3
    private _useSit: number = 0
    private _status: number = VehicleState.Normal  // 0 正常 1 等待进站 2 站台 3出站
    private _ready: boolean = false

    get isFull(): boolean {
        return this._useSit >= this._capcity
    }

    get sitPos():Vec3[]{
        const vehicle =  ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelLevel.rtluCurrent.vehicleType
        switch (vehicle) {
            case VehicleType.CAR:
                return [v3(-0.5,0.2,0),v3(-0.1,0.2,0),v3(0.3,0.2,0)]
            case VehicleType.BUS:
                return [v3(-0.55,0.2,0),v3(-0.05,0.2,0),v3(0.45,0.2,0)]
            case VehicleType.AIRPLANT:
                return [v3(-0.9,0.6,0),v3(-0.3,0.6,0),v3(0.5,0.6,0)]
            default:
                return [v3(-0.5,0.2,0),v3(-0.1,0.2,0),v3(0.3,0.2,0)]
        }
      
    }

    // 车辆状态
    get status(): VehicleState {
        return this._status
    }

    set status(s: VehicleState) {
        this._status = s
    }

    // 车辆状态
    get ready(): boolean {
        return this._ready
    }

    set ready(r: boolean) {
        this._ready = r
    }

    /** 颜色 */
    get color(): string {
        return this._color;
    }
    set color(value: string) {
        this._color = value;
    }

    /** 模型类型 车-飞机 */
    get type(): string {
        return this._type;
    }
    set type(value: string) {
        this._type = value;
        // this.vm.type = value;
    }

    /** 模型路径 */
    get path(): string {
        return this._path;
    }
    set path(value: string) {
        this._path = value;
        // this.vm.path = value;
    }

    /** 容量 */
    get capcity(): number {
        return this._capcity;
    }
    set capcity(value: number) {
        this._capcity = value;
        // this.vm.capcity = value;
    }


    /** 上车席位 */
    get useSit(): number {
        return this._useSit;
    }
    set useSit(value: number) {
        this._useSit = value;
        // this.vm.useSit = value;
    }



    // vmAdd() {
    //     VM.add(this.vm, "Vehicle");
    // }

    // vmRemove() {
    //     this.vm.reset();
    //     VM.remove("Vehicle");
    // }

    reset() {
        // this.vmRemove();
    }
}

