From 6c116d2c362d3fb8d985d0cec2f9b5abc7e340b2 Mon Sep 17 00:00:00 2001 From: Chris Andrew Date: Fri, 19 May 2017 00:31:55 +0100 Subject: [PATCH] Released 0.2.0 --- dist/phaser-arcade-slopes.js | 165 ++++++++++++++++++++++++++----- dist/phaser-arcade-slopes.min.js | 4 +- 2 files changed, 140 insertions(+), 29 deletions(-) diff --git a/dist/phaser-arcade-slopes.js b/dist/phaser-arcade-slopes.js index a7b5b46..20ec41d 100644 --- a/dist/phaser-arcade-slopes.js +++ b/dist/phaser-arcade-slopes.js @@ -54,7 +54,7 @@ Phaser.Plugin.ArcadeSlopes.prototype.constructor = Phaser.Plugin.ArcadeSlopes; * @constant * @type {string} */ -Phaser.Plugin.ArcadeSlopes.VERSION = '0.2.0-beta2'; +Phaser.Plugin.ArcadeSlopes.VERSION = '0.2.0'; /** * The Separating Axis Theorem collision solver type. @@ -232,6 +232,7 @@ Phaser.Plugin.ArcadeSlopes.Facade.prototype.enableBody = function (body) { body.slopes = body.slopes || { debug: false, friction: new Phaser.Point(), + heuristics: null, preferY: false, pullUp: 0, pullDown: 0, @@ -296,7 +297,7 @@ Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemapLayer = function (laye * @return {boolean} - Whether the body was separated. */ Phaser.Plugin.ArcadeSlopes.Facade.prototype.collide = function (i, body, tile, tilemapLayer, overlapOnly) { - return this.solvers[this.defaultSolver].collide(i, body, tile, tilemapLayer, overlapOnly); + return this.solvers.sat.collide(i, body, tile, tilemapLayer, overlapOnly); }; /** @@ -814,12 +815,23 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer = function () { */ this.restraints = {}; + /** + * A reusable separation axis vector. + * + * @property {SAT.Vector} separationAxis + */ + this.separationAxis = new SAT.Vector(); + // Define all of the default restraints this.setDefaultRestraints(); }; /** * Restrain the given SAT body-tile collision context based on the set rules. + * + * Returns false if the collision is handled by a restraint condition, either + * triggering separation itself in the best case or skipping it entirely in the + * worst case. * * @method Phaser.Plugin.ArcadeSlopes.SatRestrainer#restrain * @param {Phaser.Plugin.ArcadeSlopes.SatSolver} solver - The SAT solver. @@ -879,9 +891,17 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.restrain = function (solver, separate = separate.call(this, body, tile, response); } - // Collide on the tile's preferred axis if desired and available - if (separate && tile.slope.axis) { - solver.collideOnAxis(body, tile, tile.slope.axis); + // Separate on the tile's preferred axis by default + var separationAxis = tile.slope.axis; + + // Use the restraint decision as the axis if it's a vector + if (separate instanceof SAT.Vector) { + separationAxis = separate; + } + + // Collide on the separation axis if desired and available + if (separate && separationAxis) { + solver.collideOnAxis(body, tile, separationAxis); } return false; @@ -921,6 +941,8 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps = function (direction) overlapX: [0, 1], overlapY: 0 }; + case 'any': + return {}; } console.warn('Unknown overlap direction \'' + direction + '\''); @@ -941,7 +963,7 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps = function (direction) * @param {object} restraints - The restraints to prepare. * @return {object} - The prepared restraints. */ -Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function(restraints) { +Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function (restraints) { var prepared = {}; for (var type in restraints) { @@ -955,8 +977,13 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function(restraints if (rule.direction) { var resolved = Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps(rule.direction); - rule.overlapX = resolved.overlapX; - rule.overlapY = resolved.overlapY; + if (resolved.hasOwnProperty('overlapX')) { + rule.overlapX = resolved.overlapX; + } + + if (resolved.hasOwnProperty('overlapY')) { + rule.overlapY = resolved.overlapY; + } } // Resolve neighbour types from their string representations @@ -964,7 +991,8 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function(restraints rule.types[nt] = Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(rule.types[nt]); } - // Conveniently set separate to true unless it's already false + // Conveniently set separate to true unless it's already false or + // it's a function that resolves a separation decision if (rule.separate !== false && typeof rule.separate !== 'function') { rule.separate = true; } @@ -978,6 +1006,62 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function(restraints return prepared; }; +/** + * Eagerly separate a body from a square tile. + * + * This is used for full tile separation constraints to avoid tiny bodies + * slipping between tile seams. + * + * Ignores any non-colliding or internal edges. + * + * Returns a desired axis to separate on, if it can. + * + * @param {Phaser.Physics.Arcade.Body} body - The physics body. + * @param {Phaser.Tile} tile - The tile. + * @param {SAT.Response} response - The initial collision response. + * @return {SAT.Vector|boolean} + */ +Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.fullTileSeparation = function (body, tile, response) { + // If the body is above the tile center and top collisions are allowed, + // and we're moving down, and more vertically than horizontally + if (body.top < tile.worldY + tile.centerY && tile.collideUp && tile.slope.edges.top !== Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY && body.velocity.y > 0 && Math.abs(body.velocity.y) > Math.abs(body.velocity.x)) { + this.separationAxis.x = 0; + this.separationAxis.y = -1; + + return this.separationAxis; + } + + // If the body is below the tile center and bottom collisions are allowed, + // and we're moving up, and more vertically than horizontally + if (body.bottom > tile.worldY + tile.centerY && tile.collideDown && tile.slope.edges.bottom !== Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY && body.slopes.velocity.y < 0 && Math.abs(body.slopes.velocity.y) > Math.abs(body.slopes.velocity.x)) { + this.separationAxis.x = 0; + this.separationAxis.y = 1; + + return this.separationAxis; + } + + // If the body is left of the tile center and left collisions are allowed, + // and we're moving right, and more horizontally than vertically + if (body.left < tile.worldX + tile.centerX && tile.collideLeft && tile.slope.edges.left !== Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY && body.slopes.velocity.x > 0 && Math.abs(body.slopes.velocity.x) > Math.abs(body.slopes.velocity.y)) { + this.separationAxis.x = -1; + this.separationAxis.y = 0; + + return this.separationAxis; + } + + // If the body is right of the tile center and right collisions are allowed, + // and we're moving left, and more horizontally than vertically + if (body.right > tile.worldX + tile.centerX && tile.collideRight && tile.slope.edges.right !== Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY && body.slopes.velocity.x < 0 && Math.abs(body.slopes.velocity.x) > Math.abs(body.slopes.velocity.y)) { + this.separationAxis.x = 1; + this.separationAxis.y = 0; + + return this.separationAxis; + } + + // Otherwise separate normally + return true; +}; + /** * Set all of the default SAT collision handling restraints. * @@ -991,6 +1075,33 @@ Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints = function(restraints Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.setDefaultRestraints = function () { var restraints = {}; + restraints.FULL = [ + { + direction: 'up', + neighbour: 'above', + types: this.resolve('bottomLeft', 'bottomRight'), + separate: this.fullTileSeparation + }, + { + direction: 'down', + neighbour: 'below', + types: this.resolve('topLeft', 'topRight'), + separate: this.fullTileSeparation + }, + { + direction: 'left', + neighbour: 'left', + types: this.resolve('topRight', 'bottomRight'), + separate: this.fullTileSeparation + }, + { + direction: 'right', + neighbour: 'right', + types: this.resolve('topLeft', 'bottomLeft'), + separate: this.fullTileSeparation + } + ]; + restraints.HALF_TOP = [ { direction: 'left', @@ -2118,8 +2229,10 @@ Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collide = function (i, body, tile tile.slope.polygon.pos.x = tile.worldX + tilemapLayer.getCollisionOffsetX(); tile.slope.polygon.pos.y = tile.worldY + tilemapLayer.getCollisionOffsetY(); + // Reuse the body's response or create one for it var response = body.slopes.sat.response || new SAT.Response(); + // Reset the response Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse(response); // Test for an overlap and bail if there isn't one @@ -2171,8 +2284,8 @@ Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collideOnAxis = function (body, t // Update the body's polygon position and velocity vector this.updateValues(body); - // Bail out if we don't have everything we need - if (!this.shouldCollide(body, tile)) { + // Bail out if we don't have everything we need or the body is circular + if (!this.shouldCollide(body, tile) || body.isCircle) { return false; } @@ -2248,38 +2361,36 @@ Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldSeparate = function (i, bod return false; } - // Ignore any non-colliding or internal edges - if ((!tile.collideUp || tile.slope.edges.top === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.y < 0 && response.overlapN.x === 0) { + // Only separate if the body is moving into the tile + if (response.overlapV.clone().scale(-1).dot(body.slopes.velocity) < 0) { return false; } - if ((!tile.collideDown || tile.slope.edges.bottom === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.y > 0 && response.overlapN.x === 0) { - return false; + // Run any separation restrainers if appropriate + if ((this.options.restrain || body.slopes.heuristics) && body.slopes.heuristics !== false && !body.isCircle) { + if (this.restrain(body, tile, response)) { + return false; + } } - if ((!tile.collideLeft || tile.slope.edges.left === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.x < 0 && response.overlapN.y === 0) { + // Ignore any non-colliding or internal edges + if ((!tile.collideUp || tile.slope.edges.top === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.y < 0 && response.overlapN.x === 0) { return false; } - if ((!tile.collideRight || tile.slope.edges.right === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.x > 0 && response.overlapN.y === 0) { + if ((!tile.collideDown || tile.slope.edges.bottom === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.y > 0 && response.overlapN.x === 0) { return false; } - // Only separate if the body is moving into the tile - if (response.overlapV.clone().scale(-1).dot(body.slopes.velocity) < 0) { + if ((!tile.collideLeft || tile.slope.edges.left === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.x < 0 && response.overlapN.y === 0) { return false; } - // Skip restraints if they are disabled or the body is circular - if (!this.options.restrain || body.isCircle) { - return true; - } - - // Run any separation restrainers - if (this.restrain(body, tile, response)) { + if ((!tile.collideRight || tile.slope.edges.right === Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY) && response.overlapN.x > 0 && response.overlapN.y === 0) { return false; } + // Otherwise we should separate normally return true; }; @@ -2346,7 +2457,7 @@ Phaser.Plugin.ArcadeSlopes.TileSlope = function (type, tile, polygon, line, edge this.line = line; /** - * The flags for each edge of the tile; empty, solid or interesting? + * The flags for each edge of the tile: empty, solid or interesting? * * @property {object} edges */ diff --git a/dist/phaser-arcade-slopes.min.js b/dist/phaser-arcade-slopes.min.js index e870cd3..b392008 100644 --- a/dist/phaser-arcade-slopes.min.js +++ b/dist/phaser-arcade-slopes.min.js @@ -1,2 +1,2 @@ -Phaser.Plugin.ArcadeSlopes=function(e,t,o){Phaser.Plugin.call(this,e,t);var r={};r[Phaser.Plugin.ArcadeSlopes.SAT]=new Phaser.Plugin.ArcadeSlopes.SatSolver,this.facade=new Phaser.Plugin.ArcadeSlopes.Facade(new Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,r,o||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.2.0-beta2",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,t,o){this.factory=e,this.solvers=t,this.defaultSolver=o||Phaser.Plugin.ArcadeSlopes.SAT,this.plugin=null},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enable=function(e){if(Array.isArray(e))for(var t=0;t0&&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,snapUp:0,snapDown:0,snapLeft:0,snapRight:0,tile:null,velocity:new SAT.Vector}},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemap=function(e,t,o,r){return this.factory.convertTilemap(e,t,o,r)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemapLayer=function(e,t,o){return this.factory.convertTilemapLayer(e,t,o)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.collide=function(e,t,o,r,l){return this.solvers[this.defaultSolver].collide(e,t,o,r,l)},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,t,o,r,l,i,s,n){if(!t.body)return!1;if(o.hasOwnProperty("slope")){if(this.game.slopes.collide(e,t.body,o,r,n))return this._total++,l&&l.call(s,t,o),!0}else if(this.separateTile(e,t.body,o,r,n))return this._total++,l&&l.call(s,t,o),!0;return!1},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles=function(e,t,o,r,l,i,s){var n=!1;if(!e.body)return n;for(var p=0;p0&&o>0?this.layers[e].data[o-1][t-1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight=function(e,t,o){return t0?this.layers[e].data[o-1][t+1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft=function(e,t,o){return t>0&&o=g&&(g=Math.max(0,g),u=Math.min(n-1,u)),P>=S&&(S=Math.max(0,S),P=Math.min(p-1,P)));var d,A,f,y,R,_,O,w,L,v=g*a-e,E=S*h-t,H=(g+(1<<20)*n)%n,I=(S+(1<<20)*p)%p;for(y=I,_=P-S,A=E;_>=0;y++,_--,A+=h){y>=p&&(y-=p);var b=this.layer.data[y];for(f=H,R=u-g,d=v;R>=0;f++,R--,d+=a){f>=n&&(f-=n);var F=b[f];if(F&&!(F.index<0)&&F.collides&&(this.debugSettings.collidingTileOverfill&&(o.fillStyle=this.debugSettings.collidingTileOverfill,o.fillRect(d,A,T,c)),this.debugSettings.facingEdgeStroke&&(o.beginPath(),o.lineWidth=1,o.strokeStyle=this.debugSettings.facingEdgeStroke,F.faceTop&&(o.moveTo(d,A),o.lineTo(d+T,A)),F.faceBottom&&(o.moveTo(d,A+c),o.lineTo(d+T,A+c)),F.faceLeft&&(o.moveTo(d,A),o.lineTo(d,A+c)),F.faceRight&&(o.moveTo(d+T,A),o.lineTo(d+T,A+c)),o.closePath(),o.stroke(),F.slope))){if(this.debugSettings.slopeEdgeStroke||this.debugSettings.slopeFill){for(o.beginPath(),o.lineWidth=1,O=F.slope.polygon,o.moveTo(d+O.points[0].x*i,A+O.points[0].y*s),w=0;w-1:s.slope.type===o.slope.type,i.hasOwnProperty("overlapX")&&(n="number"==typeof i.overlapX?n&&r.overlapN.x===i.overlapX:n&&r.overlapN.x>=i.overlapX[0]&&r.overlapN.x<=i.overlapX[1]),i.hasOwnProperty("overlapY")&&(n="number"==typeof i.overlapY?n&&r.overlapN.y===i.overlapY:n&&r.overlapN.y>=i.overlapY[0]&&r.overlapN.y<=i.overlapY[1]),n){var p=i.separate;return"function"==typeof p&&(p=p.call(this,t,o,r)),p&&o.slope.axis&&e.collideOnAxis(t,o,o.slope.axis),!1}}}return!0},Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps=function(e){switch(e){case"up":return{overlapX:0,overlapY:[-1,0]};case"down":return{overlapX:0,overlapY:[0,1]};case"left":return{overlapX:[-1,0],overlapY:0};case"right":return{overlapX:[0,1],overlapY:0}}return console.warn("Unknown overlap direction '"+e+"'"),{}},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints=function(e){var t={};for(var o in e){var r=e[o];for(var l in r){var i=r[l];if(i.direction){var s=Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps(i.direction);i.overlapX=s.overlapX,i.overlapY=s.overlapY}for(var n in i.types)i.types[n]=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(i.types[n]);i.separate!==!1&&"function"!=typeof i.separate&&(i.separate=!0)}var p=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(o);t[p]=r}return t},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.setDefaultRestraints=function(){var e={};e.HALF_TOP=[{direction:"left",neighbour:"left",types:this.resolve("topRight","right"),separate:!1},{direction:"right",neighbour:"right",types:this.resolve("topLeft","left"),separate:!1}],e.HALF_BOTTOM=[{direction:"left",neighbour:"left",types:this.resolve("right","bottomRight"),separate:!1},{direction:"right",neighbour:"right",types:this.resolve("left","bottomLeft"),separate:!1}],e.HALF_LEFT=[{direction:"up",neighbour:"above",types:this.resolve("bottomLeft","bottom"),separate:!1},{direction:"down",neighbour:"below",types:this.resolve("topLeft","top"),separate:!1}],e.HALF_RIGHT=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:!1},{direction:"down",neighbour:"below",types:this.resolve("top","topRight"),separate:!1}],e.HALF_BOTTOM_LEFT=[{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")},{direction:"up",neighbour:"topLeft",types:this.resolve("bottomRight")}],e.HALF_BOTTOM_RIGHT=[{direction:"left",neighbour:"bottomLeft",types:this.resolve("topRight")},{direction:"up",neighbour:"topRight",types:this.resolve("bottomLeft")}],e.HALF_TOP_LEFT=[{direction:"right",neighbour:"topRight",types:this.resolve("bottomLeft")},{direction:"down",neighbour:"bottomLeft",types:this.resolve("topRight")}],e.HALF_TOP_RIGHT=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_BOTTOM_LEFT_LOW=[{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")},{direction:"up",neighbour:"left",types:this.resolve("topLeft","right","bottomRight")},{direction:"left",neighbour:"left",types:this.resolve("right","bottomRight"),separate:!1}],e.QUARTER_BOTTOM_LEFT_HIGH=[{direction:"right",neighbour:"right",types:this.resolve("left","bottomLeft"),separate:function(e,t){return e.bottomt.left}},{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_LEFT_BOTTOM_HIGH=[{direction:"up",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"below",types:this.resolve("topLeft","top"),separate:!1},{direction:"right",neighbour:"below",types:this.resolve("topLeft","top","bottomRight")}],e.QUARTER_RIGHT_BOTTOM_LOW=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:function(e,t){return e.rightt.left}}],e.QUARTER_RIGHT_TOP_LOW=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight")},{direction:"left",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:!1},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_RIGHT_TOP_HIGH=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"below",types:this.resolve("top","topRight"),separate:function(e,t){return e.rightt.top}},{direction:"down",neighbour:"bottomLeft",types:this.resolve("topRight")}],e.QUARTER_TOP_RIGHT_LOW=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"right",neighbour:"right",types:this.resolve("topLeft","left"),separate:!1},{direction:"down",neighbour:"right",types:this.resolve("bottomRight","topLeft","left")}],e.QUARTER_TOP_RIGHT_HIGH=[{direction:"left",neighbour:"left",types:this.resolve("topRight","right"),separate:function(e,t){return e.top>t.top}},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],this.informalRestraints=JSON.parse(JSON.stringify(e)),this.restraints=Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints(e)},Phaser.Plugin.ArcadeSlopes.SatRestrainer.intersectArrays=function(e,t){return e.filter(function(e){return-1!==t.indexOf(e)}).filter(function(e,t,o){return o.indexOf(e)===t})},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.resolve=function(){var e=[];if(!arguments.length)return e;for(var t in arguments){var o=arguments[t];if(Phaser.Plugin.ArcadeSlopes.SatRestrainer.hasOwnProperty(o+"Vertices")){var r=Array.prototype.slice.call(Phaser.Plugin.ArcadeSlopes.SatRestrainer[o+"Vertices"]);if(1===arguments.length)return r;e=e.length?Phaser.Plugin.ArcadeSlopes.SatRestrainer.intersectArrays(e,r):r}else console.warn("Tried to resolve types from undefined vertex map location '"+o+"'")}return e},Phaser.Plugin.ArcadeSlopes.SatRestrainer.topVertices=["HALF_LEFT","HALF_RIGHT","QUARTER_LEFT_TOP_LOW","QUARTER_RIGHT_TOP_LOW","QUARTER_LEFT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomVertices=["HALF_LEFT","HALF_RIGHT","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.leftVertices=["HALF_TOP","HALF_BOTTOM","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_RIGHT_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.rightVertices=["HALF_TOP","HALF_BOTTOM","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.topLeftVertices=["FULL","HALF_TOP","HALF_LEFT","HALF_TOP_LEFT","HALF_TOP_RIGHT","HALF_BOTTOM_LEFT","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_LEFT_TOP_LOW","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_TOP_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.topRightVertices=["FULL","HALF_TOP","HALF_RIGHT","HALF_TOP_LEFT","HALF_TOP_RIGHT","HALF_BOTTOM_RIGHT","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_LOW","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_TOP_HIGH","QUARTER_RIGHT_TOP_LOW","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomLeftVertices=["FULL","HALF_LEFT","HALF_BOTTOM","HALF_TOP_LEFT","HALF_BOTTOM_LEFT","HALF_BOTTOM_RIGHT","QUARTER_TOP_LEFT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_BOTTOM_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomRightVertices=["FULL","HALF_RIGHT","HALF_BOTTOM","HALF_TOP_RIGHT","HALF_BOTTOM_LEFT","HALF_BOTTOM_RIGHT","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatSolver=function(e){this.options=Phaser.Utils.mixin(e||{},{debug:!1,preferY:!1,restrain:!0}),this.restrainers=[new Phaser.Plugin.ArcadeSlopes.SatRestrainer]},Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse=function(e){return e.overlapV.scale(-1),e.overlapN.scale(-1),e},Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse=function(e){return e.overlapN.x=0,e.overlapN.y=0,e.overlapV.x=0,e.overlapV.y=0,e.clear(),e},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetX=function(e){return e.y*e.y/e.x+e.x},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY=function(e){return e.x*e.x/e.y+e.y},Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY=function(e,t){return t.overlapV.y<0&&e.velocity.y>0||t.overlapV.y>0&&e.velocity.y<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldPreferY=function(e,t){return(this.options.preferY||e.slopes.preferY)&&0!==t.overlapV.y&&0!==t.overlapV.x&&Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY(e,t)},Phaser.Plugin.ArcadeSlopes.SatSolver.isSeparatingAxis=function(e,t,o,r){var l=SAT.isSeparatingAxis(e.pos,t.pos,e.points,t.points,o,r||null);return r&&(r.a=e,r.b=t,r.overlapV=r.overlapN.clone().scale(r.overlap)),l},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.separate=function(e,t,o,r){return r||this.shouldSeparate(t.index,e,t,o)?t.collisionCallback&&!t.collisionCallback.call(t.collisionCallbackContext,e.sprite,t)?!1:t.layer.callbacks[t.index]&&!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e.sprite,t)?!1:(this.shouldPreferY(e,o)?e.position.y+=Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY(o.overlapV):(e.position.x+=o.overlapV.x,e.position.y+=o.overlapV.y),!0):!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.applyVelocity=function(e,t,o){var r=e.slopes.velocity.clone().projectN(o.overlapN),l=e.slopes.velocity.clone().sub(r);r.x=r.x*-e.bounce.x,r.y=r.y*-e.bounce.y,l.x=l.x*(1-e.slopes.friction.x-t.slope.friction.x),l.y=l.y*(1-e.slopes.friction.y-t.slope.friction.y),e.velocity.x=r.x+l.x,e.velocity.y=r.y+l.y,this.pull(e,o)},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,t){e.touching.up=e.touching.up||t.overlapV.y>0,e.touching.down=e.touching.down||t.overlapV.y<0,e.touching.left=e.touching.left||t.overlapV.x>0,e.touching.right=e.touching.right||t.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===t.overlapV.x&&t.overlapV.y>0,e.blocked.down=e.blocked.down||0===t.overlapV.x&&t.overlapV.y<0,e.blocked.left=e.blocked.left||0===t.overlapV.y&&t.overlapV.x>0,e.blocked.right=e.blocked.right||0===t.overlapV.y&&t.overlapV.x<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.snap=function(e,t,o){if(!e.slopes||!e.slopes.snapUp&&!e.slopes.snapDown&&!e.slopes.snapLeft&&!e.slopes.snapRight)return!1;var r=new Phaser.Point(e.position.x,e.position.y);for(var l in t){var i=t[l];if(i.slope){if(e.slopes.snapUp&&(e.position.x=r.x,e.position.y=r.y-e.slopes.snapUp,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapDown&&(e.position.x=r.x,e.position.y=r.y+e.slopes.snapDown,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapLeft&&(e.position.x=r.x-e.slopes.snapLeft,e.position.y=r.y,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapRight&&(e.position.x=r.x+e.slopes.snapRight,e.position.y=r.y,this.snapCollide(e,i,o,r)))return!0}}return!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.pull=function(e,t){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 o=t.overlapN.clone().scale(-1);return e.slopes.pullUp&&o.y<0?(pullUp=o.clone().scale(e.slopes.pullUp),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullDown&&o.y>0?(pullDown=o.clone().scale(e.slopes.pullDown),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullLeft&&o.x<0?(pullLeft=o.clone().scale(e.slopes.pullLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullRight&&o.x>0?(pullRight=o.clone().scale(e.slopes.pullRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):e.slopes.pullTopLeft&&o.x<0&&o.y<0?(pullUp=o.clone().scale(e.slopes.pullTopLeft),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullTopRight&&o.x>0&&o.y<0?(pullDown=o.clone().scale(e.slopes.pullTopRight),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullBottomLeft&&o.x<0&&o.y>0?(pullLeft=o.clone().scale(e.slopes.pullBottomLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullBottomRight&&o.x>0&&o.y>0?(pullRight=o.clone().scale(e.slopes.pullBottomRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.snapCollide=function(e,t,o,r){return this.collide(0,e,t,o)?!0:(e.position.x=r.x,e.position.y=r.y,!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldCollide=function(e,t){return e.enable&&e.polygon&&e.slopes&&t.collides&&t.slope&&t.slope.polygon},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collide=function(e,t,o,r,l){if(this.updateValues(t),!this.shouldCollide(t,o))return!1;t.isCircle&&(t.polygon.pos.x+=t.halfWidth,t.polygon.pos.y+=t.halfHeight),o.slope.polygon.pos.x=o.worldX+r.getCollisionOffsetX(),o.slope.polygon.pos.y=o.worldY+r.getCollisionOffsetY();var i=t.slopes.sat.response||new SAT.Response;return Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse(i),t.isCircle&&!SAT.testCirclePolygon(t.polygon,o.slope.polygon,i)||!t.isCircle&&!SAT.testPolygonPolygon(t.polygon,o.slope.polygon,i)?!1:l?!0:(Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse(i),this.separate(t,o,i)?(t.overlapX=i.overlapV.x,t.overlapY=i.overlapV.y,t.slopes.sat.response=i,t.slopes.tile=o,this.applyVelocity(t,o,i),this.updateFlags(t,i),!0):!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collideOnAxis=function(e,t,o,r){if(this.updateValues(e),!this.shouldCollide(e,t))return!1;r=r||new SAT.Response;var l=Phaser.Plugin.ArcadeSlopes.SatSolver.isSeparatingAxis(e.polygon,t.slope.polygon,o,r);return l?!1:(Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse(r),this.separate(e,t,r,!0)?(e.overlapX=r.overlapV.x,e.overlapY=r.overlapV.y,e.slopes.sat.response=r,this.applyVelocity(e,t,r),this.updateFlags(e,r),!0):!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.restrain=function(e,t,o){for(var r in this.restrainers){var l=this.restrainers[r];if("function"==typeof l.restrain&&!l.restrain(this,e,t,o))return!0}return!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldSeparate=function(e,t,o,r){return t.enable&&r.overlap?(!o.collideUp||o.slope.edges.top===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.y<0&&0===r.overlapN.x?!1:(!o.collideDown||o.slope.edges.bottom===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.y>0&&0===r.overlapN.x?!1:(!o.collideLeft||o.slope.edges.left===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.x<0&&0===r.overlapN.y?!1:(!o.collideRight||o.slope.edges.right===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.x>0&&0===r.overlapN.y?!1:r.overlapV.clone().scale(-1).dot(t.slopes.velocity)<0?!1:!this.options.restrain||t.isCircle?!0:!this.restrain(t,o,r):!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.debug=function(e,t){},Phaser.Plugin.ArcadeSlopes.TileSlope=function(e,t,o,r,l,i){this.type=e,this.tile=t,this.polygon=o,this.line=r,this.edges=Phaser.Utils.mixin(l||{},{top:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,left:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,right:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID}),this.axis=i||null,this.solver=null,this.friction=new Phaser.Point},Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType=function(e){return parseInt(e)>=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},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.constructor=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.define=function(e,t){"function"==typeof t&&(this.definitions[e]=t)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.create=function(e,t){var o=e;return e=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(o),this.definitions.hasOwnProperty(e)?"function"!=typeof this.definitions[e]?(console.warn("Slope type definition for type "+o+" is not a function"),null):this.definitions[e].call(this,e,t):(console.warn("Slope type "+o+" not defined"),null)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemap=function(e,t,o,r){return t=e.getLayer(t),this.convertTilemapLayer(t,o,r),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemapLayer=function(e,t,o){var r=this;if("string"==typeof t){var l=this.resolveMappingType(t);if(!this.mappings[l])return console.warn("Tilemap could not be converted; mapping type '"+t+"' is unknown"),e;t=this.mappings[l](o)}return e.layer.data.forEach(function(o){o.forEach(function(o){var l;o.properties.type&&(l=r.create(o.properties.type,o)),!l&&t.hasOwnProperty(o.index)&&(l=r.create(t[o.index],o)),l&&(o.slope=l);var i=o.x,s=o.y;o.neighbours=o.neighbours||{},o.neighbours.above=e.map.getTileAbove(e.index,i,s),o.neighbours.below=e.map.getTileBelow(e.index,i,s),o.neighbours.left=e.map.getTileLeft(e.index,i,s),o.neighbours.right=e.map.getTileRight(e.index,i,s),o.neighbours.topLeft=e.map.getTileTopLeft(e.index,i,s),o.neighbours.topRight=e.map.getTileTopRight(e.index,i,s),o.neighbours.bottomLeft=e.map.getTileBottomLeft(e.index,i,s),o.neighbours.bottomRight=e.map.getTileBottomRight(e.index,i,s)})}),this.calculateEdges(e),this.addDebugSettings(e),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.calculateEdges=function(e){for(var t=null,o=null,r=null,l=null,i=0,s=e.layer.height;s>i;i++)for(var n=0,p=e.layer.width;p>n;n++){var a=e.layer.data[i][n];a&&a.hasOwnProperty("slope")&&(t=e.map.getTileAbove(e.index,n,i),o=e.map.getTileBelow(e.index,n,i),r=e.map.getTileLeft(e.index,n,i),l=e.map.getTileRight(e.index,n,i),t&&t.hasOwnProperty("slope")&&(a.slope.edges.top=this.compareEdges(a.slope.edges.top,t.slope.edges.bottom),a.collideUp=a.slope.edges.top!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,t)),o&&o.hasOwnProperty("slope")&&(a.slope.edges.bottom=this.compareEdges(a.slope.edges.bottom,o.slope.edges.top),a.collideDown=a.slope.edges.bottom!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,o)),r&&r.hasOwnProperty("slope")&&(a.slope.edges.left=this.compareEdges(a.slope.edges.left,r.slope.edges.right),a.collideLeft=a.slope.edges.left!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,r)),l&&l.hasOwnProperty("slope")&&(a.slope.edges.right=this.compareEdges(a.slope.edges.right,l.slope.edges.left),a.collideRight=a.slope.edges.right!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,l)))}},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.compareEdges=function(e,t){return e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&t===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&t===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.flagInternalVertices=function(e,t){if(e.slope.polygon&&t.slope.polygon)for(var o=e.slope.polygon,r=t.slope.polygon,l=new SAT.Vector(e.worldX,e.worldY),i=new SAT.Vector(t.worldX,t.worldY),s=0;s=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,t){var o=new SAT.Box(new SAT.Vector(t.worldX,t.worldY),t.width,t.height).toPolygon();return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,t,o)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom=function(e,t){var o=t.height/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,o),new SAT.Vector(t.width,o),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),l=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top+t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop=function(e,t){var o=t.height/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,o),new SAT.Vector(0,o)]),l=new Phaser.Line(t.left,t.top,t.right,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft=function(e,t){var o=t.width/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(o,0),new SAT.Vector(o,t.height),new SAT.Vector(0,t.height)]),l=new Phaser.Line(t.left+o,t.top,t.left+o,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight=function(e,t){var o=t.width/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(o,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(o,t.height)]),l=new Phaser.Line(t.left+o,t.top,t.left+o,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.right,t.top,t.left,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height)]),r=new Phaser.Line(t.right,t.bottom,t.left,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,t.height/2),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.left+t.width/2,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.left+t.width/2,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(t.width/2,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.bottom,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,0),new SAT.Vector(0,t.height)]),r=new Phaser.Line(0,t.height,t.width/2,0),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width/2,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.bottom,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(t.width/2,t.height)]),r=new Phaser.Line(t.left,t.top,t.left+t.width/2,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(0,t.height/2)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height/2),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height/2)]),r=new Phaser.Line(t.left,t.top,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height/2)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top+t.height),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset=function(e){var t=parseInt(e);return t=isNaN(t)||"number"!=typeof t?0:t-1},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var t={};return t[offset+1]="FULL",t[offset+2]="HALF_TOP",t[offset+3]="HALF_BOTTOM",t[offset+4]="HALF_LEFT",t[offset+5]="HALF_RIGHT",t[offset+6]="HALF_BOTTOM_LEFT",t[offset+7]="HALF_BOTTOM_RIGHT",t[offset+8]="HALF_TOP_LEFT",t[offset+9]="HALF_TOP_RIGHT",t[offset+10]="QUARTER_TOP_LEFT_HIGH",t[offset+11]="QUARTER_TOP_LEFT_LOW",t[offset+12]="QUARTER_TOP_RIGHT_LOW",t[offset+13]="QUARTER_TOP_RIGHT_HIGH",t[offset+14]="QUARTER_BOTTOM_LEFT_HIGH",t[offset+15]="QUARTER_BOTTOM_LEFT_LOW",t[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",t[offset+17]="QUARTER_BOTTOM_RIGHT_HIGH",t[offset+18]="QUARTER_LEFT_BOTTOM_HIGH",t[offset+19]="QUARTER_RIGHT_BOTTOM_HIGH",t[offset+20]="QUARTER_LEFT_TOP_HIGH",t[offset+21]="QUARTER_RIGHT_TOP_HIGH",t[offset+35]="QUARTER_LEFT_BOTTOM_LOW",t[offset+36]="QUARTER_RIGHT_BOTTOM_LOW",t[offset+37]="QUARTER_LEFT_TOP_LOW",t[offset+38]="QUARTER_RIGHT_TOP_LOW",t},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var t={};return t[offset+2]="FULL",t[offset+3]="HALF_BOTTOM_LEFT",t[offset+4]="HALF_BOTTOM_RIGHT",t[offset+6]="HALF_TOP_LEFT",t[offset+5]="HALF_TOP_RIGHT",t[offset+15]="QUARTER_BOTTOM_LEFT_LOW",t[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",t[offset+17]="QUARTER_TOP_RIGHT_LOW",t[offset+18]="QUARTER_TOP_LEFT_LOW",t[offset+19]="QUARTER_BOTTOM_LEFT_HIGH",t[offset+20]="QUARTER_BOTTOM_RIGHT_HIGH",t[offset+21]="QUARTER_TOP_RIGHT_HIGH",t[offset+22]="QUARTER_TOP_LEFT_HIGH",t[offset+23]="QUARTER_LEFT_BOTTOM_HIGH",t[offset+24]="QUARTER_RIGHT_BOTTOM_HIGH",t[offset+25]="QUARTER_RIGHT_TOP_LOW",t[offset+26]="QUARTER_LEFT_TOP_LOW",t[offset+27]="QUARTER_LEFT_BOTTOM_LOW",t[offset+28]="QUARTER_RIGHT_BOTTOM_LOW",t[offset+29]="QUARTER_RIGHT_TOP_HIGH",t[offset+30]="QUARTER_LEFT_TOP_HIGH",t[offset+31]="HALF_BOTTOM",t[offset+32]="HALF_RIGHT",t[offset+33]="HALF_TOP",t[offset+34]="HALF_LEFT",t},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES=1,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA=2,function(e,t){"use strict";"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.SAT=t()}(this,function(){"use strict";function e(e,t){this.x=e||0,this.y=t||0}function t(t,o){this.pos=t||new e,this.r=o||0}function o(t,o){this.pos=t||new e,this.angle=0,this.offset=new e,this.setPoints(o||[])}function r(t,o,r){this.pos=t||new e,this.w=o||0,this.h=r||0}function l(){this.a=null,this.b=null,this.overlapN=new e,this.overlapV=new e,this.clear()}function i(e,t,o){for(var r=Number.MAX_VALUE,l=-Number.MAX_VALUE,i=e.length,s=0;i>s;s++){var n=e[s].dot(t);r>n&&(r=n),n>l&&(l=n)}o[0]=r,o[1]=l}function s(e,t,o,r,l,s){var n=d.pop(),p=d.pop(),a=S.pop().copy(t).sub(e),h=a.dot(l);if(i(o,l,n),i(r,l,p),p[0]+=h,p[1]+=h,n[0]>p[1]||p[0]>n[1])return S.push(a),d.push(n),d.push(p),!0;if(s){var T=0;if(n[0]c?c:-g}else if(s.bInA=!1,n[1]>p[1])T=n[0]-p[1],s.aInB=!1;else{var c=n[1]-p[0],g=p[1]-n[0];T=g>c?c:-g}var u=Math.abs(T);uT&&s.overlapN.reverse())}return S.push(a),d.push(n),d.push(p),!1}function n(e,t){var o=e.len2(),r=t.dot(e);return 0>r?y:r>o?_:R}function p(e,t){var o=S.pop().copy(e).sub(t.pos),r=t.r*t.r,l=o.len2();return S.push(o),r>=l}function a(e,t){f.pos.copy(e),A.clear();var o=g(f,t,A);return o&&(o=A.aInB),o}function h(e,t,o){var r=S.pop().copy(t.pos).sub(e.pos),l=e.r+t.r,i=l*l,s=r.len2();if(s>i)return S.push(r),!1;if(o){var n=Math.sqrt(s);o.a=e,o.b=t,o.overlap=l-n,o.overlapN.copy(r.normalize()),o.overlapV.copy(r).scale(o.overlap),o.aInB=e.r<=t.r&&n<=t.r-e.r,o.bInA=t.r<=e.r&&n<=e.r-t.r}return S.push(r),!0}function T(e,t,o){for(var r=S.pop().copy(t.pos).sub(e.pos),l=t.r,i=l*l,s=e.calcPoints,p=s.length,a=S.pop(),h=S.pop(),T=0;p>T;T++){var c=T===p-1?0:T+1,g=0===T?p-1:T-1,u=0,P=null;a.copy(e.edges[T]),h.copy(r).sub(s[T]),o&&h.len2()>i&&(o.aInB=!1);var d=n(a,h);if(d===y){a.copy(e.edges[g]);var A=S.pop().copy(r).sub(s[g]);if(d=n(a,A),d===_){var f=h.len();if(f>l)return S.push(r),S.push(a),S.push(h),S.push(A),!1;o&&(o.bInA=!1,P=h.normalize(),u=l-f)}S.push(A)}else if(d===_){if(a.copy(e.edges[c]),h.copy(r).sub(s[c]),d=n(a,h),d===y){var f=h.len();if(f>l)return S.push(r),S.push(a),S.push(h),!1;o&&(o.bInA=!1,P=h.normalize(),u=l-f)}}else{var R=a.perp().normalize(),f=h.dot(R),O=Math.abs(f);if(f>0&&O>l)return S.push(r),S.push(R),S.push(h),!1;o&&(P=R,u=l-f,(f>=0||2*l>u)&&(o.bInA=!1))}P&&o&&Math.abs(u)p;p++)if(s(e.pos,t.pos,r,i,e.normals[p],o))return!1;for(var p=0;n>p;p++)if(s(e.pos,t.pos,r,i,t.normals[p],o))return!1;return o&&(o.a=e,o.b=t,o.overlapV.copy(o.overlapN).scale(o.overlap)),!0}var u={};u.Vector=e,u.V=e,e.prototype.copy=e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.clone=e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.perp=e.prototype.perp=function(){var e=this.x;return this.x=this.y,this.y=-e,this},e.prototype.rotate=e.prototype.rotate=function(e){var t=this.x,o=this.y;return this.x=t*Math.cos(e)-o*Math.sin(e),this.y=t*Math.sin(e)+o*Math.cos(e),this},e.prototype.reverse=e.prototype.reverse=function(){return this.x=-this.x,this.y=-this.y,this},e.prototype.normalize=e.prototype.normalize=function(){var e=this.len();return e>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,t){return this.x*=e,this.y*=t||e,this},e.prototype.project=e.prototype.project=function(e){var t=this.dot(e)/e.len2();return this.x=t*e.x,this.y=t*e.y,this},e.prototype.projectN=e.prototype.projectN=function(e){var t=this.dot(e);return this.x=t*e.x,this.y=t*e.y,this},e.prototype.reflect=e.prototype.reflect=function(e){var t=this.x,o=this.y;return this.project(e).scale(2),this.x-=t,this.y-=o,this},e.prototype.reflectN=e.prototype.reflectN=function(e){var t=this.x,o=this.y;return this.projectN(e).scale(2),this.x-=t,this.y-=o,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())},u.Circle=t,t.prototype.getAABB=t.prototype.getAABB=function(){var t=this.r,o=this.pos.clone().sub(new e(t,t));return new r(o,2*t,2*t).toPolygon()},u.Polygon=o,o.prototype.setPoints=o.prototype.setPoints=function(t){var o=!this.points||this.points.length!==t.length;if(o){var r,l=this.calcPoints=[],i=this.edges=[],s=this.normals=[];for(r=0;rr;r++)t[r].rotate(e);return this._recalc(),this},o.prototype.translate=o.prototype.translate=function(e,t){for(var o=this.points,r=o.length,l=0;r>l;l++)o[l].x+=e,o[l].y+=t;return this._recalc(),this},o.prototype._recalc=function(){var e,t=this.calcPoints,o=this.edges,r=this.normals,l=this.points,i=this.offset,s=this.angle,n=l.length;for(e=0;n>e;e++){var p=t[e].copy(l[e]);p.x+=i.x,p.y+=i.y,0!==s&&p.rotate(s)}for(e=0;n>e;e++){var a=t[e],h=n-1>e?t[e+1]:t[0],T=o[e].copy(h).sub(a);r[e].copy(T).perp().normalize()}return this},o.prototype.getAABB=o.prototype.getAABB=function(){for(var t=this.calcPoints,o=t.length,l=t[0].x,i=t[0].y,s=t[0].x,n=t[0].y,p=1;o>p;p++){var a=t[p];a.xs&&(s=a.x),a.yn&&(n=a.y)}return new r(this.pos.clone().add(new e(l,i)),s-l,n-i).toPolygon()},u.Box=r,r.prototype.toPolygon=r.prototype.toPolygon=function(){var t=this.pos,r=this.w,l=this.h;return new o(new e(t.x,t.y),[new e,new e(r,0),new e(r,l),new e(0,l)])},u.Response=l,l.prototype.clear=l.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this};for(var S=[],P=0;10>P;P++)S.push(new e);for(var d=[],P=0;5>P;P++)d.push([]);var A=new l,f=new r(new e,1e-6,1e-6).toPolygon();u.isSeparatingAxis=s;var y=-1,R=0,_=1;return u.pointInCircle=p,u.pointInPolygon=a,u.testCircleCircle=h,u.testPolygonCircle=T,u.testCirclePolygon=c,u.testPolygonPolygon=g,u}); \ No newline at end of file +Phaser.Plugin.ArcadeSlopes=function(e,t,o){Phaser.Plugin.call(this,e,t);var r={};r[Phaser.Plugin.ArcadeSlopes.SAT]=new Phaser.Plugin.ArcadeSlopes.SatSolver,this.facade=new Phaser.Plugin.ArcadeSlopes.Facade(new Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,r,o||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.2.0",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,t,o){this.factory=e,this.solvers=t,this.defaultSolver=o||Phaser.Plugin.ArcadeSlopes.SAT,this.plugin=null},Phaser.Plugin.ArcadeSlopes.Facade.prototype.enable=function(e){if(Array.isArray(e))for(var t=0;t0&&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,heuristics:null,preferY:!1,pullUp:0,pullDown:0,pullLeft:0,pullRight:0,pullTopLeft:0,pullTopRight:0,pullBottomLeft:0,pullBottomRight:0,sat:{response:null},skipFriction:!1,snapUp:0,snapDown:0,snapLeft:0,snapRight:0,tile:null,velocity:new SAT.Vector}},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemap=function(e,t,o,r){return this.factory.convertTilemap(e,t,o,r)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.convertTilemapLayer=function(e,t,o){return this.factory.convertTilemapLayer(e,t,o)},Phaser.Plugin.ArcadeSlopes.Facade.prototype.collide=function(e,t,o,r,l){return this.solvers.sat.collide(e,t,o,r,l)},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,t,o,r,l,i,s,n){if(!t.body)return!1;if(o.hasOwnProperty("slope")){if(this.game.slopes.collide(e,t.body,o,r,n))return this._total++,l&&l.call(s,t,o),!0}else if(this.separateTile(e,t.body,o,r,n))return this._total++,l&&l.call(s,t,o),!0;return!1},Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles=function(e,t,o,r,l,i,s){var n=!1;if(!e.body)return n;for(var p=0;p0&&o>0?this.layers[e].data[o-1][t-1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileTopRight=function(e,t,o){return t0?this.layers[e].data[o-1][t+1]:null},Phaser.Plugin.ArcadeSlopes.Overrides.getTileBottomLeft=function(e,t,o){return t>0&&o=g&&(g=Math.max(0,g),u=Math.min(n-1,u)),P>=S&&(S=Math.max(0,S),P=Math.min(p-1,P)));var d,A,f,y,R,_,O,w,L,v=g*a-e,E=S*h-t,H=(g+(1<<20)*n)%n,I=(S+(1<<20)*p)%p;for(y=I,_=P-S,A=E;_>=0;y++,_--,A+=h){y>=p&&(y-=p);var b=this.layer.data[y];for(f=H,R=u-g,d=v;R>=0;f++,R--,d+=a){f>=n&&(f-=n);var F=b[f];if(F&&!(F.index<0)&&F.collides&&(this.debugSettings.collidingTileOverfill&&(o.fillStyle=this.debugSettings.collidingTileOverfill,o.fillRect(d,A,T,c)),this.debugSettings.facingEdgeStroke&&(o.beginPath(),o.lineWidth=1,o.strokeStyle=this.debugSettings.facingEdgeStroke,F.faceTop&&(o.moveTo(d,A),o.lineTo(d+T,A)),F.faceBottom&&(o.moveTo(d,A+c),o.lineTo(d+T,A+c)),F.faceLeft&&(o.moveTo(d,A),o.lineTo(d,A+c)),F.faceRight&&(o.moveTo(d+T,A),o.lineTo(d+T,A+c)),o.closePath(),o.stroke(),F.slope))){if(this.debugSettings.slopeEdgeStroke||this.debugSettings.slopeFill){for(o.beginPath(),o.lineWidth=1,O=F.slope.polygon,o.moveTo(d+O.points[0].x*i,A+O.points[0].y*s),w=0;w-1:s.slope.type===o.slope.type,i.hasOwnProperty("overlapX")&&(n="number"==typeof i.overlapX?n&&r.overlapN.x===i.overlapX:n&&r.overlapN.x>=i.overlapX[0]&&r.overlapN.x<=i.overlapX[1]),i.hasOwnProperty("overlapY")&&(n="number"==typeof i.overlapY?n&&r.overlapN.y===i.overlapY:n&&r.overlapN.y>=i.overlapY[0]&&r.overlapN.y<=i.overlapY[1]),n){var p=i.separate;"function"==typeof p&&(p=p.call(this,t,o,r));var a=o.slope.axis;return p instanceof SAT.Vector&&(a=p),p&&a&&e.collideOnAxis(t,o,a),!1}}}return!0},Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps=function(e){switch(e){case"up":return{overlapX:0,overlapY:[-1,0]};case"down":return{overlapX:0,overlapY:[0,1]};case"left":return{overlapX:[-1,0],overlapY:0};case"right":return{overlapX:[0,1],overlapY:0};case"any":return{}}return console.warn("Unknown overlap direction '"+e+"'"),{}},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints=function(e){var t={};for(var o in e){var r=e[o];for(var l in r){var i=r[l];if(i.direction){var s=Phaser.Plugin.ArcadeSlopes.SatRestrainer.resolveOverlaps(i.direction);s.hasOwnProperty("overlapX")&&(i.overlapX=s.overlapX),s.hasOwnProperty("overlapY")&&(i.overlapY=s.overlapY)}for(var n in i.types)i.types[n]=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(i.types[n]);i.separate!==!1&&"function"!=typeof i.separate&&(i.separate=!0)}var p=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(o);t[p]=r}return t},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.fullTileSeparation=function(e,t,o){return e.top0&&Math.abs(e.velocity.y)>Math.abs(e.velocity.x)?(this.separationAxis.x=0,this.separationAxis.y=-1,this.separationAxis):e.bottom>t.worldY+t.centerY&&t.collideDown&&t.slope.edges.bottom!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY&&e.slopes.velocity.y<0&&Math.abs(e.slopes.velocity.y)>Math.abs(e.slopes.velocity.x)?(this.separationAxis.x=0,this.separationAxis.y=1,this.separationAxis):e.left0&&Math.abs(e.slopes.velocity.x)>Math.abs(e.slopes.velocity.y)?(this.separationAxis.x=-1,this.separationAxis.y=0,this.separationAxis):e.right>t.worldX+t.centerX&&t.collideRight&&t.slope.edges.right!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY&&e.slopes.velocity.x<0&&Math.abs(e.slopes.velocity.x)>Math.abs(e.slopes.velocity.y)?(this.separationAxis.x=1,this.separationAxis.y=0,this.separationAxis):!0},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.setDefaultRestraints=function(){var e={};e.FULL=[{direction:"up",neighbour:"above",types:this.resolve("bottomLeft","bottomRight"),separate:this.fullTileSeparation},{direction:"down",neighbour:"below",types:this.resolve("topLeft","topRight"),separate:this.fullTileSeparation},{direction:"left",neighbour:"left",types:this.resolve("topRight","bottomRight"),separate:this.fullTileSeparation},{direction:"right",neighbour:"right",types:this.resolve("topLeft","bottomLeft"),separate:this.fullTileSeparation}],e.HALF_TOP=[{direction:"left",neighbour:"left",types:this.resolve("topRight","right"),separate:!1},{direction:"right",neighbour:"right",types:this.resolve("topLeft","left"),separate:!1}],e.HALF_BOTTOM=[{direction:"left",neighbour:"left",types:this.resolve("right","bottomRight"),separate:!1},{direction:"right",neighbour:"right",types:this.resolve("left","bottomLeft"),separate:!1}],e.HALF_LEFT=[{direction:"up",neighbour:"above",types:this.resolve("bottomLeft","bottom"),separate:!1},{direction:"down",neighbour:"below",types:this.resolve("topLeft","top"),separate:!1}],e.HALF_RIGHT=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:!1},{direction:"down",neighbour:"below",types:this.resolve("top","topRight"),separate:!1}],e.HALF_BOTTOM_LEFT=[{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")},{direction:"up",neighbour:"topLeft",types:this.resolve("bottomRight")}],e.HALF_BOTTOM_RIGHT=[{direction:"left",neighbour:"bottomLeft",types:this.resolve("topRight")},{direction:"up",neighbour:"topRight",types:this.resolve("bottomLeft")}],e.HALF_TOP_LEFT=[{direction:"right",neighbour:"topRight",types:this.resolve("bottomLeft")},{direction:"down",neighbour:"bottomLeft",types:this.resolve("topRight")}],e.HALF_TOP_RIGHT=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_BOTTOM_LEFT_LOW=[{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")},{direction:"up",neighbour:"left",types:this.resolve("topLeft","right","bottomRight")},{direction:"left",neighbour:"left",types:this.resolve("right","bottomRight"),separate:!1}],e.QUARTER_BOTTOM_LEFT_HIGH=[{direction:"right",neighbour:"right",types:this.resolve("left","bottomLeft"),separate:function(e,t){return e.bottomt.left}},{direction:"right",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_LEFT_BOTTOM_HIGH=[{direction:"up",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"below",types:this.resolve("topLeft","top"),separate:!1},{direction:"right",neighbour:"below",types:this.resolve("topLeft","top","bottomRight")}],e.QUARTER_RIGHT_BOTTOM_LOW=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:function(e,t){return e.rightt.left}}],e.QUARTER_RIGHT_TOP_LOW=[{direction:"up",neighbour:"above",types:this.resolve("bottom","bottomRight")},{direction:"left",neighbour:"above",types:this.resolve("bottom","bottomRight"),separate:!1},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],e.QUARTER_RIGHT_TOP_HIGH=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"down",neighbour:"below",types:this.resolve("top","topRight"),separate:function(e,t){return e.rightt.top}},{direction:"down",neighbour:"bottomLeft",types:this.resolve("topRight")}],e.QUARTER_TOP_RIGHT_LOW=[{direction:"left",neighbour:"topLeft",types:this.resolve("bottomRight")},{direction:"right",neighbour:"right",types:this.resolve("topLeft","left"),separate:!1},{direction:"down",neighbour:"right",types:this.resolve("bottomRight","topLeft","left")}],e.QUARTER_TOP_RIGHT_HIGH=[{direction:"left",neighbour:"left",types:this.resolve("topRight","right"),separate:function(e,t){return e.top>t.top}},{direction:"down",neighbour:"bottomRight",types:this.resolve("topLeft")}],this.informalRestraints=JSON.parse(JSON.stringify(e)),this.restraints=Phaser.Plugin.ArcadeSlopes.SatRestrainer.prepareRestraints(e)},Phaser.Plugin.ArcadeSlopes.SatRestrainer.intersectArrays=function(e,t){return e.filter(function(e){return-1!==t.indexOf(e)}).filter(function(e,t,o){return o.indexOf(e)===t})},Phaser.Plugin.ArcadeSlopes.SatRestrainer.prototype.resolve=function(){var e=[];if(!arguments.length)return e;for(var t in arguments){var o=arguments[t];if(Phaser.Plugin.ArcadeSlopes.SatRestrainer.hasOwnProperty(o+"Vertices")){var r=Array.prototype.slice.call(Phaser.Plugin.ArcadeSlopes.SatRestrainer[o+"Vertices"]);if(1===arguments.length)return r;e=e.length?Phaser.Plugin.ArcadeSlopes.SatRestrainer.intersectArrays(e,r):r}else console.warn("Tried to resolve types from undefined vertex map location '"+o+"'")}return e},Phaser.Plugin.ArcadeSlopes.SatRestrainer.topVertices=["HALF_LEFT","HALF_RIGHT","QUARTER_LEFT_TOP_LOW","QUARTER_RIGHT_TOP_LOW","QUARTER_LEFT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomVertices=["HALF_LEFT","HALF_RIGHT","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.leftVertices=["HALF_TOP","HALF_BOTTOM","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_RIGHT_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.rightVertices=["HALF_TOP","HALF_BOTTOM","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.topLeftVertices=["FULL","HALF_TOP","HALF_LEFT","HALF_TOP_LEFT","HALF_TOP_RIGHT","HALF_BOTTOM_LEFT","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_LEFT_TOP_LOW","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_TOP_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.topRightVertices=["FULL","HALF_TOP","HALF_RIGHT","HALF_TOP_LEFT","HALF_TOP_RIGHT","HALF_BOTTOM_RIGHT","QUARTER_TOP_LEFT_LOW","QUARTER_TOP_LEFT_HIGH","QUARTER_TOP_RIGHT_LOW","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_TOP_HIGH","QUARTER_RIGHT_TOP_LOW","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomLeftVertices=["FULL","HALF_LEFT","HALF_BOTTOM","HALF_TOP_LEFT","HALF_BOTTOM_LEFT","HALF_BOTTOM_RIGHT","QUARTER_TOP_LEFT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_TOP_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_LEFT_BOTTOM_HIGH","QUARTER_RIGHT_BOTTOM_LOW"],Phaser.Plugin.ArcadeSlopes.SatRestrainer.bottomRightVertices=["FULL","HALF_RIGHT","HALF_BOTTOM","HALF_TOP_RIGHT","HALF_BOTTOM_LEFT","HALF_BOTTOM_RIGHT","QUARTER_TOP_RIGHT_HIGH","QUARTER_BOTTOM_LEFT_LOW","QUARTER_BOTTOM_LEFT_HIGH","QUARTER_BOTTOM_RIGHT_LOW","QUARTER_BOTTOM_RIGHT_HIGH","QUARTER_LEFT_BOTTOM_LOW","QUARTER_RIGHT_TOP_HIGH","QUARTER_RIGHT_BOTTOM_LOW","QUARTER_RIGHT_BOTTOM_HIGH"],Phaser.Plugin.ArcadeSlopes.SatSolver=function(e){this.options=Phaser.Utils.mixin(e||{},{debug:!1,preferY:!1,restrain:!0}),this.restrainers=[new Phaser.Plugin.ArcadeSlopes.SatRestrainer]},Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse=function(e){return e.overlapV.scale(-1),e.overlapN.scale(-1),e},Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse=function(e){return e.overlapN.x=0,e.overlapN.y=0,e.overlapV.x=0,e.overlapV.y=0,e.clear(),e},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetX=function(e){return e.y*e.y/e.x+e.x},Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY=function(e){return e.x*e.x/e.y+e.y},Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY=function(e,t){return t.overlapV.y<0&&e.velocity.y>0||t.overlapV.y>0&&e.velocity.y<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldPreferY=function(e,t){return(this.options.preferY||e.slopes.preferY)&&0!==t.overlapV.y&&0!==t.overlapV.x&&Phaser.Plugin.ArcadeSlopes.SatSolver.movingAgainstY(e,t)},Phaser.Plugin.ArcadeSlopes.SatSolver.isSeparatingAxis=function(e,t,o,r){var l=SAT.isSeparatingAxis(e.pos,t.pos,e.points,t.points,o,r||null);return r&&(r.a=e,r.b=t,r.overlapV=r.overlapN.clone().scale(r.overlap)),l},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.separate=function(e,t,o,r){return r||this.shouldSeparate(t.index,e,t,o)?t.collisionCallback&&!t.collisionCallback.call(t.collisionCallbackContext,e.sprite,t)?!1:t.layer.callbacks[t.index]&&!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e.sprite,t)?!1:(this.shouldPreferY(e,o)?e.position.y+=Phaser.Plugin.ArcadeSlopes.SatSolver.minimumOffsetY(o.overlapV):(e.position.x+=o.overlapV.x,e.position.y+=o.overlapV.y),!0):!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.applyVelocity=function(e,t,o){var r=e.slopes.velocity.clone().projectN(o.overlapN),l=e.slopes.velocity.clone().sub(r);r.x=r.x*-e.bounce.x,r.y=r.y*-e.bounce.y,l.x=l.x*(1-e.slopes.friction.x-t.slope.friction.x),l.y=l.y*(1-e.slopes.friction.y-t.slope.friction.y),e.velocity.x=r.x+l.x,e.velocity.y=r.y+l.y,this.pull(e,o)},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,t){e.touching.up=e.touching.up||t.overlapV.y>0,e.touching.down=e.touching.down||t.overlapV.y<0,e.touching.left=e.touching.left||t.overlapV.x>0,e.touching.right=e.touching.right||t.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===t.overlapV.x&&t.overlapV.y>0,e.blocked.down=e.blocked.down||0===t.overlapV.x&&t.overlapV.y<0,e.blocked.left=e.blocked.left||0===t.overlapV.y&&t.overlapV.x>0,e.blocked.right=e.blocked.right||0===t.overlapV.y&&t.overlapV.x<0},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.snap=function(e,t,o){if(!e.slopes||!e.slopes.snapUp&&!e.slopes.snapDown&&!e.slopes.snapLeft&&!e.slopes.snapRight)return!1;var r=new Phaser.Point(e.position.x,e.position.y);for(var l in t){var i=t[l];if(i.slope){if(e.slopes.snapUp&&(e.position.x=r.x,e.position.y=r.y-e.slopes.snapUp,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapDown&&(e.position.x=r.x,e.position.y=r.y+e.slopes.snapDown,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapLeft&&(e.position.x=r.x-e.slopes.snapLeft,e.position.y=r.y,this.snapCollide(e,i,o,r)))return!0;if(e.slopes.snapRight&&(e.position.x=r.x+e.slopes.snapRight,e.position.y=r.y,this.snapCollide(e,i,o,r)))return!0}}return!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.pull=function(e,t){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 o=t.overlapN.clone().scale(-1);return e.slopes.pullUp&&o.y<0?(pullUp=o.clone().scale(e.slopes.pullUp),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullDown&&o.y>0?(pullDown=o.clone().scale(e.slopes.pullDown),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullLeft&&o.x<0?(pullLeft=o.clone().scale(e.slopes.pullLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullRight&&o.x>0?(pullRight=o.clone().scale(e.slopes.pullRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):e.slopes.pullTopLeft&&o.x<0&&o.y<0?(pullUp=o.clone().scale(e.slopes.pullTopLeft),e.velocity.x+=pullUp.x,e.velocity.y+=pullUp.y,!0):e.slopes.pullTopRight&&o.x>0&&o.y<0?(pullDown=o.clone().scale(e.slopes.pullTopRight),e.velocity.x+=pullDown.x,e.velocity.y+=pullDown.y,!0):e.slopes.pullBottomLeft&&o.x<0&&o.y>0?(pullLeft=o.clone().scale(e.slopes.pullBottomLeft),e.velocity.x+=pullLeft.x,e.velocity.y+=pullLeft.y,!0):e.slopes.pullBottomRight&&o.x>0&&o.y>0?(pullRight=o.clone().scale(e.slopes.pullBottomRight),e.velocity.x+=pullRight.x,e.velocity.y+=pullRight.y,!0):!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.snapCollide=function(e,t,o,r){return this.collide(0,e,t,o)?!0:(e.position.x=r.x,e.position.y=r.y,!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldCollide=function(e,t){return e.enable&&e.polygon&&e.slopes&&t.collides&&t.slope&&t.slope.polygon},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collide=function(e,t,o,r,l){if(this.updateValues(t),!this.shouldCollide(t,o))return!1;t.isCircle&&(t.polygon.pos.x+=t.halfWidth,t.polygon.pos.y+=t.halfHeight),o.slope.polygon.pos.x=o.worldX+r.getCollisionOffsetX(),o.slope.polygon.pos.y=o.worldY+r.getCollisionOffsetY();var i=t.slopes.sat.response||new SAT.Response;return Phaser.Plugin.ArcadeSlopes.SatSolver.resetResponse(i),t.isCircle&&!SAT.testCirclePolygon(t.polygon,o.slope.polygon,i)||!t.isCircle&&!SAT.testPolygonPolygon(t.polygon,o.slope.polygon,i)?!1:l?!0:(Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse(i),this.separate(t,o,i)?(t.overlapX=i.overlapV.x,t.overlapY=i.overlapV.y,t.slopes.sat.response=i,t.slopes.tile=o,this.applyVelocity(t,o,i),this.updateFlags(t,i),!0):!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.collideOnAxis=function(e,t,o,r){if(this.updateValues(e),!this.shouldCollide(e,t)||e.isCircle)return!1;r=r||new SAT.Response;var l=Phaser.Plugin.ArcadeSlopes.SatSolver.isSeparatingAxis(e.polygon,t.slope.polygon,o,r);return l?!1:(Phaser.Plugin.ArcadeSlopes.SatSolver.prepareResponse(r),this.separate(e,t,r,!0)?(e.overlapX=r.overlapV.x,e.overlapY=r.overlapV.y,e.slopes.sat.response=r,this.applyVelocity(e,t,r),this.updateFlags(e,r),!0):!1)},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.restrain=function(e,t,o){for(var r in this.restrainers){var l=this.restrainers[r];if("function"==typeof l.restrain&&!l.restrain(this,e,t,o))return!0}return!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.shouldSeparate=function(e,t,o,r){return t.enable&&r.overlap?r.overlapV.clone().scale(-1).dot(t.slopes.velocity)<0?!1:(this.options.restrain||t.slopes.heuristics)&&t.slopes.heuristics!==!1&&!t.isCircle&&this.restrain(t,o,r)?!1:(!o.collideUp||o.slope.edges.top===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.y<0&&0===r.overlapN.x?!1:(!o.collideDown||o.slope.edges.bottom===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.y>0&&0===r.overlapN.x?!1:(!o.collideLeft||o.slope.edges.left===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY)&&r.overlapN.x<0&&0===r.overlapN.y?!1:o.collideRight&&o.slope.edges.right!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY||!(r.overlapN.x>0)||0!==r.overlapN.y:!1},Phaser.Plugin.ArcadeSlopes.SatSolver.prototype.debug=function(e,t){},Phaser.Plugin.ArcadeSlopes.TileSlope=function(e,t,o,r,l,i){this.type=e,this.tile=t,this.polygon=o,this.line=r,this.edges=Phaser.Utils.mixin(l||{},{top:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,bottom:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,left:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID,right:Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID}),this.axis=i||null,this.solver=null,this.friction=new Phaser.Point},Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType=function(e){return parseInt(e)>=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},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.constructor=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.define=function(e,t){"function"==typeof t&&(this.definitions[e]=t)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.create=function(e,t){var o=e;return e=Phaser.Plugin.ArcadeSlopes.TileSlope.resolveType(o),this.definitions.hasOwnProperty(e)?"function"!=typeof this.definitions[e]?(console.warn("Slope type definition for type "+o+" is not a function"),null):this.definitions[e].call(this,e,t):(console.warn("Slope type "+o+" not defined"),null)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemap=function(e,t,o,r){return t=e.getLayer(t),this.convertTilemapLayer(t,o,r),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.convertTilemapLayer=function(e,t,o){var r=this;if("string"==typeof t){var l=this.resolveMappingType(t);if(!this.mappings[l])return console.warn("Tilemap could not be converted; mapping type '"+t+"' is unknown"),e;t=this.mappings[l](o)}return e.layer.data.forEach(function(o){o.forEach(function(o){var l;o.properties.type&&(l=r.create(o.properties.type,o)),!l&&t.hasOwnProperty(o.index)&&(l=r.create(t[o.index],o)),l&&(o.slope=l);var i=o.x,s=o.y;o.neighbours=o.neighbours||{},o.neighbours.above=e.map.getTileAbove(e.index,i,s),o.neighbours.below=e.map.getTileBelow(e.index,i,s),o.neighbours.left=e.map.getTileLeft(e.index,i,s),o.neighbours.right=e.map.getTileRight(e.index,i,s),o.neighbours.topLeft=e.map.getTileTopLeft(e.index,i,s),o.neighbours.topRight=e.map.getTileTopRight(e.index,i,s),o.neighbours.bottomLeft=e.map.getTileBottomLeft(e.index,i,s),o.neighbours.bottomRight=e.map.getTileBottomRight(e.index,i,s)})}),this.calculateEdges(e),this.addDebugSettings(e),e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.calculateEdges=function(e){for(var t=null,o=null,r=null,l=null,i=0,s=e.layer.height;s>i;i++)for(var n=0,p=e.layer.width;p>n;n++){var a=e.layer.data[i][n];a&&a.hasOwnProperty("slope")&&(t=e.map.getTileAbove(e.index,n,i),o=e.map.getTileBelow(e.index,n,i),r=e.map.getTileLeft(e.index,n,i),l=e.map.getTileRight(e.index,n,i),t&&t.hasOwnProperty("slope")&&(a.slope.edges.top=this.compareEdges(a.slope.edges.top,t.slope.edges.bottom),a.collideUp=a.slope.edges.top!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,t)),o&&o.hasOwnProperty("slope")&&(a.slope.edges.bottom=this.compareEdges(a.slope.edges.bottom,o.slope.edges.top),a.collideDown=a.slope.edges.bottom!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,o)),r&&r.hasOwnProperty("slope")&&(a.slope.edges.left=this.compareEdges(a.slope.edges.left,r.slope.edges.right),a.collideLeft=a.slope.edges.left!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,r)),l&&l.hasOwnProperty("slope")&&(a.slope.edges.right=this.compareEdges(a.slope.edges.right,l.slope.edges.left),a.collideRight=a.slope.edges.right!==Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY,this.flagInternalVertices(a,l)))}},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.compareEdges=function(e,t){return e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&t===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e===Phaser.Plugin.ArcadeSlopes.TileSlope.SOLID&&t===Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY?Phaser.Plugin.ArcadeSlopes.TileSlope.EMPTY:e},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prototype.flagInternalVertices=function(e,t){if(e.slope.polygon&&t.slope.polygon)for(var o=e.slope.polygon,r=t.slope.polygon,l=new SAT.Vector(e.worldX,e.worldY),i=new SAT.Vector(t.worldX,t.worldY),s=0;s=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,t){var o=new SAT.Box(new SAT.Vector(t.worldX,t.worldY),t.width,t.height).toPolygon();return new Phaser.Plugin.ArcadeSlopes.TileSlope(e,t,o)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottom=function(e,t){var o=t.height/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,o),new SAT.Vector(t.width,o),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),l=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top+t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTop=function(e,t){var o=t.height/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,o),new SAT.Vector(0,o)]),l=new Phaser.Line(t.left,t.top,t.right,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfLeft=function(e,t){var o=t.width/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(o,0),new SAT.Vector(o,t.height),new SAT.Vector(0,t.height)]),l=new Phaser.Line(t.left+o,t.top,t.left+o,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfRight=function(e,t){var o=t.width/2,r=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(o,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(o,t.height)]),l=new Phaser.Line(t.left+o,t.top,t.left+o,t.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,t,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomLeft=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfBottomRight=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopLeft=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.right,t.top,t.left,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createHalfTopRight=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height)]),r=new Phaser.Line(t.right,t.bottom,t.left,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomLeftHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,t.height/2),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterBottomRightHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,t.height/2),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftBottomHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.top,t.left+t.width/2,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.left+t.width/2,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightBottomHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(t.width/2,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.bottom,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width/2,0),new SAT.Vector(0,t.height)]),r=new Phaser.Line(0,t.height,t.width/2,0),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterLeftTopHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width/2,t.height),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.bottom,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(t.width/2,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height)]),r=new Phaser.Line(t.left+t.width/2,t.top,t.right,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterRightTopHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(t.width/2,t.height)]),r=new Phaser.Line(t.left,t.top,t.left+t.width/2,t.bottom),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(0,t.height/2)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopLeftHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height/2),new SAT.Vector(0,t.height)]),r=new Phaser.Line(t.left,t.bottom,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightLow=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height/2)]),r=new Phaser.Line(t.left,t.top,t.right,t.top+t.height/2),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.createQuarterTopRightHigh=function(e,t){var o=new SAT.Polygon(new SAT.Vector(t.worldX,t.worldY),[new SAT.Vector(0,0),new SAT.Vector(t.width,0),new SAT.Vector(t.width,t.height),new SAT.Vector(0,t.height/2)]),r=new Phaser.Line(t.left,t.top+t.height/2,t.right,t.top+t.height),l={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,t,o,r,l,i)},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset=function(e){var t=parseInt(e);return t=isNaN(t)||"number"!=typeof t?0:t-1},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapArcadeSlopes=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var t={};return t[offset+1]="FULL",t[offset+2]="HALF_TOP",t[offset+3]="HALF_BOTTOM",t[offset+4]="HALF_LEFT",t[offset+5]="HALF_RIGHT",t[offset+6]="HALF_BOTTOM_LEFT",t[offset+7]="HALF_BOTTOM_RIGHT",t[offset+8]="HALF_TOP_LEFT",t[offset+9]="HALF_TOP_RIGHT",t[offset+10]="QUARTER_TOP_LEFT_HIGH",t[offset+11]="QUARTER_TOP_LEFT_LOW",t[offset+12]="QUARTER_TOP_RIGHT_LOW",t[offset+13]="QUARTER_TOP_RIGHT_HIGH",t[offset+14]="QUARTER_BOTTOM_LEFT_HIGH",t[offset+15]="QUARTER_BOTTOM_LEFT_LOW",t[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",t[offset+17]="QUARTER_BOTTOM_RIGHT_HIGH",t[offset+18]="QUARTER_LEFT_BOTTOM_HIGH",t[offset+19]="QUARTER_RIGHT_BOTTOM_HIGH",t[offset+20]="QUARTER_LEFT_TOP_HIGH",t[offset+21]="QUARTER_RIGHT_TOP_HIGH",t[offset+35]="QUARTER_LEFT_BOTTOM_LOW",t[offset+36]="QUARTER_RIGHT_BOTTOM_LOW",t[offset+37]="QUARTER_LEFT_TOP_LOW",t[offset+38]="QUARTER_RIGHT_TOP_LOW",t},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.mapNinjaPhysics=function(e){offset=Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.prepareOffset(e);var t={};return t[offset+2]="FULL",t[offset+3]="HALF_BOTTOM_LEFT",t[offset+4]="HALF_BOTTOM_RIGHT",t[offset+6]="HALF_TOP_LEFT",t[offset+5]="HALF_TOP_RIGHT",t[offset+15]="QUARTER_BOTTOM_LEFT_LOW",t[offset+16]="QUARTER_BOTTOM_RIGHT_LOW",t[offset+17]="QUARTER_TOP_RIGHT_LOW",t[offset+18]="QUARTER_TOP_LEFT_LOW",t[offset+19]="QUARTER_BOTTOM_LEFT_HIGH",t[offset+20]="QUARTER_BOTTOM_RIGHT_HIGH",t[offset+21]="QUARTER_TOP_RIGHT_HIGH",t[offset+22]="QUARTER_TOP_LEFT_HIGH",t[offset+23]="QUARTER_LEFT_BOTTOM_HIGH",t[offset+24]="QUARTER_RIGHT_BOTTOM_HIGH",t[offset+25]="QUARTER_RIGHT_TOP_LOW",t[offset+26]="QUARTER_LEFT_TOP_LOW",t[offset+27]="QUARTER_LEFT_BOTTOM_LOW",t[offset+28]="QUARTER_RIGHT_BOTTOM_LOW",t[offset+29]="QUARTER_RIGHT_TOP_HIGH",t[offset+30]="QUARTER_LEFT_TOP_HIGH",t[offset+31]="HALF_BOTTOM",t[offset+32]="HALF_RIGHT",t[offset+33]="HALF_TOP",t[offset+34]="HALF_LEFT",t},Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.ARCADESLOPES=1,Phaser.Plugin.ArcadeSlopes.TileSlopeFactory.NINJA=2,function(e,t){"use strict";"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.SAT=t()}(this,function(){"use strict";function e(e,t){this.x=e||0,this.y=t||0}function t(t,o){this.pos=t||new e,this.r=o||0}function o(t,o){this.pos=t||new e,this.angle=0,this.offset=new e,this.setPoints(o||[])}function r(t,o,r){this.pos=t||new e,this.w=o||0,this.h=r||0}function l(){this.a=null,this.b=null,this.overlapN=new e,this.overlapV=new e,this.clear()}function i(e,t,o){for(var r=Number.MAX_VALUE,l=-Number.MAX_VALUE,i=e.length,s=0;i>s;s++){var n=e[s].dot(t);r>n&&(r=n),n>l&&(l=n)}o[0]=r,o[1]=l}function s(e,t,o,r,l,s){var n=d.pop(),p=d.pop(),a=S.pop().copy(t).sub(e),h=a.dot(l);if(i(o,l,n),i(r,l,p),p[0]+=h,p[1]+=h,n[0]>p[1]||p[0]>n[1])return S.push(a),d.push(n),d.push(p),!0;if(s){var T=0;if(n[0]c?c:-g}else if(s.bInA=!1,n[1]>p[1])T=n[0]-p[1],s.aInB=!1;else{var c=n[1]-p[0],g=p[1]-n[0];T=g>c?c:-g}var u=Math.abs(T);uT&&s.overlapN.reverse())}return S.push(a),d.push(n),d.push(p),!1}function n(e,t){var o=e.len2(),r=t.dot(e);return 0>r?y:r>o?_:R}function p(e,t){var o=S.pop().copy(e).sub(t.pos),r=t.r*t.r,l=o.len2();return S.push(o),r>=l}function a(e,t){f.pos.copy(e),A.clear();var o=g(f,t,A);return o&&(o=A.aInB),o}function h(e,t,o){var r=S.pop().copy(t.pos).sub(e.pos),l=e.r+t.r,i=l*l,s=r.len2();if(s>i)return S.push(r),!1;if(o){var n=Math.sqrt(s);o.a=e,o.b=t,o.overlap=l-n,o.overlapN.copy(r.normalize()),o.overlapV.copy(r).scale(o.overlap),o.aInB=e.r<=t.r&&n<=t.r-e.r,o.bInA=t.r<=e.r&&n<=e.r-t.r}return S.push(r),!0}function T(e,t,o){for(var r=S.pop().copy(t.pos).sub(e.pos),l=t.r,i=l*l,s=e.calcPoints,p=s.length,a=S.pop(),h=S.pop(),T=0;p>T;T++){var c=T===p-1?0:T+1,g=0===T?p-1:T-1,u=0,P=null;a.copy(e.edges[T]),h.copy(r).sub(s[T]),o&&h.len2()>i&&(o.aInB=!1);var d=n(a,h);if(d===y){a.copy(e.edges[g]);var A=S.pop().copy(r).sub(s[g]);if(d=n(a,A),d===_){var f=h.len();if(f>l)return S.push(r),S.push(a),S.push(h),S.push(A),!1;o&&(o.bInA=!1,P=h.normalize(),u=l-f)}S.push(A)}else if(d===_){if(a.copy(e.edges[c]),h.copy(r).sub(s[c]),d=n(a,h),d===y){var f=h.len();if(f>l)return S.push(r),S.push(a),S.push(h),!1;o&&(o.bInA=!1,P=h.normalize(),u=l-f)}}else{var R=a.perp().normalize(),f=h.dot(R),O=Math.abs(f);if(f>0&&O>l)return S.push(r),S.push(R),S.push(h),!1;o&&(P=R,u=l-f,(f>=0||2*l>u)&&(o.bInA=!1))}P&&o&&Math.abs(u)p;p++)if(s(e.pos,t.pos,r,i,e.normals[p],o))return!1;for(var p=0;n>p;p++)if(s(e.pos,t.pos,r,i,t.normals[p],o))return!1;return o&&(o.a=e,o.b=t,o.overlapV.copy(o.overlapN).scale(o.overlap)),!0}var u={};u.Vector=e,u.V=e,e.prototype.copy=e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.clone=e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.perp=e.prototype.perp=function(){var e=this.x;return this.x=this.y,this.y=-e,this},e.prototype.rotate=e.prototype.rotate=function(e){var t=this.x,o=this.y;return this.x=t*Math.cos(e)-o*Math.sin(e),this.y=t*Math.sin(e)+o*Math.cos(e),this},e.prototype.reverse=e.prototype.reverse=function(){return this.x=-this.x,this.y=-this.y,this},e.prototype.normalize=e.prototype.normalize=function(){var e=this.len();return e>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,t){return this.x*=e,this.y*=t||e,this},e.prototype.project=e.prototype.project=function(e){var t=this.dot(e)/e.len2();return this.x=t*e.x,this.y=t*e.y,this},e.prototype.projectN=e.prototype.projectN=function(e){var t=this.dot(e);return this.x=t*e.x,this.y=t*e.y,this},e.prototype.reflect=e.prototype.reflect=function(e){var t=this.x,o=this.y;return this.project(e).scale(2),this.x-=t,this.y-=o,this},e.prototype.reflectN=e.prototype.reflectN=function(e){var t=this.x,o=this.y;return this.projectN(e).scale(2),this.x-=t,this.y-=o,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())},u.Circle=t,t.prototype.getAABB=t.prototype.getAABB=function(){var t=this.r,o=this.pos.clone().sub(new e(t,t));return new r(o,2*t,2*t).toPolygon()},u.Polygon=o,o.prototype.setPoints=o.prototype.setPoints=function(t){var o=!this.points||this.points.length!==t.length;if(o){var r,l=this.calcPoints=[],i=this.edges=[],s=this.normals=[];for(r=0;rr;r++)t[r].rotate(e);return this._recalc(),this},o.prototype.translate=o.prototype.translate=function(e,t){for(var o=this.points,r=o.length,l=0;r>l;l++)o[l].x+=e,o[l].y+=t;return this._recalc(),this},o.prototype._recalc=function(){var e,t=this.calcPoints,o=this.edges,r=this.normals,l=this.points,i=this.offset,s=this.angle,n=l.length;for(e=0;n>e;e++){var p=t[e].copy(l[e]);p.x+=i.x,p.y+=i.y,0!==s&&p.rotate(s)}for(e=0;n>e;e++){var a=t[e],h=n-1>e?t[e+1]:t[0],T=o[e].copy(h).sub(a);r[e].copy(T).perp().normalize()}return this},o.prototype.getAABB=o.prototype.getAABB=function(){for(var t=this.calcPoints,o=t.length,l=t[0].x,i=t[0].y,s=t[0].x,n=t[0].y,p=1;o>p;p++){var a=t[p];a.xs&&(s=a.x),a.yn&&(n=a.y)}return new r(this.pos.clone().add(new e(l,i)),s-l,n-i).toPolygon()},u.Box=r,r.prototype.toPolygon=r.prototype.toPolygon=function(){var t=this.pos,r=this.w,l=this.h;return new o(new e(t.x,t.y),[new e,new e(r,0),new e(r,l),new e(0,l)])},u.Response=l,l.prototype.clear=l.prototype.clear=function(){return this.aInB=!0,this.bInA=!0,this.overlap=Number.MAX_VALUE,this};for(var S=[],P=0;10>P;P++)S.push(new e);for(var d=[],P=0;5>P;P++)d.push([]);var A=new l,f=new r(new e,1e-6,1e-6).toPolygon();u.isSeparatingAxis=s;var y=-1,R=0,_=1;return u.pointInCircle=p,u.pointInPolygon=a,u.testCircleCircle=h,u.testPolygonCircle=T,u.testCirclePolygon=c,u.testPolygonPolygon=g,u}); \ No newline at end of file