{
  "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",
  "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"
  ]
}
