Add Modular grenades (chemnades). (#7138)

This commit is contained in:
Leon Friedrich
2022-03-25 17:17:29 +13:00
committed by GitHub
parent 414c03978d
commit 1b0e7ae0f5
51 changed files with 994 additions and 96 deletions

View File

@@ -1,14 +1,14 @@
using Content.Server.Explosion.EntitySystems;
using Content.Server.Interaction.Components;
using Content.Server.Sound.Components;
using Content.Server.Throwing;
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Random;
namespace Content.Server.Sound
{
@@ -18,6 +18,8 @@ namespace Content.Server.Sound
[UsedImplicitly]
public sealed class EmitSoundSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
/// <inheritdoc />
public override void Initialize()
{
@@ -26,6 +28,12 @@ namespace Content.Server.Sound
SubscribeLocalEvent<EmitSoundOnUseComponent, UseInHandEvent>(HandleEmitSoundOnUseInHand);
SubscribeLocalEvent<EmitSoundOnThrowComponent, ThrownEvent>(HandleEmitSoundOnThrown);
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld);
SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
}
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
{
TryEmitSound(component);
}
private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
@@ -35,9 +43,7 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnUseInHand(EntityUid eUI, BaseEmitSoundComponent component, UseInHandEvent arg)
{
if (arg.Handled) return;
arg.Handled = true;
// Intentionally not handling interaction. This component is an easy way to add sounds in addition to other behavior.
TryEmitSound(component);
}
@@ -48,15 +54,14 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
{
if (arg.Handled) return;
arg.Handled = true;
// Intentionally not handling interaction. This component is an easy way to add sounds in addition to other behavior.
TryEmitSound(component);
}
private static void TryEmitSound(BaseEmitSoundComponent component)
private void TryEmitSound(BaseEmitSoundComponent component)
{
SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
var audioParams = component.AudioParams.WithPitchScale((float) _random.NextGaussian(1, component.PitchVariation));
SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.Sound.GetSound(), component.Owner, audioParams);
}
}
}