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

@@ -90,7 +90,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
("desc", Loc.GetString(proto.PhysicalDescription))));
}
private void UpdateAppearance(EntityUid uid, Solution solution,
public void UpdateAppearance(EntityUid uid, Solution solution,
AppearanceComponent? appearanceComponent = null)
{
if (!EntityManager.EntityExists(uid)
@@ -116,7 +116,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
return splitSol;
}
private void UpdateChemicals(EntityUid uid, Solution solutionHolder, bool needsReactionsProcessing = false)
public void UpdateChemicals(EntityUid uid, Solution solutionHolder, bool needsReactionsProcessing = false)
{
// Process reactions
if (needsReactionsProcessing && solutionHolder.CanReact)

View File

@@ -0,0 +1,32 @@
using Content.Server.Administration.Logs;
using Content.Shared.Construction;
using Content.Shared.Database;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions;
/// <summary>
/// Generate an admin log upon reaching this node. Useful for dangerous construction (e.g., modular grenades)
/// </summary>
[UsedImplicitly]
public sealed class AdminLog : IGraphAction
{
[DataField("logType", required: true)]
public LogType LogType = LogType.Construction;
[DataField("impact")]
public LogImpact Impact = LogImpact.Medium;
[DataField("message", required: true)]
public string Message = string.Empty;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
var logSys = entityManager.EntitySysManager.GetEntitySystem<AdminLogSystem>();
if (userUid.HasValue)
logSys.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}, User: {entityManager.ToPrettyString(userUid.Value):user}");
else
logSys.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}");
}
}

View File

@@ -1,12 +1,9 @@
using System.Threading.Tasks;
using Content.Shared.Audio;
using Content.Shared.Construction;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Random;
namespace Content.Server.Construction.Completions
{
@@ -16,9 +13,17 @@ namespace Content.Server.Construction.Completions
{
[DataField("sound", required: true)] public SoundSpecifier Sound { get; private set; } = default!;
[DataField("AudioParams")]
public AudioParams AudioParams = AudioParams.Default;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("variation")]
public float Variation = 0.125f;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
SoundSystem.Play(Filter.Pvs(uid), Sound.GetSound(), uid, AudioHelpers.WithVariation(0.125f));
var scale = (float) IoCManager.Resolve<IRobustRandom>().NextGaussian(1, Variation);
SoundSystem.Play(Filter.Pvs(uid, entityManager: entityManager), Sound.GetSound(), uid, AudioParams.WithPitchScale(scale));
}
}
}

View File

@@ -0,0 +1,29 @@
using Content.Shared.Sound;
using Robust.Shared.Audio;
namespace Content.Server.Explosion.Components;
/// <summary>
/// Component for tracking active trigger timers. A timers can activated by some other component, e.g. <see cref="OnUseTimerTriggerComponent"/>.
/// </summary>
[RegisterComponent]
public sealed class ActiveTimerTriggerComponent : Component
{
[DataField("timeRemaining")]
public float TimeRemaining;
[DataField("user")]
public EntityUid? User;
[DataField("beepInterval")]
public float BeepInterval;
[DataField("timeUntilBeep")]
public float TimeUntilBeep;
[DataField("beepSound")]
public SoundSpecifier? BeepSound;
[DataField("beepParams")]
public AudioParams BeepParams = AudioParams.Default;
}

View File

@@ -1,11 +1,36 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Content.Shared.Sound;
using Robust.Shared.Audio;
namespace Content.Server.Explosion.Components
{
[RegisterComponent]
public sealed class OnUseTimerTriggerComponent : Component
{
[DataField("delay")] public float Delay = 0f;
[DataField("delay")]
public float Delay = 1f;
/// <summary>
/// If not null, a user can use verbs to configure the delay to one of these options.
/// </summary>
[DataField("delayOptions")]
public List<float>? DelayOptions = null;
/// <summary>
/// If not null, this timer will periodically play this sound wile active.
/// </summary>
[DataField("beepSound")]
public SoundSpecifier? BeepSound;
/// <summary>
/// Time before beeping starts. Defaults to a single beep interval. If set to zero, will emit a beep immediately after use.
/// </summary>
[DataField("initialBeepDelay")]
public float? InitialBeepDelay;
[DataField("beepInterval")]
public float BeepInterval = 1;
[DataField("beepParams")]
public AudioParams BeepParams = AudioParams.Default.WithVolume(-2f);
}
}

View File

@@ -1,19 +0,0 @@
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Explosion.Components
{
/// <summary>
/// Whenever a <see cref="TriggerEvent"/> is run play a sound in PVS range.
/// </summary>
[RegisterComponent]
public sealed class SoundOnTriggerComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sound")]
public SoundSpecifier? Sound { get; set; }
}
}

