Radiation pulse ECS (#10641)
This commit is contained in:
@@ -12,6 +12,6 @@ namespace Content.Server.Sound.Components
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("sound", required: true)]
|
||||
public SoundSpecifier Sound { get; set; } = default!;
|
||||
public SoundSpecifier? Sound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Content.Server.Sound.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Simple sound emitter that emits sound on entity spawn.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class EmitSoundOnSpawnComponent : BaseEmitSoundComponent
|
||||
{
|
||||
}
|
||||
@@ -54,6 +54,7 @@ namespace Content.Server.Sound
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<EmitSoundOnSpawnComponent, ComponentInit>(HandleEmitSpawnOnInit);
|
||||
SubscribeLocalEvent<EmitSoundOnLandComponent, LandEvent>(HandleEmitSoundOnLand);
|
||||
SubscribeLocalEvent<EmitSoundOnUseComponent, UseInHandEvent>(HandleEmitSoundOnUseInHand);
|
||||
SubscribeLocalEvent<EmitSoundOnThrowComponent, ThrownEvent>(HandleEmitSoundOnThrown);
|
||||
@@ -64,6 +65,11 @@ namespace Content.Server.Sound
|
||||
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(HandleEmitSoundOnDrop);
|
||||
}
|
||||
|
||||
private void HandleEmitSpawnOnInit(EntityUid uid, EmitSoundOnSpawnComponent component, ComponentInit args)
|
||||
{
|
||||
TryEmitSound(component);
|
||||
}
|
||||
|
||||
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
TryEmitSound(component);
|
||||
@@ -122,6 +128,8 @@ namespace Content.Server.Sound
|
||||
|
||||
private void TryEmitSound(BaseEmitSoundComponent component)
|
||||
{
|
||||
if (component.Sound == null)
|
||||
return;
|
||||
_audioSystem.PlayPvs(component.Sound, component.Owner, component.Sound.Params.AddVolume(-2f));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user