2019-12-16 00:35:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Utility
|
|
|
|
|
{
|
2019-12-17 01:55:52 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Keeps track of custom game-modifying engines
|
|
|
|
|
/// </summary>
|
2019-12-16 00:35:59 +00:00
|
|
|
|
public static class GameEngineManager
|
|
|
|
|
{
|
|
|
|
|
private static Dictionary<string, IApiEngine> _gameEngines = new Dictionary<string, IApiEngine>();
|
|
|
|
|
|
2020-01-26 19:28:57 +00:00
|
|
|
|
private static EnginesRoot _lastEngineRoot;
|
|
|
|
|
|
2019-12-16 00:35:59 +00:00
|
|
|
|
public static void AddGameEngine(IApiEngine engine)
|
|
|
|
|
{
|
|
|
|
|
_gameEngines[engine.Name] = engine;
|
2020-01-26 19:28:57 +00:00
|
|
|
|
if (_lastEngineRoot != null)
|
|
|
|
|
{
|
|
|
|
|
Logging.MetaDebugLog($"Registering Game IApiEngine {engine.Name}");
|
|
|
|
|
_lastEngineRoot.AddEngine(engine);
|
|
|
|
|
}
|
2019-12-16 00:35:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2020-01-26 19:28:57 +00:00
|
|
|
|
_lastEngineRoot = enginesRoot;
|
2019-12-16 00:35:59 +00:00
|
|
|
|
foreach (var key in _gameEngines.Keys)
|
|
|
|
|
{
|
2019-12-17 01:55:52 +00:00
|
|
|
|
Logging.MetaDebugLog($"Registering Game IApiEngine {_gameEngines[key].Name}");
|
2019-12-16 00:35:59 +00:00
|
|
|
|
enginesRoot.AddEngine(_gameEngines[key]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|