Make anomaly generator always spawn anomalies on station (#18508)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.Anomaly.Components;
|
using Content.Server.Anomaly.Components;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
|
using Content.Server.Station.Components;
|
||||||
using Content.Shared.Anomaly;
|
using Content.Shared.Anomaly;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Materials;
|
using Content.Shared.Materials;
|
||||||
@@ -93,8 +94,7 @@ public sealed partial class AnomalySystem
|
|||||||
var xform = Transform(grid);
|
var xform = Transform(grid);
|
||||||
|
|
||||||
var targetCoords = xform.Coordinates;
|
var targetCoords = xform.Coordinates;
|
||||||
var gridBounds = gridComp.LocalAABB;
|
var gridBounds = gridComp.LocalAABB.Scale(_configuration.GetCVar(CCVars.AnomalyGenerationGridBoundsScale));
|
||||||
gridBounds.Scale(_configuration.GetCVar(CCVars.AnomalyGenerationGridBoundsScale));
|
|
||||||
|
|
||||||
for (var i = 0; i < 25; i++)
|
for (var i = 0; i < 25; i++)
|
||||||
{
|
{
|
||||||
@@ -147,11 +147,18 @@ public sealed partial class AnomalySystem
|
|||||||
|
|
||||||
private void OnGeneratingFinished(EntityUid uid, AnomalyGeneratorComponent component)
|
private void OnGeneratingFinished(EntityUid uid, AnomalyGeneratorComponent component)
|
||||||
{
|
{
|
||||||
var grid = Transform(uid).GridUid;
|
var xform = Transform(uid);
|
||||||
if (grid == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
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);
|
RemComp<GeneratingAnomalyGeneratorComponent>(uid);
|
||||||
Appearance.SetData(uid, AnomalyGeneratorVisuals.Generating, false);
|
Appearance.SetData(uid, AnomalyGeneratorVisuals.Generating, false);
|
||||||
Audio.PlayPvs(component.GeneratingFinishedSound, uid);
|
Audio.PlayPvs(component.GeneratingFinishedSound, uid);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Content.Server.Audio;
|
|||||||
using Content.Server.Explosion.EntitySystems;
|
using Content.Server.Explosion.EntitySystems;
|
||||||
using Content.Server.Materials;
|
using Content.Server.Materials;
|
||||||
using Content.Server.Radio.EntitySystems;
|
using Content.Server.Radio.EntitySystems;
|
||||||
|
using Content.Server.Station.Systems;
|
||||||
using Content.Shared.Anomaly;
|
using Content.Shared.Anomaly;
|
||||||
using Content.Shared.Anomaly.Components;
|
using Content.Shared.Anomaly.Components;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
@@ -28,6 +29,7 @@ public sealed partial class AnomalySystem : SharedAnomalySystem
|
|||||||
[Dependency] private readonly ExplosionSystem _explosion = default!;
|
[Dependency] private readonly ExplosionSystem _explosion = default!;
|
||||||
[Dependency] private readonly MaterialStorageSystem _material = default!;
|
[Dependency] private readonly MaterialStorageSystem _material = default!;
|
||||||
[Dependency] private readonly SharedPointLightSystem _pointLight = default!;
|
[Dependency] private readonly SharedPointLightSystem _pointLight = default!;
|
||||||
|
[Dependency] private readonly StationSystem _station = default!;
|
||||||
[Dependency] private readonly RadioSystem _radio = default!;
|
[Dependency] private readonly RadioSystem _radio = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
|
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ public sealed class StationSystem : EntitySystem
|
|||||||
/// Returns the first station that has a grid in a certain map.
|
/// Returns the first station that has a grid in a certain map.
|
||||||
/// If the map has no stations, null is returned instead.
|
/// If the map has no stations, null is returned instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// </remarks
|
/// <remarks>
|
||||||
/// If there are multiple stations on a map it is probably arbitrary which one is returned.
|
/// If there are multiple stations on a map it is probably arbitrary which one is returned.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public EntityUid? GetStationInMap(MapId map)
|
public EntityUid? GetStationInMap(MapId map)
|
||||||
|
|||||||
Reference in New Issue
Block a user