TechbloxModdingAPI/GamecraftModdingAPI/Commands/CommandManager.cs

61 lines
1.6 KiB
C#
Raw Normal View History

2019-12-15 07:20:20 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2019-12-15 07:20:20 +00:00
using Svelto.ECS;
2019-12-17 01:55:52 +00:00
using GamecraftModdingAPI.Utility;
2019-12-15 07:20:20 +00:00
namespace GamecraftModdingAPI.Commands
{
/// <summary>
/// Keeps track of custom commands
/// This is used to add, remove and get command engines
/// </summary>
public static class CommandManager
{
private static Dictionary<string, ICustomCommandEngine> _customCommands = new Dictionary<string, ICustomCommandEngine>();
public static void AddCommand(ICustomCommandEngine engine)
{
_customCommands[engine.Name] = engine;
}
public static bool ExistsCommand(string name)
{
return _customCommands.ContainsKey(name);
}
public static bool ExistsCommand(ICustomCommandEngine engine)
{
return ExistsCommand(engine.Name);
}
public static ICustomCommandEngine GetCommand(string name)
{
return _customCommands[name];
}
public static string[] GetCommandNames()
2019-12-15 07:20:20 +00:00
{
return _customCommands.Keys.ToArray();
2019-12-15 07:20:20 +00:00
}
public static void RemoveCommand(string name)
{
_customCommands.Remove(name);
}
public static void RegisterEngines(EnginesRoot enginesRoot)
{
foreach (var key in _customCommands.Keys)
{
2019-12-17 01:55:52 +00:00
Logging.MetaDebugLog($"Registering ICustomCommandEngine {_customCommands[key].Name}");
2019-12-15 07:20:20 +00:00
enginesRoot.AddEngine(_customCommands[key]);
}
}
}
}