6f948268-57c6-4423-94f9-b1e4ea12e4de.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. cc._RF.push(module, '6f948JoV8ZEI5T5seTqEuTe', 'CommandManager');
  3. // lightMVC/core/manager/CommandManager.ts
  4. "use strict";
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var SimpleCommand_1 = require("../command/SimpleCommand");
  7. var SyncMacroCommand_1 = require("../command/SyncMacroCommand");
  8. var AsyncMacroCommand_1 = require("../command/AsyncMacroCommand");
  9. var CommandManager = /** @class */ (function () {
  10. /**
  11. * @constructor
  12. * @private
  13. */
  14. function CommandManager() {
  15. }
  16. /**
  17. * 单例获取类
  18. */
  19. CommandManager.getInstance = function () {
  20. return this._instance;
  21. };
  22. /**
  23. * 执行命令
  24. * @param {{new (): BaseCommand}} command 命令对象
  25. * @param {Object} body 命令参数
  26. */
  27. CommandManager.prototype.__executeCommand__ = function (command, body) {
  28. if (cc.js.isChildClassOf(command, SimpleCommand_1.default)) {
  29. var cmd = new command();
  30. cmd.execute(body);
  31. }
  32. else if (cc.js.isChildClassOf(command, SyncMacroCommand_1.default)) {
  33. // TODO: 同步按顺序执行的命令组合宏
  34. }
  35. else if (cc.js.isChildClassOf(command, AsyncMacroCommand_1.default)) {
  36. var cmd = new command();
  37. // 初始化宏
  38. cmd["initialize"]();
  39. // 执行
  40. cmd["asyncExecute"]();
  41. }
  42. else {
  43. console.log(command.prototype + " 不是可执行的命令!");
  44. }
  45. };
  46. /**
  47. * 撤销命令
  48. * @param {{new (): BaseCommand}} command 命令对象
  49. * @param {Object} body 命令参数
  50. */
  51. CommandManager.prototype.__undoCommand__ = function (command, body) {
  52. if (cc.js.isChildClassOf(command, SimpleCommand_1.default)) {
  53. var cmd = new command();
  54. cmd.undo(body);
  55. }
  56. else if (cc.js.isChildClassOf(command, SyncMacroCommand_1.default)) {
  57. // TODO: 同步按顺序撤销的命令组合宏
  58. }
  59. else if (cc.js.isChildClassOf(command, AsyncMacroCommand_1.default)) {
  60. var cmd = new command();
  61. // 初始化宏
  62. cmd["initialize"]();
  63. // 执行
  64. cmd["asyncUndo"]();
  65. }
  66. else {
  67. console.log(command.prototype + " 不是可执行的命令!");
  68. }
  69. };
  70. // 实例
  71. CommandManager._instance = new CommandManager();
  72. return CommandManager;
  73. }());
  74. exports.default = CommandManager;
  75. cc._RF.pop();