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.

59 lines
1.5KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Svelto.ECS;
  7. namespace GamecraftModdingAPI.Utility
  8. {
  9. /// <summary>
  10. /// Keeps track of custom menu-modifying engines
  11. /// </summary>
  12. public static class MenuEngineManager
  13. {
  14. private static Dictionary<string, IApiEngine> _menuEngines = new Dictionary<string, IApiEngine>();
  15. // menu engine management
  16. public static void AddMenuEngine(IApiEngine engine)
  17. {
  18. _menuEngines[engine.Name] = engine;
  19. }
  20. public static bool ExistsMenuEngine(string name)
  21. {
  22. return _menuEngines.ContainsKey(name);
  23. }
  24. public static bool ExistsMenuEngine(IApiEngine engine)
  25. {
  26. return ExistsMenuEngine(engine.Name);
  27. }
  28. public static IApiEngine GetMenuEngine(string name)
  29. {
  30. return _menuEngines[name];
  31. }
  32. public static string[] GetMenuEngineNames()
  33. {
  34. return _menuEngines.Keys.ToArray();
  35. }
  36. public static void RemoveMenuEngine(string name)
  37. {
  38. _menuEngines.Remove(name);
  39. }
  40. public static void RegisterEngines(EnginesRoot enginesRoot)
  41. {
  42. foreach (var key in _menuEngines.Keys)
  43. {
  44. Logging.MetaDebugLog($"Registering Menu IApiEngine {_menuEngines[key].Name}");
  45. enginesRoot.AddEngine(_menuEngines[key]);
  46. }
  47. }
  48. }
  49. }