// sets the board being looked at to the board being placed so it can be moved/rotated/deleted without removing all its children first
    public static void MoveExistingBoard()
    {
        RaycastHit hit;

        if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask))
        {
            if (hit.collider.tag == "CircuitBoard")
            {
                GameObject MoveThis = hit.collider.gameObject;
                if (Input.GetButton("Mod"))
                {
                    GameObject RootBoard = hit.collider.transform.root.gameObject;
                    if (RootBoard.tag == "CircuitBoard")
                    {
                        MoveThis = RootBoard;
                    }                                                              // make sure to check for circuitboard in case of mounts
                }
                BoardPlacer.NewBoardBeingPlaced(MoveThis);

                GameplayUIManager.UIState = UIState.BoardBeingPlaced;
                return;
            }
        }

        SoundPlayer.PlaySoundGlobal(References.Sounds.FailDoSomething);
        GameplayUIManager.UIState = UIState.None;
    }
    public static void CloneBoard()
    {
        RaycastHit hit;

        if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask))
        {
            if (hit.collider.tag == "CircuitBoard")
            {
                GameObject CloneThis = hit.collider.gameObject;
                if (Input.GetButton("Mod"))
                {
                    GameObject RootBoard = hit.collider.transform.root.gameObject;
                    if (RootBoard.tag == "CircuitBoard")
                    {
                        CloneThis = RootBoard;
                    }
                }

                GameObject newboard = Object.Instantiate(CloneThis, new Vector3(0, -2000, 0), Quaternion.identity); // instantiated so far away so that nothing can interfere with connection.findpoints's raycasts
                RecalculateClustersOfBoard(newboard);
                BoardPlacer.NewBoardBeingPlaced(newboard);

                GameplayUIManager.UIState = UIState.BoardBeingPlaced;
                return;
            }
        }

        SoundPlayer.PlaySoundGlobal(References.Sounds.FailDoSomething);
        GameplayUIManager.UIState = UIState.None;
    }
    public static void CreateNewBoard(int x, int z)
    {
        GameObject NewBoard = Object.Instantiate(References.Prefabs.CircuitBoard, BoardPlacer.ReferenceObject.transform);

        // set the board's dimensions
        CircuitBoard board = NewBoard.GetComponent <CircuitBoard>();

        board.x = x;
        board.z = z;
        board.CreateCuboid();

        BoardPlacer.NewBoardBeingPlaced(NewBoard);
    }
    public static void RestoreMostRecentlyDeletedBoard()
    {
        string[] BoardBackups = Directory.GetFiles(Application.persistentDataPath + "/backups/_____deletedboards");
        System.Array.Sort(BoardBackups);

        SavedObjectV2 save        = (SavedObjectV2)FileUtilities.LoadFromFile(BoardBackups[BoardBackups.Length - 1]);
        GameObject    LoadedBoard = SavedObjectUtilities.LoadSavedObject(save);

        LoadedBoard.transform.position = new Vector3(0, -2000, 0);
        RecalculateClustersOfBoard(LoadedBoard);

        BoardPlacer.NewBoardBeingPlaced(LoadedBoard);
        GameplayUIManager.UIState = UIState.BoardBeingPlaced;
    }
    public void Load()
    {
        if (SelectedBoard == null)
        {
            return;
        }

        SavedObjectV2 save        = (SavedObjectV2)FileUtilities.LoadFromFile(SelectedBoard.FilePath);
        GameObject    LoadedBoard = SavedObjectUtilities.LoadSavedObject(save);

        HideAll();

        LoadedBoard.transform.position = new Vector3(0, -2000, 0);
        BoardFunctions.RecalculateClustersOfBoard(LoadedBoard);

        BoardPlacer.NewBoardBeingPlaced(LoadedBoard);
        GameplayUIManager.UIState = UIState.BoardBeingPlaced;
    }