LoopWaiter.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // LoopWaiter.hpp
  3. // redream_runtime_mac
  4. //
  5. // Created by zhu on 2023/5/23.
  6. //
  7. #ifndef LoopWaiter_hpp
  8. #define LoopWaiter_hpp
  9. #include "WaitableStateBase.hpp"
  10. #include "behaviac/RedBehaviacTree.h"
  11. namespace redream {
  12. class LoopWaiter : public WaitableStateBase, public red::RedBehaviacTreeDelegate {
  13. public:
  14. static LoopWaiter* create(ReboltRedManager* reboltManager, red::RedBehaviacTree* tree, std::map<std::string, bool> &boolMap, std::map<std::string, std::string> &stringMap, std::string treeName);
  15. LoopWaiter(ReboltRedManager* reboltManager, red::RedBehaviacTree* tree, std::map<std::string, bool> &boolMap, std::map<std::string, std::string> &stringMap, std::string treeName);
  16. ~LoopWaiter();
  17. bool init();
  18. int getLoopTimes();
  19. void onLoopEnd();
  20. public:
  21. virtual void run() override;
  22. void onTreeRunningEnd(red::RedBehaviacTree* tree, int endType, std::string treeName) override;
  23. private:
  24. void createTreeAndRun();
  25. private:
  26. int _loopTimes;
  27. std::string _treeName;
  28. std::map<std::string, bool> _boolMap;
  29. std::map<std::string, std::string> _stringMap;
  30. bool _isLoopEnd;
  31. red::RedBehaviacTree* _tree;
  32. };
  33. };
  34. #endif /* LoopWaiter_hpp */