mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Stop empty audio system filters from playing sounds for all players (#5444)
* Fix audio system empty filter bug * The nullable attributes are lying
This commit is contained in:
@@ -66,32 +66,26 @@ public sealed partial class AudioSystem : SharedAudioSystem
|
||||
|
||||
private void AddAudioFilter(EntityUid uid, AudioComponent component, Filter filter)
|
||||
{
|
||||
var count = filter.Count;
|
||||
DebugTools.Assert(component.IncludedEntities == null);
|
||||
component.IncludedEntities = new();
|
||||
|
||||
if (count == 0)
|
||||
if (filter.Count == 0)
|
||||
return;
|
||||
|
||||
_pvs.AddSessionOverrides(uid, filter);
|
||||
|
||||
var ents = new HashSet<EntityUid>(count);
|
||||
|
||||
foreach (var session in filter.Recipients)
|
||||
{
|
||||
var ent = session.AttachedEntity;
|
||||
|
||||
if (ent == null)
|
||||
continue;
|
||||
|
||||
ents.Add(ent.Value);
|
||||
if (session.AttachedEntity is {} ent)
|
||||
component.IncludedEntities.Add(ent);
|
||||
}
|
||||
|
||||
DebugTools.Assert(component.IncludedEntities == null);
|
||||
component.IncludedEntities = ents;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override (EntityUid Entity, AudioComponent Component)? PlayGlobal(string? filename, Filter playerFilter, bool recordReplay, AudioParams? audioParams = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return null;
|
||||
|
||||
var entity = SetupAudio(filename, audioParams);
|
||||
AddAudioFilter(entity, entity.Comp, playerFilter);
|
||||
entity.Comp.Global = true;
|
||||
|
||||
Reference in New Issue
Block a user