Make anomaly generator always spawn anomalies on station (#18508)

This commit is contained in:
Nemanja
2023-08-01 00:12:55 -04:00
committed by GitHub
parent 73c323fd62
commit edd7535564
3 changed files with 16 additions and 7 deletions

View File

@@ -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<StationDataComponent>(station, out var data) ||
_station.GetLargestGrid(data) is not { } grid)
{
if (xform.GridUid == null)
return;
grid = xform.GridUid.Value;
}
SpawnOnRandomGridLocation(grid, component.SpawnerPrototype);
RemComp<GeneratingAnomalyGeneratorComponent>(uid);
Appearance.SetData(uid, AnomalyGeneratorVisuals.Generating, false);
Audio.PlayPvs(component.GeneratingFinishedSound, uid);

View File

@@ -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!;

View File

@@ -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.
/// </summary>
/// </remarks
/// <remarks>
/// If there are multiple stations on a map it is probably arbitrary which one is returned.
/// </remarks>
public EntityUid? GetStationInMap(MapId map)