Orrexon

bt1::Status bt1::ActionFindPathAndGo<Subject>::update()

Apr 6th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. template<class Subject>
  2. bt1::Status bt1::ActionFindPathAndGo<Subject>::update()
  3. {
  4.     if (BB->GetGameWorldTankSearching())
  5.     {
  6.         return bt1::BH_RUNNING;
  7.     }
  8.  
  9.     sf::Vector2f goal = BB->GetGameWorldTilePosition(BB->GetGoalPosition());
  10.     sf::Vector2f start = BB->GetGameWorldTilePosition(BB->GetGameWorldTankPosition());
  11.     bool succeed = BB->GameWorldPathObjectFindPath(start, goal);
  12.     if (succeed == true)
  13.     {
  14.         std::cout << "Agent: " << BB->GetGameWorldTankID() << " Reporting to have found a path" << std::endl;
  15.         BB->SetGameWorldTankSearching(true);
  16.         for (int i = BB->GameWorldPathObjectPathListSize() - 1; i > -1; i--)
  17.         {
  18.             sf::Vector2f position = BB->GetGameWorldPathObjectPathListIndexPosition(i);
  19.             BB->GameWorldTankPathAttach(position);
  20.         }
  21.         return bt1::BH_SUCCESS;
  22.     }
  23.     return bt1::BH_FAILURE;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment