Files
tbd-station-14/Content.Server/Sound/Components/LoopingLoopingSoundComponent.cs
Galactic Chimp 10af8efc0e #4219 emit sound system add single sound support (#4237)
* Revert "#3935 implemented suggestions from PR"

This reverts commit a9b1c7b96333ca570067d6a9df1954481005892a.

* #4219 revert of single sound removal in EmitSoundSystem

* #4219 single sounds in EmitSoundSystem should work now

* #4219 some small project tweaks

* #4219 upgraded EmitSoundSystem to use SoundSpecifier

* #4219 pr tweaks

* #4219 pr tweak

* #4219 missing bike horn .yaml change
2021-07-25 04:37:01 -07:00

68 lines
2.2 KiB
C#

using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Network;
namespace Content.Server.Sound.Components
{
[RegisterComponent]
public class LoopingLoopingSoundComponent : SharedLoopingSoundComponent
{
/// <summary>
/// Stops all sounds.
/// </summary>
/// <param name="channel">User that will be affected.</param>
public void StopAllSounds(INetChannel? channel)
{
SendNetworkMessage(new StopAllSoundsMessage(), channel);
}
/// <summary>
/// Stops a certain scheduled sound from playing.
/// </summary>
/// <param name="channel">User that will be affected.</param>
public void StopScheduledSound(string filename, INetChannel? channel)
{
SendNetworkMessage(new StopSoundScheduleMessage() {Filename = filename}, channel);
}
/// <summary>
/// Adds an scheduled sound to be played.
/// </summary>
/// <param name="channel">User that will be affected.</param>
public void AddScheduledSound(ScheduledSound schedule, INetChannel? channel)
{
SendNetworkMessage(new ScheduledSoundMessage() {Schedule = schedule}, channel);
}
public override void StopAllSounds()
{
StopAllSounds(null);
}
public override void StopScheduledSound(string filename)
{
StopScheduledSound(filename, null);
}
public override void AddScheduledSound(ScheduledSound schedule)
{
AddScheduledSound(schedule, null);
}
/// <summary>
/// Play an audio file following the entity.
/// </summary>
/// <param name="filename">The resource path to the OGG Vorbis file to play.</param>
/// <param name="channel">User that will be affected.</param>
public void Play(string filename, AudioParams? audioParams = null, INetChannel? channel = null)
{
AddScheduledSound(new ScheduledSound()
{
Filename = filename,
AudioParams = audioParams,
}, channel);
}
}
}