using Content.Server.Ghost; using Content.Server.Light.Components; using Content.Server.Xenoarchaeology.Artifact.XAE.Components; using Content.Shared.Xenoarchaeology.Artifact; using Content.Shared.Xenoarchaeology.Artifact.XAE; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.Artifact.XAE; /// /// System for xeno artifact activation effect that flickers light on and off. /// public sealed class XAELightFlickerSystem : BaseXAESystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly GhostSystem _ghost = default!; private EntityQuery _lights; /// Pre-allocated and re-used collection. private readonly HashSet _entities = new(); /// public override void Initialize() { base.Initialize(); _lights = GetEntityQuery(); } /// protected override void OnActivated(Entity ent, ref XenoArtifactNodeActivatedEvent args) { _entities.Clear(); _lookup.GetEntitiesInRange(ent.Owner, ent.Comp.Radius, _entities, LookupFlags.StaticSundries); foreach (var light in _entities) { if (!_lights.HasComponent(light)) continue; if (!_random.Prob(ent.Comp.FlickerChance)) continue; //todo: extract effect from ghost system, update power system accordingly _ghost.DoGhostBooEvent(light); } } }