import { Component, _decorator, v3, Collider, Layers, CapsuleCollider } from "cc";
import { Vehicle } from "../Vehicle";
import { MoveToComp } from "../../common/ecs/position/MoveTo";
import { VehicleSitComp } from "../bll/VehicleCheck";
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { Puppet } from "../../puppet/puppet";
import { PuppetModelComp } from "../../puppet/model/PuppetModelComp";
import { smc } from "../../common/SingletonModuleComp";
import { PuppetAnimatorType } from "../../puppet/model/PuppetEnum";


const { ccclass, property } = _decorator;

/** 车辆控制 */
@ccclass('VehicleViewController')
export class VehicleViewController extends Component {
    /** 角色对象 */
    vehicle: Vehicle = null!;

    onLoad() {
        const collider = this.node.getComponent(Collider);
        if (collider) {
            collider.on('onTriggerEnter', this.onTriggerEnter, this);
        }
    }

    onTriggerEnter(event, self) {
        const { otherCollider } = event
        // 确认触发事件的对象是玩家
        // console.log('车辆检测到碰撞')
        if (otherCollider.node.layer === Layers.Enum.PUPPET) {
            // console.log('车辆碰撞事件')
            this.vehicle.VehicleView.ske.play('opendoor'); // 播放开门动画
            // this.vehicle.add(VehicleSitComp)
            // if (this.vehicle.VehicleModel.isFull)
            //     this.vehicle.VehicleModel.ready = true
            // this.createPuppet(this.vehicle)
        }
    }




    onDestroy() {

    }
}