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.

64 line
3.2KB

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