Adds a sound effect to health analyzers (#13425)

This commit is contained in:
nmajask
2023-01-12 01:38:39 -05:00
committed by GitHub
parent 9199bd649c
commit a0086b5184
6 changed files with 34 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.UserInterface;
using Content.Shared.Disease;
using Content.Shared.MedicalScanner;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Medical.Components
@@ -25,6 +26,18 @@ namespace Content.Server.Medical.Components
public CancellationTokenSource? CancelToken;
public BoundUserInterface? UserInterface => Owner.GetUIOrNull(HealthAnalyzerUiKey.Key);
/// <summary>
/// Sound played on scanning begin
/// </summary>
[DataField("scanningBeginSound")]
public SoundSpecifier? ScanningBeginSound = null;
/// <summary>
/// Sound played on scanning end
/// </summary>
[DataField("scanningEndSound")]
public SoundSpecifier? ScanningEndSound = null;
/// <summary>
/// The disease this will give people.
/// </summary>

View File

@@ -7,6 +7,7 @@ using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using static Content.Shared.MedicalScanner.SharedHealthAnalyzerComponent;
@@ -15,6 +16,7 @@ namespace Content.Server.Medical
{
public sealed class HealthAnalyzerSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly DiseaseSystem _disease = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
@@ -55,6 +57,9 @@ namespace Content.Server.Medical
return;
healthAnalyzer.CancelToken = new CancellationTokenSource();
_audio.PlayPvs(healthAnalyzer.ScanningBeginSound, uid);
_doAfterSystem.DoAfter(new DoAfterEventArgs(args.User, healthAnalyzer.ScanDelay, healthAnalyzer.CancelToken.Token, target: args.Target)
{
BroadcastFinishedEvent = new TargetScanSuccessfulEvent(args.User, args.Target, healthAnalyzer),
@@ -69,6 +74,9 @@ namespace Content.Server.Medical
private void OnTargetScanSuccessful(TargetScanSuccessfulEvent args)
{
args.Component.CancelToken = null;
_audio.PlayPvs(args.Component.ScanningEndSound, args.User);
UpdateScannedUser(args.Component.Owner, args.User, args.Target, args.Component);
// Below is for the traitor item
// Piggybacking off another component's doafter is complete CBT so I gave up