SubTree.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const s = t("Actions"),
  6. o = t("BaseAction"),
  7. a = t("constants"),
  8. n = t("BehaviorTree");
  9. class r extends o.default {
  10. constructor() {
  11. super(...arguments), (this.tree = null);
  12. }
  13. static setSubTreeLoadFunc(t) {
  14. this.subTreeLoadFunc = t;
  15. }
  16. set properties(t) {
  17. (this._properties = t), this._properties.path && r.subTreeLoadFunc(this);
  18. }
  19. get properties() {
  20. return this._properties;
  21. }
  22. loadDataFinish(t) {
  23. (this.tree = new n.default()), this.tree.load(t, s.Actions);
  24. }
  25. open(t) {}
  26. tick(t) {
  27. return this.tree ? this.tree.tick(t.target, t.blackboard) : a.RUNNING;
  28. }
  29. interrupt(i) {
  30. var s = i.blackboard.get("openNodes", this.tree.id);
  31. if (s) {
  32. var t = i.tree;
  33. i.tree = this.tree;
  34. for (let e = 0; e < s.length; e++) {
  35. let t = s[e];
  36. t._close(i), t.interrupt && t.interrupt(i);
  37. }
  38. i.tree = t;
  39. }
  40. }
  41. }
  42. i.default = r;