Exemple #1
0
        public static void Connect(this IConnectedGridElement3D element, IConnectedGridElement3D other, Direction direction)
        {
            if (element == null || other == null)
            {
                throw new ArgumentException("null values not allowed.");
            }
            switch (direction)
            {
            case Direction.Left:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourLeft = other;
                other.NeighbourRight  = element;
                break;

            case Direction.Right:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourRight = other;
                other.NeighbourLeft    = element;
                break;

            case Direction.Back:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourBack = other;
                other.NeighbourFront  = element;
                break;

            case Direction.Front:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourFront = other;
                other.NeighbourBack    = element;
                break;

            case Direction.Down:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourDown = other;
                other.NeighbourUp     = element;
                break;

            case Direction.Up:
                element.Disconnect(direction);
                other.Disconnect(direction.OppositeDirection());
                element.NeighbourUp = other;
                other.NeighbourDown = element;
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public static void Disconnect(this IConnectedGridElement3D element, Direction direction)
        {
            var other = element.Neighbour(direction);

            if (other == null)
            {
                return;
            }

            switch (direction)
            {
            case Direction.Left:
                other.NeighbourRight  = null;
                element.NeighbourLeft = null;
                break;

            case Direction.Right:
                other.NeighbourLeft    = null;
                element.NeighbourRight = null;
                break;

            case Direction.Back:
                other.NeighbourFront  = null;
                element.NeighbourBack = null;
                break;

            case Direction.Front:
                other.NeighbourFront  = null;
                element.NeighbourBack = null;
                break;

            case Direction.Down:
                other.NeighbourUp     = null;
                element.NeighbourDown = null;
                break;

            case Direction.Up:
                other.NeighbourDown = null;
                element.NeighbourUp = null;
                break;

            default:
                break;
            }
        }