NotNode.cc 536 B

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