Files
RobustToolbox/Robust.Shared/Audio/AudioDebugCommands.cs
2025-07-22 22:08:31 +02:00

37 lines
1.1 KiB
C#

using Robust.Shared.Audio.Systems;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Shared.Audio;
internal sealed class AudioDebugCommands : LocalizedCommands
{
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
public override string Command => "audio_length";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError(LocalizationManager.GetString("cmd-invalid-arg-number-error"));
return;
}
var audioSystem = _entitySystem.GetEntitySystem<SharedAudioSystem>();
var length = audioSystem.GetAudioLength(new ResolvedPathSpecifier(args[0]));
shell.WriteLine(length.ToString());
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromHint(LocalizationManager.GetString("cmd-audio_length-arg-file-name"));
}
return CompletionResult.Empty;
}
}