Skip to content

Commit

Permalink
Filter orders
Browse files Browse the repository at this point in the history
  • Loading branch information
GreaseMonk committed Apr 3, 2024
1 parent 072a54d commit abec0de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down Expand Up @@ -366,7 +369,7 @@ StationDataComponent stationData
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(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);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private List<CargoOrderData> 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
Expand Down
5 changes: 4 additions & 1 deletion Content.Shared/Cargo/CargoOrderData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ 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;
Price = price;
OrderQuantity = amount;
Requester = requester;
Reason = reason;
Computer = computer;
}

public void SetApproverData(string? fullName, string? jobTitle)
Expand Down

0 comments on commit abec0de

Please sign in to comment.