57 lines
1.5 KiB
C#
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.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 Dictionary<string, ICustomCommandEngine> GetCommands()
|
|||
|
{
|
|||
|
return _customCommands;
|
|||
|
}
|
|||
|
|
|||
|
public static void RemoveCommand(string name)
|
|||
|
{
|
|||
|
_customCommands.Remove(name);
|
|||
|
}
|
|||
|
|
|||
|
public static void RegisterEngines(EnginesRoot enginesRoot)
|
|||
|
{
|
|||
|
foreach (var key in _customCommands.Keys)
|
|||
|
{
|
|||
|
enginesRoot.AddEngine(_customCommands[key]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|