diff --git a/Content.Server/Shuttles/Components/GridSpawnComponent.cs b/Content.Server/Shuttles/Components/GridSpawnComponent.cs
index d8144354b8..430c9c8df2 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 0976bc5de1..a31fda074f 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
@@ -10,6 +10,7 @@ using Content.Shared.Shuttles.Components;
using Content.Shared.Station.Components;
using Robust.Shared.Collections;
using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -86,9 +87,15 @@ public sealed partial class ShuttleSystem
_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))
@@ -96,11 +103,13 @@ public sealed partial class ShuttleSystem
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 85703389e9..aae466ba0d 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 c7b54f4571..de191277ae 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: