FiniteReality/Finite.Commands

Implement command router

FiniteReality opened this issue · 4 comments

Somehow commands need to be routed to the correct location so they can be handled.

I could possibly use the previous structures defined in 0.2, but they weren't necessarily the best...

Currently this is done as part of the command parser in ab0e75c

Since there are multiple ways to route a command (e.g. in Discord, each command has a unique identifier) this might be better to implement as part of the command store, and transition it to a semi-tree based structure

The command store now uses a semi-tree based structure

ICommandBinder can be used to bind an ICommand to a context, which in effect does the routing:

var binder = services.GetRequiredService<ICommandBinder>();

foreach (var command in potentialCommands)
{
    if (binder.TryBind(context, command))
    {
        context.Command = command;
        return
    }
}