Prevent infinite loops in device linking (#16856)

This commit is contained in:
Julian Giebel
2023-05-28 18:14:06 +02:00
committed by GitHub
parent 9c1fe530c1
commit 49cb9d0e1e
11 changed files with 185 additions and 14 deletions

View File

@@ -0,0 +1,29 @@
using Content.Server.DeviceLinking.Components;
using Content.Server.DeviceLinking.Components.Overload;
using Content.Server.DeviceLinking.Events;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
namespace Content.Server.DeviceLinking.Systems;
public sealed class DeviceLinkOverloadSystem : EntitySystem
{
[Dependency] private readonly AudioSystem _audioSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<SoundOnOverloadComponent, DeviceLinkOverloadedEvent>(OnOverloadSound);
SubscribeLocalEvent<SpawnOnOverloadComponent, DeviceLinkOverloadedEvent>(OnOverloadSpawn);
}
private void OnOverloadSound(EntityUid uid, SoundOnOverloadComponent component, ref DeviceLinkOverloadedEvent args)
{
_audioSystem.PlayPvs(component.OverloadSound, uid, AudioParams.Default.WithVolume(component.VolumeModifier));
}
private void OnOverloadSpawn(EntityUid uid, SpawnOnOverloadComponent component, ref DeviceLinkOverloadedEvent args)
{
Spawn(component.Prototype, Transform(uid).Coordinates);
}
}