diff --git a/Content.Server/Anomaly/AnomalySystem.Generator.cs b/Content.Server/Anomaly/AnomalySystem.Generator.cs index 924c3a2a42..f1b147ac80 100644 --- a/Content.Server/Anomaly/AnomalySystem.Generator.cs +++ b/Content.Server/Anomaly/AnomalySystem.Generator.cs @@ -1,6 +1,7 @@ using Content.Server.Anomaly.Components; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; +using Content.Server.Station.Components; using Content.Shared.Anomaly; using Content.Shared.CCVar; using Content.Shared.Materials; @@ -93,8 +94,7 @@ public sealed partial class AnomalySystem var xform = Transform(grid); var targetCoords = xform.Coordinates; - var gridBounds = gridComp.LocalAABB; - gridBounds.Scale(_configuration.GetCVar(CCVars.AnomalyGenerationGridBoundsScale)); + var gridBounds = gridComp.LocalAABB.Scale(_configuration.GetCVar(CCVars.AnomalyGenerationGridBoundsScale)); for (var i = 0; i < 25; i++) { @@ -147,11 +147,18 @@ public sealed partial class AnomalySystem private void OnGeneratingFinished(EntityUid uid, AnomalyGeneratorComponent component) { - var grid = Transform(uid).GridUid; - if (grid == null) - return; + var xform = Transform(uid); - SpawnOnRandomGridLocation(grid.Value, component.SpawnerPrototype); + if (_station.GetStationInMap(xform.MapID) is not { } station || + !TryComp(station, out var data) || + _station.GetLargestGrid(data) is not { } grid) + { + if (xform.GridUid == null) + return; + grid = xform.GridUid.Value; + } + + SpawnOnRandomGridLocation(grid, component.SpawnerPrototype); RemComp(uid); Appearance.SetData(uid, AnomalyGeneratorVisuals.Generating, false); Audio.PlayPvs(component.GeneratingFinishedSound, uid); diff --git a/Content.Server/Anomaly/AnomalySystem.cs b/Content.Server/Anomaly/AnomalySystem.cs index 5f50d43907..b32119264b 100644 --- a/Content.Server/Anomaly/AnomalySystem.cs +++ b/Content.Server/Anomaly/AnomalySystem.cs @@ -4,6 +4,7 @@ using Content.Server.Audio; using Content.Server.Explosion.EntitySystems; using Content.Server.Materials; using Content.Server.Radio.EntitySystems; +using Content.Server.Station.Systems; using Content.Shared.Anomaly; using Content.Shared.Anomaly.Components; using Content.Shared.DoAfter; @@ -28,6 +29,7 @@ public sealed partial class AnomalySystem : SharedAnomalySystem [Dependency] private readonly ExplosionSystem _explosion = default!; [Dependency] private readonly MaterialStorageSystem _material = default!; [Dependency] private readonly SharedPointLightSystem _pointLight = default!; + [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly RadioSystem _radio = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; diff --git a/Content.Server/Station/Systems/StationSystem.cs b/Content.Server/Station/Systems/StationSystem.cs index 7f8507205b..9f154c1b72 100644 --- a/Content.Server/Station/Systems/StationSystem.cs +++ b/Content.Server/Station/Systems/StationSystem.cs @@ -449,7 +449,7 @@ public sealed class StationSystem : EntitySystem /// Returns the first station that has a grid in a certain map. /// If the map has no stations, null is returned instead. /// - /// /// If there are multiple stations on a map it is probably arbitrary which one is returned. /// public EntityUid? GetStationInMap(MapId map)