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.

66 lines
1.7KB

  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 game-modifying engines
  11. /// </summary>
  12. public static class GameEngineManager
  13. {
  14. private static Dictionary<string, IApiEngine> _gameEngines = new Dictionary<string, IApiEngine>();
  15. private static EnginesRoot _lastEngineRoot;
  16. public static void AddGameEngine(IApiEngine engine)
  17. {
  18. _gameEngines[engine.Name] = engine;
  19. if (_lastEngineRoot != null)
  20. {
  21. Logging.MetaDebugLog($"Registering Game IApiEngine {engine.Name}");
  22. _lastEngineRoot.AddEngine(engine);
  23. }
  24. }
  25. public static bool ExistsGameEngine(string name)
  26. {
  27. return _gameEngines.ContainsKey(name);
  28. }
  29. public static bool ExistsGameEngine(IApiEngine engine)
  30. {
  31. return ExistsGameEngine(engine.Name);
  32. }
  33. public static IApiEngine GetGameEngine(string name)
  34. {
  35. return _gameEngines[name];
  36. }
  37. public static string[] GetGameEngineNames()
  38. {
  39. return _gameEngines.Keys.ToArray();
  40. }
  41. public static void RemoveGameEngine(string name)
  42. {
  43. _gameEngines.Remove(name);
  44. }
  45. public static void RegisterEngines(EnginesRoot enginesRoot)
  46. {
  47. _lastEngineRoot = enginesRoot;
  48. foreach (var key in _gameEngines.Keys)
  49. {
  50. Logging.MetaDebugLog($"Registering Game IApiEngine {_gameEngines[key].Name}");
  51. enginesRoot.AddEngine(_gameEngines[key]);
  52. }
  53. }
  54. }
  55. }