View File

@@ -1,32 +1,119 @@
using System;
using Content.Server.Explosion.Components;
using Content.Shared.Examine;
using Content.Shared.Popups;
using Content.Shared.Interaction.Events;
using Content.Shared.Trigger;
using Robust.Shared.GameObjects;
using Content.Shared.Verbs;
using Robust.Shared.Player;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class TriggerSystem
{
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
private void InitializeOnUse()
{
SubscribeLocalEvent<OnUseTimerTriggerComponent, UseInHandEvent>(OnTimerUse);
SubscribeLocalEvent<OnUseTimerTriggerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<OnUseTimerTriggerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
}
private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
{
if (args.IsInDetailsRange)
args.PushText(Loc.GetString("examine-trigger-timer", ("time", component.Delay)));
}
/// <summary>
/// Add an alt-click interaction that cycles through delays.
/// </summary>
private void OnGetAltVerbs(EntityUid uid, OnUseTimerTriggerComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
return;
args.Verbs.Add(new AlternativeVerb()
{
Category = TimerOptions,
Text = Loc.GetString("verb-trigger-timer-cycle"),
Act = () => CycleDelay(component, args.User),
Priority = 1
});
foreach (var option in component.DelayOptions)
{
if (MathHelper.CloseTo(option, component.Delay))
{
args.Verbs.Add(new AlternativeVerb()
{
Category = TimerOptions,
Text = Loc.GetString("verb-trigger-timer-set-current", ("time", option)),
Disabled = true,
Priority = (int) (-100 * option)
});
continue;
}
args.Verbs.Add(new AlternativeVerb()
{
Category = TimerOptions,
Text = Loc.GetString("verb-trigger-timer-set", ("time", option)),
Priority = (int) (-100 * option),
Act = () =>
{
component.Delay = option;
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), args.User, Filter.Entities(args.User));
},
});
}
}
private void CycleDelay(OnUseTimerTriggerComponent component, EntityUid user)
{
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
return;
// This is somewhat inefficient, but its good enough. This is run rarely, and the lists should be short.
component.DelayOptions.Sort();
if (component.DelayOptions[^1] <= component.Delay)
{
component.Delay = component.DelayOptions[0];
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", component.Delay)), user, Filter.Entities(user));
return;
}
foreach (var option in component.DelayOptions)
{
if (option > component.Delay)
{
component.Delay = option;
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), user, Filter.Entities(user));
return;
}
}
}
private void OnTimerUse(EntityUid uid, OnUseTimerTriggerComponent component, UseInHandEvent args)
{
if (args.Handled) return;
Trigger(uid, args.User, component);
HandleTimerTrigger(
uid,
args.User,
component.Delay,
component.BeepInterval,
component.InitialBeepDelay,
component.BeepSound,
component.BeepParams);
args.Handled = true;
}
// TODO: Need to split this out so it's a generic "OnUseTimerTrigger" component.
private void Trigger(EntityUid uid, EntityUid user, OnUseTimerTriggerComponent component)
{
if (TryComp<AppearanceComponent>(uid, out var appearance))
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
HandleTimerTrigger(TimeSpan.FromSeconds(component.Delay), uid, user);
}
public static VerbCategory TimerOptions = new("verb-categories-timer", "/Textures/Interface/VerbIcons/clock.svg.192dpi.png");
}

View File

