From abec0dece3444bd7e287294ae8cf3d74a99f03de Mon Sep 17 00:00:00 2001 From: Wiebe Geertsma <1354802+GreaseMonk@users.noreply.github.com> Date: Wed, 3 Apr 2024 21:54:57 +0200 Subject: [PATCH] Filter orders --- Content.Server/Cargo/Systems/CargoSystem.Orders.cs | 13 ++++++++----- Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs | 2 +- Content.Shared/Cargo/CargoOrderData.cs | 5 ++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index caf437fccee..7cc1427ea73 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -234,7 +234,7 @@ private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent compone if (!component.AllowedGroups.Contains(product.Group)) return; - var data = GetOrderData(args, product, GenerateOrderId(orderDatabase)); + var data = GetOrderData(EntityManager.GetNetEntity(uid), args, product, GenerateOrderId(orderDatabase)); if (!TryAddOrder(orderDatabase.Owner, data, orderDatabase)) { @@ -283,12 +283,15 @@ private void UpdateOrderState(CargoOrderConsoleComponent component, EntityUid? s if (station == null || !TryGetOrderDatabase(station.Value, out var _, out var orderDatabase, component)) return; + // Frontier - we only want to see orders made on the same computer, so filter them out + var filteredOrders = orderDatabase.Orders.Where(order => order.Computer == EntityManager.GetNetEntity(component.Owner)).ToList(); + var state = new CargoConsoleInterfaceState( MetaData(player).EntityName, GetOutstandingOrderCount(orderDatabase), orderDatabase.Capacity, balance, - orderDatabase.Orders); + filteredOrders); _uiSystem.SetUiState(bui, state); } @@ -303,9 +306,9 @@ private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component) _audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid); } - private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id) + private static CargoOrderData GetOrderData(NetEntity consoleUid, CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id) { - return new CargoOrderData(id, cargoProduct.Product, cargoProduct.Cost, args.Amount, args.Requester, args.Reason); + return new CargoOrderData(id, cargoProduct.Product, cargoProduct.Cost, args.Amount, args.Requester, args.Reason, consoleUid); } public static int GetOutstandingOrderCount(StationCargoOrderDatabaseComponent component) @@ -366,7 +369,7 @@ StationDataComponent stationData DebugTools.Assert(_protoMan.HasIndex(spawnId)); // Make an order var id = GenerateOrderId(component); - var order = new CargoOrderData(id, spawnId, cost, qty, sender, description); + var order = new CargoOrderData(id, spawnId, cost, qty, sender, description, null); // Approve it now order.SetApproverData(dest, sender); diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 27fde30a257..38aed90626f 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -160,7 +160,7 @@ private List GetProjectedOrders( // We won't be able to fit the whole order on, so make one // which represents the space we do have left: var reducedOrder = new CargoOrderData(order.OrderId, - order.ProductId, order.Price, spaceRemaining, order.Requester, order.Reason); + order.ProductId, order.Price, spaceRemaining, order.Requester, order.Reason, null); orders.Add(reducedOrder); } else diff --git a/Content.Shared/Cargo/CargoOrderData.cs b/Content.Shared/Cargo/CargoOrderData.cs index a6d5fb0a18a..879c4225b0e 100644 --- a/Content.Shared/Cargo/CargoOrderData.cs +++ b/Content.Shared/Cargo/CargoOrderData.cs @@ -39,7 +39,9 @@ public sealed class CargoOrderData public bool Approved => Approver is not null; public string? Approver; - public CargoOrderData(int orderId, string productId, int price, int amount, string requester, string reason) + public NetEntity? Computer = null; + + public CargoOrderData(int orderId, string productId, int price, int amount, string requester, string reason, NetEntity? computer) { OrderId = orderId; ProductId = productId; @@ -47,6 +49,7 @@ public CargoOrderData(int orderId, string productId, int price, int amount, stri OrderQuantity = amount; Requester = requester; Reason = reason; + Computer = computer; } public void SetApproverData(string? fullName, string? jobTitle)