forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
246 changed files
with
16,476 additions
and
12,457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using Content.Shared.Audio; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.GameTicking; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client.Audio; | ||
|
||
public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem | ||
{ | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
|
||
// Admin music | ||
private bool _adminAudioEnabled = true; | ||
private List<IPlayingAudioStream?> _adminAudio = new(1); | ||
|
||
// Event sounds (e.g. nuke timer) | ||
private bool _eventAudioEnabled = true; | ||
private Dictionary<StationEventMusicType, IPlayingAudioStream?> _eventAudio = new(1); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart); | ||
SubscribeNetworkEvent<AdminSoundEvent>(PlayAdminSound); | ||
_cfg.OnValueChanged(CCVars.AdminSoundsEnabled, ToggleAdminSound, true); | ||
|
||
SubscribeNetworkEvent<StationEventMusicEvent>(PlayStationEventMusic); | ||
SubscribeNetworkEvent<StopStationEventMusic>(StopStationEventMusic); | ||
_cfg.OnValueChanged(CCVars.EventMusicEnabled, ToggleStationEventMusic, true); | ||
|
||
SubscribeNetworkEvent<GameGlobalSoundEvent>(PlayGameSound); | ||
} | ||
|
||
private void OnRoundRestart(RoundRestartCleanupEvent ev) | ||
{ | ||
ClearAudio(); | ||
} | ||
|
||
public override void Shutdown() | ||
{ | ||
base.Shutdown(); | ||
ClearAudio(); | ||
} | ||
|
||
private void ClearAudio() | ||
{ | ||
foreach (var stream in _adminAudio) | ||
{ | ||
stream?.Stop(); | ||
} | ||
_adminAudio.Clear(); | ||
|
||
foreach (var (_, stream) in _eventAudio) | ||
{ | ||
stream?.Stop(); | ||
} | ||
|
||
_eventAudio.Clear(); | ||
} | ||
|
||
private void PlayAdminSound(AdminSoundEvent soundEvent) | ||
{ | ||
if(!_adminAudioEnabled) return; | ||
|
||
var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); | ||
_adminAudio.Add(stream); | ||
} | ||
|
||
private void PlayStationEventMusic(StationEventMusicEvent soundEvent) | ||
{ | ||
// Either the cvar is disabled or it's already playing | ||
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return; | ||
|
||
var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); | ||
_eventAudio.Add(soundEvent.Type, stream); | ||
} | ||
|
||
private void PlayGameSound(GameGlobalSoundEvent soundEvent) | ||
{ | ||
SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); | ||
} | ||
|
||
private void StopStationEventMusic(StopStationEventMusic soundEvent) | ||
{ | ||
if (!_eventAudio.TryGetValue(soundEvent.Type, out var stream)) return; | ||
stream?.Stop(); | ||
_eventAudio.Remove(soundEvent.Type); | ||
} | ||
|
||
private void ToggleAdminSound(bool enabled) | ||
{ | ||
_adminAudioEnabled = enabled; | ||
if (_adminAudioEnabled) return; | ||
foreach (var stream in _adminAudio) | ||
{ | ||
stream?.Stop(); | ||
} | ||
_adminAudio.Clear(); | ||
} | ||
|
||
private void ToggleStationEventMusic(bool enabled) | ||
{ | ||
_eventAudioEnabled = enabled; | ||
if (_eventAudioEnabled) return; | ||
foreach (var stream in _eventAudio) | ||
{ | ||
stream.Value?.Stop(); | ||
} | ||
_eventAudio.Clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
Content.IntegrationTests/Tests/Destructible/TestDestructibleListenerSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Content.Server.Access.Systems; | ||
|
||
namespace Content.Server.Access.Components; | ||
|
||
[RegisterComponent, Access(typeof(IdExaminableSystem))] | ||
public sealed class IdExaminableComponent : Component | ||
{ | ||
} |
Oops, something went wrong.