using System; using System.Collections.Generic; using System.Linq; namespace Robust.Shared.Input.Binding { /// /// An individual binding of a given handler to a given key function, with associated /// dependency information to resolve handlers bound to the same key function from different types. /// public sealed class CommandBind { private readonly BoundKeyFunction _boundKeyFunction; private readonly IEnumerable _after; private readonly IEnumerable _before; private readonly InputCmdHandler _handler; /// /// Key function the handler should be triggered on /// public BoundKeyFunction BoundKeyFunction => _boundKeyFunction; /// /// If other types register bindings for this key function, this handler will always fire /// after them if they appear in this list. /// public IEnumerable After => _after; /// /// If other types register bindings for this key function, this handler will always fire /// before them if they appear in this list. /// public IEnumerable Before => _before; /// /// Handler which should handle inputs for the key function /// public InputCmdHandler Handler => _handler; /// /// A binding of a handler to the indicated key function, with the indicated dependencies. /// /// key function this handler should handle /// handler to handle the input /// If other types register bindings for this key function, this handler will always fire /// before them if they appear in this list. /// If other types register bindings for this key function, this handler will always fire /// after them if they appear in this list. public CommandBind(BoundKeyFunction boundKeyFunction, InputCmdHandler handler, IEnumerable? before = null, IEnumerable? after = null) { _boundKeyFunction = boundKeyFunction; _after = after ?? Enumerable.Empty(); _before = before ?? Enumerable.Empty(); _handler = handler; } } }