cb6ed17bd527d1a4e97fdce5c658fd1b32eb963a.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Animation, Component, ParticleSystem, _decorator, sp, EffectEvent, message, _dec, _class, _crd, ccclass, property, EffectFinishedRelease;
  4. function _reportPossibleCrUseOfEffectEvent(extras) {
  5. _reporterNs.report("EffectEvent", "./EffectEvent", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfmessage(extras) {
  8. _reporterNs.report("message", "../../core/common/event/MessageManager", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. Animation = _cc.Animation;
  18. Component = _cc.Component;
  19. ParticleSystem = _cc.ParticleSystem;
  20. _decorator = _cc._decorator;
  21. sp = _cc.sp;
  22. }, function (_unresolved_2) {
  23. EffectEvent = _unresolved_2.EffectEvent;
  24. }, function (_unresolved_3) {
  25. message = _unresolved_3.message;
  26. }],
  27. execute: function () {
  28. _crd = true;
  29. _cclegacy._RF.push({}, "a751fmayL5JMYH0D4uJoK5H", "EffectFinishedRelease", undefined);
  30. /*
  31. * @Author: dgflash
  32. * @Date: 2022-08-19 15:36:08
  33. * @LastEditors: dgflash
  34. * @LastEditTime: 2023-03-01 18:28:55
  35. */
  36. __checkObsolete__(['Animation', 'Component', 'ParticleSystem', '_decorator', 'sp']);
  37. ({
  38. ccclass,
  39. property
  40. } = _decorator);
  41. /** 动画播放完释放特效 - Animation、ParticleSystem */
  42. _export("EffectFinishedRelease", EffectFinishedRelease = (_dec = ccclass('EffectFinishedRelease'), _dec(_class = class EffectFinishedRelease extends Component {
  43. constructor(...args) {
  44. super(...args);
  45. /** 动画最大播放时间 */
  46. this.maxDuration = 0;
  47. }
  48. onEnable() {
  49. // SPINE动画
  50. let spine = this.getComponent(sp.Skeleton);
  51. if (spine) {
  52. // 播放第一个动画
  53. let json = spine.skeletonData.skeletonJson.animations;
  54. for (let name in json) {
  55. spine.setCompleteListener(this.onRecovery.bind(this));
  56. spine.setAnimation(0, name, false);
  57. break;
  58. }
  59. } else {
  60. // COCOS动画
  61. let anims = this.node.getComponentsInChildren(Animation);
  62. if (anims.length > 0) {
  63. anims.forEach(animator => {
  64. var _animator$defaultClip;
  65. let aniName = (_animator$defaultClip = animator.defaultClip) == null ? void 0 : _animator$defaultClip.name;
  66. if (aniName) {
  67. let aniState = animator.getState(aniName);
  68. if (aniState) {
  69. let duration = aniState.duration;
  70. this.maxDuration = duration > this.maxDuration ? duration : this.maxDuration;
  71. }
  72. }
  73. animator.play();
  74. });
  75. this.scheduleOnce(this.onRecovery.bind(this), this.maxDuration);
  76. } // 粒子动画
  77. else if (ParticleSystem) {
  78. let particles = this.node.getComponentsInChildren(ParticleSystem);
  79. particles.forEach(particle => {
  80. particle.clear();
  81. particle.stop();
  82. particle.play();
  83. let duration = particle.duration;
  84. this.maxDuration = duration > this.maxDuration ? duration : this.maxDuration;
  85. });
  86. this.scheduleOnce(this.onRecovery.bind(this), this.maxDuration);
  87. }
  88. }
  89. }
  90. onRecovery() {
  91. if (this.node.parent) (_crd && message === void 0 ? (_reportPossibleCrUseOfmessage({
  92. error: Error()
  93. }), message) : message).dispatchEvent((_crd && EffectEvent === void 0 ? (_reportPossibleCrUseOfEffectEvent({
  94. error: Error()
  95. }), EffectEvent) : EffectEvent).Put, this.node);
  96. }
  97. }) || _class));
  98. _cclegacy._RF.pop();
  99. _crd = false;
  100. }
  101. };
  102. });
  103. //# sourceMappingURL=cb6ed17bd527d1a4e97fdce5c658fd1b32eb963a.js.map