SoundSystem Improvements (#3697)

* Refactor all audio to use the new SoundSystem.

* Update submodule

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
Acruid
2021-03-21 09:12:03 -07:00
committed by GitHub
parent d4030edff6
commit 9459400002
104 changed files with 401 additions and 279 deletions

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Interactable
@@ -107,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (LitSound != string.Empty)
{
EntitySystem.Get<AudioSystem>().PlayFromEntity(LitSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), LitSound, Owner);
}
if (IconStateLit != string.Empty)
@@ -127,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (DieSound != string.Empty)
{
EntitySystem.Get<AudioSystem>().PlayFromEntity(DieSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), DieSound, Owner);
}
if (LoopedSound != string.Empty && Owner.TryGetComponent<LoopingLoopingSoundComponent>(out var loopSound))

View File

@@ -14,9 +14,11 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -119,7 +121,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (makeNoise)
{
if (TurnOffSound != null) EntitySystem.Get<AudioSystem>().PlayFromEntity(TurnOffSound, Owner);
if (TurnOffSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound, Owner);
}
return true;
@@ -134,7 +136,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (Cell == null)
{
if (TurnOnFailSound != null) EntitySystem.Get<AudioSystem>().PlayFromEntity(TurnOnFailSound, Owner);
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner);
Owner.PopupMessage(user, Loc.GetString("Cell missing..."));
UpdateLightAction();
return false;
@@ -145,7 +147,7 @@ namespace Content.Server.GameObjects.Components.Interactable
// Simple enough.
if (Wattage > Cell.CurrentCharge)
{
if (TurnOnFailSound != null) EntitySystem.Get<AudioSystem>().PlayFromEntity(TurnOnFailSound, Owner);
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner);
Owner.PopupMessage(user, Loc.GetString("Dead cell..."));
UpdateLightAction();
return false;
@@ -156,7 +158,7 @@ namespace Content.Server.GameObjects.Components.Interactable
SetState(true);
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
if (TurnOnSound != null) EntitySystem.Get<AudioSystem>().PlayFromEntity(TurnOnSound, Owner);
if (TurnOnSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound, Owner);
return true;
}

View File

@@ -1,10 +1,12 @@
#nullable enable
#nullable enable
using System.Threading.Tasks;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -68,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Interactable
// Play Sound
if (!string.IsNullOrEmpty(_igniteSound))
{
EntitySystem.Get<AudioSystem>().PlayFromEntity(_igniteSound, Owner,
SoundSystem.Play(Filter.Pvs(Owner), _igniteSound, Owner,
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
}

View File

@@ -3,7 +3,9 @@ using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -44,7 +46,6 @@ namespace Content.Server.GameObjects.Components.Interactable
[DataField("tools")] private List<ToolEntry> _tools = new();
private int _currentTool = 0;
private AudioSystem _audioSystem = default!;
private ToolComponent? _tool;
private SpriteComponent? _sprite;
@@ -53,9 +54,6 @@ namespace Content.Server.GameObjects.Components.Interactable
base.Initialize();
Owner.TryGetComponent(out _tool);
Owner.TryGetComponent(out _sprite);
_audioSystem = EntitySystem.Get<AudioSystem>();
SetTool();
}
@@ -65,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Interactable
SetTool();
var current = _tools[_currentTool];
if(!string.IsNullOrEmpty(current.ChangeSound))
_audioSystem.PlayFromEntity(current.ChangeSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), current.ChangeSound, Owner);
}
private void SetTool()

View File

@@ -5,7 +5,9 @@ using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -102,8 +104,7 @@ namespace Content.Server.GameObjects.Components.Interactable
}
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
EntitySystem.Get<AudioSystem>()
.PlayFromEntity(file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
public void PlayUseSound(float volume=-5f)
@@ -112,8 +113,7 @@ namespace Content.Server.GameObjects.Components.Interactable
{
if (!string.IsNullOrEmpty(UseSound))
{
EntitySystem.Get<AudioSystem>()
.PlayFromEntity(UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
SoundSystem.Play(Filter.Pvs(Owner), UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
}
else

View File

@@ -17,9 +17,11 @@ using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
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.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -321,7 +323,7 @@ namespace Content.Server.GameObjects.Components.Interactable
var drained = targetSolution.Drain(trans);
_solutionComponent.TryAddSolution(drained);
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/refill.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/refill.ogg", Owner);
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("Welder refueled"));
}
}