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);