123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- 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=fae2f1c33de6350c26fec47c7441e277eec07bcd.js.map
|