using Content.Server.Polymorph.Systems; using Content.Server.Xenoarchaeology.Artifact.XAE.Components; using Content.Shared.Humanoid; using Content.Shared.Mobs.Systems; using Content.Shared.Xenoarchaeology.Artifact; using Content.Shared.Xenoarchaeology.Artifact.XAE; using Robust.Shared.Audio.Systems; namespace Content.Server.Xenoarchaeology.Artifact.XAE; /// /// System for xeno artifact activation effect that is polymorphing all humanoid entities in range. /// public sealed class XAEPolymorphSystem : BaseXAESystem { [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly MobStateSystem _mob = default!; [Dependency] private readonly PolymorphSystem _poly = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; /// Pre-allocated and re-used collection. private readonly HashSet> _humanoids = new(); /// protected override void OnActivated(Entity ent, ref XenoArtifactNodeActivatedEvent args) { _humanoids.Clear(); _lookup.GetEntitiesInRange(args.Coordinates, ent.Comp.Range, _humanoids); foreach (var comp in _humanoids) { var target = comp.Owner; if (!_mob.IsAlive(target)) continue; _poly.PolymorphEntity(target, ent.Comp.PolymorphPrototypeName); _audio.PlayPvs(ent.Comp.PolySound, ent); } } }