Add FTL destinations (#9685)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Labels.Components;
|
||||
@@ -6,6 +5,7 @@ using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Components;
|
||||
@@ -15,7 +15,6 @@ using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.MobState.Components;
|
||||
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
@@ -40,16 +39,11 @@ public sealed partial class CargoSystem
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
||||
[Dependency] private readonly ShuttleSystem _shuttle = default!;
|
||||
|
||||
public MapId? CargoMap { get; private set; }
|
||||
|
||||
private const float ShuttleRecallRange = 100f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum mass a grid needs to be to block a shuttle recall.
|
||||
/// </summary>
|
||||
private const float ShuttleCallMassThreshold = 300f;
|
||||
|
||||
private const float CallOffset = 50f;
|
||||
|
||||
private int _index;
|
||||
@@ -162,12 +156,11 @@ public sealed partial class CargoSystem
|
||||
var orders = GetProjectedOrders(orderDatabase, shuttle);
|
||||
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;
|
||||
|
||||
// TODO: Loc
|
||||
_uiSystem.GetUiOrNull(component.Owner, CargoConsoleUiKey.Shuttle)?.SetState(
|
||||
new CargoShuttleConsoleBoundUserInterfaceState(
|
||||
station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"),
|
||||
string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName,
|
||||
CanRecallShuttle(shuttle?.Owner, out _),
|
||||
_shuttle.CanFTL(shuttle?.Owner, out _),
|
||||
shuttle?.NextCall,
|
||||
orders));
|
||||
}
|
||||
@@ -194,7 +187,7 @@ public sealed partial class CargoSystem
|
||||
var oldCanRecall = component.CanRecall;
|
||||
|
||||
// Check if we can update the recall status.
|
||||
var canRecall = CanRecallShuttle(uid, out _, args.Component);
|
||||
var canRecall = _shuttle.CanFTL(uid, out _, args.Component);
|
||||
if (oldCanRecall == canRecall) return;
|
||||
|
||||
component.CanRecall = canRecall;
|
||||
@@ -370,6 +363,7 @@ public sealed partial class CargoSystem
|
||||
shuttle.NextCall = null;
|
||||
|
||||
// Find a valid free area nearby to spawn in on
|
||||
// TODO: Make this use hyperspace now.
|
||||
var center = new Vector2();
|
||||
var minRadius = 0f;
|
||||
Box2? aabb = null;
|
||||
@@ -399,6 +393,7 @@ public sealed partial class CargoSystem
|
||||
AddCargoContents(shuttle, orderDatabase);
|
||||
UpdateOrders(orderDatabase);
|
||||
UpdateShuttleCargoConsoles(shuttle);
|
||||
_console.RefreshShuttleConsoles();
|
||||
|
||||
_sawmill.Info($"Retrieved cargo shuttle {ToPrettyString(shuttle.Owner)} from {ToPrettyString(orderDatabase.Owner)}");
|
||||
}
|
||||
@@ -469,29 +464,6 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanRecallShuttle(EntityUid? uid, [NotNullWhen(false)] out string? reason, TransformComponent? xform = null)
|
||||
{
|
||||
reason = null;
|
||||
|
||||
if (!TryComp<IMapGridComponent>(uid, out var grid) ||
|
||||
!Resolve(uid.Value, ref xform)) return true;
|
||||
|
||||
var bounds = grid.Grid.WorldAABB.Enlarged(ShuttleRecallRange);
|
||||
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
||||
|
||||
foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds))
|
||||
{
|
||||
if (grid.GridIndex == other.Index ||
|
||||
!bodyQuery.TryGetComponent(other.GridEntityId, out var body) ||
|
||||
body.Mass < ShuttleCallMassThreshold) continue;
|
||||
|
||||
reason = Loc.GetString("cargo-shuttle-console-proximity");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void RecallCargoShuttle(EntityUid uid, CargoShuttleConsoleComponent component, CargoRecallShuttleMessage args)
|
||||
{
|
||||
var player = args.Session.AttachedEntity;
|
||||
@@ -505,11 +477,11 @@ public sealed partial class CargoSystem
|
||||
|
||||
if (!TryComp<CargoShuttleComponent>(orderDatabase.Shuttle, out var shuttle))
|
||||
{
|
||||
_popup.PopupEntity($"No cargo shuttle found!", args.Entity, Filter.Entities(args.Entity));
|
||||
_popup.PopupEntity(Loc.GetString("cargo-no-shuttle"), args.Entity, Filter.Entities(args.Entity));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanRecallShuttle(shuttle.Owner, out var reason))
|
||||
if (!_shuttle.CanFTL(shuttle.Owner, out var reason))
|
||||
{
|
||||
_popup.PopupEntity(reason, args.Entity, Filter.Entities(args.Entity));
|
||||
return;
|
||||
@@ -523,7 +495,7 @@ public sealed partial class CargoSystem
|
||||
};
|
||||
|
||||
SellPallets(shuttle, bank);
|
||||
|
||||
_console.RefreshShuttleConsoles();
|
||||
SendToCargoMap(orderDatabase.Shuttle.Value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user