Files
wwdpublic/Content.Server/Audio/ServerGlobalSoundSystem.cs
SimpleStation14 883ded1154 Mirror: Nuke Music start adjusted for duration (#163)
## Mirror of PR #25946: [Nuke Music start adjusted for
duration](https://github.com/space-wizards/space-station-14/pull/25946)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `680cf5fec13b92f09355acec9892f2db51f3e80e`

PR opened by <img
src="https://avatars.githubusercontent.com/u/35878406?v=4"
width="16"/><a href="https://github.com/Errant-4"> Errant-4</a> at
2024-03-09 18:24:36 UTC
PR merged by <img
src="https://avatars.githubusercontent.com/u/19864447?v=4"
width="16"/><a href="https://github.com/web-flow"> web-flow</a> at
2024-03-12 18:50:34 UTC

---

PR changed 2 files with 16 additions and 5 deletions.

The PR had the following labels:


---

<details open="true"><summary><h1>Original Body</h1></summary>

> ## About the PR
> 
> Nuke Music now begins playing at the appropriate time to end
just-on-target regardless of the duration of the music (as long as it's
less than 290 seconds)
> 
> fixes  #25775
> 
> ## Media
> - [X] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> 


</details>

Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com>
2024-05-08 23:26:31 -04:00

67 lines
2.4 KiB
C#

using Content.Server.Station.Systems;
using Content.Shared.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Console;
using Robust.Shared.Player;
namespace Content.Server.Audio;
public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
{
[Dependency] private readonly IConsoleHost _conHost = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Shutdown()
{
base.Shutdown();
_conHost.UnregisterCommand("playglobalsound");
}
public void PlayAdminGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null, bool replay = true)
{
var msg = new AdminSoundEvent(filename, audioParams);
RaiseNetworkEvent(msg, playerFilter, recordReplay: replay);
}
private Filter GetStationAndPvs(EntityUid source)
{
var stationFilter = _stationSystem.GetInOwningStation(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)
{
// TODO REPLAYS
// these start & stop events are gonna be a PITA
// theres probably some nice way of handling them. Maybe it just needs dedicated replay data (in which case these events should NOT get recorded).
var msg = new StopStationEventMusic(type);
var filter = GetStationAndPvs(source);
RaiseNetworkEvent(msg, filter);
}
public void DispatchStationEventMusic(EntityUid source, SoundSpecifier sound, StationEventMusicType type)
{
DispatchStationEventMusic(source, _audio.GetSound(sound), type);
}
public void DispatchStationEventMusic(EntityUid source, string sound, StationEventMusicType type)
{
var audio = AudioParams.Default.WithVolume(-8);
var msg = new StationEventMusicEvent(sound, type, audio);
var filter = GetStationAndPvs(source);
RaiseNetworkEvent(msg, filter);
}
}