Repeater.js 815 B

123456789101112131415161718192021222324
  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: "Repeater", title: "Repeat <maxLoop>x", properties: {maxLoop: -1}}), (this.maxLoop = t);
  10. }
  11. open(t) {
  12. t.blackboard.set("i", 0, t.tree.id, this.id);
  13. }
  14. tick(t) {
  15. if (!this.child) return s.ERROR;
  16. for (
  17. var e = t.blackboard.get("i", t.tree.id, this.id), i = s.SUCCESS;
  18. (this.maxLoop < 0 || e < this.maxLoop) && ((i = this.child._execute(t)) == s.SUCCESS || i == s.FAILURE);
  19. )
  20. e++;
  21. return t.blackboard.set("i", e, t.tree.id, this.id), i;
  22. }
  23. };