import { v3 } from "cc";
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { MoveToComp } from "../../common/ecs/position/MoveTo";
import { Vehicle } from "../Vehicle";
import { VehicleModelComp } from "../model/VehicleModelComp";


/** 检查车是不是满的，满了开走 */
@ecs.register('VehicleSit')
export class VehicleSitComp extends ecs.Comp {
    reset() { }
}

export class VehicleSitSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
    filter(): ecs.IMatcher {
        return ecs.allOf(VehicleSitComp,VehicleModelComp);
    }

    entityEnter(e: Vehicle): void {
          e.VehicleModel.useSit+=1
          console.log('车上人数加1')
        //   if(e.VehicleModel.useSit>=e.VehicleModel.capcity){
        //     console.log('车满了，开走')
        //     const moveTo =  e.add(MoveToComp)
        //     moveTo.target = v3(0,1000,0)
        //   }
          e.remove(VehicleSitComp)
    }

}