home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 04 Pathfinding and Movement / 05 Hancock / Goal.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  1.2 KB  |  51 lines

  1.  
  2. enum typeGoalStatus { statusSucceeded = 0, statusFailed, statusInProgress };
  3.  
  4. class Goal
  5. {
  6. public:
  7.     Goal( AI* pAI );
  8.     virtual ~Goal();
  9.     
  10.     // Update the goal
  11.     virtual void Update( float secs_elapsed ) = 0;
  12.     
  13.     typeGoalStatus GoalStatus() { return mGoalStatus; }
  14.     
  15.     virtual void SetStatus(typeGoalStatus GoalStatus) {mGoalStatus = GoalStatus;}
  16.     
  17.     AI* GetAI() { return mpAI; }
  18.     
  19. protected:
  20.     Goal(AI *pAI) : mpAI(pAI), mGoalStatus(statusInProgress){}
  21.     Goal(){mGoalStatus = statusInProgress;}    //for virtual constructor purposes
  22.     AI*           mpAI;             // The AI we are controlling
  23.     typeGoalStatus mGoalStatus;  // What is are current status (default is statusInProgress)
  24. };
  25.  
  26.  
  27. class GoalQueue
  28. {
  29. public:
  30.     GoalQueue();
  31.     virtual ~GoalQueue();
  32.     
  33.     typeGoalStatus UpdateSubgoals( float secs_elapsed );
  34.     bool NoSubgoals() const { return mGoals.empty(); }
  35.     
  36.     void InsertSubgoal (Goal *pGoal); //adds a goal to the front of the queue
  37.     void NewSubgoal( Goal* pGoal ); //adds a goal to the back of the queue
  38.     
  39.     void ResetSubgoals(); //deletes all current subgoals
  40.     
  41.     virtual bool ReplanSubgoals() { return false; }
  42.     
  43.     Goal*   ActiveGoal() { return mGoals.empty() ? NULL : mGoals.front(); }
  44.     
  45. protected:
  46.     std::list<Goal *> mGoals;
  47. };
  48.  
  49.  
  50.  
  51.