From 91e47c060d304b3cbe13faec251c3db5529827f9 Mon Sep 17 00:00:00 2001 From: Derek Detweiler Date: Tue, 20 Oct 2015 14:57:57 -0400 Subject: [PATCH] Recording node references to speed up node retrieval by id in the NodeMap component. --- lib/platypus.combined.js | 97 +++++++++++++++++++++++++++++++++------ lib/platypus.min.js | 14 +++--- src/components/NodeMap.js | 20 ++++---- 3 files changed, 101 insertions(+), 30 deletions(-) diff --git a/lib/platypus.combined.js b/lib/platypus.combined.js index c24864a0..4dddfecf 100644 --- a/lib/platypus.combined.js +++ b/lib/platypus.combined.js @@ -27,7 +27,7 @@ this.platypus = this.platypus || {}; * @type String * @static **/ - platypus.buildDate = /*=date*/"Mon, 19 Oct 2015 21:14:39 GMT"; // injected by build process + platypus.buildDate = /*=date*/"Tue, 20 Oct 2015 18:50:23 GMT"; // injected by build process })(); @@ -2823,6 +2823,10 @@ platypus.Entity = (function () { * @readonly */ this.playing = false; + + this._visible = true; + + this._updating = false; // Set up initial playthrough. if (textures.length < 2) { @@ -2838,6 +2842,22 @@ platypus.Entity = (function () { Object.defineProperties(prototype, { /** + * The visibility of the sprite. + * + * @property visible + * @memberof PIXI.DisplayObject# + */ + visible: { + get: function () { + return this._visible; + }, + set: function (value) { + this._visible = value; + this._syncUpdate(); + } + }, + + /** * The PIXIAnimations current frame index * * @member {number} @@ -2863,7 +2883,7 @@ platypus.Entity = (function () { } this.playing = false; - PIXI.ticker.shared.remove(this.update, this); + this._syncUpdate(); }; /** @@ -2876,7 +2896,21 @@ platypus.Entity = (function () { } this.playing = true; - PIXI.ticker.shared.add(this.update, this); + this._syncUpdate(); + }; + + prototype._syncUpdate = function () { + var update = this.playing && this._visible; + + if (update !== this._updating) { + this._updating = update; + + if (update) { + PIXI.ticker.shared.add(this.update, this); + } else { + PIXI.ticker.shared.remove(this.update, this); + } + } }; /** @@ -15014,12 +15048,13 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on var i = 0; this.owner.map = this.map = []; + this.nodes = {}; this.residentsAwaitingNode = []; if (definition.map) { for (i = 0; i < definition.map.length; i++) { - this.map.push(new Node(definition.map[i], this)); + this.addNode(new Node(definition.map[i], this)); } } }, @@ -15036,8 +15071,8 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on } else { node = new Node(nodeDefinition, this); } - - this.map.push(node); + + this.addNode(node); for (i = this.residentsAwaitingNode.length - 1; i >= 0; i--) { entity = this.residentsAwaitingNode[i]; @@ -15063,6 +15098,11 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on }, publicMethods: { + addNode: function (node) { + this.map.push(node); + this.nodes[node.id] = node; + }, + getNode: function () { var i = 0, id = '', @@ -15081,12 +15121,8 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on id += divider + args[i]; divider = '|'; } - for (i = 0; i < this.map.length; i++) { - if (this.map[i].id === id) { - return this.map[i]; - } - } - return null; + + return this.nodes[id] || null; }, /** @@ -17932,6 +17968,7 @@ This component will destroy the entity once an animation has finished. This is u "cache": function () { this.updateSprite(false); this.owner.cacheRender = this.container; + this.cache = true; if (this.owner.parent && this.owner.parent.triggerEventOnChildren) { /** * On receiving a "cache" event, this component triggers "cache-sprite" to cache its rendering into the background. This is an optimization for static images to reduce render calls. @@ -18627,6 +18664,9 @@ This component will destroy the entity once an animation has finished. This is u } this.removePins(); this.followThroughs = null; + if (!this.cache) { + this.sprite.destroy(); + } this.sprite = null; } } @@ -18656,6 +18696,7 @@ This component will destroy the entity once an animation has finished. This is u var AABB = include('platypus.AABB'), Animation = include('platypus.PIXIAnimation'), Application = include('springroll.Application'), + CanvasRenderer = include('PIXI.CanvasRenderer'), Container = include('PIXI.Container'), Graphics = include('PIXI.Graphics'), ParticleContainer = include('PIXI.ParticleContainer'), @@ -18703,7 +18744,8 @@ This component will destroy the entity once an animation has finished. This is u tile.template = this; // backwards reference for clearing index later. }, nullTemplate = { - getNext: doNothing + getNext: doNothing, + destroy: doNothing }, prototype = Template.prototype; @@ -18729,6 +18771,16 @@ This component will destroy the entity once an animation has finished. This is u prototype.clear = function () { this.index = 0; }; + + prototype.destroy = function () { + var i = 0; + + for (i = 0; i < this.instances.length; i++) { + this.instances[i].destroy(); + } + + this.instances.length = 0; + }; return platypus.createComponentClass({ @@ -18840,6 +18892,7 @@ This component will destroy the entity once an animation has finished. This is u var imgMap = this.imageMap; this.doMap = null; //list of display objects that should overlay tile map. + this.cachedDisplayObjects = null; this.populate = this.populateTiles; this.tiles = {}; @@ -18858,7 +18911,7 @@ This component will destroy the entity once an animation has finished. This is u this.cachePixels = new AABB(); // Set up containers - this.tileContainer = (this.spriteSheet.images.length > 1) ? new Container() : new ParticleContainer(15000, {position: true, rotation: true, scale: true}); + this.tileContainer = ((this.spriteSheet.images.length > 1) || (this.renderer instanceof CanvasRenderer)) ? new Container() : new ParticleContainer(15000, {position: true, rotation: true, scale: true}); this.mapContainer = new Container(); this.mapContainer.addChild(this.tileContainer); @@ -19156,8 +19209,10 @@ This component will destroy the entity once an animation has finished. This is u if (this.entityCache && object) { //TODO: currently only handles a single display object on the cached entity. if (!this.doMap) { this.doMap = []; + this.cachedDisplayObjects = []; this.populate = this.populateTilesAndEntities; } + this.cachedDisplayObjects.push(object); // Determine range: bounds = object.getBounds(object.transformMatrix); @@ -19422,6 +19477,7 @@ This component will destroy the entity once an animation has finished. This is u destroy: function () { var x = 0, y = 0, + key = '', grid = this.cacheGrid; if (grid) { @@ -19442,9 +19498,22 @@ This component will destroy the entity once an animation has finished. This is u this.parentContainer.removeChild(this.mapContainer); } this.imageMap.length = 0; + + for (key in this.tiles) { + if (this.tiles.hasOwnProperty(key)) { + this.tiles[key].destroy(); + } + } this.tiles = null; this.parentContainer = null; this.tilesSprite = null; + + if (this.cachedDisplayObjects) { + for (x = 0; x < this.cachedDisplayObjects.length; x++) { + this.cachedDisplayObjects[x].destroy(); + } + this.cachedDisplayObjects.length = 0; + } } } }); diff --git a/lib/platypus.min.js b/lib/platypus.min.js index 8e84877a..f8c054c7 100644 --- a/lib/platypus.min.js +++ b/lib/platypus.min.js @@ -6,10 +6,10 @@ * * This notice shall be included in all copies or substantial portions of the Software. */ -this.platypus=this.platypus||{},function(){"use strict";platypus.version="NEXT",platypus.buildDate="Mon, 19 Oct 2015 21:14:39 GMT"}(),platypus.Game=function(){"use strict";var a=null,b=null,c={},d=function(a,b){b["fade-to-black"]=function(b,c,d){var e=b.stage,f=springroll.Application.instance.display.canvas,g=new PIXI.Graphics;g.beginFill("#000").drawRect(0,0,f.width,f.height),g.alpha=0,e.addChild(g),a.get(g).to({alpha:1},500).wait(250).call(function(b){c(),d(),e.removeChild(g),e.addChild(g),setTimeout(function(){a.get(g).to({alpha:0},500).call(function(a){e.removeChild(g)})},250)})}},e=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.responseType="text",c.onload=function(){var d=null;if(200===c.status)try{d=JSON.parse(c.responseText)}catch(e){console.warn('Error parsing "'+a+'": '+e.message)}else console.warn('Error opening "'+a+'": '+c.description);b(d)},c.send()},f=function(a,b){var c=0,d="",g=0,h=function(c){g-=1,g||b(a)},i=function(a,b,c){f(a[b],function(d){a[b]=d,c(d)})};if(a){if(Array.isArray(a)){if(g=a.length)for(c=0;c5&&".json"===a.src.substring(a.src.length-5).toLowerCase())f(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(d in a)a.hasOwnProperty(d)&&(g+=1);if(g)for(d in a)a.hasOwnProperty(d)&&i(a,d,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void e(a,function(a){"object"==typeof a?f(a,b):b(a)})}b(a)},g=function(c,d,e){var g=this,h=function(f){var h=null;if(c=f,console.log("Game config loaded.",c),platypus.game=g,g.currentScene=null,g.loaded=null,g.settings=c,d)g.stage=d;else if(b){try{h=document.getElementById(c.global.canvas)}catch(i){console.warn('Stage not provided and canvas ID "'+c.global.canvas+'" not found in HTML wrapper.')}g.stage=new b(h)}else console.warn("Platypus requires a CreateJS Stage for rendering.");g.loadScene(c.global.initialScene),e&&e(g),a&&c.global.tickerOn!==!1&&(g.tickHandler=function(a){g.tick(a)},a.timingMode="raf",a.setFPS(c.global.fps||60),a.addEventListener("tick",g.tickHandler)),window&&(window.getEntityById=function(a){return g.getEntityById(a)},window.getEntitiesByType=function(a){return g.getEntitiesByType(a)},window.getVisibleSprites=function(a,b){if(b=b||[],a=a||d,!a.texture&&a.visible){for(var c=0;c1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b),d=0;d5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}d=0}if(this.loopCheck.push(a),this.messages[a]&&this.messages[a].length)for(g=this.messages[a].slice(),h=g.length,d=0;h>d;d++)g[d].callback.call(g[d].scope||this,b,c);if(this.loopCheck.length=this.loopCheck.length-1,!this.loopCheck.length&&this.unbindLater.length){for(e=0;ef;f++)this.matrix[f]=d[f];return this},b.copyValues=function(a){return this.set(a)},b.magnitude=function(a){var b=0,c=0;for(a=a||this.matrix.length,c=0;a>c;c++)b+=Math.pow(this.matrix[c],2);return Math.sqrt(b)},b.getAngle=function(){var a=this.magnitude(2),b=0;return 0!==a&&(b=Math.acos(this.x/a),this.y<0&&(b=2*Math.PI-b)),b},b.getUnit=function(){return new platypus.Vector(this).normalize()},b.getInverse=function(){return new platypus.Vector(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this.multiply(0):this.multiply(1/a)},b.cross=function(){var a=function(a,b,c,d){return a*d-b*c};return function(b){var c=a(this.y,this.z,b.y,b.z),d=-a(this.x,this.z,b.x,b.z),e=a(this.x,this.y,b.x,b.y);return this.x=c,this.y=d,this.z=e,this}}(),b.getCrossProduct=function(a){return new platypus.Vector(this).cross(a)},b.rotate=function(b,c){var d=c,e=Math.cos(b),f=Math.sin(b),g=1-e,h=0,i=0,j=0;return d?"x"===d?d=new a(1,0,0):"y"===d?d=new a(0,1,0):"z"===d&&(d=new a(0,0,1)):d=new a(0,0,1),h=d.x,i=d.y,j=d.z,this.multiply([[e+h*h*g,h*i*g-j*f,h*j*g+i*f],[i*h*g+j*f,e+i*i*g,i*j*g-h*f],[j*h*g-i*f,j*i*g+h*f,e+j*j*g]])},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a))for(e=this.matrix.slice(),f=b||a.length,c=0;f>c;c++)for(this.matrix[c]=0,d=0;f>d;d++)this.matrix[c]+=e[d]*a[c][d];else for(f=b||this.matrix.length,c=0;f>c;c++)this.matrix[c]*=a;return this},b.add=function(b,c,d){var e=b,f=0,g=0;for(Array.isArray(e)?f=c||this.matrix.length:e instanceof a?(e=e.matrix,f=c||this.matrix.length):(e=[b||0,c||0,d||0],f=this.matrix.length),g=0;f>g;g++)this.matrix[g]+=e[g];return this},b.addVector=function(a,b){return this.add(a,b)},b.subtractVector=function(a,b){return this.add(a.getInverse(),b)},b.scale=function(a,b){return this.multiply(a,b)},b.dot=function(a,b){var c=0,d=0;for(b=b||this.matrix.length,d=0;b>d;d++)c+=this.matrix[d]*(a.matrix[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit();return Math.acos(b.dot(c))},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit();return c.getCrossProduct(d).dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d))},b.scalarProjection=function(a){var b=0;return b="number"==typeof a?a:this.angleTo(a),this.magnitude(2)*Math.cos(b)},b.copy=function(){return new platypus.Vector(this)},a.assign=function(){var a=function(a,b,c,d){var e=null,f=!1;"string"==typeof a&&"undefined"!=typeof b[a]&&(e=b[a],delete b[a],f=!0),Object.defineProperty(b,a,{get:function(){return c.matrix[d]},set:function(a){c.matrix[d]=a},enumerable:!0}),f&&(b[a]=e)};return function(b,c){var d=0;if(b&&c){if(!b[c]){for(b[c]=new platypus.Vector,d=2;da.left&&(this.left=a.left),this.righta.top&&(this.top=a.top),this.bottomthis.bottom||a.leftthis.right)},b.containsVector=function(a){return!(a.ythis.bottom||a.xthis.right)},b.intersects=function(a){return!(a.bottomthis.bottom||a.rightthis.right)},a}(),function(){"use strict";var a=navigator.userAgent.toLowerCase(),b={touch:"undefined"!==window.ontouchstart,iPod:a.search("ipod")>-1,iPhone:a.search("iphone")>-1,iPad:a.search("ipad")>-1,safari:a.search("safari")>-1,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:a.search("android")>-1,chrome:a.search("chrome")>-1,silk:a.search("silk")>-1,iPhone4:!1,iPad2:!1,iOS:!1,mobile:!1,desktop:!1};b.iPhone4=b.iPhone&&480===window.screen.height,b.iPad2=b.iPad&&(!window.devicePixelRatio||1===window.devicePixelRatio),b.iOS=b.iPod||b.iPhone||b.iPad,b.mobile=b.iOS||b.android||b.silk,b.desktop=!b.mobile,platypus.supports=b}(),platypus.CollisionData=function(){"use strict";var a=function(a,b,c,d,e,f,g,h,i){this.occurred=a||!1,this.direction=b||null,this.position=c||null,this.deltaMovement=d||null,this.aABB=e||null,this.thisShape=f||null,this.thatShape=g||null,this.vector=h||null,this.stuck=i||0},b=a.prototype;return b.copy=function(a){this.occurred=a.occurred,this.direction=a.direction,this.position=a.position,this.deltaMovement=a.deltaMovement,this.aABB=a.aABB,this.thisShape=a.thisShape,this.thatShape=a.thatShape,this.vector=a.vector,this.stuck=a.stuck},b.clear=function(){this.occurred=!1,this.direction=null,this.position=null,this.deltaMovement=null,this.aABB=null,this.thisShape=null,this.thatShape=null,this.vector=null,this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=[new platypus.CollisionData,new platypus.CollisionData],this.yData=[new platypus.CollisionData,new platypus.CollisionData],this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},b=a.prototype;return b.getXEntry=function(a){return this.xData[a]},b.getYEntry=function(a){return this.yData[a]},b.tryToAddX=function(a){return a.deltaMovementa;a++)this.xData[a]=new platypus.CollisionData},b.ensureRoomY=function(){var a=0,b=2*this.yData.length;if(this.yData.length<=this.yCount)for(a=this.yData.length;b>a;a++)this.yData[a]=new platypus.CollisionData},b.reset=function(){this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},a}(),platypus.CollisionShape=function(){"use strict";var a=function(a,b,c){var d=b.regX,e=b.regY,f=0,g=0;switch(this.owner=a,this.collisionType=c,this.width=b.width||2*b.radius||0,this.height=b.height||2*b.radius||0,this.radius=b.radius||0,"number"!=typeof d&&(d=this.width/2),"number"!=typeof e&&(e=this.height/2),platypus.Vector.assign(this,"offset","offsetX","offsetY"),this.offsetX=b.offsetX||this.width/2-d,this.offsetY=b.offsetY||this.height/2-e,platypus.Vector.assign(this,"position","x","y"),a?(this.x=a.x+this.offsetX,this.y=a.y+this.offsetY):(this.x=b.x+this.offsetX,this.y=b.y+this.offsetY),this.type=b.type||"rectangle",this.subType="",this.aABB=void 0,this.type){case"circle":f=g=2*this.radius;break;case"rectangle":f=this.width,g=this.height}platypus.Vector.assign(this,"size","width","height"),this.width=f,this.height=g,this.aABB=new platypus.AABB(this.x,this.y,f,g)},b=a.prototype;return b.update=function(a,b){this.x=a+this.offsetX,this.y=b+this.offsetY,this.aABB.move(this.x,this.y)},b.moveX=function(a){this.x=a,this.aABB.moveX(this.x)},b.moveY=function(a){this.y=a,this.aABB.moveY(this.y)},b.getAABB=function(){return this.aABB},b.setXWithEntityX=function(a){this.x=a+this.offsetX,this.aABB.moveX(this.x)},b.setYWithEntityY=function(a){this.y=a+this.offsetY,this.aABB.moveY(this.y)},b.destroy=function(){this.aABB=void 0},b.multiply=function(a){this.position.subtractVector(this.owner.position),this.position.multiply(a),this.offset.multiply(a),this.size.multiply(a),this.position.addVector(this.owner.position),this.width=Math.abs(this.width),this.height=Math.abs(this.height),this.aABB.setAll(this.x,this.y,this.width,this.height)},a}(),platypus.Entity=function(){"use strict";var a={},b=function(b,c){var d=this,e=0,f=null,g=b||{},h=g.components||[],i=g.properties||{},j=c||{},k=j.properties||{};for(platypus.Messenger.call(d),d.components=[],d.type=g.id||"none",d.id=j.id||k.id,d.id||(a[d.type]||(a[d.type]=0),d.id=d.type+"-"+a[d.type],a[d.type]+=1),this.setProperty(i),this.setProperty(k),this.bind("set-property",function(a){d.setProperty(a)}),d.state||(d.state={}),d.lastState={},this.destroyed=!1,e=0;e=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},d=function(b){var c=0,d=[],e=null,f=a.instance.assetManager.cache;for(c=0;cd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},i.destroy=function(){this.stop(),PIXI.Sprite.prototype.destroy.call(this)}}(),function(){"use strict";var a=function(a){return function(){return platypus.game.settings.debug&&console.log('"'+a+'" is not an available PIXI.Graphics method.'),this}},b=PIXI.Graphics.prototype;b.a=b.arc,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.c=b.clear,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dr=b.drawRect,b.ef=b.endFill,b.f=b.beginFill,b.lt=b.lineTo,b.mt=b.moveTo,b.qt=b.quadraticCurveTo,b.r=b.drawRect,b.rr=b.drawRoundedRect,b.cp=a("cp"),b.lf=a("lf"),b.rf=a("rf"),b.bf=a("bf"),b.ss=a("ss"),b.sd=a("sd"),b.s=a("s"),b.ls=a("ls"),b.rs=a("rs"),b.bs=a("bs"),b.es=a("es"),b.rc=a("rc"),b.dp=a("dp"),b.p=a("p")}(),function(){"use strict";var a=PIXI.Container.prototype;a.updateTransform=function(){var a=0,b=0;if(this.visible)for(this.transformMatrix?(this.transformMatrix.copy(this.worldTransform).prepend(this.parent.worldTransform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null):this.displayObjectUpdateTransform(),a=0,b=this.children.length;b>a;++a)this.children[a].updateTransform()},a.containerUpdateTransform=a.updateTransform}(),function(){"use strict";var a=include("springroll.ApplicationPlugin"),b=null,c=new a,d=null;c.preload=function(a){var c=this.config.platypus,e=null,f={delta:0};c?(this.options.debug&&(c.debug=!0),e=this.platypus=new platypus.Game(c,this.display.stage),b=function(a){f.delta=a,e.tick(f)},this.on("update",b,320),d=function(a){e.currentScene.trigger("resize",a)},this.on("resize",d)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},c.teardown=function(){this.platypus&&(this.off("update",b),this.off("resize",d),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(a){this.target=this.owner.target||null,this.offset=new platypus.Vector(0,0)},events:{load:function(){return this.owner.addMover?void(this.direction=this.owner.addMover({vector:[this.speed,0,0],event:"chase",accelerator:this.accelerate}).vector):void console.warn('The "AIChaser" component requires a "Mover" component to function correctly.')},"handle-ai":function(){var b=a,c=0,d=!1;this.target&&this.chasing&&(b.set(this.offset).add(this.target.position).subtractVector(this.owner.position),c=b.magnitude(2),c&&(d=!0,this.direction.set(b).normalize().multiply(this.speed))),d!==this.owner.state.chasing&&(this.owner.state.chasing=d,this.owner.triggerEvent("chase",d))},"set-target":function(a){this.target=a,this.offset.x=0,this.offset.y=0},"set-target-offset":function(a){this.offset.x=a.x,this.offset.y=a.y},"start-chasing":function(a){a&&(this.target=a),this.chasing=!0},"stop-chasing":function(){this.chasing=!1}},methods:{destroy:function(){this.target=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"AIPacer",properties:{movement:"both",direction:null},constructor:function(a){this.lastDirection="",this.currentDirection=this.direction||("horizontal"===this.movement?"left":"up")},events:{"handle-ai":function(){this.currentDirection!==this.lastDirection&&(this.lastDirection=this.currentDirection,this.owner.triggerEvent("stop"),this.owner.triggerEvent("go-"+this.currentDirection))},"turn-around":function(a){("both"===this.movement||"horizontal"===this.movement)&&(a.x>0?this.currentDirection="left":a.x<0&&(this.currentDirection="right")),("both"===this.movement||"vertical"===this.movement)&&(a.y>0?this.currentDirection="up":a.y<0&&(this.currentDirection="down"))}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a){var b=a.split("/");return b=b[b.length-1].split("."),b[0]},c=function(a,c){var d=0,e=!1;for(a.id||(a.id=b(a.src)),d=0;d=0;b--)e.exists(d[b].id)&&(e.preload(d[b].id,a),d.splice(b,1));d.length&&this.app.load(d,{taskDone:a})}}})}(),function(){"use strict";var a=include("springroll.Application"),b={interrupt:createjs.Sound.INTERRUPT_ANY,delay:0,offset:0,loop:0,volume:1,pan:0,mute:!1,paused:!1,next:!1,events:!1},c=function(a,b){return a.time-b.time},d=function(){var b=a.instance.voPlayer;this.play=function(a,c){var d=c.complete;return b.play(a,function(){d(!1)},function(){d(!0)}),this},this.stop=this.pause=function(){b.stop()},this.unpause=function(){},Object.defineProperty(this,"position",{get:function(){return b.playing?b.getElapsed():0}})},e=function(){var b=a.instance.sound;this.play=function(a,c){return b.play(a,c)}},f=function(a){var d=0,e="",f="",g=null;if("string"==typeof a)e=a,g={};else if(Array.isArray(a)){if("string"==typeof a[0])e=a[0],g={next:[]};else{e=a[0].sound,g={};for(f in a[0])a[0].hasOwnProperty(f)&&(g[f]=a[0][f]);g.next?g.next=g.next.slice():g.next=[]}for(d=1;d=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},checkTimeEvents:function(a,b){var c=a.sequenceEvents,d=0;if(c&&c.length)for(d=a.position;c.length&&(b||c[0].time<=d);)this.owner.trigger(c[0].event,c[0].message),c.splice(0,1)},onComplete:function(a,b){if(this.removeClip(a),this.checkTimeEvents(a,!0),this.owner.triggerEvent("clip-complete"),b&&b.length)if("string"==typeof b)f(b).call(this);else{var c=b.slice();c.splice(0,1),c.length>0?f(b[0]).call(this,{next:c}):f(b[0]).call(this)}else this.owner.triggerEvent("sequence-complete")},removeClip:function(a){var b=0;for(b=0;b=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},onComplete:function(a){this.removeClip(a),this.owner.triggerEvent("clip-complete")},removeClip:function(a){var b=0;for(b=0;bthis.threshold?(this.worldWidth&&0!==this.worldWidth&&this.worldWidththis.worldWidth?b.moveX(this.worldWidth-b.halfWidth):this.worldWidth&&0!==this.worldWidth&&athis.threshold?(this.worldHeight&&0!==this.worldHeight&&this.worldHeightthis.worldHeight?b.moveY(this.worldHeight-b.halfHeight):this.worldHeight&&0!==this.worldHeight&&a1e-4?(this.worldCamera.orientation=a,!0):!1},lockedFollow:function(){var a=Math.min,b=function(a,b,c){return c*b+(1-c)*a},c=function(b,c){return b?a(c/b,1):1};return function(a,d,e){var f=b(this.worldCamera.viewport.x,a.x,c(this.transitionX,d)),g=b(this.worldCamera.viewport.y,a.y,c(this.transitionY,d));return this.rotate?this.move(f,g,b(this.worldCamera.orientation,-(a.orientation||0),c(this.transitionAngle,d))):this.move(f,g,0)}}(),forwardFollow:function(a,b){var c=this.forwardFollower,d=15/b,e=!1,f=a.x+this.offsetX,g=a.y+this.offsetY,h=(a.orientation||0)+this.offsetAngle;return this.followFocused&&this.lastX===f&&this.lastY===g?this.lockedFollow(c,b):(this.averageOffsetX*=.9,this.averageOffsetY*=.9,this.averageOffsetX+=.1*(f-this.lastX)*d,this.averageOffsetY+=.1*(g-this.lastY)*d,Math.abs(this.averageOffsetX)>this.worldCamera.viewport.width/(2*this.forwardX)&&(this.averageOffsetX=0),Math.abs(this.averageOffsetY)>this.worldCamera.viewport.height/(2*this.forwardY)&&(this.averageOffsetY=0),this.rotate&&(this.averageOffsetAngle*=.9,this.averageOffsetAngle+=.1*(h-this.lastOrientation)*d,Math.abs(this.averageOffsetAngle)>this.worldCamera.orientation/(2*this.forwardAngle)&&(this.averageOffsetAngle=0)),c.x=this.averageOffsetX*this.forwardX+f,c.y=this.averageOffsetY*this.forwardY+g,c.orientation=this.averageOffsetAngle*this.forwardAngle+h,this.lastX=f,this.lastY=g,this.lastOrientation=h,e=this.lockedFollow(c,b),this.followFocused||e||(this.followFocused=!0),e)},boundingFollow:function(a,b){var c=0,d=0,e=this.transitionX?Math.min(b/this.transitionX,1):1,f=1-e,g=this.transitionY?Math.min(b/this.transitionY,1):1,h=1-g;return this.boundingBox.move(this.worldCamera.viewport.x,this.worldCamera.viewport.y),a.x>this.boundingBox.right?c=a.x-this.boundingBox.halfWidth:a.xthis.boundingBox.bottom?d=a.y-this.boundingBox.halfHeight:a.ya?this.overflow?this.worldCamera.viewport.resize(this.height*b,this.height):this.viewport.resize(this.viewport.height*a,this.viewport.height):this.overflow?this.worldCamera.viewport.resize(this.width,this.width/b):this.viewport.resize(this.viewport.width,this.viewport.width/a)),this.worldPerWindowUnitWidth=this.worldCamera.viewport.width/this.viewport.width,this.worldPerWindowUnitHeight=this.worldCamera.viewport.height/this.viewport.height,this.windowPerWorldUnitWidth=this.viewport.width/this.worldCamera.viewport.width,this.windowPerWorldUnitHeight=this.viewport.height/this.worldCamera.viewport.height,this.matrix.tx=this.viewport.x-this.viewport.halfWidth,this.matrix.ty=this.viewport.y-this.viewport.halfHeight,this.viewportUpdate=!0},windowToWorld:function(a){var b=[];return b[0]=Math.round((a[0]-this.viewport.x)*this.worldPerWindowUnitWidth),b[1]=Math.round((a[1]-this.viewport.y)*this.worldPerWindowUnitHeight),b},worldToWindow:function(a){var b=[];return b[0]=Math.round(a[0]*this.windowPerWorldUnitWidth+this.viewport.x),b[1]=Math.round(a[1]*this.windowPerWorldUnitHeight+this.viewport.y),b},destroy:function(){this.parentContainer.removeChild(this.container),this.parentContainer=null,this.container=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"CameraFollowMe",properties:{camera:{},mode:"forward",pause:!1},constructor:function(a){this.pauseGame=a.pause?{time:a.time}:null,this.camera={entity:this.owner,mode:this.camera.mode||this.mode,top:this.camera.top,left:this.camera.left,offsetX:this.camera.offsetX,offsetY:this.camera.offsetY,width:this.camera.width,height:this.camera.height,time:this.camera.time}},events:{"follow-me":function(a){var b=this.camera;a&&(b={entity:this.owner,mode:a.mode||this.camera.mode,top:a.top||this.camera.top,left:a.left||this.camera.left,offsetX:a.offsetX||this.camera.offsetX,offsetY:a.offsetY||this.camera.offsetY,width:a.width||this.camera.width,height:a.height||this.camera.height,time:a.time||this.camera.time}),this.pauseGame&&(this.owner.parent.trigger("pause-logic",this.pauseGame),this.owner.parent.trigger("pause-render",this.pauseGame)),this.owner.parent.trigger("follow",b)}}})}(),function(){"use strict";var a=function(a,b,c){var d=0,e=b.stuck;e&&(d=a.magnitude(),b.thatShape.owner&&Math.abs(e)>1&&(e*=.05),(!d||d>Math.abs(e))&&(b.vector.x&&(a.x=e,a.y=0),b.vector.y&&(a.x=0,a.y=e),c.stuckWith=new platypus.Vector(b.thatShape.x,b.thatShape.y)))},b=function(a,b,c){return"string"==typeof a?function(d){d.myType===c&&d.hitType===b&&this.owner.triggerEvent(a,d)}:Array.isArray(a)?function(d){var e=0;if(d.myType===c&&d.hitType===b)for(e=0;e0&&a.bottom&&this.owner.trigger(a.bottom,d),0>f&&a.top&&this.owner.trigger(a.top,d),e>0&&a.right&&this.owner.trigger(a.right,d),0>e&&a.left&&this.owner.trigger(a.left,d),a.all&&this.owner.trigger(a.all,d))}},c=function(b,c){c.collisionFunctions||(c.collisionFunctions={},c.getAABB=function(a){var b=null,d="";if(a)return c.collisionFunctions[a]?c.collisionFunctions[a].getAABB():null;b=c.aabb=c.aabb||new platypus.AABB,b.reset();for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&b.include(c.collisionFunctions[d].getAABB());return b},c.getPreviousAABB=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPreviousAABB():null},c.getShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getShapes():null},c.getPrevShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPrevShapes():null},c.prepareCollision=function(a,b){var d="";for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&c.collisionFunctions[d].prepareCollision(a,b)},c.relocateEntity=function(b,d){var e=null;d.xCount&&(e=new platypus.Vector(0,0,0),a(e,d.getXEntry(0),c)),d.yCount&&(e=e||new platypus.Vector(0,0,0),a(e,d.getYEntry(0),c)),c.triggerEvent("relocate-entity",{position:b,unstick:e})},c.movePreviousX=function(a){var b="";for(b in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(b)&&c.collisionFunctions[b].movePreviousX(a)},c.getCollisionTypes=function(){return c.collisionTypes},c.getSolidCollisions=function(){return c.solidCollisions}),c.collisionFunctions[b.collisionType]={getAABB:function(){return b.getAABB()},getPreviousAABB:function(){return b.getPreviousAABB()},getShapes:function(){return b.getShapes()},getPrevShapes:function(){return b.getPrevShapes()},prepareCollision:function(a,c){b.prepareCollision(a,c)},movePreviousX:function(a){b.movePreviousX(a)}}};return platypus.createComponentClass({id:"CollisionBasic",properties:{collisionType:"none",shapeType:"rectangle",ignoreOrientation:!1,regX:null,regY:null,width:0,height:0,radius:0,margin:0,shapes:null},publicProperties:{immobile:!1,bullet:!1,jumpThrough:!1},constructor:function(a){var d=0,e="",f=null,g=this.regX,h=this.regY,i=this.width,j=this.height,k=this.radius,l=this.margin.left||this.margin,m=this.margin.right||this.margin,n=this.margin.top||this.margin,o=this.margin.bottom||this.margin;for(null===g&&(g=this.regX=i/2),null===h&&(h=this.regY=j/2),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.aabb=new platypus.AABB,this.prevAABB=new platypus.AABB,this.shapes?f=this.shapes:"circle"===this.shapeType?(k=k||((i||0)+(j||0))/4,f=[{regX:(isNaN(g)?k:g)-(m-l)/2,regY:(isNaN(h)?k:h)-(o-n)/2,radius:k,type:this.shapeType}]):f=[{regX:(isNaN(g)?(i||0)/2:g)-(m-l)/2,regY:(isNaN(h)?(j||0)/2:h)-(o-n)/2,points:a.points,width:(i||0)+l+m,height:(j||0)+n+o,type:this.shapeType}],this.owner.collisionTypes=this.owner.collisionTypes||[],this.owner.collisionTypes.push(this.collisionType),this.shapes=[],this.prevShapes=[],this.entities=void 0,d=0;d0?this.owner.position.add(b):this.stuck=!1),this.aabb.reset(),d=0;d0&&(this.stuck||(this.stuck=!0),this.move=this.owner.stuckWith.copy().add(-this.owner.x,-this.owner.y).normalize())},"handle-logic":function(){this.move&&this.owner.position.add(this.move),this.owner.checkCollision=!0},"orientation-updated":function(a){var b=0;if(!this.ignoreOrientation)for(b=0;b0&&(this.owner.collides=!0),this.owner.softCollisions[this.collisionType]&&(this.owner.softCollisions[this.collisionType].length=0,delete this.owner.softCollisions[this.collisionType]),delete this.owner.collisionFunctions[this.collisionType],this.shapes.length=0,this.prevShapes.length=0,delete this.entities,this.owner.collisionTypes.length&&this.owner.parent.trigger("add-collision-entity",this.owner)}}})}(),function(){"use strict";var a=function(a,b,c){return function(d){a.state[b]&&a.trigger(c,d)}},b=function(a,b,c){return function(d){a.state[b]||a.trigger(c,d)}};return platypus.createComponentClass({id:"CollisionFilter",properties:{collisions:{},state:""},constructor:function(c){var d="",e=this.collisions,f=this.state;if(e)if("!"===f[0]){f=f.substring(1);for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,b(this.owner,f,e[d]))}else for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,a(this.owner,f,e[d]))}})}(),function(){"use strict";var a=function(a,b){var c=0,d=0,e=a.length,f=!1;for(c=0;cd;d++)if(b[c]===a[d]){f=!0;break}f||a.push(b[c])}return a};return platypus.createComponentClass({id:"CollisionGroup",constructor:function(a){var b=this;this.solidEntities=[],this.terrain=void 0,this.aabb=new platypus.AABB(this.owner.x,this.owner.y),this.prevAABB=new platypus.AABB(this.owner.x,this.owner.y),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.collisionGroup=this.owner.collisionGroup={getAllEntities:function(){var a=0,c=0,d=null;for(a=0;aa?(a=Math.abs(a)-2,b[a]):a},e=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g];return h},f=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g],a[b+f][c+g]=-1;return h},g=function(a,b,c,d,e,f){var g=0,h=0;for(h=0;f>h;h++)for(g=0;e>g;g++)a[c+g][d+h]=b[h][g];return a},h={diagonal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-4,-3,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+j]=d(h[i][j],k);return a},"diagonal-inverse":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-2,-5,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[i][j],k);return a},horizontal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-2,-5,-4,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+j]=d(h[j][i],k);return a},vertical:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-3,-2,-5];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+g-j-1]=d(h[j][i],k);return a},"rotate-90":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-4,-5,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+g-j-1][c+i]=d(h[j][i],k);return a},"rotate-180":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-5,-2,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[j][i],k);return a},"rotate-270":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-2,-3,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+j][c+f-i-1]=d(h[j][i],k);return a},translate:function(a,b,c,d,e,g,h){var i=f(a,b,c,d,e),j=0,k=0;for(k=0;e>k;k++)for(j=0;d>j;j++)a[b+j+g][c+k+h]=i[k][j];return a}};return platypus.createComponentClass({id:"CollisionTiles",publicProperties:{collisionMap:[],tileWidth:10,tileHeight:10},constructor:function(a){this.tileHalfWidth=this.tileWidth/2,this.tileHalfHeight=this.tileHeight/2},events:{transform:function(a){this.transform(a)},translate:function(a){this.translate(a)}},methods:{getShape:function(c,d,e){var f=null;return b-1)a.push(this.getShape(b,c,d));else if(this.collisionMap[c][d]<-1)switch(this.collisionMap[c][d]){case-2:b.bottom<=d*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-3:b.left>=(c+1)*this.tileWidth&&a.push(this.getShape(b,c,d));break;case-4:b.top>=(d+1)*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-5:b.right<=c*this.tileWidth&&a.push(this.getShape(b,c,d))}return a}},publicMethods:{getAABB:function(){return{left:0,top:0,right:this.tileWidth*this.collisionMap.length,bottom:this.tileHeight*this.collisionMap.length[0]}},isTile:function(a,b){return!(0>a||0>b||a>=this.collisionMap.length||b>=this.collisionMap[0].length||-1===this.collisionMap[a][b])},getTileShapes:function(a,d){var e=Math.max(Math.floor(a.left/this.tileWidth),0),f=Math.max(Math.floor(a.top/this.tileHeight),0),g=Math.min(Math.ceil(a.right/this.tileWidth),this.collisionMap.length),h=Math.min(Math.ceil(a.bottom/this.tileHeight),this.collisionMap[0].length),i=0,j=0,k=c;for(c.length=0,b=0,i=e;g>i;i++)for(j=f;h>j;j++)this.addShape(k,d,i,j);return k},transform:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.type||"horizontal";return h[g]?h[g](this.collisionMap,c,d,e,f):null},translate:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.dx||0,i=b.dy||0;return h.translate(this.collisionMap,c,d,e,f,g,i)},getCollisionMatrix:function(a,b,c,d){return e(this.collisionMap,a,b,c,d)},setCollisionMatrix:function(a,b,c,d,e){return g(this.collisionMap,a,b,c,d,e)}}})}(),function(){"use strict";var a=function(a,b){return function(){setTimeout(function(){var c=0,d=0;if(a.remove)if("string"==typeof a.remove)for(c=b.components.length-1;c>-1;c--)b.components[c].type===a.remove&&b.removeComponent(b.components[c]);else for(c=0;c-1;d--)b.components[d].type===a.remove[c]&&b.removeComponent(b.components[d]);if(a.add)if(Array.isArray(a.add))for(c=0;ce&&(f=g-f),f):f},c=[null,null,null,null,["east","south","west","north"],null,null,null,["east","southeast","south","southwest","west","northwest","north","northeast"],null,null,null,null,null,null,null,["east","east-southeast","southeast","south-southeast","south","south-southwest","southwest","west-southwest","west","west-northwest","northwest","north-northwest","north","north-northeast","northeast","east-northeast"]],d=["left-button","middle-button","right-button"],e=function(a,b){this.event=a,this.trigger=b,this.filters=!1,this.current=!1,this.last=!1,this.state=!1,this.stateSummary={pressed:!1,released:!1,triggered:!1,over:!1}},f=function(a){var b=0;return Array.isArray(a)?function(c){for(b=0;bthis.joystick.outerRadius||f=b.right||a.right<=b.left||a.top>=b.bottom||a.bottom<=b.top?!1:!0},d=function(a,b){var c=0,d=0,e=null,f=null,g=0,h=0,i=null,j=0;if("rectangle"===a.type&&"rectangle"===b.type)return!0;if("circle"===a.type&&"circle"===b.type){if(c=Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2),d=Math.pow(a.radius+b.radius,2),d>=c)return!0}else if("circle"===a.type&&"rectangle"===b.type||"rectangle"===a.type&&"circle"===b.type){if("circle"===a.type?(e=a,f=b):(e=b,f=a),i=f.getAABB(),g=Math.abs(e.x-f.x),h=Math.abs(e.y-f.y),g>=i.halfWidth+e.radius)return!1;if(h>=i.halfHeight+e.radius)return!1;if(ge;e++)if(s=this.allEntities[e],s.alwaysOn||s.checkCollision||t(s.getAABB(),u)){if(s.checkCollision=!1,i[i.length]=s,w=s.collisionTypes,s!==this.owner)for(f=0;ff;f++)s=r[f],(s.alwaysOn||t(s.getAABB(),v))&&(h[h.length]=s)}}}(),prepareCollisions:function(a){var b=0,c=null;for(this.nonColliders.length=0,b=this.allEntitiesLive.length-1;b>-1;b--)c=this.allEntitiesLive[b],c.triggerEvent("prepare-for-collision",a),c.collides||this.nonColliders.push(c)},resolveNonCollisions:function(){var a=0,b=null,c={position:new platypus.Vector,relative:!1};for(a=this.nonColliders.length-1;a>-1;a--)b=this.nonColliders[a],c.position.set(b.position),b.trigger("relocate-entity",c)},checkGroupCollisions:function(){var c=function(b,c,d,e,f,g,h,i){a.entity=c,a.myType=d,a.type=e,a.x=f,a.y=g,a.direction=i,a.hitType=h,b.triggerEvent("hit-by-"+e,a),c&&(a.entity=b,a.type=d,a.myType=e,a.x=-f,a.y=-g,a.direction=i.getInverse(),a.hitType=h,c.triggerEvent("hit-by-"+d,a))};return function(){var a=0,d=0,e=this.groupsLive,f=new platypus.Vector,g=null;for(a=e.length-1;a>-1;a--)if(e[a].collisionGroup.getSize()>1){for(b.reset(),f.set(0,0,0),f=this.checkSolidEntityCollision(e[a],e[a].collisionGroup,b,f),d=0;d-1;a--){for(b.reset(),g.set(0,0,0),g=this.checkSolidEntityCollision(f[a],f[a],b,g),d=0;df;f++){if(b.prepareCollision(a.previousX+l,a.previousY+m),h.set(a.position),h=this.processCollisionStep(a,b,q,c,h,l,m,p),h.x===a.previousX&&h.y===a.previousY){b.relocateEntity(h,c);break}b.relocateEntity(h,c)}}return h},processCollisionStep:function(){var a=new platypus.AABB,b=function(a,b,c,d,e){var f=0,g=c.getAABB(d);if(c===a)return!1;if(c.jumpThrough&&b.bottom>g.top)return!1;if(a.jumpThrough&&g.bottom>b.top)return!1;if(e)for(f=0;f0?(a.copy(f.getXEntry(0)),d.x=b.previousX+a.deltaMovement*a.direction):d.x=b.x,c.movePreviousX(d.x),0!==i)for(j=0;j0?(a.copy(f.getYEntry(0)),d.y=b.previousY+a.deltaMovement*a.direction):d.y=b.y,d}}(),findMinAxisMovement:function(){var a=new platypus.CollisionData;return function(b,c,d,e,f,g){var h=0,i=c.getShapes(d),j=c.getPrevShapes(d);for(h=0;h=f.aABB.top&&e.y<=f.aABB.bottom?f.aABB.halfWidth+e.radius:(a.y=d(e.y,f.y,f.aABB.halfHeight),i=f.aABB.halfWidth+c(a.y,e.radius),g===e?(a.x=-d(e.x-h*i,f.x,f.aABB.halfWidth)/2,a.y=-a.y):a.x=d(e.x,f.x-h*i,f.aABB.halfWidth)/2,a.normalize(),i):"y"===b?e.x>=f.aABB.left&&e.x<=f.aABB.right?f.aABB.halfHeight+e.radius:(a.x=d(e.x,f.x,f.aABB.halfWidth),i=f.aABB.halfHeight+c(a.x,e.radius),g===e?(a.x=-a.x,a.y=-d(e.y-h*i,f.y,f.aABB.halfWidth)/2):a.y=d(e.y,f.y-h*i,f.aABB.halfWidth)/2,a.normalize(),i):void 0},g=function(a,b,d){return"x"===a?c(b.y-d.y,b.radius+d.radius):"y"===a?c(b.x-d.x,b.radius+d.radius):void 0};return function(c,d,h,i){if("rectangle"===h.type){if("rectangle"===i.type)return b.position=i[c]-d*e(c,h.getAABB(),i.getAABB()),a.x=0,a.y=0,a[c]=d,b;if("circle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,i,h,h,d),b}else if("circle"===h.type){if("rectangle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,h,i,h,d),b;if("circle"===i.type)return b.position=i[c]-d*g(c,h,i),a.x=i.x-h.x,a.y=i.y-h.y,a[c]=i[c]-b.position,a.normalize(),b}}}();return function(e,f,g,h,i){var j=0,k=e[g],l=f[g],m=e,n=l>k?1:-1,o=l,p=null,q=l;if(k!==l)for("x"===g?m.moveX(l):"y"===g&&m.moveY(l),j=0;j0?q>o&&(k>o&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)):o>q&&(o>k&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)));return i}}(),checkSoftCollisions:function(a){var b=0,c=function(a){return function(b){a.trigger("hit-by-"+b.type,b)}};for(b=0;b-1;b--)if(this.entities[b]===a){this.entities.splice(b,1);break}},"pause-logic":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-logic":function(){this.paused=0},"camera-update":function(a){this.camera.left=a.viewport.left,this.camera.top=a.viewport.top,this.camera.width=a.viewport.width,this.camera.height=a.viewport.height,-1===this.camera.buffer&&(this.camera.buffer=this.camera.width/10),this.camera.active=!0,this.updateNeeded=!0},tick:function(b){var c=0,d=0,e=0,f=null;if(this.leftoverTime+=b.delta,e=Math.floor(this.leftoverTime/this.stepLength)||1,this.message.delta=this.stepLength,this.leftoverTime=Math.max(this.leftoverTime-e*this.stepLength,0),this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),!this.paused){for(this.message.tick=b,this.activeEntities===this.entities&&(this.message.movers=this.activeEntities=[]),this.activeEntities.length=0,d=this.entities.length-1;d>-1;d--)f=this.entities[d],(f.alwaysOn||"undefined"==typeof f.x||f.x>=this.camera.left-this.camera.buffer&&f.x<=this.camera.left+this.camera.width+this.camera.buffer&&f.y>=this.camera.top-this.camera.buffer&&f.y<=this.camera.top+this.camera.height+this.camera.buffer)&&this.activeEntities.push(f);for(e=Math.min(e,this.maxStepsPerTick),c=0;e>c;c++){for(this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-ai",this.message),d=this.activeEntities.length-1;d>-1;d--)this.activeEntities[d].triggerEvent("handle-logic",this.message);if(this.owner.triggerEvent("check-collision-group",this.message))for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],f.triggerEvent("handle-post-collision-logic",this.message),a(f)&&f.triggerEvent("state-changed",f.state);else for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],a(f)&&f.triggerEvent("state-changed",f.state)}}}}})}(),function(){"use strict";return platypus.createComponentClass({id:"HandlerRender",properties:{acceptInput:null},publicProperties:{},constructor:function(a){this.container=new PIXI.Container,this.camera={x:0,y:0},this.acceptInput&&(this.click=this.acceptInput.click,this.cameraMovementMovesMouse=this.acceptInput.camera,this.hover=this.acceptInput.hover,(this.click||this.hover)&&(this.addInputs(),this.addEventListener())),this.renderMessage={delta:0,container:this.container}},events:{load:function(){this.owner.triggerEvent("render-world",{world:this.container})},"child-entity-added":function(a){a.triggerEvent("handle-render-load",this.renderMessage)},"pause-render":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-render":function(){this.paused=0},tick:function(){var a=function(a,b){return a.z-b.z};return function(b){var c=0,d=null,e=this.renderMessage;if(e.delta=b.delta,this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-render",e),this.container){for(c=this.container.children.length-1;c>-1;c--)d=this.container.children[c],d.visible&&(d.paused&&!this.paused?d.paused=!1:this.paused&&(d.paused=!0));this.container.reorder&&(this.container.reorder=!1,this.container.children.sort(a))}}}(),"camera-update":function(a){this.camera.x=a.viewport.left,this.camera.y=a.viewport.top,this.moveMouse&&this.moveMouse()}},methods:{addInputs:function(){var a=function(a,b){return function(c){var d=c.data.global.x,e=c.data.global.y,f=c.data.originalEvent,g=0,h=0;a.container&&(g=d/a.container.transformMatrix.a+a.camera.x,h=e/a.container.transformMatrix.d+a.camera.y,c.target.mouseTarget=!0,a.owner.trigger(b,{event:f,cjsEvent:c,x:g,y:h,entity:a.owner}),a.cameraMovementMovesMouse&&("pressup"===b?(c.target.mouseTarget=!1,a.moveMouse=null,c.target.removeDisplayObject&&c.target.removeDisplayObject()):a.moveMouse=function(){a.owner.trigger("pressmove",{event:f,x:d/a.container.transformMatrix.a+a.camera.x,y:e/a.container.transformMatrix.d+a.camera.y,entity:a.owner})}))}};return function(){var b=this.container,c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=!1;this.click&&(b.interactive=!0,k=a(this,"mousedown"),c=function(a){k(a),l=!0}.bind(this),i=a(this,"pressmove"),f=function(a){l&&i(a)}.bind(this),j=a(this,"pressup"),g=function(a){j(a),l=!1}.bind(this),h=a(this,"click"),b.addListener("mousedown",c),b.addListener("touchstart",c),b.addListener("mouseup",g),b.addListener("touchend",g),b.addListener("mouseupoutside",g),b.addListener("touchendoutside",g),b.addListener("mousemove",f),b.addListener("touchmove",f),b.addListener("click",h),b.addListener("tap",h)),this.hover&&(b.interactive=!0,d=a(this,"mouseover"),e=a(this,"mouseout"),b.addListener("mouseover",d),b.addListener("mouseout",e)),this.removeInputListeners=function(){this.click&&(b.removeListener("mousedown",c),b.removeListener("touchstart",c),b.removeListener("mouseup",g),b.removeListener("touchend",g),b.removeListener("mouseupoutside",g),b.removeListener("touchendoutside",g),b.removeListener("mousemove",f),b.removeListener("touchmove",f),b.removeListener("click",h),b.removeListener("tap",h)),this.hover&&(b.removeListener("mouseover",d),b.removeListener("mouseout",e)),this.removeInputListeners=null}}}(),destroy:function(){var a=this;this.container.mouseTarget?(this.container.visible=!1,this.container.removeDisplayObject=function(){a.container=null}):this.container=null}},publicMethods:{}})}(),function(){"use strict";var a=function(a,b,c,d,e,f){var g=0,h=0,i=0,j=a.slice();if("horizontal"===f){for(h=e-1;h>=0;h--)for(g=h*d,i=0;(h+1)*d>g;g++,i++)j.splice((h+1)*b+i,0,c[g]);return j}return"vertical"===f?a.concat(c):void 0},b=function(a,b,c,d){var e=0,f=0,g=a.slice(),h=null;for(e=0;e0?this.piOverTwo:this.v[1]<0?-this.piOverTwo:this.angle:(c=Math.atan(this.v[1]/this.v[0]),this.v[0]<0&&(c=Math.PI+c)),this.v[0]>=0?this.v[0]=Math.min(this.v[0],this.maxVelocity*Math.cos(c)):this.v[0]=Math.max(this.v[0],this.maxVelocity*Math.cos(c)),this.v[1]>=0?this.v[1]=Math.min(this.v[1],this.maxVelocity*Math.sin(c)):this.v[1]=Math.max(this.v[1],this.maxVelocity*Math.sin(c)),this.owner.x+=this.v[0],this.owner.y+=this.v[1],this.owner.rotation=c*(180/Math.PI)+this.visualOffset)},"set-angle":function(a){this.angle=a},move:function(){this.moving=!0},stop:function(){this.moving=!1,this.v[0]=0,this.v[1]=0},"set-max-velocity":function(a){this.maxVelocity=a}}})}(),function(){"use strict";var a=0;return platypus.createComponentClass({id:"LogicAttachment",properties:{attachState:"attached",attachment:"",offsetX:0,offsetY:0,offsetZ:.01},publicProperties:{},constructor:function(b){this.state=this.owner.state,this.owner.linkId||(this.owner.linkId="attachment-link-"+a,a+=1),this.state[this.attachState]=!1,this.attachmentPosition={x:0,y:0,z:0,dx:0,dy:0,linkId:this.owner.linkId},this.attachmentProperties={type:this.attachment,properties:this.attachmentPosition},this.attachment=null,this.isAttached=!1},events:{"handle-logic":function(a){var b=0,c=this.state;this.isAttached?(this.attachment||(this.attachmentPosition.x=this.owner.x,this.attachmentPosition.y=this.owner.y,this.attachmentPosition.z=this.owner.z,this.attachment=this.owner.parent.addEntity(this.attachmentProperties)),this.attachment.destroyed?(this.owner.parent.removeEntity(this.attachment),this.attachment=null,this.isAttached=!1):(this.attachment.x=this.owner.x,b=this.offsetX,c.left?(b*=-1,this.attachment.rotation=180):c.right&&(this.attachment.rotation=0),this.attachment.x+=b,this.attachment.y=this.owner.y,b=this.offsetY,c.top?(b*=-1,this.attachment.rotation=90):c.bottom&&(this.attachment.rotation=-90),this.attachment.y+=b,this.attachment.z=this.owner.z,this.attachment.z+=this.offsetZ)):this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),c[this.attachState]!==this.isAttached&&(c[this.attachState]=this.isAttached)},attach:function(a){this.isAttached=!a||a.pressed!==!1},detach:function(){this.isAttached=!1}},methods:{destroy:function(){this.state[this.attachState]=!1,this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),this.isAttached=!1}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicButton",constructor:function(a){this.state=this.owner.state,this.state.released=!0,this.state.pressed=!1,this.toggle=!!a.toggle,"pressed"===a.state&&(this.state.released=!1,this.state.pressed=!0)},events:{mousedown:function(){this.toggle||this.updateState("pressed")},pressup:function(){this.toggle?this.state.pressed?this.updateState("released"):this.updateState("pressed"):this.updateState("released")},"handle-logic":function(){}},methods:{updateState:function(a){this.state.released&&"pressed"===a?(this.state.pressed=!0,this.state.released=!1,this.owner.triggerEvent(a,this.state)):this.state.pressed&&"released"===a&&(this.state.pressed=!1,this.state.released=!0,this.owner.triggerEvent(a,this.state))}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCanvasButton",properties:{onPress:"",onRelease:"",onCancel:"",useOnce:!1,disabled:!1},publicProperties:{},constructor:function(a){this.owner.state.disabled=this.disabled,this.owner.state.down=!1,this.owner.buttonMode=!this.disabled,this.cancelled=!1,this.used=!1,this.last=null},events:{"handle-logic":function(a){this.last!==(this.disabled===this.owner.state.disabled)&&(this.last=this.disabled===this.owner.state.disabled)},mousedown:function(a){this.owner.state.down=!0,this.owner.state.disabled||this.useOnce&&this.used||this.onPress&&(this.owner.trigger(this.onPress),this.used=!0)},pressup:function(a){this.owner.state.disabled||this.useOnce&&this.used||(this.cancelled?this.onCancel&&(this.owner.trigger(this.onCancel),this.used=!0):this.onRelease&&(this.owner.trigger(this.onRelease),this.used=!0)),this.owner.state.down=!1,this.cancelled=!1},mouseover:function(){this.owner.state.down&&(this.cancelled=!1)},mouseout:function(){this.owner.state.down&&(this.cancelled=!0)},disable:function(){this.owner.state.disabled=!0,this.owner.buttonMode=!1},enable:function(){this.owner.state.disabled=!1,this.owner.buttonMode=!0},"toggle-disabled":function(){this.owner.buttonMode=this.owner.state.disabled,this.owner.state.disabled=!this.owner.state.disabled}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCarrier",constructor:function(a){},events:{load:function(a){this.owner.trigger("add-collision-entity",this.owner)||(this.owner.addComponent(new platypus.components.CollisionGroup(this.owner,{})),this.owner.trigger("add-collision-entity",this.owner))},"carry-me":function(a){this.owner.trigger("add-collision-entity",a.entity)},"release-me":function(a){this.owner.trigger("remove-collision-entity",a.entity)}}})}(),function(){"use strict";var a=function(a){var b=function(a,b){return b&&!a.message?{event:a.event,message:b,delay:a.delay,repeat:a.repeat}:a};return a.singleInstance?function(c){var d=0,e=!0;for(d=0;d-1;b--)this.queue[b]===a&&(this.queueTimes.splice(b,1),this.queue.splice(b,1))}};return platypus.createComponentClass({id:"LogicDelayMessage",constructor:function(c){var d="";if(this.queueTimes=[],this.queue=[],c.events)for(d in c.events)c.events.hasOwnProperty(d)&&(this.addEventListener(d,a(c.events[d])),c.events[d].cancelEvent&&this.addEventListener(c.events[d].cancelEvent,b(c.events[d])))},events:{"handle-logic":function(a){var b=0;for(b=this.queue.length-1;b>-1;b--)this.queueTimes[b]-=a.delta,this.queueTimes[b]<=0&&(this.owner.trigger(this.queue[b].event,this.queue[b].message),this.queue[b]&&(this.queue[b].repeat?this.queueTimes[b]+=this.queue[b].delay:(this.queueTimes.splice(b,1),this.queue.splice(b,1))))}},methods:{destroy:function(){this.queueTimes.length=0,this.queue.length=0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDestroyMe",properties:{delay:0},publicProperties:{destroyed:!1},events:{"handle-logic":function(a){var b=a.delta;this.destroyed&&!this.owner.state.paused&&(this.delay-=b,this.delay<=0&&this.owner.parent.removeEntity(this.owner))},"destroy-me":function(){this.destroyed=!0}}})}(),function(){"use strict";var a=function(a){return function(b){this[a]="undefined"==typeof b||b&&b.pressed!==!1}},b=function(){},c={x:function(a,b){a!==b&&(a>180&&180>=b||180>=a&&b>180)&&this.owner.triggerEvent("transform","vertical")},y:function(a,b){a!==b&&(a>90&&270>=a&&(90>=b||b>270)||(90>=a||a>270)&&b>90&&270>=b)&&this.owner.triggerEvent("transform","horizontal")},z:function(a,b){a!==b&&this.owner.triggerEvent("replace-transform","rotate-"+a)}};return platypus.createComponentClass({id:"LogicDirectionalMovement",properties:{axis:"y",heading:0,speed:.3},constructor:function(a){var d=this;isNaN(this.speed)||(this.speed=[this.speed,0,0]),this.initialVector=new platypus.Vector(this.speed),this.reorient=c[this.axis],this.reorient||(this.reorient=b),this.owner.state.paused=!1,a.pause&&("string"==typeof a.pause?this.pausers=[a.pause]:this.pausers=a.pause,this.addEventListener("state-changed",function(b){var c=0,e=!1;if(a.pause){for(c=0;c0?this.mX=1:0>b&&(this.mX=this.flipX),this.owner.dy=0,c>0?this.mY=1:0>c&&(this.mY=this.flipY)),!0},"hit-solid":function(a){return this.stunned&&a.y>0&&(this.stunned=!1,this.owner.dx=0,this.owner.dy=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPacingPlatform",constructor:function(a){this.ang=this.owner.angle||a.angle||0,this.dist=this.owner.distance||a.distance||128,this.period=this.owner.period||a.period||4e3,this.time=0,this.startPos=this.owner.startPos||a.startPos||0,this.offset=0,this.originX=this.owner.x,this.originY=this.owner.y},events:{"handle-logic":function(a){var b=a.delta;this.time+=b,this.time>this.period&&(this.time=this.time%this.period),this.offset=this.time/this.period*2*Math.PI,this.owner.x=this.originX+Math.sin(this.offset+this.startPos)*this.dist*Math.cos(this.ang),this.owner.y=this.originY+Math.sin(this.offset+this.startPos)*this.dist*Math.sin(this.ang)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortable",constructor:function(a){this.portableDirections=a.portableDirections||{down:!0},this.carrier=this.lastCarrier=void 0,this.message={entity:this.owner}},events:{"handle-logic":function(a){this.carrierConnected?(this.carrier!==this.lastCarrier&&(this.lastCarrier&&this.lastCarrier.trigger("release-me",this.message),this.carrier.trigger("carry-me",this.message)),this.carrierConnected=!1):this.carrier&&(this.carrier.trigger("release-me",this.message),this.carrier=void 0),this.lastCarrier=this.carrier},"hit-solid":function(a){a.y>0?this.updateCarrier(a.entity,"down"):a.y<0?this.updateCarrier(a.entity,"up"):a.x<0?this.updateCarrier(a.entity,"left"):a.x>0&&this.updateCarrier(a.entity,"right")}},methods:{updateCarrier:function(a,b){this.portableDirections[b]&&a&&(a!==this.carrier&&(this.carrier=a),this.carrierConnected=!0)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortal",constructor:function(a){var b=0,c=a.entrants||a.entrant;if(this.destination=this.owner.destination||a.destination,this.used=!1,this.ready=!1,this.wasReady=!1,c)if(this.entrants={},Array.isArray(c))for(b=0;b0&&this.vY>0||a.y<0&&this.vY<0?this.vY=0:(a.x<0&&this.vX<0||a.x>0&&this.vX>0)&&(this.vX=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicRebounder",constructor:function(a){platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.owner.mass=this.owner.mass||a.mass||1,this.elasticity=a.elasticity||.8,this.v=new platypus.Vector(0,0,0),this.incidentVector=new platypus.Vector(0,0,0),this.staticCollisionOccurred=!1,this.nonStaticCollisionOccurred=!1,this.hitThisTick=[],this.otherV=new platypus.Vector(0,0,0),this.otherVelocityData=[]},events:{"handle-logic":function(a){this.hitThisTick=[],this.otherVelocityData.length=0},"hit-static":function(a){var b=0,c=a.entity,d=0;for(d=0;db;b++)for(c=0;e>c;c++)h=Math.min(f,this.owner.width-b*f),i=Math.min(g,this.owner.height-c*g),this.regions.push({x:b*f,y:c*g,width:h,height:i});this.entityClass=platypus.game.settings.entities[a.spawn],this.interval=this.owner.interval||a.interval||1e3,this.time=0},events:{"handle-logic":function(a){var b=this.regions,c=null;this.time+=a.delta,this.time>this.interval&&(this.time-=this.interval, -b?(b.length||(this.regions=this.usedRegions,this.usedRegions=b,b=this.regions),c=b[Math.floor(b.length*Math.random())],this.spawnPosition.x=this.owner.x-(this.owner.regX||0)+(c.x+Math.random()*c.width),this.spawnPosition.y=this.owner.y-(this.owner.regY||0)+(c.y+Math.random()*c.height)):(this.spawnPosition.x=this.owner.x-(this.owner.regX||0)+Math.random()*this.owner.width,this.spawnPosition.y=this.owner.y-(this.owner.regY||0)+Math.random()*this.owner.height),this.owner.triggerEvent("entity-created",this.owner.parent.addEntity(new platypus.Entity(this.entityClass,this.spawnProperties))))}}})}(),function(){"use strict";var a=Math.PI,b=Math.cos,c=Math.sin,d=function(a,c){return a*b(c)},e=function(a,b){return a*c(b)};return platypus.createComponentClass({id:"LogicRotationalMovement",constructor:function(b){this.speed=b.speed||.3,this.magnitude=0,this.degree=(b.degree||1)*a/180,this.angle=b.angle||0,this.state=this.owner.state,this.state.moving=!1,this.state.turningRight=!1,this.state.turningLeft=!1,this.owner.orientation=0,this.moving=!1,this.turningRight=!1,this.turningLeft=!1},events:{"handle-logic":function(a){var b=0,c=0;this.turningRight&&(this.angle+=this.degree*a.delta/15),this.turningLeft&&(this.angle-=this.degree*a.delta/15),this.moving&&(b=d(this.magnitude,this.angle),c=e(this.magnitude,this.angle)),this.owner.x+=b*a.delta,this.owner.y+=c*a.delta,this.state.moving!==this.moving&&(this.state.moving=this.moving),this.state.turningLeft!==this.turningLeft&&(this.state.turningLeft=this.turningLeft),this.state.turningRight!==this.turningRight&&(this.state.turningRight=this.turningRight),this.owner.orientation!==this.angle&&(this.owner.orientation=this.angle)},"turn-right":function(a){a?this.turningRight=a.pressed:this.turningRight=!0},"turn-left":function(a){a?this.turningLeft=a.pressed:this.turningLeft=!0},"go-forward":function(a){!a||a.pressed?(this.moving=!0,this.magnitude=this.speed):this.moving=!1},"go-backward":function(a){!a||a.pressed?(this.moving=!0,this.magnitude=-this.speed):this.moving=!1},stop:function(a){(!a||a.pressed)&&(this.moving=!1,this.turningLeft=!1,this.turningRight=!1)},"stop-moving":function(a){(!a||a.pressed)&&(this.moving=!1)},"stop-turning":function(a){(!a||a.pressed)&&(this.turningLeft=!1,this.turningRight=!1)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicSpawner",constructor:function(a){var b=this.owner.spawneeClass||a.spawneeClass,c="",d=0;if(this.state=this.owner.state,this.stateName=a.state||"spawning",this.entityClass=platypus.game.settings.entities[b],this.speed=a.speed||this.owner.speed||0,this.state[this.stateName]=!1,this.spawneeProperties={x:0,y:0,z:0,dx:0,dy:0,spawner:this.owner},a.passOnProperties)for(d=0;d-1;b--)this.queueTimes[b]-=a.delta,this.queueTimes[b]<=0&&(this.owner.trigger(this.queue[b].event,this.queue[b].message),this.queueTimes.splice(b,1),this.queue.splice(b,1))},"update-state":function(a){var b="";for(b in a)a.hasOwnProperty(b)&&(this.state[b]=a[b])},"state-changed":function(a){var b=null;if(this.outputs){for(b in a)a[b]!==this.snapshot[b]&&(this.snapshot[b]=a[b]);for(this.tempQueue.length=0,d("outputs",this.snapshot,this.last,this.outputs,!1,this.owner,this.tempQueue),b=0;b0&&a.entity.trigger("teleport",this.destination);break;case"down":a.y>0&&a.entity.trigger("teleport",this.destination);break;case"left":a.x<0&&a.entity.trigger("teleport",this.destination);break;default:a.entity.trigger("teleport",this.destination)}}},methods:{destroy:function(){this.destination=void 0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicTimer",constructor:function(a){this.time=this.owner.time||a.time||0,this.prevTime=this.time,this.alarmTime=this.owner.alarmTime||a.alarmTime||void 0,this.isInterval=this.owner.isInterval||a.isInterval||!1,this.alarmMessage=this.owner.alarmMessage||a.alarmMessage||"",this.updateMessage=this.owner.updateMessage||a.updateMessage||"",this.isOn=this.owner.on||a.on||!0,this.isIncrementing=this.owner.isIncrementing||a.isIncrementing||!0,this.maxTime=this.owner.maxTime||a.maxTime||36e5},events:{"handle-logic":function(a){this.isOn&&(this.prevTime=this.time,this.isIncrementing?this.time+=a.delta:this.time-=a.delta,Math.abs(this.time)>this.maxTime&&(this.time>0?this.time=this.maxTime:this.time<0&&(this.time=-this.maxTime),this["stop-timer"]()),"undefined"!=typeof this.alarmTime&&(this.isInterval?this.isIncrementing?Math.floor(this.time/this.alarmTime)>Math.floor(this.prevTime/this.alarmTime)&&this.owner.trigger(this.alarmMessage):Math.floor(this.time/this.alarmTime)this.alarmTime&&this.prevTimethis.alarmTime&&this.owner.trigger(this.alarmMessage))),this.owner.trigger(this.updateMessage,{time:this.time})},"set-timer":function(a){this.time=a.time},"start-timer":function(){this.isOn=!0},"stop-timer":function(){this.isOn=!1}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicWindUpRacer",constructor:function(a){this.windTime=a.windTime||500,this.raceTime=a.raceTime||5e3,this.speed=a.speed||this.owner.speed||.3,this.windProgress=0,this.winding=!1,this.racing=!1,this.blocked=!1,this.right=!1,this.left=!1,this.state=this.owner.state,this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1},events:{"handle-logic":function(a){this.racing?!this.blocked&&this.right&&this.state.right?(this.owner.x+=this.speed,this.owner.trigger("racing")):!this.blocked&&this.left&&this.state.left?(this.owner.x-=this.speed,this.owner.trigger("racing")):(this.racing=!1,this.owner.trigger("stopped-racing")):this.winding?((this.right&&this.state.right||this.left&&this.state.left)&&(this.windProgress+=a.delta),this.owner.trigger("winding")):this.windProgress&&(this.windProgress>this.windTime&&(this.racing=!0),this.windProgress=0,this.owner.trigger("stopped-winding")),this.state.windingUp!==this.winding&&(this.state.windingUp=this.winding),this.state.racing!==this.racing&&(this.state.racing=this.racing),this.state.blocked!==this.blocked&&(this.state.blocked=this.blocked),this.blocked=!1},"stop-racing":function(a){this.racing=!1,this.owner.trigger("stopped-racing")},"wind-up":function(a){this.winding=!a||a.pressed!==!1,this.right=this.state.right,this.left=this.state.left},"hit-solid":function(a){a.x&&this.racing&&(this.right&&a.x>0||this.left&&a.x<0)&&(this.blocked=!0,this.owner.trigger("blocked",a))}},methods:{destroy:function(){this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1}}})}(),function(){"use strict";var a=new platypus.Vector,b=function(a){return function(b,c,d,e){this.accelerator?this.resultant=b:this.resultant=c,this.update=a,this.update(b,c,d,e)}},c=function(){return!0},d=function(a,d){var e=a.active,f=!0,g=!0,h=c,i=c,j=a.owner.state,k=d.controlState,l=d.instantState,m=d.instantSuccess;k&&(h=function(){return j[k]}),d.event&&a.addEventListener(d.event,function(a){e=a&&a.pressed!==!1}),d.instantEvent||l||d.instantBegin||d.instantEnd?(l&&(i=function(){return j[l]}),(d.instantEvent||d.instantBegin||d.instantEnd)&&(f=!1,d.instantEvent&&a.addEventListener(d.instantEvent,function(a){f=a&&a.pressed!==!1}),d.instantBegin&&a.addEventListener(d.instantBegin,function(){f=!0}),d.instantEnd&&a.addEventListener(d.instantEnd,function(){f=!1})),a.update=b(function(a,b,c,d){var j=i();this.active=e&&h(),g&&f&&this.active&&j?(g=!1,this.move(1),m&&this.owner.triggerEvent(m)):g||f&&j||(g=!0,this.decay())})):a.update=b(function(a,b,c,d){this.active=e&&h(),this.active&&this.move(c)})};return platypus.createComponentClass({id:"Motion",properties:{orient:!0,accelerator:!1,active:!0,maxMagnitude:1/0,event:"",controlState:"",instantEvent:"",instantBegin:"",instantEnd:"",instantState:"",instantSuccess:"",instantDecay:null,vector:0},constructor:function(a){this.vector=new platypus.Vector(this.vector),this.triggered=!1,isNaN(this.instantDecay)?this.capMagnitude=-1:this.capMagnitude=this.vector.magnitude()*this.instantDecay,d(this,a),this.orient&&this.owner.triggerEvent("orient-vector",this.vector)},events:{"set-vector":function(a){this.vector.set(a),isNaN(this.instantDecay)?this.capMagnitude=-1:this.capMagnitude=this.vector.magnitude()*this.instantDecay}},methods:{move:function(b){this.vector.magnitude()>this.maxMagnitude&&this.vector.normalize().multiply(this.maxMagnitude),this.resultant.add(a.set(this.vector).multiply(b))},decay:function(){var b=null;this.capMagnitude>=0&&(b=a.set(this.resultant).scalarProjection(this.vector),b>this.capMagnitude&&this.resultant.subtractVector(a.set(this.vector).normalize().scale(b-this.capMagnitude)))},destroy:function(){this.orient&&this.owner.triggerEvent("remove-vector",this.vector)}},publicMethods:{}})}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"Mover",properties:{ground:[0,1]},publicProperties:{movers:[],gravity:0,jump:0,speed:0,drag:.99,friction:.94,maxMagnitude:1/0},constructor:function(a){platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.position=this.owner.position,this.velocity=this.owner.velocity,this.moversCopy=this.movers,this.movers=[],this.ground=new platypus.Vector(this.ground)},events:{"component-added":function(a){"Motion"===a.type&&this.movers.push(a)},"component-removed":function(a){var b=0;if("Motion"===a.type)for(b=0;bthis.maxMagnitude&&f.normalize().multiply(this.maxMagnitude),e.set(f).multiply(d),g.add(e),this.grounded!==this.owner.state.grounded&&(this.owner.state.grounded=this.grounded),this.grounded=!1}},"hit-solid":function(b){var c=this.velocity.scalarProjection(b.direction),d=a;b.direction.dot(this.ground)>0&&(this.grounded=!0),d.set(b.direction).normalize().multiply(c).dot(this.velocity)>0&&this.velocity.subtractVector(d)}},methods:{destroy:function(){var a=0;for(a=this.movers.length-1;a>=0;a--)this.removeMover(this.movers[a])}},publicMethods:{addMover:function(a){var b=this.owner.addComponent(new platypus.components.Motion(this.owner,a));return b},removeMover:function(a){this.owner.removeComponent(a)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"Node",publicProperties:{x:0,y:0,z:0},constructor:function(a){this.nodeId=a.nodeId||this.owner.nodeId||this.owner.id||String(Math.random()),"string"!=typeof this.nodeId&&this.nodeId.length&&(this.nodeId=a.nodeId.join("|")),this.owner.nodeId=this.nodeId,this.owner.isNode=!0,this.map=this.owner.map=this.owner.map||null,this.contains=this.owner.contains=[],this.edgesContain=this.owner.edgesContain=[],platypus.Vector.assign(this.owner,"position","x","y","z"),this.neighbors=this.owner.neighbors=a.neighbors||this.owner.neighbors||{}},events:{"add-neighbors":function(a){var b=0,c=null;for(c in a)a.hasOwnProperty(c)&&(this.neighbors[c]=a[c]);for(b=0;b=0;c--)d=this.residentsAwaitingNode[c],e.id===d.nodeId&&(this.residentsAwaitingNode.splice(c,1),d.node=this.getNode(d.nodeId),d.triggerEvent("on-node",d.node))},"child-entity-added":function(a){a.isNode?this.owner.triggerEvent("add-node",a):a.nodeId&&(a.node=this.getNode(a.nodeId),a.node?a.triggerEvent("on-node",a.node):this.residentsAwaitingNode.push(a))}},publicMethods:{getNode:function(){var a=0,b="",c="",d=arguments;if(1===d.length){if(d[0].isNode)return d[0];Array.isArray(d[0])&&(d=d[0])}for(a=0;aj){if(e){for(m=!1,g=0;gf&&(g=2*Math.PI-g),180*g/Math.PI):g},d=function(a,b,c,d){return b*(1-a)+c*a+d},e=function(a,b){var c=0,d=0,e=!1;if(null===b)return!0;for(;c=this.distance?(g=this.destinationNodes[0],f-=this.distance-this.progress,this.progress=0,this.destinationNodes.splice(0,1),this.owner.triggerEvent("on-node",g),this.destinationNodes.length&&f&&this.onEdge(this.destinationNodes[0])):(this.progress+=f,e=this.progress/this.distance,this.owner.x=d(e,this.lastNode.x,this.destinationNodes[0].x,this.offset.x),this.owner.y=d(e,this.lastNode.y,this.destinationNodes[0].y,this.offset.y),this.owner.z=d(e,this.lastNode.z,this.destinationNodes[0].z,this.offset.z),this.updateOrientation&&(this.owner.rotation=c(this.lastNode,this.destinationNodes[0],this.distanc,e)),f=0)}else this.state.moving=!1},"on-node":function(a){var b=0,c=null;for(this.owner.node=this.node=a,this.node.removeFromEdge(this.owner),this.lastNode&&this.lastNode.removeFromEdge(this.owner),this.node.addToNode(this.owner),this.setState("on-node"),this.owner.x=this.node.x+this.offset.x,this.owner.y=this.node.y+this.offset.y,this.owner.z=this.node.z+this.offset.z,this.updateOrientation&&this.node.rotation&&(this.owner.rotation=this.node.rotation),this.owner.triggerEvent("set-directions"),this.friendlyNodes&&this.friendlyNodes[a.type]&&this.owner.trigger(this.friendlyNodes[a.type],a),c=a.contains,b=0;bthis.followDistance)return this.lag=e.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(e,i);this.lag=0}else if(e.blocked)return this.blocked=!0,!1;return!1}}(),"set-directions":function(){var b="",c=0,d=null,e=this.node,f=null;this.owner.triggerEvent("remove-directions");for(b in e.neighbors)if(this.neighbors[b]=a(e.neighbors[b],e.map,b),this.addEventListener(b,this.neighbors[b]),f=e.map.getNode(e.neighbors[b]))for(d=f.contains,c=0;cthis.followDistance)return this.lag=c.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(c);this.lag=0}else if(c.blocked)return this.blocked=!0,!1;return!1}}(),isPassable:function(a){return!(!a||this.node===a||this.friendlyNodes&&"undefined"==typeof this.friendlyNodes[a.type]||a.contains.length&&!e(a.contains,this.friendlyEntities))},traverseNode:function(a){var c=1,d="",e=a.position.map,f=null,g=null,h=null,i=null,j=a.algorithm||b,k={shortestPath:1/0,found:!1,blocked:!1},l=!0,m=!1;if(0===a.depth||a.distance>a.shortestPath)return a;if(a.test(a.position,a.destination))return a.found=!0,a.shortestPath=a.distance,a;for(h=a.nodes;ci.shortestPath&&(k=i),l=!1);return k.blocked=m&&l,k},setPath:function(a,b){a.nodes[0]===this.node&&a.nodes.splice(0,1),this.destinationNodes=a.nodes,b&&(this.destinationNodes.length=Math.min(b,this.destinationNodes.length))},setState:function(a){"on-node"===a?this.state["on-node"]=!0:(this.state["on-node"]=!1,this.currentState&&(this.state[this.currentState]=!1),this.currentState=a,this.state[a]=!0)},onEdge:function(a){this.distance=b(this.node,a),this.updateOrientation&&(this.owner.rotation=c(this.node,a,this.distance,this.progress/this.distance)),this.node.addToEdge(this.owner),a.addToEdge(this.owner),this.owner.triggerEvent("leave-node")}}})}(),function(){"use strict";var a={horizontal:[[-1,0,0],[0,1,0],[0,0,-1]],vertical:[[1,0,0],[0,-1,0],[0,0,-1]],diagonal:[[0,1,0],[1,0,0],[0,0,-1]],"diagonal-inverse":[[0,-1,0],[-1,0,0],[0,0,-1]],"rotate-90":[[0,-1,0],[1,0,0],[0,0,1]],"rotate-180":[[-1,0,0],[0,-1,0],[0,0,1]],"rotate-270":[[0,1,0],[-1,0,0],[0,0,1]]},b=function(){var a=function(a,b,c){var d=0,e=0;for(d=0;db;b++)for(c=0;3>c;c++)b===c?a[b][c]=1:a[b][c]=0;return a};return platypus.createComponentClass({id:"Orientation",publicProperties:{scaleX:1,scaleY:1,rotation:0,orientation:0,orientationMatrix:null},constructor:function(){var a=function(a,d){var e=new platypus.Vector([0,0,1]),f=new platypus.Vector([1,0,0]),g=new platypus.Vector([1,0,0]),h=a.owner,i=[[1,0,0],[0,1,0],[0,0,1]];return Object.defineProperty(h,"orientationMatrix",{get:function(){return b(a.matrixTween,a.matrix,c(i)),i},enumerable:!0}),delete h.orientation,Object.defineProperty(h,"orientation",{get:function(){return g.signedAngleTo(f,e)},set:function(a){g.set(f).rotate(a)},enumerable:!0}),d&&(isNaN(d)?g.set(d):g.rotate(d)),g};return function(b){this.loadedOrientationMatrix=this.orientationMatrix,this.matrix=[[1,0,0],[0,1,0],[0,0,1]],this.matrixTween=[[1,0,0],[0,1,0],[0,0,1]],this.vectors=[],this.inverses=[],this.tweens=[],this.owner.triggerEvent("orient-vector",a(this,this.orientation))}}(),events:{load:function(){this.loadedOrientationMatrix?this.transform(this.loadedOrientationMatrix):(this.scaleX&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.transform("horizontal")),this.scaleY&&this.scaleY<0&&(this.scaleY=-this.scaleY,this.transform("vertical")),this.rotation&&((this.rotation+270)%360===0?(this.rotation=0,this.transform("rotate-90")):(this.rotation+180)%360===0?(this.rotation=0,this.transform("rotate-180")):(this.rotation+90)%360===0&&(this.rotation=0,this.transform("rotate-270")))),delete this.loadedOrientationMatrix},"handle-logic":function(a){var b=0,d=a.delta,e=this.owner.state,f=[];if(this.tweens.length){for(e.reorienting=!0,c(this.matrixTween),b=this.tweens.length-1;b>=0;b--)this.updateTween(this.tweens[b],d)&&f.push(this.tweens.splice(b,1)[0]);for(b=0;bb;b++)c+=a[b][0]*a[(b+1)%3][1]*a[(b+2)%3][2],c-=a[b][2]*a[(b+1)%3][1]*a[(b+2)%3][0];return c},c=function(c){var d=[[],[],[]],e=1/b(c);return d[0].push(a(c[1][1],c[1][2],c[2][1],c[2][2])*e),d[0].push(a(c[0][2],c[0][1],c[2][2],c[2][1])*e),d[0].push(a(c[0][1],c[0][2],c[1][1],c[1][2])*e),d[1].push(a(c[1][2],c[1][0],c[2][2],c[2][0])*e),d[1].push(a(c[0][0],c[0][2],c[2][0],c[2][2])*e),d[1].push(a(c[0][2],c[0][0],c[1][2],c[1][0])*e),d[2].push(a(c[1][0],c[1][1],c[2][0],c[2][1])*e),d[2].push(a(c[0][1],c[0][0],c[2][1],c[2][0])*e),d[2].push(a(c[0][0],c[0][1],c[1][0],c[1][1])*e),d};return function(a){this.multiply(c(this.matrix)),this.multiply(a)}}(),updateTween:function(){var a=function(a,b,c){return a*(1-c)+b*c};return function(c,d){var e=0,f=1,g=0,h=0,i=1,j=1,k=0,l=c.endMatrix,m=null;return c.time+=d,c.time>=c.endTime?!0:(e=c.tween(c.time/c.endTime),c.angle?(k=e*c.angle,f=i=Math.cos(k),g=Math.sin(k),h=-g):(f=a(f,l[0][0],e),g=a(g,l[1][0],e),h=a(h,l[0][1],e),i=a(i,l[1][1],e),j=a(j,l[2][2],e)),m=[[f,h,0],[g,i,0],[0,0,j]],b(m,this.matrixTween,this.matrixTween),void c.onTick(e,m))}}(),updateVector:function(a,b){b.set(a.add(b)),a.multiply(this.matrixTween),b.subtractVector(a)},destroy:function(){}},publicMethods:{}})}(),function(){"use strict";var a=function(a){return function(b,c){this.owner.trigger(a[Math.floor(Math.random()*a.length)],b,c)}};return platypus.createComponentClass({id:"RandomEvents",constructor:function(b){var c="";if(b.events)for(c in b.events)b.events.hasOwnProperty(c)&&this.addEventListener(c,a(b.events[c]))}})}(),function(){"use strict";var a=function(a,b,c,d){var e=0;for(e=0;e=-1?(this.currentAnimation=a,this.lastState=-1,this.animationFinished=!1,this.sprite.gotoAndPlay(a)):(this.waitingAnimation=a,this.waitingState=-1)}},d=function(a,b){var c=0,d=a.replace(/ /g,"").split(",");return"default"===a?function(a){return b}:function(a){for(c=0;cthis.camera.right||a.y+a.heightthis.camera.bottom)?this.isOnCamera=!1:this.isOnCamera=!0},addStage:function(a){return a&&!this.pinTo?(this.parentContainer=a,this.parentContainer.addChild(this.container),this.mask&&this.setMask(this.mask),this.addInputs(),a):null},updateSprite:function(){var a=function(a,b){return a.z-b.z};return function(b){var c=0,d=0,e=0,f=null,g=0,h=!1,i=1,j=1,k=null,l=this.affine.copy(this.container.transformMatrix),m=PIXI.Matrix.TEMP_MATRIX;if(this.buttonMode!==this.container.buttonMode&&(this.container.buttonMode=this.buttonMode),this.pinnedTo?this.pinnedTo.frames&&this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame]?(d=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].x,e=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].y,this.container.z!==this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].z&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].z),g=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].angle||0,this.visible=!0):this.pinnedTo.defaultPin?(d=this.pinnedTo.defaultPin.x,e=this.pinnedTo.defaultPin.y,this.container.z!==this.pinnedTo.defaultPin.z&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.pinnedTo.defaultPin.z),g=this.pinnedTo.defaultPin.angle||0,this.visible=!0):this.visible=!1:(d=this.owner.x,e=this.owner.y,this.rotate&&(g=this.rotation),this.container.z!==this.owner.z+this.offsetZ&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.owner.z+this.offsetZ),this.ignoreOpacity||!this.owner.opacity&&0!==this.owner.opacity||(this.container.alpha=this.owner.opacity)),this.container.reorder&&(this.container.reorder=!1,this.container.children.sort(a)),(this.mirror||this.flip)&&(k=this.rotation%360,this.mirror&&k>90&&270>k&&(i=-1),this.flip&&180>k&&(j=-1)),this.stateBased&&this.stateChange){if(void 0!==this.state.visible&&(this.visible=this.state.visible),this.checkStates)for(c=0;c=+c)?(this.currentAnimation=h,this.lastState=+c,this.animationFinished=!1,b?this.sprite.gotoAndPlay(h):this.sprite.gotoAndStop(h)):(this.waitingAnimation=h,this.waitingState=+c):this.waitingAnimation&&!this.followThroughs[this.currentAnimation]&&(this.waitingAnimation=!1);break}this.stateChange=!1}g&&l.rotate(g/180*Math.PI),this.pinnedTo?(m.tx=d,m.ty=e,m.a=i,m.b=0,m.c=0,m.d=j,l.prepend(m)):(this.owner.orientationMatrix&&(f=this.owner.orientationMatrix,m.tx=f[0][2],m.ty=f[1][2],m.a=f[0][0],m.b=f[1][0],m.c=f[0][1],m.d=f[1][1],l.prepend(m)),m.tx=d,m.ty=e,m.a=this.scaleX*i,m.b=this.owner.skewX,m.c=this.owner.skewY,m.d=this.scaleY*j,l.prepend(m)),this.sprite&&(!this.wasVisible&&this.visible||this.lastX!==this.owner.x||this.lastY!==this.owner.y)&&this.checkCameraBounds(),this.lastX=this.owner.x,this.lastY=this.owner.y,this.wasVisible=this.visible,this.container.visible=this.visible&&this.isOnCamera}}(),triggerInput:function(a,b){this.container&&this.owner.trigger(b,{event:a.data.originalEvent,pixiEvent:a,x:a.data.global.x/this.parentContainer.transformMatrix.a+this.camera.left,y:a.data.global.y/this.parentContainer.transformMatrix.d+this.camera.top,entity:this.owner})},addInputs:function(){var a=!1,b=this.container,c=null,d=null,e=null,f=null,g=null,h=null;this.click&&(b.interactive=!0,c=function(b){this.triggerInput(b,"mousedown"),b.target.mouseTarget=!0,a=!0}.bind(this),f=function(b){a?(this.triggerInput(b,"pressmove"),b.target.mouseTarget=!0):this.triggerInput(b,"mousemove")}.bind(this),g=function(b){this.triggerInput(b,"pressup"),b.target.mouseTarget=!1,a=!1,b.target.removeDisplayObject&&b.target.removeDisplayObject()}.bind(this),h=function(a){this.triggerInput(a,"click")}.bind(this),b.addListener("mousedown",c),b.addListener("touchstart",c),b.addListener("mouseup",g),b.addListener("touchend",g),b.addListener("mouseupoutside",g),b.addListener("touchendoutside",g),b.addListener("mousemove",f),b.addListener("touchmove",f),b.addListener("click",h),b.addListener("tap",h)),this.hover&&(b.interactive=!0,d=function(a){this.triggerInput(a,"mouseover")}.bind(this),e=function(a){this.triggerInput(a,"mouseout")}.bind(this),b.addListener("mouseover",d),b.addListener("mouseout",e)),this.removeInputListeners=function(){this.click&&(b.removeListener("mousedown",c),b.removeListener("touchstart",c),b.removeListener("mouseup",g),b.removeListener("touchend",g),b.removeListener("mouseupoutside",g),b.removeListener("touchendoutside",g),b.removeListener("mousemove",f),b.removeListener("touchmove",f),b.removeListener("click",h),b.removeListener("tap",h)),this.hover&&(b.removeListener("mouseover",d),b.removeListener("mouseout",e)),b.interactive=!1,this.removeInputListeners=null}},addPins:function(a,b){var c=0,d=0,e=null,f=b.regX||0,g=b.regY||0,h=Array.isArray(b);for(this.pinsToRemove=this.pinsToRemove||[],this.pins={},c=0;cb;)b*=2;return b},m=function(a,b){var c=+a.substring(4),d=0;return 2147483648&c&&(b.scale.x=-1),1073741824&c&&(b.scale.y=-1),536870912&c&&(d=b.scale.x,b.scale.x=b.scale.y,b.scale.y=-d,b.rotation=Math.PI/2),268435455&c},n=function(a){this.instances=[a],this.index=0,a.template=this},o={getNext:i},p=n.prototype;return p.getNext=function(){var a=this.instances[this.index],b=null;return a||(b=this.instances[0],a=this.instances[this.index]=new h(b.texture),a.scale=b.scale,a.rotation=b.rotation,a.anchor=b.anchor),this.index+=1,a},p.clear=function(){this.index=0},platypus.createComponentClass({id:"RenderTiles",properties:{buffer:0,cacheAll:!1,entityCache:!1,imageMap:[],maximumBuffer:2048,scaleX:1,scaleY:1,spriteSheet:null,tileCache:!0,tileHeight:10,tileWidth:10},constructor:function(b){var e=this.imageMap;this.doMap=null,this.populate=this.populateTiles,this.tiles={},this.renderer=c.instance.display.renderer,this.tilesSprite=null,this.cacheTexture=null,this.mapContainer=null,this.laxCam=new a,this.worldWidth=this.tileWidth,this.worldHeight=this.tileHeight,this.cache=new a,this.cachePixels=new a,this.tileContainer=this.spriteSheet.images.length>1?new d:new f(15e3,{position:!0,rotation:!0,scale:!0}),this.mapContainer=new d,this.mapContainer.addChild(this.tileContainer),this.reorderedStage=!1,this.updateCache=!1,this.imageMap=[],this.addImageMap(e),this.tilesWidth=this.imageMap[0].length,this.tilesHeight=this.imageMap[0][0].length,this.layerWidth=this.tilesWidth*this.tileWidth,this.layerHeight=this.tilesHeight*this.tileHeight,this.cacheWidth=Math.min(l(this.layerWidth),this.maximumBuffer),this.cacheHeight=Math.min(l(this.layerHeight),this.maximumBuffer),this.tileCache||(this.buffer=0,this.cacheAll=!1)},events:{"handle-render-load":function(a){var b=this.owner.z,c=this.renderer,e=null;a&&a.container&&(e=this.parentContainer=a.container,e&&!this.reorderedStage&&(e.reorder=!0,this.reorderedStage=!0),this.updateRegion(),this.tileCache?(this.render=this.renderCache,this.mapContainerWrapper=new d,this.mapContainerWrapper.addChild(this.mapContainer),this.layerWidth<=this.cacheWidth&&this.layerHeight<=this.cacheHeight?(this.cacheAll=!0,this.cacheTexture=new g(c,this.cacheWidth,this.cacheHeight),this.tilesSprite=new h(this.cacheTexture),this.tilesSprite.scaleX=this.scaleX,this.tilesSprite.scaleY=this.scaleY,this.tilesSprite.z=b,this.cache.setBounds(0,0,this.tilesWidth-1,this.tilesHeight-1),this.update(this.cacheTexture,this.cache),e.addChild(this.tilesSprite)):this.cacheAll||this.layerWidth<=2*this.cacheWidth&&this.layerHeight<=this.cacheHeight||this.layerWidth<=this.cacheWidth&&this.layerHeight<=2*this.cacheHeight?(this.cacheAll=!0,this.cacheGrid=[],this.createGrid=function(){var a=0,b=0,d=0,f=0,i=this.owner.z,j=null,k=null;for(d=0;d0&&(n&&this.updateBufferRegion(p),f=this.cacheTilesWidth-1,g=this.cacheTilesHeight-1,h=f/2,i=g/2,o.setAll(Math.round(p.x/this.tileWidth-h)+h,Math.round(p.y/this.tileHeight-i)+i,f,g),o.left<0?o.moveX(o.halfWidth):o.right>this.tilesWidth-1&&o.moveX(this.tilesWidth-1-o.halfWidth),o.top<0?o.moveY(o.halfHeight):o.bottom>this.tilesHeight-1&&o.moveY(this.tilesHeight-1-o.halfHeight),this.tileCache?(k.empty||!o.contains(k))&&(this.tilesSpriteCache.texture=this.cacheTexture,this.cacheTexture=this.cacheTexture.alternate,this.tilesSprite.texture=this.cacheTexture,this.update(this.cacheTexture,o,this.tilesSpriteCache,k)):this.update(null,o),l.set(k).setAll((l.x+.5)*this.tileWidth,(l.y+.5)*this.tileHeight,(l.width+1)*this.tileWidth,(l.height+1)*this.tileHeight)),this.cacheGrid)for(b=0;bb;b++)for(this.doMap[b]||(this.doMap[b]=[]),c=f;g>c;c++)this.doMap[b][c]||(this.doMap[b][c]=[]),this.doMap[b][c].push(d);a.removeComponent("RenderSprite"),this.updateCache=!0}},convertCamera:function(a){var b=this.worldWidth/this.scaleX,c=b-a.width,d=this.worldHeight/this.scaleY,e=d-a.height,f=this.laxCam;return b!==this.layerWidth&&c?f.moveX(a.left*(this.layerWidth-a.width)/c+a.halfWidth):f.moveX(a.x),d!==this.layerHeight&&e?f.moveY(a.top*(this.layerHeight-a.height)/e+a.halfHeight):f.moveY(a.y),(a.width!==f.width||a.height!==f.height)&&f.resize(a.width,a.height), -f},createTile:function(a){var c=null,d="";return"tile-1"===a?o:(c=new b(this.spriteSheet),d="tile"+m(a,c),c.gotoAndStop(d),new n(c))},addImageMap:function(a){var b=0,c=0,d="",e=[],f=this.tiles,g=null;for(b=0;bb.bottom||db.right||cb.bottom||db.right||cb;b++)e.data.push(1);return platypus.assets&&platypus.assets[a.name]&&platypus.assets[a.name].asset?(e.image=a.name,e.tileheight=platypus.assets[a.name].asset.height,e.tilewidth=platypus.assets[a.name].asset.width):g.assetCache.read(a.name)?(e.image=a.name,e.tileheight=g.assetCache.read(a.name).height,e.tilewidth=g.assetCache.read(a.name).width):(console.warn('Component TiledLoader: Cannot find the "'+a.name+'" sprite sheet. Add it to the list of assets in config.json and give it the id "'+a.name+'".'),e.image=a.image),e},O=function(a,c){var d=c.width,l=c.height,m=c.tileheight||k,n=c.tilewidth||j,o=0,p=0,q=0,r=null,s=null,t=null,u=null,v=!1,w=null,x=null,y=0,z=0,A=0,B="",C=c.data;if(c.properties&&(c.properties.width&&(o=parseInt(c.properties.width,10)),c.properties.height&&(p=parseInt(c.properties.height,10)),o||p)){for(o=o||d,p=p||l,C=[],z=0;o>z;z++)for(A=0;p>A;A++)d>z&&l>A?C[z+A*o]=c.data[z+A*d]:C[z+A*o]=0;d=o,l=p}if(r=JSON.parse(JSON.stringify(platypus.game.settings.entities[a]||e[a])),s={},t=[],u=[],"collision-layer"===a)for(x=[],z=0;zz;z++)s["tile"+z]=z;for(z=0;d>z;z++)for(t[z]=[],u[z]=[],A=0;l>A;A++)y=+C[z+A*d]-1,u[z][A]="tile"+y,x&&x.length&&x[0]===(268435455&y)&&(y=b(y)),t[z][A]=y;for(z=0;zA);o++)G=i[o];if(z="",""!==v.type?z=v.type:""!==v.name?z=v.name:G.tileproperties[A-G.firstgid]&&(G.tileproperties[A-G.firstgid].entity?z=G.tileproperties[A-G.firstgid].entity:G.tileproperties[A-G.firstgid].type&&(z=G.tileproperties[A-G.firstgid].type)),""!==z){if(H={},F?(H.scaleX=F.x,H.scaleY=F.y):(H.scaleX=1,H.scaleY=1),A>=0&&G.tileproperties&&G.tileproperties[A-G.firstgid])for(n in G.tileproperties[A-G.firstgid])G.tileproperties[A-G.firstgid].hasOwnProperty(n)&&(J=parseFloat(G.tileproperties[A-G.firstgid][n]),0===J||J?H[n]=J:"true"===G.tileproperties[A-G.firstgid][n]?H[n]=!0:"false"===G.tileproperties[A-G.firstgid][n]?H[n]=!1:H[n]=G.tileproperties[A-G.firstgid][n]);for(n in v.properties)if(v.properties.hasOwnProperty(n))if(y=v.properties[n],"string"==typeof y)if(J=parseFloat(y),0===J||J)H[n]=J;else if("true"===y)H[n]=!0;else if("false"===y)H[n]=!1;else if(y.length>2&&("{"===y[0]&&"}"===y[y.length-1]||"["===y[0]&&"]"===y[y.length-1]))try{H[n]=JSON.parse(y)}catch(P){H[n]=y}else H[n]=y;else H[n]=y;if(v.polygon||v.polyline){for(B=1/0,C=-(1/0),D=1/0,E=-(1/0),K=null,v.polygon?K=v.polygon:v.polyline&&(K=v.polyline),o=0;oC&&(C=K[o].x),K[o].xE&&(E=K[o].y),K[o].y5&&".json"===a.src.substring(a.src.length-5).toLowerCase())f(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(d in a)a.hasOwnProperty(d)&&(g+=1);if(g)for(d in a)a.hasOwnProperty(d)&&i(a,d,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void e(a,function(a){"object"==typeof a?f(a,b):b(a)})}b(a)},g=function(c,d,e){var g=this,h=function(f){var h=null;if(c=f,console.log("Game config loaded.",c),platypus.game=g,g.currentScene=null,g.loaded=null,g.settings=c,d)g.stage=d;else if(b){try{h=document.getElementById(c.global.canvas)}catch(i){console.warn('Stage not provided and canvas ID "'+c.global.canvas+'" not found in HTML wrapper.')}g.stage=new b(h)}else console.warn("Platypus requires a CreateJS Stage for rendering.");g.loadScene(c.global.initialScene),e&&e(g),a&&c.global.tickerOn!==!1&&(g.tickHandler=function(a){g.tick(a)},a.timingMode="raf",a.setFPS(c.global.fps||60),a.addEventListener("tick",g.tickHandler)),window&&(window.getEntityById=function(a){return g.getEntityById(a)},window.getEntitiesByType=function(a){return g.getEntitiesByType(a)},window.getVisibleSprites=function(a,b){if(b=b||[],a=a||d,!a.texture&&a.visible){for(var c=0;c1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b),d=0;d5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}d=0}if(this.loopCheck.push(a),this.messages[a]&&this.messages[a].length)for(g=this.messages[a].slice(),h=g.length,d=0;h>d;d++)g[d].callback.call(g[d].scope||this,b,c);if(this.loopCheck.length=this.loopCheck.length-1,!this.loopCheck.length&&this.unbindLater.length){for(e=0;ef;f++)this.matrix[f]=d[f];return this},b.copyValues=function(a){return this.set(a)},b.magnitude=function(a){var b=0,c=0;for(a=a||this.matrix.length,c=0;a>c;c++)b+=Math.pow(this.matrix[c],2);return Math.sqrt(b)},b.getAngle=function(){var a=this.magnitude(2),b=0;return 0!==a&&(b=Math.acos(this.x/a),this.y<0&&(b=2*Math.PI-b)),b},b.getUnit=function(){return new platypus.Vector(this).normalize()},b.getInverse=function(){return new platypus.Vector(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this.multiply(0):this.multiply(1/a)},b.cross=function(){var a=function(a,b,c,d){return a*d-b*c};return function(b){var c=a(this.y,this.z,b.y,b.z),d=-a(this.x,this.z,b.x,b.z),e=a(this.x,this.y,b.x,b.y);return this.x=c,this.y=d,this.z=e,this}}(),b.getCrossProduct=function(a){return new platypus.Vector(this).cross(a)},b.rotate=function(b,c){var d=c,e=Math.cos(b),f=Math.sin(b),g=1-e,h=0,i=0,j=0;return d?"x"===d?d=new a(1,0,0):"y"===d?d=new a(0,1,0):"z"===d&&(d=new a(0,0,1)):d=new a(0,0,1),h=d.x,i=d.y,j=d.z,this.multiply([[e+h*h*g,h*i*g-j*f,h*j*g+i*f],[i*h*g+j*f,e+i*i*g,i*j*g-h*f],[j*h*g-i*f,j*i*g+h*f,e+j*j*g]])},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a))for(e=this.matrix.slice(),f=b||a.length,c=0;f>c;c++)for(this.matrix[c]=0,d=0;f>d;d++)this.matrix[c]+=e[d]*a[c][d];else for(f=b||this.matrix.length,c=0;f>c;c++)this.matrix[c]*=a;return this},b.add=function(b,c,d){var e=b,f=0,g=0;for(Array.isArray(e)?f=c||this.matrix.length:e instanceof a?(e=e.matrix,f=c||this.matrix.length):(e=[b||0,c||0,d||0],f=this.matrix.length),g=0;f>g;g++)this.matrix[g]+=e[g];return this},b.addVector=function(a,b){return this.add(a,b)},b.subtractVector=function(a,b){return this.add(a.getInverse(),b)},b.scale=function(a,b){return this.multiply(a,b)},b.dot=function(a,b){var c=0,d=0;for(b=b||this.matrix.length,d=0;b>d;d++)c+=this.matrix[d]*(a.matrix[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit();return Math.acos(b.dot(c))},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit();return c.getCrossProduct(d).dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d))},b.scalarProjection=function(a){var b=0;return b="number"==typeof a?a:this.angleTo(a),this.magnitude(2)*Math.cos(b)},b.copy=function(){return new platypus.Vector(this)},a.assign=function(){var a=function(a,b,c,d){var e=null,f=!1;"string"==typeof a&&"undefined"!=typeof b[a]&&(e=b[a],delete b[a],f=!0),Object.defineProperty(b,a,{get:function(){return c.matrix[d]},set:function(a){c.matrix[d]=a},enumerable:!0}),f&&(b[a]=e)};return function(b,c){var d=0;if(b&&c){if(!b[c]){for(b[c]=new platypus.Vector,d=2;da.left&&(this.left=a.left),this.righta.top&&(this.top=a.top),this.bottomthis.bottom||a.leftthis.right)},b.containsVector=function(a){return!(a.ythis.bottom||a.xthis.right)},b.intersects=function(a){return!(a.bottomthis.bottom||a.rightthis.right)},a}(),function(){"use strict";var a=navigator.userAgent.toLowerCase(),b={touch:"undefined"!==window.ontouchstart,iPod:a.search("ipod")>-1,iPhone:a.search("iphone")>-1,iPad:a.search("ipad")>-1,safari:a.search("safari")>-1,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:a.search("android")>-1,chrome:a.search("chrome")>-1,silk:a.search("silk")>-1,iPhone4:!1,iPad2:!1,iOS:!1,mobile:!1,desktop:!1};b.iPhone4=b.iPhone&&480===window.screen.height,b.iPad2=b.iPad&&(!window.devicePixelRatio||1===window.devicePixelRatio),b.iOS=b.iPod||b.iPhone||b.iPad,b.mobile=b.iOS||b.android||b.silk,b.desktop=!b.mobile,platypus.supports=b}(),platypus.CollisionData=function(){"use strict";var a=function(a,b,c,d,e,f,g,h,i){this.occurred=a||!1,this.direction=b||null,this.position=c||null,this.deltaMovement=d||null,this.aABB=e||null,this.thisShape=f||null,this.thatShape=g||null,this.vector=h||null,this.stuck=i||0},b=a.prototype;return b.copy=function(a){this.occurred=a.occurred,this.direction=a.direction,this.position=a.position,this.deltaMovement=a.deltaMovement,this.aABB=a.aABB,this.thisShape=a.thisShape,this.thatShape=a.thatShape,this.vector=a.vector,this.stuck=a.stuck},b.clear=function(){this.occurred=!1,this.direction=null,this.position=null,this.deltaMovement=null,this.aABB=null,this.thisShape=null,this.thatShape=null,this.vector=null,this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=[new platypus.CollisionData,new platypus.CollisionData],this.yData=[new platypus.CollisionData,new platypus.CollisionData],this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},b=a.prototype;return b.getXEntry=function(a){return this.xData[a]},b.getYEntry=function(a){return this.yData[a]},b.tryToAddX=function(a){return a.deltaMovementa;a++)this.xData[a]=new platypus.CollisionData},b.ensureRoomY=function(){var a=0,b=2*this.yData.length;if(this.yData.length<=this.yCount)for(a=this.yData.length;b>a;a++)this.yData[a]=new platypus.CollisionData},b.reset=function(){this.xCount=0,this.yCount=0,this.xDeltaMovement=1/0,this.yDeltaMovement=1/0},a}(),platypus.CollisionShape=function(){"use strict";var a=function(a,b,c){var d=b.regX,e=b.regY,f=0,g=0;switch(this.owner=a,this.collisionType=c,this.width=b.width||2*b.radius||0,this.height=b.height||2*b.radius||0,this.radius=b.radius||0,"number"!=typeof d&&(d=this.width/2),"number"!=typeof e&&(e=this.height/2),platypus.Vector.assign(this,"offset","offsetX","offsetY"),this.offsetX=b.offsetX||this.width/2-d,this.offsetY=b.offsetY||this.height/2-e,platypus.Vector.assign(this,"position","x","y"),a?(this.x=a.x+this.offsetX,this.y=a.y+this.offsetY):(this.x=b.x+this.offsetX,this.y=b.y+this.offsetY),this.type=b.type||"rectangle",this.subType="",this.aABB=void 0,this.type){case"circle":f=g=2*this.radius;break;case"rectangle":f=this.width,g=this.height}platypus.Vector.assign(this,"size","width","height"),this.width=f,this.height=g,this.aABB=new platypus.AABB(this.x,this.y,f,g)},b=a.prototype;return b.update=function(a,b){this.x=a+this.offsetX,this.y=b+this.offsetY,this.aABB.move(this.x,this.y)},b.moveX=function(a){this.x=a,this.aABB.moveX(this.x)},b.moveY=function(a){this.y=a,this.aABB.moveY(this.y)},b.getAABB=function(){return this.aABB},b.setXWithEntityX=function(a){this.x=a+this.offsetX,this.aABB.moveX(this.x)},b.setYWithEntityY=function(a){this.y=a+this.offsetY,this.aABB.moveY(this.y)},b.destroy=function(){this.aABB=void 0},b.multiply=function(a){this.position.subtractVector(this.owner.position),this.position.multiply(a),this.offset.multiply(a),this.size.multiply(a),this.position.addVector(this.owner.position),this.width=Math.abs(this.width),this.height=Math.abs(this.height),this.aABB.setAll(this.x,this.y,this.width,this.height)},a}(),platypus.Entity=function(){"use strict";var a={},b=function(b,c){var d=this,e=0,f=null,g=b||{},h=g.components||[],i=g.properties||{},j=c||{},k=j.properties||{};for(platypus.Messenger.call(d),d.components=[],d.type=g.id||"none",d.id=j.id||k.id,d.id||(a[d.type]||(a[d.type]=0),d.id=d.type+"-"+a[d.type],a[d.type]+=1),this.setProperty(i),this.setProperty(k),this.bind("set-property",function(a){d.setProperty(a)}),d.state||(d.state={}),d.lastState={},this.destroyed=!1,e=0;e=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},d=function(b){var c=0,d=[],e=null,f=a.instance.assetManager.cache;for(c=0;cd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},i.destroy=function(){this.stop(),PIXI.Sprite.prototype.destroy.call(this)}}(),function(){"use strict";var a=function(a){return function(){return platypus.game.settings.debug&&console.log('"'+a+'" is not an available PIXI.Graphics method.'),this}},b=PIXI.Graphics.prototype;b.a=b.arc,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.c=b.clear,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dr=b.drawRect,b.ef=b.endFill,b.f=b.beginFill,b.lt=b.lineTo,b.mt=b.moveTo,b.qt=b.quadraticCurveTo,b.r=b.drawRect,b.rr=b.drawRoundedRect,b.cp=a("cp"),b.lf=a("lf"),b.rf=a("rf"),b.bf=a("bf"),b.ss=a("ss"),b.sd=a("sd"),b.s=a("s"),b.ls=a("ls"),b.rs=a("rs"),b.bs=a("bs"),b.es=a("es"),b.rc=a("rc"),b.dp=a("dp"),b.p=a("p")}(),function(){"use strict";var a=PIXI.Container.prototype;a.updateTransform=function(){var a=0,b=0;if(this.visible)for(this.transformMatrix?(this.transformMatrix.copy(this.worldTransform).prepend(this.parent.worldTransform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null):this.displayObjectUpdateTransform(),a=0,b=this.children.length;b>a;++a)this.children[a].updateTransform()},a.containerUpdateTransform=a.updateTransform}(),function(){"use strict";var a=include("springroll.ApplicationPlugin"),b=null,c=new a,d=null;c.preload=function(a){var c=this.config.platypus,e=null,f={delta:0};c?(this.options.debug&&(c.debug=!0),e=this.platypus=new platypus.Game(c,this.display.stage),b=function(a){f.delta=a,e.tick(f)},this.on("update",b,320),d=function(a){e.currentScene.trigger("resize",a)},this.on("resize",d)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},c.teardown=function(){this.platypus&&(this.off("update",b),this.off("resize",d),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(a){this.target=this.owner.target||null,this.offset=new platypus.Vector(0,0)},events:{load:function(){return this.owner.addMover?void(this.direction=this.owner.addMover({vector:[this.speed,0,0],event:"chase",accelerator:this.accelerate}).vector):void console.warn('The "AIChaser" component requires a "Mover" component to function correctly.')},"handle-ai":function(){var b=a,c=0,d=!1;this.target&&this.chasing&&(b.set(this.offset).add(this.target.position).subtractVector(this.owner.position),c=b.magnitude(2),c&&(d=!0,this.direction.set(b).normalize().multiply(this.speed))),d!==this.owner.state.chasing&&(this.owner.state.chasing=d,this.owner.triggerEvent("chase",d))},"set-target":function(a){this.target=a,this.offset.x=0,this.offset.y=0},"set-target-offset":function(a){this.offset.x=a.x,this.offset.y=a.y},"start-chasing":function(a){a&&(this.target=a),this.chasing=!0},"stop-chasing":function(){this.chasing=!1}},methods:{destroy:function(){this.target=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"AIPacer",properties:{movement:"both",direction:null},constructor:function(a){this.lastDirection="",this.currentDirection=this.direction||("horizontal"===this.movement?"left":"up")},events:{"handle-ai":function(){this.currentDirection!==this.lastDirection&&(this.lastDirection=this.currentDirection,this.owner.triggerEvent("stop"),this.owner.triggerEvent("go-"+this.currentDirection))},"turn-around":function(a){("both"===this.movement||"horizontal"===this.movement)&&(a.x>0?this.currentDirection="left":a.x<0&&(this.currentDirection="right")),("both"===this.movement||"vertical"===this.movement)&&(a.y>0?this.currentDirection="up":a.y<0&&(this.currentDirection="down"))}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a){var b=a.split("/");return b=b[b.length-1].split("."),b[0]},c=function(a,c){var d=0,e=!1;for(a.id||(a.id=b(a.src)),d=0;d=0;b--)e.exists(d[b].id)&&(e.preload(d[b].id,a),d.splice(b,1));d.length&&this.app.load(d,{taskDone:a})}}})}(),function(){"use strict";var a=include("springroll.Application"),b={interrupt:createjs.Sound.INTERRUPT_ANY,delay:0,offset:0,loop:0,volume:1,pan:0,mute:!1,paused:!1,next:!1,events:!1},c=function(a,b){return a.time-b.time},d=function(){var b=a.instance.voPlayer;this.play=function(a,c){var d=c.complete;return b.play(a,function(){d(!1)},function(){d(!0)}),this},this.stop=this.pause=function(){b.stop()},this.unpause=function(){},Object.defineProperty(this,"position",{get:function(){return b.playing?b.getElapsed():0}})},e=function(){var b=a.instance.sound;this.play=function(a,c){return b.play(a,c)}},f=function(a){var d=0,e="",f="",g=null; +if("string"==typeof a)e=a,g={};else if(Array.isArray(a)){if("string"==typeof a[0])e=a[0],g={next:[]};else{e=a[0].sound,g={};for(f in a[0])a[0].hasOwnProperty(f)&&(g[f]=a[0][f]);g.next?g.next=g.next.slice():g.next=[]}for(d=1;d=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},checkTimeEvents:function(a,b){var c=a.sequenceEvents,d=0;if(c&&c.length)for(d=a.position;c.length&&(b||c[0].time<=d);)this.owner.trigger(c[0].event,c[0].message),c.splice(0,1)},onComplete:function(a,b){if(this.removeClip(a),this.checkTimeEvents(a,!0),this.owner.triggerEvent("clip-complete"),b&&b.length)if("string"==typeof b)f(b).call(this);else{var c=b.slice();c.splice(0,1),c.length>0?f(b[0]).call(this,{next:c}):f(b[0]).call(this)}else this.owner.triggerEvent("sequence-complete")},removeClip:function(a){var b=0;for(b=0;b=0;c--)d[c].soundId===a&&(b?d[c].addEventListener("loop",f):(d[c].stop(),d.splice(c,1)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.splice(b,1))},onComplete:function(a){this.removeClip(a),this.owner.triggerEvent("clip-complete")},removeClip:function(a){var b=0;for(b=0;bthis.threshold?(this.worldWidth&&0!==this.worldWidth&&this.worldWidththis.worldWidth?b.moveX(this.worldWidth-b.halfWidth):this.worldWidth&&0!==this.worldWidth&&athis.threshold?(this.worldHeight&&0!==this.worldHeight&&this.worldHeightthis.worldHeight?b.moveY(this.worldHeight-b.halfHeight):this.worldHeight&&0!==this.worldHeight&&a1e-4?(this.worldCamera.orientation=a,!0):!1},lockedFollow:function(){var a=Math.min,b=function(a,b,c){return c*b+(1-c)*a},c=function(b,c){return b?a(c/b,1):1};return function(a,d,e){var f=b(this.worldCamera.viewport.x,a.x,c(this.transitionX,d)),g=b(this.worldCamera.viewport.y,a.y,c(this.transitionY,d));return this.rotate?this.move(f,g,b(this.worldCamera.orientation,-(a.orientation||0),c(this.transitionAngle,d))):this.move(f,g,0)}}(),forwardFollow:function(a,b){var c=this.forwardFollower,d=15/b,e=!1,f=a.x+this.offsetX,g=a.y+this.offsetY,h=(a.orientation||0)+this.offsetAngle;return this.followFocused&&this.lastX===f&&this.lastY===g?this.lockedFollow(c,b):(this.averageOffsetX*=.9,this.averageOffsetY*=.9,this.averageOffsetX+=.1*(f-this.lastX)*d,this.averageOffsetY+=.1*(g-this.lastY)*d,Math.abs(this.averageOffsetX)>this.worldCamera.viewport.width/(2*this.forwardX)&&(this.averageOffsetX=0),Math.abs(this.averageOffsetY)>this.worldCamera.viewport.height/(2*this.forwardY)&&(this.averageOffsetY=0),this.rotate&&(this.averageOffsetAngle*=.9,this.averageOffsetAngle+=.1*(h-this.lastOrientation)*d,Math.abs(this.averageOffsetAngle)>this.worldCamera.orientation/(2*this.forwardAngle)&&(this.averageOffsetAngle=0)),c.x=this.averageOffsetX*this.forwardX+f,c.y=this.averageOffsetY*this.forwardY+g,c.orientation=this.averageOffsetAngle*this.forwardAngle+h,this.lastX=f,this.lastY=g,this.lastOrientation=h,e=this.lockedFollow(c,b),this.followFocused||e||(this.followFocused=!0),e)},boundingFollow:function(a,b){var c=0,d=0,e=this.transitionX?Math.min(b/this.transitionX,1):1,f=1-e,g=this.transitionY?Math.min(b/this.transitionY,1):1,h=1-g;return this.boundingBox.move(this.worldCamera.viewport.x,this.worldCamera.viewport.y),a.x>this.boundingBox.right?c=a.x-this.boundingBox.halfWidth:a.xthis.boundingBox.bottom?d=a.y-this.boundingBox.halfHeight:a.ya?this.overflow?this.worldCamera.viewport.resize(this.height*b,this.height):this.viewport.resize(this.viewport.height*a,this.viewport.height):this.overflow?this.worldCamera.viewport.resize(this.width,this.width/b):this.viewport.resize(this.viewport.width,this.viewport.width/a)),this.worldPerWindowUnitWidth=this.worldCamera.viewport.width/this.viewport.width,this.worldPerWindowUnitHeight=this.worldCamera.viewport.height/this.viewport.height,this.windowPerWorldUnitWidth=this.viewport.width/this.worldCamera.viewport.width,this.windowPerWorldUnitHeight=this.viewport.height/this.worldCamera.viewport.height,this.matrix.tx=this.viewport.x-this.viewport.halfWidth,this.matrix.ty=this.viewport.y-this.viewport.halfHeight,this.viewportUpdate=!0},windowToWorld:function(a){var b=[];return b[0]=Math.round((a[0]-this.viewport.x)*this.worldPerWindowUnitWidth),b[1]=Math.round((a[1]-this.viewport.y)*this.worldPerWindowUnitHeight),b},worldToWindow:function(a){var b=[];return b[0]=Math.round(a[0]*this.windowPerWorldUnitWidth+this.viewport.x),b[1]=Math.round(a[1]*this.windowPerWorldUnitHeight+this.viewport.y),b},destroy:function(){this.parentContainer.removeChild(this.container),this.parentContainer=null,this.container=null}}})}(),function(){"use strict";return platypus.createComponentClass({id:"CameraFollowMe",properties:{camera:{},mode:"forward",pause:!1},constructor:function(a){this.pauseGame=a.pause?{time:a.time}:null,this.camera={entity:this.owner,mode:this.camera.mode||this.mode,top:this.camera.top,left:this.camera.left,offsetX:this.camera.offsetX,offsetY:this.camera.offsetY,width:this.camera.width,height:this.camera.height,time:this.camera.time}},events:{"follow-me":function(a){var b=this.camera;a&&(b={entity:this.owner,mode:a.mode||this.camera.mode,top:a.top||this.camera.top,left:a.left||this.camera.left,offsetX:a.offsetX||this.camera.offsetX,offsetY:a.offsetY||this.camera.offsetY,width:a.width||this.camera.width,height:a.height||this.camera.height,time:a.time||this.camera.time}),this.pauseGame&&(this.owner.parent.trigger("pause-logic",this.pauseGame),this.owner.parent.trigger("pause-render",this.pauseGame)),this.owner.parent.trigger("follow",b)}}})}(),function(){"use strict";var a=function(a,b,c){var d=0,e=b.stuck;e&&(d=a.magnitude(),b.thatShape.owner&&Math.abs(e)>1&&(e*=.05),(!d||d>Math.abs(e))&&(b.vector.x&&(a.x=e,a.y=0),b.vector.y&&(a.x=0,a.y=e),c.stuckWith=new platypus.Vector(b.thatShape.x,b.thatShape.y)))},b=function(a,b,c){return"string"==typeof a?function(d){d.myType===c&&d.hitType===b&&this.owner.triggerEvent(a,d)}:Array.isArray(a)?function(d){var e=0;if(d.myType===c&&d.hitType===b)for(e=0;e0&&a.bottom&&this.owner.trigger(a.bottom,d),0>f&&a.top&&this.owner.trigger(a.top,d),e>0&&a.right&&this.owner.trigger(a.right,d),0>e&&a.left&&this.owner.trigger(a.left,d),a.all&&this.owner.trigger(a.all,d))}},c=function(b,c){c.collisionFunctions||(c.collisionFunctions={},c.getAABB=function(a){var b=null,d="";if(a)return c.collisionFunctions[a]?c.collisionFunctions[a].getAABB():null;b=c.aabb=c.aabb||new platypus.AABB,b.reset();for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&b.include(c.collisionFunctions[d].getAABB());return b},c.getPreviousAABB=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPreviousAABB():null},c.getShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getShapes():null},c.getPrevShapes=function(a){return c.collisionFunctions[a]?c.collisionFunctions[a].getPrevShapes():null},c.prepareCollision=function(a,b){var d="";for(d in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(d)&&c.collisionFunctions[d].prepareCollision(a,b)},c.relocateEntity=function(b,d){var e=null;d.xCount&&(e=new platypus.Vector(0,0,0),a(e,d.getXEntry(0),c)),d.yCount&&(e=e||new platypus.Vector(0,0,0),a(e,d.getYEntry(0),c)),c.triggerEvent("relocate-entity",{position:b,unstick:e})},c.movePreviousX=function(a){var b="";for(b in c.collisionFunctions)c.collisionFunctions.hasOwnProperty(b)&&c.collisionFunctions[b].movePreviousX(a)},c.getCollisionTypes=function(){return c.collisionTypes},c.getSolidCollisions=function(){return c.solidCollisions}),c.collisionFunctions[b.collisionType]={getAABB:function(){return b.getAABB()},getPreviousAABB:function(){return b.getPreviousAABB()},getShapes:function(){return b.getShapes()},getPrevShapes:function(){return b.getPrevShapes()},prepareCollision:function(a,c){b.prepareCollision(a,c)},movePreviousX:function(a){b.movePreviousX(a)}}};return platypus.createComponentClass({id:"CollisionBasic",properties:{collisionType:"none",shapeType:"rectangle",ignoreOrientation:!1,regX:null,regY:null,width:0,height:0,radius:0,margin:0,shapes:null},publicProperties:{immobile:!1,bullet:!1,jumpThrough:!1},constructor:function(a){var d=0,e="",f=null,g=this.regX,h=this.regY,i=this.width,j=this.height,k=this.radius,l=this.margin.left||this.margin,m=this.margin.right||this.margin,n=this.margin.top||this.margin,o=this.margin.bottom||this.margin;for(null===g&&(g=this.regX=i/2),null===h&&(h=this.regY=j/2),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.aabb=new platypus.AABB,this.prevAABB=new platypus.AABB,this.shapes?f=this.shapes:"circle"===this.shapeType?(k=k||((i||0)+(j||0))/4,f=[{regX:(isNaN(g)?k:g)-(m-l)/2,regY:(isNaN(h)?k:h)-(o-n)/2,radius:k,type:this.shapeType}]):f=[{regX:(isNaN(g)?(i||0)/2:g)-(m-l)/2,regY:(isNaN(h)?(j||0)/2:h)-(o-n)/2,points:a.points,width:(i||0)+l+m,height:(j||0)+n+o,type:this.shapeType}],this.owner.collisionTypes=this.owner.collisionTypes||[],this.owner.collisionTypes.push(this.collisionType),this.shapes=[],this.prevShapes=[],this.entities=void 0,d=0;d0?this.owner.position.add(b):this.stuck=!1),this.aabb.reset(),d=0;d0&&(this.stuck||(this.stuck=!0),this.move=this.owner.stuckWith.copy().add(-this.owner.x,-this.owner.y).normalize())},"handle-logic":function(){this.move&&this.owner.position.add(this.move),this.owner.checkCollision=!0},"orientation-updated":function(a){var b=0;if(!this.ignoreOrientation)for(b=0;b0&&(this.owner.collides=!0),this.owner.softCollisions[this.collisionType]&&(this.owner.softCollisions[this.collisionType].length=0,delete this.owner.softCollisions[this.collisionType]),delete this.owner.collisionFunctions[this.collisionType],this.shapes.length=0,this.prevShapes.length=0,delete this.entities,this.owner.collisionTypes.length&&this.owner.parent.trigger("add-collision-entity",this.owner)}}})}(),function(){"use strict";var a=function(a,b,c){return function(d){a.state[b]&&a.trigger(c,d)}},b=function(a,b,c){return function(d){a.state[b]||a.trigger(c,d)}};return platypus.createComponentClass({id:"CollisionFilter",properties:{collisions:{},state:""},constructor:function(c){var d="",e=this.collisions,f=this.state;if(e)if("!"===f[0]){f=f.substring(1);for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,b(this.owner,f,e[d]))}else for(d in e)e.hasOwnProperty(d)&&this.addEventListener(d,a(this.owner,f,e[d]))}})}(),function(){"use strict";var a=function(a,b){var c=0,d=0,e=a.length,f=!1;for(c=0;cd;d++)if(b[c]===a[d]){f=!0;break}f||a.push(b[c])}return a};return platypus.createComponentClass({id:"CollisionGroup",constructor:function(a){var b=this;this.solidEntities=[],this.terrain=void 0,this.aabb=new platypus.AABB(this.owner.x,this.owner.y),this.prevAABB=new platypus.AABB(this.owner.x,this.owner.y),platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"previousPosition","previousX","previousY","previousZ"),this.owner.previousX=this.owner.previousX||this.owner.x,this.owner.previousY=this.owner.previousY||this.owner.y,this.collisionGroup=this.owner.collisionGroup={getAllEntities:function(){var a=0,c=0,d=null;for(a=0;aa?(a=Math.abs(a)-2,b[a]):a},e=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g];return h},f=function(a,b,c,d,e){var f=0,g=0,h=[];for(g=0;e>g;g++)for(h[g]=[],f=0;d>f;f++)h[g][f]=a[b+f][c+g],a[b+f][c+g]=-1;return h},g=function(a,b,c,d,e,f){var g=0,h=0;for(h=0;f>h;h++)for(g=0;e>g;g++)a[c+g][d+h]=b[h][g];return a},h={diagonal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-4,-3,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+j]=d(h[i][j],k);return a},"diagonal-inverse":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-2,-5,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[i][j],k);return a},horizontal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-2,-5,-4,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+j]=d(h[j][i],k);return a},vertical:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-3,-2,-5];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][c+g-j-1]=d(h[j][i],k);return a},"rotate-90":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-3,-4,-5,-2];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+g-j-1][c+i]=d(h[j][i],k);return a},"rotate-180":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-4,-5,-2,-3];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][c+g-j-1]=d(h[j][i],k);return a},"rotate-270":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=[-5,-2,-3,-4];for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+j][c+f-i-1]=d(h[j][i],k);return a},translate:function(a,b,c,d,e,g,h){var i=f(a,b,c,d,e),j=0,k=0;for(k=0;e>k;k++)for(j=0;d>j;j++)a[b+j+g][c+k+h]=i[k][j];return a}};return platypus.createComponentClass({id:"CollisionTiles",publicProperties:{collisionMap:[],tileWidth:10,tileHeight:10},constructor:function(a){this.tileHalfWidth=this.tileWidth/2,this.tileHalfHeight=this.tileHeight/2},events:{transform:function(a){this.transform(a)},translate:function(a){this.translate(a)}},methods:{getShape:function(c,d,e){var f=null;return b-1)a.push(this.getShape(b,c,d));else if(this.collisionMap[c][d]<-1)switch(this.collisionMap[c][d]){case-2:b.bottom<=d*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-3:b.left>=(c+1)*this.tileWidth&&a.push(this.getShape(b,c,d));break;case-4:b.top>=(d+1)*this.tileHeight&&a.push(this.getShape(b,c,d));break;case-5:b.right<=c*this.tileWidth&&a.push(this.getShape(b,c,d))}return a}},publicMethods:{getAABB:function(){return{left:0,top:0,right:this.tileWidth*this.collisionMap.length,bottom:this.tileHeight*this.collisionMap.length[0]}},isTile:function(a,b){return!(0>a||0>b||a>=this.collisionMap.length||b>=this.collisionMap[0].length||-1===this.collisionMap[a][b])},getTileShapes:function(a,d){var e=Math.max(Math.floor(a.left/this.tileWidth),0),f=Math.max(Math.floor(a.top/this.tileHeight),0),g=Math.min(Math.ceil(a.right/this.tileWidth),this.collisionMap.length),h=Math.min(Math.ceil(a.bottom/this.tileHeight),this.collisionMap[0].length),i=0,j=0,k=c;for(c.length=0,b=0,i=e;g>i;i++)for(j=f;h>j;j++)this.addShape(k,d,i,j);return k},transform:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.type||"horizontal";return h[g]?h[g](this.collisionMap,c,d,e,f):null},translate:function(a){var b=a||{},c=b.left||0,d=b.top||0,e=b.width||this.collisionMap[0].length,f=b.height||this.collisionMap.length,g=b.dx||0,i=b.dy||0;return h.translate(this.collisionMap,c,d,e,f,g,i)},getCollisionMatrix:function(a,b,c,d){return e(this.collisionMap,a,b,c,d)},setCollisionMatrix:function(a,b,c,d,e){return g(this.collisionMap,a,b,c,d,e)}}})}(),function(){"use strict";var a=function(a,b){return function(){setTimeout(function(){var c=0,d=0;if(a.remove)if("string"==typeof a.remove)for(c=b.components.length-1;c>-1;c--)b.components[c].type===a.remove&&b.removeComponent(b.components[c]);else for(c=0;c-1;d--)b.components[d].type===a.remove[c]&&b.removeComponent(b.components[d]);if(a.add)if(Array.isArray(a.add))for(c=0;ce&&(f=g-f),f):f},c=[null,null,null,null,["east","south","west","north"],null,null,null,["east","southeast","south","southwest","west","northwest","north","northeast"],null,null,null,null,null,null,null,["east","east-southeast","southeast","south-southeast","south","south-southwest","southwest","west-southwest","west","west-northwest","northwest","north-northwest","north","north-northeast","northeast","east-northeast"]],d=["left-button","middle-button","right-button"],e=function(a,b){this.event=a,this.trigger=b,this.filters=!1,this.current=!1,this.last=!1,this.state=!1,this.stateSummary={pressed:!1,released:!1,triggered:!1,over:!1}},f=function(a){var b=0;return Array.isArray(a)?function(c){for(b=0;bthis.joystick.outerRadius||f=b.right||a.right<=b.left||a.top>=b.bottom||a.bottom<=b.top?!1:!0},d=function(a,b){var c=0,d=0,e=null,f=null,g=0,h=0,i=null,j=0;if("rectangle"===a.type&&"rectangle"===b.type)return!0;if("circle"===a.type&&"circle"===b.type){if(c=Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2),d=Math.pow(a.radius+b.radius,2),d>=c)return!0}else if("circle"===a.type&&"rectangle"===b.type||"rectangle"===a.type&&"circle"===b.type){if("circle"===a.type?(e=a,f=b):(e=b,f=a),i=f.getAABB(),g=Math.abs(e.x-f.x),h=Math.abs(e.y-f.y),g>=i.halfWidth+e.radius)return!1;if(h>=i.halfHeight+e.radius)return!1;if(ge;e++)if(s=this.allEntities[e],s.alwaysOn||s.checkCollision||t(s.getAABB(),u)){if(s.checkCollision=!1,i[i.length]=s,w=s.collisionTypes,s!==this.owner)for(f=0;ff;f++)s=r[f],(s.alwaysOn||t(s.getAABB(),v))&&(h[h.length]=s)}}}(),prepareCollisions:function(a){var b=0,c=null;for(this.nonColliders.length=0,b=this.allEntitiesLive.length-1;b>-1;b--)c=this.allEntitiesLive[b],c.triggerEvent("prepare-for-collision",a),c.collides||this.nonColliders.push(c)},resolveNonCollisions:function(){var a=0,b=null,c={position:new platypus.Vector,relative:!1};for(a=this.nonColliders.length-1;a>-1;a--)b=this.nonColliders[a],c.position.set(b.position),b.trigger("relocate-entity",c)},checkGroupCollisions:function(){var c=function(b,c,d,e,f,g,h,i){a.entity=c,a.myType=d,a.type=e,a.x=f,a.y=g,a.direction=i,a.hitType=h,b.triggerEvent("hit-by-"+e,a),c&&(a.entity=b,a.type=d,a.myType=e,a.x=-f,a.y=-g,a.direction=i.getInverse(),a.hitType=h,c.triggerEvent("hit-by-"+d,a))};return function(){var a=0,d=0,e=this.groupsLive,f=new platypus.Vector,g=null;for(a=e.length-1;a>-1;a--)if(e[a].collisionGroup.getSize()>1){for(b.reset(),f.set(0,0,0),f=this.checkSolidEntityCollision(e[a],e[a].collisionGroup,b,f),d=0;d-1;a--){for(b.reset(),g.set(0,0,0),g=this.checkSolidEntityCollision(f[a],f[a],b,g),d=0;df;f++){if(b.prepareCollision(a.previousX+l,a.previousY+m),h.set(a.position),h=this.processCollisionStep(a,b,q,c,h,l,m,p),h.x===a.previousX&&h.y===a.previousY){b.relocateEntity(h,c);break}b.relocateEntity(h,c)}}return h},processCollisionStep:function(){var a=new platypus.AABB,b=function(a,b,c,d,e){var f=0,g=c.getAABB(d);if(c===a)return!1;if(c.jumpThrough&&b.bottom>g.top)return!1;if(a.jumpThrough&&g.bottom>b.top)return!1;if(e)for(f=0;f0?(a.copy(f.getXEntry(0)),d.x=b.previousX+a.deltaMovement*a.direction):d.x=b.x,c.movePreviousX(d.x),0!==i)for(j=0;j0?(a.copy(f.getYEntry(0)),d.y=b.previousY+a.deltaMovement*a.direction):d.y=b.y,d}}(),findMinAxisMovement:function(){var a=new platypus.CollisionData;return function(b,c,d,e,f,g){var h=0,i=c.getShapes(d),j=c.getPrevShapes(d);for(h=0;h=f.aABB.top&&e.y<=f.aABB.bottom?f.aABB.halfWidth+e.radius:(a.y=d(e.y,f.y,f.aABB.halfHeight),i=f.aABB.halfWidth+c(a.y,e.radius),g===e?(a.x=-d(e.x-h*i,f.x,f.aABB.halfWidth)/2,a.y=-a.y):a.x=d(e.x,f.x-h*i,f.aABB.halfWidth)/2,a.normalize(),i):"y"===b?e.x>=f.aABB.left&&e.x<=f.aABB.right?f.aABB.halfHeight+e.radius:(a.x=d(e.x,f.x,f.aABB.halfWidth),i=f.aABB.halfHeight+c(a.x,e.radius),g===e?(a.x=-a.x,a.y=-d(e.y-h*i,f.y,f.aABB.halfWidth)/2):a.y=d(e.y,f.y-h*i,f.aABB.halfWidth)/2,a.normalize(),i):void 0},g=function(a,b,d){return"x"===a?c(b.y-d.y,b.radius+d.radius):"y"===a?c(b.x-d.x,b.radius+d.radius):void 0};return function(c,d,h,i){if("rectangle"===h.type){if("rectangle"===i.type)return b.position=i[c]-d*e(c,h.getAABB(),i.getAABB()),a.x=0,a.y=0,a[c]=d,b;if("circle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,i,h,h,d),b}else if("circle"===h.type){if("rectangle"===i.type)return a.x=0,a.y=0,a[c]=d,b.position=i[c]-d*f(c,h,i,h,d),b;if("circle"===i.type)return b.position=i[c]-d*g(c,h,i),a.x=i.x-h.x,a.y=i.y-h.y,a[c]=i[c]-b.position,a.normalize(),b}}}();return function(e,f,g,h,i){var j=0,k=e[g],l=f[g],m=e,n=l>k?1:-1,o=l,p=null,q=l;if(k!==l)for("x"===g?m.moveX(l):"y"===g&&m.moveY(l),j=0;j0?q>o&&(k>o&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)):o>q&&(o>k&&(o=k),q=o,a(i,n,q,k,f,h[j],p.contactVector)));return i}}(),checkSoftCollisions:function(a){var b=0,c=function(a){return function(b){a.trigger("hit-by-"+b.type,b)}};for(b=0;b-1;b--)if(this.entities[b]===a){this.entities.splice(b,1);break}},"pause-logic":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-logic":function(){this.paused=0},"camera-update":function(a){this.camera.left=a.viewport.left,this.camera.top=a.viewport.top,this.camera.width=a.viewport.width,this.camera.height=a.viewport.height,-1===this.camera.buffer&&(this.camera.buffer=this.camera.width/10),this.camera.active=!0,this.updateNeeded=!0},tick:function(b){var c=0,d=0,e=0,f=null;if(this.leftoverTime+=b.delta,e=Math.floor(this.leftoverTime/this.stepLength)||1,this.message.delta=this.stepLength,this.leftoverTime=Math.max(this.leftoverTime-e*this.stepLength,0),this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),!this.paused){for(this.message.tick=b,this.activeEntities===this.entities&&(this.message.movers=this.activeEntities=[]),this.activeEntities.length=0,d=this.entities.length-1;d>-1;d--)f=this.entities[d],(f.alwaysOn||"undefined"==typeof f.x||f.x>=this.camera.left-this.camera.buffer&&f.x<=this.camera.left+this.camera.width+this.camera.buffer&&f.y>=this.camera.top-this.camera.buffer&&f.y<=this.camera.top+this.camera.height+this.camera.buffer)&&this.activeEntities.push(f);for(e=Math.min(e,this.maxStepsPerTick),c=0;e>c;c++){for(this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-ai",this.message),d=this.activeEntities.length-1;d>-1;d--)this.activeEntities[d].triggerEvent("handle-logic",this.message);if(this.owner.triggerEvent("check-collision-group",this.message))for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],f.triggerEvent("handle-post-collision-logic",this.message),a(f)&&f.triggerEvent("state-changed",f.state);else for(d=this.activeEntities.length-1;d>-1;d--)f=this.activeEntities[d],a(f)&&f.triggerEvent("state-changed",f.state)}}}}})}(),function(){"use strict";return platypus.createComponentClass({id:"HandlerRender",properties:{acceptInput:null},publicProperties:{},constructor:function(a){this.container=new PIXI.Container,this.camera={x:0,y:0},this.acceptInput&&(this.click=this.acceptInput.click,this.cameraMovementMovesMouse=this.acceptInput.camera,this.hover=this.acceptInput.hover,(this.click||this.hover)&&(this.addInputs(),this.addEventListener())),this.renderMessage={delta:0,container:this.container}},events:{load:function(){this.owner.triggerEvent("render-world",{world:this.container})},"child-entity-added":function(a){a.triggerEvent("handle-render-load",this.renderMessage)},"pause-render":function(a){a&&a.time?this.paused=a.time:this.paused=-1},"unpause-render":function(){this.paused=0},tick:function(){var a=function(a,b){return a.z-b.z};return function(b){var c=0,d=null,e=this.renderMessage;if(e.delta=b.delta,this.paused>0&&(this.paused-=b.delta,this.paused<0&&(this.paused=0)),this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-render",e),this.container){for(c=this.container.children.length-1;c>-1;c--)d=this.container.children[c],d.visible&&(d.paused&&!this.paused?d.paused=!1:this.paused&&(d.paused=!0));this.container.reorder&&(this.container.reorder=!1,this.container.children.sort(a))}}}(),"camera-update":function(a){this.camera.x=a.viewport.left,this.camera.y=a.viewport.top,this.moveMouse&&this.moveMouse()}},methods:{addInputs:function(){var a=function(a,b){return function(c){var d=c.data.global.x,e=c.data.global.y,f=c.data.originalEvent,g=0,h=0;a.container&&(g=d/a.container.transformMatrix.a+a.camera.x,h=e/a.container.transformMatrix.d+a.camera.y,c.target.mouseTarget=!0,a.owner.trigger(b,{event:f,cjsEvent:c,x:g,y:h,entity:a.owner}),a.cameraMovementMovesMouse&&("pressup"===b?(c.target.mouseTarget=!1,a.moveMouse=null,c.target.removeDisplayObject&&c.target.removeDisplayObject()):a.moveMouse=function(){a.owner.trigger("pressmove",{event:f,x:d/a.container.transformMatrix.a+a.camera.x,y:e/a.container.transformMatrix.d+a.camera.y,entity:a.owner})}))}};return function(){var b=this.container,c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=!1;this.click&&(b.interactive=!0,k=a(this,"mousedown"),c=function(a){k(a),l=!0}.bind(this),i=a(this,"pressmove"),f=function(a){l&&i(a)}.bind(this),j=a(this,"pressup"),g=function(a){j(a),l=!1}.bind(this),h=a(this,"click"),b.addListener("mousedown",c),b.addListener("touchstart",c),b.addListener("mouseup",g),b.addListener("touchend",g),b.addListener("mouseupoutside",g),b.addListener("touchendoutside",g),b.addListener("mousemove",f),b.addListener("touchmove",f),b.addListener("click",h),b.addListener("tap",h)),this.hover&&(b.interactive=!0,d=a(this,"mouseover"),e=a(this,"mouseout"),b.addListener("mouseover",d),b.addListener("mouseout",e)),this.removeInputListeners=function(){this.click&&(b.removeListener("mousedown",c),b.removeListener("touchstart",c),b.removeListener("mouseup",g),b.removeListener("touchend",g),b.removeListener("mouseupoutside",g),b.removeListener("touchendoutside",g),b.removeListener("mousemove",f),b.removeListener("touchmove",f),b.removeListener("click",h),b.removeListener("tap",h)),this.hover&&(b.removeListener("mouseover",d),b.removeListener("mouseout",e)),this.removeInputListeners=null}}}(),destroy:function(){var a=this;this.container.mouseTarget?(this.container.visible=!1,this.container.removeDisplayObject=function(){a.container=null}):this.container=null}},publicMethods:{}})}(),function(){"use strict";var a=function(a,b,c,d,e,f){var g=0,h=0,i=0,j=a.slice();if("horizontal"===f){for(h=e-1;h>=0;h--)for(g=h*d,i=0;(h+1)*d>g;g++,i++)j.splice((h+1)*b+i,0,c[g]);return j}return"vertical"===f?a.concat(c):void 0},b=function(a,b,c,d){var e=0,f=0,g=a.slice(),h=null;for(e=0;e0?this.piOverTwo:this.v[1]<0?-this.piOverTwo:this.angle:(c=Math.atan(this.v[1]/this.v[0]),this.v[0]<0&&(c=Math.PI+c)),this.v[0]>=0?this.v[0]=Math.min(this.v[0],this.maxVelocity*Math.cos(c)):this.v[0]=Math.max(this.v[0],this.maxVelocity*Math.cos(c)),this.v[1]>=0?this.v[1]=Math.min(this.v[1],this.maxVelocity*Math.sin(c)):this.v[1]=Math.max(this.v[1],this.maxVelocity*Math.sin(c)),this.owner.x+=this.v[0],this.owner.y+=this.v[1],this.owner.rotation=c*(180/Math.PI)+this.visualOffset)},"set-angle":function(a){this.angle=a},move:function(){this.moving=!0},stop:function(){this.moving=!1,this.v[0]=0,this.v[1]=0},"set-max-velocity":function(a){this.maxVelocity=a}}})}(),function(){"use strict";var a=0;return platypus.createComponentClass({id:"LogicAttachment",properties:{attachState:"attached",attachment:"",offsetX:0,offsetY:0,offsetZ:.01},publicProperties:{},constructor:function(b){this.state=this.owner.state,this.owner.linkId||(this.owner.linkId="attachment-link-"+a,a+=1),this.state[this.attachState]=!1,this.attachmentPosition={x:0,y:0,z:0,dx:0,dy:0,linkId:this.owner.linkId},this.attachmentProperties={type:this.attachment,properties:this.attachmentPosition},this.attachment=null,this.isAttached=!1},events:{"handle-logic":function(a){var b=0,c=this.state;this.isAttached?(this.attachment||(this.attachmentPosition.x=this.owner.x,this.attachmentPosition.y=this.owner.y,this.attachmentPosition.z=this.owner.z,this.attachment=this.owner.parent.addEntity(this.attachmentProperties)),this.attachment.destroyed?(this.owner.parent.removeEntity(this.attachment),this.attachment=null,this.isAttached=!1):(this.attachment.x=this.owner.x,b=this.offsetX,c.left?(b*=-1,this.attachment.rotation=180):c.right&&(this.attachment.rotation=0),this.attachment.x+=b,this.attachment.y=this.owner.y,b=this.offsetY,c.top?(b*=-1,this.attachment.rotation=90):c.bottom&&(this.attachment.rotation=-90),this.attachment.y+=b,this.attachment.z=this.owner.z,this.attachment.z+=this.offsetZ)):this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),c[this.attachState]!==this.isAttached&&(c[this.attachState]=this.isAttached)},attach:function(a){this.isAttached=!a||a.pressed!==!1},detach:function(){this.isAttached=!1}},methods:{destroy:function(){this.state[this.attachState]=!1,this.attachment&&(this.owner.parent.removeEntity(this.attachment),this.attachment=null),this.isAttached=!1}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicButton",constructor:function(a){this.state=this.owner.state,this.state.released=!0,this.state.pressed=!1,this.toggle=!!a.toggle,"pressed"===a.state&&(this.state.released=!1,this.state.pressed=!0)},events:{mousedown:function(){this.toggle||this.updateState("pressed")},pressup:function(){this.toggle?this.state.pressed?this.updateState("released"):this.updateState("pressed"):this.updateState("released")},"handle-logic":function(){}},methods:{updateState:function(a){this.state.released&&"pressed"===a?(this.state.pressed=!0,this.state.released=!1,this.owner.triggerEvent(a,this.state)):this.state.pressed&&"released"===a&&(this.state.pressed=!1,this.state.released=!0,this.owner.triggerEvent(a,this.state))}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCanvasButton",properties:{onPress:"",onRelease:"",onCancel:"",useOnce:!1,disabled:!1},publicProperties:{},constructor:function(a){this.owner.state.disabled=this.disabled,this.owner.state.down=!1,this.owner.buttonMode=!this.disabled,this.cancelled=!1,this.used=!1,this.last=null},events:{"handle-logic":function(a){this.last!==(this.disabled===this.owner.state.disabled)&&(this.last=this.disabled===this.owner.state.disabled)},mousedown:function(a){this.owner.state.down=!0,this.owner.state.disabled||this.useOnce&&this.used||this.onPress&&(this.owner.trigger(this.onPress),this.used=!0)},pressup:function(a){this.owner.state.disabled||this.useOnce&&this.used||(this.cancelled?this.onCancel&&(this.owner.trigger(this.onCancel),this.used=!0):this.onRelease&&(this.owner.trigger(this.onRelease),this.used=!0)),this.owner.state.down=!1,this.cancelled=!1},mouseover:function(){this.owner.state.down&&(this.cancelled=!1)},mouseout:function(){this.owner.state.down&&(this.cancelled=!0)},disable:function(){this.owner.state.disabled=!0,this.owner.buttonMode=!1},enable:function(){this.owner.state.disabled=!1,this.owner.buttonMode=!0},"toggle-disabled":function(){this.owner.buttonMode=this.owner.state.disabled,this.owner.state.disabled=!this.owner.state.disabled}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicCarrier",constructor:function(a){},events:{load:function(a){this.owner.trigger("add-collision-entity",this.owner)||(this.owner.addComponent(new platypus.components.CollisionGroup(this.owner,{})),this.owner.trigger("add-collision-entity",this.owner))},"carry-me":function(a){this.owner.trigger("add-collision-entity",a.entity)},"release-me":function(a){this.owner.trigger("remove-collision-entity",a.entity)}}})}(),function(){"use strict";var a=function(a){var b=function(a,b){return b&&!a.message?{event:a.event,message:b,delay:a.delay,repeat:a.repeat}:a};return a.singleInstance?function(c){var d=0,e=!0;for(d=0;d-1;b--)this.queue[b]===a&&(this.queueTimes.splice(b,1),this.queue.splice(b,1))}};return platypus.createComponentClass({id:"LogicDelayMessage",constructor:function(c){var d="";if(this.queueTimes=[],this.queue=[],c.events)for(d in c.events)c.events.hasOwnProperty(d)&&(this.addEventListener(d,a(c.events[d])),c.events[d].cancelEvent&&this.addEventListener(c.events[d].cancelEvent,b(c.events[d])))},events:{"handle-logic":function(a){var b=0;for(b=this.queue.length-1;b>-1;b--)this.queueTimes[b]-=a.delta,this.queueTimes[b]<=0&&(this.owner.trigger(this.queue[b].event,this.queue[b].message),this.queue[b]&&(this.queue[b].repeat?this.queueTimes[b]+=this.queue[b].delay:(this.queueTimes.splice(b,1),this.queue.splice(b,1))))}},methods:{destroy:function(){this.queueTimes.length=0,this.queue.length=0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDestroyMe",properties:{delay:0},publicProperties:{destroyed:!1},events:{"handle-logic":function(a){var b=a.delta;this.destroyed&&!this.owner.state.paused&&(this.delay-=b,this.delay<=0&&this.owner.parent.removeEntity(this.owner))},"destroy-me":function(){this.destroyed=!0}}})}(),function(){"use strict";var a=function(a){return function(b){this[a]="undefined"==typeof b||b&&b.pressed!==!1}},b=function(){},c={x:function(a,b){a!==b&&(a>180&&180>=b||180>=a&&b>180)&&this.owner.triggerEvent("transform","vertical")},y:function(a,b){a!==b&&(a>90&&270>=a&&(90>=b||b>270)||(90>=a||a>270)&&b>90&&270>=b)&&this.owner.triggerEvent("transform","horizontal")},z:function(a,b){a!==b&&this.owner.triggerEvent("replace-transform","rotate-"+a)}};return platypus.createComponentClass({id:"LogicDirectionalMovement",properties:{axis:"y",heading:0,speed:.3},constructor:function(a){var d=this;isNaN(this.speed)||(this.speed=[this.speed,0,0]),this.initialVector=new platypus.Vector(this.speed),this.reorient=c[this.axis],this.reorient||(this.reorient=b),this.owner.state.paused=!1,a.pause&&("string"==typeof a.pause?this.pausers=[a.pause]:this.pausers=a.pause,this.addEventListener("state-changed",function(b){var c=0,e=!1;if(a.pause){for(c=0;c0?this.mX=1:0>b&&(this.mX=this.flipX),this.owner.dy=0,c>0?this.mY=1:0>c&&(this.mY=this.flipY)),!0},"hit-solid":function(a){return this.stunned&&a.y>0&&(this.stunned=!1,this.owner.dx=0,this.owner.dy=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPacingPlatform",constructor:function(a){this.ang=this.owner.angle||a.angle||0,this.dist=this.owner.distance||a.distance||128,this.period=this.owner.period||a.period||4e3,this.time=0,this.startPos=this.owner.startPos||a.startPos||0,this.offset=0,this.originX=this.owner.x,this.originY=this.owner.y},events:{"handle-logic":function(a){var b=a.delta;this.time+=b,this.time>this.period&&(this.time=this.time%this.period),this.offset=this.time/this.period*2*Math.PI,this.owner.x=this.originX+Math.sin(this.offset+this.startPos)*this.dist*Math.cos(this.ang),this.owner.y=this.originY+Math.sin(this.offset+this.startPos)*this.dist*Math.sin(this.ang)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortable",constructor:function(a){this.portableDirections=a.portableDirections||{down:!0},this.carrier=this.lastCarrier=void 0,this.message={entity:this.owner}},events:{"handle-logic":function(a){this.carrierConnected?(this.carrier!==this.lastCarrier&&(this.lastCarrier&&this.lastCarrier.trigger("release-me",this.message),this.carrier.trigger("carry-me",this.message)),this.carrierConnected=!1):this.carrier&&(this.carrier.trigger("release-me",this.message),this.carrier=void 0),this.lastCarrier=this.carrier},"hit-solid":function(a){a.y>0?this.updateCarrier(a.entity,"down"):a.y<0?this.updateCarrier(a.entity,"up"):a.x<0?this.updateCarrier(a.entity,"left"):a.x>0&&this.updateCarrier(a.entity,"right")}},methods:{updateCarrier:function(a,b){this.portableDirections[b]&&a&&(a!==this.carrier&&(this.carrier=a),this.carrierConnected=!0)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicPortal",constructor:function(a){var b=0,c=a.entrants||a.entrant;if(this.destination=this.owner.destination||a.destination,this.used=!1,this.ready=!1,this.wasReady=!1,c)if(this.entrants={},Array.isArray(c))for(b=0;b0&&this.vY>0||a.y<0&&this.vY<0?this.vY=0:(a.x<0&&this.vX<0||a.x>0&&this.vX>0)&&(this.vX=0),!0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicRebounder",constructor:function(a){platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.owner.mass=this.owner.mass||a.mass||1,this.elasticity=a.elasticity||.8,this.v=new platypus.Vector(0,0,0),this.incidentVector=new platypus.Vector(0,0,0),this.staticCollisionOccurred=!1,this.nonStaticCollisionOccurred=!1,this.hitThisTick=[],this.otherV=new platypus.Vector(0,0,0),this.otherVelocityData=[]},events:{"handle-logic":function(a){this.hitThisTick=[],this.otherVelocityData.length=0},"hit-static":function(a){var b=0,c=a.entity,d=0;for(d=0;db;b++)for(c=0;e>c;c++)h=Math.min(f,this.owner.width-b*f),i=Math.min(g,this.owner.height-c*g),this.regions.push({x:b*f,y:c*g,width:h, +height:i});this.entityClass=platypus.game.settings.entities[a.spawn],this.interval=this.owner.interval||a.interval||1e3,this.time=0},events:{"handle-logic":function(a){var b=this.regions,c=null;this.time+=a.delta,this.time>this.interval&&(this.time-=this.interval,b?(b.length||(this.regions=this.usedRegions,this.usedRegions=b,b=this.regions),c=b[Math.floor(b.length*Math.random())],this.spawnPosition.x=this.owner.x-(this.owner.regX||0)+(c.x+Math.random()*c.width),this.spawnPosition.y=this.owner.y-(this.owner.regY||0)+(c.y+Math.random()*c.height)):(this.spawnPosition.x=this.owner.x-(this.owner.regX||0)+Math.random()*this.owner.width,this.spawnPosition.y=this.owner.y-(this.owner.regY||0)+Math.random()*this.owner.height),this.owner.triggerEvent("entity-created",this.owner.parent.addEntity(new platypus.Entity(this.entityClass,this.spawnProperties))))}}})}(),function(){"use strict";var a=Math.PI,b=Math.cos,c=Math.sin,d=function(a,c){return a*b(c)},e=function(a,b){return a*c(b)};return platypus.createComponentClass({id:"LogicRotationalMovement",constructor:function(b){this.speed=b.speed||.3,this.magnitude=0,this.degree=(b.degree||1)*a/180,this.angle=b.angle||0,this.state=this.owner.state,this.state.moving=!1,this.state.turningRight=!1,this.state.turningLeft=!1,this.owner.orientation=0,this.moving=!1,this.turningRight=!1,this.turningLeft=!1},events:{"handle-logic":function(a){var b=0,c=0;this.turningRight&&(this.angle+=this.degree*a.delta/15),this.turningLeft&&(this.angle-=this.degree*a.delta/15),this.moving&&(b=d(this.magnitude,this.angle),c=e(this.magnitude,this.angle)),this.owner.x+=b*a.delta,this.owner.y+=c*a.delta,this.state.moving!==this.moving&&(this.state.moving=this.moving),this.state.turningLeft!==this.turningLeft&&(this.state.turningLeft=this.turningLeft),this.state.turningRight!==this.turningRight&&(this.state.turningRight=this.turningRight),this.owner.orientation!==this.angle&&(this.owner.orientation=this.angle)},"turn-right":function(a){a?this.turningRight=a.pressed:this.turningRight=!0},"turn-left":function(a){a?this.turningLeft=a.pressed:this.turningLeft=!0},"go-forward":function(a){!a||a.pressed?(this.moving=!0,this.magnitude=this.speed):this.moving=!1},"go-backward":function(a){!a||a.pressed?(this.moving=!0,this.magnitude=-this.speed):this.moving=!1},stop:function(a){(!a||a.pressed)&&(this.moving=!1,this.turningLeft=!1,this.turningRight=!1)},"stop-moving":function(a){(!a||a.pressed)&&(this.moving=!1)},"stop-turning":function(a){(!a||a.pressed)&&(this.turningLeft=!1,this.turningRight=!1)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicSpawner",constructor:function(a){var b=this.owner.spawneeClass||a.spawneeClass,c="",d=0;if(this.state=this.owner.state,this.stateName=a.state||"spawning",this.entityClass=platypus.game.settings.entities[b],this.speed=a.speed||this.owner.speed||0,this.state[this.stateName]=!1,this.spawneeProperties={x:0,y:0,z:0,dx:0,dy:0,spawner:this.owner},a.passOnProperties)for(d=0;d-1;b--)this.queueTimes[b]-=a.delta,this.queueTimes[b]<=0&&(this.owner.trigger(this.queue[b].event,this.queue[b].message),this.queueTimes.splice(b,1),this.queue.splice(b,1))},"update-state":function(a){var b="";for(b in a)a.hasOwnProperty(b)&&(this.state[b]=a[b])},"state-changed":function(a){var b=null;if(this.outputs){for(b in a)a[b]!==this.snapshot[b]&&(this.snapshot[b]=a[b]);for(this.tempQueue.length=0,d("outputs",this.snapshot,this.last,this.outputs,!1,this.owner,this.tempQueue),b=0;b0&&a.entity.trigger("teleport",this.destination);break;case"down":a.y>0&&a.entity.trigger("teleport",this.destination);break;case"left":a.x<0&&a.entity.trigger("teleport",this.destination);break;default:a.entity.trigger("teleport",this.destination)}}},methods:{destroy:function(){this.destination=void 0}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicTimer",constructor:function(a){this.time=this.owner.time||a.time||0,this.prevTime=this.time,this.alarmTime=this.owner.alarmTime||a.alarmTime||void 0,this.isInterval=this.owner.isInterval||a.isInterval||!1,this.alarmMessage=this.owner.alarmMessage||a.alarmMessage||"",this.updateMessage=this.owner.updateMessage||a.updateMessage||"",this.isOn=this.owner.on||a.on||!0,this.isIncrementing=this.owner.isIncrementing||a.isIncrementing||!0,this.maxTime=this.owner.maxTime||a.maxTime||36e5},events:{"handle-logic":function(a){this.isOn&&(this.prevTime=this.time,this.isIncrementing?this.time+=a.delta:this.time-=a.delta,Math.abs(this.time)>this.maxTime&&(this.time>0?this.time=this.maxTime:this.time<0&&(this.time=-this.maxTime),this["stop-timer"]()),"undefined"!=typeof this.alarmTime&&(this.isInterval?this.isIncrementing?Math.floor(this.time/this.alarmTime)>Math.floor(this.prevTime/this.alarmTime)&&this.owner.trigger(this.alarmMessage):Math.floor(this.time/this.alarmTime)this.alarmTime&&this.prevTimethis.alarmTime&&this.owner.trigger(this.alarmMessage))),this.owner.trigger(this.updateMessage,{time:this.time})},"set-timer":function(a){this.time=a.time},"start-timer":function(){this.isOn=!0},"stop-timer":function(){this.isOn=!1}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicWindUpRacer",constructor:function(a){this.windTime=a.windTime||500,this.raceTime=a.raceTime||5e3,this.speed=a.speed||this.owner.speed||.3,this.windProgress=0,this.winding=!1,this.racing=!1,this.blocked=!1,this.right=!1,this.left=!1,this.state=this.owner.state,this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1},events:{"handle-logic":function(a){this.racing?!this.blocked&&this.right&&this.state.right?(this.owner.x+=this.speed,this.owner.trigger("racing")):!this.blocked&&this.left&&this.state.left?(this.owner.x-=this.speed,this.owner.trigger("racing")):(this.racing=!1,this.owner.trigger("stopped-racing")):this.winding?((this.right&&this.state.right||this.left&&this.state.left)&&(this.windProgress+=a.delta),this.owner.trigger("winding")):this.windProgress&&(this.windProgress>this.windTime&&(this.racing=!0),this.windProgress=0,this.owner.trigger("stopped-winding")),this.state.windingUp!==this.winding&&(this.state.windingUp=this.winding),this.state.racing!==this.racing&&(this.state.racing=this.racing),this.state.blocked!==this.blocked&&(this.state.blocked=this.blocked),this.blocked=!1},"stop-racing":function(a){this.racing=!1,this.owner.trigger("stopped-racing")},"wind-up":function(a){this.winding=!a||a.pressed!==!1,this.right=this.state.right,this.left=this.state.left},"hit-solid":function(a){a.x&&this.racing&&(this.right&&a.x>0||this.left&&a.x<0)&&(this.blocked=!0,this.owner.trigger("blocked",a))}},methods:{destroy:function(){this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1}}})}(),function(){"use strict";var a=new platypus.Vector,b=function(a){return function(b,c,d,e){this.accelerator?this.resultant=b:this.resultant=c,this.update=a,this.update(b,c,d,e)}},c=function(){return!0},d=function(a,d){var e=a.active,f=!0,g=!0,h=c,i=c,j=a.owner.state,k=d.controlState,l=d.instantState,m=d.instantSuccess;k&&(h=function(){return j[k]}),d.event&&a.addEventListener(d.event,function(a){e=a&&a.pressed!==!1}),d.instantEvent||l||d.instantBegin||d.instantEnd?(l&&(i=function(){return j[l]}),(d.instantEvent||d.instantBegin||d.instantEnd)&&(f=!1,d.instantEvent&&a.addEventListener(d.instantEvent,function(a){f=a&&a.pressed!==!1}),d.instantBegin&&a.addEventListener(d.instantBegin,function(){f=!0}),d.instantEnd&&a.addEventListener(d.instantEnd,function(){f=!1})),a.update=b(function(a,b,c,d){var j=i();this.active=e&&h(),g&&f&&this.active&&j?(g=!1,this.move(1),m&&this.owner.triggerEvent(m)):g||f&&j||(g=!0,this.decay())})):a.update=b(function(a,b,c,d){this.active=e&&h(),this.active&&this.move(c)})};return platypus.createComponentClass({id:"Motion",properties:{orient:!0,accelerator:!1,active:!0,maxMagnitude:1/0,event:"",controlState:"",instantEvent:"",instantBegin:"",instantEnd:"",instantState:"",instantSuccess:"",instantDecay:null,vector:0},constructor:function(a){this.vector=new platypus.Vector(this.vector),this.triggered=!1,isNaN(this.instantDecay)?this.capMagnitude=-1:this.capMagnitude=this.vector.magnitude()*this.instantDecay,d(this,a),this.orient&&this.owner.triggerEvent("orient-vector",this.vector)},events:{"set-vector":function(a){this.vector.set(a),isNaN(this.instantDecay)?this.capMagnitude=-1:this.capMagnitude=this.vector.magnitude()*this.instantDecay}},methods:{move:function(b){this.vector.magnitude()>this.maxMagnitude&&this.vector.normalize().multiply(this.maxMagnitude),this.resultant.add(a.set(this.vector).multiply(b))},decay:function(){var b=null;this.capMagnitude>=0&&(b=a.set(this.resultant).scalarProjection(this.vector),b>this.capMagnitude&&this.resultant.subtractVector(a.set(this.vector).normalize().scale(b-this.capMagnitude)))},destroy:function(){this.orient&&this.owner.triggerEvent("remove-vector",this.vector)}},publicMethods:{}})}(),function(){"use strict";var a=new platypus.Vector;return platypus.createComponentClass({id:"Mover",properties:{ground:[0,1]},publicProperties:{movers:[],gravity:0,jump:0,speed:0,drag:.99,friction:.94,maxMagnitude:1/0},constructor:function(a){platypus.Vector.assign(this.owner,"position","x","y","z"),platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.position=this.owner.position,this.velocity=this.owner.velocity,this.moversCopy=this.movers,this.movers=[],this.ground=new platypus.Vector(this.ground)},events:{"component-added":function(a){"Motion"===a.type&&this.movers.push(a)},"component-removed":function(a){var b=0;if("Motion"===a.type)for(b=0;bthis.maxMagnitude&&f.normalize().multiply(this.maxMagnitude),e.set(f).multiply(d),g.add(e),this.grounded!==this.owner.state.grounded&&(this.owner.state.grounded=this.grounded),this.grounded=!1}},"hit-solid":function(b){var c=this.velocity.scalarProjection(b.direction),d=a;b.direction.dot(this.ground)>0&&(this.grounded=!0),d.set(b.direction).normalize().multiply(c).dot(this.velocity)>0&&this.velocity.subtractVector(d)}},methods:{destroy:function(){var a=0;for(a=this.movers.length-1;a>=0;a--)this.removeMover(this.movers[a])}},publicMethods:{addMover:function(a){var b=this.owner.addComponent(new platypus.components.Motion(this.owner,a));return b},removeMover:function(a){this.owner.removeComponent(a)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"Node",publicProperties:{x:0,y:0,z:0},constructor:function(a){this.nodeId=a.nodeId||this.owner.nodeId||this.owner.id||String(Math.random()),"string"!=typeof this.nodeId&&this.nodeId.length&&(this.nodeId=a.nodeId.join("|")),this.owner.nodeId=this.nodeId,this.owner.isNode=!0,this.map=this.owner.map=this.owner.map||null,this.contains=this.owner.contains=[],this.edgesContain=this.owner.edgesContain=[],platypus.Vector.assign(this.owner,"position","x","y","z"),this.neighbors=this.owner.neighbors=a.neighbors||this.owner.neighbors||{}},events:{"add-neighbors":function(a){var b=0,c=null;for(c in a)a.hasOwnProperty(c)&&(this.neighbors[c]=a[c]);for(b=0;b=0;c--)d=this.residentsAwaitingNode[c],e.id===d.nodeId&&(this.residentsAwaitingNode.splice(c,1),d.node=this.getNode(d.nodeId),d.triggerEvent("on-node",d.node))},"child-entity-added":function(a){a.isNode?this.owner.triggerEvent("add-node",a):a.nodeId&&(a.node=this.getNode(a.nodeId),a.node?a.triggerEvent("on-node",a.node):this.residentsAwaitingNode.push(a))}},publicMethods:{addNode:function(a){this.map.push(a),this.nodes[a.id]=a},getNode:function(){var a=0,b="",c="",d=arguments;if(1===d.length){if(d[0].isNode)return d[0];Array.isArray(d[0])&&(d=d[0])}for(a=0;aj){if(e){for(m=!1,g=0;gf&&(g=2*Math.PI-g),180*g/Math.PI):g},d=function(a,b,c,d){return b*(1-a)+c*a+d},e=function(a,b){var c=0,d=0,e=!1;if(null===b)return!0;for(;c=this.distance?(g=this.destinationNodes[0],f-=this.distance-this.progress,this.progress=0,this.destinationNodes.splice(0,1),this.owner.triggerEvent("on-node",g),this.destinationNodes.length&&f&&this.onEdge(this.destinationNodes[0])):(this.progress+=f,e=this.progress/this.distance,this.owner.x=d(e,this.lastNode.x,this.destinationNodes[0].x,this.offset.x),this.owner.y=d(e,this.lastNode.y,this.destinationNodes[0].y,this.offset.y),this.owner.z=d(e,this.lastNode.z,this.destinationNodes[0].z,this.offset.z),this.updateOrientation&&(this.owner.rotation=c(this.lastNode,this.destinationNodes[0],this.distanc,e)),f=0)}else this.state.moving=!1},"on-node":function(a){var b=0,c=null;for(this.owner.node=this.node=a,this.node.removeFromEdge(this.owner),this.lastNode&&this.lastNode.removeFromEdge(this.owner),this.node.addToNode(this.owner),this.setState("on-node"),this.owner.x=this.node.x+this.offset.x,this.owner.y=this.node.y+this.offset.y,this.owner.z=this.node.z+this.offset.z,this.updateOrientation&&this.node.rotation&&(this.owner.rotation=this.node.rotation),this.owner.triggerEvent("set-directions"),this.friendlyNodes&&this.friendlyNodes[a.type]&&this.owner.trigger(this.friendlyNodes[a.type],a),c=a.contains,b=0;bthis.followDistance)return this.lag=e.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(e,i);this.lag=0}else if(e.blocked)return this.blocked=!0,!1;return!1}}(),"set-directions":function(){var b="",c=0,d=null,e=this.node,f=null;this.owner.triggerEvent("remove-directions");for(b in e.neighbors)if(this.neighbors[b]=a(e.neighbors[b],e.map,b),this.addEventListener(b,this.neighbors[b]),f=e.map.getNode(e.neighbors[b]))for(d=f.contains,c=0;cthis.followDistance)return this.lag=c.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(c);this.lag=0}else if(c.blocked)return this.blocked=!0,!1;return!1}}(),isPassable:function(a){return!(!a||this.node===a||this.friendlyNodes&&"undefined"==typeof this.friendlyNodes[a.type]||a.contains.length&&!e(a.contains,this.friendlyEntities))},traverseNode:function(a){var c=1,d="",e=a.position.map,f=null,g=null,h=null,i=null,j=a.algorithm||b,k={shortestPath:1/0,found:!1,blocked:!1},l=!0,m=!1;if(0===a.depth||a.distance>a.shortestPath)return a;if(a.test(a.position,a.destination))return a.found=!0,a.shortestPath=a.distance,a;for(h=a.nodes;ci.shortestPath&&(k=i),l=!1);return k.blocked=m&&l,k},setPath:function(a,b){a.nodes[0]===this.node&&a.nodes.splice(0,1),this.destinationNodes=a.nodes,b&&(this.destinationNodes.length=Math.min(b,this.destinationNodes.length))},setState:function(a){"on-node"===a?this.state["on-node"]=!0:(this.state["on-node"]=!1,this.currentState&&(this.state[this.currentState]=!1),this.currentState=a,this.state[a]=!0)},onEdge:function(a){this.distance=b(this.node,a),this.updateOrientation&&(this.owner.rotation=c(this.node,a,this.distance,this.progress/this.distance)),this.node.addToEdge(this.owner),a.addToEdge(this.owner),this.owner.triggerEvent("leave-node")}}})}(),function(){"use strict";var a={horizontal:[[-1,0,0],[0,1,0],[0,0,-1]],vertical:[[1,0,0],[0,-1,0],[0,0,-1]],diagonal:[[0,1,0],[1,0,0],[0,0,-1]],"diagonal-inverse":[[0,-1,0],[-1,0,0],[0,0,-1]],"rotate-90":[[0,-1,0],[1,0,0],[0,0,1]],"rotate-180":[[-1,0,0],[0,-1,0],[0,0,1]],"rotate-270":[[0,1,0],[-1,0,0],[0,0,1]]},b=function(){var a=function(a,b,c){var d=0,e=0;for(d=0;db;b++)for(c=0;3>c;c++)b===c?a[b][c]=1:a[b][c]=0;return a};return platypus.createComponentClass({id:"Orientation",publicProperties:{scaleX:1,scaleY:1,rotation:0,orientation:0,orientationMatrix:null},constructor:function(){var a=function(a,d){var e=new platypus.Vector([0,0,1]),f=new platypus.Vector([1,0,0]),g=new platypus.Vector([1,0,0]),h=a.owner,i=[[1,0,0],[0,1,0],[0,0,1]];return Object.defineProperty(h,"orientationMatrix",{get:function(){return b(a.matrixTween,a.matrix,c(i)),i},enumerable:!0}),delete h.orientation,Object.defineProperty(h,"orientation",{get:function(){return g.signedAngleTo(f,e)},set:function(a){g.set(f).rotate(a)},enumerable:!0}),d&&(isNaN(d)?g.set(d):g.rotate(d)),g};return function(b){this.loadedOrientationMatrix=this.orientationMatrix,this.matrix=[[1,0,0],[0,1,0],[0,0,1]],this.matrixTween=[[1,0,0],[0,1,0],[0,0,1]],this.vectors=[],this.inverses=[],this.tweens=[],this.owner.triggerEvent("orient-vector",a(this,this.orientation))}}(),events:{load:function(){this.loadedOrientationMatrix?this.transform(this.loadedOrientationMatrix):(this.scaleX&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.transform("horizontal")),this.scaleY&&this.scaleY<0&&(this.scaleY=-this.scaleY,this.transform("vertical")),this.rotation&&((this.rotation+270)%360===0?(this.rotation=0,this.transform("rotate-90")):(this.rotation+180)%360===0?(this.rotation=0,this.transform("rotate-180")):(this.rotation+90)%360===0&&(this.rotation=0,this.transform("rotate-270")))),delete this.loadedOrientationMatrix},"handle-logic":function(a){var b=0,d=a.delta,e=this.owner.state,f=[];if(this.tweens.length){for(e.reorienting=!0,c(this.matrixTween),b=this.tweens.length-1;b>=0;b--)this.updateTween(this.tweens[b],d)&&f.push(this.tweens.splice(b,1)[0]);for(b=0;bb;b++)c+=a[b][0]*a[(b+1)%3][1]*a[(b+2)%3][2],c-=a[b][2]*a[(b+1)%3][1]*a[(b+2)%3][0];return c},c=function(c){var d=[[],[],[]],e=1/b(c);return d[0].push(a(c[1][1],c[1][2],c[2][1],c[2][2])*e),d[0].push(a(c[0][2],c[0][1],c[2][2],c[2][1])*e),d[0].push(a(c[0][1],c[0][2],c[1][1],c[1][2])*e),d[1].push(a(c[1][2],c[1][0],c[2][2],c[2][0])*e),d[1].push(a(c[0][0],c[0][2],c[2][0],c[2][2])*e),d[1].push(a(c[0][2],c[0][0],c[1][2],c[1][0])*e),d[2].push(a(c[1][0],c[1][1],c[2][0],c[2][1])*e),d[2].push(a(c[0][1],c[0][0],c[2][1],c[2][0])*e),d[2].push(a(c[0][0],c[0][1],c[1][0],c[1][1])*e),d};return function(a){this.multiply(c(this.matrix)),this.multiply(a)}}(),updateTween:function(){var a=function(a,b,c){return a*(1-c)+b*c};return function(c,d){var e=0,f=1,g=0,h=0,i=1,j=1,k=0,l=c.endMatrix,m=null;return c.time+=d,c.time>=c.endTime?!0:(e=c.tween(c.time/c.endTime),c.angle?(k=e*c.angle,f=i=Math.cos(k),g=Math.sin(k),h=-g):(f=a(f,l[0][0],e),g=a(g,l[1][0],e),h=a(h,l[0][1],e),i=a(i,l[1][1],e),j=a(j,l[2][2],e)),m=[[f,h,0],[g,i,0],[0,0,j]],b(m,this.matrixTween,this.matrixTween),void c.onTick(e,m))}}(),updateVector:function(a,b){b.set(a.add(b)),a.multiply(this.matrixTween),b.subtractVector(a)},destroy:function(){}},publicMethods:{}})}(),function(){"use strict";var a=function(a){return function(b,c){this.owner.trigger(a[Math.floor(Math.random()*a.length)],b,c)}};return platypus.createComponentClass({id:"RandomEvents",constructor:function(b){var c="";if(b.events)for(c in b.events)b.events.hasOwnProperty(c)&&this.addEventListener(c,a(b.events[c]))}})}(),function(){"use strict";var a=function(a,b,c,d){var e=0;for(e=0;e=-1?(this.currentAnimation=a,this.lastState=-1,this.animationFinished=!1,this.sprite.gotoAndPlay(a)):(this.waitingAnimation=a,this.waitingState=-1)}},d=function(a,b){var c=0,d=a.replace(/ /g,"").split(",");return"default"===a?function(a){return b}:function(a){for(c=0;cthis.camera.right||a.y+a.heightthis.camera.bottom)?this.isOnCamera=!1:this.isOnCamera=!0},addStage:function(a){return a&&!this.pinTo?(this.parentContainer=a,this.parentContainer.addChild(this.container),this.mask&&this.setMask(this.mask),this.addInputs(),a):null},updateSprite:function(){var a=function(a,b){return a.z-b.z};return function(b){var c=0,d=0,e=0,f=null,g=0,h=!1,i=1,j=1,k=null,l=this.affine.copy(this.container.transformMatrix),m=PIXI.Matrix.TEMP_MATRIX;if(this.buttonMode!==this.container.buttonMode&&(this.container.buttonMode=this.buttonMode),this.pinnedTo?this.pinnedTo.frames&&this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame]?(d=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].x,e=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].y,this.container.z!==this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].z&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].z),g=this.pinnedTo.frames[this.pinnedTo.sprite.currentFrame].angle||0,this.visible=!0):this.pinnedTo.defaultPin?(d=this.pinnedTo.defaultPin.x,e=this.pinnedTo.defaultPin.y,this.container.z!==this.pinnedTo.defaultPin.z&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.pinnedTo.defaultPin.z),g=this.pinnedTo.defaultPin.angle||0,this.visible=!0):this.visible=!1:(d=this.owner.x,e=this.owner.y,this.rotate&&(g=this.rotation),this.container.z!==this.owner.z+this.offsetZ&&(this.parentContainer&&(this.parentContainer.reorder=!0),this.container.z=this.owner.z+this.offsetZ),this.ignoreOpacity||!this.owner.opacity&&0!==this.owner.opacity||(this.container.alpha=this.owner.opacity)),this.container.reorder&&(this.container.reorder=!1,this.container.children.sort(a)),(this.mirror||this.flip)&&(k=this.rotation%360,this.mirror&&k>90&&270>k&&(i=-1),this.flip&&180>k&&(j=-1)),this.stateBased&&this.stateChange){if(void 0!==this.state.visible&&(this.visible=this.state.visible),this.checkStates)for(c=0;c=+c)?(this.currentAnimation=h,this.lastState=+c,this.animationFinished=!1,b?this.sprite.gotoAndPlay(h):this.sprite.gotoAndStop(h)):(this.waitingAnimation=h,this.waitingState=+c):this.waitingAnimation&&!this.followThroughs[this.currentAnimation]&&(this.waitingAnimation=!1);break}this.stateChange=!1}g&&l.rotate(g/180*Math.PI),this.pinnedTo?(m.tx=d,m.ty=e,m.a=i,m.b=0,m.c=0,m.d=j,l.prepend(m)):(this.owner.orientationMatrix&&(f=this.owner.orientationMatrix,m.tx=f[0][2],m.ty=f[1][2],m.a=f[0][0],m.b=f[1][0],m.c=f[0][1],m.d=f[1][1],l.prepend(m)),m.tx=d,m.ty=e,m.a=this.scaleX*i,m.b=this.owner.skewX,m.c=this.owner.skewY,m.d=this.scaleY*j,l.prepend(m)),this.sprite&&(!this.wasVisible&&this.visible||this.lastX!==this.owner.x||this.lastY!==this.owner.y)&&this.checkCameraBounds(),this.lastX=this.owner.x,this.lastY=this.owner.y,this.wasVisible=this.visible,this.container.visible=this.visible&&this.isOnCamera}}(),triggerInput:function(a,b){this.container&&this.owner.trigger(b,{event:a.data.originalEvent,pixiEvent:a,x:a.data.global.x/this.parentContainer.transformMatrix.a+this.camera.left,y:a.data.global.y/this.parentContainer.transformMatrix.d+this.camera.top,entity:this.owner})},addInputs:function(){var a=!1,b=this.container,c=null,d=null,e=null,f=null,g=null,h=null;this.click&&(b.interactive=!0,c=function(b){this.triggerInput(b,"mousedown"),b.target.mouseTarget=!0,a=!0}.bind(this),f=function(b){a?(this.triggerInput(b,"pressmove"),b.target.mouseTarget=!0):this.triggerInput(b,"mousemove")}.bind(this),g=function(b){this.triggerInput(b,"pressup"),b.target.mouseTarget=!1,a=!1,b.target.removeDisplayObject&&b.target.removeDisplayObject()}.bind(this),h=function(a){this.triggerInput(a,"click")}.bind(this),b.addListener("mousedown",c),b.addListener("touchstart",c),b.addListener("mouseup",g),b.addListener("touchend",g),b.addListener("mouseupoutside",g),b.addListener("touchendoutside",g),b.addListener("mousemove",f),b.addListener("touchmove",f),b.addListener("click",h),b.addListener("tap",h)),this.hover&&(b.interactive=!0,d=function(a){this.triggerInput(a,"mouseover")}.bind(this),e=function(a){this.triggerInput(a,"mouseout")}.bind(this),b.addListener("mouseover",d),b.addListener("mouseout",e)),this.removeInputListeners=function(){this.click&&(b.removeListener("mousedown",c),b.removeListener("touchstart",c),b.removeListener("mouseup",g),b.removeListener("touchend",g),b.removeListener("mouseupoutside",g),b.removeListener("touchendoutside",g),b.removeListener("mousemove",f),b.removeListener("touchmove",f),b.removeListener("click",h),b.removeListener("tap",h)),this.hover&&(b.removeListener("mouseover",d),b.removeListener("mouseout",e)),b.interactive=!1,this.removeInputListeners=null}},addPins:function(a,b){var c=0,d=0,e=null,f=b.regX||0,g=b.regY||0,h=Array.isArray(b);for(this.pinsToRemove=this.pinsToRemove||[],this.pins={},c=0;cb;)b*=2;return b},n=function(a,b){var c=+a.substring(4),d=0;return 2147483648&c&&(b.scale.x=-1),1073741824&c&&(b.scale.y=-1),536870912&c&&(d=b.scale.x,b.scale.x=b.scale.y,b.scale.y=-d,b.rotation=Math.PI/2),268435455&c},o=function(a){this.instances=[a],this.index=0,a.template=this},p={getNext:j,destroy:j},q=o.prototype;return q.getNext=function(){var a=this.instances[this.index],b=null;return a||(b=this.instances[0],a=this.instances[this.index]=new i(b.texture),a.scale=b.scale,a.rotation=b.rotation,a.anchor=b.anchor),this.index+=1,a},q.clear=function(){this.index=0},q.destroy=function(){var a=0;for(a=0;a1||this.renderer instanceof d?new e:new g(15e3,{position:!0,rotation:!0,scale:!0}),this.mapContainer=new e,this.mapContainer.addChild(this.tileContainer),this.reorderedStage=!1,this.updateCache=!1,this.imageMap=[],this.addImageMap(f),this.tilesWidth=this.imageMap[0].length,this.tilesHeight=this.imageMap[0][0].length,this.layerWidth=this.tilesWidth*this.tileWidth,this.layerHeight=this.tilesHeight*this.tileHeight,this.cacheWidth=Math.min(m(this.layerWidth),this.maximumBuffer),this.cacheHeight=Math.min(m(this.layerHeight),this.maximumBuffer),this.tileCache||(this.buffer=0,this.cacheAll=!1)},events:{"handle-render-load":function(a){var b=this.owner.z,c=this.renderer,d=null;a&&a.container&&(d=this.parentContainer=a.container,d&&!this.reorderedStage&&(d.reorder=!0,this.reorderedStage=!0),this.updateRegion(),this.tileCache?(this.render=this.renderCache,this.mapContainerWrapper=new e,this.mapContainerWrapper.addChild(this.mapContainer),this.layerWidth<=this.cacheWidth&&this.layerHeight<=this.cacheHeight?(this.cacheAll=!0,this.cacheTexture=new h(c,this.cacheWidth,this.cacheHeight),this.tilesSprite=new i(this.cacheTexture),this.tilesSprite.scaleX=this.scaleX,this.tilesSprite.scaleY=this.scaleY,this.tilesSprite.z=b,this.cache.setBounds(0,0,this.tilesWidth-1,this.tilesHeight-1),this.update(this.cacheTexture,this.cache),d.addChild(this.tilesSprite)):this.cacheAll||this.layerWidth<=2*this.cacheWidth&&this.layerHeight<=this.cacheHeight||this.layerWidth<=this.cacheWidth&&this.layerHeight<=2*this.cacheHeight?(this.cacheAll=!0,this.cacheGrid=[],this.createGrid=function(){var a=0,b=0,e=0,f=0,g=this.owner.z,j=null,k=null;for(e=0;e0&&(n&&this.updateBufferRegion(p),f=this.cacheTilesWidth-1,g=this.cacheTilesHeight-1,h=f/2,i=g/2,o.setAll(Math.round(p.x/this.tileWidth-h)+h,Math.round(p.y/this.tileHeight-i)+i,f,g),o.left<0?o.moveX(o.halfWidth):o.right>this.tilesWidth-1&&o.moveX(this.tilesWidth-1-o.halfWidth),o.top<0?o.moveY(o.halfHeight):o.bottom>this.tilesHeight-1&&o.moveY(this.tilesHeight-1-o.halfHeight),this.tileCache?(j.empty||!o.contains(j))&&(this.tilesSpriteCache.texture=this.cacheTexture,this.cacheTexture=this.cacheTexture.alternate,this.tilesSprite.texture=this.cacheTexture,this.update(this.cacheTexture,o,this.tilesSpriteCache,j)):this.update(null,o),l.set(j).setAll((l.x+.5)*this.tileWidth,(l.y+.5)*this.tileHeight,(l.width+1)*this.tileWidth,(l.height+1)*this.tileHeight)),this.cacheGrid)for(b=0;bb;b++)for(this.doMap[b]||(this.doMap[b]=[]),c=f;g>c;c++)this.doMap[b][c]||(this.doMap[b][c]=[]),this.doMap[b][c].push(d);a.removeComponent("RenderSprite"),this.updateCache=!0}},convertCamera:function(a){var b=this.worldWidth/this.scaleX,c=b-a.width,d=this.worldHeight/this.scaleY,e=d-a.height,f=this.laxCam;return b!==this.layerWidth&&c?f.moveX(a.left*(this.layerWidth-a.width)/c+a.halfWidth):f.moveX(a.x),d!==this.layerHeight&&e?f.moveY(a.top*(this.layerHeight-a.height)/e+a.halfHeight):f.moveY(a.y),(a.width!==f.width||a.height!==f.height)&&f.resize(a.width,a.height),f},createTile:function(a){var c=null,d="";return"tile-1"===a?p:(c=new b(this.spriteSheet),d="tile"+n(a,c),c.gotoAndStop(d),new o(c))},addImageMap:function(a){var b=0,c=0,d="",e=[],f=this.tiles,g=null;for(b=0;bb.bottom||db.right||cb.bottom||db.right||cb;b++)e.data.push(1);return platypus.assets&&platypus.assets[a.name]&&platypus.assets[a.name].asset?(e.image=a.name,e.tileheight=platypus.assets[a.name].asset.height,e.tilewidth=platypus.assets[a.name].asset.width):g.assetCache.read(a.name)?(e.image=a.name,e.tileheight=g.assetCache.read(a.name).height,e.tilewidth=g.assetCache.read(a.name).width):(console.warn('Component TiledLoader: Cannot find the "'+a.name+'" sprite sheet. Add it to the list of assets in config.json and give it the id "'+a.name+'".'),e.image=a.image),e},O=function(a,c){var d=c.width,l=c.height,m=c.tileheight||k,n=c.tilewidth||j,o=0,p=0,q=0,r=null,s=null,t=null,u=null,v=!1,w=null,x=null,y=0,z=0,A=0,B="",C=c.data;if(c.properties&&(c.properties.width&&(o=parseInt(c.properties.width,10)),c.properties.height&&(p=parseInt(c.properties.height,10)),o||p)){for(o=o||d,p=p||l,C=[],z=0;o>z;z++)for(A=0;p>A;A++)d>z&&l>A?C[z+A*o]=c.data[z+A*d]:C[z+A*o]=0;d=o,l=p}if(r=JSON.parse(JSON.stringify(platypus.game.settings.entities[a]||e[a])),s={},t=[],u=[],"collision-layer"===a)for(x=[],z=0;zz;z++)s["tile"+z]=z;for(z=0;d>z;z++)for(t[z]=[],u[z]=[],A=0;l>A;A++)y=+C[z+A*d]-1,u[z][A]="tile"+y,x&&x.length&&x[0]===(268435455&y)&&(y=b(y)),t[z][A]=y;for(z=0;zA);o++)G=i[o];if(z="",""!==v.type?z=v.type:""!==v.name?z=v.name:G.tileproperties[A-G.firstgid]&&(G.tileproperties[A-G.firstgid].entity?z=G.tileproperties[A-G.firstgid].entity:G.tileproperties[A-G.firstgid].type&&(z=G.tileproperties[A-G.firstgid].type)),""!==z){if(H={},F?(H.scaleX=F.x,H.scaleY=F.y):(H.scaleX=1,H.scaleY=1),A>=0&&G.tileproperties&&G.tileproperties[A-G.firstgid])for(n in G.tileproperties[A-G.firstgid])G.tileproperties[A-G.firstgid].hasOwnProperty(n)&&(J=parseFloat(G.tileproperties[A-G.firstgid][n]),0===J||J?H[n]=J:"true"===G.tileproperties[A-G.firstgid][n]?H[n]=!0:"false"===G.tileproperties[A-G.firstgid][n]?H[n]=!1:H[n]=G.tileproperties[A-G.firstgid][n]);for(n in v.properties)if(v.properties.hasOwnProperty(n))if(y=v.properties[n],"string"==typeof y)if(J=parseFloat(y),0===J||J)H[n]=J;else if("true"===y)H[n]=!0;else if("false"===y)H[n]=!1;else if(y.length>2&&("{"===y[0]&&"}"===y[y.length-1]||"["===y[0]&&"]"===y[y.length-1]))try{H[n]=JSON.parse(y)}catch(P){H[n]=y}else H[n]=y;else H[n]=y;if(v.polygon||v.polyline){for(B=1/0,C=-(1/0),D=1/0,E=-(1/0),K=null,v.polygon?K=v.polygon:v.polyline&&(K=v.polyline),o=0;oC&&(C=K[o].x),K[o].xE&&(E=K[o].y),K[o].y= 0; i--) { entity = this.residentsAwaitingNode[i]; @@ -187,6 +188,11 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on }, publicMethods: { + addNode: function (node) { + this.map.push(node); + this.nodes[node.id] = node; + }, + getNode: function () { var i = 0, id = '', @@ -205,12 +211,8 @@ This component sets up a NodeMap to be used by the [[NodeResident]] component on id += divider + args[i]; divider = '|'; } - for (i = 0; i < this.map.length; i++) { - if (this.map[i].id === id) { - return this.map[i]; - } - } - return null; + + return this.nodes[id] || null; }, /**