private void AddNodeCapsuleToOpenList(SortedDictionary<int, SortedDictionary<int, AStarNodeCapsule>> list, AStarNodeCapsule capsule) { int distanceToEnd = capsule.Priority; if (!list.ContainsKey(distanceToEnd)) { list[distanceToEnd] = new SortedDictionary<int, AStarNodeCapsule>(); } list[distanceToEnd][capsule.Node.ID] = capsule; }
private void AddNodeCapsuleToClosedList(SortedDictionary<int, SortedDictionary<int, AStarNodeCapsule>> list, AStarNodeCapsule capsule) { if (capsule.ShortestDistance != null) { int distance = (int)capsule.ShortestDistance; if (!list.ContainsKey(distance)) { list[distance] = new SortedDictionary<int, AStarNodeCapsule>(); } list[distance][capsule.Node.ID] = capsule; } }
private void RemoveNodeCapsuleFromOpenList(SortedDictionary<int, SortedDictionary<int, AStarNodeCapsule>> list, AStarNodeCapsule capsule) { list[(int)capsule.Priority].Remove(capsule.Node.ID); if (list[(int)capsule.Priority].Count == 0) { list.Remove(capsule.Priority); } }
private void UpdateCurrentRouteWithEndCapsuleData(AStarNodeCapsule endCapsule) { currentRouteEdges.Clear(); currentRouteNodes.Clear(); AStarNodeCapsule currentCapsule = endCapsule; while (currentCapsule.PreviousRouteNode != null) { currentRouteEdges.AddFirst(currentCapsule.PreviousRouteEdge); currentRouteNodes.AddFirst(currentCapsule.Node); currentCapsule = currentCapsule.PreviousRouteNode; } }
/*Convenience*/ private AStarNodeCapsule GetAdjacent(Dictionary<int, AStarNodeCapsule> capsuleMap, AStarNodeCapsule capsule, Edge edge) { if (edge.Node1 == capsule.Node) { return capsuleMap[edge.Node2.ID]; } else { return capsuleMap[edge.Node1.ID]; } }