phaser3-rex-plugins
Version:
2 lines (1 loc) • 27.5 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexlineprogresscanvasplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,(n=s.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(n,"string"))?r:String(r)),s);}var n,r;}function s(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var i,s=r(t);if(e){var n=r(this).constructor;i=Reflect.construct(s,arguments,n);}else i=s.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)}(this,i)}}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var s=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(s){var n=Object.getOwnPropertyDescriptor(s,e);return n.get?n.get.call(arguments.length<3?t:i):n.value}},u.apply(this,arguments)}var c,l=Phaser.Renderer.WebGL.Utils,v={renderWebGL:function(t,e,i,s){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.addToRenderList(e);var n=e.frame,r=n.width,a=n.height,o=l.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),u=h.setTexture2D(n.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,n.glTexture,r,a,e.x,e.y,r/e.resolution,a/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,r,a,o(e.tintTopLeft,i.alpha*e._alphaTL),o(e.tintTopRight,i.alpha*e._alphaTR),o(e.tintBottomLeft,i.alpha*e._alphaBL),o(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,s,!1,u),t.pipelines.postBatch(e);}},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s));}},f=Phaser.Display.Color,d={clear:function(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill:function(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame:function(t,e,i,s,n,r,a,o,h,u){var c=this.scene.sys.textures.getFrame(t,e);if(!c)return this;var l=c.cutWidth,v=c.cutHeight;void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=l),void 0===r&&(r=v),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=l),void 0===u&&(u=v);var f=c.cutX+a,d=c.cutY+o;return this.context.drawImage(c.source.image,f,d,h,u,i,s,n,r),this.dirty=!0,this},getDataURL:function(t,e){return this.canvas.toDataURL(t,e)},getPixel:function(t,e,i){void 0===i&&(i=new f);var s=this.context.getImageData(t,e,1,1);return i.setTo(s.data[0],s.data[1],s.data[2],s.data[3]),i},setPixel:function(t,e,i,s,n,r){if("number"!=typeof i){var a=i;i=a.red,s=a.green,n=a.blue,r=a.alpha;}void 0===r&&(r=0!==i||0!==s||0!==n?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=s,o.data[2]=n,o.data[3]=r,this.context.putImageData(o,t,e),this.dirty=!0,this}},y={updateTexture:function(t,e){t&&(e?t.call(e,this.canvas,this.context):t(this.canvas,this.context)),this.canvas.width===this.frame.width&&this.canvas.height===this.frame.height||this.frame.setSize(this.canvas.width,this.canvas.height),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(this.canvas,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!1;var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=this.width,i.hitArea.height=this.height),this},generateTexture:function(t,e,i,s,n){var r=this.canvas;return void 0===s?s=r.width:s*=this.resolution,void 0===n?n=r.height:n*=this.resolution,function(t,e,i,s,n,r,a){var o,h=t.sys.textures,u=t.renderer;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=e.width),void 0===a&&(a=e.height);var c=(o=h.exists(i)?h.get(i):h.createCanvas(i,r,a)).getSourceImage();c.width!==r&&(c.width=r),c.height!==a&&(c.height=a);var l=c.getContext("2d",{willReadFrequently:!0});l.clearRect(0,0,r,a),l.drawImage(e,s,n,r,a),u.gl&&o&&u.canvasToTexture(c,o.source[0].glTexture,!0,0);}(this.scene,r,t,e,i,s,n),this},loadTexture:function(t,e){var i=this.scene.sys.textures.getFrame(t,e);return i?(this.width!==i.cutWidth||this.height!==i.cutHeight?this.setSize(i.cutWidth,i.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}},p=!1;p||(void 0===c&&(c=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<c&&console.error("Minimum supported version : 3.".concat(c)),p=!0);var m=Phaser.Display.Canvas.CanvasPool,k=function(t){n(r,t);var i=h(r);function r(t,s,n,a,h){var u;return e(this,r),void 0===s&&(s=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===h&&(h=1),(u=i.call(this,t,"rexCanvas")).renderer=t.sys.game.renderer,u.resolution=1,u._width=a,u._height=h,a=Math.max(Math.ceil(a*u.resolution),1),h=Math.max(Math.ceil(h*u.resolution),1),u.canvas=m.create(o(u),a,h),u.context=u.canvas.getContext("2d",{willReadFrequently:!0}),u.dirty=!1,u.setPosition(s,n),u.setOrigin(.5,.5),u.initPipeline(),u.initPostPipeline(!0),u._crop=u.resetCropObject(),u.texture=t.sys.textures.addCanvas(null,u.canvas,!0),u.frame=u.texture.get(),u.frame.source.resolution=u.resolution,u.renderer&&u.renderer.gl&&(u.renderer.deleteTexture(u.frame.source.glTexture),u.frame.source.glTexture=null),u.dirty=!0,u}return s(r,[{key:"preDestroy",value:function(){m.remove(this.canvas),this.texture.destroy(),this.canvas=null,this.context=null;}},{key:"width",get:function(){return this._width},set:function(t){this.setSize(t,this._height);}},{key:"height",get:function(){return this._height},set:function(t){this.setSize(this._width,t);}},{key:"setCanvasSize",value:function(t,e){return this._width===t&&this._height===e||(this._width=t,this._height=e,this.updateDisplayOrigin(),t=Math.max(Math.ceil(t*this.resolution),1),e=Math.max(Math.ceil(e*this.resolution),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.dirty=!0),this}},{key:"setSize",value:function(t,e){return this.setCanvasSize(t,e),this}},{key:"displayWidth",get:function(){return this.scaleX*this._width},set:function(t){this.scaleX=t/this._width;}},{key:"displayHeight",get:function(){return this.scaleY*this._height},set:function(t){this.scaleY=t/this._height;}},{key:"setDisplaySize",value:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}},{key:"getCanvas",value:function(t){return t||(this.dirty=!0),this.canvas}},{key:"getContext",value:function(t){return t||(this.dirty=!0),this.context}},{key:"needRedraw",value:function(){return this.dirty=!0,this}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}}]),r}(Phaser.GameObjects.GameObject),g=Phaser.GameObjects.Components;Phaser.Class.mixin(k,[g.Alpha,g.BlendMode,g.Crop,g.Depth,g.Flip,g.GetBounds,g.Mask,g.Origin,g.Pipeline,g.PostPipeline,g.ScrollFactor,g.Tint,g.Transform,g.Visible,v,d,y]);var b=Phaser.Math.Linear,w=Phaser.Math.Percent,T={setValue:function(t,e,i){return null==t||(void 0!==e&&(t=w(t,e,i)),this.value=t),this},addValue:function(t,e,i){return void 0!==e&&(t=w(t,e,i)),this.value+=t,this},getValue:function(t,e){var i=this.value;return void 0!==t&&(i=b(t,e,i)),i}},_={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},P=Phaser.Scene,E=function(t){return t instanceof P},C=Phaser.Game,S=function(t){return t instanceof C},x=Phaser.Utils.Objects.GetValue,O=function(){function i(t,s){e(this,i),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(x(s,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this));}return s(i,[{key:"shutdown",value:function(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0);}},{key:"destroy",value:function(t){this.shutdown(t);}},{key:"onEnvDestroy",value:function(){this.destroy(!0);}},{key:"onParentDestroy",value:function(t,e){this.destroy(e);}},{key:"setParent",value:function(e){var i;return this.parent=e,this.scene=null==(i=e)||"object"!==t(i)?null:E(i)?i:i.scene&&E(i.scene)?i.scene:i.parent&&i.parent.scene&&E(i.parent.scene)?i.parent.scene:null,this.game=function(e){return null==e||"object"!==t(e)?null:S(e)?e:S(e.game)?e.game:E(e)?e.sys.game:E(e.scene)?e.scene.sys.game:void 0}(e),this}}]),i}();Object.assign(O.prototype,_);var R=Phaser.Utils.Objects.GetValue,D=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s))._isRunning=!1,n.isPaused=!1,n.tickingState=!1,n.setTickingMode(R(s,"tickingMode",1)),n}return s(a,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking();}},{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),u(r(a.prototype),"shutdown",this).call(this,t));}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=j[t]),this.tickingMode=t;}},{key:"startTicking",value:function(){this.tickingState=!0;}},{key:"stopTicking",value:function(){this.tickingState=!1;}},{key:"isRunning",get:function(){return this._isRunning},set:function(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()));}},{key:"start",value:function(){return this.isPaused=!1,this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}},{key:"resume",value:function(){return this.isPaused&&(this.isRunning=!0),this}},{key:"stop",value:function(){return this.isPaused=!1,this.isRunning=!1,this}},{key:"complete",value:function(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this);}}]),a}(O),j={no:0,lazy:1,always:2},V=Phaser.Utils.Objects.GetValue,G=function(t){n(a,t);var i=h(a);function a(t,s){var n;e(this,a);var r=(n=i.call(this,t,s)).scene?"update":"step";return n.tickEventName=V(s,"tickEventName",r),n.isSceneTicker=!L(n.tickEventName),n}return s(a,[{key:"startTicking",value:function(){u(r(a.prototype),"startTicking",this).call(this),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this);}},{key:"stopTicking",value:function(){u(r(a.prototype),"stopTicking",this).call(this),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this);}}]),a}(D),L=function(t){return "step"===t||"poststep"===t},F=Phaser.Utils.Objects.GetValue,M=Phaser.Math.Clamp,N=function(){function t(i){e(this,t),this.resetFromJSON(i);}return s(t,[{key:"resetFromJSON",value:function(t){this.state=F(t,"state",z),this.timeScale=F(t,"timeScale",1),this.delay=F(t,"delay",0),this.repeat=F(t,"repeat",0),this.repeatCounter=F(t,"repeatCounter",0),this.repeatDelay=F(t,"repeatDelay",0),this.duration=F(t,"duration",0),this.nowTime=F(t,"nowTime",0),this.justRestart=F(t,"justRestart",!1);}},{key:"toJSON",value:function(){return {state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}},{key:"destroy",value:function(){}},{key:"setTimeScale",value:function(t){return this.timeScale=t,this}},{key:"setDelay",value:function(t){return void 0===t&&(t=0),this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatInfinity",value:function(){return this.repeat=-1,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"start",value:function(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?X:B,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=z,this}},{key:"update",value:function(t,e){this.state!==z&&this.state!==H&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=U)):(this.nowTime=this.duration,this.state=H):this.nowTime>=0&&(this.state=X));}},{key:"t",get:function(){var t;switch(this.state){case z:case B:case U:t=0;break;case X:t=this.nowTime/this.duration;break;case H:t=1;}return M(t,0,1)},set:function(t){(t=M(t,-1,1))<0?(this.state=B,this.nowTime=-this.delay*t):(this.state=X,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++);}},{key:"setT",value:function(t){return this.t=t,this}},{key:"isIdle",get:function(){return this.state===z}},{key:"isDelay",get:function(){return this.state===B}},{key:"isCountDown",get:function(){return this.state===X}},{key:"isRunning",get:function(){return this.state===B||this.state===X}},{key:"isDone",get:function(){return this.state===H}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),t}(),z=0,B=1,X=2,U=3,H=-1,I=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s)).timer=new N,n}return s(a,[{key:"shutdown",value:function(t){this.isShutdown||(u(r(a.prototype),"shutdown",this).call(this,t),this.timer.destroy(),this.timer=void 0);}},{key:"start",value:function(){return this.timer.start(),u(r(a.prototype),"start",this).call(this),this}},{key:"stop",value:function(){return this.timer.stop(),u(r(a.prototype),"stop",this).call(this),this}},{key:"complete",value:function(){return this.timer.stop(),u(r(a.prototype),"complete",this).call(this),this}}]),a}(G),A=Phaser.Utils.Objects.GetValue,W=Phaser.Utils.Objects.GetAdvancedValue,J=Phaser.Tweens.Builders.GetEaseFunction,Y=function(t){n(a,t);var i=h(a);function a(){return e(this,a),i.apply(this,arguments)}return s(a,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(A(t,"timer")),this.setEnable(A(t,"enable",!0)),this.setTarget(A(t,"target",this.parent)),this.setDelay(W(t,"delay",0)),this.setDuration(W(t,"duration",1e3)),this.setEase(A(t,"ease","Linear")),this.setRepeat(A(t,"repeat",0)),this}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setTarget",value:function(t){return void 0===t&&(t=this.parent),this.target=t,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=J(t),this}},{key:"start",value:function(){return this.timer.isRunning||u(r(a.prototype),"start",this).call(this),this}},{key:"restart",value:function(){return this.timer.stop(),this.start.apply(this,arguments),this}},{key:"stop",value:function(t){return void 0===t&&(t=!1),u(r(a.prototype),"stop",this).call(this),t&&(this.timer.setT(1),this.updateGameObject(this.target,this.timer),this.complete()),this}},{key:"update",value:function(t,e){if(!this.isRunning||!this.enable||!this.parent.active)return this;var i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateGameObject(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}},{key:"updateGameObject",value:function(t,e){}}]),a}(I),K=Phaser.Utils.Objects.GetValue,q=Phaser.Math.Linear,Q=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s)).resetFromJSON(),n.boot(),n}return s(a,[{key:"start",value:function(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=K(t,"key","value");var i=e[this.propertyKey];return this.fromValue=K(t,"from",i),this.toValue=K(t,"to",i),this.setEase(K(t,"ease",this.ease)),this.setDuration(K(t,"duration",this.duration)),this.setRepeat(K(t,"repeat",0)),this.setDelay(K(t,"delay",0)),this.setRepeatDelay(K(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),e[this.propertyKey]=this.fromValue,u(r(a.prototype),"start",this).call(this),this}},{key:"updateGameObject",value:function(t,e){var i=e.t;i=this.easeFn(i),t[this.propertyKey]=q(this.fromValue,this.toValue,i);}}]),a}(Y),Z=Phaser.Math.Percent,$={setEaseValuePropName:function(t){return this.easeValuePropName=t,this},setEaseValueDuration:function(t){return this.easeValueDuration=t,this},setEaseValueFunction:function(t){return this.easeFunction=t,this},stopEaseValue:function(){return this.easeValueTask&&this.easeValueTask.stop(),this},easeValueTo:function(t,e,i){return null==t||(void 0!==e&&(t=Z(t,e,i)),void 0===this.easeValueTask&&(this.easeValueTask=new Q(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,to:t,duration:this.easeValueDuration,ease:this.easeFunction})),this},easeValueRepeat:function(t,e,i,s){return void 0===i&&(i=-1),void 0===s&&(s=0),void 0===this.easeValueTask&&(this.easeValueTask=new Q(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,from:t,to:e,duration:this.easeValueDuration,ease:this.easeFunction,repeat:i,repeatDelay:s}),this}},tt=Phaser.Utils.Objects.GetValue,et=Phaser.Math.Clamp;var it=Phaser.Utils.String.Pad,st=function(e,i,s){if(null==e)return e;switch(t(e)){case"string":default:return e;case"number":return "#".concat(it(Math.floor(e).toString(16),6,"0",1));case"function":return e(i,s);case"object":return e.hasOwnProperty("r")?e.hasOwnProperty("a")?"rgba(".concat(e.r,",").concat(e.g,",").concat(e.b,",").concat(e.a,")"):"rgb(".concat(e.r,",").concat(e.g,",").concat(e.b,")"):e.hasOwnProperty("h")?e.hasOwnProperty("a")?"hsla(".concat(e.h,",").concat(e.s,",").concat(e.l,",").concat(e.a,")"):"hsl(".concat(e.h,",").concat(e.s,",").concat(e.l,")"):e}},nt=function(t,e,i,s,n,r,a){void 0===a&&(a="round"),function(t,e){t.save(),t.beginPath();var i=e[0];t.moveTo(i.x,i.y);for(var s=1,n=e.length;s<n;s++)i=e[s],t.lineTo(i.x,i.y);t.closePath(),t.restore();}(e,i),e.lineJoin=a,null!=s&&(e.fillStyle=s,e.fill()),null!=n&&(e.strokeStyle=n,e.lineWidth=r,e.stroke());},rt=function(){var t,e,i=this.skewX,s=this.width-Math.abs(i),n=this.height,r=(this.canvas,this.context);if((this.trackColor||this.trackStrokeColor)&&at(0,0,s,n,i,this.trackPoints),this.barColor&&(this.rtl?(t=s*(1-this.value),e=s):(t=0,e=s*this.value),at(t,0,e,n,i,this.barPoints)),this.trackColor&&(r.save(),nt(0,r,this.trackPoints,this.trackColor),r.restore()),this.barColor){var a;if(r.save(),this.barColor2){var o;if(this.isHorizontalGradient){var h=n/2;o=r.createLinearGradient(t,h,e,h);}else {var u=s/2;o=r.createLinearGradient(u,0,u,n);}o.addColorStop(0,this.rtl?this.barColor:this.barColor2),o.addColorStop(1,this.rtl?this.barColor2:this.barColor),a=o;}else a=this.barColor;nt(0,r,this.barPoints,a),r.restore();}this.trackStrokeColor&&this.trackStrokeThickness>0&&(r.save(),nt(0,r,this.trackPoints,void 0,this.trackStrokeColor,this.trackStrokeThickness),r.restore());},at=function(t,e,i,s,n,r){void 0===r&&(r=[]),r.length=4;for(var a=0;a<4;a++)r[a]||(r[a]={});var o;return n>=0?((o=r[0]).x=t+n,o.y=e,(o=r[1]).x=i+n,o.y=e,(o=r[2]).x=i,o.y=s,(o=r[3]).x=t,o.y=s):((o=r[0]).x=t,o.y=e,(o=r[1]).x=i,o.y=e,(o=r[2]).x=i-n,o.y=s,(o=r[3]).x=t-n,o.y=s),r},ot=Phaser.Utils.Objects.GetValue,ht=Phaser.Utils.Objects.IsPlainObject,ut=function(t){n(a,t);var i=h(a);function a(t,s,n,r,o,h,u,c){var l;return e(this,a),ht(s)?(s=ot(c=s,"x",0),n=ot(c,"y",0),r=ot(c,"width",2),o=ot(c,"height",2),h=ot(c,"barColor",void 0),u=ot(c,"value",0)):ht(r)?(r=ot(c=r,"width",2),o=ot(c,"height",2),h=ot(c,"barColor",void 0),u=ot(c,"value",0)):ht(h)&&(h=ot(c=h,"barColor",void 0),u=ot(c,"value",0)),(l=i.call(this,t,s,n,r,o)).type="rexLineProgressCanvas",l.trackPoints=[],l.barPoints=[],l.bootProgressBase(c),l.setTrackColor(ot(c,"trackColor",void 0)),l.setBarColor(h,ot(c,"barColor2",void 0),ot(c,"isHorizontalGradient",void 0)),l.setTrackStroke(ot(c,"trackStrokeThickness",2),ot(c,"trackStrokeColor",void 0)),l.setSkewX(ot(c,"skewX",0)),l.setRTL(ot(c,"rtl",!1)),l.setValue(u),l}return s(a,[{key:"trackColor",get:function(){return this._trackColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._trackColor!=t,this._trackColor=t;}},{key:"setTrackColor",value:function(t){return this.trackColor=t,this}},{key:"trackStrokeColor",get:function(){return this._trackStrokeColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._trackStrokeColor!=t,this._trackStrokeColor=t;}},{key:"trackStrokeThickness",get:function(){return this._trackStrokeThickness},set:function(t){this.dirty=this.dirty||this._trackStrokeThickness!=t,this._trackStrokeThickness=t;}},{key:"setTrackStroke",value:function(t,e){return this.trackStrokeThickness=t,this.trackStrokeColor=e,this}},{key:"barColor",get:function(){return this._barColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._barColor!=t,this._barColor=t;}},{key:"barColor2",get:function(){return this._barColor2},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._barColor2!=t,this._barColor2=t;}},{key:"isHorizontalGradient",get:function(){return this._isHorizontalGradient},set:function(t){this.dirty|=this._isHorizontalGradient!=t,this._isHorizontalGradient=t;}},{key:"setBarColor",value:function(t,e,i){return void 0===i&&(i=!0),this.barColor=t,this.barColor2=e,this.isHorizontalGradient=i,this}},{key:"skewX",get:function(){return this._skewX},set:function(t){this.dirty=this.dirty||this._skewX!=t,this._skewX=t;}},{key:"setSkewX",value:function(t){return this.skewX=t,this}},{key:"rtl",get:function(){return this._rtl},set:function(t){t=!!t,this.dirty=this.dirty||this._rtl!=t,this._rtl=t;}},{key:"setRTL",value:function(t){return void 0===t&&(t=!0),this.rtl=t,this}},{key:"updateTexture",value:function(){return this.clear(),rt.call(this),u(r(a.prototype),"updateTexture",this).call(this),this}}]),a}(function(t){var i=function(t){n(r,t);var i=h(r);function r(){return e(this,r),i.apply(this,arguments)}return s(r,[{key:"bootProgressBase",value:function(t){this.eventEmitter=tt(t,"eventEmitter",this);var e=tt(t,"valuechangeCallback",null);if(null!==e){var i=tt(t,"valuechangeCallbackScope",void 0);this.eventEmitter.on("valuechange",e,i);}return this.setEaseValuePropName("value").setEaseValueDuration(tt(t,"easeValue.duration",0)).setEaseValueFunction(tt(t,"easeValue.ease","Linear")),this}},{key:"value",get:function(){return this._value},set:function(t){t=et(t,0,1);var e=this._value,i=e!=t;this.dirty=this.dirty||i,this._value=t,i&&this.eventEmitter.emit("valuechange",this._value,e,this.eventEmitter);}}]),r}(t);return Object.assign(i.prototype,T,$),i}(k));function ct(t,e,i,s,n,r,a){var o=new ut(this.scene,t,e,i,s,n,r,a);return this.scene.add.existing(o),o}var lt=Phaser.GameObjects.BuildGameObject;function vt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new ut(this.scene,t);return lt(this.scene,i,t),i}var ft=function(t){return null==t||""===t||0===t.length},dt=function(t){n(r,Phaser.Plugins.BasePlugin);var i=h(r);function r(t){var s;return e(this,r),s=i.call(this,t),t.registerGameObject("rexLineProgressCanvas",ct,vt),s}return s(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}}]),r}();return function(e,i,s,n){if(void 0===n&&(n="."),"object"===t(e)){if(ft(i)){if(null==s)return;"object"===t(s)&&(e=s);}else {"string"==typeof i&&(i=i.split(n));var r=i.pop(),a=function(e,i,s){var n=e;if(ft(i));else {var r;"string"==typeof i&&(i=i.split("."));for(var a=0,o=i.length;a<o;a++){var h;null!=n[r=i[a]]&&"object"===t(n[r])||(h=a===o-1?void 0===s?{}:s:{},n[r]=h),n=n[r];}}return n}(e,i);a[r]=s;}}}(window,"RexPlugins.GameObjects.LineProgressCanvas",ut),dt}));