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; /// /// This handles... /// public sealed class LightFlickerArtifactSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly GhostSystem _ghost = default!; /// public override void Initialize() { SubscribeLocalEvent(OnActivated); } private void OnActivated(EntityUid uid, LightFlickerArtifactComponent component, ArtifactActivatedEvent args) { var lights = GetEntityQuery(); 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); } } }