Remove the awful audio command (#22071)

This commit is contained in:
metalgearsloth
2023-12-02 10:45:19 +11:00
committed by GitHub
parent 8a210761c2
commit 8185212a02

View File

@@ -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<IEntityManager>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var resourceManager = IoCManager.Resolve<IResourceManager>();
var audioSystem = entManager.System<AudioSystem>();
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<MetaDataComponent>(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<TimedDespawnComponent>(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<AudioComponent>(audio.Value.Entity).SessionSpecific}");
shell.WriteLine($"Audio dirty tick is {audioMetadata.LastModifiedTick} spawn tick is {audioMetadata.CreationTick} current tick is {IoCManager.Resolve<IGameTiming>().CurTick}");
shell.WriteLine($"Session overrides: {string.Join(", ", entManager.System<PvsOverrideSystem>().GetSessionOverrides(shell.Player!))}");
if (args.Length > 1 && args[1] == "true")
{
var ent = audio.Value.Entity;
entManager.RemoveComponent<TimedDespawnComponent>(ent);
Timer.Spawn(600000, () => entManager.DeleteEntity(ent));
}
else
{
var WEH = entManager.GetComponent<TimedDespawnComponent>(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
{