@Override
 public boolean handleMessage(Telegram telegram) {
   switch (telegram.message) {
     case PF_RESPONSE: // PathFinderQueue will call us directly, no need to register for this
       // message
       if (PathFinderRequestControl.DEBUG) {
         @SuppressWarnings("unchecked")
         PathFinderQueue<HierarchicalTiledNode> pfQueue =
             (PathFinderQueue<HierarchicalTiledNode>) telegram.sender;
         System.out.println("pfQueue.size = " + pfQueue.size());
       }
       MyPathFinderRequest pfr = (MyPathFinderRequest) telegram.extraInfo;
       TiledSmoothableGraphPath<HierarchicalTiledNode> path = paths[pfr.pathIndex];
       int n = path.getCount();
       if (n > 0 && pfr.pathFound && pfr.endNode != path.get(n - 1)) {
         pfr.startNode = path.get(n - 1);
         if (pfr.pathIndex + 1 < paths.length) {
           pfr.pathIndex++;
         }
         pfr.resultPath = paths[pfr.pathIndex];
         pfr.changeStatus(PathFinderRequest.SEARCH_NEW);
         numPaths = pfr.pathIndex;
       } else {
         requestPool.free(pfr);
         numPaths = pfr.pathIndex + 1;
       }
       break;
   }
   return true;
 }
  private void requestNewPathFinding(
      HierarchicalTiledNode startNode, HierarchicalTiledNode endNode, int pathIndex) {
    TiledSmoothableGraphPath<HierarchicalTiledNode> path = paths[pathIndex];

    MyPathFinderRequest pfRequest = requestPool.obtain();
    pfRequest.startNode = startNode;
    pfRequest.endNode = endNode;
    pfRequest.heuristic = heuristic;
    pfRequest.resultPath = path;
    pfRequest.pathIndex = pathIndex;
    pfRequest.responseMessageCode = PF_RESPONSE;
    MessageManager.getInstance().dispatchMessage(this, PF_REQUEST, pfRequest);
  }