Discord integration for Gamecraft
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.

63 lines
2.6KB

  1. using System.Reflection;
  2. using IllusionPlugin;
  3. // using GamecraftModdingAPI;
  4. using GamecraftModdingAPI.Commands;
  5. namespace HelloModdingWorld
  6. {
  7. public class MyPlugin : IPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin'
  8. {
  9. public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; // HelloModdingWorld by default
  10. // To change the name, change the project's name
  11. public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); // 0.0.1 by default
  12. // To change the version, change <Version>0.0.1</Version> in HelloModdingWorld.csproj
  13. private static readonly string helloWorldCommandName = "HelloWorld"; // command name
  14. // called when Gamecraft shuts down
  15. public void OnApplicationQuit()
  16. {
  17. // Shutdown this mod
  18. GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
  19. // Shutdown the Gamecraft modding API last
  20. GamecraftModdingAPI.Main.Shutdown();
  21. }
  22. // called when Gamecraft starts up
  23. public void OnApplicationStart()
  24. {
  25. // Initialize the Gamecraft modding API first
  26. GamecraftModdingAPI.Main.Init();
  27. // check out the modding API docs here: https://mod.exmods.org/
  28. // Initialize this mod
  29. // create SimpleCustomCommandEngine
  30. // this writes "Hello modding world!" when you execute it in Gamecraft's console
  31. // (use the forward-slash key '/' to open the console in Gamecraft when in a game)
  32. SimpleCustomCommandEngine helloWorldCommand = new SimpleCustomCommandEngine(
  33. () => { GamecraftModdingAPI.Utility.Logging.CommandLog("Hello modding world!"); }, // command action
  34. // also try using CommandLogWarning or CommandLogError instead of CommandLog
  35. helloWorldCommandName, // command name (used to invoke it in the console)
  36. "Says Hello modding world!" // command description (displayed when help command is executed)
  37. ); // this command can also be executed using the Command Computer
  38. // register the command so the modding API knows about it
  39. CommandManager.AddCommand(helloWorldCommand);
  40. GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
  41. }
  42. // unused methods
  43. public void OnFixedUpdate() { } // called once per physics update
  44. public void OnLevelWasInitialized(int level) { } // called after a level is initialized
  45. public void OnLevelWasLoaded(int level) { } // called after a level is loaded
  46. public void OnUpdate() { } // called once per rendered frame (frame update)
  47. }
  48. }