Point[] UnpackPoints(BufferChunk chunk)
{
// Need to know how many points so that space can be allocated for them on the receiving end
int numPoints = chunk.NextInt32();
// Allocate a points array of the right size
Point[] points = new Point[numPoints];
// Encode each of the points
for (int i = 0; i < numPoints; i++)
{
points[i].x = chunk.NextInt32();
points[i].y = chunk.NextInt32();
}
return points;
}