1 line
750 B
JavaScript
1 line
750 B
JavaScript
"use strict";var t=require("../../bt/factory"),r=require("../../bt/base"),e=r.Status,i=r.createBehavior;module.exports=i({constructor:function(t){this.children=t||[],this.current=-1},start:function(){return 0===this.children.length?!1:(this.current=0,this.findStart())},findStart:function(){for(var t=!1;!t&&this.current<this.children.length;)t=this.children[this.current].start(),t||this.current++;return!0},stop:function(){this.current=-1},update:function(){if(-1!==this.current&&this.current<this.children.length){var t=this.children[this.current].update();return t===e.FAILED?(this.current++,this.current>=this.children.length||!this.findStart()?e.SUCCEEDED:e.IN_PROGRESS):t===e.PAUSED?e.IN_PROGRESS:t}return e.SUCCEEDED}}),t.addBehavior(module); |