IonStormRule.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using Content.Server.Silicons.Laws;
  2. using Content.Server.StationEvents.Components;
  3. using Content.Shared.GameTicking.Components;
  4. using Content.Shared.Silicons.Laws.Components;
  5. using Content.Shared.Station.Components;
  6. namespace Content.Server.StationEvents.Events;
  7. public sealed class IonStormRule : StationEventSystem<IonStormRuleComponent>
  8. {
  9. [Dependency] private readonly IonStormSystem _ionStorm = default!;
  10. protected override void Started(EntityUid uid, IonStormRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
  11. {
  12. base.Started(uid, comp, gameRule, args);
  13. if (!TryGetRandomStation(out var chosenStation))
  14. return;
  15. var query = EntityQueryEnumerator<SiliconLawBoundComponent, TransformComponent, IonStormTargetComponent>();
  16. while (query.MoveNext(out var ent, out var lawBound, out var xform, out var target))
  17. {
  18. // only affect law holders on the station
  19. if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != chosenStation)
  20. continue;
  21. _ionStorm.IonStormTarget((ent, lawBound, target));
  22. }
  23. }
  24. }