39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Content.Server.Ghost;
|
|
using Content.Server.Light.Components;
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
|
|
|
|
/// <summary>
|
|
/// This handles...
|
|
/// </summary>
|
|
public sealed class LightFlickerArtifactSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
|
[Dependency] private readonly GhostSystem _ghost = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<LightFlickerArtifactComponent, ArtifactActivatedEvent>(OnActivated);
|
|
}
|
|
|
|
private void OnActivated(EntityUid uid, LightFlickerArtifactComponent component, ArtifactActivatedEvent args)
|
|
{
|
|
var lights = GetEntityQuery<PoweredLightComponent>();
|
|
foreach (var light in _lookup.GetEntitiesInRange(uid, component.Radius, LookupFlags.StaticSundries ))
|
|
{
|
|
if (!lights.HasComponent(light))
|
|
continue;
|
|
|
|
if (!_random.Prob(component.FlickerChance))
|
|
continue;
|
|
|
|
_ghost.DoGhostBooEvent(light);
|
|
}
|
|
}
|
|
}
|