void CutToBoxes(GameObject cloud_go) { // using linked list so we can change order on the fly ImportedCloud iCloud = cloud_go.GetComponent<ImportedCloud>(); slices = new LinkedList<Slice>( iCloud.slices ); maxTodoCount = cutBoxes.Count * Prefs.MaxCompactSize; done = 0; portionCount = 0; Progressor prog = new Progressor ("Cutting " + cloud_go.name + " according to boxes"); // open the original file for reading origReader = new CloudStream.Reader( new FileStream( Prefs.ImportedBin(cloud_go.name) , FileMode.Open, FileAccess.Read)); try { // since we get rid of full boxes and exhausted slices ... while( cutBoxHelpers.Count > 0 && slices.Count > 0 ) { // iterate over remaining slices LinkedListNode<Slice> slice_iter = slices.First; do { // deal with this once slice ... SortSlicePortion(slice_iter, cutBoxHelpers, shadowBoxHelpers); prog.Progress( (float)done/(float)maxTodoCount, "Sorting..."); } while (cutBoxHelpers.Count > 0 && (slice_iter = slice_iter.Next) != null); portionCount++; } // close remaining boxes foreach (BoxHelper box in cutBoxHelpers) box.Finish (); foreach (BoxHelper box in shadowBoxHelpers) box.Finish (); } finally { prog.Done(); } }