public static GameObject CreateSeparateBoard(Node baseNode, ref WoodMaterialObject boardToSplit)
    {
        List <Node> nodes = new List <Node>();

        WoodManagerHelper.RetrieveNodes(ref nodes, baseNode);

        GameObject board = new GameObject("WoodStrip");

        board.tag = "WoodStrip";
        WoodMaterialObject woodBoard   = board.AddComponent <WoodMaterialObject>();
        List <Node>        boardNodes  = new List <Node>();
        List <CutLine>     boardLines  = new List <CutLine>();
        Bounds             boardBounds = new Bounds();

        for (int index = 0; index < nodes.Count; index++)
        {
            Node n = nodes[index];
            boardNodes.Add(n);//n.gameObject.transform.parent = board.transform;
            woodBoard.WoodPieces.Add(n.gameObject);
            if (index == 0)
            {
                boardBounds = new Bounds(n.gameObject.transform.position, Vector3.zero);
            }
            else
            {
                boardBounds.Encapsulate(n.gameObject.transform.position);
            }
            if (n.gameObject.tag == "DadoBlock")
            {
                woodBoard.AddDado(n.gameObject.GetComponent <DadoBlock>());
            }
            for (int i = 0; i < boardToSplit.LinesToCut.Count; i++)
            {
                if (boardToSplit.LinesToCut[i].ContainsPiece(n))
                {
                    boardLines.Add(boardToSplit.LinesToCut[i]);//boardToSplit.LinesToCut[i].gameObject.transform.parent = board.transform;
                    boardBounds.Encapsulate(boardToSplit.LinesToCut[i].gameObject.transform.position);
                    woodBoard.AddLine(boardToSplit.LinesToCut[i]);
                    boardToSplit.RemoveLine(i--);
                }
            }
        }

        board.transform.position = boardBounds.center;

        foreach (Node n in boardNodes)
        {
            n.gameObject.transform.parent = board.transform;
        }

        foreach (CutLine line in boardLines)
        {
            line.gameObject.transform.parent = board.transform;
        }

        return(board);
    }
 //Recursive call to get all connected nodes
 private static void RetrieveNodes(ref List <Node> nodes, Node baseNode)
 {
     nodes.Add(baseNode);
     foreach (Node c in baseNode.ConnectedPieces)
     {
         if (!nodes.Contains(c))
         {
             WoodManagerHelper.RetrieveNodes(ref nodes, c);
         }
     }
 }
    /// <summary>
    /// Separates the pieces of the wood material based on the node passed in.
    /// Using a graph structure, this builds out a new wood material gameobject with the pieces that were
    /// connected to the base node and the base node's children
    /// </summary>
    /// <param name="baseNode">The node to start from</param>
    /// <param name="boardToSplit">The wood material that will be split</param>
    /// <returns>A gameobject representing the split wood material</returns>
    public static GameObject CreateSeparateBoard(Node baseNode, ref WoodMaterialObject boardToSplit)
    {
        //Finds all of the connected nodes that will be part of the new wood material gameobject
        List <Node> nodes = new List <Node>();

        WoodManagerHelper.RetrieveNodes(ref nodes, baseNode);

        GameObject board = new GameObject("WoodStrip");

        board.tag = "WoodStrip";
        WoodMaterialObject woodBoard   = board.AddComponent <WoodMaterialObject>();
        List <Node>        boardNodes  = new List <Node>();    //The pieces for the new wood material gameobject
        List <CutLine>     boardLines  = new List <CutLine>(); //The lines that belong to the new wood material gameobject
        Bounds             boardBounds = new Bounds();

        for (int index = 0; index < nodes.Count; index++)
        {
            Node n = nodes[index];
            boardNodes.Add(n);
            woodBoard.WoodPieces.Add(n.gameObject);
            if (index == 0)
            {
                boardBounds = new Bounds(n.gameObject.transform.position, Vector3.zero);
            }
            else
            {
                boardBounds.Encapsulate(n.gameObject.transform.position);
            }
            //Like the lines, make sure the dado cut areas go to the correct wood material
            if (n.gameObject.tag == "DadoBlock")
            {
                woodBoard.AddDado(n.gameObject.GetComponent <DadoBlock>());
            }
            for (int i = 0; i < boardToSplit.LinesToCut.Count; i++)
            {
                if (boardToSplit.LinesToCut[i] == null)
                {
                    Debug.Log(i + " is null");
                }
                else
                {
                    if (boardToSplit.LinesToCut[i].ContainsPiece(n))
                    {
                        boardLines.Add(boardToSplit.LinesToCut[i]);
                        boardBounds.Encapsulate(boardToSplit.LinesToCut[i].gameObject.transform.position);
                        woodBoard.AddLine(boardToSplit.LinesToCut[i]);
                        boardToSplit.RemoveLine(i--);
                    }
                }
            }
        }

        board.transform.position = boardBounds.center;

        foreach (Node n in boardNodes)
        {
            n.gameObject.transform.parent = board.transform;
        }

        foreach (CutLine line in boardLines)
        {
            line.gameObject.transform.parent = board.transform;
        }
        Rigidbody r = board.AddComponent <Rigidbody>();

        r.useGravity = true;
        return(board);
    }