--- /dev/null
+using Robust.Shared.Utility;
+
+namespace Content.Server.Shuttles.Components;
+
+/// <summary>
+/// GridSpawnComponent but for cargo shuttles
+/// <remarks>
+/// This exists so we don't need to make 1 change to GridSpawn for every single station's unique shuttles.
+/// </remarks>
+/// </summary>
+[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");
+}
private void InitializeGridFills()
{
SubscribeLocalEvent<GridSpawnComponent, StationPostInitEvent>(OnGridSpawnPostInit);
+ SubscribeLocalEvent<StationCargoShuttleComponent, StationPostInitEvent>(OnCargoSpawnPostInit);
+
SubscribeLocalEvent<GridFillComponent, MapInitEvent>(OnGridFillMapInit);
_cfg.OnValueChanged(CCVars.GridFill, OnGridFillChange);
{
GridSpawns(uid, comp);
}
+
+ var cargoQuery = AllEntityQuery<StationCargoShuttleComponent>();
+
+ while (cargoQuery.MoveNext(out var uid, out var comp))
+ {
+ CargoSpawn(uid, comp);
+ }
}
}
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<ShuttleComponent>(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))