using System.Linq;
using Content.Server.Station.Components;
using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using Content.Shared.Cargo.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Server.Cargo.Components;
///
/// Stores all of cargo orders for a particular station.
///
[RegisterComponent]
public sealed partial class StationCargoOrderDatabaseComponent : Component
{
///
/// Maximum amount of orders a station is allowed, approved or not.
///
[DataField]
public int Capacity = 20;
[ViewVariables]
public IEnumerable AllOrders => Orders.SelectMany(p => p.Value);
[DataField]
public Dictionary, List> Orders = new();
///
/// Used to determine unique order IDs
///
[ViewVariables]
public int NumOrdersCreated;
// TODO: Can probably dump this
///
/// The cargo shuttle assigned to this station.
///
[DataField("shuttle")]
public EntityUid? Shuttle;
///
/// The paper-type prototype to spawn with the order information.
///
[DataField]
public EntProtoId PrinterOutput = "PaperCargoInvoice";
}
///
/// Event broadcast before a cargo order is fulfilled, allowing alternate systems to fulfill the order.
///
[ByRefEvent]
public record struct FulfillCargoOrderEvent(Entity Station, CargoOrderData Order, Entity OrderConsole)
{
public Entity OrderConsole = OrderConsole;
public Entity Station = Station;
public CargoOrderData Order = Order;
public EntityUid? FulfillmentEntity;
public bool Handled = false;
}