using System.Threading; using System.Threading.Tasks; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Toolshed; namespace Robust.Shared.Console; /// /// A variant on that has some built-in default localization strings. /// /// /// For server commands, it is much preferred to use . /// public abstract partial class LocalizedCommands : IConsoleCommand { [Dependency] protected ILocalizationManager LocalizationManager = default!; public ILocalizationManager Loc => LocalizationManager; /// public abstract string Command { get; } /// public virtual string Description => LocalizationManager.TryGetString($"cmd-{Command}-desc", out var val) ? val : ""; /// public virtual string Help => LocalizationManager.TryGetString($"cmd-{Command}-help", out var val, ("command", Command)) ? val : ""; /// public virtual bool RequireServerOrSingleplayer => false; /// public abstract void Execute(IConsoleShell shell, string argStr, string[] args); /// public virtual CompletionResult GetCompletion(IConsoleShell shell, string[] args) => CompletionResult.Empty; /// public virtual ValueTask GetCompletionAsync(IConsoleShell shell, string[] args, string argStr, CancellationToken cancel) { return ValueTask.FromResult(GetCompletion(shell, args)); } } /// /// Base class for localized console commands that run in "entity space". /// /// /// /// This type of command is registered only while the entity system is active. /// On the client this means that the commands are only available while connected to a server or in single player. /// /// /// These commands are allowed to take dependencies on entity systems, reducing boilerplate for many usages. /// /// public abstract partial class LocalizedEntityCommands : LocalizedCommands, IEntityConsoleCommand { [Dependency] protected EntityManager EntityManager = default!; }