From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 7 Jan 2024 13:23:22 +0000 (+1100) Subject: Fix audio fades (#23684) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=bc07cbc97ce365dde83ee4e5b32a4ffa603b1d5e;p=space-station-14.git Fix audio fades (#23684) Audio refactor casualty --- 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)) {