A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.5KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using uREPL;
  7. using RobocraftX.CommandLine.Custom;
  8. namespace GamecraftModdingAPI.Commands
  9. {
  10. /// <summary>
  11. /// Convenient methods for registering commands to Gamecraft.
  12. /// All methods register to the command line and console block by default.
  13. /// </summary>
  14. public static class CommandRegistrationHelper
  15. {
  16. public static void Register(string name, Action action, string desc, bool noConsole = false)
  17. {
  18. RuntimeCommands.Register(name, action, desc);
  19. if (noConsole) { return; }
  20. ConsoleCommands.Register(name, action, desc);
  21. }
  22. public static void Register(string name, Action<object> action, string desc, bool noConsole = false)
  23. {
  24. Register<object>(name, action, desc, noConsole);
  25. }
  26. public static void Register(string name, Action<object, object> action, string desc, bool noConsole = false)
  27. {
  28. Register<object, object>(name, action, desc, noConsole);
  29. }
  30. public static void Register(string name, Action<object, object, object> action, string desc, bool noConsole = false)
  31. {
  32. Register<object, object, object>(name, action, desc, noConsole);
  33. }
  34. public static void Register<Param0>(string name, Action<Param0> action, string desc, bool noConsole = false)
  35. {
  36. RuntimeCommands.Register<Param0>(name, action, desc);
  37. if (noConsole) { return; }
  38. ConsoleCommands.Register<Param0>(name, action, desc);
  39. }
  40. public static void Register<Param0, Param1>(string name, Action<Param0, Param1> action, string desc, bool noConsole = false)
  41. {
  42. RuntimeCommands.Register<Param0, Param1>(name, action, desc);
  43. if (noConsole) { return; }
  44. ConsoleCommands.Register<Param0, Param1>(name, action, desc);
  45. }
  46. public static void Register<Param0, Param1, Param2>(string name, Action<Param0, Param1, Param2> action, string desc, bool noConsole = false)
  47. {
  48. RuntimeCommands.Register<Param0, Param1, Param2>(name, action, desc);
  49. if (noConsole) { return; }
  50. ConsoleCommands.Register<Param0, Param1, Param2>(name, action, desc);
  51. }
  52. public static void Unregister(string name, bool noConsole = false)
  53. {
  54. RuntimeCommands.Unregister(name);
  55. if (noConsole) { return; }
  56. ConsoleCommands.Unregister(name);
  57. }
  58. }
  59. }