8f89b48ccc3bce15708c7f9ae2fc26d22dc74d1f.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCFloat, game, SkeletalAnimation, _decorator, AnimatorAnimation, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _crd, ccclass, property, requireComponent, disallowMultiple, menu, help, AnimatorSkeletal;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfAnimatorAnimation(extras) {
  8. _reporterNs.report("AnimatorAnimation", "./AnimatorAnimation", _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. CCFloat = _cc.CCFloat;
  18. game = _cc.game;
  19. SkeletalAnimation = _cc.SkeletalAnimation;
  20. _decorator = _cc._decorator;
  21. }, function (_unresolved_2) {
  22. AnimatorAnimation = _unresolved_2.default;
  23. }],
  24. execute: function () {
  25. _crd = true;
  26. _cclegacy._RF.push({}, "8c545jBn4xF7LWXjl506avi", "AnimatorSkeletal", undefined);
  27. /*
  28. * @Author: dgflash
  29. * @Date: 2021-06-30 13:56:26
  30. * @LastEditors: dgflash
  31. * @LastEditTime: 2021-11-04 10:46:00
  32. */
  33. __checkObsolete__(['CCFloat', 'game', 'SkeletalAnimation', '_decorator']);
  34. ({
  35. ccclass,
  36. property,
  37. requireComponent,
  38. disallowMultiple,
  39. menu,
  40. help
  41. } = _decorator);
  42. _export("AnimatorSkeletal", AnimatorSkeletal = (_dec = requireComponent(SkeletalAnimation), _dec2 = menu('OopsFramework/Animator/AnimatorSkeletal (骨骼动画状态机)'), _dec3 = help('https://gitee.com/dgflash/oops-framework/wikis/pages?sort_id=12036279&doc_id=2873565'), _dec4 = property({
  43. type: CCFloat,
  44. tooltip: "动画切换过度时间"
  45. }), ccclass(_class = disallowMultiple(_class = _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class AnimatorSkeletal extends (_crd && AnimatorAnimation === void 0 ? (_reportPossibleCrUseOfAnimatorAnimation({
  46. error: Error()
  47. }), AnimatorAnimation) : AnimatorAnimation) {
  48. constructor() {
  49. super(...arguments);
  50. _initializerDefineProperty(this, "duration", _descriptor, this);
  51. this.cross_duration = 0;
  52. // 防止切换动画时间少于间隔时间导致动画状态错乱的问题
  53. this.current_time = 0;
  54. }
  55. // 上一次切换状态时间
  56. onLoad() {
  57. this.cross_duration = this.duration * 1000;
  58. }
  59. /**
  60. * 播放动画
  61. * @override
  62. * @param animName 动画名
  63. * @param loop 是否循环播放
  64. */
  65. playAnimation(animName, loop) {
  66. if (!animName) {
  67. return;
  68. }
  69. if (game.totalTime - this.current_time > this.cross_duration) {
  70. this._animation.crossFade(animName, this.duration);
  71. } else {
  72. this._animation.play(animName);
  73. }
  74. this.current_time = game.totalTime;
  75. this._animState = this._animation.getState(animName);
  76. if (!this._animState) {
  77. return;
  78. }
  79. if (!this._wrapModeMap.has(this._animState)) {
  80. this._wrapModeMap.set(this._animState, this._animState.wrapMode);
  81. } // this._animState.wrapMode = loop ? 2 : this._wrapModeMap.get(this._animState)!;
  82. this._animState.wrapMode = loop ? 2 : 1; // 2为循环播放,1为单次播放
  83. }
  84. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "duration", [_dec4], {
  85. configurable: true,
  86. enumerable: true,
  87. writable: true,
  88. initializer: function initializer() {
  89. return 0.3;
  90. }
  91. })), _class2)) || _class) || _class) || _class) || _class) || _class));
  92. _cclegacy._RF.pop();
  93. _crd = false;
  94. }
  95. };
  96. });
  97. //# sourceMappingURL=8f89b48ccc3bce15708c7f9ae2fc26d22dc74d1f.js.map