using System; using System.Collections.Generic; namespace Clave.Glass { /// /// Something a player can bind keys to, such as Jump, with the keys it starts with. /// public class KeyAction { /// /// The name it is saved under, which stays the same when is translated. /// /// The name a player reads. /// /// What the trigger key does to fire a binding a player captures, such as Held for walking. /// public KeyAction(string id, string name, KeyStateKind kind, params Chord[] defaults) : this(id, name, kind, null, defaults) { } /// The situation the action is live in, or null for any. public KeyAction(string id, string name, KeyStateKind kind, ChordContext context, params Chord[] defaults) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException("An action needs an id to be saved under.", nameof(id)); } if (kind < KeyStateKind.Held || kind > KeyStateKind.Tapped) { throw new ArgumentOutOfRangeException(nameof(kind), kind, "That isn't a kind of key state."); } Id = id; Name = name ?? throw new ArgumentNullException(nameof(name)); Kind = kind; Context = context; Defaults = (Chord[])(defaults ?? throw new ArgumentNullException(nameof(defaults))).Clone(); } public string Id { get; } public string Name { get; } public KeyStateKind Kind { get; } public ChordContext Context { get; } public IReadOnlyList Defaults { get; } public override string ToString() { return Id; } } }