Skip to content

Commit

Permalink
Eliminate the second loop
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Dec 22, 2024
1 parent 67ed36b commit 7fd866a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Content.Server/StationEvents/Events/AirlockVirusRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,16 @@ protected override void Started(EntityUid uid, AirlockVirusRuleComponent compone
}

var query = EntityManager.EntityQueryEnumerator<AirlockVirusTargetComponent>();
List<EntityUid> airlocks = new();
while (query.MoveNext(out var airlockUid, out var _))
{
var parent = Transform(airlockUid).GridUid;
if (parent is null
|| !stationGrids.Contains(parent!.Value))
continue;

airlocks.Add(airlockUid);
}
foreach (var target in airlocks)
Timer.Spawn(TimeSpan.FromSeconds(_random.NextDouble(component.MinimumTimeToEmag, component.MaximumTimeToEmag)), () =>
_emag.DoEmagEffect(uid, target));
_emag.DoEmagEffect(uid, airlockUid));
}

_announcer.SendAnnouncement(
_announcer.GetAnnouncementId(args.RuleId),
Expand Down

0 comments on commit 7fd866a

Please sign in to comment.