mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 19:01:13 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
38 lines
1.3 KiB
C#
38 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 partial class ShuffleParticlesAnomalySystem : EntitySystem
|
|
{
|
|
[Dependency] private AnomalySystem _anomaly = default!;
|
|
[Dependency] private 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));
|
|
}
|
|
}
|
|
}
|
|
|