diff --git a/Content.Server/Shuttles/Components/GridSpawnComponent.cs b/Content.Server/Shuttles/Components/GridSpawnComponent.cs
index d8144354b8e7..430c9c8df285 100644
--- a/Content.Server/Shuttles/Components/GridSpawnComponent.cs
+++ b/Content.Server/Shuttles/Components/GridSpawnComponent.cs
@@ -26,6 +26,11 @@ public interface IGridSpawnGroup
///
public float MinimumDistance { get; }
+ ///
+ /// Maximum distance to spawn away from the station.
+ ///
+ public float MaximumDistance { get; }
+
///
public ProtoId? NameDataset { get; }
@@ -67,6 +72,8 @@ public sealed class DungeonSpawnGroup : IGridSpawnGroup
///
public float MinimumDistance { get; }
+ public float MaximumDistance { get; }
+
///
public ProtoId? NameDataset { get; }
@@ -94,7 +101,11 @@ public sealed class GridSpawnGroup : IGridSpawnGroup
{
public List Paths = new();
+ ///
public float MinimumDistance { get; }
+
+ ///
+ public float MaximumDistance { get; }
public ProtoId? NameDataset { get; }
public int MinCount { get; set; } = 1;
public int MaxCount { get; set; } = 1;
diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
index b4fcccd80557..789f74997f45 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
@@ -9,6 +9,7 @@
using Content.Shared.Shuttles.Components;
using Robust.Shared.Collections;
using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -85,9 +86,15 @@ private void CargoSpawn(EntityUid uid, StationCargoShuttleComponent component)
_mapManager.DeleteMap(mapId);
}
- private bool TryDungeonSpawn(EntityUid targetGrid, EntityUid stationUid, MapId mapId, DungeonSpawnGroup group, out EntityUid spawned)
+ private bool TryDungeonSpawn(Entity targetGrid, EntityUid stationUid, MapId mapId, DungeonSpawnGroup group, out EntityUid spawned)
{
spawned = EntityUid.Invalid;
+
+ if (!_gridQuery.Resolve(targetGrid.Owner, ref targetGrid.Comp))
+ {
+ return false;
+ }
+
var dungeonProtoId = _random.Pick(group.Protos);
if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto))
@@ -95,11 +102,13 @@ private bool TryDungeonSpawn(EntityUid targetGrid, EntityUid stationUid, MapId m
return false;
}
- var spawnCoords = new EntityCoordinates(targetGrid, Vector2.Zero);
+ var targetPhysics = _physicsQuery.Comp(targetGrid);
+ var spawnCoords = new EntityCoordinates(targetGrid, targetPhysics.LocalCenter);
if (group.MinimumDistance > 0f)
{
- spawnCoords = spawnCoords.Offset(_random.NextVector2(group.MinimumDistance, group.MinimumDistance * 1.5f));
+ var distancePadding = MathF.Max(targetGrid.Comp.LocalAABB.Width, targetGrid.Comp.LocalAABB.Height);
+ spawnCoords = spawnCoords.Offset(_random.NextVector2(distancePadding + group.MinimumDistance, distancePadding + group.MaximumDistance));
}
var spawnMapCoords = _transform.ToMapCoordinates(spawnCoords);
diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs
index 85703389e9de..aae466ba0dcc 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs
@@ -58,12 +58,16 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
[Dependency] private readonly ThrusterSystem _thruster = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
+ private EntityQuery _gridQuery;
+
public const float TileMassMultiplier = 0.5f;
public override void Initialize()
{
base.Initialize();
+ _gridQuery = GetEntityQuery();
+
InitializeFTL();
InitializeGridFills();
InitializeIFF();
diff --git a/Resources/Prototypes/Entities/Stations/base.yml b/Resources/Prototypes/Entities/Stations/base.yml
index c7b54f457170..de191277aef7 100644
--- a/Resources/Prototypes/Entities/Stations/base.yml
+++ b/Resources/Prototypes/Entities/Stations/base.yml
@@ -73,7 +73,8 @@
- /Maps/Ruins/whiteship_ancient.yml
- /Maps/Ruins/whiteship_bluespacejumper.yml
vgroid: !type:DungeonSpawnGroup
- minimumDistance: 1000
+ minimumDistance: 400
+ maximumDistance: 450
nameDataset: names_borer
stationGrid: false
addComponents: