47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Svelto.ECS;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GamecraftModdingAPI.Commands
|
|
{
|
|
/// <summary>
|
|
/// A simple implementation of ICustomCommandEngine sufficient for most commands.
|
|
/// This version is for commands which take 2 argument(s)
|
|
/// </summary>
|
|
class SimpleCustomCommandEngine<A,B> : ICustomCommandEngine
|
|
{
|
|
public string Name { get; }
|
|
|
|
public string Description { get; }
|
|
|
|
private Action<A,B> runCommand;
|
|
|
|
public IEntitiesDB entitiesDB { set; private get; }
|
|
|
|
public void Dispose()
|
|
{
|
|
CommandRegistrationHelper.Unregister(this.Name);
|
|
}
|
|
|
|
public void Ready()
|
|
{
|
|
CommandRegistrationHelper.Register<A,B>(this.Name, this.runCommand, this.Description);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Construct the engine
|
|
/// </summary>
|
|
/// <param name="command">The command's operation</param>
|
|
/// <param name="name">The name of the command</param>
|
|
/// <param name="description">The command's description, shown in command help messages</param>
|
|
public SimpleCustomCommandEngine(Action<A,B> command, string name, string description)
|
|
{
|
|
this.runCommand = command;
|
|
this.Name = name;
|
|
this.Description = description;
|
|
}
|
|
}
|
|
}
|