import Pool from "../MComponents/Pool";
import Bullet from "../Game/Bullet";
import { MConst } from "../Global/MConst";
import PoolMgr from "./PoolMgr";
import MainScene from "../Scene/MainScene";
import GameMgr from "./GameMgr";
import GameObject from "../Game/GameObject";

export default class ParticleMgr {
    private data: Bullet[] = [];

    private layer: egret.DisplayObjectContainer = null;
    constructor(layer: egret.DisplayObjectContainer) {
        this.layer = layer;
    }

    create(context: MainScene) {
        if (this.data.length > 0) {
            let e = this.data.pop();
            e.onElementInit();
            return e;
        } else {
            let b = new Bullet(context);
            this.layer.addChild(b);
            return b;
        }
    }

    destroy(bullet: Bullet) {
        bullet.onElementRecycle();
        this.data.push(bullet);
    }
}