ChargeBatteryArtifactSystem.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. using Content.Server.Power.Components;
  2. using Content.Server.Power.EntitySystems;
  3. using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
  4. using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
  5. using Robust.Server.GameObjects;
  6. namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
  7. /// <summary>
  8. /// This handles <see cref="ChargeBatteryArtifactComponent"/>
  9. /// </summary>
  10. public sealed class ChargeBatteryArtifactSystem : EntitySystem
  11. {
  12. [Dependency] private readonly BatterySystem _battery = default!;
  13. [Dependency] private readonly EntityLookupSystem _lookup = default!;
  14. [Dependency] private readonly TransformSystem _transform = default!;
  15. /// <inheritdoc/>
  16. public override void Initialize()
  17. {
  18. SubscribeLocalEvent<ChargeBatteryArtifactComponent, ArtifactActivatedEvent>(OnActivated);
  19. }
  20. private void OnActivated(EntityUid uid, ChargeBatteryArtifactComponent component, ArtifactActivatedEvent args)
  21. {
  22. foreach (var battery in _lookup.GetEntitiesInRange<BatteryComponent>(_transform.GetMapCoordinates(uid), component.Radius))
  23. {
  24. _battery.SetCharge(battery, battery.Comp.MaxCharge, battery);
  25. }
  26. }
  27. }