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.

49 lines
1.4KB

  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 3 argument(s)
  12. /// </summary>
  13. class SimpleCustomCommandEngine<A,B,C> : ICustomCommandEngine
  14. {
  15. public string Name { get; }
  16. public string Description { get; }
  17. private Action<A,B,C> runCommand;
  18. public IEntitiesDB entitiesDB { set; private get; }
  19. public void Dispose()
  20. {
  21. CommandRegistrationHelper.Unregister(this.Name);
  22. }
  23. public void Ready()
  24. {
  25. CommandRegistrationHelper.Register<A,B,C>(this.Name, this.runCommand, this.Description);
  26. }
  27. /// <summary>
  28. /// Construct the engine
  29. /// </summary>
  30. /// <param name="command">The command's operation</param>
  31. /// <param name="name">The name of the command</param>
  32. /// <param name="description">The command's description, shown in command help messages</param>
  33. public SimpleCustomCommandEngine(Action<A,B,C> command, string name, string description)
  34. {
  35. this.runCommand = command;
  36. this.Name = name;
  37. this.Description = description;
  38. }
  39. }
  40. }