Moar Gamecraft commands!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

60 wiersze
2.8KB

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