1
0

DeviceLinkOverloadSystem.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using Content.Server.DeviceLinking.Components;
  2. using Content.Server.DeviceLinking.Components.Overload;
  3. using Content.Server.DeviceLinking.Events;
  4. using Robust.Server.Audio;
  5. using Robust.Server.GameObjects;
  6. using Robust.Shared.Audio;
  7. namespace Content.Server.DeviceLinking.Systems;
  8. public sealed class DeviceLinkOverloadSystem : EntitySystem
  9. {
  10. [Dependency] private readonly AudioSystem _audioSystem = default!;
  11. public override void Initialize()
  12. {
  13. SubscribeLocalEvent<SoundOnOverloadComponent, DeviceLinkOverloadedEvent>(OnOverloadSound);
  14. SubscribeLocalEvent<SpawnOnOverloadComponent, DeviceLinkOverloadedEvent>(OnOverloadSpawn);
  15. }
  16. private void OnOverloadSound(EntityUid uid, SoundOnOverloadComponent component, ref DeviceLinkOverloadedEvent args)
  17. {
  18. _audioSystem.PlayPvs(component.OverloadSound, uid, AudioParams.Default.WithVolume(component.VolumeModifier));
  19. }
  20. private void OnOverloadSpawn(EntityUid uid, SpawnOnOverloadComponent component, ref DeviceLinkOverloadedEvent args)
  21. {
  22. Spawn(component.Prototype, Transform(uid).Coordinates);
  23. }
  24. }