2022-11-17 18:10:45 -05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Content.Server.Atmos.Components;
|
|
|
|
|
|
using Content.Server.Atmos.EntitySystems;
|
|
|
|
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
|
|
|
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed class IgniteArtifactSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
|
|
|
|
|
[Dependency] private readonly FlammableSystem _flammable = default!;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
SubscribeLocalEvent<IgniteArtifactComponent, ArtifactActivatedEvent>(OnActivate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnActivate(EntityUid uid, IgniteArtifactComponent component, ArtifactActivatedEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
var flammable = GetEntityQuery<FlammableComponent>();
|
2023-06-30 15:25:33 -04:00
|
|
|
|
foreach (var target in _lookup.GetEntitiesInRange(uid, component.Range))
|
2022-11-17 18:10:45 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (!flammable.TryGetComponent(target, out var fl))
|
|
|
|
|
|
continue;
|
|
|
|
|
|
fl.FireStacks += _random.Next(component.MinFireStack, component.MaxFireStack);
|
2023-08-04 21:18:09 -05:00
|
|
|
|
_flammable.Ignite(target, uid, fl);
|
2022-11-17 18:10:45 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|