import { Color, MeshRenderer, RenderableComponent, SkeletalAnimation, _decorator } from "cc";
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { Subway } from "../Subway";
import { SubwayViewController } from "./SubwayViewController";
import { smc } from "../../common/SingletonModuleComp";
import { Puppet } from "../../puppet/puppet";
import { PuppetModelComp } from "../../puppet/model/PuppetModelComp";
import { PuppetAnimatorType } from "../../puppet/model/PuppetEnum";
import { SubwayEnum } from "../model/SubwayEnum";
import { Label3D } from "../../../components/label-3d";
import { SubwayGenPuppetComp } from "../bll/SubwayGenPuppet";


const { ccclass, property } = _decorator;

/** 地铁显示组件 */
@ccclass('SubwayViewComp')                   // 定义为 Cocos Creator 组件
@ecs.register('SubwayView', false)           // 定义为 ECS 组件
export class SubwayViewComp extends CCComp {

    @property({ type: Label3D, tooltip: '角色动画' })
    label: Label3D = null!;
    /** 地铁控制器 */
    controller: SubwayViewController = null!;

    /** 视图层逻辑代码分离演示 */
    onLoad() {
        const subway = this.ent as Subway;

        this.controller = this.node.addComponent(SubwayViewController);
        this.controller.subway = subway;
        const timer = setTimeout(() => {
            this.updateCount(subway?.SubwayModel.colorArr.length)
            clearTimeout(timer)
        }, 0)
    }

    updateCount(count = 0) {
        if (this.label)
            this.label.string = `${count}`
    }


    reset() {
        this.node.destroy();
    }
}