UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 36.7 kB
!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).rextriangleplugin=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 h(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 function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function o(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 h(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)}function l(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=new Array(e);i<e;i++)s[i]=t[i];return s}var f=Phaser.GameObjects.GetCalcMatrix,p=Phaser.Renderer.Canvas.SetTransform,d={renderWebGL:function(t,e,i,s){e.updateData(),i.addToRenderList(e);var n=t.pipelines.set(e.pipeline),r=f(e,i,s),a=n.calcMatrix.copyFrom(r.calc),h=e._displayOriginX,o=e._displayOriginY,u=i.alpha*e.alpha;t.pipelines.preBatch(e);for(var l=e.geom,c=0,p=l.length;c<p;c++)l[c].webglRender(n,a,u,h,o);t.pipelines.postBatch(e);},renderCanvas:function(t,e,i,s){e.updateData(),i.addToRenderList(e);var n=t.currentContext;if(p(t,n,e,i,s)){for(var r=e._displayOriginX,a=e._displayOriginY,h=e.geom,o=0,u=h.length;o<u;o++)h[o].canvasRender(n,r,a);n.restore();}}},v=function(e){if("object"!==t(e)||null===e)return e;if(Array.isArray(e))e.length=0;else for(var i in e)delete e[i];return e},y=Phaser.GameObjects.Shape,g=Phaser.Utils.Array.Remove,m=function(t){n(r,t);var i=o(r);function r(t,s,n,a,h){var o;return e(this,r),void 0===s&&(s=0),void 0===n&&(n=0),void 0===a&&(a=2),void 0===h&&(h=a),(o=i.call(this,t,"rexShapes",[]))._width=-1,o._height=-1,o.dirty=!0,o.isSizeChanged=!0,o.shapes={},o.setPosition(s,n),o.setSize(a,h),o.updateDisplayOrigin(),o}return s(r,[{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:"setDirty",value:function(t){return void 0===t&&(t=!0),this.dirty=t,this}},{key:"setSize",value:function(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}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}},{key:"fillColor",get:function(){return this._fillColor},set:function(t){this.setFillStyle(t,this._fillAlpha);}},{key:"fillAlpha",get:function(){return this._fillAlpha},set:function(t){this.setFillStyle(this._fillColor,t);}},{key:"setFillStyle",value:function(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}},{key:"lineWidth",get:function(){return this._lineWidth},set:function(t){this.setStrokeStyle(t,this._strokeColor,this._strokeAlpha);}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this.setStrokeStyle(this._lineWidth,t,this._strokeAlpha);}},{key:"strokeAlpha",get:function(){return this._strokeAlpha},set:function(t){this.setStrokeStyle(this._lineWidth,this._strokeColor,t);}},{key:"setStrokeStyle",value:function(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}},{key:"updateShapes",value:function(){}},{key:"updateData",value:function(){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}},{key:"clear",value:function(){return this.geom.length=0,v(this.shapes),this}},{key:"getShape",value:function(t){return this.shapes[t]}},{key:"getShapes",value:function(){return this.geom}},{key:"addShape",value:function(t){this.geom.push(t);var e=t.name;return e&&(this.shapes[e]=t),this.dirty=!0,this}},{key:"deleteShape",value:function(t){var e=this.getShape(t);return e&&(delete this.shapes[t],g(this.geom,e)),this}}]),r}(y);Object.assign(m.prototype,d);var k={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}},b={enableData:function(){return void 0===this.data&&(this.data={}),this},setData:function(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:function(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var s=e.split("."),n=t,r=i,a=0;a<s.length;a++){if(!n.hasOwnProperty(s[a])){r=i;break}r=n[s[a]],n=n[s[a]];}return r}return i}return i}(this.data,t,e)},incData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData:function(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData:function(){return this.data&&v(this.data),this}},D=function(){function t(){e(this,t),this.name=void 0,this.dirty=!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;}return s(t,[{key:"setName",value:function(t){return this.name=t,this}},{key:"reset",value:function(){return this.fillStyle().lineStyle(),this}},{key:"webglRender",value:function(t,e,i,s,n){}},{key:"canvasRender",value:function(t,e,i){}},{key:"updateData",value:function(){this.dirty=!1;}}]),t}();Object.assign(D.prototype,k,b);var P=Phaser.Renderer.WebGL.Utils,S=Phaser.Renderer.WebGL.Utils,T=Phaser.Geom.Polygon.Earcut,_=function(t){n(a,t);var i=o(a);function a(){var t;return e(this,a),(t=i.call(this)).pathData=[],t.pathIndexes=[],t.closePath=!1,t}return s(a,[{key:"updateData",value:function(){return this.pathIndexes=T(this.pathData),u(r(a.prototype),"updateData",this).call(this),this}},{key:"webglRender",value:function(t,e,i,s,n){this.isFilled&&function(t,e,i,s,n,r){for(var a=P.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*s),h=i.pathData,o=i.pathIndexes,u=0;u<o.length;u+=3){var l=2*o[u],c=2*o[u+1],f=2*o[u+2],p=h[l+0]-n,d=h[l+1]-r,v=h[c+0]-n,y=h[c+1]-r,g=h[f+0]-n,m=h[f+1]-r,k=e.getX(p,d),b=e.getY(p,d),D=e.getX(v,y),S=e.getY(v,y),T=e.getX(g,m),_=e.getY(g,m);t.batchTri(i,k,b,D,S,T,_,0,0,1,1,a,a,a,2);}}(t,e,this,i,s,n),this.isStroked&&function(t,e,i,s,n){var r=t.strokeTint,a=S.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);r.TL=a,r.TR=a,r.BL=a,r.BR=a;var h=e.pathData,o=h.length-1,u=e.lineWidth,l=u/2,c=h[0]-s,f=h[1]-n;e.closePath||(o-=2);for(var p=2;p<o;p+=2){var d=h[p]-s,v=h[p+1]-n;t.batchLine(c,f,d,v,l,l,u,p-2,!!e.closePath&&p===o-1),c=d,f=v;}}(t,this,i,s,n);}},{key:"canvasRender",value:function(t,e,i){var s=this.pathData,n=s.length-1,r=s[0]-e,a=s[1]-i;t.beginPath(),t.moveTo(r,a),this.closePath||(n-=2);for(var h=2;h<n;h+=2){var o=s[h]-e,u=s[h+1]-i;t.lineTo(o,u);}this.closePath&&t.closePath(),this.isFilled&&(!function(t,e,i,s){var n=i||e.fillColor,r=s||e.fillAlpha,a=(16711680&n)>>>16,h=(65280&n)>>>8,o=255&n;t.fillStyle="rgba("+a+","+h+","+o+","+r+")";}(t,this),t.fill()),this.isStroked&&(!function(t,e,i,s){var n=i||e.strokeColor,r=s||e.strokeAlpha,a=(16711680&n)>>>16,h=(65280&n)>>>8,o=255&n;t.strokeStyle="rgba("+a+","+h+","+o+","+r+")",t.lineWidth=e.lineWidth;}(t,this),t.stroke());}}]),a}(D),w=function(t,e,i){var s=i.length;if(s>=2){var n=i[s-2],r=i[s-1];if(t===n&&e===r)return i}return i.push(t,e),i},E=Phaser.Math.DegToRad;Phaser.Math.DegToRad;var C=Phaser.Math.Interpolation.QuadraticBezier,R=Phaser.Math.Interpolation.CubicBezier,O=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},A={clear:function(){return this.start(),this},start:function(){return this.startAt(),this},startAt:function(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:function(t,e,i){return void 0===i&&(i=!1),i&&(t+=this.lastPointX,e+=this.lastPointY),w(t,e,this.pathData),this.lastPointX=t,this.lastPointY=e,this},verticalLineTo:function(t,e){return this.lineTo(t,this.lastPointY,e),this},horizontalLineTo:function(t,e){return this.lineTo(this.lastPointX,t,e),this},ellipticalArc:function(t,e,i,s,n,r,a){return void 0===a&&(a=!1),function(t,e,i,s,n,r,a,h,o){a&&r>n?r-=360:!a&&r<n&&(r+=360);var u=E(r-n)/h;n=E(n);for(var l=0;l<=h;l++){var c=n+u*l,f=t+i*Math.cos(c),p=e+s*Math.sin(c);w(f,p,o);}}(t,e,i,s,n,r,a,this.iterations,this.pathData),this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this},arc:function(t,e,i,s,n,r){return this.ellipticalArc(t,e,i,i,s,n,r),this},quadraticBezierTo:function(t,e,i,s){return function(t,e,i,s,n,r){for(var a=r.length,h=r[a-2],o=r[a-1],u=1,l=n-1;u<=l;u++){var c=u/l;r.push(C(c,h,t,i),C(c,o,e,s));}}(t,e,i,s,this.iterations,this.pathData),this.lastPointX=i,this.lastPointY=s,this.lastCX=t,this.lastCY=e,this},smoothQuadraticBezierTo:function(t,e){var i=2*this.lastPointX-this.lastCX,s=2*this.lastPointY-this.lastCY;return this.quadraticBezierTo(i,s,t,e),this},cubicBezierCurveTo:function(t,e,i,s,n,r){return function(t,e,i,s,n,r,a,h){for(var o=h.length,u=h[o-2],l=h[o-1],c=1,f=a-1;c<=f;c++){var p=c/f;h.push(R(p,u,t,i,n),R(p,l,e,s,r));}}(t,e,i,s,n,r,this.iterations,this.pathData),this.lastPointX=n,this.lastPointY=r,this.lastCX=i,this.lastCY=s,this},smoothCubicBezierCurveTo:function(t,e,i,s){var n=2*this.lastPointX-this.lastCX,r=2*this.lastPointY-this.lastCY;return this.cubicBezierCurveTo(n,r,t,e,i,s),this},close:function(){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:function(){return O(this.pathData),this}},j=Phaser.Math.RotateAround,x=Phaser.Math.DegToRad,L=Phaser.Math.RotateAround,M={rotateAround:function(t,e,i){if(0===this.pathData.length)return this;!function(t,e,i,s){for(var n={x:0,y:0},r=0,a=s.length-1;r<a;r+=2)n.x=s[r],n.y=s[r+1],j(n,t,e,i),s[r]=n.x,s[r+1]=n.y;}(t,e,i=x(i),this.pathData);var s=this.pathData.length;if(this.lastPointX=this.pathData[s-2],this.lastPointY=this.pathData[s-1],void 0!==this.lastCX){var n={x:this.lastCX,y:this.lastCY};L(n,t,e,i),this.lastCX=n.x,this.lastCY=n.y;}return this},scale:function(t,e,i,s){if(0===this.pathData.length)return this;if(function(t,e,i,s,n){for(var r=0,a=n.length-1;r<a;r+=2){var h=n[r]-t,o=n[r+1]-e;h*=i,o*=s,n[r]=h+t,n[r+1]=o+e;}}(t,e,i,s,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1],void 0!==this.lastCX){var n=this.lastCX-t,r=this.lastCY-e;n*=i,r*=s,this.lastCX=n+t,this.lastCY=r+e;}return this},offset:function(t,e){return function(t,e,i){for(var s=0,n=i.length-1;s<n;s+=2)i[s]+=t,i[s+1]+=e;}(t,e,this.pathData),this}},X={savePathData:function(){return this.pathDataSaved||(this.pathDataSave=l(this.pathData),this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData:function(){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 n=0,r=t.length;n<r;n++)t[n]=e[n+i];}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}},Y=Phaser.Math.Distance.Between,z=Phaser.Math.Wrap,G=Phaser.Math.Linear,F=function(t,e,i,s,n){if(void 0===s&&(s=i,i=0),(i=N(i))!==(s=N(s))){var r=e[e.length-1],a=r*i,h=r*s;i<s?B(t,e,a,h,n):(B(t,e,a,r,n),B(t,e,0,h,n)),O(n);}},B=function(t,e,i,s,n){for(var r=i>0,a=0,h=e.length;a<h;a++){var o=2*a,u=e[a];if(r){if(u<i)continue;if(u==i)r=!1;else {var l=1-(u-i)/(u-e[a-1]);n.push(W(t,o-2,o,l)),n.push(W(t,o-1,o+1,l)),r=!1;}}if(!(u<=s)){l=1-(u-s)/(u-e[a-1]);n.push(W(t,o-2,o,l)),n.push(W(t,o-1,o+1,l));break}if(n.push(t[o]),n.push(t[o+1]),u===s)break}},W=function(t,e,i,s){var n=t[e],r=t[i];return G(n,r,s)},N=function(t){return 0===t?0:t%1==0?1:z(t,0,1)},I={updateAccumulationLengths:function(){if(null==this.accumulationLengths)this.accumulationLengths=[];else if(this.accumulationLengths.length===this.pathData.length/2)return this;for(var t,e,i,s,n=this.accumulationLengths,r=this.pathData,a=0,h=0,o=r.length;h<o;h+=2)i=r[h],s=r[h+1],a+=void 0===t?0:Y(t,e,i,s),n.push(a),t=i,e=s;return this.totalPathLength=a,this},setDisplayPathSegment:function(t,e){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,F(this.pathDataSave,this.accumulationLengths,t,e,this.pathData),this},appendFromPathSegment:function(t,e,i){var s;void 0===e?(s=this.pathData).push.apply(s,l(t.pathData)):(t.updateAccumulationLengths(),F(t.pathData,t.accumulationLengths,e,i,this.pathData));return 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}},U=Phaser.Geom.Polygon,V=function(){function t(i){e(this,t),void 0===i&&(i=[]),this.pathData=i,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;}return s(t,[{key:"setIterations",value:function(t){return this.iterations=t,this}},{key:"toPoints",value:function(){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)}},{key:"toPolygon",value:function(t){return function(t,e){return void 0===e&&(e=new U),e.setTo(t),e}(this.pathData,t)}}]),t}();Object.assign(V.prototype,A,M,X,I,{draw:function(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}});var J=function(t){n(r,t);var i=o(r);function r(){var t;return e(this,r),(t=i.call(this)).builder=new V(t.pathData),t}return s(r,[{key:"iterations",get:function(){return this.builder.iterations},set:function(t){this.dirty=this.dirty||this.builder.iterations!==t,this.builder.setIterations(t);}},{key:"setIterations",value:function(t){return this.iterations=t,this}},{key:"lastPointX",get:function(){return this.builder.lastPointX}},{key:"lastPointY",get:function(){return this.builder.lastPointY}},{key:"start",value:function(){return this.builder.start(),this.dirty=!0,this}},{key:"startAt",value:function(t,e){return this.builder.startAt(t,e),this.dirty=!0,this}},{key:"lineTo",value:function(t,e,i){return this.builder.lineTo(t,e,i),this.dirty=!0,this}},{key:"verticalLineTo",value:function(t,e){return this.builder.verticalLineTo(t,e),this.dirty=!0,this}},{key:"horizontalLineTo",value:function(t,e){return this.builder.horizontalLineTo(t,e),this.dirty=!0,this}},{key:"ellipticalArc",value:function(t,e,i,s,n,r,a){return this.builder.ellipticalArc(t,e,i,s,n,r,a),this.dirty=!0,this}},{key:"arc",value:function(t,e,i,s,n,r){return this.builder.arc(t,e,i,s,n,r),this.dirty=!0,this}},{key:"quadraticBezierTo",value:function(t,e,i,s){return this.builder.quadraticBezierTo(t,e,i,s),this.dirty=!0,this}},{key:"smoothQuadraticBezierTo",value:function(t,e){return this.builder.smoothQuadraticBezierTo(t,e),this.dirty=!0,this}},{key:"cubicBezierCurveTo",value:function(t,e,i,s,n,r){return this.builder.cubicBezierCurveTo(t,e,i,s,n,r),this.dirty=!0,this}},{key:"smoothCubicBezierCurveTo",value:function(t,e,i,s){return this.builder.smoothCubicBezierCurveTo(t,e,i,s),this.dirty=!0,this}},{key:"close",value:function(){return this.builder.close(),this.closePath=this.builder.closePath,this.dirty=!0,this}},{key:"end",value:function(){return this.builder.end(),this.dirty=!0,this}},{key:"rotateAround",value:function(t,e,i){return this.builder.rotateAround(t,e,i),this.dirty=!0,this}},{key:"scale",value:function(t,e,i,s){return this.builder.scale(t,e,i,s),this.dirty=!0,this}},{key:"offset",value:function(t,e){return this.builder.offset(t,e),this.dirty=!0,this}},{key:"toPolygon",value:function(t){return this.builder.toPolygon(t)}},{key:"appendPathFrom",value:function(t,e,i){return this.builder.appendFromPathSegment(t.builder,e,i),this}},{key:"copyPathFrom",value:function(t,e,i){return this.builder.clear().appendFromPathSegment(t.builder,e,i),this}},{key:"setDisplayPathSegment",value:function(t,e){return this.builder.setDisplayPathSegment(t,e),this}}]),r}(_);Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha,Phaser.Utils.Objects.GetValue,Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha,Phaser.Math.Wrap;var q=Phaser.Math.Linear,K=function(){var t,e,i,s,n,r,a=this.getShape("triangle"),h=this.padding,o=this.width-h.right,u=0+h.left,l=this.height-h.bottom,c=0+h.top,f=(u+o)/2,p=(c+l)/2,d={0:{a:{x:u,y:c},b:{x:o,y:p},c:{x:u,y:l}},1:{a:{x:u,y:c},b:{x:f,y:l},c:{x:o,y:c}},2:{a:{x:o,y:c},b:{x:u,y:p},c:{x:o,y:l}},3:{a:{x:u,y:l},b:{x:f,y:c},c:{x:o,y:l}}};if(void 0===this.previousDirection){var v=d[this.direction],y=v.a,g=v.b,m=v.c;t=y.x,e=y.y,i=g.x,s=g.y,n=m.x,r=m.y;}else {var k=d[this.previousDirection],b=d[this.direction],D=this.easeDirectionProgress;t=q(k.a.x,b.a.x,D),e=q(k.a.y,b.a.y,D),i=q(k.b.x,b.b.x,D),s=q(k.b.y,b.b.y,D),n=q(k.c.x,b.c.x,D),r=q(k.c.y,b.c.y,D);}a.startAt(t,e).lineTo(i,s).lineTo(n,r),this.arrowOnly?a.end():a.close();},Q=(0, Phaser.Math.DegToRad)(120),H=function(t){t=this.getShape("triangle");var e=this.width/2,i=this.height/2,s=Math.min(e,i)*this.radius,n=this.verticeRotation;t.startAt(e+s*Math.cos(n+Q),i+s*Math.sin(n+Q)).lineTo(e+s*Math.cos(n),i+s*Math.sin(n)).lineTo(e+s*Math.cos(n-Q),i+s*Math.sin(n-Q)),this.arrowOnly?t.end():t.close();},$={buildShapes:function(){this.addShape((new J).setName("triangle"));},updateShapes:function(){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?K.call(this):H.call(this);}},Z={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):[]}},tt=Phaser.Scene,et=function(t){return t instanceof tt},it=Phaser.Game,st=function(t){return t instanceof it},nt=Phaser.Utils.Objects.GetValue,rt=function(){function i(t,s){e(this,i),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(nt(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:et(i)?i:i.scene&&et(i.scene)?i.scene:i.parent&&i.parent.scene&&et(i.parent.scene)?i.parent.scene:null,this.game=function(e){return null==e||"object"!==t(e)?null:st(e)?e:st(e.game)?e.game:et(e)?e.sys.game:et(e.scene)?e.scene.sys.game:void 0}(e),this}}]),i}();Object.assign(rt.prototype,Z);var at=Phaser.Utils.Objects.GetValue,ht=function(t){n(a,t);var i=o(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(at(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=ot[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}(rt),ot={no:0,lazy:1,always:2},ut=Phaser.Utils.Objects.GetValue,lt=function(t){n(a,t);var i=o(a);function a(t,s){var n;e(this,a);var r=(n=i.call(this,t,s)).scene?"update":"step";return n.tickEventName=ut(s,"tickEventName",r),n.isSceneTicker=!ct(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}(ht),ct=function(t){return "step"===t||"poststep"===t},ft=Phaser.Utils.Objects.GetValue,pt=Phaser.Math.Clamp,dt=function(){function t(i){e(this,t),this.resetFromJSON(i);}return s(t,[{key:"resetFromJSON",value:function(t){this.state=ft(t,"state",vt),this.timeScale=ft(t,"timeScale",1),this.delay=ft(t,"delay",0),this.repeat=ft(t,"repeat",0),this.repeatCounter=ft(t,"repeatCounter",0),this.repeatDelay=ft(t,"repeatDelay",0),this.duration=ft(t,"duration",0),this.nowTime=ft(t,"nowTime",0),this.justRestart=ft(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?gt:yt,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=vt,this}},{key:"update",value:function(t,e){this.state!==vt&&this.state!==kt&&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=mt)):(this.nowTime=this.duration,this.state=kt):this.nowTime>=0&&(this.state=gt));}},{key:"t",get:function(){var t;switch(this.state){case vt:case yt:case mt:t=0;break;case gt:t=this.nowTime/this.duration;break;case kt:t=1;}return pt(t,0,1)},set:function(t){(t=pt(t,-1,1))<0?(this.state=yt,this.nowTime=-this.delay*t):(this.state=gt,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===vt}},{key:"isDelay",get:function(){return this.state===yt}},{key:"isCountDown",get:function(){return this.state===gt}},{key:"isRunning",get:function(){return this.state===yt||this.state===gt}},{key:"isDone",get:function(){return this.state===kt}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),t}(),vt=0,yt=1,gt=2,mt=3,kt=-1,bt=function(t){n(a,t);var i=o(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s)).timer=new dt,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}(lt),Dt=Phaser.Utils.Objects.GetValue,Pt=Phaser.Utils.Objects.GetAdvancedValue,St=Phaser.Tweens.Builders.GetEaseFunction,Tt=function(t){n(a,t);var i=o(a);function a(){return e(this,a),i.apply(this,arguments)}return s(a,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(Dt(t,"timer")),this.setEnable(Dt(t,"enable",!0)),this.setTarget(Dt(t,"target",this.parent)),this.setDelay(Pt(t,"delay",0)),this.setDuration(Pt(t,"duration",1e3)),this.setEase(Dt(t,"ease","Linear")),this.setRepeat(Dt(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=St(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}(bt),_t=Phaser.Utils.Objects.GetValue,wt=Phaser.Math.Linear,Et=function(t){n(a,t);var i=o(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=_t(t,"key","value");var i=e[this.propertyKey];return this.fromValue=_t(t,"from",i),this.toValue=_t(t,"to",i),this.setEase(_t(t,"ease",this.ease)),this.setDuration(_t(t,"duration",this.duration)),this.setRepeat(_t(t,"repeat",0)),this.setDelay(_t(t,"delay",0)),this.setRepeatDelay(_t(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]=wt(this.fromValue,this.toValue,i);}}]),a}(Tt),Ct={setEaseDuration:function(t){return void 0===t&&(t=0),this.easeDuration=t,this},playEaseDirectionation:function(){return void 0===this.easeDirectionProgressTask&&(this.easeDirectionProgressTask=new Et(this,{eventEmitter:null})),this.easeDirectionProgressTask.restart({key:"easeDirectionProgress",from:0,to:1,duration:this.easeDuration}),this},stopEaseDirection:function(){return void 0===this.easeDirectionProgressTask||this.easeDirectionProgressTask.stop(),this}},Rt=Phaser.Utils.Objects.GetValue,Ot=Phaser.Utils.Objects.IsPlainObject,At=Phaser.Math.DegToRad,jt=Phaser.Math.RadToDeg,xt=function(i){n(a,i);var r=o(a);function a(t,i,s,n,h,o,u){var l,c,f,p,d,v,y,g,m;if(e(this,a),Ot(i)){var k=i;i=k.x,s=k.y,n=k.width,h=k.height,o=k.color,u=k.alpha,c=k.strokeColor,f=k.strokeAlpha,p=k.strokeWidth,d=k.arrowOnly,v=k.direction,y=k.easeDuration,g=k.padding,m=k.radius;}return void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=1),void 0===h&&(h=n),void 0===d&&(d=!1),void 0===v&&(v=0),void 0===y&&(y=0),void 0===g&&(g=0),void 0===m&&(m=void 0),(l=r.call(this,t,i,s,n,h)).type="rexTriangle",l.setFillStyle(o,u),void 0!==c&&void 0===p&&(p=2),l.setStrokeStyle(p,c,f),l.setArrowOnly(d),l.setDirection(v,y),l.setPadding(g),l.setRadius(m),l.buildShapes(),l}return s(a,[{key:"arrowOnly",get:function(){return this._arrowOnly},set:function(t){this.dirty=this.dirty||this._arrowOnly!=t,this._arrowOnly=t;}},{key:"setArrowOnly",value:function(t){return void 0===t&&(t=!0),this.arrowOnly=t,this}},{key:"direction",get:function(){return this._direction},set:function(t){t=Mt(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());}},{key:"setDirection",value:function(t,e){return void 0!==e&&this.setEaseDuration(e),this.direction=t,this}},{key:"toggleDirection",value:function(t){return this.setDirection(this.direction+2,t),this}},{key:"easeDirectionProgress",get:function(){return this._easeDirectionProgress},set:function(t){this._easeDirectionProgress!==t&&(this._easeDirectionProgress=t,this.dirty=!0);}},{key:"setPadding",value:function(e,i,s,n){if("object"===t(e)){var r=e,a=Rt(r,"x",null);null!==a?(e=a,s=a):(e=Rt(r,"left",0),s=Rt(r,"right",e));var h=Rt(r,"y",null);null!==h?(i=h,n=h):(i=Rt(r,"top",0),n=Rt(r,"bottom",i));}else void 0===e&&(e=0),void 0===i&&(i=e),void 0===s&&(s=e),void 0===n&&(n=i);return void 0===this.padding&&(this.padding={}),this.dirty=this.dirty||this.padding.left!=e||this.padding.top!=i||this.padding.right!=s||this.padding.bottom!=n,this.padding.left=e,this.padding.top=i,this.padding.right=s,this.padding.bottom=n,this.setRadius(),this}},{key:"radius",get:function(){return this._radius},set:function(t){this.dirty=this.dirty||this._radius!=t,this._radius=t;}},{key:"setRadius",value:function(t){return this.radius=t,this.shapeMode=null==t?0:1,this}},{key:"verticeRotation",get:function(){return this._verticeRotation},set:function(t){this.dirty=this.dirty||this._verticeRotation!=t,this._verticeRotation=t;}},{key:"setVerticeRotation",value:function(t){return this.verticeRotation=t,this}},{key:"verticeAngle",get:function(){return jt(this.verticeRotation)},set:function(t){this.verticeRotation=At(t);}},{key:"setVerticeAngle",value:function(t){return this.verticeAngle=t,this}}]),a}(m),Lt={right:0,down:1,left:2,up:3},Mt=function(t){return "string"==typeof t&&(t=Lt[t]),t%=4};function Xt(t,e,i,s,n,r){var a=new xt(this.scene,t,e,i,s,n,r);return this.scene.add.existing(a),a}Object.assign(xt.prototype,$,Ct);var Yt=Phaser.GameObjects.BuildGameObject;function zt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new xt(this.scene,t);return Yt(this.scene,i,t),i}var Gt=function(t){return null==t||""===t||0===t.length},Ft=function(t){n(r,Phaser.Plugins.BasePlugin);var i=o(r);function r(t){var s;return e(this,r),s=i.call(this,t),t.registerGameObject("rexTriangle",Xt,zt),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(Gt(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(Gt(i));else {var r;"string"==typeof i&&(i=i.split("."));for(var a=0,h=i.length;a<h;a++){var o;null!=n[r=i[a]]&&"object"===t(n[r])||(o=a===h-1?void 0===s?{}:s:{},n[r]=o),n=n[r];}}return n}(e,i);a[r]=s;}}}(window,"RexPlugins.GameObjects.Triangle",xt),Ft}));