System.register(["cc"], function (_export, _context) { "use strict"; var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Node, NodePool, instantiate, PrefabPool, _crd; function get_new_prefab_pool() { return new PrefabPool(); } _export("default", get_new_prefab_pool); return { setters: [function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; Node = _cc.Node; NodePool = _cc.NodePool; instantiate = _cc.instantiate; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "12f30kX+ltO4JZlGRue34gE", "PrefabPool", undefined); /** node对象池 */ __checkObsolete__(['Node', 'NodePool', 'Prefab', 'instantiate']); PrefabPool = class PrefabPool { constructor() { this._pools = new Map(); this._node = void 0; if (this._node == null) { this._node = new Node(); this._node.active = false; } } getPool(path) { let pool = this._pools.get(path); if (pool == null) { pool = new NodePool(); this._pools.set(path, pool); } return pool; } GetNode(p) { let pool = this.getPool(p.name); let node = pool.get(); if (!node) { node = instantiate(p); node.name = p.name; } return node; } RecNode(node) { node.parent = this._node; this.getPool(node.name).put(node); } InitPool(p, n = 10) { let pool = this.getPool(p.name); for (let i = 0; i < n; i++) { let node = instantiate(p); node.name = p.name; node.parent = this._node; pool.put(node); } } Clear() { if (!this._node) return; this._node.removeAllChildren(); this._pools.forEach((v, k) => { v.clear(); }); this._pools.clear(); } getAllPoolNames() { return Object.keys(this._pools); } getPoolSize(poolName) { const pool = this._pools[poolName]; if (pool) { return pool.size(); } return 0; } }; _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=8e81d067c8870d70331d8b9656a976c1f558e5de.js.map