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).
This commit is contained in:
parent
0b0bd83120
commit
48c81209d6
|
|
@ -40,14 +40,21 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
|
|||
/// <summary>
|
||||
/// Countdown audio stream.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? Stream = null;
|
||||
|
||||
/// <summary>
|
||||
/// Sound that plays when the mission end is imminent.
|
||||
/// </summary>
|
||||
[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),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Song selected on MapInit so we can predict the audio countdown properly.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public SoundPathSpecifier SelectedSong;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<SalvageExpeditionConsoleComponent, EntParentChangedMessage>(OnSalvageConsoleParent);
|
||||
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, ClaimSalvageMessage>(OnSalvageClaimMessage);
|
||||
|
||||
SubscribeLocalEvent<SalvageExpeditionComponent, MapInitEvent>(OnExpeditionMapInit);
|
||||
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentShutdown>(OnExpeditionShutdown);
|
||||
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentGetState>(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);
|
||||
|
|
|
|||
|
|
@ -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<MapComponent>(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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
- type: soundCollection
|
||||
id: ExpeditionEnd
|
||||
files:
|
||||
- /Audio/Misc/tension_session.ogg
|
||||
Loading…
Reference in New Issue