public void GetExitVectorCover(out Vector2Int1Float position, out int coverType)
 {
     coverType = 0;
     coverType = Math.Max(coverType, volume.coverType[mainX][mainZ]);
     coverType = Math.Max(coverType, volume.coverType[mainX + 1][mainZ]);
     coverType = Math.Max(coverType, volume.coverType[mainX][mainZ + 1]);
     coverType = Math.Max(coverType, volume.coverType[mainX + 1][mainZ + 1]);
     position  = GetExitVector();
 }
        public void GetExitVector(out Vector2Int1Float position, ref HashSet <VolumeArea> areaOutput)
        {
            //  Z
            //0 T 0
            //L   R  X
            //1 B 0
            //int count = 0;
            //float y = 0;

            if (volume.GetState(mainX, mainZ, VoxelState.InterconnectionArea))
            {
                foreach (var a in volume.volumeArea[new VolumePosSmall(mainX, mainZ)])
                {
                    areaOutput.Add(a);
                }
            }
            if (volume.GetState(mainX + 1, mainZ, VoxelState.InterconnectionArea))
            {
                foreach (var a in volume.volumeArea[new VolumePosSmall(mainX + 1, mainZ)])
                {
                    areaOutput.Add(a);
                }
            }
            if (volume.GetState(mainX, mainZ + 1, VoxelState.InterconnectionArea))
            {
                foreach (var a in volume.volumeArea[new VolumePosSmall(mainX, mainZ + 1)])
                {
                    areaOutput.Add(a);
                }
            }
            if (volume.GetState(mainX + 1, mainZ + 1, VoxelState.InterconnectionArea))
            {
                foreach (var a in volume.volumeArea[new VolumePosSmall(mainX + 1, mainZ + 1)])
                {
                    areaOutput.Add(a);
                }
            }
            position = GetExitVector();

            ////get values are just for counting how much samples we take to calculate height
            //switch (exitDirection) {
            //    case SquareEdge.Left:
            //    if (GetValues(mainX, mainZ, ref y))
            //        count++;
            //    if (GetValues(mainX, mainZ + 1, ref y))
            //        count++;
            //    position = new Vector2Int1Float(mainX * 2, count > 0 ? (y / count) : 0, (mainZ * 2) + 1);
            //    break;

            //    case SquareEdge.Right:
            //    if (GetValues(mainX + 1, mainZ, ref y))
            //        count++;
            //    if (GetValues(mainX + 1, mainZ + 1, ref y))
            //        count++;
            //    position = new Vector2Int1Float((mainX + 1) * 2, count > 0 ? (y / count) : 0, (mainZ * 2) + 1);
            //    break;

            //    case SquareEdge.Bottom:
            //    if (GetValues(mainX, mainZ, ref y))
            //        count++;
            //    if (GetValues(mainX + 1, mainZ, ref y))
            //        count++;
            //    position = new Vector2Int1Float((mainX * 2) + 1, count > 0 ? (y / count) : 0, mainZ * 2);
            //    break;

            //    case SquareEdge.Top:
            //    if (GetValues(mainX, mainZ + 1, ref y))
            //        count++;
            //    if (GetValues(mainX + 1, mainZ + 1, ref y))
            //        count++;
            //    position = new Vector2Int1Float((mainX * 2) + 1, count > 0 ? (y / count) : 0, (mainZ + 1) * 2);
            //    break;

            //    default:
            //    position = Vector2Int1Float.zero;
            //    break;
            //}
            //position = new Vector2Int1Float(position.x + 1, position.y, position.z + 1);
        }
        private Vector2Int1Float GetExitVector()
        {
            //  Z
            //0 T 0
            //L   R  X
            //1 B 0
            int              count = 0;
            float            y     = 0;
            Vector2Int1Float position;

            //get values are just for counting how much samples we take to calculate height
            switch (exitDirection)
            {
            case SquareEdge.Left:
                if (GetValues(mainX, mainZ, ref y))
                {
                    count++;
                }
                if (GetValues(mainX, mainZ + 1, ref y))
                {
                    count++;
                }
                position = new Vector2Int1Float(mainX * 2, count > 0 ? (y / count) : 0, (mainZ * 2) + 1);
                break;

            case SquareEdge.Right:
                if (GetValues(mainX + 1, mainZ, ref y))
                {
                    count++;
                }
                if (GetValues(mainX + 1, mainZ + 1, ref y))
                {
                    count++;
                }
                position = new Vector2Int1Float((mainX + 1) * 2, count > 0 ? (y / count) : 0, (mainZ * 2) + 1);
                break;

            case SquareEdge.Bottom:
                if (GetValues(mainX, mainZ, ref y))
                {
                    count++;
                }
                if (GetValues(mainX + 1, mainZ, ref y))
                {
                    count++;
                }
                position = new Vector2Int1Float((mainX * 2) + 1, count > 0 ? (y / count) : 0, mainZ * 2);
                break;

            case SquareEdge.Top:
                if (GetValues(mainX, mainZ + 1, ref y))
                {
                    count++;
                }
                if (GetValues(mainX + 1, mainZ + 1, ref y))
                {
                    count++;
                }
                position = new Vector2Int1Float((mainX * 2) + 1, count > 0 ? (y / count) : 0, (mainZ + 1) * 2);
                break;

            default:
                position = Vector2Int1Float.zero;
                break;
            }
            position = new Vector2Int1Float(position.x + 1, position.y, position.z + 1);
            return(position);
        }