]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Replace some sound PlayEntity with PlayPvs (#34317)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 10 Jan 2025 14:44:30 +0000 (01:44 +1100)
committerGitHub <noreply@github.com>
Fri, 10 Jan 2025 14:44:30 +0000 (01:44 +1100)
Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs
Content.Server/Light/EntitySystems/PoweredLightSystem.cs
Content.Server/Nuke/NukeSystem.cs
Content.Server/Power/Generator/PortableGeneratorSystem.cs
Content.Shared/Audio/AudioHelpers.cs

index 42b66b5479facbd92855ebb2264379b59d5706e6..0962674504deaaa7bdaee1272ddbde763b3b634f 100644 (file)
@@ -356,6 +356,11 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
         // + if the bomb is big enough, people outside of it too
         // this is capped to 30 because otherwise really huge bombs
         // will attempt to play regular audio for people who can't hear it anyway because the epicenter is so far away
+        //
+        // TODO EXPLOSION redo this.
+        // Use the Filter.Pvs range-multiplier option instead of AddInRange.
+        // Also the default PVS range is 25*2 = 50. So capping it at 30 makes no sense here.
+        // So actually maybe don't use Filter.Pvs at all and only use AddInRange?
         var audioRange = Math.Min(iterationIntensity.Count * 2, MaxExplosionAudioRange);
         var filter = Filter.Pvs(pos).AddInRange(pos, audioRange);
         var sound = iterationIntensity.Count < queued.Proto.SmallSoundIterationThreshold
index fec65430c12ca2e7b3da22eadaa8e1aeae7d3ae5..9b70426faa7f0f1c30ae45562eaea33e49b7070f 100644 (file)
@@ -165,7 +165,7 @@ namespace Content.Server.Kitchen.EntitySystems
                 QueueDel(gib);
             }
 
-            _audio.PlayEntity(component.SpikeSound, Filter.Pvs(uid), uid, true);
+            _audio.PlayPvs(component.SpikeSound, uid);
         }
 
         private bool TryGetPiece(EntityUid uid, EntityUid user, EntityUid used,
index 3bd788bcf43f3f787309a26d35ef950a36fd2205..bc4b80be97a49c12e2714266319c08d825e2aba7 100644 (file)
@@ -275,7 +275,7 @@ namespace Content.Server.Light.EntitySystems
                         if (time > light.LastThunk + ThunkDelay)
                         {
                             light.LastThunk = time;
-                            _audio.PlayEntity(light.TurnOnSound, Filter.Pvs(uid), uid, true, AudioParams.Default.WithVolume(-10f));
+                            _audio.PlayPvs(light.TurnOnSound, uid, light.TurnOnSound.Params.AddVolume(-10f));
                         }
                     }
                     else
index ffeb852e8b5de93b3403f14bb5b5b144cc516da9..0a6228750580e1174f5b479ffbf3c285ae4a8c68 100644 (file)
@@ -235,7 +235,7 @@ public sealed class NukeSystem : EntitySystem
 
     private void OnClearButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadClearMessage args)
     {
-        _audio.PlayEntity(component.KeypadPressSound, Filter.Pvs(uid), uid, true);
+        _audio.PlayPvs(component.KeypadPressSound, uid);
 
         if (component.Status != NukeStatus.AWAIT_CODE)
             return;
@@ -351,12 +351,12 @@ public sealed class NukeSystem : EntitySystem
                 {
                     component.Status = NukeStatus.AWAIT_ARM;
                     component.RemainingTime = component.Timer;
-                    _audio.PlayEntity(component.AccessGrantedSound, Filter.Pvs(uid), uid, true);
+                    _audio.PlayPvs(component.AccessGrantedSound, uid);
                 }
                 else
                 {
                     component.EnteredCode = "";
-                    _audio.PlayEntity(component.AccessDeniedSound, Filter.Pvs(uid), uid, true);
+                    _audio.PlayPvs(component.AccessDeniedSound, uid);
                 }
 
                 break;
@@ -425,7 +425,9 @@ public sealed class NukeSystem : EntitySystem
         // Don't double-dip on the octave shifting
         component.LastPlayedKeypadSemitones = number == 0 ? component.LastPlayedKeypadSemitones : semitoneShift;
 
-        _audio.PlayEntity(component.KeypadPressSound, Filter.Pvs(uid), uid, true, AudioHelpers.ShiftSemitone(semitoneShift).WithVolume(-5f));
+        var opts = component.KeypadPressSound.Params;
+        opts = AudioHelpers.ShiftSemitone(opts, semitoneShift).AddVolume(-5f);
+        _audio.PlayPvs(component.KeypadPressSound, uid, opts);
     }
 
     public string GenerateRandomNumberString(int length)
index 0ee228680ebbae9a46b36c4c9b1fce035b689d25..a2d506f6c25998954342efdbf5a79d533b8e54c4 100644 (file)
@@ -117,7 +117,7 @@ public sealed class PortableGeneratorSystem : SharedPortableGeneratorSystem
         var clogged = _generator.GetIsClogged(uid);
 
         var sound = empty ? component.StartSoundEmpty : component.StartSound;
-        _audio.PlayEntity(sound, Filter.Pvs(uid), uid, true);
+        _audio.PlayPvs(sound, uid);
 
         if (!clogged && !empty && _random.Prob(component.StartChance))
         {
index 74ec0361ec50e95c5376fa89c4741aedc87b6a61..b6159ecccccbb4bfe208498678840ff818414257 100644 (file)
@@ -4,11 +4,12 @@ using Robust.Shared.Random;
 
 namespace Content.Shared.Audio
 {
-    public static class AudioHelpers{
+    public static class AudioHelpers
+    {
         /// <summary>
         ///     Returns a random pitch.
         /// </summary>
-        [Obsolete("Use variation datafield.")]
+        [Obsolete("Use AudioParams.Variation data-field")]
         public static AudioParams WithVariation(float amplitude)
         {
             return WithVariation(amplitude, null);
@@ -17,6 +18,7 @@ namespace Content.Shared.Audio
         /// <summary>
         ///     Returns a random pitch.
         /// </summary>
+        [Obsolete("Use AudioParams.Variation data-field")]
         public static AudioParams WithVariation(float amplitude, IRobustRandom? rand)
         {
             IoCManager.Resolve(ref rand);
@@ -42,22 +44,22 @@ namespace Content.Shared.Audio
         /// </summary>
         /// <param name="shift">Number of semitones to shift, positive or negative. Clamped between -12 and 12
         /// which correspond to a pitch multiplier of 0.5 and 2.0 respectively.</param>
-        public static AudioParams ShiftSemitone(int shift)
+        public static AudioParams ShiftSemitone(AudioParams @params, int shift)
         {
             shift = MathHelper.Clamp(shift, -12, 12);
             float pitchMult = SemitoneMultipliers[shift + 12];
-            return AudioParams.Default.WithPitchScale(pitchMult);
+            return @params.WithPitchScale(pitchMult);
         }
 
         /// <summary>
         /// Returns a pitch multiplier shifted by a random number of semitones within variation.
         /// </summary>
         /// <param name="variation">Max number of semitones to shift in either direction. Values above 12 have no effect.</param>
-        public static AudioParams WithSemitoneVariation(int variation, IRobustRandom? rand)
+        public static AudioParams WithSemitoneVariation(AudioParams @params, int variation, IRobustRandom rand)
         {
             IoCManager.Resolve(ref rand);
             variation = Math.Clamp(variation, 0, 12);
-            return ShiftSemitone(rand.Next(-variation, variation));
+            return ShiftSemitone(@params, rand.Next(-variation, variation));
         }
     }
 }