From bc07cbc97ce365dde83ee4e5b32a4ffa603b1d5e Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 8 Jan 2024 00:23:22 +1100 Subject: [PATCH] Fix audio fades (#23684) Audio refactor casualty --- Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs | 4 +--- Content.Client/Audio/ContentAudioSystem.cs | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs b/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs index aafd0ea630..89324f2225 100644 --- a/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs +++ b/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs @@ -26,7 +26,6 @@ public sealed partial class ContentAudioSystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IPrototypeManager _proto = default!; - [Dependency] private readonly IResourceCache _resource = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IStateManager _state = default!; [Dependency] private readonly RulesSystem _rules = default!; @@ -153,8 +152,7 @@ public sealed partial class ContentAudioSystem // Update still runs in lobby so just ignore it. if (_state.CurrentState is not GameplayState) { - Audio.Stop(_ambientMusicStream); - _ambientMusicStream = null; + _ambientMusicStream = Audio.Stop(_ambientMusicStream); _musicProto = null; return; } diff --git a/Content.Client/Audio/ContentAudioSystem.cs b/Content.Client/Audio/ContentAudioSystem.cs index b5d2d4bcdc..ae881766ed 100644 --- a/Content.Client/Audio/ContentAudioSystem.cs +++ b/Content.Client/Audio/ContentAudioSystem.cs @@ -118,7 +118,8 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem } var volume = component.Volume - change * frameTime; - component.Volume = MathF.Max(MinVolume, volume); + volume = MathF.Max(MinVolume, volume); + _audio.SetVolume(stream, volume, component); if (component.Volume.Equals(MinVolume)) { @@ -144,7 +145,8 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem } var volume = component.Volume + change * frameTime; - component.Volume = MathF.Min(target, volume); + volume = MathF.Max(target, volume); + _audio.SetVolume(stream, volume, component); if (component.Volume.Equals(target)) { -- 2.51.2