public void CopyOccupantsFrom(Level other) { // Make sure the levels are assessed. AssessLevel(); other.AssessLevel(); // Quick check that the levels are compatible with this operation. if (boxes != other.boxes || sokobans > 1 || other.sokobans > 1 || insideSquares != other.insideSquares) { throw new InvalidOperationException("incompatible level"); } // Remove the old sokoban. if (sokobans == 1) { RemoveSokoban(); } // Move the boxes. MoveBoxes(other.boxCoordinates); // Add the new sokoban. if (other.sokobans == 1) { AddSokoban(other.SokobanCoordinate); } if (markAccessible) { AddAccessible(); } #if DEBUG if (validate) { if (!Equals(other)) { throw new Exception("copy occupants failed"); } } #endif }