HPASharp.Cluster.ComputePathBetweenEntrances C# (CSharp) Méthode

ComputePathBetweenEntrances() private méthode

private ComputePathBetweenEntrances ( EntrancePoint e1, EntrancePoint e2 ) : void
e1 EntrancePoint
e2 EntrancePoint
Résultat void
        private void ComputePathBetweenEntrances(EntrancePoint e1, EntrancePoint e2)
        {
            var start = GetEntrancePositionIndex(e1);
            var target = GetEntrancePositionIndex(e2);
            var startIdx = e1.EntranceLocalIdx;
            var targetIdx = e2.EntranceLocalIdx;
	        var tuple = Tuple.Create(startIdx, targetIdx);
			var invtuple = Tuple.Create(targetIdx, startIdx);

			// If a path already existed, or both are the same node, just return
			if (this.DistanceCalculated.ContainsKey(tuple) || startIdx == targetIdx)
                return;

            var search = new AStar();
            var path = search.FindPath(SubConcreteMap, start, target);

            // TODO: Store the path as well, not only the cost. This will make everything faster!
	        if (path.PathCost != -1)
	        {
				// Yeah, we are supposing reaching A - B is the same like reaching B - A. Which
				// depending on the game this is NOT necessarily true (e.g climbing, downstepping a mountain)
		        Distances[tuple] = Distances[invtuple] = path.PathCost;
		        CachedPaths[tuple] = CachedPaths[invtuple] = path.PathNodes;
	        }

            this.DistanceCalculated[tuple] = this.DistanceCalculated[invtuple] = true;
        }