!function(){function t(t){QyEventTarget.call(this);this.setStepProps(t);this.scheduledIdx=null;this.speedRatio=t&&t.speed||1}inherits(t,QyEventTarget);window.QyTimeline=t;t.prototype.getDirector=qyengine.getDirector;t.prototype.setPosition=function(t,e){e&&(t+=this.stepProps.startPosition);this.stepProps.startPosition=t;return this};t.prototype.setSpeed=function(t,e){t=null!=t?t/100:1;e&&(t*=this.speedRatio);this.speedRatio=t;return this};t.prototype.setStepProps=function(t){t||(t={});this.stepProps={loop:null!=t.loop?t.loop:!1,delay:t.delay||0,startPosition:t.startPosition||0};return this};t.prototype.stop=function(){if(null!=this.scheduledIdx){qyengine.unscheduleTask(this.scheduledIdx);this.scheduledIdx=null;if(this.started){this.started=!1;this.dispatchEvent("timelinestop");if(!(this instanceof QyKeyframe)){var t=this.startedOpt&&this.startedOpt.target||this.target;t&&t.dispatchEvent("timelinestop")}}}return this};t.prototype.start=function(t){if(!this.stepDefs_)return this;this.stop();var e=qyengine.merge(this.stepProps,t);if(e.startPosition>=this.stepMax_){if(!e.loop)return this;e.offset=e.startPosition%this.stepMax_}else e.offset=e.startPosition;for(var s=this.stepDefs_,i=s.length,r=0;i>r&&!(s[r][0]>=e.offset);r++);e.startIdx=r;this.startedOpt=e;var n=this.startedOpt.delay;n?this.scheduledIdx=qyengine.callAfter(this.startImm_.bind(this),n):this.startImm_();return this};t.prototype.startImm_=function(){this.stop();this.dispatchEvent("timelinestart");if(!(this instanceof QyKeyframe)){var t=this.startedOpt&&this.startedOpt.target||this.target;t&&t.dispatchEvent("timelinestart")}this.started=!0;this.scheduledIdx=qyengine.scheduleTask(this.step_.bind(this),this,-1);window.current_scene&&current_scene.isPaused_&&current_game.director&&qyengine.changeDirectorActivity&&qyengine.changeDirectorActivity(current_game.director,!0);return this};t.prototype.step_=function(t){t/=10;for(var e=this.startedOpt.target||this.target,s=this.startedOpt.loop,i=this.startedOpt.offset,r=t*this.speedRatio,n=i+r,o={type:"timeline"},a=this.stepDefs_,h=a.length;this.started;){for(var p=this.startedOpt.startIdx;h>p;p++){var d=a[p],c=d[0],l=d[1],u=d[2];if(!(n>c)){this.startedOpt.offset=n;this.startedOpt.startIdx=p;current_scene.isPaused_;return}o.step=c;u&&(o.extraArg=u);l.call(e,o)}if(!(s===!0||s>1)){this.stop();current_scene.isPaused_;return}s!==!0&&this.startedOpt.loop--;i=0;this.startedOpt.startIdx=0;n-=this.stepMax_}}}();