/** * Phaser Arcade Slopes v0.3.1 * * A Phaser plugin that brings sloped tile collision handling to Phaser's Arcade Physics engine * * @copyright 2016-2018 Chris Andrew * @license MIT * @see https://github.com/hexus/phaser-arcade-slopes */ Phaser.Plugin.ArcadeSlopes=function(e,o,t){Phaser.Plugin.call(this,e,o);var l={};l[Phaser.Plugin.ArcadeSlopes.SAT]=new Phaser.Plugin.ArcadeSlopes.SatSolver,this.facade=new Phaser.Plugin.ArcadeSlopes.Facade(new Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,l,t||Phaser.Plugin.ArcadeSlopes.SAT),this.facade.plugin=this},Phaser.Plugin.ArcadeSlopes.prototype=Object.create(Phaser.Plugin.prototype),Phaser.Plugin.ArcadeSlopes.prototype.constructor=Phaser.Plugin.ArcadeSlopes,Phaser.Plugin.ArcadeSlopes.VERSION="0.3.1",Phaser.Plugin.ArcadeSlopes.SAT="sat",Phaser.Plugin.ArcadeSlopes.prototype.init=function(){this.game.slopes=this.game.slopes||this.facade,this.originalCollideSpriteVsTilemapLayer=Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer,Phaser.Physics.Arcade.prototype.collideSpriteVsTile=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile,Phaser.Physics.Arcade.prototype.collideSpriteVsTiles=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles,Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer=Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTilemapLayer,Phaser.Tilemap.prototype.getTileTopLeft=Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopLeft,Phaser.Tilemap.prototype.getTileTopRight=Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight,Phaser.Tilemap.prototype.getTileBottomLeft=Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft,Phaser.Tilemap.prototype.getTileBottomRight=Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomRight,this.originalRenderDebug=Phaser.TilemapLayer.prototype.renderDebug,Phaser.TilemapLayer.prototype.getCollisionOffsetX=Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetX,Phaser.TilemapLayer.prototype.getCollisionOffsetY=Phaser.Plugin.ArcadeSlopes.Overrides.getCollisionOffsetY,Phaser.TilemapLayer.prototype.renderDebug=Phaser.Plugin.ArcadeSlopes.Overrides.renderDebug},Phaser.Plugin.ArcadeSlopes.prototype.destroy=function(){this.game.slopes=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTile=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTiles=null,Phaser.Physics.Arcade.prototype.collideSpriteVsTilemapLayer=this.originalCollideSpriteVsTilemapLayer,Phaser.Tilemap.prototype.getTileTopLeft=null,Phaser.Tilemap.prototype.getTileTopRight=null,Phaser.Tilemap.prototype.getTileBottomLeft=null,Phaser.Tilemap.prototype.getTileBottomRight=null,Phaser.TilemapLayer.prototype.getCollisionOffsetX=null,Phaser.TilemapLayer.prototype.getCollisionOffsetY=null,Phaser.TilemapLayer.prototype.renderDebug=this.originalRenderDebug,Phaser.Plugin.prototype.destroy.call(this)},Phaser.Plugin.ArcadeSlopes.Facade=function(e,o,t){this.factory=e,this.solvers=o,this.defaultSolver=t||Phaser.Plugin.ArcadeSlopes.SAT,this.plugin=null},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enable=function(e){if(Array.isArray(e))for(var o=0;o0&&this.enable(e.children))},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enableBody=function(e){e.isCircle?e.polygon=new SAT.Circle(new SAT.Vector(e.x+e.halfWidth,e.y+e.halfHeight),e.radius):e.polygon=new SAT.Box(new SAT.Vector(e.x,e.y),e.width*e.sprite.scale.x,e.height*e.sprite.scale.y).toPolygon(),e.slopes=e.slopes||{debug:!1,friction:new Phaser.Point,preferY:!1,pullUp:0,pullDown:0,pullLeft:0,pullRight:0,pullTopLeft:0,pullTopRight:0,pullBottomLeft:0,pullBottomRight:0,sat:{response:null},skipFriction:!1,tile:null,velocity:new SAT.Vector}},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemap=function(e,o,t,l){return this.factory.convertTilemap(e,o,t,l)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemapLayer=function(e,o,t){return this.factory.convertTilemapLayer(e,o,t)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.collide=function(e,o,t,l,r){return this.solvers.sat.collide(e,o,t,l,r)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.resetCollision=function(e){e.touching.none=!0,e.touching.up=!1,e.touching.down=!1,e.touching.left=!1,e.touching.right=!1,e.blocked.none=!0,e.blocked.up=!1,e.blocked.down=!1,e.blocked.left=!1,e.blocked.right=!1,e.overlapX=0,e.overlapY=0,e.slopes&&(e.slopes.sat.response=null)},Object.defineProperty(Phaser.Plugin.ArcadeSlopes.Facade.prototype,"preferY",{get:function(){return this.solvers.sat.options.preferY},set:function(e){this.solvers.sat.options.preferY=!!e}}),Object.defineProperty(Phaser.Plugin.ArcadeSlopes.Facade.prototype,"heuristics",{get:function(){return this.solvers.sat.options.restrain},set:function(e){this.solvers.sat.options.restrain=!!e}}),Phaser.Plugin.ArcadeSlopes.Overrides={},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile=function(e,o,t,l,r,i,s,p){if(!o.body||!t||!l)return!1;if(t.hasOwnProperty("slope")){if(this.game.slopes.collide(e,o.body,t,l,p))return this._total++,r&&r.call(s,o,t),!0}else if(this.separateTile(e,o.body,t,l,p))return this._total++,r&&r.call(s,o,t),!0;return!1},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles=function(e,o,t,l,r,i,s){if(!(e.body&&o&&o.length&&t))return!1;for(var p=!1,n=0;n0&&t>0?this.layers[e].data[t-1][o-1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight=function(e,o,t){return o0?this.layers[e].data[t-1][o+1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft=function(e,o,t){return o>0&&t=0;E++,L--,v+=h){E>=n&&(E-=n);var M=this.layer.data[E];for(_=Q,O=f-A,R=G;O>=0;_++,O--,R+=a){_>=p&&(_-=p);var Y=M[_];if(Y&&!(Y.index<0)&&Y.collides&&(this.debugSettings.collidingTileOverfill&&(t.fillStyle=this.debugSettings.collidingTileOverfill,t.fillRect(R,v,P,u)),this.debugSettings.facingEdgeStroke&&(t.beginPath(),t.lineWidth=1,t.strokeStyle=this.debugSettings.facingEdgeStroke,Y.faceTop&&(t.moveTo(R,v),t.lineTo(R+P,v)),Y.faceBottom&&(t.moveTo(R,v+u),t.lineTo(R+P,v+u)),Y.faceLeft&&(t.moveTo(R,v),t.lineTo(R,v+u)),Y.faceRight&&(t.moveTo(R+P,v),t.lineTo(R+P,v+u)),t.closePath(),t.stroke(),Y.slope))){if(this.debugSettings.slopeEdgeStroke||this.debugSettings.slopeFill){for(t.beginPath(),t.lineWidth=1,I=Y.slope.polygon,t.moveTo(R+I.points[0].x*i,v+I.points[0].y*s),m=0;m0||o.overlapV.y>0&&e.velocity.y<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldPreferY=function(e,o){return(this.options.preferY||e.slopes.preferY)&&0!==o.overlapV.y&&0!==o.overlapV.x&&Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY(e,o)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.separate=function(e,o,t,l){return!(!l&&!this.shouldSeparate(o.index,e,o,t))&&(!(o.collisionCallback&&!o.collisionCallback.call(o.collisionCallbackContext,e.sprite,o))&&(!(o.layer.callbacks[o.index]&&!o.layer.callbacks[o.index].callback.call(o.layer.callbacks[o.index].callbackContext,e.sprite,o))&&(this.shouldPreferY(e,t)?e.position.y+=Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY(t.overlapV):(e.position.x+=t.overlapV.x,e.position.y+=t.overlapV.y),!0)))},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.applyVelocity=function(e,o,t){var l=this.vectorPool.pop().copy(e.slopes.velocity).projectN(t.overlapN),r=this.vectorPool.pop().copy(e.slopes.velocity).sub(l);l.x=l.x*-e.bounce.x,l.y=l.y*-e.bounce.y,r.x=r.x*(1-e.slopes.friction.x-o.slope.friction.x),r.y=r.y*(1-e.slopes.friction.y-o.slope.friction.y),e.velocity.x=l.x+r.x,e.velocity.y=l.y+r.y,this.pull(e,t),this.vectorPool.push(l,r)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.updateValues=function(e){e.polygon.pos.x=e.x,e.polygon.pos.y=e.y,e.slopes.velocity.x=e.velocity.x,e.slopes.velocity.y=e.velocity.y},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.updateFlags=function(e,o){e.touching.up=e.touching.up||o.overlapV.y>0,e.touching.down=e.touching.down||o.overlapV.y<0,e.touching.left=e.touching.left||o.overlapV.x>0,e.touching.right=e.touching.right||o.overlapV.x<0,e.touching.none=!(e.touching.up||e.touching.down||e.touching.left||e.touching.right),e.blocked.up=e.blocked.up||0===o.overlapV.x&&o.overlapV.y>0,e.blocked.down=e.blocked.down||0===o.overlapV.x&&o.overlapV.y<0,e.blocked.left=e.blocked.left||0===o.overlapV.y&&o.overlapV.x>0,e.blocked.right=e.blocked.right||0===o.overlapV.y&&o.overlapV.x<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.pull=function(e,o){if(!(e.slopes.pullUp||e.slopes.pullDown||e.slopes.pullLeft||e.slopes.pullRight||e.slopes.pullTopLeft||e.slopes.pullTopRight||e.slopes.pullBottomLeft||e.slopes.pullBottomRight))return!1;var t=o.overlapN.clone().scale(-1);return e.slopes.pullUp&&t.y<0?(pullUp=t.clone().scale(e.slopes.pullUp),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullDown&&t.y>0?(pullDown=t.clone().scale(e.slopes.pullDown),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullLeft&&t.x<0?(pullLeft=t.clone().scale(e.slopes.pullLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullRight&&t.x>0?(pullRight=t.clone().scale(e.slopes.pullRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):e.slopes.pullTopLeft&&t.x<0&&t.y<0?(pullUp=t.clone().scale(e.slopes.pullTopLeft),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullTopRight&&t.x>0&&t.y<0?(pullDown=t.clone().scale(e.slopes.pullTopRight),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullBottomLeft&&t.x<0&&t.y>0?(pullLeft=t.clone().scale(e.slopes.pullBottomLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):!!(e.slopes.pullBottomRight&&t.x>0&&t.y>0)&&(pullRight=t.clone().scale(e.slopes.pullBottomRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldCollide=function(e,o){return e.enable&&e.polygon&&e.slopes&&o.collides&&o.slope&&o.slope.polygon},Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn=function(e,o,t){for(var l=Number.MAX_VALUE,r=-Number.MAX_VALUE,i=e.length,s=0;sr&&(r=p)}t[0]=l,t[1]=r},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.isSeparatingAxis=function(e,o,t,l){var r=e.pos,i=o.pos,s=e.calcPoints,p=o.calcPoints,n=this.arrayPool.pop(),a=this.arrayPool.pop(),h=this.vectorPool.pop().copy(i).sub(r),c=h.dot(t);if(Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn(s,t,n),Phaser.Plugin.ArcadeSlopes.SatSolver.flattenPointsOn(p,t,a),a[0]+=c,a[1]+=c,n[0]>=a[1]||a[0]>=n[1])return this.vectorPool.push(h),this.arrayPool.push(n),this.arrayPool.push(a),!0;var T,S,g=0;n[0]a[1]?(g=n[0]-a[1],l.aInB=!1):(T=n[1]-a[0],S=a[1]-n[0],T>=S&&(g=-S)));var P=Math.abs(g);return P0&&T[i].overlap0)){for(P=!1,s=0;s=0?e:("string"==typeof e&&(e=e.toUpperCase()),Phaser.Plugin.ArcadeSlopes.TileSlope.hasOwnProperty(e)?Phaser.Plugin.ArcadeSlopes.TileSlope[e]:(console.warn("Unknown slope type '"+e+"'"),Phaser.Plugin.ArcadeSlopes.TileSlope.UNKNOWN))},Object.defineProperty(Phaser.Plugin.ArcadeSlopes.TileSlope.prototype,"slope",{get:function(){return this.line?(this.line.start.y-this.line.end.y)/(this.line.start.x-this.line.end.x):0}}),Object.defineProperty(Phaser.Plugin.ArcadeSlopes.TileSlope.prototype,"typeName",{get:function(){return Phaser.Plugin.ArcadeSlopes.TileSlope.resolveTypeName(this.type)},set:function(e){this.type=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(e)}}),Phaser.Plugin.ArcadeSlopes.TileSlope.resolveTypeName=function(e){return Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames.hasOwnProperty(e)?Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames[e]:Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames[-1]},Phaser.Plugin.ArcadeSlopes.TileSlope.typeNames={"-1":"UNKNOWN",0:"FULL",21:"HALF_BOTTOM",22:"HALF_TOP",23:"HALF_LEFT",24:"HALF_RIGHT",1:"HALF_BOTTOM_LEFT",2:"HALF_BOTTOM_RIGHT",3:"HALF_TOP_LEFT",4:"HALF_TOP_RIGHT",5:"QUARTER_BOTTOM_LEFT_LOW",6:"QUARTER_BOTTOM_LEFT_HIGH",7:"QUARTER_BOTTOM_RIGHT_LOW",8:"QUARTER_BOTTOM_RIGHT_HIGH",9:"QUARTER_LEFT_BOTTOM_LOW",10:"QUARTER_LEFT_BOTTOM_HIGH",11:"QUARTER_RIGHT_BOTTOM_LOW",12:"QUARTER_RIGHT_BOTTOM_HIGH",13:"QUARTER_LEFT_TOP_LOW",14:"QUARTER_LEFT_TOP_HIGH",15:"QUARTER_RIGHT_TOP_LOW",16:"QUARTER_RIGHT_TOP_HIGH",17:"QUARTER_TOP_LEFT_LOW",18:"QUARTER_TOP_LEFT_HIGH",19:"QUARTER_TOP_RIGHT_LOW",20:"QUARTER_TOP_RIGHT_HIGH"},Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY=0,Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID=1,Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING=2,Phaser.Plugin.ArcadeSlopes.TileSlope.UNKNOWN=-1,Phaser.Plugin.ArcadeSlopes.TileSlope.FULL=0,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM=21,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP=22,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_LEFT=23,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_RIGHT=24,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_LEFT=1,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_RIGHT=2,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_LEFT=3,Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_RIGHT=4,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_LOW=5,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_HIGH=6,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_LOW=7,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_HIGH=8,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_LOW=9,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_HIGH=10,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_LOW=11,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_HIGH=12,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_LOW=13,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_HIGH=14,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_LOW=15,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_HIGH=16,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_LOW=17,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_HIGH=18,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_LOW=19,Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_HIGH=20,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory=function(){this.definitions={},this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.FULL]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createFull,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_BOTTOM_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_LEFT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.HALF_TOP_RIGHT]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_LEFT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_BOTTOM_RIGHT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_BOTTOM_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_BOTTOM_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_LEFT_TOP_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_RIGHT_TOP_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_LEFT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_LOW]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow,this.definitions[Phaser.Plugin.ArcadeSlopes.TileSlope.QUARTER_TOP_RIGHT_HIGH]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh,this.mappings={},this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes,this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA]=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics,this.vectorPool=[];for(var e=0;e<100;e++)this.vectorPool.push(new SAT.Vector)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.constructor=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.define=function(e,o){"function"==typeof o&&(this.definitions[e]=o)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.create=function(e,o){var t=e;return e=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(t),this.definitions.hasOwnProperty(e)?"function"!=typeof this.definitions[e]?(console.warn("Slope type definition for type "+t+" is not a function"),null):this.definitions[e].call(this,e,o):(console.warn("Slope type "+t+" not defined"),null)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemap=function(e,o,t,l){return o=e.getLayer(o),this.convertTilemapLayer(o,t,l),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemapLayer=function(e,o,t){var l=this;if("string"==typeof o){var r=this.resolveMappingType(o);if(!this.mappings[r])return console.warn("Tilemap could not be converted; mapping type '"+o+"' is unknown"),e;o=this.mappings[r](t)}return e.layer.data.forEach(function(t){t.forEach(function(t){var r;t.properties.type&&(r=l.create(t.properties.type,t)),!r&&o.hasOwnProperty(t.index)&&(r=l.create(o[t.index],t)),r&&(t.slope=r);var i=t.x,s=t.y;t.neighbours=t.neighbours||{},t.neighbours.above=e.map.getTileAbove(e.index,i,s),t.neighbours.below=e.map.getTileBelow(e.index,i,s),t.neighbours.left=e.map.getTileLeft(e.index,i,s),t.neighbours.right=e.map.getTileRight(e.index,i,s),t.neighbours.topLeft=e.map.getTileTopLeft(e.index,i,s),t.neighbours.topRight=e.map.getTileTopRight(e.index,i,s),t.neighbours.bottomLeft=e.map.getTileBottomLeft(e.index,i,s),t.neighbours.bottomRight=e.map.getTileBottomRight(e.index,i,s)})}),this.calculateEdges(e),this.addDebugSettings(e),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.calculateEdges=function(e){var o,t,l,r,i,s,p,n,a;for(l=e.layer.height,r=e.layer.width,t=0;t=0?e:("string"==typeof e&&(e=e.toUpperCase()),Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.hasOwnProperty(e)&&this.mappings[Phaser.Plugin.ArcadeSlopes.TileSlopeFactory[e]]?Phaser.Plugin.ArcadeSlopes.TileSlopeFactory[e]:(console.warn("Unknown tileset mapping type '"+e+"'"),-1))},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createFull=function(e,o){var t=new SAT.Box(new SAT.Vector(o.worldX,o.worldY),o.width,o.height).toPolygon();return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom=function(e,o){var t=o.height/2,l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,t),new SAT.Vector(o.width,t),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),r=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top+o.height/2),i={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop=function(e,o){var t=o.height/2,l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,t),new SAT.Vector(0,t)]),r=new Phaser.Line(o.left,o.top,o.right,o.top),i={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft=function(e,o){var t=o.width/2,l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(t,0),new SAT.Vector(t,o.height),new SAT.Vector(0,o.height)]),r=new Phaser.Line(o.left+t,o.top,o.left+t,o.bottom),i={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight=function(e,o){var t=o.width/2,l=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(t,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(t,o.height)]),r=new Phaser.Line(o.left+t,o.top,o.left+t,o.bottom),i={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING};return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.7071067811865475,(-.7071067811865475));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.bottom,o.right,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.707106781186548),(-.707106781186548));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.right,o.top,o.left,o.bottom),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.7071067811865475,.7071067811865475);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height)]),l=new Phaser.Line(o.right,o.bottom,o.left,o.top),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.7071067811865475),.7071067811865475);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.4472135954999579,(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.top,o.right,o.top+o.height/2),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.4472135954999579,(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,o.height/2),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.bottom,o.right,o.top+o.height/2),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.4472135954999579),(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,o.height/2),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.bottom,o.right,o.top+o.height/2),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.4472135954999579),(-.8944271909999159));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left+o.width/2,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.8944271909999159,(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.top,o.left+o.width/2,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.8944271909999159,(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.bottom,o.left+o.width/2,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.8944271909999159),(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(o.width/2,o.height)]),l=new Phaser.Line(o.left+o.width/2,o.bottom,o.right,o.top),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.8944271909999159),(-.4472135954999579));return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width/2,0),new SAT.Vector(0,o.height)]),l=new Phaser.Line(0,o.height,o.width/2,0),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.8944271909999159,.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width/2,o.height),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left+o.width/2,o.bottom,o.right,o.bottom),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.8944271909999159,.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(o.width/2,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height)]),l=new Phaser.Line(o.left+o.width/2,o.top,o.right,o.bottom),r={top:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.8944271909999159),.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(o.width/2,o.height)]),l=new Phaser.Line(o.left,o.top,o.left+o.width/2,o.bottom),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.8944271909999159),.4472135954999579);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(0,o.height/2)]),l=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.4472135954999579,.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height/2),new SAT.Vector(0,o.height)]),l=new Phaser.Line(o.left,o.bottom,o.right,o.top+o.height/2),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector(.4472135954999579,.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height/2)]),l=new Phaser.Line(o.left,o.top,o.right,o.top+o.height/2),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,right:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.4472135954999579),.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh=function(e,o){var t=new SAT.Polygon(new SAT.Vector(o.worldX,o.worldY),[new SAT.Vector(0,0),new SAT.Vector(o.width,0),new SAT.Vector(o.width,o.height),new SAT.Vector(0,o.height/2)]),l=new Phaser.Line(o.left,o.top+o.height/2,o.right,o.top+o.height),r={bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING,left:Phaser.Plugin.ArcadeSlopes.TileSlope.INTERESTING},i=new SAT.Vector((-.4472135954999579),.8944271909999159);return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,o,t,l,r,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset=function(e){var o=parseInt(e);return o=isNaN(o)||"number"!=typeof o?0:o-1},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var o={};return o[offset+1]="FULL",o[offset+2]="HALF_TOP",o[offset+3]="HALF_BOTTOM",o[offset+4]="HALF_LEFT",o[offset+5]="HALF_RIGHT",o[offset+6]="HALF_BOTTOM_LEFT",o[offset+7]="HALF_BOTTOM_RIGHT",o[offset+8]="HALF_TOP_LEFT",o[offset+9]="HALF_TOP_RIGHT",o[offset+10]="QUARTER_TOP_LEFT_HIGH",o[offset+11]="QUARTER_TOP_LEFT_LOW",o[offset+12]="QUARTER_TOP_RIGHT_LOW",o[offset+13]="QUARTER_TOP_RIGHT_HIGH",o[offset+14]="QUARTER_BOTTOM_LEFT_HIGH",o[offset+15]="QUARTER_BOTTOM_LEFT_LOW",o[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",o[offset+17]="QUARTER_BOTTOM_RIGHT_HIGH",o[offset+18]="QUARTER_LEFT_BOTTOM_HIGH",o[offset+19]="QUARTER_RIGHT_BOTTOM_HIGH",o[offset+20]="QUARTER_LEFT_TOP_HIGH",o[offset+21]="QUARTER_RIGHT_TOP_HIGH",o[offset+35]="QUARTER_LEFT_BOTTOM_LOW",o[offset+36]="QUARTER_RIGHT_BOTTOM_LOW",o[offset+37]="QUARTER_LEFT_TOP_LOW",o[offset+38]="QUARTER_RIGHT_TOP_LOW",o},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var o={};return o[offset+2]="FULL",o[offset+3]="HALF_BOTTOM_LEFT",o[offset+4]="HALF_BOTTOM_RIGHT",o[offset+6]="HALF_TOP_LEFT",o[offset+5]="HALF_TOP_RIGHT",o[offset+15]="QUARTER_BOTTOM_LEFT_LOW",o[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",o[offset+17]="QUARTER_TOP_RIGHT_LOW",o[offset+18]="QUARTER_TOP_LEFT_LOW",o[offset+19]="QUARTER_BOTTOM_LEFT_HIGH",o[offset+20]="QUARTER_BOTTOM_RIGHT_HIGH",o[offset+21]="QUARTER_TOP_RIGHT_HIGH",o[offset+22]="QUARTER_TOP_LEFT_HIGH",o[offset+23]="QUARTER_LEFT_BOTTOM_HIGH",o[offset+24]="QUARTER_RIGHT_BOTTOM_HIGH",o[offset+25]="QUARTER_RIGHT_TOP_LOW",o[offset+26]="QUARTER_LEFT_TOP_LOW",o[offset+27]="QUARTER_LEFT_BOTTOM_LOW",o[offset+28]="QUARTER_RIGHT_BOTTOM_LOW",o[offset+29]="QUARTER_RIGHT_TOP_HIGH",o[offset+30]="QUARTER_LEFT_TOP_HIGH",o[offset+31]="HALF_BOTTOM",o[offset+32]="HALF_RIGHT",o[offset+33]="HALF_TOP",o[offset+34]="HALF_LEFT",o},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES=1,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA=2,function(e,o){"use strict";"function"==typeof define&&define.amd?define(o):"object"==typeof exports?module.exports=o():e.SAT=o()}(this,function(){"use strict";function e(e,o){this.x=e||0,this.y=o||0}function o(o,t){this.pos=o||new e,this.r=t||0}function t(o,t){this.pos=o||new e,this.angle=0,this.offset=new e,this.setPoints(t||[])}function l(o,t,l){this.pos=o||new e,this.w=t||0,this.h=l||0}function r(){this.a=null,this.b=null,this.overlapN=new e,this.overlapV=new e,this.clear()}function i(e,o,t){for(var l=Number.MAX_VALUE,r=-Number.MAX_VALUE,i=e.length,s=0;sr&&(r=p)}t[0]=l,t[1]=r}function s(e,o,t,l,r,s){var p=d.pop(),n=d.pop(),a=P.pop().copy(o).sub(e),h=a.dot(r);if(i(t,r,p),i(l,r,n),n[0]+=h,n[1]+=h,p[0]>n[1]||n[0]>p[1])return P.push(a),d.push(p),d.push(n),!0;if(s){var c=0;if(p[0]n[1])c=p[0]-n[1],s.aInB=!1;else{var T=p[1]-n[0],S=n[1]-p[0];c=Tt?R:w}function n(e,o){var t=P.pop().copy(e).sub(o.pos),l=o.r*o.r,r=t.len2();return P.push(t),r<=l}function a(e,o){f.pos.copy(e),A.clear();var t=S(f,o,A);return t&&(t=A.aInB),t}function h(e,o,t){var l=P.pop().copy(o.pos).sub(e.pos),r=e.r+o.r,i=r*r,s=l.len2();if(s>i)return P.push(l),!1;if(t){var p=Math.sqrt(s);t.a=e,t.b=o,t.overlap=r-p,t.overlapN.copy(l.normalize()),t.overlapV.copy(l).scale(t.overlap),t.aInB=e.r<=o.r&&p<=o.r-e.r,t.bInA=o.r<=e.r&&p<=e.r-o.r}return P.push(l),!0}function c(e,o,t){for(var l=P.pop().copy(o.pos).sub(e.pos),r=o.r,i=r*r,s=e.calcPoints,n=s.length,a=P.pop(),h=P.pop(),c=0;ci&&(t.aInB=!1);var d=p(a,h);if(d===y){a.copy(e.edges[S]);var A=P.pop().copy(l).sub(s[S]);if(d=p(a,A),d===R){var f=h.len();if(f>r)return P.push(l),P.push(a),P.push(h),P.push(A),!1;t&&(t.bInA=!1,u=h.normalize(),g=r-f)}P.push(A)}else if(d===R){if(a.copy(e.edges[T]),h.copy(l).sub(s[T]),d=p(a,h),d===y){var f=h.len();if(f>r)return P.push(l),P.push(a),P.push(h),!1;t&&(t.bInA=!1,u=h.normalize(),g=r-f)}}else{var w=a.perp().normalize(),f=h.dot(w),v=Math.abs(f);if(f>0&&v>r)return P.push(l),P.push(w),P.push(h),!1;t&&(u=w,g=r-f,(f>=0||g<2*r)&&(t.bInA=!1))}u&&t&&Math.abs(g)0&&(this.x=this.x/e,this.y=this.y/e),this},e.prototype.add=e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.sub=e.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.scale=e.prototype.scale=function(e,o){return this.x*=e,this.y*=o||e,this},e.prototype.project=e.prototype.project=function(e){var o=this.dot(e)/e.len2();return this.x=o*e.x,this.y=o*e.y,this},e.prototype.projectN=e.prototype.projectN=function(e){var o=this.dot(e);return this.x=o*e.x,this.y=o*e.y,this},e.prototype.reflect=e.prototype.reflect=function(e){var o=this.x,t=this.y;return this.project(e).scale(2),this.x-=o,this.y-=t,this},e.prototype.reflectN=e.prototype.reflectN=function(e){var o=this.x,t=this.y;return this.projectN(e).scale(2),this.x-=o,this.y-=t,this},e.prototype.dot=e.prototype.dot=function(e){return this.x*e.x+this.y*e.y},e.prototype.len2=e.prototype.len2=function(){return this.dot(this)},e.prototype.len=e.prototype.len=function(){return Math.sqrt(this.len2())},g.Circle=o,o.prototype.getAABB=o.prototype.getAABB=function(){var o=this.r,t=this.pos.clone().sub(new e(o,o));return new l(t,2*o,2*o).toPolygon()},g.Polygon=t,t.prototype.setPoints=t.prototype.setPoints=function(o){var t=!this.points||this.points.length!==o.length;if(t){var l,r=this.calcPoints=[],i=this.edges=[],s=this.normals=[];for(l=0;ls&&(s=a.x),a.yp&&(p=a.y)}return new l(this.pos.clone().add(new e(r,i)),s-r,p-i).toPolygon()},g.Box=l,l.prototype.toPolygon=l.prototype.toPolygon=function(){var o=this.pos,l=this.w,r=this.h;return new t(new e(o.x,o.y),[new e,new e(l,0),new e(l,r),new e(0,r)])},g.Response=r,r.prototype.clear=r.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this};for(var P=[],u=0;u<10;u++)P.push(new e);for(var d=[],u=0;u<5;u++)d.push([]);var A=new r,f=new l(new e,1e-6,1e-6).toPolygon();g.isSeparatingAxis=s;var y=-1,w=0,R=1;return g.pointInCircle=n,g.pointInPolygon=a,g.testCircleCircle=h,g.testPolygonCircle=c,g.testCirclePolygon=T,g.testPolygonPolygon=S,g});