7473ce01db9380cb13080d7142a9942ea2897aff.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, AnimatorCondition, ParamType, AnimatorTransition, _crd;
  4. function _reportPossibleCrUseOfAnimatorCondition(extras) {
  5. _reporterNs.report("AnimatorCondition", "./AnimatorCondition", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfParamType(extras) {
  8. _reporterNs.report("ParamType", "./AnimatorCondition", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfAnimatorController(extras) {
  11. _reporterNs.report("AnimatorController", "./AnimatorController", _context.meta, extras);
  12. }
  13. _export("default", void 0);
  14. return {
  15. setters: [function (_unresolved_) {
  16. _reporterNs = _unresolved_;
  17. }, function (_cc) {
  18. _cclegacy = _cc.cclegacy;
  19. }, function (_unresolved_2) {
  20. AnimatorCondition = _unresolved_2.default;
  21. ParamType = _unresolved_2.ParamType;
  22. }],
  23. execute: function () {
  24. _crd = true;
  25. _cclegacy._RF.push({}, "39224xRIkpEG7hvPJlKoGDy", "AnimatorTransition", undefined);
  26. /**
  27. * 状态过渡类
  28. */
  29. _export("default", AnimatorTransition = class AnimatorTransition {
  30. constructor(data, ac) {
  31. this._toStateName = '';
  32. this._hasExitTime = false;
  33. this._conditions = [];
  34. this._ac = null;
  35. this._toStateName = data.toState;
  36. this._hasExitTime = data.hasExitTime;
  37. this._ac = ac;
  38. for (var i = 0; i < data.conditions.length; i++) {
  39. var condition = new (_crd && AnimatorCondition === void 0 ? (_reportPossibleCrUseOfAnimatorCondition({
  40. error: Error()
  41. }), AnimatorCondition) : AnimatorCondition)(data.conditions[i], ac);
  42. this._conditions.push(condition);
  43. }
  44. }
  45. /**
  46. * 返回该transition是否有效,当未勾选hasExitTime以及没有添加任何condition时此transition无效并忽略
  47. */
  48. isValid() {
  49. return this._hasExitTime || this._conditions.length > 0;
  50. }
  51. /**
  52. * 判断是否满足所有转换条件
  53. */
  54. check() {
  55. if (this._toStateName === this._ac.curState.name) {
  56. return false;
  57. }
  58. if (this._hasExitTime && (this._ac.curState !== this._ac.animCompleteState || !this._ac.animComplete)) {
  59. return false;
  60. }
  61. for (var i = 0; i < this._conditions.length; i++) {
  62. if (!this._conditions[i].check()) {
  63. return false;
  64. }
  65. }
  66. return true;
  67. }
  68. /**
  69. * 转换状态
  70. */
  71. doTrans() {
  72. // 满足条件时重置动画播完标记
  73. if (this._hasExitTime) {
  74. this._ac.animComplete = false;
  75. } // 满足状态转换条件时重置trigger和autoTrigger
  76. for (var i = 0; i < this._conditions.length; i++) {
  77. var type = this._conditions[i].getParamType();
  78. var name = this._conditions[i].getParamName();
  79. if (type === (_crd && ParamType === void 0 ? (_reportPossibleCrUseOfParamType({
  80. error: Error()
  81. }), ParamType) : ParamType).TRIGGER) {
  82. this._ac.params.resetTrigger(name);
  83. } else if (type === (_crd && ParamType === void 0 ? (_reportPossibleCrUseOfParamType({
  84. error: Error()
  85. }), ParamType) : ParamType).AUTO_TRIGGER) {
  86. this._ac.params.resetAutoTrigger(name);
  87. }
  88. }
  89. this._ac.changeState(this._toStateName);
  90. }
  91. });
  92. _cclegacy._RF.pop();
  93. _crd = false;
  94. }
  95. };
  96. });
  97. //# sourceMappingURL=7473ce01db9380cb13080d7142a9942ea2897aff.js.map