Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class Subject>
- bt1::Status bt1::ActionFindPathAndGo<Subject>::update()
- {
- if (BB->GetGameWorldTankSearching())
- {
- return bt1::BH_RUNNING;
- }
- sf::Vector2f goal = BB->GetGameWorldTilePosition(BB->GetGoalPosition());
- sf::Vector2f start = BB->GetGameWorldTilePosition(BB->GetGameWorldTankPosition());
- bool succeed = BB->GameWorldPathObjectFindPath(start, goal);
- if (succeed == true)
- {
- std::cout << "Agent: " << BB->GetGameWorldTankID() << " Reporting to have found a path" << std::endl;
- BB->SetGameWorldTankSearching(true);
- //MIND THE GetCurrentTankDistanceUnits! This is a new function in BlackBoard, it returns the distance int through gameworld::tankIter.
- //The definition is pasted below.
- //this loop traverses the path list generated by the AStarPath object from back to front, stopping prematurely.
- //in this particular case GetCurrentTankDistanceUnits() returns the number two.
- for (int i = (BB->GameWorldPathObjectPathListSize() - 1 ); i > BB->GetCurrentTankDistanceUnits(); i--)
- {
- sf::Vector2f position = BB->GetGameWorldPathObjectPathListIndexPosition(i);
- BB->GameWorldTankPathAttach(position);
- }
- return bt1::BH_SUCCESS;
- }
- return bt1::BH_FAILURE;
- }
- template<class Subject>
- int BlackBoard<Subject>::GetCurrentTankDistanceUnits()
- {
- return (*gameWorld->tankIter)->distanceUnits;
- }
- //distanceUnits is an int declared in the base class Agent, from which class Tank inherits.
Advertisement
Add Comment
Please, Sign In to add comment