Skip to content

Commit e03f99f

Browse files
committed
rework target grid finder
1 parent 57bc9c6 commit e03f99f

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

Content.Server/_Starlight/GameTicking/Rules/FullMoonHowlRule.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,13 @@ protected override void Started(EntityUid uid, FullMoonHowlRuleComponent compone
3232
if (!TryComp<StationDataComponent>(chosenStation.Value, out var stationData))
3333
return;
3434

35-
var mainGrids = stationData.MainGrids;
35+
// Prefer initial "main station" grid if available, otherwise fallback to all station grids.
36+
var grids = stationData.MainGrids.Count > 0
37+
? stationData.MainGrids
38+
: stationData.Grids;
3639

37-
EntityUid? mainGrid = null;
38-
foreach (var grid in mainGrids)
39-
{
40-
if (!Exists(grid))
41-
continue;
42-
43-
mainGrid = grid;
44-
break;
45-
}
46-
47-
if (mainGrid is null)
40+
// If no suitable grid is found, abort the event.
41+
if (!grids.TryFirstOrNull(out var mainGrid))
4842
return;
4943

5044
// Recipients are selected by map, not grid, so off-grid players on the station map may still hear the announcement.
@@ -80,7 +74,7 @@ protected override void Started(EntityUid uid, FullMoonHowlRuleComponent compone
8074
if (!beacon.Enabled)
8175
continue;
8276

83-
if (xform.GridUid is not { } gridUid || !mainGrids.Contains(gridUid))
77+
if (xform.GridUid is not { } gridUid || !grids.Contains(gridUid))
8478
continue;
8579

8680
var locationName = !string.IsNullOrWhiteSpace(beacon.Text)

0 commit comments

Comments
 (0)