@@ -1,27 +1,17 @@
using System;
using Content.Server.Administration.Logs;
using Content.Server.Doors;
using Content.Server.Doors.Components;
using Content.Server.Doors.Systems;
using Content.Server.Explosion.Components;
using Content.Server.Flash;
using Content.Server.Flash.Components;
using Content.Shared.Audio;
using Content.Shared.Doors;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using System.Threading;
using Content.Server.Construction.Components;
using Content.Shared.Sound;
using Content.Shared.Trigger;
using Timer = Robust.Shared.Timing.Timer;
using Content.Shared.Physics;
using System.Collections.Generic;
using Content.Shared.Database;
namespace Content.Server.Explosion.EntitySystems
{
@@ -48,6 +38,7 @@ namespace Content.Server.Explosion.EntitySystems
[Dependency] private readonly FlashSystem _flashSystem = default!;
[Dependency] private readonly DoorSystem _sharedDoorSystem = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly AdminLogSystem _logSystem = default!;
public override void Initialize()
{
@@ -59,7 +50,6 @@ namespace Content.Server.Explosion.EntitySystems
SubscribeLocalEvent<TriggerOnCollideComponent, StartCollideEvent>(OnTriggerCollide);
SubscribeLocalEvent<DeleteOnTriggerComponent, TriggerEvent>(HandleDeleteTrigger);
SubscribeLocalEvent<SoundOnTriggerComponent, TriggerEvent>(HandleSoundTrigger);
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
SubscribeLocalEvent<ToggleDoorOnTriggerComponent, TriggerEvent>(HandleDoorTrigger);
@@ -100,12 +90,6 @@ namespace Content.Server.Explosion.EntitySystems
}
#endregion
private void HandleSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
{
if (component.Sound == null) return;
SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), uid);
}
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
{
EntityManager.QueueDeleteEntity(uid);
@@ -128,19 +112,39 @@ namespace Content.Server.Explosion.EntitySystems
EntityManager.EventBus.RaiseLocalEvent(trigger, triggerEvent);
}
public void HandleTimerTrigger(TimeSpan delay, EntityUid triggered, EntityUid? user = null)
public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay , float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound, AudioParams beepParams)
{
if (delay.TotalSeconds <= 0)
if (delay <= 0)
{
Trigger(triggered, user);
RemComp<ActiveTimerTriggerComponent>(uid);
Trigger(uid, user);
return;
}
Timer.Spawn(delay, () =>
if (HasComp<ActiveTimerTriggerComponent>(uid))
return;
if (user != null)
{
if (Deleted(triggered)) return;
Trigger(triggered, user);
});
_logSystem.Add(LogType.Trigger,
$"{ToPrettyString(user.Value):user} started a {delay} second timer trigger on entity {ToPrettyString(uid):timer}");
}
else
{
_logSystem.Add(LogType.Trigger,
$"{delay} second timer trigger started on entity {ToPrettyString(uid):timer}");
}
var active = AddComp<ActiveTimerTriggerComponent>(uid);
active.TimeRemaining = delay;
active.User = user;
active.BeepParams = beepParams;
active.BeepSound = beepSound;
active.BeepInterval = beepInterval;
active.TimeUntilBeep = initialBeepDelay == null ? active.BeepInterval : initialBeepDelay.Value;
if (TryComp<AppearanceComponent>(uid, out var appearance))
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
}
public override void Update(float frameTime)
@@ -148,6 +152,40 @@ namespace Content.Server.Explosion.EntitySystems
base.Update(frameTime);
UpdateProximity(frameTime);
UpdateTimer(frameTime);
}
private void UpdateTimer(float frameTime)
{
HashSet<EntityUid> toRemove = new();
foreach (var timer in EntityQuery<ActiveTimerTriggerComponent>())
{
timer.TimeRemaining -= frameTime;
timer.TimeUntilBeep -= frameTime;
if (timer.TimeRemaining <= 0)
{
Trigger(timer.Owner, timer.User);
toRemove.Add(timer.Owner);
continue;
}
if (timer.BeepSound == null || timer.TimeUntilBeep > 0)
continue;
timer.TimeUntilBeep += timer.BeepInterval;
var filter = Filter.Pvs(timer.Owner, entityManager: EntityManager);
SoundSystem.Play(filter, timer.BeepSound.GetSound(), timer.Owner, timer.BeepParams);
}
foreach (var uid in toRemove)
{
RemComp<ActiveTimerTriggerComponent>(uid);
// In case this is a re-usable grenade, un-prime it.
if (TryComp<AppearanceComponent>(uid, out var appearance))
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Unprimed);
}
}
}
}

View File

