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.

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