private static OrderBufferElement FirstValidOrder(DynamicBuffer <OrderBufferElement> orders, DynamicBuffer <InventoryBufferElement> inventory) { for (int i = 0; i < orders.Length; i++) { var order = orders[i]; if (!order.IsTaken && order.RequestedAmount <= inventory.GetAmountOf(order.RequestedResourceName)) { return(order); } } return(default);