* dev it * screw it * Revert "screw it" This reverts commit 5657a1d20128e630bebbaf38f4dcb4dbac28d026. * Revert "dev it" This reverts commit f3d7c355da17de92e43c145efbd348f8378d6146. * slarti best * Revert "slarti best" This reverts commit 8de1caafb254515202aa21d2b96029a1fce24df2. * Reapply "dev it" This reverts commit c603940a73246f8a22a171c5559eb3f3f995e7bc. * Reapply "screw it" This reverts commit 468722abe7bde7e30bc3b421bc28fa90a013bd63. * refactor: renaming +xml-doc --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Content.Server.Anomaly.Components;
|
|
using Content.Shared.Anomaly.Components;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Anomaly.Effects;
|
|
|
|
public sealed class ShuffleParticlesAnomalySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AnomalySystem _anomaly = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<ShuffleParticlesAnomalyComponent, AnomalyPulseEvent>(OnPulse);
|
|
SubscribeLocalEvent<ShuffleParticlesAnomalyComponent, AnomalyAffectedByParticleEvent>(OnAffectedByParticle);
|
|
}
|
|
|
|
private void OnAffectedByParticle(Entity<ShuffleParticlesAnomalyComponent> ent, ref AnomalyAffectedByParticleEvent args)
|
|
{
|
|
if (!TryComp<AnomalyComponent>(ent, out var anomalyComp))
|
|
return;
|
|
|
|
if (ent.Comp.ShuffleOnParticleHit && _random.Prob(ent.Comp.Prob))
|
|
_anomaly.ShuffleParticlesEffect((args.Anomaly, anomalyComp));
|
|
}
|
|
|
|
private void OnPulse(Entity<ShuffleParticlesAnomalyComponent> ent, ref AnomalyPulseEvent args)
|
|
{
|
|
if (!TryComp<AnomalyComponent>(ent, out var anomaly))
|
|
return;
|
|
|
|
if (ent.Comp.ShuffleOnPulse && _random.Prob(ent.Comp.Prob))
|
|
{
|
|
_anomaly.ShuffleParticlesEffect((ent, anomaly));
|
|
}
|
|
}
|
|
}
|
|
|