DebugTree.js 889 B

123456789101112131415161718192021
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0}), (i.DebugTree = void 0);
  5. const s = t("BehaviorTree"),
  6. l = t("Tick");
  7. i.DebugTree = class extends s.default {
  8. tick(t, e) {
  9. if (!e) throw "The blackboard parameter is obligatory and must be an instance of b3.Blackboard";
  10. let i = new l.default();
  11. (i.debug = this.debug), (i.target = t), (i.blackboard = e);
  12. let s,
  13. o = (i.tree = this).root._execute(i),
  14. a = e.get("openNodes", this.id),
  15. n = i._openNodes.slice(0),
  16. r = 0;
  17. for (s = 0; s < Math.min(a.length, n.length) && ((r = s + 1), e.get("openNodes", this.id), a[s] === n[s]); s++);
  18. for (s = a.length - 1; s >= r; s--) a[s]._close(i);
  19. return e.set("openNodes", n, this.id), e.set("nodeCount", i._nodeCount, this.id), o;
  20. }
  21. };