|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using Svelto.ECS;
-
- namespace GamecraftModdingAPI.Utility
- {
- /// <summary>
- /// Keeps track of custom menu-modifying engines
- /// </summary>
- public static class MenuEngineManager
- {
- private static Dictionary<string, IApiEngine> _menuEngines = new Dictionary<string, IApiEngine>();
-
- private static EnginesRoot _lastEngineRoot;
-
- // menu engine management
- public static void AddMenuEngine(IApiEngine engine)
- {
- _menuEngines[engine.Name] = engine;
- if (_lastEngineRoot != null)
- {
- Logging.MetaDebugLog($"Registering Menu IApiEngine {engine.Name}");
- _lastEngineRoot.AddEngine(engine);
- }
- }
-
- public static bool ExistsMenuEngine(string name)
- {
- return _menuEngines.ContainsKey(name);
- }
-
- public static bool ExistsMenuEngine(IApiEngine engine)
- {
- return ExistsMenuEngine(engine.Name);
- }
-
- public static IApiEngine GetMenuEngine(string name)
- {
- return _menuEngines[name];
- }
-
- public static string[] GetMenuEngineNames()
- {
- return _menuEngines.Keys.ToArray();
- }
-
- public static void RemoveMenuEngine(string name)
- {
- _menuEngines.Remove(name);
- }
-
- public static void RegisterEngines(EnginesRoot enginesRoot)
- {
- _lastEngineRoot = enginesRoot;
- foreach (var key in _menuEngines.Keys)
- {
- Logging.MetaDebugLog($"Registering Menu IApiEngine {_menuEngines[key].Name}");
- enginesRoot.AddEngine(_menuEngines[key]);
- }
- }
- }
- }
|