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:
14
Content.Server/Audio/AmbientOnPoweredComponent.cs
Normal file
14
Content.Server/Audio/AmbientOnPoweredComponent.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Audio
|
||||
{
|
||||
/// <summary>
|
||||
/// Toggles <see cref="AmbientSoundComponent"/> on when powered and off when not powered.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class AmbientOnPoweredComponent : Component
|
||||
{
|
||||
public override string Name => "AmbientOnPowered";
|
||||
}
|
||||
}
|
||||
23
Content.Server/Audio/AmbientSoundSystem.cs
Normal file
23
Content.Server/Audio/AmbientSoundSystem.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user