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.

60 lines
1.9KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Svelto.ECS;
  7. namespace GamecraftModdingAPI.Commands
  8. {
  9. /// <summary>
  10. /// A simple implementation of ICustomCommandEngine sufficient for most commands.
  11. /// This version is for commands which take 0 argument(s)
  12. /// </summary>
  13. public class SimpleCustomCommandEngine : ICustomCommandEngine
  14. {
  15. /// <summary>
  16. /// The name of the command
  17. /// </summary>
  18. public string Name { get; }
  19. /// <summary>
  20. /// The command's description, shown in command help messages
  21. /// </summary>
  22. public string Description { get; }
  23. /// <summary>
  24. /// The operation to execute when the command is called by the player
  25. /// </summary>
  26. private Action runCommand;
  27. public IEntitiesDB entitiesDB { set; private get; }
  28. public void Dispose()
  29. {
  30. GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}");
  31. CommandRegistrationHelper.Unregister(this.Name);
  32. }
  33. public void Ready()
  34. {
  35. GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}");
  36. CommandRegistrationHelper.Register(this.Name, this.runCommand, this.Description);
  37. }
  38. /// <summary>
  39. /// Construct the engine
  40. /// </summary>
  41. /// <param name="command">The command's operation</param>
  42. /// <param name="name">The name of the command</param>
  43. /// <param name="description">The command's description, shown in command help messages</param>
  44. public SimpleCustomCommandEngine(Action command, string name, string description)
  45. {
  46. this.runCommand = command;
  47. this.Name = name;
  48. this.Description = description;
  49. }
  50. }
  51. }