IgniteArtifactSystem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Linq;
  2. using Content.Server.Atmos.Components;
  3. using Content.Server.Atmos.EntitySystems;
  4. using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
  5. using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
  6. using Robust.Shared.Random;
  7. namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
  8. public sealed class IgniteArtifactSystem : EntitySystem
  9. {
  10. [Dependency] private readonly IRobustRandom _random = default!;
  11. [Dependency] private readonly EntityLookupSystem _lookup = default!;
  12. [Dependency] private readonly FlammableSystem _flammable = default!;
  13. /// <inheritdoc/>
  14. public override void Initialize()
  15. {
  16. SubscribeLocalEvent<IgniteArtifactComponent, ArtifactActivatedEvent>(OnActivate);
  17. }
  18. private void OnActivate(EntityUid uid, IgniteArtifactComponent component, ArtifactActivatedEvent args)
  19. {
  20. var flammable = GetEntityQuery<FlammableComponent>();
  21. foreach (var target in _lookup.GetEntitiesInRange(uid, component.Range))
  22. {
  23. if (!flammable.TryGetComponent(target, out var fl))
  24. continue;
  25. fl.FireStacks += _random.Next(component.MinFireStack, component.MaxFireStack);
  26. _flammable.Ignite(target, uid, fl);
  27. }
  28. }
  29. }