UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 28.5 kB
var t,e;t=void 0,e=function(){const t=Phaser.GameObjects.GetCalcMatrix,e=Phaser.Renderer.Canvas.SetTransform;var s={renderWebGL:function(e,s,i,r){s.updateData();var a=i.camera;a.addToRenderList(s);for(var h,n=t(s,a,r,!i.useCanvas).calc,o=s._displayOriginX,l=s._displayOriginY,u=s.alpha,d=s.customRenderNodes.Submitter||s.defaultRenderNodes.Submitter,p=s.geom,c=0,v=p.length;c<v;c++)(h=p[c]).visible&&h.webglRender(i,d,n,s,u,o,l)},renderCanvas:function(t,s,i,r){s.updateData(),i.addToRenderList(s);var a=t.currentContext;if(e(t,a,s,i,r)){for(var h,n=s._displayOriginX,o=s._displayOriginY,l=s.geom,u=0,d=l.length;u<d;u++)(h=l[u]).visible&&h.canvasRender(a,n,o);a.restore()}}},i=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e];return t};const r=Phaser.GameObjects.Shape,a=Phaser.Utils.Array.Remove;class h extends r{constructor(t,e,s,i,r){void 0===e&&(e=0),void 0===s&&(s=0),void 0===i&&(i=2),void 0===r&&(r=i),super(t,"rexShapes",[]),this._width=-1,this._height=-1,this.dirty=!0,this.isSizeChanged=!0,this.shapes={},this.setPosition(e,s),this.setSize(i,r),this.updateDisplayOrigin()}get width(){return this._width}set width(t){this.setSize(t,this._height)}get height(){return this._height}set height(t){this.setSize(this._width,t)}setDirty(t){return void 0===t&&(t=!0),this.dirty=t,this}setSize(t,e){this.isSizeChanged=this.isSizeChanged||this._width!==t||this._height!==e,this.dirty=this.dirty||this.isSizeChanged,this._width=t,this._height=e,this.updateDisplayOrigin();var s=this.input;return s&&!s.customHitArea&&(s.hitArea.width=t,s.hitArea.height=e),this}resize(t,e){return this.setSize(t,e),this}get fillColor(){return this._fillColor}set fillColor(t){this.setFillStyle(t,this._fillAlpha)}get fillAlpha(){return this._fillAlpha}set fillAlpha(t){this.setFillStyle(this._fillColor,t)}setFillStyle(t,e){return void 0===e&&(e=1),this.dirty=this.dirty||this.fillColor!==t||this.fillAlpha!==e,this._fillColor=t,this._fillAlpha=e,this}get lineWidth(){return this._lineWidth}set lineWidth(t){this.setStrokeStyle(t,this._strokeColor,this._strokeAlpha)}get strokeColor(){return this._strokeColor}set strokeColor(t){this.setStrokeStyle(this._lineWidth,t,this._strokeAlpha)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(t){this.setStrokeStyle(this._lineWidth,this._strokeColor,t)}setStrokeStyle(t,e,s){return void 0===s&&(s=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==e||this.strokeAlpha!==s,this._lineWidth=t,this._strokeColor=e,this._strokeAlpha=s,this}updateShapes(){}updateData(){if(!this.dirty)return this;this.updateShapes();for(var t=this.geom,e=0,s=t.length;e<s;e++){var i=t[e];i.dirty&&i.updateData()}return this.isSizeChanged=!1,this.dirty=!1,this}clear(){return this.geom.length=0,i(this.shapes),this.dirty=!0,this}getShape(t){return this.shapes[t]}getShapes(){return this.geom}addShape(t){this.geom.push(t);var e=t.name;return e&&(this.shapes[e]=t),this.dirty=!0,this}deleteShape(t){var e=this.getShape(t);return e&&(delete this.shapes[t],a(this.geom,e)),this}}Object.assign(h.prototype,s);const n=Phaser.Math.Linear,o=Phaser.Math.Percent;var l={setValue(t,e,s){return null==t||(void 0!==e&&(t=o(t,e,s)),this.value=t),this},addValue(t,e,s){return void 0!==e&&(t=o(t,e,s)),this.value+=t,this},getValue(t,e){var s=this.value;return void 0!==t&&void 0!==e&&(s=n(t,e,s)),s}},u={setEventEmitter(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(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const d=Phaser.Scene;var p=function(t){return t instanceof d};const c=Phaser.Game;var v=function(t){return t instanceof c};const g=Phaser.Utils.Objects.GetValue;class m{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(g(e,"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))}shutdown(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)}destroy(t){this.shutdown(t)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(t,e){this.destroy(e)}setParent(t){var e;return this.parent=t,this.scene=null==(e=t)||"object"!=typeof e?null:p(e)?e:e.scene&&p(e.scene)?e.scene:e.parent&&e.parent.scene&&p(e.parent.scene)?e.parent.scene:null,this.game=function(t){return null==t||"object"!=typeof t?null:v(t)?t:v(t.game)?t.game:p(t)?t.sys.game:p(t.scene)?t.scene.sys.game:void 0}(t),this}}Object.assign(m.prototype,u);const y=Phaser.Utils.Objects.GetValue;class f extends m{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(y(e,"tickingMode",1))}boot(){2!==this.tickingMode||this.tickingState||this.startTicking()}shutdown(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),super.shutdown(t))}setTickingMode(t){"string"==typeof t&&(t=k[t]),this.tickingMode=t}startTicking(){this.tickingState=!0}stopTicking(){this.tickingState=!1}get isRunning(){return this._isRunning}set isRunning(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}start(){return this.isPaused=!1,this.isRunning=!0,this}pause(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}resume(){return this.isPaused&&(this.isPaused=!1,this.isRunning=!0),this}stop(){return this.isPaused=!1,this.isRunning=!1,this}complete(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}const k={no:0,lazy:1,always:2},P=Phaser.Utils.Objects.GetValue;class D extends f{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=P(e,"tickEventName",s),this.isSceneTicker=!S(this.tickEventName)}startTicking(){super.startTicking(),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this)}stopTicking(){super.stopTicking(),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)}}var S=function(t){return"step"===t||"poststep"===t};const b=Phaser.Utils.Objects.GetValue,T=Phaser.Math.Clamp;class _{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=b(t,"state",E),this.timeScale=b(t,"timeScale",1),this.delay=b(t,"delay",0),this.repeat=b(t,"repeat",0),this.repeatCounter=b(t,"repeatCounter",0),this.repeatDelay=b(t,"repeatDelay",0),this.duration=b(t,"duration",0),this.nowTime=b(t,"nowTime",0),this.justRestart=b(t,"justRestart",!1)}toJSON(){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}}destroy(){}setTimeScale(t){return this.timeScale=t,this}setDelay(t){return void 0===t&&(t=0),this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatInfinity(){return this.repeat=-1,this}setRepeatDelay(t){return this.repeatDelay=t,this}start(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?w:C,this.repeatCounter=0,this}stop(){return this.state=E,this}update(t,e){this.state!==E&&this.state!==A&&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=R)):(this.nowTime=this.duration,this.state=A):this.nowTime>=0&&(this.state=w))}get t(){var t;switch(this.state){case E:case C:case R:t=0;break;case w:t=this.nowTime/this.duration;break;case A:t=1}return T(t,0,1)}set t(t){(t=T(t,-1,1))<0?(this.state=C,this.nowTime=-this.delay*t):(this.state=w,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===E}get isDelay(){return this.state===C}get isCountDown(){return this.state===w}get isRunning(){return this.state===C||this.state===w}get isDone(){return this.state===A}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const E=0,C=1,w=2,R=3,A=-1;class V extends D{constructor(t,e){super(t,e),this.timer=new _}shutdown(t){this.isShutdown||(super.shutdown(t),this.timer.destroy(),this.timer=void 0)}start(){return this.timer.start(),super.start(),this}stop(){return this.timer.stop(),super.stop(),this}complete(){return this.timer.stop(),super.complete(),this}}const L=Phaser.Utils.Objects.GetValue,O=Phaser.Utils.Objects.GetAdvancedValue,j=Phaser.Tweens.Builders.GetEaseFunction;class F extends V{resetFromJSON(t){return this.timer.resetFromJSON(L(t,"timer")),this.setEnable(L(t,"enable",!0)),this.setTarget(L(t,"target",this.parent)),this.setDelay(O(t,"delay",0)),this.setDuration(O(t,"duration",1e3)),this.setEase(L(t,"ease","Linear")),this.setRepeat(L(t,"repeat",0)),this}setEnable(t){return null==t&&(t=!0),this.enable=t,this}setTarget(t){return void 0===t&&(t=this.parent),this.target=t,this}setDelay(t){return this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=j(t),this}start(){return this.timer.isRunning||super.start(),this}restart(){return this.timer.stop(),this.start.apply(this,arguments),this}stop(t){return void 0===t&&(t=!1),super.stop(),t&&(this.timer.setT(1),this.updateTarget(this.target,this.timer),this.complete()),this}update(t,e){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var s=this.target,i=this.timer;return i.update(t,e),i.isDelay||this.updateTarget(s,i),this.emit("update",s,this),i.isDone&&this.complete(),this}updateTarget(t,e){}}const x=Phaser.Utils.Objects.GetValue,X=Phaser.Math.Linear;class N extends F{constructor(t,e){super(t,e),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=x(t,"key","value");var s=e[this.propertyKey];return this.fromValue=x(t,"from",s),this.toValue=x(t,"to",s),this.setEase(x(t,"ease",this.ease)),this.setDuration(x(t,"duration",this.duration)),this.setRepeat(x(t,"repeat",0)),this.setDelay(x(t,"delay",0)),this.setRepeatDelay(x(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),e[this.propertyKey]=this.fromValue,super.start(),this}updateTarget(t,e){var s=e.t;s=this.easeFn(s),t[this.propertyKey]=X(this.fromValue,this.toValue,s)}}const M=Phaser.Math.Percent;var G={setEaseValuePropName(t){return this.easeValuePropName=t,this},setEaseValueDuration(t){return this.easeValueDuration=t,this},setEaseValueFunction(t){return this.easeFunction=t,this},stopEaseValue(){return this.easeValueTask&&this.easeValueTask.stop(),this},easeValueTo(t,e,s){return null==t||(void 0!==e&&(t=M(t,e,s)),void 0===this.easeValueTask&&(this.easeValueTask=new N(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,to:t,duration:this.easeValueDuration,ease:this.easeFunction})),this},easeValueRepeat(t,e,s,i){return void 0===s&&(s=-1),void 0===i&&(i=0),void 0===this.easeValueTask&&(this.easeValueTask=new N(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,from:t,to:e,duration:this.easeValueDuration,ease:this.easeFunction,repeat:s,repeatDelay:i}),this}};const z=Phaser.Utils.Objects.GetValue,Y=Phaser.Math.Clamp;var W={fillStyle:function(t,e){return null==t?this.isFilled=!1:(void 0===e&&(e=1),this.isFilled=!0,this.fillColor=t,this.fillAlpha=e),this},lineStyle:function(t,e,s){return null==t||null==e?this.isStroked=!1:(void 0===s&&(s=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=s),this}},B={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var s=t;for(t in s)this.data[t]=s[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:function(t,e,s){if(!t||"number"==typeof t)return s;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return s;e=e.split(".")}for(var i=e,r=t,a=s,h=0;h<i.length;h++){if(e=i[h],!r.hasOwnProperty(e)){a=s;break}r=a=r[e]}return a}(this.data,t,e)},incData(t,e,s){return void 0===s&&(s=0),this.enableData(),this.setData(t,this.getData(t,s)+e),this},mulData(t,e,s){return void 0===s&&(s=0),this.enableData(),this.setData(t,this.getData(t,s)*e),this},clearData(){return this.data&&i(this.data),this}};class U{constructor(){this.name=void 0,this.dirty=!0,this.visible=!0,this.data=void 0,this.isFilled=!1,this.fillColor=void 0,this.fillAlpha=1,this.isStroked=!1,this.lineWidth=1,this.strokeColor=void 0,this.strokeAlpha=1}setName(t){return this.name=t,this}setVisible(t){return void 0===t&&(t=!0),this.visible=t,this}reset(){return this.setVisible().fillStyle().lineStyle(),this}webglRender(t,e,s,i,r,a,h){}canvasRender(t,e,s){}updateData(){this.dirty=!1}}Object.assign(U.prototype,W,B);var I=Phaser.Renderer.WebGL.Utils,J=Phaser.Renderer.WebGL.Utils;const K=Phaser.Geom.Polygon.Earcut;class q extends U{constructor(){super(),this.pathData=[],this.pathIndexes=[],this.closePath=!1}updateData(){return this.pathIndexes=K(this.pathData),super.updateData(),this}webglRender(t,e,s,i,r,a,h){this.isFilled&&function(t,e,s,i,r,a,h,n){var o,l,u,d,p,c=I.getTintAppendFloatAlpha(r.fillColor,r.fillAlpha*a),v=r.pathData,g=r.pathIndexes,m=v.length,y=Array(2*m),f=Array(m),k=0,P=0;for(o=0;o<m;o+=2)l=v[o]-h,u=v[o+1]-n,d=s.getX(l,u),p=s.getY(l,u),y[k++]=d,y[k++]=p,f[P++]=c;e.batch(t,g,y,f)}(t,e,s,0,this,r,a,h),this.isStroked&&function(t,e,s,i,r,a,h,n){var o=J.getTintAppendFloatAlpha(r.strokeColor,r.strokeAlpha*a),l=r.pathData,u=l.length-1,d=r.lineWidth,p=!r.closePath,c=i.customRenderNodes.StrokePath||i.defaultRenderNodes.StrokePath,v=[];p&&(u-=2);for(var g=0;g<u;g+=2){var m=l[g]-h,y=l[g+1]-n;g>0&&m===l[g-2]&&y===l[g-1]||v.push({x:m,y:y,width:d})}c.run(t,e,v,d,p,s,o,o,o,o)}(t,e,s,i,this,r,a,h)}canvasRender(t,e,s){var i=this.pathData,r=i.length-1,a=i[0]-e,h=i[1]-s;t.beginPath(),t.moveTo(a,h),this.closePath||(r-=2);for(var n=2;n<r;n+=2){var o=i[n]-e,l=i[n+1]-s;t.lineTo(o,l)}this.closePath&&t.closePath(),this.isFilled&&(function(t,e,s,i){var r=s||e.fillColor,a=i||e.fillAlpha,h=(16711680&r)>>>16,n=(65280&r)>>>8,o=255&r;t.fillStyle="rgba("+h+","+n+","+o+","+a+")"}(t,this),t.fill()),this.isStroked&&(function(t,e,s,i){var r=s||e.strokeColor,a=i||e.strokeAlpha,h=(16711680&r)>>>16,n=(65280&r)>>>8,o=255&r;t.strokeStyle="rgba("+h+","+n+","+o+","+a+")",t.lineWidth=e.lineWidth}(t,this),t.stroke())}}var H=function(t,e,s){var i=s.length;if(i>=2){var r=s[i-2],a=s[i-1];if(t===r&&e===a)return s}return s.push(t,e),s};const Q=Phaser.Math.DegToRad;Phaser.Math.DegToRad;const Z=Phaser.Math.Interpolation.QuadraticBezier,$=Phaser.Math.Interpolation.CubicBezier,tt=Phaser.Math.Interpolation.CatmullRom;var et=function(t){var e=t.length;if(e<2)return t;var s=t[e-2],i=t[e-1];return t.push(s),t.push(i),t},st={clear(){return this.start(),this},start(){return this.startAt(),this},startAt(t,e){return this.restorePathData(),this.accumulationLengths=void 0,function(t,e,s){s.length=0,null!=t&&s.push(t,e)}(t,e,this.pathData),this.firstPointX=t,this.firstPointY=e,this.lastPointX=t,this.lastPointY=e,this},lineTo(t,e,s){return void 0===s&&(s=!1),s&&(t+=this.lastPointX,e+=this.lastPointY),H(t,e,this.pathData),this.lastPointX=t,this.lastPointY=e,this},verticalLineTo(t,e){return this.lineTo(t,this.lastPointY,e),this},horizontalLineTo(t,e){return this.lineTo(this.lastPointX,t,e),this},ellipticalArc(t,e,s,i,r,a,h){return void 0===h&&(h=!1),function(t,e,s,i,r,a,h,n,o){h&&a>r?a-=360:!h&&a<r&&(a+=360);var l=Q(a-r)/n;r=Q(r);for(var u=0;u<=n;u++){var d=r+l*u,p=t+s*Math.cos(d),c=e+i*Math.sin(d);H(p,c,o)}}(t,e,s,i,r,a,h,this.iterations,this.pathData),this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this},arc(t,e,s,i,r,a){return this.ellipticalArc(t,e,s,s,i,r,a),this},quadraticBezierTo(t,e,s,i){return function(t,e,s,i,r,a){for(var h=a.length,n=a[h-2],o=a[h-1],l=1,u=r-1;l<=u;l++){var d=l/u;a.push(Z(d,n,t,s),Z(d,o,e,i))}}(t,e,s,i,this.iterations,this.pathData),this.lastPointX=s,this.lastPointY=i,this},cubicBezierTo(t,e,s,i,r,a){return function(t,e,s,i,r,a,h,n){for(var o=n.length,l=n[o-2],u=n[o-1],d=1,p=h-1;d<=p;d++){var c=d/p;n.push($(c,l,t,s,r),$(c,u,e,i,a))}}(t,e,s,i,r,a,this.iterations,this.pathData),this.lastPointX=r,this.lastPointY=a,this},catmullRomTo(...t){return function(t,e,s){for(var i=s.length,r=[s[i-2]],a=[s[i-1]],h=0,n=t.length;h<n;h+=2)r.push(t[h]),a.push(t[h+1]);h=1;for(var o=e-1;h<=o;h++){var l=h/o;s.push(tt(r,l),tt(a,l))}}(t,this.iterations,this.pathData),this.lastPointX=t[t.length-2],this.lastPointY=t[t.length-1],this},close(){var t=this.pathData[0],e=this.pathData[1];return t===this.lastPointX&&e===this.lastPointY||this.lineTo(t,e),this.closePath=!0,this},end(){return et(this.pathData),this}};const it=Phaser.Math.RotateAround,rt=Phaser.Math.DegToRad;Phaser.Math.RotateAround;var at={rotateAround(t,e,s){if(0===this.pathData.length)return this;!function(t,e,s,i){for(var r={x:0,y:0},a=0,h=i.length-1;a<h;a+=2)r.x=i[a],r.y=i[a+1],it(r,t,e,s),i[a]=r.x,i[a+1]=r.y}(t,e,s=rt(s),this.pathData);var i=this.pathData.length;return this.lastPointX=this.pathData[i-2],this.lastPointY=this.pathData[i-1],this},scale(t,e,s,i){return 0===this.pathData.length||(function(t,e,s,i,r){for(var a=0,h=r.length-1;a<h;a+=2){var n=r[a]-t,o=r[a+1]-e;n*=s,o*=i,r[a]=n+t,r[a+1]=o+e}}(t,e,s,i,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1]),this},offset(t,e){return function(t,e,s){for(var i=0,r=s.length-1;i<r;i+=2)s[i]+=t,s[i+1]+=e}(t,e,this.pathData),this}},ht={savePathData(){return this.pathDataSaved||(this.pathDataSave=[...this.pathData],this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData(){return this.pathDataSaved?(function(t,e,s,i){void 0===s&&(s=0),void 0===i&&(i=e.length),t.length=i-s;for(var r=0,a=t.length;r<a;r++)t[r]=e[r+s]}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}};const nt=Phaser.Math.Distance.Between,ot=Phaser.Math.Wrap,lt=Phaser.Math.Linear;var ut=function(t,e,s,i,r){if(void 0===i&&(i=s,s=0),(s=ct(s))!==(i=ct(i))){var a=e[e.length-1],h=a*s,n=a*i;s<i?dt(t,e,h,n,r):(dt(t,e,h,a,r),dt(t,e,0,n,r)),et(r)}},dt=function(t,e,s,i,r){for(var a=s>0,h=0,n=e.length;h<n;h++){var o=2*h,l=e[h];if(a){if(l<s)continue;if(l==s)a=!1;else{var u=1-(l-s)/(l-e[h-1]);r.push(pt(t,o-2,o,u)),r.push(pt(t,o-1,o+1,u)),a=!1}}if(!(l<=i)){u=1-(l-i)/(l-e[h-1]),r.push(pt(t,o-2,o,u)),r.push(pt(t,o-1,o+1,u));break}if(r.push(t[o]),r.push(t[o+1]),l===i)break}},pt=function(t,e,s,i){var r=t[e],a=t[s];return lt(r,a,i)},ct=function(t){return 0===t?0:t%1==0?1:ot(t,0,1)},vt={updateAccumulationLengths(){if(null==this.accumulationLengths)this.accumulationLengths=[];else if(this.accumulationLengths.length===this.pathData.length/2)return this;for(var t,e,s,i,r=this.accumulationLengths,a=this.pathData,h=0,n=0,o=a.length;n<o;n+=2)s=a[n],i=a[n+1],h+=void 0===t?0:nt(t,e,s,i),r.push(h),t=s,e=i;return this.totalPathLength=h,this},setDisplayPathSegment(t,e){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,ut(this.pathDataSave,this.accumulationLengths,t,e,this.pathData),this},appendFromPathSegment(t,e,s){return void 0===e?this.pathData.push(...t.pathData):(t.updateAccumulationLengths(),ut(t.pathData,t.accumulationLengths,e,s,this.pathData)),this.firstPointX=this.pathData[0],this.firstPointY=this.pathData[1],this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this}},gt={draw(t,e,s){var i=this.toPoints();return e&&t.fillPoints(i,this.closePath,this.closePath),s&&t.strokePoints(i,this.closePath,this.closePath),this}};const mt=Phaser.Geom.Polygon;class yt{constructor(t){void 0===t&&(t=[]),this.pathData=t,this.closePath=!1,this.setIterations(32),this.firstPointX=void 0,this.firstPointY=void 0,this.lastPointX=void 0,this.lastPointY=void 0,this.accumulationLengths=void 0}setIterations(t){return this.iterations=t,this}toPoints(){return function(t,e){void 0===e&&(e=[]);for(var s=0,i=t.length-1;s<i;s+=2)e.push({x:t[s],y:t[s+1]});return e}(this.pathData)}toPolygon(t){return function(t,e){return void 0===e&&(e=new mt),e.setTo(t),e}(this.pathData,t)}}Object.assign(yt.prototype,st,at,ht,vt,gt);class ft extends q{constructor(){super(),this.builder=new yt(this.pathData)}get iterations(){return this.builder.iterations}set iterations(t){this.dirty=this.dirty||this.builder.iterations!==t,this.builder.setIterations(t)}setIterations(t){return this.iterations=t,this}get lastPointX(){return this.builder.lastPointX}get lastPointY(){return this.builder.lastPointY}start(){return this.builder.start(),this.dirty=!0,this}startAt(t,e){return this.builder.startAt(t,e),this.dirty=!0,this}lineTo(t,e,s){return this.builder.lineTo(t,e,s),this.dirty=!0,this}verticalLineTo(t,e){return this.builder.verticalLineTo(t,e),this.dirty=!0,this}horizontalLineTo(t,e){return this.builder.horizontalLineTo(t,e),this.dirty=!0,this}ellipticalArc(t,e,s,i,r,a,h){return this.builder.ellipticalArc(t,e,s,i,r,a,h),this.dirty=!0,this}arc(t,e,s,i,r,a){return this.builder.arc(t,e,s,i,r,a),this.dirty=!0,this}quadraticBezierTo(t,e,s,i){return this.builder.quadraticBezierTo(t,e,s,i),this.dirty=!0,this}cubicBezierTo(t,e,s,i,r,a){return this.builder.cubicBezierTo(t,e,s,i,r,a),this.dirty=!0,this}catmullRomTo(...t){return this.builder.catmullRomTo(...t),this.dirty=!0,this}close(){return this.builder.close(),this.closePath=this.builder.closePath,this.dirty=!0,this}end(){return this.builder.end(),this.dirty=!0,this}rotateAround(t,e,s){return this.builder.rotateAround(t,e,s),this.dirty=!0,this}scale(t,e,s,i){return this.builder.scale(t,e,s,i),this.dirty=!0,this}offset(t,e){return this.builder.offset(t,e),this.dirty=!0,this}toPolygon(t){return this.builder.toPolygon(t)}appendPathFrom(t,e,s){return this.builder.appendFromPathSegment(t.builder,e,s),this}copyPathFrom(t,e,s){return this.builder.clear().appendFromPathSegment(t.builder,e,s),this}setDisplayPathSegment(t,e){return this.builder.setDisplayPathSegment(t,e),this}}Phaser.Renderer.WebGL.Utils,Phaser.Utils.Objects.GetValue,Phaser.Renderer.WebGL.Utils;var kt=function(t,e,s,i,r,a){var h=(e+i)/2;return a>=0?t.startAt(h+a,s).lineTo(i+a,s).lineTo(i,r).lineTo(e,r).lineTo(e+a,s).lineTo(h+a,s):t.startAt(h,s).lineTo(i,s).lineTo(i-a,r).lineTo(e-a,r).lineTo(e,s).lineTo(h,s),t.close(),t};const Pt=Phaser.Utils.Objects.GetValue,Dt=Phaser.Utils.Objects.IsPlainObject;class St extends(function(t){class e extends t{bootProgressBase(t){this.eventEmitter=z(t,"eventEmitter",this);var e=z(t,"valuechangeCallback",null);if(null!==e){var s=z(t,"valuechangeCallbackScope",void 0);this.eventEmitter.on("valuechange",e,s)}return this.setEaseValuePropName("value").setEaseValueDuration(z(t,"easeValue.duration",0)).setEaseValueFunction(z(t,"easeValue.ease","Linear")),this}get value(){return this._value}set value(t){t=Y(t,0,1);var e=this._value,s=e!=t;this.dirty=this.dirty||s,this._value=t,s&&this.eventEmitter.emit("valuechange",this._value,e,this.eventEmitter)}}return Object.assign(e.prototype,l,G),e}(h)){constructor(t,e,s,i,r,a,h,n){Dt(e)?(e=(n=e).x,s=n.y,i=n.width,r=n.height,a=n.barColor,h=n.value):Dt(i)?(i=(n=i).width,r=n.height,a=n.barColor,h=n.value):Dt(a)&&(a=(n=a).barColor,h=n.value),void 0===e&&(e=0),void 0===s&&(s=0),void 0===i&&(i=2),void 0===r&&(r=i),void 0===h&&(h=0),super(t,e,s,i,r,n),this.type="rexLineProgress",this.bootProgressBase(n),this.addShape((new ft).setName("trackFill")).addShape((new ft).setName("bar")).addShape((new ft).setName("trackStroke")),this.setTrackColor(Pt(n,"trackColor",void 0)),this.setBarColor(a),this.setTrackStroke(Pt(n,"trackStrokeThickness",2),Pt(n,"trackStrokeColor",void 0)),this.setSkewX(Pt(n,"skewX",0)),this.setRTL(Pt(n,"rtl",!1)),this.setValue(h)}get trackColor(){return this._trackColor}set trackColor(t){this.dirty=this.dirty||this._trackColor!=t,this._trackColor=t}setTrackColor(t){return this.trackColor=t,this}get trackStrokeColor(){return this._trackStrokeColor}set trackStrokeColor(t){this.dirty=this.dirty||this._trackStrokeColor!=t,this._trackStrokeColor=t}get trackStrokeThickness(){return this._trackStrokeThickness}set trackStrokeThickness(t){this.dirty=this.dirty||this._trackStrokeThickness!=t,this._trackStrokeThickness=t}setTrackStroke(t,e){return this.trackStrokeThickness=t,this.trackStrokeColor=e,this}get barColor(){return this._barColor}set barColor(t){this.dirty=this.dirty||this._barColor!=t,this._barColor=t}setBarColor(t){return this.barColor=t,this}get skewX(){return this._skewX}set skewX(t){this.dirty=this.dirty||this._skewX!=t,this._skewX=t}setSkewX(t){return this.skewX=t,this}get rtl(){return this._rtl}set rtl(t){t=!!t,this.dirty=this.dirty||this._rtl!=t,this._rtl=t}setRTL(t){return void 0===t&&(t=!0),this.rtl=t,this}}var bt={updateShapes:function(){var t=this.skewX,e=this.width-Math.abs(t),s=this.height,i=this.getShape("trackFill");i.fillStyle(this.trackColor),i.isFilled&&kt(i,0,0,e,s,t);var r,a,h=this.getShape("bar");h.fillStyle(this.barColor),h.isFilled&&(this.rtl?(r=e*(1-this.value),a=e):(r=0,a=e*this.value),kt(h,r,0,a,s,t));var n=this.getShape("trackStroke");n.lineStyle(this.trackStrokeThickness,this.trackStrokeColor),n.isStroked&&kt(n,0,0,e,s,t)}};function Tt(t,e,s,i,r,a,h){var n=new St(this.scene,t,e,s,i,r,a,h);return this.scene.add.existing(n),n}Object.assign(St.prototype,bt);const _t=Phaser.GameObjects.BuildGameObject;function Et(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var s=new St(this.scene,t);return _t(this.scene,s,t),s}var Ct=function(t){return null==t||""===t||0===t.length};class wt extends Phaser.Plugins.BasePlugin{constructor(t){super(t),t.registerGameObject("rexLineProgress",Tt,Et)}start(){this.game.events.on("destroy",this.destroy,this)}}return function(t,e,s,i){if(void 0===i&&(i="."),"object"==typeof t)if(Ct(e)){if(null==s)return;"object"==typeof s&&(t=s)}else{"string"==typeof e&&(e=e.split(i));var r=e.pop(),a=function(t,e,s){var i=t;if(Ct(e));else{var r;"string"==typeof e&&(e=e.split("."));for(var a=0,h=e.length;a<h;a++){var n;null!=i[r=e[a]]&&"object"==typeof i[r]||(n=a===h-1?void 0===s?{}:s:{},i[r]=n),i=i[r]}}return i}(t,e);a[r]=s}}(window,"RexPlugins.GameObjects.LineProgress",St),wt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexlineprogressplugin=e();