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AAC;YACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;YAEnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,+BAAc,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CACtC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EACrB,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EACjB,EAAE,CAAC,KAAK,CACJ,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EACtB,EAAE,CAAC,QAAQ,CACP,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAClB,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAClB,CACJ,CACJ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACT,IAAI,IAAI,EAAE;oBACN,IAAK,IAAY,CAAC,KAAK,EAAE;wBACrB,iCAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;qBACjC;yBAAM;wBACH,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;qBAC/B;iBACJ;gBACD,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAjCe,4BAAe,kBAiC9B,CAAA;AACL,CAAC,EAzFgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAyF5B","file":"","sourceRoot":"/","sourcesContent":["import { NodePoolFactory } from \"../../utils/NodePoolFactory\";\r\nimport { AnimationUtils } from \"../../utils/AnimationUtils\";\r\nimport SpecialToast, { SpecialToastType } from \"../../../game/ui/SpecialToast\";\r\n\r\nexport namespace ToastManager {\r\n    const path = \"prefab/ui/Toast\";\r\n    const specialPath = \"prefab/ui/SpecialToast\";\r\n    let nodeCount = 0;\r\n\r\n    let initialized = false;\r\n    export async function init() {\r\n        if (!initialized) {\r\n            await NodePoolFactory.createPool(path, 3);\r\n            await NodePoolFactory.createPool(specialPath, 3);\r\n            initialized = true;\r\n        }\r\n    }\r\n\r\n    export function addToast(parent: cc.Node, content: string | cc.Node, time: number = 0.6) {\r\n        let node = typeof content === \"string\" ? NodePoolFactory.getNode(path) : content;\r\n        if (node) {\r\n            nodeCount++;\r\n            if (typeof content === \"string\") {\r\n                let textComp = node.getChildByName(\"text\").getComponent(cc.RichText);\r\n                textComp.string = content;\r\n\r\n                node.height = textComp.node.height + 10;\r\n            }\r\n            node.stopAllActions();\r\n            node.x = 0;\r\n            node.y = 0;\r\n            node.scaleX = 0;\r\n            node.scaleY = 0;\r\n            node.opacity = 255;\r\n\r\n            node.parent = parent;\r\n            AnimationUtils.runAction(node, cc.sequence(\r\n                cc.scaleTo(0.2, 1, 1),\r\n                cc.delayTime(0.2),\r\n                cc.spawn(\r\n                    cc.moveBy(0.8, 0, 100),\r\n                    cc.sequence(\r\n                        cc.delayTime(time),\r\n                        cc.fadeOut(0.2)\r\n                    )\r\n                )\r\n            )).then(() => {\r\n                if (node) {\r\n                    if ((node as any)._path) {\r\n                        NodePoolFactory.putNode(node);\r\n                    } else {\r\n                        node.removeFromParent(true);\r\n                    }\r\n                }\r\n                nodeCount--;\r\n            });\r\n        }\r\n    }\r\n\r\n    export function addSpecialToast(parent: cc.Node, type: SpecialToastType, time: number = 0.6) {\r\n        let node = NodePoolFactory.getNode(specialPath);\r\n        if (node) {\r\n            node.getComponent(SpecialToast).setData(type);;\r\n            node.stopAllActions();\r\n            node.x = 0;\r\n            node.y = 0;\r\n            node.scaleX = 0;\r\n            node.scaleY = 0;\r\n            node.opacity = 255;\r\n\r\n            node.parent = parent;\r\n            AnimationUtils.runAction(node, cc.sequence(\r\n                cc.scaleTo(0.2, 1, 1),\r\n                cc.delayTime(0.2),\r\n                cc.spawn(\r\n                    cc.moveBy(0.8, 0, 100),\r\n                    cc.sequence(\r\n                        cc.delayTime(time),\r\n                        cc.fadeOut(0.2)\r\n                    )\r\n                )\r\n            )).then(() => {\r\n                if (node) {\r\n                    if ((node as any)._path) {\r\n                        NodePoolFactory.putNode(node);\r\n                    } else {\r\n                        node.removeFromParent(true);\r\n                    }\r\n                }\r\n                nodeCount--;\r\n            });\r\n        }\r\n    }\r\n}"]}