public BaseImplementation( PathfinderCostStrategy costStrategy, PathfinderNodeCreator nodeCreator ) { currentCostStrategy = costStrategy; currentNodeCreator = nodeCreator; }
public static List <PathfinderNode> GetNeighbors( PathfinderNode node, Dictionary <Point, PathfinderNode> activeNodes, PathfinderNodeCreator nodeCreator ) { List <PathfinderNode> neighbors = new List <PathfinderNode>(); List <Point> neighborPoints = instance.grid.GetNeighbors(node.GetGridCoord()); List <Point> unActiveNeighbors = Pools.ListPoints; for (int i = 0; i < neighborPoints.Count; i++) { Point currentPoint = neighborPoints[i]; PathfinderNode currentNode = null; activeNodes.TryGetValue(currentPoint, out currentNode); // current node is already active if (currentNode != null) { neighbors.Add(currentNode); Pools.Point = currentPoint; // current node is not active } else { unActiveNeighbors.Add(currentPoint); currentNode = nodeCreator.CreateNode( currentPoint, instance.grid.GetMapNodeAt(currentPoint) ); activeNodes.Add(currentPoint, currentNode); neighbors.Add(currentNode); } } Pools.ListPoints = neighborPoints; Pools.ListPoints = unActiveNeighbors; return(neighbors); }