phaser4-rex-plugins
Version:
2 lines (1 loc) • 23.1 kB
JavaScript
var t,i;t=void 0,i=function(){const t=Phaser.GameObjects.GetCalcMatrix,i=Phaser.Renderer.Canvas.SetTransform;var e={renderWebGL:function(i,e,s,h){e.updateData();var a=s.camera;a.addToRenderList(e);for(var r,o=t(e,a,h,!s.useCanvas).calc,l=e._displayOriginX,n=e._displayOriginY,d=e.alpha,u=e.customRenderNodes.Submitter||e.defaultRenderNodes.Submitter,p=e.geom,c=0,v=p.length;c<v;c++)(r=p[c]).visible&&r.webglRender(s,u,o,e,d,l,n)},renderCanvas:function(t,e,s,h){e.updateData(),s.addToRenderList(e);var a=t.currentContext;if(i(t,a,e,s,h)){for(var r,o=e._displayOriginX,l=e._displayOriginY,n=e.geom,d=0,u=n.length;d<u;d++)(r=n[d]).visible&&r.canvasRender(a,o,l);a.restore()}}},s=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var i in t)delete t[i];return t};const h=Phaser.GameObjects.Shape,a=Phaser.Utils.Array.Remove;class r extends h{constructor(t,i,e,s,h){void 0===i&&(i=0),void 0===e&&(e=0),void 0===s&&(s=2),void 0===h&&(h=s),super(t,"rexShapes",[]),this._width=-1,this._height=-1,this.dirty=!0,this.isSizeChanged=!0,this.shapes={},this.setPosition(i,e),this.setSize(s,h),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,i){this.isSizeChanged=this.isSizeChanged||this._width!==t||this._height!==i,this.dirty=this.dirty||this.isSizeChanged,this._width=t,this._height=i,this.updateDisplayOrigin();var e=this.input;return e&&!e.customHitArea&&(e.hitArea.width=t,e.hitArea.height=i),this}resize(t,i){return this.setSize(t,i),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,i){return void 0===i&&(i=1),this.dirty=this.dirty||this.fillColor!==t||this.fillAlpha!==i,this._fillColor=t,this._fillAlpha=i,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,i,e){return void 0===e&&(e=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==i||this.strokeAlpha!==e,this._lineWidth=t,this._strokeColor=i,this._strokeAlpha=e,this}updateShapes(){}updateData(){if(!this.dirty)return this;this.updateShapes();for(var t=this.geom,i=0,e=t.length;i<e;i++){var s=t[i];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 i=t.name;return i&&(this.shapes[i]=t),this.dirty=!0,this}deleteShape(t){var i=this.getShape(t);return i&&(delete this.shapes[t],a(this.geom,i)),this}}Object.assign(r.prototype,e);const o={bezier:0,spline:1,polyline:2,poly:2,straightline:3,straight:3},l={none:0,triangle:1,dot:2,box:3,diamond:4};var n={setHeadShape(t){return"string"==typeof t&&(t=l[t.toLowerCase()]),this.headShape=t,this},setHeadSize(t){return this.headSize=t,this},setHeadFillStyle(t,i){return void 0===i&&(i=1),this.headColor=t,this.headAlpha=i,this},setHeadStrokeStyle(t,i,e){return void 0===e&&(e=1),this.headStrokeWidth=t,this.headStrokeColor=i,this.headStrokeAlpha=e,this},setTailShape(t){return"string"==typeof t&&(t=l[t.toLowerCase()]),this.tailShape=t,this},setTailSize(t){return this.tailSize=t,this},setTailFillStyle(t,i){return void 0===i&&(i=1),this.tailColor=t,this.tailAlpha=i,this},setTailStrokeStyle(t,i,e){return void 0===e&&(e=1),this.tailStrokeWidth=t,this.tailStrokeColor=i,this.tailStrokeAlpha=e,this}},d={fillStyle:function(t,i){return null==t?this.isFilled=!1:(void 0===i&&(i=1),this.isFilled=!0,this.fillColor=t,this.fillAlpha=i),this},lineStyle:function(t,i,e){return null==t||null==i?this.isStroked=!1:(void 0===e&&(e=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=i,this.strokeAlpha=e),this}},u={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,i){if(this.enableData(),1===arguments.length){var e=t;for(t in e)this.data[t]=e[t]}else this.data[t]=i;return this},getData(t,i){return this.enableData(),void 0===t?this.data:function(t,i,e){if(!t||"number"==typeof t)return e;if("string"==typeof i){if(t.hasOwnProperty(i))return t[i];if(-1===i.indexOf("."))return e;i=i.split(".")}for(var s=i,h=t,a=e,r=0;r<s.length;r++){if(i=s[r],!h.hasOwnProperty(i)){a=e;break}h=a=h[i]}return a}(this.data,t,i)},incData(t,i,e){return void 0===e&&(e=0),this.enableData(),this.setData(t,this.getData(t,e)+i),this},mulData(t,i,e){return void 0===e&&(e=0),this.enableData(),this.setData(t,this.getData(t,e)*i),this},clearData(){return this.data&&s(this.data),this}};class p{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,i,e,s,h,a,r){}canvasRender(t,i,e){}updateData(){this.dirty=!1}}Object.assign(p.prototype,d,u);var c=Phaser.Renderer.WebGL.Utils,v=Phaser.Renderer.WebGL.Utils;const g=Phaser.Geom.Polygon.Earcut;class y extends p{constructor(){super(),this.pathData=[],this.pathIndexes=[],this.closePath=!1}updateData(){return this.pathIndexes=g(this.pathData),super.updateData(),this}webglRender(t,i,e,s,h,a,r){this.isFilled&&function(t,i,e,s,h,a,r,o){var l,n,d,u,p,v=c.getTintAppendFloatAlpha(h.fillColor,h.fillAlpha*a),g=h.pathData,y=h.pathIndexes,S=g.length,f=Array(2*S),P=Array(S),b=0,k=0;for(l=0;l<S;l+=2)n=g[l]-r,d=g[l+1]-o,u=e.getX(n,d),p=e.getY(n,d),f[b++]=u,f[b++]=p,P[k++]=v;i.batch(t,y,f,P)}(t,i,e,0,this,h,a,r),this.isStroked&&function(t,i,e,s,h,a,r,o){var l=v.getTintAppendFloatAlpha(h.strokeColor,h.strokeAlpha*a),n=h.pathData,d=n.length-1,u=h.lineWidth,p=!h.closePath,c=s.customRenderNodes.StrokePath||s.defaultRenderNodes.StrokePath,g=[];p&&(d-=2);for(var y=0;y<d;y+=2){var S=n[y]-r,f=n[y+1]-o;y>0&&S===n[y-2]&&f===n[y-1]||g.push({x:S,y:f,width:u})}c.run(t,i,g,u,p,e,l,l,l,l)}(t,i,e,s,this,h,a,r)}canvasRender(t,i,e){var s=this.pathData,h=s.length-1,a=s[0]-i,r=s[1]-e;t.beginPath(),t.moveTo(a,r),this.closePath||(h-=2);for(var o=2;o<h;o+=2){var l=s[o]-i,n=s[o+1]-e;t.lineTo(l,n)}this.closePath&&t.closePath(),this.isFilled&&(function(t,i,e,s){var h=e||i.fillColor,a=s||i.fillAlpha,r=(16711680&h)>>>16,o=(65280&h)>>>8,l=255&h;t.fillStyle="rgba("+r+","+o+","+l+","+a+")"}(t,this),t.fill()),this.isStroked&&(function(t,i,e,s){var h=e||i.strokeColor,a=s||i.strokeAlpha,r=(16711680&h)>>>16,o=(65280&h)>>>8,l=255&h;t.strokeStyle="rgba("+r+","+o+","+l+","+a+")",t.lineWidth=i.lineWidth}(t,this),t.stroke())}}var S=function(t,i,e){var s=e.length;if(s>=2){var h=e[s-2],a=e[s-1];if(t===h&&i===a)return e}return e.push(t,i),e};const f=Phaser.Math.DegToRad;Phaser.Math.DegToRad;const P=Phaser.Math.Interpolation.QuadraticBezier,b=Phaser.Math.Interpolation.CubicBezier,k=Phaser.Math.Interpolation.CatmullRom;var D=function(t){var i=t.length;if(i<2)return t;var e=t[i-2],s=t[i-1];return t.push(e),t.push(s),t},A={clear(){return this.start(),this},start(){return this.startAt(),this},startAt(t,i){return this.restorePathData(),this.accumulationLengths=void 0,function(t,i,e){e.length=0,null!=t&&e.push(t,i)}(t,i,this.pathData),this.firstPointX=t,this.firstPointY=i,this.lastPointX=t,this.lastPointY=i,this},lineTo(t,i,e){return void 0===e&&(e=!1),e&&(t+=this.lastPointX,i+=this.lastPointY),S(t,i,this.pathData),this.lastPointX=t,this.lastPointY=i,this},verticalLineTo(t,i){return this.lineTo(t,this.lastPointY,i),this},horizontalLineTo(t,i){return this.lineTo(this.lastPointX,t,i),this},ellipticalArc(t,i,e,s,h,a,r){return void 0===r&&(r=!1),function(t,i,e,s,h,a,r,o,l){r&&a>h?a-=360:!r&&a<h&&(a+=360);var n=f(a-h)/o;h=f(h);for(var d=0;d<=o;d++){var u=h+n*d,p=t+e*Math.cos(u),c=i+s*Math.sin(u);S(p,c,l)}}(t,i,e,s,h,a,r,this.iterations,this.pathData),this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this},arc(t,i,e,s,h,a){return this.ellipticalArc(t,i,e,e,s,h,a),this},quadraticBezierTo(t,i,e,s){return function(t,i,e,s,h,a){for(var r=a.length,o=a[r-2],l=a[r-1],n=1,d=h-1;n<=d;n++){var u=n/d;a.push(P(u,o,t,e),P(u,l,i,s))}}(t,i,e,s,this.iterations,this.pathData),this.lastPointX=e,this.lastPointY=s,this},cubicBezierTo(t,i,e,s,h,a){return function(t,i,e,s,h,a,r,o){for(var l=o.length,n=o[l-2],d=o[l-1],u=1,p=r-1;u<=p;u++){var c=u/p;o.push(b(c,n,t,e,h),b(c,d,i,s,a))}}(t,i,e,s,h,a,this.iterations,this.pathData),this.lastPointX=h,this.lastPointY=a,this},catmullRomTo(...t){return function(t,i,e){for(var s=e.length,h=[e[s-2]],a=[e[s-1]],r=0,o=t.length;r<o;r+=2)h.push(t[r]),a.push(t[r+1]);r=1;for(var l=i-1;r<=l;r++){var n=r/l;e.push(k(h,n),k(a,n))}}(t,this.iterations,this.pathData),this.lastPointX=t[t.length-2],this.lastPointY=t[t.length-1],this},close(){var t=this.pathData[0],i=this.pathData[1];return t===this.lastPointX&&i===this.lastPointY||this.lineTo(t,i),this.closePath=!0,this},end(){return D(this.pathData),this}};const m=Phaser.Math.RotateAround,C=Phaser.Math.DegToRad;Phaser.Math.RotateAround;var _={rotateAround(t,i,e){if(0===this.pathData.length)return this;!function(t,i,e,s){for(var h={x:0,y:0},a=0,r=s.length-1;a<r;a+=2)h.x=s[a],h.y=s[a+1],m(h,t,i,e),s[a]=h.x,s[a+1]=h.y}(t,i,e=C(e),this.pathData);var s=this.pathData.length;return this.lastPointX=this.pathData[s-2],this.lastPointY=this.pathData[s-1],this},scale(t,i,e,s){return 0===this.pathData.length||(function(t,i,e,s,h){for(var a=0,r=h.length-1;a<r;a+=2){var o=h[a]-t,l=h[a+1]-i;o*=e,l*=s,h[a]=o+t,h[a+1]=l+i}}(t,i,e,s,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1]),this},offset(t,i){return function(t,i,e){for(var s=0,h=e.length-1;s<h;s+=2)e[s]+=t,e[s+1]+=i}(t,i,this.pathData),this}},T={savePathData(){return this.pathDataSaved||(this.pathDataSave=[...this.pathData],this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData(){return this.pathDataSaved?(function(t,i,e,s){void 0===e&&(e=0),void 0===s&&(s=i.length),t.length=s-e;for(var h=0,a=t.length;h<a;h++)t[h]=i[h+e]}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}};const x=Phaser.Math.Distance.Between,z=Phaser.Math.Wrap,L=Phaser.Math.Linear;var w=function(t,i,e,s,h){if(void 0===s&&(s=e,e=0),(e=O(e))!==(s=O(s))){var a=i[i.length-1],r=a*e,o=a*s;e<s?R(t,i,r,o,h):(R(t,i,r,a,h),R(t,i,0,o,h)),D(h)}},R=function(t,i,e,s,h){for(var a=e>0,r=0,o=i.length;r<o;r++){var l=2*r,n=i[r];if(a){if(n<e)continue;if(n==e)a=!1;else{var d=1-(n-e)/(n-i[r-1]);h.push(W(t,l-2,l,d)),h.push(W(t,l-1,l+1,d)),a=!1}}if(!(n<=s)){d=1-(n-s)/(n-i[r-1]),h.push(W(t,l-2,l,d)),h.push(W(t,l-1,l+1,d));break}if(h.push(t[l]),h.push(t[l+1]),n===s)break}},W=function(t,i,e,s){var h=t[i],a=t[e];return L(h,a,s)},O=function(t){return 0===t?0:t%1==0?1:z(t,0,1)},G={updateAccumulationLengths(){if(null==this.accumulationLengths)this.accumulationLengths=[];else if(this.accumulationLengths.length===this.pathData.length/2)return this;for(var t,i,e,s,h=this.accumulationLengths,a=this.pathData,r=0,o=0,l=a.length;o<l;o+=2)e=a[o],s=a[o+1],r+=void 0===t?0:x(t,i,e,s),h.push(r),t=e,i=s;return this.totalPathLength=r,this},setDisplayPathSegment(t,i){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,w(this.pathDataSave,this.accumulationLengths,t,i,this.pathData),this},appendFromPathSegment(t,i,e){return void 0===i?this.pathData.push(...t.pathData):(t.updateAccumulationLengths(),w(t.pathData,t.accumulationLengths,i,e,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}},j={draw(t,i,e){var s=this.toPoints();return i&&t.fillPoints(s,this.closePath,this.closePath),e&&t.strokePoints(s,this.closePath,this.closePath),this}};const X=Phaser.Geom.Polygon;class Y{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,i){void 0===i&&(i=[]);for(var e=0,s=t.length-1;e<s;e+=2)i.push({x:t[e],y:t[e+1]});return i}(this.pathData)}toPolygon(t){return function(t,i){return void 0===i&&(i=new X),i.setTo(t),i}(this.pathData,t)}}Object.assign(Y.prototype,A,_,T,G,j);class F extends y{constructor(){super(),this.builder=new Y(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,i){return this.builder.startAt(t,i),this.dirty=!0,this}lineTo(t,i,e){return this.builder.lineTo(t,i,e),this.dirty=!0,this}verticalLineTo(t,i){return this.builder.verticalLineTo(t,i),this.dirty=!0,this}horizontalLineTo(t,i){return this.builder.horizontalLineTo(t,i),this.dirty=!0,this}ellipticalArc(t,i,e,s,h,a,r){return this.builder.ellipticalArc(t,i,e,s,h,a,r),this.dirty=!0,this}arc(t,i,e,s,h,a){return this.builder.arc(t,i,e,s,h,a),this.dirty=!0,this}quadraticBezierTo(t,i,e,s){return this.builder.quadraticBezierTo(t,i,e,s),this.dirty=!0,this}cubicBezierTo(t,i,e,s,h,a){return this.builder.cubicBezierTo(t,i,e,s,h,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,i,e){return this.builder.rotateAround(t,i,e),this.dirty=!0,this}scale(t,i,e,s){return this.builder.scale(t,i,e,s),this.dirty=!0,this}offset(t,i){return this.builder.offset(t,i),this.dirty=!0,this}toPolygon(t){return this.builder.toPolygon(t)}appendPathFrom(t,i,e){return this.builder.appendFromPathSegment(t.builder,i,e),this}copyPathFrom(t,i,e){return this.builder.clear().appendFromPathSegment(t.builder,i,e),this}setDisplayPathSegment(t,i){return this.builder.setDisplayPathSegment(t,i),this}}Phaser.Renderer.WebGL.Utils,Phaser.Utils.Objects.GetValue,Phaser.Renderer.WebGL.Utils;var M=function(t){var i=this.points,e=i[1],s=i[2];t.startAt(0,0).quadraticBezierTo(e.x,e.y,s.x,s.y).end()},B=function(t){var i=this.points,e=i[1],s=i[2],h=i[3];t.startAt(0,0).cubicBezierTo(e.x,e.y,s.x,s.y,h.x,h.y).end()},I=function(t){for(var i=this.points,e=[],s=1,h=i.length;s<h;s++){var a=i[s];e.push(a.x),e.push(a.y)}t.startAt(0,0).catmullRomTo(...e).end()},H=function(t){var i=this.points,e=i[i.length-1];t.startAt(0,0).lineTo(e.x,e.y).end()},N=function(t){var i=this.points;t.startAt(0,0);for(var e=1,s=i.length;e<s;e++){var h=i[e];t.lineTo(h.x,h.y)}t.end()};const U=Phaser.Geom.Rectangle;var V=function(t,i){switch(void 0===i?i=new U:!0===i&&(i=q),t.length){case 0:i.setTo(0,0,0,0);break;case 2:i.setTo(t[0],t[1],0,0);break;default:for(var e=1/0,s=1/0,h=-e,a=-s,r=0,o=t.length;r<o;r+=2){var l=t[r],n=t[r+1];e=Math.min(e,l),s=Math.min(s,n),h=Math.max(h,l),a=Math.max(a,n)}i.setTo(e,s,h-e,a-s)}return i},q=new U,E=function(t,i,e,s,h,a,r){var o=a/2;switch(r){case 1:var l,n;if(i===s&&e===h)l=1,n=0;else{l=i-s,n=e-h;var d=Math.hypot(l,n);l/=d,n/=d}var u=-n,p=i-l*a,c=e-n*a,v=a/2,g=p+u*v,y=c+l*v,S=p-u*v,f=c-l*v;t.startAt(i,e).lineTo(g,y).lineTo(S,f).close();break;case 2:default:t.start().arc(i,e,o,0,360).close();break;case 3:t.startAt(i-o,e-o).lineTo(a,0,!0).lineTo(0,a,!0).lineTo(-a,0,!0).lineTo(0,-a,!0).close();break;case 4:t.startAt(i,e-o).lineTo(i+o,e).lineTo(i,e+o).lineTo(i-o,e).close()}},Q=function(){var t=this.bounds,i=this.pointRadius,e=t.x-i,s=t.y-i,h=t.width+2*i,a=t.height+2*i;this.setSize(h,a),this.setOrigin(-e/h,-s/a);for(var r=this.getShapes(),o=0,l=r.length;o<l;o++){var n=r[o];n.visible&&n.offset(-e,-s)}},J={buildShapes(){var t=(new F).setName("body"),i=(new F).setName("head"),e=(new F).setName("tail");this.addShape(t).addShape(i).addShape(e)},updateShapes(){var t=this.points.length,i=t>=2,e=this.getShape("body").setVisible(i);i&&(e.lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),3===this.lineType||2==t?H.call(this,e):0===this.lineType&&3===t?M.call(this,e):0===this.lineType&&4===t?B.call(this,e):2===this.lineType?N.call(this,e):I.call(this,e));var s=t>=1,h=s&&0!==this.headShape,a=s&&0!==this.tailShape,r=this.getShape("head").setVisible(h),o=this.getShape("tail").setVisible(a);if(h){r.fillStyle(this.headColor,this.headAlpha).lineStyle(this.headStrokeWidth,this.headStrokeColor,this.headStrokeAlpha);var l=this.points[0];n=t>=2?3===this.lineType?this.points[t-1]:this.points[1]:l,E(r,l.x,l.y,n.x,n.y,this.headSize,this.headShape)}if(a){o.fillStyle(this.tailColor,this.tailAlpha).lineStyle(this.tailStrokeWidth,this.tailStrokeColor,this.tailStrokeAlpha);var n,d=this.points[t-1];n=3===this.lineType?this.points[0]:this.points[t-2],E(o,d.x,d.y,n.x,n.y,this.tailSize,this.tailShape)}this.bounds=V.call(this,e.pathData,!0),Q.call(this)}};const K=Phaser.Geom.Intersects.LineToCircle,Z=new Phaser.Geom.Line,$=Phaser.Geom.Rectangle,tt=Phaser.Geom.Rectangle.Contains,it=Phaser.GameObjects.GameObject.prototype.setInteractive,et=new Phaser.Geom.Circle;var st=function(t,i,e,s){return!!tt(t,i,e)&&(et.setTo(i,e,s.pointRadius),function(t,i){Z.x1=t[0],Z.y1=t[1];for(var e=2,s=t.length;e<s;e+=2){if(Z.x2=t[e],Z.y2=t[e+1],K(Z,i))return!0;Z.x1=Z.x2,Z.y1=Z.y2}return!1}(s.getShapes()[0].pathData,et))},ht={setPointRadius(t){return this.pointRadius=t,this},setInteractive(t){return void 0===t&&(t={}),t.hitArea=new $(0,0,this.width,this.height),t.hitAreaCallback=st,it.call(this,t),this}},at={};Object.assign(at,n,J,ht);class rt extends r{constructor(t,i,e,s,h,a){var r,o,l,n,d,u,p,c,v,g,y,S,f,P,b,k;void 0!==i&&("number"==typeof i?(r=h,h=s,s=e,e=i,i=[]):Array.isArray(i)||(i=(a=i).points,e=a.lineWidth,s=a.color,h=a.alpha)),void 0===a&&(a={}),r=a.lineType,o=a.pointRadius,l=a.headShape,n=a.headSize,d=a.headColor,u=a.headAlpha,p=a.headStrokeWidth,c=a.headStrokeColor,v=a.headStrokeAlpha,g=a.tailShape,y=a.tailSize,S=a.tailColor,f=a.tailAlpha,P=a.tailStrokeWidth,b=a.tailStrokeColor,k=a.tailStrokeAlpha,void 0===i&&(i=[]),void 0===e&&(e=2),void 0===s&&(s=16777215),void 0===h&&(h=1),void 0===r&&(r=0),void 0===o&&(o=10),void 0===l&&(l=0),void 0===n&&(n=4*e),void 0===d&&(d=s),void 0===p&&(p=1),void 0===g&&(g=0),void 0===y&&(y=n),void 0===S&&(S=s),void 0===P&&(P=1),super(t),this.type="rexLine",this.points=[],this.padding={},this.bounds=void 0,this.setPointRadius(o),this.setLine(i,r),this.setStrokeStyle(e,s,h),this.setHeadShape(l),this.setHeadSize(n),this.setHeadFillStyle(d,u),this.setHeadStrokeStyle(p,c,v),this.setTailShape(g),this.setTailSize(y),this.setTailFillStyle(S,f),this.setTailStrokeStyle(P,b,k),this.buildShapes(),this.updateData()}setLine(t,i){void 0===t&&(t=[]),void 0!==i&&("string"==typeof i&&(i=o[i.toLocaleLowerCase()]),this.lineType=i),this.points.length=0;var e=0,s=0;t.length>0&&(e=t[0].x,s=t[0].y),this.x=e,this.y=s;for(var h=0,a=t.length;h<a;h++){var r=t[h];this.points.push({x:r.x-e,y:r.y-s})}return this.dirty=!0,this.geom.length>0&&this.updateData(),this}setLineType(t){return"string"==typeof t&&(t=o[t.toLocaleLowerCase()]),this.lineType===t||(this.lineType=t,this.dirty=!0,this.geom.length>0&&this.updateData()),this}getPoints(t){void 0===t&&(t=[]);for(var i=this.x,e=this.y,s=this.points,h=0,a=s.length;h<a;h++){var r=s[h];t.push({x:r.x+i,y:r.y+e})}return t}get headShape(){return this._headShape}set headShape(t){this.dirty=this.dirty||this._headShape!=t,this._headShape=t}get headSize(){return this._headSize}set headSize(t){this.dirty=this.dirty||this._headSize!=t,this._headSize=t}get headColor(){return this._headColor}set headColor(t){this.dirty=this.dirty||this._headColor!=t,this._headColor=t}get headAlpha(){return this._headAlpha}set headAlpha(t){this.dirty=this.dirty||this._headAlpha!=t,this._headAlpha=t}get headStokeWidth(){return this._headStokeWidth}set headStokeWidth(t){this.dirty=this.dirty||this._headStokeWidth!=t,this._headStokeWidth=t}get headStokeColor(){return this._headStokeColor}set headStokeColor(t){this.dirty=this.dirty||this._headStokeColor!=t,this._headStokeColor=t}get headStokeAlpha(){return this._headStokeAlpha}set headStokeAlpha(t){this.dirty=this.dirty||this._headStokeAlpha!=t,this._headStokeAlpha=t}get tailShape(){return this._tailShape}set tailShape(t){this.dirty=this.dirty||this._tailShape!=t,this._tailShape=t}get tailSize(){return this._tailSize}set tailSize(t){this.dirty=this.dirty||this._tailSize!=t,this._tailSize=t}get tailColor(){return this._tailColor}set tailColor(t){this.dirty=this.dirty||this._tailColor!=t,this._tailColor=t}get tailAlpha(){return this._tailAlpha}set tailAlpha(t){this.dirty=this.dirty||this._tailAlpha!=t,this._tailAlpha=t}get tailStokeWidth(){return this._tailStokeWidth}set tailStokeWidth(t){this.dirty=this.dirty||this._tailStokeWidth!=t,this._tailStokeWidth=t}get tailStokeColor(){return this._tailStokeColor}set tailStokeColor(t){this.dirty=this.dirty||this._tailStokeColor!=t,this._tailStokeColor=t}get tailStokeAlpha(){return this._tailStokeAlpha}set tailStokeAlpha(t){this.dirty=this.dirty||this._tailStokeAlpha!=t,this._tailStokeAlpha=t}}function ot(t,i,e,s,h){var a=new rt(this.scene,t,i,e,s,h);return this.scene.add.existing(a),a}Object.assign(rt.prototype,at);const lt=Phaser.Utils.Objects.GetAdvancedValue,nt=Phaser.Utils.Objects.GetValue,dt=Phaser.GameObjects.BuildGameObject;function ut(t,i){void 0===t&&(t={}),void 0!==i&&(t.add=i);var e=nt(t,"points",void 0),s=lt(t,"lineWidth",2),h=lt(t,"color",16777215),a=lt(t,"alpha",1),r=lt(t,"lineType",0),o=new rt(this.scene,e,s,h,a,r);return dt(this.scene,o,t),o}var pt=function(t){return null==t||""===t||0===t.length};class ct extends Phaser.Plugins.BasePlugin{constructor(t){super(t),t.registerGameObject("rexLineShape",ot,ut)}start(){this.game.events.on("destroy",this.destroy,this)}}return function(t,i,e,s){if(void 0===s&&(s="."),"object"==typeof t)if(pt(i)){if(null==e)return;"object"==typeof e&&(t=e)}else{"string"==typeof i&&(i=i.split(s));var h=i.pop(),a=function(t,i,e){var s=t;if(pt(i));else{var h;"string"==typeof i&&(i=i.split("."));for(var a=0,r=i.length;a<r;a++){var o;null!=s[h=i[a]]&&"object"==typeof s[h]||(o=a===r-1?void 0===e?{}:e:{},s[h]=o),s=s[h]}}return s}(t,i);a[h]=e}}(window,"RexPlugins.GameObjects.LineShape",rt),ct},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).rexlineshapeplugin=i();