{
  "code": "var Sprite3D = Laya.Sprite3D;\r\nimport { EventManager } from \"./EventManager\";\r\nimport { Runner } from \"./Runner\";\r\nimport { GameState } from \"./GameManager\";\r\nexport class MeshSprite3DData {\r\n    constructor(_sprite) {\r\n        this.ownSprite = _sprite;\r\n        this.position = _sprite.transform.position.clone();\r\n        this.rotation = _sprite.transform.rotation.clone();\r\n        this.scale = _sprite.transform.scale.clone();\r\n    }\r\n}\r\nexport default class PoolManager {\r\n    constructor() {\r\n        this.PoolSize = 30;\r\n        this.ObjDic = {};\r\n        PoolManager.PoolManagerInstance = this;\r\n        EventManager.GameStateEventOn(GameState.Idle, this, this.ClearPool);\r\n    }\r\n    static get Instance() {\r\n        if (PoolManager.PoolManagerInstance) {\r\n            return PoolManager.PoolManagerInstance;\r\n        }\r\n        else {\r\n            var instance = new PoolManager();\r\n            return instance;\r\n        }\r\n    }\r\n    CreatMeshSprite3D(_obj, _group) {\r\n        var objName = _group + _obj.name;\r\n        if (this.ObjDic[objName] != null && this.ObjDic[objName] != undefined) {\r\n            if (this.ObjDic[objName].length > 0) {\r\n                var obj = this.ObjDic[objName][0];\r\n                this.ObjDic[objName].splice(0, 1);\r\n                if (obj.ownSprite.destroyed) {\r\n                    obj.ownSprite = Sprite3D.instantiate(_obj);\r\n                }\r\n                obj.ownSprite.active = true;\r\n                obj.ownSprite.transform.position = _obj.transform.position.clone();\r\n                obj.ownSprite.transform.rotation = _obj.transform.rotation.clone();\r\n                obj.ownSprite.transform.scale = _obj.transform.scale.clone();\r\n                return obj.ownSprite;\r\n            }\r\n            else {\r\n                return Sprite3D.instantiate(_obj);\r\n            }\r\n        }\r\n        else {\r\n            return Sprite3D.instantiate(_obj);\r\n        }\r\n    }\r\n    RecoverMeshSprite3D(_obj, _group = \"\", _destory = false) {\r\n        if (!_obj) {\r\n            return;\r\n        }\r\n        if (_destory) {\r\n            _obj.destroy();\r\n            return;\r\n        }\r\n        if (_obj.destroyed) {\r\n            return;\r\n        }\r\n        if (_obj.active == false) {\r\n            return;\r\n        }\r\n        var objName = _group + _obj.name;\r\n        if (this.ObjDic[objName] != null && this.ObjDic[objName] != undefined) {\r\n            var array = this.ObjDic[objName];\r\n            if (array.length > this.PoolSize) {\r\n                _obj.destroy();\r\n                return;\r\n            }\r\n            else {\r\n                array.push(new MeshSprite3DData(_obj));\r\n            }\r\n        }\r\n        else {\r\n            array = [];\r\n            array.push(new MeshSprite3DData(_obj));\r\n            this.ObjDic[objName] = array;\r\n        }\r\n        var runner = _obj.getComponent(Runner);\r\n        if (runner)\r\n            runner.destroy();\r\n        var rig = _obj.getComponent(Laya.Rigidbody3D);\r\n        if (rig) {\r\n            rig.isKinematic = true;\r\n            rig.detectCollisions = false;\r\n        }\r\n        _obj.transform.position = new Laya.Vector3(0, 0, -100);\r\n        _obj.removeSelf();\r\n        _obj.active = false;\r\n    }\r\n    ClearPool() {\r\n        for (var key in this.ObjDic) {\r\n            var objs = this.ObjDic[key];\r\n            for (var i = 0; i < objs.length; i++) {\r\n                objs[i].ownSprite.destroy();\r\n            }\r\n        }\r\n        this.ObjDic = {};\r\n    }\r\n}\r\n//# sourceMappingURL=PoolManager.js.map",
  "references": [
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/EventManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/Runner.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/GameManager.ts"
  ],
  "map": "{\"version\":3,\"file\":\"PoolManager.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../../src/Scripts/Game/PoolManager.ts\"],\"names\":[],\"mappings\":\"AACA,IAAO,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAa,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAO,gBAAgB;IAEzB,YAAY,OAAgB;QAExB,IAAI,C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