replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -1,6 +1,7 @@
using Content.Server.Flash.Components;
using Content.Server.Storage.Components;
using Content.Shared.Acts;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -22,7 +23,7 @@ namespace Content.Server.Explosion.Components
[DataField("duration")]
private float _duration = 8.0f;
[DataField("sound")]
private string _sound = "/Audio/Effects/flash_bang.ogg";
private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg");
[DataField("deleteOnFlash")]
private bool _deleteOnFlash = true;
@@ -35,9 +36,9 @@ namespace Content.Server.Explosion.Components
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
}
if (_sound != null)
if (_sound.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates);
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates);
}
if (_deleteOnFlash && !Owner.Deleted)

View File

@@ -8,6 +8,7 @@ using Content.Shared.Acts;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -36,6 +37,7 @@ namespace Content.Server.Explosion
/// </summary>
private static readonly float LightBreakChance = 0.3f;
private static readonly float HeavyBreakChance = 0.8f;
private static SoundSpecifier _explosionSound = new SoundPathSpecifier("/Audio/Effects/explosion.ogg");
private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable");
@@ -311,7 +313,8 @@ namespace Content.Server.Explosion
var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange),
epicenterMapPos + new Vector2(maxRange, maxRange));
SoundSystem.Play(Filter.Broadcast(), "/Audio/Effects/explosion.ogg", epicenter);
if(_explosionSound.TryGetSound(out var explosionSound))
SoundSystem.Play(Filter.Broadcast(), explosionSound, epicenter);
DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId);
var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox);