
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/lq_base/util/lq_pool_util.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, '984882e2dpD17LvCQnTDykE', 'lq_pool_util');
// Script/lq_base/util/lq_pool_util.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LQPoolUtil = void 0;
var Animation = cc.Animation;
var ParticleSystem = cc.ParticleSystem;
var instantiate = cc.instantiate;
var LQPoolUtil = /** @class */ (function () {
    function LQPoolUtil() {
    }
    LQPoolUtil.reset_ani = function (node) {
        var ani = node.getComponent(Animation);
        if (ani) {
            var clip = ani.currentClip ? ani.currentClip : ani.defaultClip;
            if (!clip) {
                return;
            }
            if (ani.playOnLoad && clip && clip.wrapMode === cc.WrapMode.Normal) {
                ani.play(clip.name);
            }
        }
        else {
            var ani_1 = node.getComponent(sp.Skeleton);
            if (ani_1 && !ani_1.loop) {
                ani_1.setAnimation(0, ani_1.animation, false);
            }
        }
        for (var i = 0; i < node.childrenCount; i++) {
            var child = node.children[i];
            this.reset_ani(child);
        }
    };
    LQPoolUtil.recursion_stop_particle = function (node, obj) {
        var p = node.getComponent(ParticleSystem);
        if (p) {
            p.stopSystem();
            obj.has = true;
            p.node.opacity = 0;
        }
        for (var i = 0; i < node.childrenCount; i++) {
            var child = node.children[i];
            this.recursion_stop_particle(child, obj);
        }
    };
    LQPoolUtil.recursion_reset_particle = function (node) {
        if (!node.isValid) {
            return;
        }
        var p = node.getComponent(ParticleSystem);
        if (p) {
            p.resetSystem();
            p.node.opacity = 255;
        }
        for (var i = 0; i < node.childrenCount; i++) {
            var child = node.children[i];
            this.recursion_reset_particle(child);
        }
    };
    LQPoolUtil.get_node_from_pool = function (node_parent, prefab) {
        var arr = this.any_pool[prefab.uuid];
        if (!arr) {
            this.any_pool[prefab.uuid] = [];
            arr = [];
        }
        var node = arr.pop();
        if (!node || !node.isValid) {
            node = instantiate(prefab);
            //@ts-ignore
            node.recovery_uuid = prefab.uuid;
            //@ts-ignore
            node.is_from_pool = false;
            node_parent.addChild(node);
        }
        else {
            node.active = true;
            //@ts-ignore
            node.is_from_pool = true;
            this.reset_ani(node);
        }
        return node;
    };
    LQPoolUtil.check_pool_push = function (arr, node) {
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] === node) {
                //@ts-ignore
                console.warn("\u6C60\u5B50\u4E0D\u80FD\u91CD\u590D\u6DFB\u52A0\u8282\u70B9", node.name, node.recovery_uuid);
                return;
            }
        }
        node.active = false;
        arr.push(node);
    };
    LQPoolUtil.push_node_to_pool = function (node) {
        var _this = this;
        //@ts-ignore
        if (!node.recovery_uuid || !this.any_pool[node.recovery_uuid]) {
            if (node.isValid) {
                node.destroy();
            }
            return;
        }
        var obj = { has: false };
        this.recursion_stop_particle(node, obj);
        if (obj.has) {
            var old_opacity_1 = node.opacity;
            node.opacity = 0;
            setTimeout(function () {
                _this.recursion_reset_particle(node);
                node.opacity = old_opacity_1;
                //@ts-ignore
                _this.check_pool_push(_this.any_pool[node.recovery_uuid], node);
            }, 500);
        }
        else {
            //@ts-ignore
            this.check_pool_push(this.any_pool[node.recovery_uuid], node);
        }
    };
    LQPoolUtil.any_pool = {};
    return LQPoolUtil;
}());
exports.LQPoolUtil = LQPoolUtil;

cc._RF.pop();
                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 10540 characters]