// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import AniList from "./aniList";
import MonsterFactory from "./monsterFactory";

const {ccclass, property, executeInEditMode, playOnFocus} = cc._decorator;

@ccclass
@executeInEditMode
@playOnFocus
export default class MonsterPlay extends cc.Component {


    protected onFocusInEditor(): void {
        let arr = this.getComponentsInChildren(MonsterFactory);
        arr.forEach(v=>{
            v.end();
            v.play();
        });

        this.getComponentsInChildren(AniList).forEach(v=>{
            v.end();
            v.play();
        });
    }

    protected onLostFocusInEditor(): void {
        let arr = this.getComponentsInChildren(MonsterFactory);
        arr.forEach(v=>{
            v.end();
        });

        this.getComponentsInChildren(AniList).forEach(v=>{
            v.end();
        });
    }
}
