public static bool isAtEndPoint(PathNode currentNode, Point endPoint, GameLocation location, Character c) { return(currentNode.x == endPoint.X && currentNode.y == endPoint.Y); }
// Token: 0x060002F6 RID: 758 RVA: 0x0003C542 File Offset: 0x0003A742 public bool Contains(PathNode p, int priority) { return(this.nodes.ContainsKey(priority) && this.nodes[priority].Contains(p)); }
public static Stack <Point> findPathForNPCSchedules(Point startPoint, Point endPoint, GameLocation location, int limit) { sbyte[,] array = new sbyte[, ] { { -1, 0 }, { 1, 0 }, { 0, 1 }, { 0, -1 } }; PriorityQueue priorityQueue = new PriorityQueue(); Dictionary <PathNode, PathNode> dictionary = new Dictionary <PathNode, PathNode>(); int num = 0; priorityQueue.Enqueue(new PathNode(startPoint.X, startPoint.Y, 0, null), Math.Abs(endPoint.X - startPoint.X) + Math.Abs(endPoint.Y - startPoint.Y)); PathNode pathNode = (PathNode)priorityQueue.Peek(); while (!priorityQueue.IsEmpty()) { PathNode pathNode2 = priorityQueue.Dequeue(); if (pathNode2.x == endPoint.X && pathNode2.y == endPoint.Y) { return(PathFindController.reconstructPath(pathNode2, dictionary)); } if (pathNode2.x == 79) { int arg_B2_0 = pathNode2.y; } if (!dictionary.ContainsKey(pathNode2)) { dictionary.Add(pathNode2, pathNode2.parent); } for (int i = 0; i < 4; i++) { PathNode pathNode3 = new PathNode(pathNode2.x + (int)array[i, 0], pathNode2.y + (int)array[i, 1], pathNode2); pathNode3.g = pathNode2.g + 1; if (!dictionary.ContainsKey(pathNode3) && ((pathNode3.x == endPoint.X && pathNode3.y == endPoint.Y) || (pathNode3.x >= 0 && pathNode3.y >= 0 && pathNode3.x < location.map.Layers[0].LayerWidth && pathNode3.y < location.map.Layers[0].LayerHeight && !PathFindController.isPositionImpassableForNPCSchedule(location, pathNode3.x, pathNode3.y)))) { int priority = (int)pathNode3.g + PathFindController.getPreferenceValueForTerrainType(location, pathNode3.x, pathNode3.y) + (Math.Abs(endPoint.X - pathNode3.x) + Math.Abs(endPoint.Y - pathNode3.y) + (((pathNode3.x == pathNode2.x && pathNode3.x == pathNode.x) || (pathNode3.y == pathNode2.y && pathNode3.y == pathNode.y)) ? -2 : 0)); if (!priorityQueue.Contains(pathNode3, priority)) { priorityQueue.Enqueue(pathNode3, priority); } } } pathNode = pathNode2; num++; if (num >= limit) { return(null); } } return(null); }