From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:45:19 +0000 (+1100) Subject: Remove the awful audio command (#22071) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=8185212a02ee4c56891d64753a93e0b9d643afeb;p=space-station-14.git Remove the awful audio command (#22071) --- diff --git a/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs b/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs index 678174bc1a..ac55ce8325 100644 --- a/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs +++ b/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs @@ -1,110 +1,14 @@ -using System.IO; using System.Linq; -using System.Timers; using Content.Server.Audio; using Content.Shared.Administration; -using Robust.Server.Audio; -using Robust.Server.GameStates; using Robust.Server.Player; using Robust.Shared.Audio; -using Robust.Shared.Audio.Components; using Robust.Shared.Console; using Robust.Shared.ContentPack; using Robust.Shared.Player; -using Robust.Shared.Prototypes; -using Robust.Shared.Spawners; -using Robust.Shared.Timing; -using Timer = Robust.Shared.Timing.Timer; namespace Content.Server.Administration.Commands; -// This is for debugging nothing more. -[AdminCommand(AdminFlags.Debug)] -public sealed class PlayGlobalAudioCommand : IConsoleCommand -{ - public string Command => "playaudio"; - public string Description => "Plays audio globally for debugging"; - public string Help => $"{Command}"; - public void Execute(IConsoleShell shell, string argStr, string[] args) - { - var entManager = IoCManager.Resolve(); - var protoManager = IoCManager.Resolve(); - var resourceManager = IoCManager.Resolve(); - var audioSystem = entManager.System(); - var fileName = args[0]; - - shell.WriteLine($"Checking {fileName} global audio"); - - var audioLength = audioSystem.GetAudioLength(fileName); - - shell.WriteLine($"Cached audio length is: {audioLength}"); - - // Copied code to get the actual length determination - // Check shipped metadata from packaging. - if (protoManager.TryIndex(fileName, out AudioMetadataPrototype? metadata)) - { - shell.WriteLine($"Used prototype, length is: {metadata.Length}"); - } - else if (!resourceManager.TryContentFileRead(fileName, out var stream)) - { - throw new FileNotFoundException($"Unable to find metadata for audio file {fileName}"); - } - else - { - shell.WriteLine("Looks like audio stream used and cached."); - } - - Filter filter; - - if (args.Length > 2 && args[2] == "local") - { - filter = Filter.SinglePlayer(shell.Player!); - } - else - { - filter = Filter.Broadcast(); - } - - shell.WriteLine($"Playing filter to {filter.Count} players"); - - var audio = audioSystem.PlayGlobal(fileName, filter, true); - var audioMetadata = entManager.GetComponent(audio!.Value.Entity); - - shell.WriteLine($"Shell entity is {shell.Player!.AttachedEntity} / netuid {entManager.GetNetEntity(shell.Player!.AttachedEntity)}"); - shell.WriteLine($"Audio entityuid {audio!.Value.Entity} / netuid {entManager.GetNetEntity(audio!.Value.Entity)}"); - shell.WriteLine($"Audio excluded entities: {audio.Value.Component.ExcludedEntity}"); - shell.WriteLine($"Audio included entities: {string.Join(", ", audio.Value.Component.IncludedEntities!.Select(o => entManager.ToPrettyString(o)))}"); - shell.WriteLine($"Audio start: {audio?.Component.AudioStart}"); - shell.WriteLine($"Audio global: {audio?.Component.Global}"); - shell.WriteLine($"Audio paused: {entManager.IsPaused(audio?.Entity)}"); - shell.WriteLine($"Audio lifetime: {entManager.GetComponent(audio!.Value.Entity).Lifetime}"); - shell.WriteLine($"Can get state: {entManager.CanGetComponentState(entManager.EventBus, audio.Value.Component, shell.Player!)}"); - shell.WriteLine($"Session specific: {(audioMetadata.Flags & MetaDataFlags.SessionSpecific) != 0x0}"); - shell.WriteLine($"Audio specific: {entManager.GetComponent(audio.Value.Entity).SessionSpecific}"); - - shell.WriteLine($"Audio dirty tick is {audioMetadata.LastModifiedTick} spawn tick is {audioMetadata.CreationTick} current tick is {IoCManager.Resolve().CurTick}"); - - shell.WriteLine($"Session overrides: {string.Join(", ", entManager.System().GetSessionOverrides(shell.Player!))}"); - - if (args.Length > 1 && args[1] == "true") - { - var ent = audio.Value.Entity; - entManager.RemoveComponent(ent); - Timer.Spawn(600000, () => entManager.DeleteEntity(ent)); - } - else - { - var WEH = entManager.GetComponent(audio.Value.Entity); - WEH.Lifetime = 20f; - } - - Timer.Spawn(2, () => - { - shell.WriteLine($"Audio deleted: {entManager.Deleted(audio.Value.Entity)}"); - }); - } -} - [AdminCommand(AdminFlags.Fun)] public sealed class PlayGlobalSoundCommand : IConsoleCommand {