Add connect sound for gastank internals (#8318)

This commit is contained in:
metalgearsloth
2022-05-22 12:31:37 +10:00
committed by GitHub
parent 5640b047f7
commit c3fa24ccd8
4 changed files with 28 additions and 2 deletions

View File

@@ -29,7 +29,21 @@ namespace Content.Server.Atmos.Components
[ViewVariables] public BoundUserInterface? UserInterface;
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
[ViewVariables(VVAccess.ReadWrite), DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("/Audio/Effects/spray.ogg");
[ViewVariables(VVAccess.ReadWrite), DataField("connectSound")] private SoundSpecifier? _connectSound =
new SoundPathSpecifier("/Audio/Effects/internals.ogg")
{
Params = AudioParams.Default.WithVolume(10f),
};
[ViewVariables(VVAccess.ReadWrite), DataField("disconnectSound")] private SoundSpecifier? _disconnectSound;
// Cancel toggles sounds if we re-toggle again.
private IPlayingAudioStream? _connectStream;
private IPlayingAudioStream? _disconnectStream;
[DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new();
@@ -131,6 +145,11 @@ namespace Content.Server.Atmos.Components
if (internals == null) return;
IsConnected = internals.TryConnectTank(Owner);
EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, IsConnected);
_connectStream?.Stop();
if (_connectSound != null)
_connectStream = SoundSystem.Play(Filter.Pvs(Owner, entityManager: _entMan), _connectSound.GetSound(), Owner, _connectSound.Params);
UpdateUserInterface();
}
@@ -140,6 +159,11 @@ namespace Content.Server.Atmos.Components
IsConnected = false;
EntitySystem.Get<SharedActionsSystem>().SetToggled(ToggleAction, false);
GetInternalsComponent(owner)?.DisconnectTank();
_disconnectStream?.Stop();
if (_disconnectSound != null)
_disconnectStream = SoundSystem.Play(Filter.Pvs(Owner, entityManager: _entMan), _disconnectSound.GetSound(), Owner, _disconnectSound.Params);
UpdateUserInterface();
}