home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 03 Pathfinding with Astar / 03 Higgins / Listing1.cpp next >
Encoding:
Text File  |  2001-12-09  |  1.0 KB  |  37 lines

  1. /* Copyright (C) Dan Higgins, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Dan Higgins, 2001"
  9.  */
  10.  
  11. PathManager::DoPriorityPath(Unit* inUnit)
  12. {
  13.     // find the pathfinder for this unit.
  14.     Pathfinder* thePath = this->FindPathfinder(inUnit);
  15.  
  16.     // If we have a node, finish the path right away!
  17.     if(thePath != NULL)
  18.     {
  19.         // Tell it not to pause.
  20.         thePath->SetPauseCount(-1);
  21.  
  22.         // let's artificially cap the path so that they 
  23.         // don't bring down the CPU.
  24.         thePath->AddToMaxRevolutions (250);
  25.                                     
  26.         // go-pher-it..
  27.         thePath->RunAStar();    
  28.  
  29.         // Process the completed path.
  30.         this->ProcessFinishedPath(thePath);
  31.  
  32.         // Remove this unit's path 
  33.         // which includes erasing it from our queue
  34.         this->RemovePath(inUnit);
  35.     }
  36. }
  37.