CatStation/Content.Server/Anomaly/Effects/ShuffleParticlesAnomalySystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* 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
2026-05-09 03:29:58 +00:00

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