31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using Content.Server.Silicons.Laws;
|
|
using Content.Server.StationEvents.Components;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.Silicons.Laws.Components;
|
|
using Content.Shared.Station.Components;
|
|
|
|
namespace Content.Server.StationEvents.Events;
|
|
|
|
public sealed class IonStormRule : StationEventSystem<IonStormRuleComponent>
|
|
{
|
|
[Dependency] private readonly IonStormSystem _ionStorm = default!;
|
|
|
|
protected override void Started(EntityUid uid, IonStormRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
|
{
|
|
base.Started(uid, comp, gameRule, args);
|
|
|
|
if (!TryGetRandomStation(out var chosenStation))
|
|
return;
|
|
|
|
var query = EntityQueryEnumerator<SiliconLawBoundComponent, TransformComponent, IonStormTargetComponent>();
|
|
while (query.MoveNext(out var ent, out var lawBound, out var xform, out var target))
|
|
{
|
|
// only affect law holders on the station
|
|
if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != chosenStation)
|
|
continue;
|
|
|
|
_ionStorm.IonStormTarget((ent, lawBound, target));
|
|
}
|
|
}
|
|
}
|