private static bool reformatHeightMap(WorldSegmentPlanner w)
        {
            bool somethingChanged = false;

            for (int y = 0; y < WorldSegmentPlanner.WorldSegmentBlockSize.Y; y++)
            {
                for (int x = 0; x < WorldSegmentPlanner.WorldSegmentBlockSize.X; x++)
                {
                    if (w.Blocks[x, y] == null)
                    {
                        continue;
                    }

                    var currentHeight = w.Blocks[x, y].ElevationHeight;

                    if (currentHeight == 0)
                    {
                        continue;
                    }

                    var neighbors = w.GetNeighbors(x, y);
                }
            }

            if (somethingChanged)
            {
                reformatHeightMap(w);

                return(true);
            }

            return(false);
        }
        private static bool flattenHeightMap(WorldSegmentPlanner w)
        {
            bool changedHeight = false;

            for (int y = WorldSegmentPlanner.WorldSegmentBlockSize.Y - 1; y >= 0; y--)
            {
                for (int x = WorldSegmentPlanner.WorldSegmentBlockSize.X - 1; x >= 0; x--)
                {
                    if (w.Blocks[x, y] == null)
                    {
                        continue;
                    }

                    var currentHeight = w.Blocks[x, y].ElevationHeight;

                    if (currentHeight == 0)
                    {
                        continue;
                    }

                    var neighbors = w.GetNeighbors(x, y);
                }
            }

            if (changedHeight == true)
            {
                flattenHeightMap(w);

                return(true);
            }

            return(false);
        }
        private static bool finalizeHeightMap(WorldSegmentPlanner w)
        {
            bool changedBlock = false;

            for (int y = WorldSegmentPlanner.WorldSegmentBlockSize.Y - 1; y >= 0; y--)
            {
                for (int x = WorldSegmentPlanner.WorldSegmentBlockSize.X - 1; x >= 0; x--)
                {
                    if (w.Blocks[x, y] == null)
                    {
                        continue;
                    }

                    var currentHeight = w.Blocks[x, y].ElevationHeight;

                    if (currentHeight == 0)
                    {
                        continue;
                    }

                    var neighbors = w.GetNeighbors(x, y);

                    // 0 0 0
                    // 1 1 1
                    // 0 1 0
                    if (neighbors[1].ElevationHeight == currentHeight &&
                        neighbors[4].ElevationHeight == currentHeight &&
                        neighbors[6].ElevationHeight == currentHeight &&
                        neighbors[3].ElevationHeight < currentHeight &&
                        neighbors[2].ElevationHeight < currentHeight)
                    {
                        neighbors[2].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight < currentHeight &&
                             neighbors[7].ElevationHeight < currentHeight)
                    {
                        neighbors[7].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    // 0 1 0
                    // 1 1 0
                    // 0 1 0
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight < currentHeight &&
                             neighbors[0].ElevationHeight < currentHeight)
                    {
                        neighbors[0].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight < currentHeight &&
                             neighbors[2].ElevationHeight < currentHeight)
                    {
                        neighbors[2].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    // 0 1 0
                    // 0 1 1
                    // 0 1 0
                    else if (neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[1].ElevationHeight < currentHeight &&
                             neighbors[5].ElevationHeight < currentHeight)
                    {
                        neighbors[5].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    else if (neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[1].ElevationHeight < currentHeight &&
                             neighbors[7].ElevationHeight < currentHeight)
                    {
                        neighbors[7].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    // 0 1 0
                    // 1 1 1
                    // 0 0 0
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight < currentHeight &&
                             neighbors[0].ElevationHeight < currentHeight)
                    {
                        neighbors[0].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight < currentHeight &&
                             neighbors[5].ElevationHeight < currentHeight)
                    {
                        neighbors[5].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    // 0 1 1
                    // 1 1 1
                    // 1 1 0
                    else if (neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[2].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[5].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[0].ElevationHeight < currentHeight &&
                             neighbors[7].ElevationHeight < currentHeight)
                    {
                        neighbors[0].ElevationHeight = currentHeight;
                        neighbors[7].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                    // 1 1 0
                    // 1 1 1
                    // 0 1 1
                    else if (neighbors[0].ElevationHeight == currentHeight &&
                             neighbors[1].ElevationHeight == currentHeight &&
                             neighbors[3].ElevationHeight == currentHeight &&
                             neighbors[4].ElevationHeight == currentHeight &&
                             neighbors[6].ElevationHeight == currentHeight &&
                             neighbors[7].ElevationHeight == currentHeight &&
                             neighbors[2].ElevationHeight < currentHeight &&
                             neighbors[5].ElevationHeight < currentHeight)
                    {
                        neighbors[2].ElevationHeight = currentHeight;
                        neighbors[5].ElevationHeight = currentHeight;
                        changedBlock = true;
                    }
                }
            }

            if (changedBlock == true)
            {
                finalizeHeightMap(w);

                return(true);
            }

            return(false);
        }