TechbloxModdingAPI/GamecraftModdingAPI/Commands/CommandRegistrationHelper.cs
2019-12-28 14:40:34 -05:00

89 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using uREPL;
using RobocraftX.CommandLine.Custom;
namespace GamecraftModdingAPI.Commands
{
/// <summary>
/// Convenient methods for registering commands to Gamecraft.
/// All methods register to the command line and console block by default.
/// </summary>
public static class CommandRegistrationHelper
{
public static void Register(string name, Action action, string desc, bool noConsole = false)
{
RuntimeCommands.Register(name, action, desc);
if (noConsole) { return; }
ConsoleCommands.Register(name, action, desc);
}
public static void Register(string name, Action<object> action, string desc, bool noConsole = false)
{
Register<object>(name, action, desc, noConsole);
}
public static void Register(string name, Action<object, object> action, string desc, bool noConsole = false)
{
Register<object, object>(name, action, desc, noConsole);
}
public static void Register(string name, Action<object, object, object> action, string desc, bool noConsole = false)
{
Register<object, object, object>(name, action, desc, noConsole);
}
public static void Register<Param0>(string name, Action<Param0> action, string desc, bool noConsole = false)
{
RuntimeCommands.Register<Param0>(name, action, desc);
if (noConsole) { return; }
ConsoleCommands.Register<Param0>(name, action, desc);
}
public static void Register<Param0, Param1>(string name, Action<Param0, Param1> action, string desc, bool noConsole = false)
{
RuntimeCommands.Register<Param0, Param1>(name, action, desc);
if (noConsole) { return; }
ConsoleCommands.Register<Param0, Param1>(name, action, desc);
}
public static void Register<Param0, Param1, Param2>(string name, Action<Param0, Param1, Param2> action, string desc, bool noConsole = false)
{
RuntimeCommands.Register<Param0, Param1, Param2>(name, action, desc);
if (noConsole) { return; }
ConsoleCommands.Register<Param0, Param1, Param2>(name, action, desc);
}
public static void Unregister(string name, bool noConsole = false)
{
RuntimeCommands.Unregister(name);
if (noConsole) { return; }
ConsoleCommands.Unregister(name);
}
public static void Call(string name)
{
RuntimeCommands.Call(name);
}
public static void Call<Param0>(string name, Param0 param0)
{
RuntimeCommands.Call<Param0>(name, param0);
}
public static void Call<Param0, Param1>(string name, Param0 param0, Param1 param1)
{
RuntimeCommands.Call<Param0, Param1>(name, param0, param1);
}
public static void Call<Param0, Param1, Param2>(string name, Param0 param0, Param1 param1, Param2 param2)
{
RuntimeCommands.Call<Param0, Param1, Param2>(name, param0, param1, param2);
}
}
}