60b06ae900f4cd994af68bc3e1b2e92c44cd1dae.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, FMS, _crd;
  4. /**注册一个继承IFMS的状态类型 */
  5. function FMSRegister(name) {
  6. return function (target) {
  7. var instance = new target();
  8. instance.type = name;
  9. FMS.IFMS.set(name, instance);
  10. };
  11. }
  12. /**状态接口*/
  13. function get_new_fms() {
  14. return new FMS();
  15. }
  16. _export({
  17. FMSRegister: FMSRegister,
  18. default: get_new_fms
  19. });
  20. return {
  21. setters: [function (_cc) {
  22. _cclegacy = _cc.cclegacy;
  23. }],
  24. execute: function () {
  25. _crd = true;
  26. _cclegacy._RF.push({}, "bbc25Bst09Pm7REKGq+Wn2J", "FMS", undefined);
  27. /**全局状态机,游戏流程 (私有有行为机更灵活)*/
  28. FMS = class FMS {
  29. constructor() {
  30. this._current = void 0;
  31. }
  32. /**当前状态*/
  33. get Current() {
  34. return this._current;
  35. }
  36. get CurrentTaype() {
  37. return this._current ? null : this._current.type;
  38. }
  39. /**初始1个状态*/
  40. Init(type) {
  41. this.Change(type);
  42. }
  43. /**切换状态*/
  44. Change(type) {
  45. if (this._current) this._current.onExit();
  46. this._current = FMS.IFMS.get(type);
  47. if (this._current) this._current.onEntry();
  48. }
  49. };
  50. /**例子:
  51. @FMSRegister("Init")
  52. export class FMSInit implements IFMS{
  53. type: string;
  54. onExit: () => void;
  55. onEntry():void{
  56. console.log(this.type,"---------------------");
  57. }
  58. }
  59. */
  60. FMS.IFMS = new Map();
  61. _cclegacy._RF.pop();
  62. _crd = false;
  63. }
  64. };
  65. });
  66. //# sourceMappingURL=60b06ae900f4cd994af68bc3e1b2e92c44cd1dae.js.map