public virtual Dictionary <FloorNode, List <FloorNode> > cachePaths(List <FloorNode> cells, FloorNode aNodeHeuristicIsBasedOn, DelegateReturnNodeIndex delegateReturnNodeIndex) { var edges = GetGraphEdges(cells, delegateReturnNodeIndex); var paths = _Pathfinder.findAllPaths(edges, aNodeHeuristicIsBasedOn, m_Movement); return(paths); }
protected virtual Dictionary <FloorNode, Dictionary <FloorNode, int> > GetGraphEdges(List <FloorNode> NodeList, DelegateReturnNodeIndex delegateReturnNodeIndex) { Dictionary <FloorNode, Dictionary <FloorNode, int> > ret = new Dictionary <FloorNode, Dictionary <FloorNode, int> >(); foreach (FloorNode Node in NodeList) { if (delegateReturnNodeIndex(Node, m_Position) == true || Node.Equals(Node_ObjectIsOn)) { ret[Node] = new Dictionary <FloorNode, int>(); foreach (FloorNode neighbour in Node.GetNeighbours(NodeList)) { if (delegateReturnNodeIndex(neighbour, m_Position) == true) { ret[Node][neighbour] = neighbour.m_MovementCost; } } } } return(ret); }
public HashSet <FloorNode> GetNodesInRange(List <FloorNode> aCells, FloorNode aNodeHeuristicIsBasedOff, int aRange, DelegateReturnNodeIndex delegateReturnNodeIndex) { cachedPaths = new Dictionary <FloorNode, List <FloorNode> >(); var paths = cachePaths(aCells, aNodeHeuristicIsBasedOff, delegateReturnNodeIndex); foreach (var key in paths.Keys) { var path = paths[key]; var pathCost = path.Sum(c => 1); key.m_Heuristic = pathCost; if (pathCost <= aRange) { cachedPaths.Add(key, path); } } return(new HashSet <FloorNode>(cachedPaths.Keys)); }