RUBehaviacTreeFactory.h 722 B

12345678910111213141516171819202122232425262728
  1. /// 代理工厂
  2. #ifndef RUBehaviacTreeFactory_h
  3. #define RUBehaviacTreeFactory_h
  4. #include "RUDefine.h"
  5. #include "RUBehaviacTree.h"
  6. NS_RU_BEGIN
  7. class RUBehaviacTreeFactory
  8. {
  9. public:
  10. static RUBehaviacTreeFactory* getInstance();
  11. /// 向工厂注册一个状态代理类的注册器
  12. void registerBehaviacTreeCreator(const std::string& treeName, std::function<RUBehaviacTree*(void)> behaviacTreeCreator);
  13. RUBehaviacTree* createBehaviacTree(const std::string& treeName);
  14. private:
  15. RUBehaviacTreeFactory() = default;
  16. ~RUBehaviacTreeFactory() = default;
  17. private:
  18. std::map<std::string, std::function<RUBehaviacTree*(void)>> _behaviacTreeCreators;
  19. };
  20. NS_RU_END
  21. #endif /* RUBehaviacTreeFactory_h */