using System; using System.Collections.Generic; using System.Linq; namespace Game; [AttributeUsage(AttributeTargets.All)] public abstract class ConsoleBaseAttribute : Attribute { // Additional aliases for this command, these should only be used with user interaction. // Commands such as 'cvarlist' should not list these in order to avoid clutter. internal string[] aliases = new string[0]; internal string name; public ConsoleBaseAttribute(string name) { this.name = name.ToLowerInvariant(); } public ConsoleBaseAttribute(params string[] names) { name = names[0].ToLowerInvariant(); aliases = new List(names).Skip(1).Select(x => x.ToLowerInvariant()).ToArray(); } public ConsoleFlags flags { get; private set; } } [AttributeUsage(AttributeTargets.All)] public class ConsoleVariableAttribute : ConsoleBaseAttribute { public ConsoleVariableAttribute(string name) : base(name) { } } [AttributeUsage(AttributeTargets.All)] public class ConsoleCommandAttribute : ConsoleBaseAttribute { /// /// Registers a command to Console system. /// /// Name used for calling this command. public ConsoleCommandAttribute(string name) : base(name) { } /// /// Registers a command to Console system. /// /// /// Names used for calling this command. First name is the main name for this command, /// rest of the names are aliases. /// public ConsoleCommandAttribute(params string[] names) : base(names) { } } /// /// Constructor for the subsystem, must be called first before registering console commands. /// [AttributeUsage(AttributeTargets.All)] public class ConsoleSubsystemInitializer : Attribute { }