Fix cargo shuttle (#10397)
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Server.Shuttles.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Components;
|
||||
@@ -358,13 +359,22 @@ public sealed partial class CargoSystem
|
||||
/// </summary>
|
||||
public void CallShuttle(StationCargoOrderDatabaseComponent orderDatabase)
|
||||
{
|
||||
if (!TryComp<CargoShuttleComponent>(orderDatabase.Shuttle, out var shuttle) ||
|
||||
!TryComp<TransformComponent>(orderDatabase.Owner, out var xform)) return;
|
||||
if (!TryComp<CargoShuttleComponent>(orderDatabase.Shuttle, out var shuttle))
|
||||
return;
|
||||
|
||||
// Already called / not available
|
||||
if (shuttle.NextCall == null || _timing.CurTime < shuttle.NextCall)
|
||||
return;
|
||||
|
||||
if (!TryComp<StationDataComponent>(orderDatabase.Owner, out var stationData))
|
||||
return;
|
||||
|
||||
var targetGrid = _station.GetLargestGrid(stationData);
|
||||
|
||||
// Nowhere to warp in to.
|
||||
if (!TryComp<TransformComponent>(targetGrid, out var xform))
|
||||
return;
|
||||
|
||||
shuttle.NextCall = null;
|
||||
|
||||
// Find a valid free area nearby to spawn in on
|
||||
|
||||
@@ -96,7 +96,7 @@ public sealed partial class ShuttleSystem
|
||||
!TryComp<StationDataComponent>(_station.GetOwningStation(player.Value), out var stationData) ||
|
||||
!TryComp<ShuttleComponent>(stationData.EmergencyShuttle, out var shuttle)) return;
|
||||
|
||||
var targetGrid = GetLargestGrid(stationData);
|
||||
var targetGrid = _station.GetLargestGrid(stationData);
|
||||
if (targetGrid == null) return;
|
||||
var config = GetDockingConfig(shuttle, targetGrid.Value);
|
||||
if (config == null) return;
|
||||
@@ -242,7 +242,7 @@ public sealed partial class ShuttleSystem
|
||||
!TryComp<TransformComponent>(stationData.EmergencyShuttle, out var xform) ||
|
||||
!TryComp<ShuttleComponent>(stationData.EmergencyShuttle, out var shuttle)) return;
|
||||
|
||||
var targetGrid = GetLargestGrid(stationData);
|
||||
var targetGrid = _station.GetLargestGrid(stationData);
|
||||
|
||||
// UHH GOOD LUCK
|
||||
if (targetGrid == null)
|
||||
@@ -378,27 +378,6 @@ public sealed partial class ShuttleSystem
|
||||
_commsConsole.UpdateCommsConsoleInterface();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the largest member grid from a station.
|
||||
/// </summary>
|
||||
private EntityUid? GetLargestGrid(StationDataComponent component)
|
||||
{
|
||||
EntityUid? largestGrid = null;
|
||||
Box2 largestBounds = new Box2();
|
||||
|
||||
foreach (var gridUid in component.Grids)
|
||||
{
|
||||
if (!TryComp<IMapGridComponent>(gridUid, out var grid)) continue;
|
||||
|
||||
if (grid.Grid.LocalAABB.Size.LengthSquared < largestBounds.Size.LengthSquared) continue;
|
||||
|
||||
largestBounds = grid.Grid.LocalAABB;
|
||||
largestGrid = gridUid;
|
||||
}
|
||||
|
||||
return largestGrid;
|
||||
}
|
||||
|
||||
private List<DockingComponent> GetDocks(EntityUid uid)
|
||||
{
|
||||
var result = new List<DockingComponent>();
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class StationSystem : EntitySystem
|
||||
|
||||
private void OnStationDeleted(EntityUid uid, StationDataComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (_stations.Contains(uid) && // Was not deleted via DeleteStation()
|
||||
if (_stations.Contains(uid) && // Was not deleted via DeleteStation()
|
||||
_gameTicker.RunLevel == GameRunLevel.InRound) // And not due to a round restart
|
||||
{
|
||||
throw new InvalidOperationException($"Station entity {ToPrettyString(uid)} is getting deleted mid-round.");
|
||||
@@ -205,6 +205,27 @@ public sealed class StationSystem : EntitySystem
|
||||
|
||||
#endregion Event handlers
|
||||
|
||||
/// <summary>
|
||||
/// Gets the largest member grid from a station.
|
||||
/// </summary>
|
||||
public EntityUid? GetLargestGrid(StationDataComponent component)
|
||||
{
|
||||
EntityUid? largestGrid = null;
|
||||
Box2 largestBounds = new Box2();
|
||||
|
||||
foreach (var gridUid in component.Grids)
|
||||
{
|
||||
if (!TryComp<IMapGridComponent>(gridUid, out var grid) ||
|
||||
grid.Grid.LocalAABB.Size.LengthSquared < largestBounds.Size.LengthSquared)
|
||||
continue;
|
||||
|
||||
largestBounds = grid.Grid.LocalAABB;
|
||||
largestGrid = gridUid;
|
||||
}
|
||||
|
||||
return largestGrid;
|
||||
}
|
||||
|
||||
public Filter GetInStation(EntityUid source, float range = 32f)
|
||||
{
|
||||
var station = GetOwningStation(source);
|
||||
|
||||
Reference in New Issue
Block a user