From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Mon, 6 May 2024 00:19:43 +0000 (+1000)
Subject: Expeditions audio tweaks (#27524)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d1a5d3562355a514c42b1027742549180f6edc37;p=space-station-14.git
Expeditions audio tweaks (#27524)
- Now uses a SoundCollection.
- Now properly handles going between maps (audio rework mucho wow).
- GetAudioLength used so it can properly countdown ANY song (wow audio rework wow wow).
---
diff --git a/Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs b/Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs
index 6a58c209cf..ff3c8176fd 100644
--- a/Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs
+++ b/Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs
@@ -40,14 +40,21 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
///
/// Countdown audio stream.
///
+ [DataField, AutoNetworkedField]
public EntityUid? Stream = null;
///
/// Sound that plays when the mission end is imminent.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("sound")]
- public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Misc/tension_session.ogg")
+ [ViewVariables(VVAccess.ReadWrite), DataField]
+ public SoundSpecifier Sound = new SoundCollectionSpecifier("ExpeditionEnd")
{
Params = AudioParams.Default.WithVolume(-5),
};
+
+ ///
+ /// Song selected on MapInit so we can predict the audio countdown properly.
+ ///
+ [DataField]
+ public SoundPathSpecifier SelectedSong;
}
diff --git a/Content.Server/Salvage/SalvageSystem.Expeditions.cs b/Content.Server/Salvage/SalvageSystem.Expeditions.cs
index 4d5d569dab..923880169d 100644
--- a/Content.Server/Salvage/SalvageSystem.Expeditions.cs
+++ b/Content.Server/Salvage/SalvageSystem.Expeditions.cs
@@ -4,7 +4,9 @@ using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Shared.CCVar;
using Content.Shared.Examine;
+using Content.Shared.Random.Helpers;
using Content.Shared.Salvage.Expeditions;
+using Robust.Shared.Audio;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.CPUJob.JobQueues.Queues;
using Robust.Shared.GameStates;
@@ -32,6 +34,7 @@ public sealed partial class SalvageSystem
SubscribeLocalEvent(OnSalvageConsoleParent);
SubscribeLocalEvent(OnSalvageClaimMessage);
+ SubscribeLocalEvent(OnExpeditionMapInit);
SubscribeLocalEvent(OnExpeditionShutdown);
SubscribeLocalEvent(OnExpeditionGetState);
@@ -64,6 +67,12 @@ public sealed partial class SalvageSystem
_cooldown = obj;
}
+ private void OnExpeditionMapInit(EntityUid uid, SalvageExpeditionComponent component, MapInitEvent args)
+ {
+ var selectedFile = _audio.GetSound(component.Sound);
+ component.SelectedSong = new SoundPathSpecifier(selectedFile, component.Sound.Params);
+ }
+
private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
{
component.Stream = _audio.Stop(component.Stream);
diff --git a/Content.Server/Salvage/SalvageSystem.Runner.cs b/Content.Server/Salvage/SalvageSystem.Runner.cs
index 8a1498cbe9..e6e29eb577 100644
--- a/Content.Server/Salvage/SalvageSystem.Runner.cs
+++ b/Content.Server/Salvage/SalvageSystem.Runner.cs
@@ -144,6 +144,7 @@ public sealed partial class SalvageSystem
while (query.MoveNext(out var uid, out var comp))
{
var remaining = comp.EndTime - _timing.CurTime;
+ var audioLength = _audio.GetAudioLength(comp.SelectedSong.Path.ToString());
if (comp.Stage < ExpeditionStage.FinalCountdown && remaining < TimeSpan.FromSeconds(45))
{
@@ -151,13 +152,14 @@ public sealed partial class SalvageSystem
Dirty(uid, comp);
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-seconds", ("duration", TimeSpan.FromSeconds(45).Seconds)));
}
- else if (comp.Stage < ExpeditionStage.MusicCountdown && remaining < TimeSpan.FromMinutes(2))
+ else if (comp.Stream == null && remaining < audioLength)
{
- // TODO: Some way to play audio attached to a map for players.
- comp.Stream = _audio.PlayGlobal(comp.Sound, Filter.BroadcastMap(Comp(uid).MapId), true).Value.Entity;
+ var audio = _audio.PlayPvs(comp.Sound, uid).Value;
+ comp.Stream = audio.Entity;
+ _audio.SetMapAudio(audio);
comp.Stage = ExpeditionStage.MusicCountdown;
Dirty(uid, comp);
- Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(2).Minutes)));
+ Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", audioLength.Minutes)));
}
else if (comp.Stage < ExpeditionStage.Countdown && remaining < TimeSpan.FromMinutes(4))
{
diff --git a/Resources/Prototypes/SoundCollections/expeditions.yml b/Resources/Prototypes/SoundCollections/expeditions.yml
new file mode 100644
index 0000000000..665ac12c69
--- /dev/null
+++ b/Resources/Prototypes/SoundCollections/expeditions.yml
@@ -0,0 +1,4 @@
+- type: soundCollection
+ id: ExpeditionEnd
+ files:
+ - /Audio/Misc/tension_session.ogg