TechbloxModdingAPI/GamecraftModdingAPI/Utility/GameEngineManager.cs
2019-12-16 20:55:52 -05:00

57 lines
1.5 KiB
C#

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 game-modifying engines
/// </summary>
public static class GameEngineManager
{
private static Dictionary<string, IApiEngine> _gameEngines = new Dictionary<string, IApiEngine>();
public static void AddGameEngine(IApiEngine engine)
{
_gameEngines[engine.Name] = engine;
}
public static bool ExistsGameEngine(string name)
{
return _gameEngines.ContainsKey(name);
}
public static bool ExistsGameEngine(IApiEngine engine)
{
return ExistsGameEngine(engine.Name);
}
public static IApiEngine GetGameEngine(string name)
{
return _gameEngines[name];
}
public static string[] GetGameEngineNames()
{
return _gameEngines.Keys.ToArray();
}
public static void RemoveGameEngine(string name)
{
_gameEngines.Remove(name);
}
public static void RegisterEngines(EnginesRoot enginesRoot)
{
foreach (var key in _gameEngines.Keys)
{
Logging.MetaDebugLog($"Registering Game IApiEngine {_gameEngines[key].Name}");
enginesRoot.AddEngine(_gameEngines[key]);
}
}
}
}