A stable modding interface between Techblox and mods https://mod.exmods.org/
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.

80 lines
3.3KB

  1. using System;
  2. using System.Reflection;
  3. using Harmony;
  4. using GamecraftModdingAPI.Commands;
  5. using GamecraftModdingAPI.Events;
  6. using GamecraftModdingAPI.Utility;
  7. namespace GamecraftModdingAPI.Tests
  8. {
  9. // unused by design
  10. /// <summary>
  11. /// Modding API implemented as a standalone IPA Plugin.
  12. /// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself
  13. /// </summary>
  14. public class GamecraftModdingAPIPluginTest
  15. #if DEBUG
  16. : IllusionPlugin.IEnhancedPlugin
  17. #endif
  18. {
  19. public static HarmonyInstance harmony { get; protected set; }
  20. public string[] Filter { get; } = new string[] { "Gamecraft" };
  21. public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
  22. public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
  23. public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi";
  24. public void OnApplicationQuit()
  25. {
  26. GamecraftModdingAPI.Main.Shutdown();
  27. }
  28. public void OnApplicationStart()
  29. {
  30. GamecraftModdingAPI.Main.Init();
  31. // in case Steam is not installed/running
  32. // this will crash the game slightly later during startup
  33. //SteamInitPatch.ForcePassSteamCheck = true;
  34. // in case running in a VM
  35. //MinimumSpecsCheckPatch.ForcePassMinimumSpecCheck = true;
  36. // debug/test handlers
  37. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("App Inited event!"); }, () => { },
  38. EventType.ApplicationInitialized, "appinit API debug"));
  39. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Menu Activated event!"); },
  40. () => { Logging.Log("Menu Destroyed event!"); },
  41. EventType.Menu, "menuact API debug"));
  42. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Menu Switched To event!"); }, () => { },
  43. EventType.MenuSwitchedTo, "menuswitch API debug"));
  44. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Activated event!"); },
  45. () => { Logging.Log("Game Destroyed event!"); },
  46. EventType.Game, "gameact API debug"));
  47. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Reloaded event!"); }, () => { },
  48. EventType.GameReloaded, "gamerel API debug"));
  49. EventManager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Switched To event!"); }, () => { },
  50. EventType.GameSwitchedTo, "gameswitch API debug"));
  51. // debug/test commands
  52. CommandManager.AddCommand(new SimpleCustomCommandEngine(() => { UnityEngine.Application.Quit(); },
  53. "Exit", "Close Gamecraft without any prompts"));
  54. CommandManager.AddCommand(new SimpleCustomCommandEngine<float>((float d) => { UnityEngine.Camera.main.fieldOfView = d; },
  55. "SetFOV", "Set the player camera's field of view"));
  56. }
  57. public void OnFixedUpdate() { }
  58. public void OnLateUpdate() { }
  59. public void OnLevelWasInitialized(int level) { }
  60. public void OnLevelWasLoaded(int level) { }
  61. public void OnUpdate() { }
  62. }
  63. }