NotNode.cc 635 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stddef.h>
  2. #include "BehaviorTree/NotNode.h"
  3. #include "BehaviorTree/BehaviorTreeConf.pb.h"
  4. namespace Egametang {
  5. NotNode::NotNode(int32 type): BehaviorNode(type), node(nullptr)
  6. {
  7. }
  8. NotNode::~NotNode()
  9. {
  10. delete node;
  11. }
  12. bool NotNode::Run(ContexIf* contex)
  13. {
  14. return !node->Run(contex);
  15. }
  16. void NotNode::AddChildNode(BehaviorNode *node)
  17. {
  18. this->node = node;
  19. }
  20. std::string NotNode::ToString()
  21. {
  22. std::string s;
  23. s += "NotNode: \n";
  24. s += " " + node->ToString() + "\n";
  25. return s;
  26. }
  27. BehaviorNode* NotNodeFactory::GetInstance(const BehaviorNodeConf& conf)
  28. {
  29. return new NotNode(conf.type());
  30. }
  31. } // namespace Egametang