const { ccclass, property } = cc._decorator;

@ccclass
export default class NodeFollowHidden extends cc.Component {

    @property({
        type: cc.Node,
        displayName: "跟随节点"
    })
    followNodeList: cc.Node[] = [];

    @property({
        displayName: "是否反向跟随"
    })
    isReverseFollow: boolean = false;

    @property({
        displayName: "激活时是否触发"
    })
    useEnable: boolean = true;

    @property({
        displayName: "禁用时是否触发"
    })
    useDisable: boolean = true;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    // start() {}

    protected onEnable(): void {
        if (this.useEnable) {
            for (const iterator of this.followNodeList) {
                iterator.active = this.isReverseFollow ? !this.node.active : this.node.active;
            }
        }
    }

    protected onDisable(): void {
        if (this.useDisable) {
            for (const iterator of this.followNodeList) {
                iterator.active = this.isReverseFollow ? !this.node.active : this.node.active;
            }
        }
    }

    // update (dt) {}
}