void FindCorners()
    {
        foreach (GridPoint gp in Grid)
        {
            Vector3 dir = gp.Dir;
            if (dir == Vector3.zero)
            {
                continue;
            }

            if (gp.IsHalf())
            {
                dir *= .5f;
            }

            GridPoint g = gp.GetNeighbor(dir, Grid);
            if (g != null)
            {
                if (g.Dir != gp.Dir && g.Dir != gp.Dir * -1f && g.IsPointValid())
                {
                    g.IsCorner = true;
                }
            }
        }
    }
    void RecheckRoofCorners()
    {
        List <GridPoint> newPoints = new List <GridPoint>();

        List <GridPoint> newFullRoofPoints = new List <GridPoint>();
        List <GridPoint> newHalfRoofPoints = new List <GridPoint>();
        List <GridPoint> newSkipRoofPoints = new List <GridPoint>();

        foreach (GridPoint gp in Grid)
        {
            if (!gp.IsPointValid())
            {
                continue;
            }
            if (gp.IsRoofType())
            {
                continue;
            }

            GridPoint NeighboorPoint = gp.GetNeighbor(gp.Dir, Grid, true);
            if (NeighboorPoint != null)
            {
                if (NeighboorPoint.IsRoofType())
                {
                    GridPoint newGP = new GridPoint(PointType.Wall, gp.Location);
                    newPoints.Add(newGP);

                    if (gp.IsHalf())
                    {
                        newHalfRoofPoints.Add(gp);
                    }
                    else
                    {
                        newFullRoofPoints.Add(gp);
                        GridPoint HalfNeighboor = gp.GetNeighbor(gp.Dir * 0.5f, Grid, false);
                        if (HalfNeighboor != null)
                        {
                            newSkipRoofPoints.Add(HalfNeighboor);
                        }
                    }

                    for (int i = 0; i < DirectionArray.Length; i++)
                    {
                        GridPoint g = newGP.GetNeighbor(DirectionArray[i], Grid, false);
                        if (g != null)
                        {
                            if (g.IsPointValid() && !g.IsRoofType())
                            {
                                if (DirectionArray[i] * -1f != g.Dir)
                                {
                                    newGP.Dir      = DirectionArray[i];
                                    newGP.IsCorner = true;
                                    g.IsCorner     = true;

                                    GridPoint newEmptyRoofPoint = new GridPoint(PointType.None_SkipRoof, g.Location);
                                    newPoints.Add(newEmptyRoofPoint);
                                }
                            }
                        }
                    }
                }
            }
        }

        foreach (GridPoint gp in newFullRoofPoints)
        {
            gp.Type = PointType.Roof;
        }

        foreach (GridPoint gp in newHalfRoofPoints)
        {
            gp.Type = PointType.HalfRoof;
        }

        foreach (GridPoint gp in newSkipRoofPoints)
        {
            gp.Type = PointType.None_SkipRoof;
        }

        foreach (GridPoint gp in newPoints)
        {
            Grid.Add(gp);
        }
    }
    void SortGridPointsPrElevation()
    {
        //Finds starting grid point
        GridPoint CurrentGridPoint = FindCornerPoint(Grid, true);

        GridPoint NextGridPoint = CurrentGridPoint;

        List <GridPoint> SelectedElevation = FindAllPointsOfSameElevation(CurrentGridPoint, Grid);
        List <GridPoint> RunThrughList     = CloneList(SelectedElevation);

        bool IsBreaking = false;

        while (RunThrughList.Count > 0)
        {
            IsBreaking = false;
            if (CurrentGridPoint.Type == PointType.Filler)
            {
                Debug.LogWarning("FIlle is chosen"); break;
            }

            //Looks thrugh Unsorted to find neighbor
            if (!CurrentGridPoint.IsPointPlaceable())
            {
                for (int i = 0; i < DirectionArray.Length; i++)
                {
                    GridPoint FullNeighbor = CurrentGridPoint.GetNeighbor(DirectionArray[i], SelectedElevation);
                    GridPoint HalfNeighbor = CurrentGridPoint.GetNeighbor(DirectionArray[i] * 0.5f, SelectedElevation);
                    if (FullNeighbor != null && FullNeighbor.IsPointValid() && FullNeighbor.Type == PointType.Unsorted)
                    {
                        if (HalfNeighbor != null && HalfNeighbor.Type != PointType.Filler)
                        {
                            if (CurrentGridPoint.GetNeighbor(new Vector3(0, 1f, 0), Grid) != null)
                            {
                                CurrentGridPoint.Type = PointType.Wall;
                                HalfNeighbor.Type     = PointType.None_SkipWall;
                            }
                            else
                            {
                                CurrentGridPoint.Type = PointType.Roof;
                                HalfNeighbor.Type     = PointType.None_SkipRoof;
                            }

                            RunThrughList.Remove(HalfNeighbor);

                            CurrentGridPoint.Dir = DirectionArray[i];
                            NextGridPoint        = FullNeighbor;
                            IsBreaking           = true;
                            break;
                        }
                    }
                }

                //checks thrugh fulls to find neighthbor
                for (int i = 0; i < DirectionArray.Length; i++)
                {
                    if (IsBreaking)
                    {
                        break;
                    }

                    GridPoint FullNeighbor = CurrentGridPoint.GetNeighbor(DirectionArray[i], SelectedElevation);
                    GridPoint HalfNeighbor = CurrentGridPoint.GetNeighbor(DirectionArray[i] * 0.5f, SelectedElevation);
                    if (FullNeighbor != null && FullNeighbor.IsPointValid())
                    {
                        if (HalfNeighbor != null && HalfNeighbor.Type != PointType.Filler && FullNeighbor.Dir * -1 != DirectionArray[i])
                        {
                            if (CurrentGridPoint.GetNeighbor(new Vector3(0, 1f, 0), Grid) != null)
                            {
                                CurrentGridPoint.Type = PointType.Wall;
                                HalfNeighbor.Type     = PointType.None_SkipWall;
                            }
                            else
                            {
                                CurrentGridPoint.Type = PointType.Roof;
                                HalfNeighbor.Type     = PointType.None_SkipRoof;
                            }

                            RunThrughList.Remove(HalfNeighbor);

                            CurrentGridPoint.Dir = DirectionArray[i];
                            NextGridPoint        = FullNeighbor;
                            IsBreaking           = true;
                            break;
                        }
                    }
                }

                //looks thrugh halfs to find neighbor
                for (int i = 0; i < DirectionArray.Length; i++)
                {
                    if (IsBreaking)
                    {
                        break;
                    }

                    GridPoint HalfNeighbor = CurrentGridPoint.GetNeighbor(DirectionArray[i] * 0.5f, SelectedElevation);
                    if (HalfNeighbor != null && HalfNeighbor.IsPointValid() && HalfNeighbor.Dir * -1 != DirectionArray[i])
                    {
                        if (CurrentGridPoint.GetNeighbor(new Vector3(0, 1f, 0), Grid) != null)
                        {
                            CurrentGridPoint.Type = PointType.HalfWall;
                        }
                        else
                        {
                            CurrentGridPoint.Type = PointType.HalfRoof;
                        }

                        CurrentGridPoint.Dir = DirectionArray[i];
                        NextGridPoint        = HalfNeighbor;
                        break;
                    }
                }
            }

            RunThrughList.Remove(CurrentGridPoint);
            if (NextGridPoint != null)
            {
                if (NextGridPoint.Type == PointType.Unsorted)
                {
                    CurrentGridPoint = NextGridPoint;
                    continue;
                }
            }
            if (RunThrughList.Count != 0)
            {
                CurrentGridPoint = FindCornerPoint(RunThrughList, true);
            }
        }
    }