0ceb4243222791273c0ecc056e9e57c84185fc0d.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Animation, _decorator, AnimatorBase, _dec, _dec2, _dec3, _class, _crd, ccclass, property, requireComponent, disallowMultiple, menu, help, AnimatorAnimation;
  4. function _reportPossibleCrUseOfAnimatorBase(extras) {
  5. _reporterNs.report("AnimatorBase", "./core/AnimatorBase", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfAnimationPlayer(extras) {
  8. _reporterNs.report("AnimationPlayer", "./core/AnimatorBase", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfAnimatorStateLogic(extras) {
  11. _reporterNs.report("AnimatorStateLogic", "./core/AnimatorStateLogic", _context.meta, extras);
  12. }
  13. return {
  14. setters: [function (_unresolved_) {
  15. _reporterNs = _unresolved_;
  16. }, function (_cc) {
  17. _cclegacy = _cc.cclegacy;
  18. __checkObsolete__ = _cc.__checkObsolete__;
  19. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  20. Animation = _cc.Animation;
  21. _decorator = _cc._decorator;
  22. }, function (_unresolved_2) {
  23. AnimatorBase = _unresolved_2.default;
  24. }],
  25. execute: function () {
  26. _crd = true;
  27. _cclegacy._RF.push({}, "64571Qy/TlCEZI/28RxIG+E", "AnimatorAnimation", undefined);
  28. __checkObsolete__(['Animation', 'AnimationState', '_decorator']);
  29. ({
  30. ccclass,
  31. property,
  32. requireComponent,
  33. disallowMultiple,
  34. menu,
  35. help
  36. } = _decorator);
  37. /**
  38. * Cocos Animation状态机组件
  39. */
  40. _export("default", AnimatorAnimation = (_dec = requireComponent(Animation), _dec2 = menu('OopsFramework/Animator/AnimatorAnimation (动画状态机)'), _dec3 = help('https://gitee.com/dgflash/oops-framework/wikis/pages?sort_id=12036279&doc_id=2873565'), ccclass(_class = disallowMultiple(_class = _dec(_class = _dec2(_class = _dec3(_class = class AnimatorAnimation extends (_crd && AnimatorBase === void 0 ? (_reportPossibleCrUseOfAnimatorBase({
  41. error: Error()
  42. }), AnimatorBase) : AnimatorBase) {
  43. constructor() {
  44. super(...arguments);
  45. /** Animation组件 */
  46. this._animation = null;
  47. /** 当前的动画实例 */
  48. this._animState = null;
  49. /** 记录初始的wrapmode */
  50. this._wrapModeMap = new Map();
  51. }
  52. start() {
  53. if (!this.PlayOnStart || this._hasInit) {
  54. return;
  55. }
  56. this._hasInit = true;
  57. this._animation = this.getComponent(Animation);
  58. this._animation.on(Animation.EventType.FINISHED, this.onAnimFinished, this);
  59. this._animation.on(Animation.EventType.LASTFRAME, this.onAnimFinished, this);
  60. if (this.AssetRawUrl !== null) {
  61. this.initJson(this.AssetRawUrl.json);
  62. }
  63. }
  64. /**
  65. * 手动初始化状态机,可传入0-3个参数,类型如下
  66. * - onStateChangeCall 状态切换时的回调
  67. * - stateLogicMap 各个状态逻辑控制
  68. * - animationPlayer 自定义动画控制
  69. * @override
  70. */
  71. onInit() {
  72. if (this.PlayOnStart || this._hasInit) {
  73. return;
  74. }
  75. this._hasInit = true;
  76. this.initArgs(...arguments);
  77. this._animation = this.getComponent(Animation);
  78. this._animation.on(Animation.EventType.FINISHED, this.onAnimFinished, this);
  79. this._animation.on(Animation.EventType.LASTFRAME, this.onAnimFinished, this);
  80. if (this.AssetRawUrl !== null) {
  81. this.initJson(this.AssetRawUrl.json);
  82. }
  83. }
  84. /**
  85. * 播放动画
  86. * @override
  87. * @param animName 动画名
  88. * @param loop 是否循环播放
  89. */
  90. playAnimation(animName, loop) {
  91. if (!animName) {
  92. return;
  93. }
  94. this._animation.play(animName);
  95. this._animState = this._animation.getState(animName);
  96. if (!this._animState) {
  97. return;
  98. }
  99. if (!this._wrapModeMap.has(this._animState)) {
  100. this._wrapModeMap.set(this._animState, this._animState.wrapMode);
  101. }
  102. this._animState.wrapMode = loop ? 2 : this._wrapModeMap.get(this._animState);
  103. }
  104. /**
  105. * 缩放动画播放速率
  106. * @override
  107. * @param scale 缩放倍率
  108. */
  109. scaleTime(scale) {
  110. if (this._animState) {
  111. this._animState.speed = scale;
  112. }
  113. }
  114. }) || _class) || _class) || _class) || _class) || _class));
  115. _cclegacy._RF.pop();
  116. _crd = false;
  117. }
  118. };
  119. });
  120. //# sourceMappingURL=0ceb4243222791273c0ecc056e9e57c84185fc0d.js.map