Files

32 lines
1.2 KiB
C#
Raw Permalink Normal View History

2023-01-01 00:59:38 -05:00
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
2023-01-01 00:59:38 -05:00
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Robust.Server.GameObjects;
2023-01-01 00:59:38 -05:00
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
/// <summary>
/// This handles <see cref="ChargeBatteryArtifactComponent"/>
/// </summary>
public sealed class ChargeBatteryArtifactSystem : EntitySystem
{
[Dependency] private readonly BatterySystem _battery = default!;
2023-01-01 00:59:38 -05:00
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
2023-01-01 00:59:38 -05:00
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ChargeBatteryArtifactComponent, ArtifactActivatedEvent>(OnActivated);
}
private void OnActivated(EntityUid uid, ChargeBatteryArtifactComponent component, ArtifactActivatedEvent args)
{
foreach (var battery in _lookup.GetEntitiesInRange<BatteryComponent>(_transform.GetMapCoordinates(uid), component.Radius))
2023-01-01 00:59:38 -05:00
{
_battery.SetCharge(battery, battery.Comp.MaxCharge, battery);
2023-01-01 00:59:38 -05:00
}
}
}