Moar Gamecraft commands!
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
3.0KB

  1. using System;
  2. using RobocraftX.GUI.CommandLine;
  3. using RobocraftX.Multiplayer;
  4. using RobocraftX.StateSync;
  5. using RobocraftX.Character;
  6. using Svelto.ECS;
  7. using Unity.Entities;
  8. using UnityEngine;
  9. using uREPL;
  10. using Svelto.Context;
  11. using RobocraftX;
  12. using GamecraftModdingAPI.Commands;
  13. // checklist of things to rename to make this command your own:
  14. // [ ] namespace ExtraCommands.Example -> namespace ExtraCommands.[your command's namespace]
  15. // [ ] class ExampleCommandEngine : CustomCommandEngine -> class [your command name]CommandEngine : CustomCommandEngine
  16. // [ ] public ExampleCommandEngine(UnityContext<... -> public [your command name]CommandEngine(UnityContext<...
  17. // [ ] CustomCommandUtility.Register("[your command name]", [your command name]Command, "[your command description]")
  18. // [ ] private void ExampleCommand() -> private void [your command name]Command()
  19. // [ ] CustomCommandUtility.Unregister("[your command name]")
  20. //
  21. // For aesthetics, I'd recommend using PascalCase (first letter in every word is uppercase; spaces are illegal*)
  22. // * You can use spaces in your command description, but nowhere else. The description should be written like a normal English sentence.
  23. namespace ExtraCommands.Example
  24. {
  25. // !!! Uncomment the line below this !!!
  26. // [CustomCommand("Example")]
  27. class ExampleCommandEngine : ICustomCommandEngine
  28. {
  29. public string Description => "This is an example command which does nothing!";
  30. public string Name => "Example";
  31. public IEntitiesDB entitiesDB { set; private get; }
  32. // This class is a custom implementation of CustomCommandEngine specific to this command
  33. // You can use Svelto.ECS.IEntityDB entitiesDB to query game entities or one of the protected variables for other things
  34. // More documentation on Svelto.ECS: https://github.com/sebas77/Svelto.ECS
  35. // Unfortunately the documentation is severely lacking and out of date; you may have better luck decompiling Svelto.ECS.dll
  36. // See CustomCommandEngine.cs for more information on the super class
  37. // Ready() is called when the command is registered in-game (this happens whenever you load a game)
  38. public void Ready()
  39. {
  40. // CustomCommandUtility.Register has multiple overloads depending on how many parameters you want to pass to your command
  41. // See CustomCommandUtility.cs for more information
  42. CommandRegistrationHelper.Register(Name, ExampleCommand, Description);
  43. }
  44. // ExampleCommand() is called whenever the command is executed. This can accept up to three parameters
  45. // Please rename this, but don't forget to change the name in CustomCommandUtility.Register as well
  46. private void ExampleCommand()
  47. {
  48. // command operations go here
  49. }
  50. // Dispose() is called when the command is unregistered in-game (this happens whenever you leave a game)
  51. public void Dispose()
  52. {
  53. // You must unregister the command so it doesn't waste memory and so
  54. // it can be re-registered next time
  55. CommandRegistrationHelper.Unregister(Name);
  56. }
  57. }
  58. }