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.

57 lines
1.7KB

  1. using Svelto.ECS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  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. 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. CommandRegistrationHelper.Unregister(this.Name);
  31. }
  32. public void Ready()
  33. {
  34. CommandRegistrationHelper.Register(this.Name, this.runCommand, this.Description);
  35. }
  36. /// <summary>
  37. /// Construct the engine
  38. /// </summary>
  39. /// <param name="command">The command's operation</param>
  40. /// <param name="name">The name of the command</param>
  41. /// <param name="description">The command's description, shown in command help messages</param>
  42. public SimpleCustomCommandEngine(Action command, string name, string description)
  43. {
  44. this.runCommand = command;
  45. this.Name = name;
  46. this.Description = description;
  47. }
  48. }
  49. }