12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- var t = require;
- var e = module;
- var i = exports;
- var s =
- (this && this.__decorate) ||
- function (t, e, i, s) {
- var o,
- a = arguments.length,
- n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
- else
- for (var r = t.length - 1; 0 <= r; r--)
- (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
- return 3 < a && n && Object.defineProperty(e, i, n), n;
- };
- Object.defineProperty(i, "__esModule", {value: !0});
- const {ccclass: o, property: a} = cc._decorator;
- e = class {
- constructor() {
- (this._pool = []), (this.createCnt = 0), (this.prefab = null);
- }
- push(t) {
- t && -1 === this._pool.indexOf(t) && ((t.active = !1), t.parent && t.removeFromParent(!1), this._pool.push(t));
- }
- push2(t, e) {
- this._pool.length >= e
- ? (t.removeFromParent(!0), t.destroy())
- : t &&
- -1 === this._pool.indexOf(t) &&
- ((t.active = !1), t.parent && t.removeFromParent(!1), this._pool.push(t));
- }
- pop() {
- if (0 === this._pool.length) {
- this.createCnt++;
- let t = cc.instantiate(this.prefab);
- return (t.pool = this), t;
- }
- {
- let t = this._pool.pop();
- return (t.active = !0), t;
- }
- }
- clear() {
- for (const t of this._pool) t.isValid && t.destroy();
- this._pool = null;
- }
- init(e) {
- this.createCnt += e;
- for (let t = 0; t < e; ++t) this._pool.push(cc.instantiate(this.prefab));
- }
- };
- s([a(cc.Prefab)], e.prototype, "prefab", void 0), (e = s([o("NodePool")], e)), (i.default = e);
|