Made ordering multiple crates at cargo order multiple crates (#25518)
* please tell me this is empty * it wasn't empty, fixing that * This should fix it * fix for the fix * address changes * fix * Added some comments, hoping that failed test was a fluke.
This commit is contained in:
@@ -209,7 +209,8 @@ namespace Content.Server.Cargo.Systems
|
||||
_random.Shuffle(tradePads);
|
||||
|
||||
var freePads = GetFreeCargoPallets(trade, tradePads);
|
||||
|
||||
if (freePads.Count >= order.OrderQuantity) //check if the station has enough free pallets
|
||||
{
|
||||
foreach (var pad in freePads)
|
||||
{
|
||||
var coordinates = new EntityCoordinates(trade, pad.Transform.LocalPosition);
|
||||
@@ -217,9 +218,12 @@ namespace Content.Server.Cargo.Systems
|
||||
if (FulfillOrder(order, coordinates, orderDatabase.PrinterOutput))
|
||||
{
|
||||
tradeDestination = trade;
|
||||
order.NumDispatched++;
|
||||
if (order.OrderQuantity <= order.NumDispatched) //Spawn a crate on free pellets until the order is fulfilled.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tradeDestination != null)
|
||||
break;
|
||||
|
||||
@@ -196,12 +196,14 @@ public sealed partial class CargoSystem
|
||||
return _pads;
|
||||
}
|
||||
|
||||
private IEnumerable<(EntityUid Entity, CargoPalletComponent Component, TransformComponent Transform)>
|
||||
private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent Transform)>
|
||||
GetFreeCargoPallets(EntityUid gridUid,
|
||||
List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent Transform)> pallets)
|
||||
{
|
||||
_setEnts.Clear();
|
||||
|
||||
List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent Transform)> outList = new();
|
||||
|
||||
foreach (var pallet in pallets)
|
||||
{
|
||||
var aabb = _lookup.GetAABBNoContainer(pallet.Entity, pallet.Transform.LocalPosition, pallet.Transform.LocalRotation);
|
||||
@@ -209,8 +211,10 @@ public sealed partial class CargoSystem
|
||||
if (_lookup.AnyLocalEntitiesIntersecting(gridUid, aabb, LookupFlags.Dynamic))
|
||||
continue;
|
||||
|
||||
yield return pallet;
|
||||
outList.Add(pallet);
|
||||
}
|
||||
|
||||
return outList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user