Split cargo shuttle to its own component (#23926)
* Split cargo shuttle to its own component If mappers want 1 morbillion of them this is easier to manage. * balls
This commit is contained in:
@@ -14,6 +14,8 @@ public sealed partial class ShuttleSystem
|
||||
private void InitializeGridFills()
|
||||
{
|
||||
SubscribeLocalEvent<GridSpawnComponent, StationPostInitEvent>(OnGridSpawnPostInit);
|
||||
SubscribeLocalEvent<StationCargoShuttleComponent, StationPostInitEvent>(OnCargoSpawnPostInit);
|
||||
|
||||
SubscribeLocalEvent<GridFillComponent, MapInitEvent>(OnGridFillMapInit);
|
||||
|
||||
_cfg.OnValueChanged(CCVars.GridFill, OnGridFillChange);
|
||||
@@ -35,6 +37,13 @@ public sealed partial class ShuttleSystem
|
||||
{
|
||||
GridSpawns(uid, comp);
|
||||
}
|
||||
|
||||
var cargoQuery = AllEntityQuery<StationCargoShuttleComponent>();
|
||||
|
||||
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<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))
|
||||
|
||||
Reference in New Issue
Block a user