Ambient sound system (#4552)

* Ambient sound system

Client-side system that plays audio from nearby objects that are randomly sampled.

* Decent

* Tweaks

* Tweaks

* Comment this out for now

* reduce VM sound

* Fix rolloff

* Fixes

* Volume tweak
This commit is contained in:
metalgearsloth
2021-09-07 18:47:23 +10:00
committed by GitHub
parent 97af34f70a
commit ff40a7665d
25 changed files with 361 additions and 6 deletions

View File

@@ -0,0 +1,23 @@
using Content.Server.Power.Components;
using Content.Shared.Audio;
using Robust.Shared.GameObjects;
namespace Content.Server.Audio
{
public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AmbientOnPoweredComponent, PowerChangedEvent>(HandlePowerChange);
}
private void HandlePowerChange(EntityUid uid, AmbientOnPoweredComponent component, PowerChangedEvent args)
{
if (!ComponentManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambientSound)) return;
if (ambientSound.Enabled == args.Powered) return;
ambientSound.Enabled = args.Powered;
ambientSound.Dirty();
}
}
}