Prune most yml ambientsound entries (#8573)

This commit is contained in:
metalgearsloth
2022-06-03 20:42:35 +10:00
committed by GitHub
parent 849490cd40
commit b29ed6e03a
5 changed files with 109 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using Content.Shared.Audio;
using Content.Shared.CCVar;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
@@ -29,8 +30,9 @@ namespace Content.Client.Audio
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private AmbientSoundOverlay? _overlay;
private int _maxAmbientCount;
private bool _overlayEnabled;
private float _maxAmbientRange;
private float _cooldown;
private float _accumulator;
@@ -45,7 +47,37 @@ namespace Content.Client.Audio
private const float RangeBuffer = 3f;
public bool OverlayEnabled
{
get => _overlayEnabled;
set
{
if (_overlayEnabled == value) return;
_overlayEnabled = value;
var overlayManager = IoCManager.Resolve<IOverlayManager>();
if (_overlayEnabled)
{
_overlay = new AmbientSoundOverlay(EntityManager, this, Get<EntityLookupSystem>());
overlayManager.AddOverlay(_overlay);
}
else
{
overlayManager.RemoveOverlay(_overlay!);
_overlay = null;
}
}
}
/// <summary>
/// Is this AmbientSound actively playing right now?
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
public bool IsActive(AmbientSoundComponent component)
{
return _playingSounds.ContainsKey(component);
}
public override void Initialize()
{