BaseNode.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const a = t("B3Functions"),
  6. s = t("constants");
  7. i.default = class {
  8. constructor({category: t, name: e, title: i, description: s, properties: o} = {}) {
  9. (this.id = a.createUUID()),
  10. (this.category = t || ""),
  11. (this.name = e || ""),
  12. (this.title = i || this.name),
  13. (this.description = s || ""),
  14. (this.properties = o || {});
  15. }
  16. _execute(t) {
  17. this._enter(t), t.blackboard.get("isOpen", t.tree.id, this.id) || this._open(t);
  18. var e = this._tick(t);
  19. return e !== s.RUNNING && this._close(t), this._exit(t), e;
  20. }
  21. _enter(t) {
  22. t._enterNode(this), this.enter(t);
  23. }
  24. _open(t) {
  25. t._openNode(this), t.blackboard.set("isOpen", !0, t.tree.id, this.id), this.open(t);
  26. }
  27. _tick(t) {
  28. return t._tickNode(this), this.tick(t);
  29. }
  30. _close(t) {
  31. t._closeNode(this), t.blackboard.set("isOpen", !1, t.tree.id, this.id), this.close(t);
  32. }
  33. _exit(t) {
  34. t._exitNode(this), this.exit(t);
  35. }
  36. enter(t) {}
  37. open(t) {}
  38. interrupt(t) {}
  39. close(t) {}
  40. exit(t) {}
  41. };