@@ -0,0 +1,141 @@
using Content.Server.Administration.Logs;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Database;
using Content.Shared.Payload.Components;
using Content.Shared.Tag;
using Robust.Shared.Containers;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Utility;
namespace Content.Server.Payload.EntitySystems;
public sealed class PayloadSystem : EntitySystem
{
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
[Dependency] private readonly SharedChemicalReactionSystem _chemistrySystem = default!;
[Dependency] private readonly AdminLogSystem _logSystem = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PayloadCaseComponent, TriggerEvent>(OnCaseTriggered);
SubscribeLocalEvent<PayloadTriggerComponent, TriggerEvent>(OnTriggerTriggered);
SubscribeLocalEvent<PayloadCaseComponent, EntInsertedIntoContainerMessage>(OnEntityInserted);
SubscribeLocalEvent<PayloadCaseComponent, EntRemovedFromContainerMessage>(OnEntityRemoved);
SubscribeLocalEvent<ChemicalPayloadComponent, TriggerEvent>(HandleChemicalPayloadTrigger);
}
private void OnCaseTriggered(EntityUid uid, PayloadCaseComponent component, TriggerEvent args)
{
if (!TryComp(uid, out ContainerManagerComponent? contMan))
return;
// Pass trigger event onto all contained payloads. Payload capacity configurable by construction graphs.
foreach (var container in contMan.Containers.Values)
{
foreach (var entity in container.ContainedEntities)
{
if (_tagSystem.HasTag(entity, "Payload"))
RaiseLocalEvent(entity, args, false);
}
}
}
private void OnTriggerTriggered(EntityUid uid, PayloadTriggerComponent component, TriggerEvent args)
{
if (!component.Active)
return;
if (Transform(uid).ParentUid is not { Valid: true } parent)
return;
// Ensure we don't enter a trigger-loop
DebugTools.Assert(!_tagSystem.HasTag(uid, "Payload"));
RaiseLocalEvent(parent, args, false);
}
private void OnEntityInserted(EntityUid uid, PayloadCaseComponent _, EntInsertedIntoContainerMessage args)
{
if (!TryComp(args.Entity, out PayloadTriggerComponent? trigger))
return;
trigger.Active = true;
if (trigger.Components == null)
return;
// ANY payload trigger that gets inserted can grant components. It is up to the construction graphs to determine trigger capacity.
foreach (var (name, data) in trigger.Components)
{
if (!_componentFactory.TryGetRegistration(name, out var registration))
continue;
if (HasComp(uid, registration.Type))
continue;
if (_componentFactory.GetComponent(registration.Type) is not Component component)
continue;
component.Owner = uid;
if (_serializationManager.Copy(data, component, null) is Component copied)
EntityManager.AddComponent(uid, copied);
trigger.GrantedComponents.Add(registration.Type);
}
}
private void OnEntityRemoved(EntityUid uid, PayloadCaseComponent component, EntRemovedFromContainerMessage args)
{
if (!TryComp(args.Entity, out PayloadTriggerComponent? trigger))
return;
trigger.Active = false;
foreach (var type in trigger.GrantedComponents)
{
EntityManager.RemoveComponent(uid, type);
}
trigger.GrantedComponents.Clear();
}
private void HandleChemicalPayloadTrigger(EntityUid uid, ChemicalPayloadComponent component, TriggerEvent args)
{
if (component.BeakerSlotA.Item is not EntityUid beakerA
|| component.BeakerSlotB.Item is not EntityUid beakerB
|| !TryComp(beakerA, out FitsInDispenserComponent? compA)
|| !TryComp(beakerB, out FitsInDispenserComponent? compB)
|| !_solutionSystem.TryGetSolution(beakerA, compA.Solution, out var solutionA)
|| !_solutionSystem.TryGetSolution(beakerB, compB.Solution, out var solutionB)
|| solutionA.TotalVolume == 0
|| solutionB.TotalVolume == 0)
{
return;
}
var solStringA = SolutionContainerSystem.ToPrettyString(solutionA);
var solStringB = SolutionContainerSystem.ToPrettyString(solutionB);
_logSystem.Add(LogType.ChemicalReaction,
$"Chemical bomb payload {ToPrettyString(uid):payload} at {Transform(uid).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
solutionA.MaxVolume += solutionB.MaxVolume;
_solutionSystem.TryAddSolution(beakerA, solutionA, solutionB);
solutionB.RemoveAllSolution();
// The grenade might be a dud. Redistribute solution:
var tmpSol = _solutionSystem.SplitSolution(beakerA, solutionA, solutionA.CurrentVolume * solutionB.MaxVolume / solutionA.MaxVolume);
_solutionSystem.TryAddSolution(beakerB, solutionB, tmpSol);
solutionA.MaxVolume -= solutionB.MaxVolume;
_solutionSystem.UpdateChemicals(beakerA, solutionA, false);
}
}

View File

@@ -1,7 +1,5 @@
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using Robust.Shared.Audio;
namespace Content.Server.Sound.Components
{
@@ -15,6 +13,9 @@ namespace Content.Server.Sound.Components
[DataField("sound", required: true)]
public SoundSpecifier Sound { get; set; } = default!;
[DataField("audioParams")]
public AudioParams AudioParams = AudioParams.Default.WithVolume(-2f);
[ViewVariables(VVAccess.ReadWrite)]
[DataField("variation")]
public float PitchVariation { get; set; } = 0.0f;

View File

@@ -0,0 +1,12 @@
using Content.Server.Explosion.EntitySystems;
namespace Content.Server.Sound.Components
{
/// <summary>
/// Whenever a <see cref="TriggerEvent"/> is run play a sound in PVS range.
/// </summary>
[RegisterComponent]
public sealed class EmitSoundOnTriggerComponent : BaseEmitSoundComponent
{
}
}

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);
}
}
}