2025-04-13 09:22:36 -04:00
|
|
|
using System.Linq;
|
2022-06-23 14:36:47 +10:00
|
|
|
using Content.Shared.Cargo;
|
2024-04-23 08:07:12 -04:00
|
|
|
using Content.Shared.Cargo.Components;
|
2022-07-15 14:11:41 +10:00
|
|
|
using Content.Shared.Cargo.Prototypes;
|
2025-08-08 11:22:34 -04:00
|
|
|
using Content.Shared.Station.Components;
|
2024-01-19 13:02:28 +11:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-06-23 14:36:47 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.Cargo.Components;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stores all of cargo orders for a particular station.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class StationCargoOrderDatabaseComponent : Component
|
2022-06-23 14:36:47 +10:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maximum amount of orders a station is allowed, approved or not.
|
|
|
|
|
/// </summary>
|
2025-04-13 09:22:36 -04:00
|
|
|
[DataField]
|
2022-06-23 14:36:47 +10:00
|
|
|
public int Capacity = 20;
|
|
|
|
|
|
2025-04-13 09:22:36 -04:00
|
|
|
[ViewVariables]
|
|
|
|
|
public IEnumerable<CargoOrderData> AllOrders => Orders.SelectMany(p => p.Value);
|
|
|
|
|
|
|
|
|
|
[DataField]
|
|
|
|
|
public Dictionary<ProtoId<CargoAccountPrototype>, List<CargoOrderData>> Orders = new();
|
2022-06-23 14:36:47 +10:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-03-05 04:27:30 +00:00
|
|
|
/// Used to determine unique order IDs
|
2022-06-23 14:36:47 +10:00
|
|
|
/// </summary>
|
2025-04-13 09:22:36 -04:00
|
|
|
[ViewVariables]
|
2023-03-05 04:27:30 +00:00
|
|
|
public int NumOrdersCreated;
|
2022-06-23 14:36:47 +10:00
|
|
|
|
2025-05-18 00:02:52 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// An all encompassing determiner of what markets can be ordered from.
|
|
|
|
|
/// Not every console can order from every market, but a console can't order from a market not on this list.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public List<ProtoId<CargoMarketPrototype>> Markets = new()
|
|
|
|
|
{
|
|
|
|
|
"market",
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-31 11:13:02 +10:00
|
|
|
// TODO: Can probably dump this
|
2022-06-23 14:36:47 +10:00
|
|
|
/// <summary>
|
|
|
|
|
/// The cargo shuttle assigned to this station.
|
|
|
|
|
/// </summary>
|
2022-11-16 20:22:11 +01:00
|
|
|
[DataField("shuttle")]
|
2022-06-23 14:36:47 +10:00
|
|
|
public EntityUid? Shuttle;
|
2024-01-19 13:02:28 +11:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The paper-type prototype to spawn with the order information.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public EntProtoId PrinterOutput = "PaperCargoInvoice";
|
2022-06-23 14:36:47 +10:00
|
|
|
}
|
2024-04-23 08:07:12 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Event broadcast before a cargo order is fulfilled, allowing alternate systems to fulfill the order.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
public record struct FulfillCargoOrderEvent(Entity<StationDataComponent> Station, CargoOrderData Order, Entity<CargoOrderConsoleComponent> OrderConsole)
|
|
|
|
|
{
|
|
|
|
|
public Entity<CargoOrderConsoleComponent> OrderConsole = OrderConsole;
|
|
|
|
|
public Entity<StationDataComponent> Station = Station;
|
|
|
|
|
public CargoOrderData Order = Order;
|
|
|
|
|
|
|
|
|
|
public EntityUid? FulfillmentEntity;
|
|
|
|
|
public bool Handled = false;
|
|
|
|
|
}
|