phaser4-rex-plugins
Version:
2 lines (1 loc) • 27.9 kB
JavaScript
var t,e;t=void 0,e=function(){const t=Phaser.GameObjects.GetCalcMatrix,e=Phaser.Renderer.Canvas.SetTransform;var i={renderWebGL:function(e,i,s,r){i.updateData();var h=s.camera;h.addToRenderList(i);for(var a,n=t(i,h,r,!s.useCanvas).calc,o=i._displayOriginX,l=i._displayOriginY,u=i.alpha,d=i.customRenderNodes.Submitter||i.defaultRenderNodes.Submitter,p=i.geom,c=0,v=p.length;c<v;c++)(a=p[c]).visible&&a.webglRender(s,d,n,i,u,o,l)},renderCanvas:function(t,i,s,r){i.updateData(),s.addToRenderList(i);var h=t.currentContext;if(e(t,h,i,s,r)){for(var a,n=i._displayOriginX,o=i._displayOriginY,l=i.geom,u=0,d=l.length;u<d;u++)(a=l[u]).visible&&a.canvasRender(h,n,o);h.restore()}}},s=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,h=Phaser.Utils.Array.Remove;class a extends r{constructor(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=2),void 0===r&&(r=s),super(t,"rexShapes",[]),this._width=-1,this._height=-1,this.dirty=!0,this.isSizeChanged=!0,this.shapes={},this.setPosition(e,i),this.setSize(s,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 i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.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,i){return void 0===i&&(i=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==e||this.strokeAlpha!==i,this._lineWidth=t,this._strokeColor=e,this._strokeAlpha=i,this}updateShapes(){}updateData(){if(!this.dirty)return this;this.updateShapes();for(var t=this.geom,e=0,i=t.length;e<i;e++){var s=t[e];s.dirty&&s.updateData()}return this.isSizeChanged=!1,this.dirty=!1,this}clear(){return this.geom.length=0,s(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],h(this.geom,e)),this}}Object.assign(a.prototype,i);var n={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,i){return null==t||null==e?this.isStroked=!1:(void 0===i&&(i=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i),this}},o={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,h=i,a=0;a<s.length;a++){if(e=s[a],!r.hasOwnProperty(e)){h=i;break}r=h=r[e]}return h}(this.data,t,e)},incData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData(){return this.data&&s(this.data),this}};class l{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,i,s,r,h,a){}canvasRender(t,e,i){}updateData(){this.dirty=!1}}Object.assign(l.prototype,n,o);var u=Phaser.Renderer.WebGL.Utils,d=Phaser.Renderer.WebGL.Utils;const p=Phaser.Geom.Polygon.Earcut;class c extends l{constructor(){super(),this.pathData=[],this.pathIndexes=[],this.closePath=!1}updateData(){return this.pathIndexes=p(this.pathData),super.updateData(),this}webglRender(t,e,i,s,r,h,a){this.isFilled&&function(t,e,i,s,r,h,a,n){var o,l,d,p,c,v=u.getTintAppendFloatAlpha(r.fillColor,r.fillAlpha*h),g=r.pathData,y=r.pathIndexes,m=g.length,f=Array(2*m),D=Array(m),P=0,b=0;for(o=0;o<m;o+=2)l=g[o]-a,d=g[o+1]-n,p=i.getX(l,d),c=i.getY(l,d),f[P++]=p,f[P++]=c,D[b++]=v;e.batch(t,y,f,D)}(t,e,i,0,this,r,h,a),this.isStroked&&function(t,e,i,s,r,h,a,n){var o=d.getTintAppendFloatAlpha(r.strokeColor,r.strokeAlpha*h),l=r.pathData,u=l.length-1,p=r.lineWidth,c=!r.closePath,v=s.customRenderNodes.StrokePath||s.defaultRenderNodes.StrokePath,g=[];c&&(u-=2);for(var y=0;y<u;y+=2){var m=l[y]-a,f=l[y+1]-n;y>0&&m===l[y-2]&&f===l[y-1]||g.push({x:m,y:f,width:p})}v.run(t,e,g,p,c,i,o,o,o,o)}(t,e,i,s,this,r,h,a)}canvasRender(t,e,i){var s=this.pathData,r=s.length-1,h=s[0]-e,a=s[1]-i;t.beginPath(),t.moveTo(h,a),this.closePath||(r-=2);for(var n=2;n<r;n+=2){var o=s[n]-e,l=s[n+1]-i;t.lineTo(o,l)}this.closePath&&t.closePath(),this.isFilled&&(function(t,e,i,s){var r=i||e.fillColor,h=s||e.fillAlpha,a=(16711680&r)>>>16,n=(65280&r)>>>8,o=255&r;t.fillStyle="rgba("+a+","+n+","+o+","+h+")"}(t,this),t.fill()),this.isStroked&&(function(t,e,i,s){var r=i||e.strokeColor,h=s||e.strokeAlpha,a=(16711680&r)>>>16,n=(65280&r)>>>8,o=255&r;t.strokeStyle="rgba("+a+","+n+","+o+","+h+")",t.lineWidth=e.lineWidth}(t,this),t.stroke())}}var v=function(t,e,i){var s=i.length;if(s>=2){var r=i[s-2],h=i[s-1];if(t===r&&e===h)return i}return i.push(t,e),i};const g=Phaser.Math.DegToRad;Phaser.Math.DegToRad;const y=Phaser.Math.Interpolation.QuadraticBezier,m=Phaser.Math.Interpolation.CubicBezier,f=Phaser.Math.Interpolation.CatmullRom;var D=function(t){var e=t.length;if(e<2)return t;var i=t[e-2],s=t[e-1];return t.push(i),t.push(s),t},P={clear(){return this.start(),this},start(){return this.startAt(),this},startAt(t,e){return this.restorePathData(),this.accumulationLengths=void 0,function(t,e,i){i.length=0,null!=t&&i.push(t,e)}(t,e,this.pathData),this.firstPointX=t,this.firstPointY=e,this.lastPointX=t,this.lastPointY=e,this},lineTo(t,e,i){return void 0===i&&(i=!1),i&&(t+=this.lastPointX,e+=this.lastPointY),v(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,i,s,r,h,a){return void 0===a&&(a=!1),function(t,e,i,s,r,h,a,n,o){a&&h>r?h-=360:!a&&h<r&&(h+=360);var l=g(h-r)/n;r=g(r);for(var u=0;u<=n;u++){var d=r+l*u,p=t+i*Math.cos(d),c=e+s*Math.sin(d);v(p,c,o)}}(t,e,i,s,r,h,a,this.iterations,this.pathData),this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this},arc(t,e,i,s,r,h){return this.ellipticalArc(t,e,i,i,s,r,h),this},quadraticBezierTo(t,e,i,s){return function(t,e,i,s,r,h){for(var a=h.length,n=h[a-2],o=h[a-1],l=1,u=r-1;l<=u;l++){var d=l/u;h.push(y(d,n,t,i),y(d,o,e,s))}}(t,e,i,s,this.iterations,this.pathData),this.lastPointX=i,this.lastPointY=s,this},cubicBezierTo(t,e,i,s,r,h){return function(t,e,i,s,r,h,a,n){for(var o=n.length,l=n[o-2],u=n[o-1],d=1,p=a-1;d<=p;d++){var c=d/p;n.push(m(c,l,t,i,r),m(c,u,e,s,h))}}(t,e,i,s,r,h,this.iterations,this.pathData),this.lastPointX=r,this.lastPointY=h,this},catmullRomTo(...t){return function(t,e,i){for(var s=i.length,r=[i[s-2]],h=[i[s-1]],a=0,n=t.length;a<n;a+=2)r.push(t[a]),h.push(t[a+1]);a=1;for(var o=e-1;a<=o;a++){var l=a/o;i.push(f(r,l),f(h,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 D(this.pathData),this}};const b=Phaser.Math.RotateAround,S=Phaser.Math.DegToRad;Phaser.Math.RotateAround;var _={rotateAround(t,e,i){if(0===this.pathData.length)return this;!function(t,e,i,s){for(var r={x:0,y:0},h=0,a=s.length-1;h<a;h+=2)r.x=s[h],r.y=s[h+1],b(r,t,e,i),s[h]=r.x,s[h+1]=r.y}(t,e,i=S(i),this.pathData);var s=this.pathData.length;return this.lastPointX=this.pathData[s-2],this.lastPointY=this.pathData[s-1],this},scale(t,e,i,s){return 0===this.pathData.length||(function(t,e,i,s,r){for(var h=0,a=r.length-1;h<a;h+=2){var n=r[h]-t,o=r[h+1]-e;n*=i,o*=s,r[h]=n+t,r[h+1]=o+e}}(t,e,i,s,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1]),this},offset(t,e){return function(t,e,i){for(var s=0,r=i.length-1;s<r;s+=2)i[s]+=t,i[s+1]+=e}(t,e,this.pathData),this}},k={savePathData(){return this.pathDataSaved||(this.pathDataSave=[...this.pathData],this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData(){return this.pathDataSaved?(function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=e.length),t.length=s-i;for(var r=0,h=t.length;r<h;r++)t[r]=e[r+i]}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}};const T=Phaser.Math.Distance.Between,E=Phaser.Math.Wrap,R=Phaser.Math.Linear;var w=function(t,e,i,s,r){if(void 0===s&&(s=i,i=0),(i=x(i))!==(s=x(s))){var h=e[e.length-1],a=h*i,n=h*s;i<s?A(t,e,a,n,r):(A(t,e,a,h,r),A(t,e,0,n,r)),D(r)}},A=function(t,e,i,s,r){for(var h=i>0,a=0,n=e.length;a<n;a++){var o=2*a,l=e[a];if(h){if(l<i)continue;if(l==i)h=!1;else{var u=1-(l-i)/(l-e[a-1]);r.push(C(t,o-2,o,u)),r.push(C(t,o-1,o+1,u)),h=!1}}if(!(l<=s)){u=1-(l-s)/(l-e[a-1]),r.push(C(t,o-2,o,u)),r.push(C(t,o-1,o+1,u));break}if(r.push(t[o]),r.push(t[o+1]),l===s)break}},C=function(t,e,i,s){var r=t[e],h=t[i];return R(r,h,s)},x=function(t){return 0===t?0:t%1==0?1:E(t,0,1)},O={updateAccumulationLengths(){if(null==this.accumulationLengths)this.accumulationLengths=[];else if(this.accumulationLengths.length===this.pathData.length/2)return this;for(var t,e,i,s,r=this.accumulationLengths,h=this.pathData,a=0,n=0,o=h.length;n<o;n+=2)i=h[n],s=h[n+1],a+=void 0===t?0:T(t,e,i,s),r.push(a),t=i,e=s;return this.totalPathLength=a,this},setDisplayPathSegment(t,e){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,w(this.pathDataSave,this.accumulationLengths,t,e,this.pathData),this},appendFromPathSegment(t,e,i){return void 0===e?this.pathData.push(...t.pathData):(t.updateAccumulationLengths(),w(t.pathData,t.accumulationLengths,e,i,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}},L={draw(t,e,i){var s=this.toPoints();return e&&t.fillPoints(s,this.closePath,this.closePath),i&&t.strokePoints(s,this.closePath,this.closePath),this}};const M=Phaser.Geom.Polygon;class j{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 i=0,s=t.length-1;i<s;i+=2)e.push({x:t[i],y:t[i+1]});return e}(this.pathData)}toPolygon(t){return function(t,e){return void 0===e&&(e=new M),e.setTo(t),e}(this.pathData,t)}}Object.assign(j.prototype,P,_,k,O,L);class F extends c{constructor(){super(),this.builder=new j(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,i){return this.builder.lineTo(t,e,i),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,i,s,r,h,a){return this.builder.ellipticalArc(t,e,i,s,r,h,a),this.dirty=!0,this}arc(t,e,i,s,r,h){return this.builder.arc(t,e,i,s,r,h),this.dirty=!0,this}quadraticBezierTo(t,e,i,s){return this.builder.quadraticBezierTo(t,e,i,s),this.dirty=!0,this}cubicBezierTo(t,e,i,s,r,h){return this.builder.cubicBezierTo(t,e,i,s,r,h),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,i){return this.builder.rotateAround(t,e,i),this.dirty=!0,this}scale(t,e,i,s){return this.builder.scale(t,e,i,s),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,i){return this.builder.appendFromPathSegment(t.builder,e,i),this}copyPathFrom(t,e,i){return this.builder.clear().appendFromPathSegment(t.builder,e,i),this}setDisplayPathSegment(t,e){return this.builder.setDisplayPathSegment(t,e),this}}Phaser.Renderer.WebGL.Utils,Phaser.Utils.Objects.GetValue,Phaser.Renderer.WebGL.Utils,Phaser.Math.Wrap;const z=Phaser.Math.Linear;var W=function(){var t,e,i,s,r,h,a=this.getShape("triangle"),n=this.padding,o=this.width-n.right,l=0+n.left,u=this.height-n.bottom,d=0+n.top,p=(l+o)/2,c=(d+u)/2,v={0:{a:{x:l,y:d},b:{x:o,y:c},c:{x:l,y:u}},1:{a:{x:l,y:d},b:{x:p,y:u},c:{x:o,y:d}},2:{a:{x:o,y:d},b:{x:l,y:c},c:{x:o,y:u}},3:{a:{x:l,y:u},b:{x:p,y:d},c:{x:o,y:u}}};if(void 0===this.previousDirection){var g=v[this.direction],y=g.a,m=g.b,f=g.c;t=y.x,e=y.y,i=m.x,s=m.y,r=f.x,h=f.y}else{var D=v[this.previousDirection],P=v[this.direction],b=this.easeDirectionProgress;t=z(D.a.x,P.a.x,b),e=z(D.a.y,P.a.y,b),i=z(D.b.x,P.b.x,b),s=z(D.b.y,P.b.y,b),r=z(D.c.x,P.c.x,b),h=z(D.c.y,P.c.y,b)}a.startAt(t,e).lineTo(i,s).lineTo(r,h),this.arrowOnly?a.end():a.close()};const G=(0,Phaser.Math.DegToRad)(120);var N=function(t){t=this.getShape("triangle");var e=this.width/2,i=this.height/2,s=Math.min(e,i)*this.radius,r=this.verticeRotation;t.startAt(e+s*Math.cos(r+G),i+s*Math.sin(r+G)).lineTo(e+s*Math.cos(r),i+s*Math.sin(r)).lineTo(e+s*Math.cos(r-G),i+s*Math.sin(r-G)),this.arrowOnly?t.end():t.close()},X={buildShapes(){this.addShape((new F).setName("triangle"))},updateShapes(){var t=this.getShape("triangle");this.arrowOnly?t.fillStyle().lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha):t.fillStyle(this.fillColor,this.fillAlpha).lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),0===this.shapeMode?W.call(this):N.call(this)}},Y={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 V=Phaser.Scene;var I=function(t){return t instanceof V};const U=Phaser.Game;var B=function(t){return t instanceof U};const J=Phaser.Utils.Objects.GetValue;class K{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(J(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:I(e)?e:e.scene&&I(e.scene)?e.scene:e.parent&&e.parent.scene&&I(e.parent.scene)?e.parent.scene:null,this.game=function(t){return null==t||"object"!=typeof t?null:B(t)?t:B(t.game)?t.game:I(t)?t.sys.game:I(t.scene)?t.scene.sys.game:void 0}(t),this}}Object.assign(K.prototype,Y);const q=Phaser.Utils.Objects.GetValue;class H extends K{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(q(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=Q[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 Q={no:0,lazy:1,always:2},Z=Phaser.Utils.Objects.GetValue;class $ extends H{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=Z(e,"tickEventName",i),this.isSceneTicker=!tt(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 tt=function(t){return"step"===t||"poststep"===t};const et=Phaser.Utils.Objects.GetValue,it=Phaser.Math.Clamp;class st{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=et(t,"state",rt),this.timeScale=et(t,"timeScale",1),this.delay=et(t,"delay",0),this.repeat=et(t,"repeat",0),this.repeatCounter=et(t,"repeatCounter",0),this.repeatDelay=et(t,"repeatDelay",0),this.duration=et(t,"duration",0),this.nowTime=et(t,"nowTime",0),this.justRestart=et(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?at:ht,this.repeatCounter=0,this}stop(){return this.state=rt,this}update(t,e){this.state!==rt&&this.state!==ot&&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=nt)):(this.nowTime=this.duration,this.state=ot):this.nowTime>=0&&(this.state=at))}get t(){var t;switch(this.state){case rt:case ht:case nt:t=0;break;case at:t=this.nowTime/this.duration;break;case ot:t=1}return it(t,0,1)}set t(t){(t=it(t,-1,1))<0?(this.state=ht,this.nowTime=-this.delay*t):(this.state=at,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===rt}get isDelay(){return this.state===ht}get isCountDown(){return this.state===at}get isRunning(){return this.state===ht||this.state===at}get isDone(){return this.state===ot}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const rt=0,ht=1,at=2,nt=3,ot=-1;class lt extends ${constructor(t,e){super(t,e),this.timer=new st}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 ut=Phaser.Utils.Objects.GetValue,dt=Phaser.Utils.Objects.GetAdvancedValue,pt=Phaser.Tweens.Builders.GetEaseFunction;class ct extends lt{resetFromJSON(t){return this.timer.resetFromJSON(ut(t,"timer")),this.setEnable(ut(t,"enable",!0)),this.setTarget(ut(t,"target",this.parent)),this.setDelay(dt(t,"delay",0)),this.setDuration(dt(t,"duration",1e3)),this.setEase(ut(t,"ease","Linear")),this.setRepeat(ut(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=pt(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 i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateTarget(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}updateTarget(t,e){}}const vt=Phaser.Utils.Objects.GetValue,gt=Phaser.Math.Linear;class yt extends ct{constructor(t,e){super(t,e),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=vt(t,"key","value");var i=e[this.propertyKey];return this.fromValue=vt(t,"from",i),this.toValue=vt(t,"to",i),this.setEase(vt(t,"ease",this.ease)),this.setDuration(vt(t,"duration",this.duration)),this.setRepeat(vt(t,"repeat",0)),this.setDelay(vt(t,"delay",0)),this.setRepeatDelay(vt(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 i=e.t;i=this.easeFn(i),t[this.propertyKey]=gt(this.fromValue,this.toValue,i)}}var mt={setEaseDuration(t){return void 0===t&&(t=0),this.easeDuration=t,this},playEaseDirectionation(){return void 0===this.easeDirectionProgressTask&&(this.easeDirectionProgressTask=new yt(this,{eventEmitter:null})),this.easeDirectionProgressTask.restart({key:"easeDirectionProgress",from:0,to:1,duration:this.easeDuration}),this},stopEaseDirection(){return void 0===this.easeDirectionProgressTask||this.easeDirectionProgressTask.stop(),this}};const ft=Phaser.Utils.Objects.GetValue,Dt=Phaser.Utils.Objects.IsPlainObject,Pt=Phaser.Math.DegToRad,bt=Phaser.Math.RadToDeg;class St extends a{constructor(t,e,i,s,r,h,a){var n,o,l,u,d,p,c,v;if(Dt(e)){var g=e;e=g.x,i=g.y,s=g.width,r=g.height,h=g.color,a=g.alpha,n=g.strokeColor,o=g.strokeAlpha,l=g.strokeWidth,u=g.arrowOnly,d=g.direction,p=g.easeDuration,c=g.padding,v=g.radius}void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s),void 0===u&&(u=!1),void 0===d&&(d=0),void 0===p&&(p=0),void 0===c&&(c=0),void 0===v&&(v=void 0),super(t,e,i,s,r),this.type="rexTriangle",this.setFillStyle(h,a),void 0!==n&&void 0===l&&(l=2),this.setStrokeStyle(l,n,o),this.setArrowOnly(u),this.setDirection(d,p),this.setPadding(c),this.setRadius(v),this.buildShapes()}get arrowOnly(){return this._arrowOnly}set arrowOnly(t){this.dirty=this.dirty||this._arrowOnly!=t,this._arrowOnly=t}setArrowOnly(t){return void 0===t&&(t=!0),this.arrowOnly=t,this}get direction(){return this._direction}set direction(t){t=kt(t),this._direction!==t&&(this.easeDuration>0&&void 0!==this._direction?this.previousDirection=this._direction:this.previousDirection=void 0,this._direction=t,this.verticeAngle=90*t,this.dirty=!0,void 0!==this.previousDirection?this.playEaseDirectionation():this.stopEaseDirection())}setDirection(t,e){return void 0!==e&&this.setEaseDuration(e),this.direction=t,this}toggleDirection(t){return this.setDirection(this.direction+2,t),this}get easeDirectionProgress(){return this._easeDirectionProgress}set easeDirectionProgress(t){this._easeDirectionProgress!==t&&(this._easeDirectionProgress=t,this.dirty=!0)}setPadding(t,e,i,s){if("object"==typeof t){var r=t,h=ft(r,"x",null);null!==h?(t=h,i=h):(t=ft(r,"left",0),i=ft(r,"right",t));var a=ft(r,"y",null);null!==a?(e=a,s=a):(e=ft(r,"top",0),s=ft(r,"bottom",e))}else void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=t),void 0===s&&(s=e);return void 0===this.padding&&(this.padding={}),this.dirty=this.dirty||this.padding.left!=t||this.padding.top!=e||this.padding.right!=i||this.padding.bottom!=s,this.padding.left=t,this.padding.top=e,this.padding.right=i,this.padding.bottom=s,this.setRadius(),this}get radius(){return this._radius}set radius(t){this.dirty=this.dirty||this._radius!=t,this._radius=t}setRadius(t){return this.radius=t,this.shapeMode=null==t?0:1,this}get verticeRotation(){return this._verticeRotation}set verticeRotation(t){this.dirty=this.dirty||this._verticeRotation!=t,this._verticeRotation=t}setVerticeRotation(t){return this.verticeRotation=t,this}get verticeAngle(){return bt(this.verticeRotation)}set verticeAngle(t){this.verticeRotation=Pt(t)}setVerticeAngle(t){return this.verticeAngle=t,this}}const _t={right:0,down:1,left:2,up:3};var kt=function(t){return"string"==typeof t&&(t=_t[t]),t%=4};return Object.assign(St.prototype,X,mt),St},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rextriangle=e();