// Determine what to with the given cell in terms of adding it to the open list private void ProcessCell(GridCell currentSquare, GridCell cell, SimplePriorityQueue <GridCell> openList, List <GridCell> closedList) { if (cell != null) { if (cell.walkable && !closedList.Contains(cell)) { if (!openList.Contains(cell)) { cell.g = currentSquare.g + 1; cell.f = cell.g + cell.CalculateH(destRow, destCol); openList.Enqueue(cell, cell.f); } else { // If this path would be shorter if (cell.g > (currentSquare.g + 1)) { cell.g = currentSquare.g + 1; cell.f = cell.g + cell.CalculateH(destRow, destCol); openList.UpdatePriority(cell, cell.f); } } } } }