Event Music & Nuke Countdown Song (#8597)
Co-authored-by: ike709 <ike709@github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Console;
|
||||
@@ -8,10 +11,11 @@ using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Audio;
|
||||
|
||||
public sealed class ServerAdminSoundSystem : SharedAdminSoundSystem
|
||||
public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
{
|
||||
[Dependency] private readonly IConsoleHost _conHost = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -25,12 +29,43 @@ public sealed class ServerAdminSoundSystem : SharedAdminSoundSystem
|
||||
_conHost.UnregisterCommand("playglobalsound");
|
||||
}
|
||||
|
||||
private void PlayGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null)
|
||||
private void PlayAdminGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null)
|
||||
{
|
||||
var msg = new AdminSoundEvent(filename, audioParams);
|
||||
RaiseNetworkEvent(msg, playerFilter);
|
||||
}
|
||||
|
||||
private Filter GetStationAndPvs(EntityUid source)
|
||||
{
|
||||
var stationFilter = _stationSystem.GetInStation(source);
|
||||
stationFilter.AddPlayersByPvs(source, entityManager: EntityManager);
|
||||
return stationFilter;
|
||||
}
|
||||
|
||||
public void PlayGlobalOnStation(EntityUid source, string filename, AudioParams? audioParams = null)
|
||||
{
|
||||
var msg = new GameGlobalSoundEvent(filename, audioParams);
|
||||
var filter = GetStationAndPvs(source);
|
||||
RaiseNetworkEvent(msg, filter);
|
||||
}
|
||||
|
||||
public void StopStationEventMusic(EntityUid source, StationEventMusicType type)
|
||||
{
|
||||
var msg = new StopStationEventMusic(type);
|
||||
var filter = GetStationAndPvs(source);
|
||||
RaiseNetworkEvent(msg, filter);
|
||||
}
|
||||
|
||||
public void DispatchStationEventMusic(EntityUid source, SoundSpecifier sound, StationEventMusicType type)
|
||||
{
|
||||
var audio = AudioParams.Default.WithVolume(-8);
|
||||
var soundFile = sound.GetSound();
|
||||
var msg = new StationEventMusicEvent(soundFile, type, audio);
|
||||
|
||||
var filter = GetStationAndPvs(source);
|
||||
RaiseNetworkEvent(msg, filter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command that allows admins to play global sounds.
|
||||
/// </summary>
|
||||
@@ -96,6 +131,6 @@ public sealed class ServerAdminSoundSystem : SharedAdminSoundSystem
|
||||
break;
|
||||
}
|
||||
|
||||
PlayGlobal(filter, args[0], audio);
|
||||
PlayAdminGlobal(filter, args[0], audio);
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,9 @@ namespace Content.Server.Nuke
|
||||
[DataField("disarmSound")]
|
||||
public SoundSpecifier DisarmSound = new SoundPathSpecifier("/Audio/Misc/notice2.ogg");
|
||||
|
||||
[DataField("armMusic")]
|
||||
public SoundSpecifier ArmMusic = new SoundPathSpecifier("/Audio/StationEvents/countdown.ogg");
|
||||
|
||||
// These datafields here are duplicates of those in explosive component. But I'm hesitant to use explosive
|
||||
// component, just in case at some point, somehow, when grenade crafting added in someone manages to wire up a
|
||||
// proximity trigger or something to the nuke and set it off prematurely. I want to make sure they MEAN to set of
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.Audio;
|
||||
using Content.Server.Chat;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat.Systems;
|
||||
@@ -15,6 +16,7 @@ using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Nuke
|
||||
{
|
||||
@@ -26,6 +28,7 @@ namespace Content.Server.Nuke
|
||||
[Dependency] private readonly ExplosionSystem _explosions = default!;
|
||||
[Dependency] private readonly AlertLevelSystem _alertLevel = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly ServerGlobalSoundSystem _soundSystem = default!;
|
||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -218,6 +221,7 @@ namespace Content.Server.Nuke
|
||||
if (nuke.RemainingTime <= nuke.AlertSoundTime && !nuke.PlayedAlertSound)
|
||||
{
|
||||
nuke.AlertAudioStream = SoundSystem.Play(nuke.AlertSound.GetSound(), Filter.Broadcast());
|
||||
_soundSystem.StopStationEventMusic(uid, StationEventMusicType.Nuke);
|
||||
nuke.PlayedAlertSound = true;
|
||||
}
|
||||
|
||||
@@ -335,7 +339,7 @@ namespace Content.Server.Nuke
|
||||
// Otherwise, you could set every station to whatever AlertLevelOnActivate is.
|
||||
if (stationUid != null)
|
||||
{
|
||||
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);
|
||||
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, false, true, true, true);
|
||||
}
|
||||
|
||||
// warn a crew
|
||||
@@ -344,8 +348,7 @@ namespace Content.Server.Nuke
|
||||
var sender = Loc.GetString("nuke-component-announcement-sender");
|
||||
_chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false, Color.Red);
|
||||
|
||||
// todo: move it to announcements system
|
||||
SoundSystem.Play(component.ArmSound.GetSound(), Filter.Broadcast());
|
||||
NukeArmedAudio(component);
|
||||
|
||||
component.Status = NukeStatus.ARMED;
|
||||
UpdateUserInterface(uid, component);
|
||||
@@ -373,8 +376,7 @@ namespace Content.Server.Nuke
|
||||
var sender = Loc.GetString("nuke-component-announcement-sender");
|
||||
_chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false);
|
||||
|
||||
// todo: move it to announcements system
|
||||
SoundSystem.Play(component.DisarmSound.GetSound(), Filter.Broadcast());
|
||||
NukeDisarmedAudio(component);
|
||||
|
||||
// disable sound and reset it
|
||||
component.PlayedAlertSound = false;
|
||||
@@ -423,6 +425,7 @@ namespace Content.Server.Nuke
|
||||
|
||||
RaiseLocalEvent(new NukeExplodedEvent());
|
||||
|
||||
_soundSystem.StopStationEventMusic(component.Owner, StationEventMusicType.Nuke);
|
||||
EntityManager.DeleteEntity(uid);
|
||||
}
|
||||
|
||||
@@ -438,6 +441,18 @@ namespace Content.Server.Nuke
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void NukeArmedAudio(NukeComponent component)
|
||||
{
|
||||
_soundSystem.PlayGlobalOnStation(component.Owner, component.ArmSound.GetSound());
|
||||
_soundSystem.DispatchStationEventMusic(component.Owner, component.ArmMusic, StationEventMusicType.Nuke);
|
||||
}
|
||||
|
||||
private void NukeDisarmedAudio(NukeComponent component)
|
||||
{
|
||||
_soundSystem.PlayGlobalOnStation(component.Owner, component.DisarmSound.GetSound());
|
||||
_soundSystem.StopStationEventMusic(component.Owner, StationEventMusicType.Nuke);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NukeExplodedEvent : EntityEventArgs {}
|
||||
|
||||
@@ -158,6 +158,18 @@ public sealed class StationSystem : EntitySystem
|
||||
|
||||
#endregion Event handlers
|
||||
|
||||
public Filter GetInStation(EntityUid source, float range = 32f)
|
||||
{
|
||||
var station = GetOwningStation(source);
|
||||
|
||||
if (TryComp<StationDataComponent>(station, out var data))
|
||||
{
|
||||
return GetInStation(data);
|
||||
}
|
||||
|
||||
return Filter.Empty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a filter for everything in a particular station or near its member grids.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user