diff --git a/Content.Server/Shuttles/Components/StationCargoShuttleComponent.cs b/Content.Server/Shuttles/Components/StationCargoShuttleComponent.cs
new file mode 100644
index 0000000000..6ee890a7e9
--- /dev/null
+++ b/Content.Server/Shuttles/Components/StationCargoShuttleComponent.cs
@@ -0,0 +1,19 @@
+using Robust.Shared.Utility;
+
+namespace Content.Server.Shuttles.Components;
+
+///
+/// GridSpawnComponent but for cargo shuttles
+///
+/// This exists so we don't need to make 1 change to GridSpawn for every single station's unique shuttles.
+///
+///
+[RegisterComponent]
+public sealed partial class StationCargoShuttleComponent : Component
+{
+ // If you add more than just make an abstract comp, split them, then use overloads in the system.
+ // YAML is filled out so mappers don't have to read here.
+
+ [DataField(required: true)]
+ public ResPath Path = new("/Maps/Shuttles/cargo.yml");
+}
diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
index 2d52f98423..5958bf0ebd 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
@@ -14,6 +14,8 @@ public sealed partial class ShuttleSystem
private void InitializeGridFills()
{
SubscribeLocalEvent(OnGridSpawnPostInit);
+ SubscribeLocalEvent(OnCargoSpawnPostInit);
+
SubscribeLocalEvent(OnGridFillMapInit);
_cfg.OnValueChanged(CCVars.GridFill, OnGridFillChange);
@@ -35,6 +37,13 @@ public sealed partial class ShuttleSystem
{
GridSpawns(uid, comp);
}
+
+ var cargoQuery = AllEntityQuery();
+
+ while (cargoQuery.MoveNext(out var uid, out var comp))
+ {
+ CargoSpawn(uid, comp);
+ }
}
}
@@ -43,6 +52,39 @@ public sealed partial class ShuttleSystem
GridSpawns(uid, component);
}
+ private void OnCargoSpawnPostInit(EntityUid uid, StationCargoShuttleComponent component, ref StationPostInitEvent args)
+ {
+ CargoSpawn(uid, component);
+ }
+
+ private void CargoSpawn(EntityUid uid, StationCargoShuttleComponent component)
+ {
+ if (!_cfg.GetCVar(CCVars.GridFill))
+ return;
+
+ if (!TryComp(uid, out StationDataComponent? dataComp))
+ return;
+
+ var targetGrid = _station.GetLargestGrid(dataComp);
+
+ if (targetGrid == null)
+ return;
+
+ var mapId = _mapManager.CreateMap();
+
+ if (_loader.TryLoad(mapId, component.Path.ToString(), out var ent) && ent.Count > 0)
+ {
+ if (TryComp(ent[0], out var shuttle))
+ {
+ TryFTLProximity(ent[0], shuttle, targetGrid.Value);
+ }
+
+ _station.AddGridToStation(uid, ent[0]);
+ }
+
+ _mapManager.DeleteMap(mapId);
+ }
+
private void GridSpawns(EntityUid uid, GridSpawnComponent component)
{
if (!_cfg.GetCVar(CCVars.GridFill))
diff --git a/Resources/Prototypes/Entities/Stations/base.yml b/Resources/Prototypes/Entities/Stations/base.yml
index 503fd7082d..571469253b 100644
--- a/Resources/Prototypes/Entities/Stations/base.yml
+++ b/Resources/Prototypes/Entities/Stations/base.yml
@@ -42,11 +42,10 @@
id: BaseStationShuttles
abstract: true
components:
+ - type: StationCargoShuttle
+ path: /Maps/Shuttles/cargo.yml
- type: GridSpawn
groups:
- cargo:
- paths:
- - /Maps/Shuttles/cargo.yml
mining:
paths:
- /Maps/Shuttles/mining.yml