Pathfinding.MultiTargetPath.Initialize C# (CSharp) Method

Initialize() protected method

protected Initialize ( ) : void
return void
		protected override void Initialize () {
			// Reset the start node to prevent
			// old info from previous paths to be used
			PathNode startRNode = pathHandler.GetPathNode(startNode);

			startRNode.node = startNode;
			startRNode.pathID = pathID;
			startRNode.parent = null;
			startRNode.cost = 0;
			startRNode.G = GetTraversalCost(startNode);
			startRNode.H = CalculateHScore(startNode);

			for (int j = 0; j < targetNodes.Length; j++) {
				if (startNode == targetNodes[j]) {
					// The start node is equal to the target node
					// so we can immediately mark the path as calculated
					FoundTarget(startRNode, j);
				} else if (targetNodes[j] != null) {
					// Mark the node with a flag so that we can quickly check if we have found a target node
					pathHandler.GetPathNode(targetNodes[j]).flag1 = true;
				}
			}

			// If all paths have either been invalidated or found already because they were at the same node as the start node
			if (targetNodeCount <= 0) {
				CompleteState = PathCompleteState.Complete;
				return;
			}

			//if (recalcStartEndCosts) {
			//	startNode.InitialOpen (open,hTarget,startIntPoint,this,true);
			//} else {
			startNode.Open(this, startRNode, pathHandler);
			//}
			searchedNodes++;

			//any nodes left to search?
			if (pathHandler.heap.isEmpty) {
				FailWithError("No open points, the start node didn't open any nodes");
				return;
			}

			// Take the first node off the heap
			currentR = pathHandler.heap.Remove();
		}