f8d148f31bf8ae088bac9cab5fd2990e8c8b41ec.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, State, _crd;
  4. function get_new_state() {
  5. return new State();
  6. }
  7. _export("default", get_new_state);
  8. return {
  9. setters: [function (_cc) {
  10. _cclegacy = _cc.cclegacy;
  11. }],
  12. execute: function () {
  13. _crd = true;
  14. _cclegacy._RF.push({}, "d9db0FDjAhNuLA9MVTSVAgv", "State", undefined);
  15. /*enum states{
  16. Read = 1, //0001
  17. Write = 2, //0010
  18. Create = 4,//0100
  19. Delete = 8 //1000
  20. }/**状态类型不算合并的不超过32种
  21. export enum StateType {
  22. Unmatched = 1<<1,//无敌
  23. Swoon = 1<<2,//晕眩
  24. }*/
  25. /**状态对像*/
  26. State = class State {
  27. constructor() {
  28. this._state = 0;
  29. }
  30. //无状态
  31. Init() {
  32. this._state = 0;
  33. }
  34. /**是否满足传入的状态*/
  35. Meet(state) {
  36. return State.Has(this._state, state);
  37. }
  38. /**传入的状态是组合型时只要满足其一 */
  39. MeetAny(state) {
  40. let a = this._state & state;
  41. if (a === state) return true;
  42. if (a == 0) return false;
  43. return State.Has(state, a);
  44. }
  45. /**是否满足所有传入的状态*/
  46. MeetAll(...params) {
  47. let result = 0;
  48. for (let i = 0; i < params.length; i++) {
  49. result |= params[i];
  50. }
  51. return this.Meet(State.CombieState(result));
  52. }
  53. /**是否满足其中传入的状态*/
  54. MeetAnyOne(...params) {
  55. for (let i = 0; i < params.length; i++) {
  56. if (this.Meet(params[i])) return true;
  57. }
  58. return false;
  59. }
  60. /**加入状态*/
  61. Add(state) {
  62. this._state |= state;
  63. }
  64. /**删除状态*/
  65. Delete(state) {
  66. if (!this.Meet(state)) return;
  67. this._state ^= state;
  68. }
  69. /**转成状态*/
  70. static ToState(Id) {
  71. return 1 << Id;
  72. }
  73. /**合并状态*/
  74. static CombieState(...params) {
  75. let result = 0;
  76. for (let i = 0; i < params.length; i++) {
  77. result |= params[i];
  78. }
  79. return result;
  80. }
  81. static Has(statss, state) {
  82. return (statss & state) === state;
  83. }
  84. };
  85. _cclegacy._RF.pop();
  86. _crd = false;
  87. }
  88. };
  89. });
  90. //# sourceMappingURL=f8d148f31bf8ae088bac9cab5fd2990e8c8b41ec.js.map