]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix ambient audio (#21933)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Tue, 28 Nov 2023 03:09:25 +0000 (14:09 +1100)
committerGitHub <noreply@github.com>
Tue, 28 Nov 2023 03:09:25 +0000 (14:09 +1100)
Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs

index cdf4c71e8280ffeb54c0f25e0e0a93b8a2b04acc..1860d81118ccadb21a8c499d06004587e02af80a 100644 (file)
@@ -9,6 +9,7 @@ using Robust.Client.Player;
 using Robust.Client.ResourceManagement;
 using Robust.Client.State;
 using Robust.Shared.Audio;
+using Robust.Shared.Audio.Components;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Configuration;
 using Robust.Shared.Player;
@@ -59,12 +60,6 @@ public sealed partial class ContentAudioSystem
 
     private void InitializeAmbientMusic()
     {
-        // TODO: Shitty preload
-        foreach (var audio in _proto.Index<SoundCollectionPrototype>("AmbienceSpace").PickFiles)
-        {
-            _resource.GetResource<AudioResource>(audio.ToString());
-        }
-
         _configManager.OnValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged, true);
         _sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("audio.ambience");
 
@@ -170,11 +165,16 @@ public sealed partial class ContentAudioSystem
             return;
         }
 
-        var isDone = !Exists(_ambientMusicStream);
+        bool? isDone = null;
+
+        if (TryComp(_ambientMusicStream, out AudioComponent? audioComp))
+        {
+            isDone = !audioComp.Playing;
+        }
 
         if (_interruptable)
         {
-            var player = _player.LocalPlayer?.ControlledEntity;
+            var player = _player.LocalSession?.AttachedEntity;
 
             if (player == null || _musicProto == null || !_rules.IsTrue(player.Value, _proto.Index<RulesPrototype>(_musicProto.Rules)))
             {