RepeatUntilFailure.js 824 B

12345678910111213141516171819202122232425
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const s = t("constants"),
  6. o = t("Decorator");
  7. i.default = class extends o.default {
  8. constructor({maxLoop: t = -1, child: e = null} = {}) {
  9. super({child: e, name: "RepeatUntilFailure", title: "Repeat Until Failure", properties: {maxLoop: -1}}),
  10. (this.maxLoop = t);
  11. }
  12. open(t) {
  13. t.blackboard.set("i", 0, t.tree.id, this.id);
  14. }
  15. tick(t) {
  16. if (!this.child) return s.ERROR;
  17. for (
  18. var e = t.blackboard.get("i", t.tree.id, this.id), i = s.ERROR;
  19. (this.maxLoop < 0 || e < this.maxLoop) && (i = this.child._execute(t)) == s.SUCCESS;
  20. )
  21. e++;
  22. return (e = t.blackboard.set("i", e, t.tree.id, this.id)), i;
  23. }
  24. };