let BaseNode=require("../Utils/BaseNode").BaseNode,APJS=require("../../../amazingpro");class CGTimer extends BaseNode{constructor(){super(),this.beginTime=0,this.state="",this.duration=null}setNext(t,s){this.nexts[t]=s}setInput(t,s){this.inputs[t]=s}execute(t){0===t?(this.state="start",this.beginTime=0,this.duration=this.inputs[3](),this.outputs[3]=0,this.outputs[4]=0,this.outputs[5]=this.duration,this.nexts[0]&&this.nexts[0]()):1===t?this.state="pause":2===t&&(this.state="start")}onUpdate(t,s){"start"===this.state&&(this.beginTime=this.beginTime+s,this.beginTime<this.duration&&(this.outputs[3]=this.beginTime,this.outputs[4]=this.beginTime/this.duration,this.outputs[5]=this.duration-this.beginTime,this.nexts[1])&&this.nexts[1](),this.beginTime>=this.duration)&&(this.outputs[3]=this.duration,this.outputs[4]=1,this.outputs[5]=0,this.state="finish",this.nexts[1]&&this.nexts[1](),this.nexts[2])&&this.nexts[2]()}resetOnRecord(t){this.beginTime=0,this.state="",this.duration=null,this.outputs[3]=0,this.outputs[4]=0,this.outputs[5]=0}}exports.CGTimer=CGTimer;