diff --git a/Content.Client/GameObjects/Components/PDA/PDAComponent.cs b/Content.Client/GameObjects/Components/PDA/PDAComponent.cs index 799c323a01..3e3cace9dd 100644 --- a/Content.Client/GameObjects/Components/PDA/PDAComponent.cs +++ b/Content.Client/GameObjects/Components/PDA/PDAComponent.cs @@ -1,8 +1,8 @@ using Content.Shared.GameObjects.Components.PDA; -using Robust.Client.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Players; namespace Content.Client.GameObjects.Components.PDA @@ -16,11 +16,11 @@ namespace Content.Client.GameObjects.Components.PDA switch(message) { case PDAUplinkBuySuccessMessage _ : - EntitySystem.Get().Play("/Audio/Effects/kaching.ogg", Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Local(), "/Audio/Effects/kaching.ogg", Owner, AudioParams.Default.WithVolume(-2f)); break; case PDAUplinkInsufficientFundsMessage _ : - EntitySystem.Get().Play("/Audio/Effects/error.ogg", Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); break; } diff --git a/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs b/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs index ad52eb4dce..a780dd79ab 100644 --- a/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs +++ b/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs @@ -1,10 +1,11 @@ using System.Collections.Generic; using Content.Shared.GameObjects.Components.Sound; using Content.Shared.Physics; -using Robust.Client.GameObjects; +using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Random; using Robust.Shared.Serialization; @@ -17,7 +18,6 @@ namespace Content.Client.GameObjects.Components.Sound [Dependency] private readonly IRobustRandom _random = default!; private readonly Dictionary _audioStreams = new(); - private AudioSystem _audioSystem; public override void StopAllSounds() { @@ -52,15 +52,14 @@ namespace Content.Client.GameObjects.Components.Sound Owner.SpawnTimer((int) schedule.Delay + (_random.Next((int) schedule.RandomDelay)),() => { if (!schedule.Play) return; // We make sure this hasn't changed. - if (_audioSystem == null) _audioSystem = EntitySystem.Get(); if (!_audioStreams.ContainsKey(schedule)) { - _audioStreams.Add(schedule,_audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams)); + _audioStreams.Add(schedule,SoundSystem.Play(Filter.Local(), schedule.Filename, Owner, schedule.AudioParams)); } else { - _audioStreams[schedule] = _audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams); + _audioStreams[schedule] = SoundSystem.Play(Filter.Local(), schedule.Filename, Owner, schedule.AudioParams); } if (schedule.Times == 0) return; @@ -93,7 +92,7 @@ namespace Content.Client.GameObjects.Components.Sound public override void Initialize() { base.Initialize(); - if (EntitySystem.TryGet(out _audioSystem)) _audioSystem.OcclusionCollisionMask = (int) CollisionGroup.Impassable; + SoundSystem.OcclusionCollisionMask = (int) CollisionGroup.Impassable; } public override void ExposeData(ObjectSerializer serializer) diff --git a/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs b/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs index 2351a00b5f..ae4cb13494 100644 --- a/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs @@ -100,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Singularity private SpriteComponent? _spriteComponent; private RadiationPulseComponent? _radiationPulseComponent; private AudioSystem _audioSystem = null!; - private AudioSystem.AudioSourceServer? _playingSound; + private IPlayingAudioStream? _playingSound; public override void Initialize() { diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index af66bc9ccc..5604a1fe77 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -20,6 +20,7 @@ using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Physics; +using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Serialization; @@ -211,12 +212,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels /// Target position on the map to shoot at. private void Fire(IEntity shooter, Vector2 targetPos) { - var soundSystem = EntitySystem.Get(); if (ShotsLeft == 0) { if (_soundEmpty != null) { - soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), _soundEmpty, Owner.Transform.Coordinates); } return; } @@ -225,7 +225,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var projectile = TakeProjectile(shooter.Transform.Coordinates); if (projectile == null) { - soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), _soundEmpty, Owner.Transform.Coordinates); return; } @@ -266,7 +266,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels throw new InvalidOperationException(); } - soundSystem.PlayAtCoords(_soundGunshot, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), _soundGunshot, Owner.Transform.Coordinates); _lastFire = _gameTiming.CurTime; return; @@ -316,7 +316,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var soundCollection = prototypeManager.Index(ammo.SoundCollectionEject); var randomFile = robustRandom.Pick(soundCollection.PickFiles); - EntitySystem.Get().PlayAtCoords(randomFile, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); + SoundSystem.Play(Filter.Broadcast(), randomFile, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } /// diff --git a/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs b/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs index 4333b9f6d0..884cee1660 100644 --- a/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs @@ -4,9 +4,11 @@ using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.GameTicking; using Content.Shared.GameTicking; using Robust.Server.GameObjects; +using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Player; using Robust.Shared.Timing; using Timer = Robust.Shared.Timing.Timer; @@ -80,7 +82,7 @@ namespace Content.Server.GameObjects.EntitySystems _chatManager.DispatchStationAnnouncement(Loc.GetString("An emergency shuttle has been sent. ETA: {0} minutes.", RoundEndCountdownTime.Minutes), Loc.GetString("Station")); - Get().PlayGlobal("/Audio/Announcements/shuttlecalled.ogg"); + SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg"); ExpectedCountdownEnd = _gameTiming.CurTime + RoundEndCountdownTime; Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token); @@ -104,7 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems _chatManager.DispatchStationAnnouncement(Loc.GetString("The emergency shuttle has been recalled."), Loc.GetString("Station")); - Get().PlayGlobal("/Audio/Announcements/shuttlerecalled.ogg"); + SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlerecalled.ogg"); _roundEndCancellationTokenSource.Cancel(); _roundEndCancellationTokenSource = new CancellationTokenSource(); diff --git a/Content.Server/GameTicking/GameRules/RuleSuspicion.cs b/Content.Server/GameTicking/GameRules/RuleSuspicion.cs index 1da4163b8e..7ca52223c4 100644 --- a/Content.Server/GameTicking/GameRules/RuleSuspicion.cs +++ b/Content.Server/GameTicking/GameRules/RuleSuspicion.cs @@ -9,13 +9,13 @@ using Content.Server.Mobs.Roles.Suspicion; using Content.Server.Players; using Content.Shared; using Content.Shared.GameObjects.Components.Mobs.State; -using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Player; using Robust.Shared.Timing; using Timer = Robust.Shared.Timing.Timer; @@ -48,9 +48,9 @@ namespace Content.Server.GameTicking.GameRules _chatManager.DispatchServerAnnouncement(Loc.GetString("There are traitors on the station! Find them, and kill them!")); - bool Predicate(IPlayerSession session) => session.ContentData()?.Mind?.HasRole() ?? false; - - EntitySystem.Get().PlayGlobal("/Audio/Misc/tatoralert.ogg", AudioParams.Default, Predicate); + var filter = Filter.Empty() + .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); + SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default); EntitySystem.Get().EndTime = _endTime; EntitySystem.Get().AccessType = ServerDoorSystem.AccessTypes.AllowAllNoExternal; diff --git a/Content.Server/GameTicking/GameRules/RuleTraitor.cs b/Content.Server/GameTicking/GameRules/RuleTraitor.cs index 7ca6614cd4..d892d05afd 100644 --- a/Content.Server/GameTicking/GameRules/RuleTraitor.cs +++ b/Content.Server/GameTicking/GameRules/RuleTraitor.cs @@ -1,12 +1,11 @@ -using Content.Server.Interfaces.Chat; +using Content.Server.Interfaces.Chat; using Content.Server.Mobs.Roles.Traitor; using Content.Server.Players; -using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Player; namespace Content.Server.GameTicking.GameRules { @@ -18,9 +17,9 @@ namespace Content.Server.GameTicking.GameRules { _chatManager.DispatchServerAnnouncement(Loc.GetString("Hello crew! Have a good shift!")); - bool Predicate(IPlayerSession session) => session.ContentData()?.Mind?.HasRole() ?? false; - - EntitySystem.Get().PlayGlobal("/Audio/Misc/tatoralert.ogg", AudioParams.Default, Predicate); + var filter = Filter.Empty() + .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); + SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default); } } } diff --git a/Content.Server/StationEvents/PowerGridCheck.cs b/Content.Server/StationEvents/PowerGridCheck.cs index b067c80446..e66ded5587 100644 --- a/Content.Server/StationEvents/PowerGridCheck.cs +++ b/Content.Server/StationEvents/PowerGridCheck.cs @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable using System.Collections.Generic; using System.Threading; using Content.Server.GameObjects.Components.Power.ApcNetComponents; using JetBrains.Annotations; -using Robust.Server.GameObjects; +using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Player; using Robust.Shared.Random; using Timer = Robust.Shared.Timing.Timer; @@ -68,7 +69,7 @@ namespace Content.Server.StationEvents _announceCancelToken = new CancellationTokenSource(); Timer.Spawn(3000, () => { - EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_on.ogg"); + SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/power_on.ogg"); }, _announceCancelToken.Token); _powered.Clear(); diff --git a/Content.Server/StationEvents/StationEvent.cs b/Content.Server/StationEvents/StationEvent.cs index f298bc9690..2a10161ffc 100644 --- a/Content.Server/StationEvents/StationEvent.cs +++ b/Content.Server/StationEvents/StationEvent.cs @@ -1,9 +1,8 @@ -#nullable enable +#nullable enable using Content.Server.Interfaces.Chat; -using Robust.Server.GameObjects; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; using Robust.Shared.IoC; +using Robust.Shared.Player; namespace Content.Server.StationEvents { @@ -121,7 +120,7 @@ namespace Content.Server.StationEvents if (StartAudio != null) { - EntitySystem.Get().PlayGlobal(StartAudio, AudioParams.Default.WithVolume(-10f)); + SoundSystem.Play(Filter.Broadcast(), StartAudio, AudioParams.Default.WithVolume(-10f)); } Announced = true; @@ -141,7 +140,7 @@ namespace Content.Server.StationEvents if (EndAudio != null) { - EntitySystem.Get().PlayGlobal(EndAudio, AudioParams.Default.WithVolume(-10f)); + SoundSystem.Play(Filter.Broadcast(), EndAudio, AudioParams.Default.WithVolume(-10f)); } Started = false; diff --git a/RobustToolbox b/RobustToolbox index 24707b7385..06e62b031a 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 24707b738590b53c72fb73aa5c61dfec87a6d2f9 +Subproject commit 06e62b031a036749ed1292a722169e94ab2f2bdf