Example #1
0
        /** Completes the path using the specified target node.
         * This method assumes that the node is a target node of the path
         * not just any random node.
         */
        void CompleteWith(GraphNode node)
        {
#if !ASTAR_NO_GRID_GRAPH
            if (endNode == node)
            {
                // Common case, no grid graph special case has been applied
                // Nothing to do
            }
            else
            {
                // See EndPointGridGraphSpecialCase()
                var gridNode = node as GridNode;
                if (gridNode == null)
                {
                    throw new System.Exception("Some path is not cleaning up the flag1 field. This is a bug.");
                }

                // The grid graph special case has been applied
                // The closest point on the node is not yet known
                // so we need to calculate it
                endPoint = gridNode.ClosestPointOnNode(originalEndPoint);
                // This is now our end node
                // We didn't know it before, but apparently it was optimal
                // to move to this node
                endNode = node;
            }
#else
            // This should always be true unless
            // the grid graph special case has been applied
            // which can only happen if grid graphs have not
            // been stripped out with ASTAR_NO_GRID_GRAPH
            node.MustBeEqual(endNode);
#endif
            // Mark the path as completed
            CompleteState = PathCompleteState.Complete;
        }
		/** Completes the path using the specified target node.
		 * This method assumes that the node is a target node of the path
		 * not just any random node.
		 */
		void CompleteWith (GraphNode node) {
#if !ASTAR_NO_GRID_GRAPH
			if (endNode == node) {
				// Common case, no grid graph special case has been applied
				// Nothing to do
			} else {
				// See EndPointGridGraphSpecialCase()
				var gridNode = node as GridNode;
				if (gridNode == null) {
					throw new System.Exception("Some path is not cleaning up the flag1 field. This is a bug.");
				}

				// The grid graph special case has been applied
				// The closest point on the node is not yet known
				// so we need to calculate it
				endPoint = gridNode.ClosestPointOnNode(originalEndPoint);
				// This is now our end node
				// We didn't know it before, but apparently it was optimal
				// to move to this node
				endNode = node;
			}
#else
			// This should always be true unless
			// the grid graph special case has been applied
			// which can only happen if grid graphs have not
			// been stripped out with ASTAR_NO_GRID_GRAPH
			node.MustBeEqual(endNode);
#endif
			// Mark the path as completed
			CompleteState = PathCompleteState.Complete;
		}