|
- using Svelto.ECS;
-
- using GamecraftModdingAPI.Commands;
-
- // checklist of things to rename to make this command your own:
- // [ ] namespace ExtraCommands.Example -> namespace ExtraCommands.[your command's namespace]
- // [ ] class ExampleCommandEngine : CustomCommandEngine -> class [your command name]CommandEngine : CustomCommandEngine
- // [ ] public ExampleCommandEngine(UnityContext<... -> public [your command name]CommandEngine(UnityContext<...
- // [ ] CustomCommandUtility.Register("[your command name]", [your command name]Command, "[your command description]")
- // [ ] private void ExampleCommand() -> private void [your command name]Command()
- // [ ] CustomCommandUtility.Unregister("[your command name]")
- //
- // For aesthetics, I'd recommend using PascalCase (first letter in every word is uppercase; spaces are illegal*)
- // * You can use spaces in your command description, but nowhere else. The description should be written like a normal English sentence.
-
- namespace ExtraCommands.Example
- {
- // !!! Uncomment the line below this !!!
- // [CustomCommand("Example")]
- class ExampleCommandEngine : ICustomCommandEngine
- {
- public string Description => "This is an example command which does nothing!";
-
- public string Name => "Example";
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public bool isRemovable => true;
-
- // This class is a custom implementation of CustomCommandEngine specific to this command
- // You can use Svelto.ECS.IEntityDB entitiesDB to query game entities or one of the protected variables for other things
- // More documentation on Svelto.ECS: https://github.com/sebas77/Svelto.ECS
- // Unfortunately the documentation is severely lacking and out of date; you may have better luck decompiling Svelto.ECS.dll
- // See CustomCommandEngine.cs for more information on the super class
-
- // Ready() is called when the command is registered in-game (this happens whenever you load a game)
- public void Ready()
- {
- // CustomCommandUtility.Register has multiple overloads depending on how many parameters you want to pass to your command
- // See CustomCommandUtility.cs for more information
- CommandRegistrationHelper.Register(Name, ExampleCommand, Description);
- }
-
- // ExampleCommand() is called whenever the command is executed. This can accept up to three parameters
- // Please rename this, but don't forget to change the name in CustomCommandUtility.Register as well
- private void ExampleCommand()
- {
- // command operations go here
- }
-
- // Dispose() is called when the command is unregistered in-game (this happens whenever you leave a game)
- public void Dispose()
- {
- // You must unregister the command so it doesn't waste memory and so
- // it can be re-registered next time
- CommandRegistrationHelper.Unregister(Name);
- }
- }
- }
|