diff --git a/bower.json b/bower.json index fd9f36ea..2a5bcd20 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "Platypus", - "version": "0.7.3", + "version": "0.7.4", "homepage": "https://github.com/PBS-KIDS/Platypus", "authors": [ "probityrules", diff --git a/build/package.json b/build/package.json index bf7ada51..390338db 100644 --- a/build/package.json +++ b/build/package.json @@ -1,6 +1,6 @@ { "name": "Platypus", - "version": "0.7.3", + "version": "0.7.4", "description": "Platypus Docs", "url": "https://github.com/PBS-KIDS/Platypus", "logo": "assets/platypus-title.png", diff --git a/docs/Platypus_docs-0.7.3.zip b/docs/Platypus_docs-0.7.3.zip deleted file mode 100644 index a1c776ea..00000000 Binary files a/docs/Platypus_docs-0.7.3.zip and /dev/null differ diff --git a/docs/Platypus_docs-0.7.4.zip b/docs/Platypus_docs-0.7.4.zip new file mode 100644 index 00000000..da60bc6d Binary files /dev/null and b/docs/Platypus_docs-0.7.4.zip differ diff --git a/lib/platypus.combined.js b/lib/platypus.combined.js index bb25c22c..6ed13893 100644 --- a/lib/platypus.combined.js +++ b/lib/platypus.combined.js @@ -3127,7 +3127,7 @@ this.platypus = this.platypus || {}; * @type String * @static **/ - platypus.version = /*=version*/"0.7.3"; // injected by build process + platypus.version = /*=version*/"0.7.4"; // injected by build process /** * The build date for this release in UTC format. @@ -3135,7 +3135,7 @@ this.platypus = this.platypus || {}; * @type String * @static **/ - platypus.buildDate = /*=date*/"Fri, 19 Feb 2016 21:10:20 GMT"; // injected by build process + platypus.buildDate = /*=date*/"Wed, 24 Feb 2016 21:58:39 GMT"; // injected by build process })(); @@ -3589,22 +3589,26 @@ platypus.Component = (function () { proto.destroy = function () { var func = ''; - // Handle component's destroy method before removing messaging and methods. - if (this._destroy) { - this._destroy(); - } - - // Now remove event listeners and methods. - for (func in this.publicMethods) { - if (this.publicMethods.hasOwnProperty(func)) { - this.removeMethod(func); + if (this.listener) { + // Handle component's destroy method before removing messaging and methods. + if (this._destroy) { + this._destroy(); + } + + // Now remove event listeners and methods. + for (func in this.publicMethods) { + if (this.publicMethods.hasOwnProperty(func)) { + this.removeMethod(func); + } } + this.publicMethods.recycle(); + + this.removeEventListeners(); + this.listener.events.recycle(); + this.listener.messages.recycle(); + this.listener.recycle(); + this.listener = null; } - this.publicMethods.recycle(); - this.removeEventListeners(); - this.listener.events.recycle(); - this.listener.messages.recycle(); - this.listener.recycle(); }; /** @@ -3741,7 +3745,7 @@ platypus.Component = (function () { * @class Messenger * @extends springroll.EventDispatcher */ -/*global console, platypus */ +/*global console, extend, platypus */ /*jslint plusplus:true */ platypus.Messenger = (function () { "use strict"; @@ -3753,6 +3757,7 @@ platypus.Messenger = (function () { this.loopCheck = Array.setUp(); }, debug = !!springroll.Debug, + perfTools = debug && window.performance && window.performance.mark && window.performance.measure && window.performance, // End with this to set perfTools to window.performance proto = extend(Messenger, EventDispatcher); /** @@ -3807,12 +3812,12 @@ platypus.Messenger = (function () { var count = 0, i = 0, listener = null, - listeners = null, + listeners = this._listeners, args = null; - if (!this._destroyed && this._listeners.hasOwnProperty(type) && (this._listeners[type] !== undefined)) { - // copy the listeners array - listeners = this._listeners[type].greenSlice(); + if (!this._destroyed && listeners.hasOwnProperty(type) && (listeners[type] !== undefined)) { + // copy the listeners array; reusing `listeners` variable + listeners = listeners[type].greenSlice(); if (arguments.length > 1) { args = Array.prototype.greenSlice.call(arguments); @@ -3859,13 +3864,13 @@ platypus.Messenger = (function () { } this.loopCheck.push(event); - if (window.performance) { - window.performance.mark("a"); + if (perfTools) { + perfTools.mark("a"); } count = this._triggerEvent(event, value, debug); - if (window.performance) { - window.performance.mark("b"); - window.performance.measure(this.type + ":" + event, 'a', 'b'); + if (perfTools) { + perfTools.mark("b"); + perfTools.measure(this.type + ":" + event, 'a', 'b'); } this.loopCheck.length = this.loopCheck.length - 1; if (debugLogging) { @@ -4140,17 +4145,23 @@ platypus.Entity = (function () { **/ proto.messengerDestroy = proto.destroy; proto.destroy = function () { - var i = 0; + var components = this.components, + i = components.length; - for (i = 0; i < this.components.length; i++) { - this.components[i].destroy(); + if (!this._destroyed) { + while (i--) { + components[i].destroy(); + } + components.recycle(); + + this.state.recycle(); + this.state = null; + + this.lastState.recycle(); + this.lastState = null; + + this.messengerDestroy(); } - this.components.recycle(); - - this.state.recycle(); - this.lastState.recycle(); - - this.messengerDestroy(); }; /** @@ -4798,7 +4809,7 @@ platypus.Game = (function () { sceneInstance.data = data; this.app.manager.addState(id, sceneInstance); this.stage.addChild(sceneInstance.panel); - this.app.triggerEvent('stateAdded', id, sceneInstance); + this.app.trigger('stateAdded', id, sceneInstance); this.app.manager.state = id; } }; @@ -4870,7 +4881,9 @@ platypus.Vector = (function () { "use strict"; var Vector = function (x, y, z) { - this.matrix = Array.setUp(0, 0, 0); + if (!this.matrix) { // Recycled vectors will already have a matrix array + this.matrix = Array.setUp(); + } this.set(x, y, z); }, proto = Vector.prototype; @@ -4943,27 +4956,65 @@ platypus.Vector = (function () { * @chainable */ proto.set = function (x, y, z) { - var m = null, - q = 0, + if (x && x.matrix) { // Passing in a vector. + return this.setVector(x, y); + } else if (x && Array.isArray(x)) { // Passing in an array. + return this.setArray(x, y); + } else { // Passing in coordinates. + return this.setXYZ(x, y, z); + } + }; + + /** + * Sets the coordinates of the vector. + * + * @method setXYZ + * @param x {number} The x coordinate. + * @param [y] {number} The y coordinate. + * @param [z] {number} The z coordinate. + * @chainable + * @since 0.7.4 + */ + proto.setXYZ = function (x, y, z) { + var matrix = this.matrix; + + matrix[0] = x || 0; + matrix[1] = y || 0; + matrix[2] = z || 0; + + return this; + }; + + /** + * Sets the coordinates of the vector. + * + * @method setVector + * @param vector {Vector} The Vector to copy. + * @param [dimensions] {number} The number of elements to copy from the Vector. + * @chainable + * @since 0.7.4 + */ + proto.setVector = function (vector, dimensions) { + return this.setArray(vector.matrix, dimensions); + }; + + /** + * Sets the coordinates of the vector. + * + * @method setArray + * @param arr {Array} The array to copy. + * @param [dimensions] {number} The number of elements to copy from the Array. + * @chainable + * @since 0.7.4 + */ + proto.setArray = function (arr, dimensions) { + var q = dimensions || arr.length, matrix = this.matrix; - if (x && Array.isArray(x)) { // Passing in an array. - q = y || x.length; - while (q--) { - matrix[q] = x[q]; - } - } else if (x && x.matrix) { // Passing in a vector. - m = x.matrix; - q = y || m.length; - while (q--) { - matrix[q] = m[q]; - } - } else { // Passing in coordinates. - matrix[0] = x || 0; - matrix[1] = y || 0; - matrix[2] = z || 0; + while (q--) { + matrix[q] = arr[q]; } - + return this; }; @@ -5009,10 +5060,9 @@ platypus.Vector = (function () { * * @param otherVector {platypus.Vector} The other vector. * @chainable + * @deprecated since 0.7.4 - Use `setVector` instead. */ - proto.copyValues = function (otherVector) { - return this.set(otherVector); - }; + proto.copyValues = proto.setVector; /** * Returns the magnitude of the vector. @@ -5146,14 +5196,14 @@ platypus.Vector = (function () { if (a) { if (a === 'x') { - a = temp.set(1, 0, 0); + a = temp.setXYZ(1, 0, 0); } else if (a === 'y') { - a = temp.set(0, 1, 0); + a = temp.setXYZ(0, 1, 0); } else if (a === 'z') { - a = temp.set(0, 0, 1); + a = temp.setXYZ(0, 0, 1); } } else { - a = temp.set(0, 0, 1); + a = temp.setXYZ(0, 0, 1); } x = a.x; @@ -5463,7 +5513,7 @@ platypus.Vector = (function () { * @since 0.7.1 */ proto.recycle = function () { - this.matrix.recycle(); + this.matrix.length = 0; Vector.recycle(this); }; @@ -5816,7 +5866,19 @@ platypus.AABB = (function () { }; /** - * Expresses whether this AABB intersects the given AABB. + * Expresses whether this AABB collides with the given AABB. This is similar to `intersects` but returns true for overlapping or touching edges. + * + * @method collides + * @param aabb {AABB} The AABB to check against + * @return {boolean} Returns `true` if this AABB collides with the other AABB. + * @since 0.7.4 + */ + proto.collides = function (aabb) { + return (aabb.bottom > this.top) && (aabb.top < this.bottom) && (aabb.right > this.left) && (aabb.left < this.right); + }; + + /** + * Expresses whether this AABB intersects the given AABB. This is similar to `collides` but returns true for overlapping only, not touching edges. * * @method intersects * @param aabb {AABB} The AABB to check against @@ -6109,7 +6171,7 @@ platypus.CollisionData = (function () { this.aABB = dataToCopy.aABB; this.thisShape = dataToCopy.thisShape; this.thatShape = dataToCopy.thatShape; - this.vector.set(dataToCopy.vector); + this.vector.setVector(dataToCopy.vector); this.stuck = dataToCopy.stuck; }; proto.clear = function () { @@ -6120,7 +6182,7 @@ platypus.CollisionData = (function () { this.aABB = null; this.thisShape = null; this.thatShape = null; - this.vector.set(0, 0, 0); + this.vector.setXYZ(0, 0, 0); this.stuck = 0; }; return collisionData; @@ -6237,61 +6299,100 @@ platypus.CollisionDataContainer = (function () { platypus.CollisionShape = (function () { "use strict"; - var Vector = include('platypus.Vector'), - collisionShape = function (owner, definition, collisionType) { + var AABB = include('platypus.AABB'), + Vector = include('platypus.Vector'), + circleRectCollision = function (circle, rect) { + var rectAabb = rect.aABB, + hh = rectAabb.halfHeight, + hw = rectAabb.halfWidth, + abs = Math.abs, + pow = Math.pow, + shapeDistanceX = abs(circle.x - rect.x), + shapeDistanceY = abs(circle.y - rect.y), + radius = circle.radius; + + /* This checks the following in order: + - Is the x or y distance between shapes less than half the width or height respectively of the rectangle? If so, we know they're colliding. + - Is the x or y distance between the shapes greater than the half width/height plus the radius of the circle? Then we know they're not colliding. + - Otherwise, we check the distance between a corner of the rectangle and the center of the circle. If that distance is less than the radius of the circle, we know that there is a collision; otherwise there is not. + */ + return (shapeDistanceX < hw) || (shapeDistanceY < hh) || ((shapeDistanceX < (hw + radius)) && (shapeDistanceY < (hh + radius)) && ((pow((shapeDistanceX - hw), 2) + pow((shapeDistanceY - hh), 2)) < pow(radius, 2))); + }, + collidesCircle = function (shape) { + var pow = Math.pow; + + return this.aABB.collides(shape.aABB) && ( + ((shape.type === 'rectangle') && circleRectCollision(this, shape)) || + ((shape.type === 'circle') && ((pow((this.x - shape.x), 2) + pow((this.y - shape.y), 2)) <= pow((this.radius + shape.radius), 2))) + ); + }, + collidesDefault = function () { + return false; + }, + collidesRectangle = function (shape) { + return this.aABB.collides(shape.aABB) && ( + (shape.type === 'rectangle') || + ((shape.type === 'circle') && circleRectCollision(shape, this)) + ); + }, + CollisionShape = function (owner, definition, collisionType) { var regX = definition.regX, regY = definition.regY, - width = 0, - height = 0; + width = definition.width || definition.radius * 2 || 0, + height = definition.height || definition.radius * 2 || 0, + radius = definition.radius || 0, + type = definition.type || 'rectangle'; + + // If this shape is recycled, the vectors will already be in place. + if (!this.initialized) { + this.initialized = true; + Vector.assign(this, 'offset', 'offsetX', 'offsetY'); + Vector.assign(this, 'position', 'x', 'y'); + Vector.assign(this, 'size', 'width', 'height'); + this.aABB = AABB.setUp(); + } this.owner = owner; this.collisionType = collisionType; - - this.width = definition.width || definition.radius * 2 || 0; - this.height = definition.height || definition.radius * 2 || 0; - this.radius = definition.radius || 0; + this.type = type; + this.subType = ''; + + /** + * Determines whether shapes collide. + * + * @method collides + * @param shape {platypus.CollisionShape} The shape to check against for collision. + * @return {Boolean} Whether the shapes collide. + * @since 0.7.4 + */ + if (type === 'circle') { + width = height = radius * 2; + this.collides = collidesCircle; + } else if (type === 'rectangle') { + this.collides = collidesRectangle; + } else { + this.collides = collidesDefault; + } + this.size.setXYZ(width, height); + this.radius = radius; if (typeof regX !== 'number') { - regX = this.width / 2; + regX = width / 2; } if (typeof regY !== 'number') { - regY = this.height / 2; + regY = height / 2; } + this.offset.setXYZ(definition.offsetX || ((width / 2) - regX), definition.offsetY || ((height / 2) - regY)); - Vector.assign(this, 'offset', 'offsetX', 'offsetY'); - this.offsetX = definition.offsetX || ((this.width / 2) - regX); - this.offsetY = definition.offsetY || ((this.height / 2) - regY); - - Vector.assign(this, 'position', 'x', 'y'); if (owner) { - this.x = owner.x + this.offsetX; - this.y = owner.y + this.offsetY; + this.position.setXYZ(owner.x, owner.y).add(this.offset); } else { - this.x = definition.x + this.offsetX; - this.y = definition.y + this.offsetY; + this.position.setXYZ(definition.x, definition.y).add(this.offset); } - this.type = definition.type || 'rectangle'; - this.subType = ''; - this.aABB = undefined; - - switch (this.type) { - case 'circle': //need TL and BR points - width = height = this.radius * 2; - break; - case 'rectangle': //need TL and BR points - width = this.width; - height = this.height; - break; - } - - Vector.assign(this, 'size', 'width', 'height'); - this.width = width; - this.height = height; - - this.aABB = new platypus.AABB(this.x, this.y, width, height); + this.aABB.setAll(this.x, this.y, width, height); }, - proto = collisionShape.prototype; + proto = CollisionShape.prototype; /** * Updates the location of the shape and AABB. The position you send should be that of the owner, the offset of the shape is added inside the function. @@ -6304,8 +6405,7 @@ platypus.CollisionShape = (function () { var x = ownerX + this.offsetX, y = ownerY + this.offsetY; - this.x = x; - this.y = y; + this.position.setXYZ(x, y); this.aABB.move(x, y); }; @@ -6367,9 +6467,10 @@ platypus.CollisionShape = (function () { * Destroys the shape so that it can be memory collected safely. * * @method destroy + * @deprecated since 0.7.4 - Use `recycle()` instead. */ proto.destroy = function () { - this.aABB = undefined; + this.recycle(); }; /** @@ -6379,20 +6480,45 @@ platypus.CollisionShape = (function () { * @param matrix {Array} A matrix used to transform the shape. */ proto.multiply = function (m) { - this.position.subtractVector(this.owner.position); + var pos = this.position, + own = this.owner.position; - this.position.multiply(m); + pos.subtractVector(own); + + pos.multiply(m); this.offset.multiply(m); this.size.multiply(m); - this.position.addVector(this.owner.position); + pos.addVector(own); this.width = Math.abs(this.width); this.height = Math.abs(this.height); this.aABB.setAll(this.x, this.y, this.width, this.height); }; - return collisionShape; + /** + * Returns an CollisionShape from cache or creates a new one if none are available. + * + * @method CollisionShape.setUp + * @return {platypus.CollisionShape} The instantiated CollisionShape. + * @since 0.7.4 + */ + /** + * Returns a CollisionShape back to the cache. + * + * @method CollisionShape.recycle + * @param {platypus.CollisionShape} The CollisionShape to be recycled. + * @since 0.7.4 + */ + /** + * Relinquishes properties of the CollisionShape and recycles it. + * + * @method recycle + * @since 0.7.4 + */ + platypus.setUpRecycle(CollisionShape, 'CollisionShape'); + + return CollisionShape; }()); //############################################################################## @@ -7460,7 +7586,7 @@ platypus.CollisionShape = (function () { if (m) { c = true; - this.direction.set(v).normalize().multiply(this.speed); + this.direction.setVector(v).normalize().multiply(this.speed); } v.recycle(); @@ -10455,17 +10581,17 @@ platypus.CollisionShape = (function () { if (collisionInfo.myType === collisionType) { if (collisionInfo.hitType === solidOrSoft) { if ((dy > 0) && event.bottom) { - this.owner.triggerEvent(event.bottom, collisionInfo); + this.owner.trigger(event.bottom, collisionInfo); } else if ((dy < 0) && event.top) { - this.owner.triggerEvent(event.top, collisionInfo); + this.owner.trigger(event.top, collisionInfo); } if ((dx > 0) && event.right) { - this.owner.triggerEvent(event.right, collisionInfo); + this.owner.trigger(event.right, collisionInfo); } else if ((dx < 0) && event.left) { - this.owner.triggerEvent(event.left, collisionInfo); + this.owner.trigger(event.left, collisionInfo); } if (event.all) { - this.owner.triggerEvent(event.all, collisionInfo); + this.owner.trigger(event.all, collisionInfo); } } } @@ -10880,8 +11006,8 @@ platypus.CollisionShape = (function () { this.prevShapes = Array.setUp(); this.entities = undefined; for (x = 0; x < shapes.length; x++) { - this.shapes.push(new CollisionShape(this.owner, shapes[x], this.collisionType)); - this.prevShapes.push(new CollisionShape(this.owner, shapes[x], this.collisionType)); + this.shapes.push(CollisionShape.setUp(this.owner, shapes[x], this.collisionType)); + this.prevShapes.push(CollisionShape.setUp(this.owner, shapes[x], this.collisionType)); this.prevAABB.include(this.prevShapes[x].aABB); this.aabb.include(this.shapes[x].aABB); } @@ -10922,17 +11048,24 @@ platypus.CollisionShape = (function () { * On receiving this message, the component triggers `add-collision-entity` on the parent. * * @method 'collide-on' + * @param type {String} If specified, only collision components of this type are added to the collision list. */ "collide-on": function (type) { + var owner = this.owner, + colType = this.collisionType, + colTypes = owner.collisionTypes; + /** * On receiving 'collide-on', this message is triggered on the parent to turn on collision. * * @event 'add-collision-entity' * @param entity {platypus.Entity} The entity this component is attached to. */ - if (!type || (type === this.collisionType)) { - this.owner.collisionTypes.union([this.collisionType]); - this.owner.parent.triggerEvent('add-collision-entity', this.owner); + if ((typeof type !== 'string') || (type === colType)) { + if (colTypes.indexOf(colType) === -1) { + colTypes.push(colType); + } + owner.parent.triggerEvent('add-collision-entity', owner); this.active = true; } }, @@ -10941,9 +11074,14 @@ platypus.CollisionShape = (function () { * On receiving this message, the component triggers `remove-collision-entity` on the parent. * * @method 'collide-off' + * @param type {String} If specified, only collision components of this type are removed from the collision list. */ "collide-off": function (type) { - var index = 0; + var index = 0, + owner = this.owner, + parent = owner.parent, + colType = this.collisionType, + colTypes = owner.collisionTypes; /** * On receiving 'collide-off', this message is triggered on the parent to turn off collision. @@ -10951,17 +11089,17 @@ platypus.CollisionShape = (function () { * @event 'remove-collision-entity' * @param entity {platypus.Entity} The entity this component is attached to. */ - if (!type || (type === this.collisionType)) { - this.owner.parent.triggerEvent('remove-collision-entity', this.owner); - index = this.owner.collisionTypes.indexOf(this.collisionType); + if ((typeof type !== 'string') || (type === colType)) { + parent.triggerEvent('remove-collision-entity', owner); + index = colTypes.indexOf(colType); if (index >= 0) { - this.owner.collisionTypes.greenSplice(index); + colTypes.greenSplice(index); } this.active = false; - } - if (this.owner.collisionTypes.length) { - this.owner.parent.triggerEvent('add-collision-entity', this.owner); + if (colTypes.length) { + parent.triggerEvent('add-collision-entity', owner); + } } }, @@ -10993,9 +11131,9 @@ platypus.CollisionShape = (function () { } if (resp.relative) { - owner.position.set(owner.previousPosition).add(resp.position); + owner.position.setVector(owner.previousPosition).add(resp.position); } else { - owner.position.set(resp.position); + owner.position.setVector(resp.position); } if (this.stuck) { @@ -11017,7 +11155,7 @@ platypus.CollisionShape = (function () { aabb.include(shape.aABB); } - owner.previousPosition.set(owner.position); + owner.previousPosition.setVector(owner.position); if (um > 0) { // to force check in all directions for ultimate stuck resolution (esp. for stationary entities) if (!this.stuck) { @@ -11135,15 +11273,25 @@ platypus.CollisionShape = (function () { colFuncs[this.collisionType].recycle(); delete colFuncs[this.collisionType]; + i = this.shapes.length; + while (i--) { + this.shapes[i].recycle(); + this.prevShapes[i].recycle(); + } this.shapes.recycle(); this.prevShapes.recycle(); + delete this.shapes; + delete this.prevShapes; + delete this.entities; if (this.owner.collisionTypes.length) { this.owner.parent.triggerEvent('add-collision-entity', this.owner); } else { //remove collision functions colFuncs.recycle(); + this.owner.collisionFunctions = null; this.owner.aabb.recycle(); + this.owner.aabb = null; } } } @@ -11383,7 +11531,7 @@ platypus.CollisionShape = (function () { * @method 'relocate-entity' */ "relocate-entity": function () { - this.owner.previousPosition.set(this.owner.position); + this.owner.previousPosition.setVector(this.owner.position); this.updateAABB(); } }, @@ -11469,6 +11617,7 @@ platypus.CollisionShape = (function () { var i = 0, aabb = this.filteredAABB, childEntity = null, + incAABB = null, sE = this.solidEntities; if (!collisionType) { @@ -11481,8 +11630,10 @@ platypus.CollisionShape = (function () { if ((childEntity !== this.owner) && childEntity.collisionGroup) { childEntity = childEntity.collisionGroup; } - - aabb.include(childEntity.getAABB(collisionType)); + incAABB = childEntity.getAABB(collisionType); + if (incAABB) { + aabb.include(incAABB); + } } return aabb; } @@ -11492,6 +11643,7 @@ platypus.CollisionShape = (function () { var i = 0, aabb = this.filteredAABB, childEntity = null, + incAABB = null, sE = this.solidEntities; if (!collisionType) { @@ -11505,7 +11657,10 @@ platypus.CollisionShape = (function () { childEntity = childEntity.collisionGroup; } - aabb.include(childEntity.getPreviousAABB(collisionType)); + incAABB = childEntity.getPreviousAABB(collisionType); + if (incAABB) { + aabb.include(incAABB); + } } return aabb; } @@ -11697,15 +11852,13 @@ platypus.CollisionShape = (function () { * @class CollisionTiles * @uses platypus.Component */ -// Requires: ["../CollisionShape.js"] -/*global platypus */ +/*global include, platypus */ /*jslint plusplus:true */ (function () { "use strict"; - var storedTiles = Array.setUp(), - storedTileIndex = 0, - serveTiles = Array.setUp(), + var CollisionShape = include('platypus.CollisionShape'), + Data = include('platypus.Data'), flip = function (num, arr) { if (num < -1) { num = Math.abs(num) - 2; @@ -11907,6 +12060,16 @@ platypus.CollisionShape = (function () { constructor: function (definition) { this.tileHalfWidth = this.tileWidth / 2; this.tileHalfHeight = this.tileHeight / 2; + this.shapeDefinition = Data.setUp( + "x", 0, + "y", 0, + "type", 'rectangle', + "width", this.tileWidth, + "height", this.tileHeight + ); + this.storedTiles = Array.setUp(); + this.serveTiles = Array.setUp(); + this.storedTileIndex = 0; }, events: { @@ -11943,55 +12106,70 @@ platypus.CollisionShape = (function () { }, methods: { - getShape: function (prevAABB, x, y) { - var shape = null; + getShape: function (x, y) { + var i = this.storedTileIndex, + shape = null, + storedTiles = this.storedTiles; - if (storedTileIndex < storedTiles.length) { - shape = storedTiles[storedTileIndex]; - shape.update(x * this.tileWidth + this.tileHalfWidth, y * this.tileHeight + this.tileHalfHeight); - } else { - storedTiles.push(new platypus.CollisionShape(null, { - x: x * this.tileWidth + this.tileHalfWidth, - y: y * this.tileHeight + this.tileHalfHeight, - type: 'rectangle', - width: this.tileWidth, - height: this.tileHeight - }, 'tiles')); - shape = storedTiles[storedTileIndex]; + if (i === storedTiles.length) { + storedTiles.push(CollisionShape.setUp(null, this.shapeDefinition, 'tiles')); } - storedTileIndex += 1; + + shape = storedTiles[i]; + shape.update(x * this.tileWidth + this.tileHalfWidth, y * this.tileHeight + this.tileHalfHeight); + + this.storedTileIndex += 1; return shape; }, addShape: function (shapes, prevAABB, x, y) { - if (this.collisionMap[x][y] > -1) { - shapes.push(this.getShape(prevAABB, x, y)); - } else if (this.collisionMap[x][y] < -1) { - switch (this.collisionMap[x][y]) { + var xy = this.collisionMap[x][y]; + + if (xy > -1) { + shapes.push(this.getShape(x, y)); + } else if (xy < -1) { + switch (xy) { case -2: //Top if (prevAABB.bottom <= y * this.tileHeight) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -3: //Right if (prevAABB.left >= (x + 1) * this.tileWidth) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -4: //Bottom if (prevAABB.top >= (y + 1) * this.tileHeight) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -5: //Left if (prevAABB.right <= x * this.tileWidth) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; } } return shapes; + }, + + destroy: function () { + var store = this.storedTiles, + i = store.length; + + this.shapeDefinition.recycle(); + delete this.shapeDefinition; + + while (i--) { + store[i].recycle(); + } + store.recycle(); + delete this.storedTiles; + + this.serveTiles.recycle(); + delete this.serveTiles; } }, @@ -12038,10 +12216,10 @@ platypus.CollisionShape = (function () { bottom = Math.min(Math.ceil(aabb.bottom / this.tileHeight), this.collisionMap[0].length), x = 0, y = 0, - shapes = serveTiles; + shapes = this.serveTiles; - serveTiles.length = 0; - storedTileIndex = 0; + shapes.length = 0; + this.storedTileIndex = 0; for (x = left; x < right; x++) { for (y = top; y < bottom; y++) { @@ -13208,7 +13386,7 @@ platypus.CollisionShape = (function () { * @class HandlerCollision * @uses platypus.Component */ -/*global platypus */ +/*global include, platypus */ /*jslint plusplus:true */ (function () { "use strict"; @@ -13241,53 +13419,6 @@ platypus.CollisionShape = (function () { }, groupSortBySize = function (a, b) { return a.collisionGroup.getAllEntities() - b.collisionGroup.getAllEntities(); - }, - isAABBCollision = function (boxX, boxY) { - return !((boxX.left >= boxY.right) || (boxX.right <= boxY.left) || (boxX.top >= boxY.bottom) || (boxX.bottom <= boxY.top)); - }, - shapeCollision = function (shapeA, shapeB) { - var distSquared = 0, - radiiSquared = 0, - circle = null, - rect = null, - shapeDistanceX = 0, - shapeDistanceY = 0, - rectAabb = null, - cornerDistanceSq = 0; - - if (shapeA.type === 'rectangle' && shapeB.type === 'rectangle') { - return true; - } else if (shapeA.type === 'circle' && shapeB.type === 'circle') { - distSquared = Math.pow((shapeA.x - shapeB.x), 2) + Math.pow((shapeA.y - shapeB.y), 2); - radiiSquared = Math.pow((shapeA.radius + shapeB.radius), 2); - if (distSquared <= radiiSquared) { - return true; - } - } else if ((shapeA.type === 'circle' && shapeB.type === 'rectangle') || (shapeA.type === 'rectangle' && shapeB.type === 'circle')) { - if (shapeA.type === 'circle') { - circle = shapeA; - rect = shapeB; - } else { - circle = shapeB; - rect = shapeA; - } - rectAabb = rect.aABB; - - shapeDistanceX = Math.abs(circle.x - rect.x); - shapeDistanceY = Math.abs(circle.y - rect.y); - - if (shapeDistanceX >= (rectAabb.halfWidth + circle.radius)) { return false; } - if (shapeDistanceY >= (rectAabb.halfHeight + circle.radius)) { return false; } - - if (shapeDistanceX < (rectAabb.halfWidth)) { return true; } - if (shapeDistanceY < (rectAabb.halfHeight)) { return true; } - - cornerDistanceSq = Math.pow((shapeDistanceX - rectAabb.halfWidth), 2) + Math.pow((shapeDistanceY - rectAabb.halfHeight), 2); - if (cornerDistanceSq < Math.pow(circle.radius, 2)) { - return true; - } - } - return false; }; return platypus.createComponentClass({ @@ -13476,7 +13607,6 @@ platypus.CollisionShape = (function () { y = camera.top + height / 2, entities = null, entity = null, - check = isAABBCollision, aabbLogic = this.cameraLogicAABB, aabbCollision = this.cameraCollisionAABB, types = null, @@ -13511,7 +13641,7 @@ platypus.CollisionShape = (function () { while (i--) { collides = false; entity = all[i]; - if (entity.alwaysOn || entity.checkCollision || check(entity.getAABB(), aabbLogic)) { + if (entity.alwaysOn || entity.checkCollision || aabbLogic.collides(entity.getAABB())) { entity.checkCollision = false; allLive[allLive.length] = entity; @@ -13555,7 +13685,7 @@ platypus.CollisionShape = (function () { j = entities.length; while (j--) { entity = entities[j]; - if (entity.alwaysOn || check(entity.getAABB(), aabbCollision)) { + if (entity.alwaysOn || aabbCollision.collides(entity.getAABB())) { list[list.length] = entity; } } @@ -13660,7 +13790,7 @@ platypus.CollisionShape = (function () { msg.relative = false; while (i--) { entity = nons[i]; - msg.position.set(entity.position); + msg.position.setVector(entity.position); /** * This message is triggered on an entity that has been repositioned due to a solid collision. @@ -13705,23 +13835,24 @@ platypus.CollisionShape = (function () { entities = this.groupsLive, x = entities.length, entity = null, - messageData = null; + messageData = null, + entityCDC = entityCollisionDataContainer; while (x--) { entity = entities[x]; if (entity.collisionGroup.getSize() > 1) { - entityCollisionDataContainer.reset(); - this.checkSolidEntityCollision(entity, entity.collisionGroup, entityCollisionDataContainer); + entityCDC.reset(); + this.checkSolidEntityCollision(entity, entity.collisionGroup, entityCDC); - i = entityCollisionDataContainer.xCount; + i = entityCDC.xCount; while (i--) { - messageData = entityCollisionDataContainer.getXEntry(i); + messageData = entityCDC.getXEntry(i); triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); } - i = entityCollisionDataContainer.yCount; + i = entityCDC.yCount; while (i--) { - messageData = entityCollisionDataContainer.getYEntry(i); + messageData = entityCDC.getYEntry(i); triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); } } @@ -13761,43 +13892,42 @@ platypus.CollisionShape = (function () { entities = this.solidEntitiesLive, x = entities.length, entity = null, - messageData = null; + messageData = null, + entityCDC = entityCollisionDataContainer, + trigger = triggerCollisionMessages; while (x--) { entity = entities[x]; - entityCollisionDataContainer.reset(); - this.checkSolidEntityCollision(entity, entity, entityCollisionDataContainer); + entityCDC.reset(); + this.checkSolidEntityCollision(entity, entity, entityCDC); - i = entityCollisionDataContainer.xCount; + i = entityCDC.xCount; while (i--) { - messageData = entityCollisionDataContainer.getXEntry(i); - triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); + messageData = entityCDC.getXEntry(i); + trigger(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); } - i = entityCollisionDataContainer.yCount; + i = entityCDC.yCount; while (i--) { - messageData = entityCollisionDataContainer.getYEntry(i); - triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); + messageData = entityCDC.getYEntry(i); + trigger(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); } } }; }()), checkSolidEntityCollision: function (ent, entityOrGroup, collisionDataCollection) { - var abs = Math.abs, - step = 0, + var step = 0, finalMovementInfo = null, - entityDeltaX = ent.x - ent.previousX, - entityDeltaY = ent.y - ent.previousY, aabb = null, - dX = 0, - dY = 0, + dX = ent.x - ent.previousX, + dY = ent.y - ent.previousY, sW = Infinity, sH = Infinity, collisionTypes = entityOrGroup.getCollisionTypes(), - i = collisionTypes.length, + i = 0, ignoredEntities = false, - min = Math.min; + min = null; if (entityOrGroup.getSolidEntities) { ignoredEntities = entityOrGroup.getSolidEntities(); @@ -13805,9 +13935,12 @@ platypus.CollisionShape = (function () { finalMovementInfo = Vector.setUp(ent.position); - if (entityDeltaX || entityDeltaY) { + if (dX || dY) { if (ent.bullet) { + min = Math.min; + + i = collisionTypes.length; while (i--) { aabb = entityOrGroup.getAABB(collisionTypes[i]); sW = min(sW, aabb.width); @@ -13815,31 +13948,27 @@ platypus.CollisionShape = (function () { } //Stepping to catch really fast entities - this is not perfect, but should prevent the majority of fallthrough cases. - step = Math.ceil(Math.max(abs(entityDeltaX) / sW, abs(entityDeltaY) / sH)); + step = Math.ceil(Math.max(Math.abs(dX) / sW, Math.abs(dY) / sH)); step = min(step, 100); //Prevent memory overflow if things move exponentially far. - dX = entityDeltaX / step; - dY = entityDeltaY / step; - } else { - step = 1; - dX = entityDeltaX; - dY = entityDeltaY; - } - - while (step--) { - entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + dX = dX / step; + dY = dY / step; - finalMovementInfo.set(ent.position); - - finalMovementInfo = this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, dX, dY, collisionTypes); - - - if ((finalMovementInfo.x === ent.previousX) && (finalMovementInfo.y === ent.previousY)) { - entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); - //No more movement so we bail! - break; - } else { - entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + while (step--) { + entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + + finalMovementInfo = this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo.setVector(ent.position), dX, dY, collisionTypes); + + if ((finalMovementInfo.x === ent.previousX) && (finalMovementInfo.y === ent.previousY)) { + entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + //No more movement so we bail! + break; + } else { + entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + } } + } else { + entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + entityOrGroup.relocateEntity(this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, dX, dY, collisionTypes), collisionDataCollection); } } @@ -13848,10 +13977,10 @@ platypus.CollisionShape = (function () { processCollisionStep: (function () { var sweeper = AABB.setUp(), - includeEntity = function (thisEntity, aabb, otherEntity, otherCollisionType, ignoredEntities) { - var i = 0, - otherAABB = otherEntity.getAABB(otherCollisionType); + includeEntity = function (thisEntity, aabb, otherEntity, otherAABB, ignoredEntities, sweepAABB) { + var i = 0; + //Chop out all the special case entities we don't want to check against. if (otherEntity === thisEntity) { return false; } else if (otherEntity.jumpThrough && (aabb.bottom > otherAABB.top)) { @@ -13866,7 +13995,8 @@ platypus.CollisionShape = (function () { } } } - return true; + + return sweepAABB.collides(otherAABB); }; return function (ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, entityDeltaX, entityDeltaY, collisionTypes) { @@ -13874,6 +14004,7 @@ platypus.CollisionShape = (function () { j = 0, k = 0, l = 0, + isIncluded = includeEntity, potentialCollision = false, potentialCollidingShapes = Array.setUp(), pcsGroup = null, @@ -13882,6 +14013,7 @@ platypus.CollisionShape = (function () { collisionType = null, otherEntity = null, otherCollisionType = '', + otherAABB = null, otherShapes = null, entitiesByTypeLive = this.entitiesByTypeLive, otherEntities = null, @@ -13911,12 +14043,11 @@ platypus.CollisionShape = (function () { if (otherEntities) { k = otherEntities.length; while (k--) { - - //Chop out all the special case entities we don't want to check against. otherEntity = otherEntities[k]; + otherAABB = otherEntity.getAABB(otherCollisionType); //Do our sweep check against the AABB of the other object and add potentially colliding shapes to our list. - if (includeEntity(ent, previousAABB, otherEntity, otherCollisionType, ignoredEntities) && (isAABBCollision(sweepAABB, otherEntity.getAABB(otherCollisionType)))) { + if (isIncluded(ent, previousAABB, otherEntity, otherAABB, ignoredEntities, sweepAABB)) { otherShapes = otherEntity.getShapes(otherCollisionType); l = otherShapes.length; @@ -14019,7 +14150,7 @@ platypus.CollisionShape = (function () { cd.clear(); this.findMinShapeMovementCollision(prevShapes[i], shapes[i], axis, potentialCollidingShapes, cd); - if (cd.occurred && (!bestCollisionData.occurred //if a collision occurred and we haven't already have a collision. + if (cd.occurred && (!bestCollisionData.occurred //if a collision occurred and we haven't already had a collision. || (cd.deltaMovement < bestCollisionData.deltaMovement))) { //if a collision occurred and the diff is smaller than our best diff. bestCollisionData.copy(cd); } @@ -14048,115 +14179,149 @@ platypus.CollisionShape = (function () { collisionData.aABB = thatShape.aABB; collisionData.thisShape = thisShape; collisionData.thatShape = thatShape; - collisionData.vector.set(vector); + collisionData.vector.setVector(vector); }, - findAxisCollisionPosition = (function () { - var returnInfo = { - position: 0, - contactVector: Vector.setUp() - }, - getMovementDistance = function (currentDistance, minimumDistance) { - var pow = Math.pow; - - return Math.sqrt(pow(minimumDistance, 2) - pow(currentDistance, 2)); - }, - getCorner = function (circlePos, rectanglePos, half) { - var diff = circlePos - rectanglePos; - - return diff - (diff / Math.abs(diff)) * half; - }, - getOffsetForAABB = function (axis, thisAABB, thatAABB) { - if (axis === 'x') { - return thatAABB.halfWidth + thisAABB.halfWidth; - } else if (axis === 'y') { - return thatAABB.halfHeight + thisAABB.halfHeight; - } - }, - getOffsetForCircleVsAABB = function (axis, circle, rect, moving, direction, v) { - var newAxisPosition = 0, - aabb = rect.aABB; + returnInfo = { + position: 0, + contactVector: Vector.setUp() + }, + getMovementDistance = function (currentDistance, minimumDistance) { + var pow = Math.pow; + + return Math.sqrt(pow(minimumDistance, 2) - pow(currentDistance, 2)); + }, + getCorner = function (circlePos, rectanglePos, half) { + var diff = circlePos - rectanglePos; + + return diff - (diff / Math.abs(diff)) * half; + }, + getOffsetForCircleVsAABBX = function (circle, rect, moving, direction, v) { + var newAxisPosition = 0, + aabb = rect.aABB, + hw = aabb.halfWidth, + x = circle.x, + y = circle.y; + + if (y >= aabb.top && y <= aabb.bottom) { + return hw + circle.radius; + } else { + y = getCorner(y, rect.y, aabb.halfHeight); // reusing y. + newAxisPosition = hw + getMovementDistance(y, circle.radius); + if (moving === circle) { + v.x = -getCorner(x - direction * newAxisPosition, rect.x, hw) / 2; + y = -y; + } else { + v.x = getCorner(x, rect.x - direction * newAxisPosition, hw) / 2; + } + v.y = y; + v.normalize(); + return newAxisPosition; + } + }, + getOffsetForCircleVsAABBY = function (circle, rect, moving, direction, v) { + var newAxisPosition = 0, + aabb = rect.aABB, + hh = aabb.halfHeight, + x = circle.x, + y = circle.y; + + if (x >= aabb.left && x <= aabb.right) { + return hh + circle.radius; + } else { + x = getCorner(x, rect.x, aabb.halfWidth); // reusing x. + newAxisPosition = hh + getMovementDistance(x, circle.radius); + if (moving === circle) { + x = -x; + v.y = -getCorner(y - direction * newAxisPosition, rect.y, hh) / 2; + } else { + v.y = getCorner(y, rect.y - direction * newAxisPosition, hh) / 2; + } + v.x = x; + v.normalize(); + return newAxisPosition; + } + }, + findAxisCollisionPosition = { // Decision tree for quicker access, optimized for mobile devices. + x: { + rectangle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; - if (axis === 'x') { - if (circle.y >= aabb.top && circle.y <= aabb.bottom) { - return aabb.halfWidth + circle.radius; - } else { - v.y = getCorner(circle.y, rect.y, aabb.halfHeight); - newAxisPosition = aabb.halfWidth + getMovementDistance(v.y, circle.radius); - if (moving === circle) { - v.x = -getCorner(circle.x - direction * newAxisPosition, rect.x, aabb.halfWidth) / 2; - v.y = -v.y; - } else { - v.x = getCorner(circle.x, rect.x - direction * newAxisPosition, aabb.halfWidth) / 2; - } - v.normalize(); - return newAxisPosition; - } - } else if (axis === 'y') { - if (circle.x >= aabb.left && circle.x <= aabb.right) { - return aabb.halfHeight + circle.radius; - } else { - v.x = getCorner(circle.x, rect.x, aabb.halfWidth); - newAxisPosition = aabb.halfHeight + getMovementDistance(v.x, circle.radius); - if (moving === circle) { - v.x = -v.x; - v.y = -getCorner(circle.y - direction * newAxisPosition, rect.y, aabb.halfWidth) / 2; - } else { - v.y = getCorner(circle.y, rect.y - direction * newAxisPosition, aabb.halfWidth) / 2; - } - v.normalize(); - return newAxisPosition; - } + ri.position = thatShape.x - direction * (thatShape.aABB.halfWidth + thisShape.aABB.halfWidth); + ri.contactVector.setXYZ(direction, 0); + + return ri; + }, + circle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.x - direction * getOffsetForCircleVsAABBX(thatShape, thisShape, thisShape, direction, ri.contactVector.setXYZ(direction, 0)); + + return ri; } }, - getOffsetForCircles = function (axis, thisShape, thatShape) { - if (axis === 'x') { - return getMovementDistance(thisShape.y - thatShape.y, thisShape.radius + thatShape.radius); - } else if (axis === 'y') { - return getMovementDistance(thisShape.x - thatShape.x, thisShape.radius + thatShape.radius); - } - }; + circle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.x - direction * getOffsetForCircleVsAABBX(thisShape, thatShape, thisShape, direction, ri.contactVector.setXYZ(direction, 0)); - return function (axis, direction, thisShape, thatShape) { - //Returns the value of the axis at which point thisShape collides with thatShape - var ri = returnInfo, - v = ri.contactVector; - - if (thisShape.type === 'rectangle') { - if (thatShape.type === 'rectangle') { - ri.position = thatShape[axis] - direction * getOffsetForAABB(axis, thisShape.aABB, thatShape.aABB); - v.x = 0; - v.y = 0; - v[axis] = direction; return ri; - } else if (thatShape.type === 'circle') { - v.x = 0; - v.y = 0; - v[axis] = direction; - ri.position = thatShape[axis] - direction * getOffsetForCircleVsAABB(axis, thatShape, thisShape, thisShape, direction, v); + }, + circle: function (direction, thisShape, thatShape) { + var y = thatShape.y - thisShape.y, + position = thatShape.x - direction * getMovementDistance(y, thisShape.radius + thatShape.radius), + ri = returnInfo; + + ri.contactVector.setXYZ(thatShape.x - position, y).normalize(); + ri.position = position; + return ri; } - } else if (thisShape.type === 'circle') { - if (thatShape.type === 'rectangle') { - v.x = 0; - v.y = 0; - v[axis] = direction; - ri.position = thatShape[axis] - direction * getOffsetForCircleVsAABB(axis, thisShape, thatShape, thisShape, direction, v); + } + }, + y: { + rectangle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * (thatShape.aABB.halfHeight + thisShape.aABB.halfHeight); + ri.contactVector.setXYZ(0, direction); + return ri; - } else if (thatShape.type === 'circle') { - ri.position = thatShape[axis] - direction * getOffsetForCircles(axis, thisShape, thatShape); - v.x = thatShape.x - thisShape.x; - v.y = thatShape.y - thisShape.y; + }, + circle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * getOffsetForCircleVsAABBY(thatShape, thisShape, thisShape, direction, ri.contactVector.setXYZ(0, direction)); + + return ri; + } + }, + circle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * getOffsetForCircleVsAABBY(thisShape, thatShape, thisShape, direction, ri.contactVector.setXYZ(0, direction)); + + return ri; + }, + circle: function (direction, thisShape, thatShape) { + var x = thatShape.x - thisShape.x, + position = thatShape.y - direction * getMovementDistance(x, thisShape.radius + thatShape.radius), + ri = returnInfo; + + ri.contactVector.setXYZ(x, thatShape.y - position).normalize(); + ri.position = position; - v[axis] = thatShape[axis] - ri.position; - v.normalize(); return ri; } } - }; - }()); + } + }; return function (prevShape, currentShape, axis, potentialCollidingShapes, collisionData) { - var i = potentialCollidingShapes.length, + var i = 0, initialPoint = prevShape[axis], goalPoint = currentShape[axis], translatedShape = prevShape, @@ -14164,39 +14329,39 @@ platypus.CollisionShape = (function () { position = goalPoint, pcShape = null, collisionInfo = null, - finalPosition = goalPoint; + finalPosition = goalPoint, + findACP = null; if (initialPoint !== goalPoint) { + findACP = findAxisCollisionPosition[axis][translatedShape.type]; + if (axis === 'x') { translatedShape.moveX(goalPoint); } else if (axis === 'y') { translatedShape.moveY(goalPoint); } + i = potentialCollidingShapes.length; while (i--) { pcShape = potentialCollidingShapes[i]; position = goalPoint; - if (isAABBCollision(translatedShape.aABB, pcShape.aABB)) { //TML - Could potentially shove this back into the rectangle shape check, but I'll leave it here. - if (shapeCollision(translatedShape, pcShape)) { - collisionInfo = findAxisCollisionPosition(axis, direction, translatedShape, pcShape); - position = collisionInfo.position; - if (direction > 0) { - if (position < finalPosition) { - if (position < initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD - position = initialPoint; - } - finalPosition = position; - storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); - } - } else { - if (position > finalPosition) { - if (position > initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD - position = initialPoint; - } - finalPosition = position; - storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); + if (translatedShape.collides(pcShape)) { + collisionInfo = findACP[pcShape.type](direction, translatedShape, pcShape); + position = collisionInfo.position; + if (direction > 0) { + if (position < finalPosition) { + if (position < initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD + position = initialPoint; } + finalPosition = position; + storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); + } + } else if (position > finalPosition) { + if (position > initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD + position = initialPoint; } + finalPosition = position; + storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); } } } @@ -14231,7 +14396,6 @@ platypus.CollisionShape = (function () { k = 0, l = 0, m = 0, - checkAABBCollision = isAABBCollision, collisionType = null, softCollisionMap = null, otherEntities = null, @@ -14253,16 +14417,16 @@ platypus.CollisionShape = (function () { if (otherEntities) { k = otherEntities.length; while (k--) { - collisionFound = false; otherEntity = otherEntities[k]; - if ((otherEntity !== ent) && (checkAABBCollision(ent.getAABB(collisionType), otherEntity.getAABB(otherCollisionType)))) { + if ((otherEntity !== ent) && (ent.getAABB(collisionType).collides(otherEntity.getAABB(otherCollisionType)))) { + collisionFound = false; shapes = ent.getShapes(collisionType); otherShapes = otherEntity.getShapes(otherCollisionType); l = shapes.length; while (l--) { m = otherShapes.length; while (m--) { - if (shapeCollision(shapes[l], otherShapes[m])) { + if (shapes[l].collides(otherShapes[m])) { //TML - We're only reporting the first shape we hit even though there may be multiple that we could be hitting. message.entity = otherEntity; message.type = otherCollisionType; @@ -16721,7 +16885,7 @@ This component allows certain messages to trigger new messages at a later time. }).velocity; if (this.owner.heading !== this.heading) { - this.direction.set(this.initialVector).rotate((this.owner.heading / 180) * Math.PI); + this.direction.setVector(this.initialVector).rotate((this.owner.heading / 180) * Math.PI); this.heading = this.owner.heading; } @@ -16808,7 +16972,7 @@ This component allows certain messages to trigger new messages at a later time. } if (this.owner.heading !== this.heading) { - this.direction.set(this.initialVector).rotate((this.heading / 180) * Math.PI); + this.direction.setVector(this.initialVector).rotate((this.heading / 180) * Math.PI); this.reorient(this.heading, this.owner.heading); this.owner.heading = this.heading; } @@ -17244,7 +17408,7 @@ This component will cause the entity to move in a certain direction on colliding } if (this.justJumped) { - this.direction.set(this.vector); + this.direction.setVector(this.vector); this.justJumped = false; this.stunned = true; } @@ -17782,8 +17946,8 @@ Requires: ["../Vector.js"] } this.hitThisTick.push(other); - this.v.set(this.owner.velocity); - this.incidentVector.set(collData.direction); + this.v.setVector(this.owner.velocity); + this.incidentVector.setVector(collData.direction); magnitude = this.v.scalarProjection(this.incidentVector); if (!isNaN(magnitude)) { @@ -17791,7 +17955,7 @@ Requires: ["../Vector.js"] this.v.subtractVector(this.incidentVector); } - this.owner.velocity.set(this.v); + this.owner.velocity.setVector(this.v); }, "hit-non-static": function (collData) { var x = 0, @@ -17809,19 +17973,19 @@ Requires: ["../Vector.js"] for (x = 0; x < this.otherVelocityData.length; x++) { if (other === this.otherVelocityData[x].entity) { - this.otherV.set(this.otherVelocityData[x].velocity); + this.otherV.setVector(this.otherVelocityData[x].velocity); otherVSet = true; break; } } if (!otherVSet) { - this.otherV.set(other.velocity); + this.otherV.setVector(other.velocity); other.triggerEvent('share-velocity', this.owner); } - this.v.set(this.owner.velocity); - this.incidentVector.set(collData.direction); + this.v.setVector(this.owner.velocity); + this.incidentVector.setVector(collData.direction); relevantV = this.v.scalarProjection(this.incidentVector); @@ -17833,7 +17997,7 @@ Requires: ["../Vector.js"] this.incidentVector.scale(reboundV - relevantV); - this.owner.velocity.set(this.incidentVector); + this.owner.velocity.setVector(this.incidentVector); }, "share-velocity": function (other) { @@ -18101,17 +18265,19 @@ This component changes the (x, y) position of an object according to its current this.owner.x += (vX * resp.delta); this.owner.y += (vY * resp.delta); - if (this.state.moving !== this.moving) { - this.state.moving = this.moving; - } - if (this.state.turningLeft !== this.turningLeft) { - this.state.turningLeft = this.turningLeft; - } - if (this.state.turningRight !== this.turningRight) { - this.state.turningRight = this.turningRight; - } - if (this.owner.rotation !== this.angle) { - this.owner.rotation = this.angle; + if (this.state) { + if (this.state.moving !== this.moving) { + this.state.moving = this.moving; + } + if (this.state.turningLeft !== this.turningLeft) { + this.state.turningLeft = this.turningLeft; + } + if (this.state.turningRight !== this.turningRight) { + this.state.turningRight = this.turningRight; + } + if (this.owner.rotation !== this.angle) { + this.owner.rotation = this.angle; + } } }, "turn-right": function (state) { @@ -18162,6 +18328,12 @@ This component changes the (x, y) position of an object according to its current this.turningRight = false; } } + }, + + methods: { + destroy: function () { + this.state = null; + } } }); }()); @@ -18748,7 +18920,7 @@ Requires: ["../Vector.js"] methods: { setDestination: function (position) { - this.teleportDestination.set(position.x, position.y, this.owner.z); + this.teleportDestination.setXYZ(position.x, position.y, this.owner.z); this.destinationSet = true; }, @@ -19254,7 +19426,7 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series if (this.ready && this.enact && state) { this.ready = false; // to insure a single instance until things are reset - this.velocity.set(this.instant); + this.velocity.setVector(this.instant); if (instantSuccess) { this.owner.triggerEvent(instantSuccess); } @@ -19537,7 +19709,7 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series if (this.instant) { this.enact = false; this.instant = Vector.setUp(this.velocity); - this.velocity.set(0, 0, 0); + this.velocity.setXYZ(0, 0, 0); } if (this.orient) { // Orient vectors in case the entity is in a transformed position. @@ -20103,7 +20275,7 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series this.externalForces.addVector(velocity).subtractVector(this.lastVelocity); } - velocity.set(0, 0, 0); + velocity.setXYZ(0, 0, 0); while (i--) { m = movers[i].update(delta); @@ -20126,7 +20298,7 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series } this.clamp(velocity, delta); - this.lastVelocity.set(velocity); + this.lastVelocity.setVector(velocity); vect = Vector.setUp(velocity).multiply(delta); position.add(vect); @@ -20165,7 +20337,7 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series if (entityV) { e = Math.max(entityV.scalarProjection(direction), 0); if (e < s) { - s -= e; + s = e; } else { s = 0; } @@ -20176,17 +20348,15 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series while (i--) { if ((s < vc[i]) && (vd[i].dot(direction) > 0)) { vc[i] = s; - vd[i].set(direction); + vd[i].setVector(direction); add = false; break; } } - if(!this.aaa) {this.aaa = [];} if (add) { vc.push(s); vd.push(Vector.setUp(direction)); - this.aaa.push(entityV); } } }, @@ -20221,8 +20391,8 @@ Replicates logic for a wind-up toy: listens for a wind-up message over a series sdi = s / j; while (j--) { m = soc[j]; - v.set(direction).normalize().multiply(m.velocity.scalarProjection(direction) - sdi); - m.velocity.subtractVector(v); + v.setVector(direction).normalize().multiply(sdi - m.velocity.scalarProjection(direction)); + m.velocity.add(v); } direction.recycle(); } @@ -20793,7 +20963,7 @@ This component causes an entity to be a position on a [[NodeMap]]. This componen d = Infinity; for (i = 0; i < list.length; i++) { - m = p2.set(p1).subtractVector(list[i].position).magnitude(); + m = p2.setVector(p1).subtractVector(list[i].position).magnitude(); if (m < d) { if (excluding) { j = excluding.indexOf(list[i]); @@ -21643,13 +21813,13 @@ This component connects an entity to its parent's [[NodeMap]]. It manages naviga return vector.signedAngleTo(origin, normal); }, set: function (value) { - vector.set(origin).rotate(value); + vector.setVector(origin).rotate(value); }, enumerable: true }); if (orientation) { - if (isNaN(orientation)) { + if (typeof orientation !== 'number') { vector.set(orientation); } else { vector.rotate(orientation); @@ -22117,7 +22287,7 @@ This component connects an entity to its parent's [[NodeMap]]. It manages naviga }()), updateVector: function (vector, inverse) { - inverse.set(vector.add(inverse)); // Inverses are stored to return to the original postion, *but* also allow outside changes on the vectors to be retained. This introduces floating point errors on tweened vectors. - DDD 2/10/2016 + inverse.setVector(vector.add(inverse)); // Inverses are stored to return to the original postion, *but* also allow outside changes on the vectors to be retained. This introduces floating point errors on tweened vectors. - DDD 2/10/2016 vector.multiply(this.matrixTween); inverse.subtractVector(vector); }, @@ -22863,27 +23033,12 @@ This component is attached to entities that will appear in the game world. It se //############################################################################## /** -# COMPONENT **RenderDestroyMe** -This component will destroy the entity once an animation has finished. This is useful for explosions or similar animations where the entity is no longer needed once the animation completes. - -## Dependencies: -- [[RenderSprite]] (component on entity) - This component listens for the "animation-complete" event triggered by RenderSprite. - -### Listens for: -- **animation-complete** - On receiving this message, the component match the animation id with its animation id setting and destroy the entity if they match. - - @param animationId (string) - animation id for the animation that just finished. - -## JSON Definition: - { - "type": "RenderDestroyMe", - - "animationId": "bigExplosion" - //This or animationIds Required. String identifying the animation that should destroy this entity on its completion. - - "animationIds": ["bigExplosion", "lessBigExplosion"] - //This or animationIds Required. Array of Strings identifying the animations that should destroy this entity on their completion. - } -*/ + * This component will destroy the entity once an animation has finished. This is useful for explosions or similar animations where the entity is no longer needed once the animation completes. + * + * @namespace platypus.components + * @class RenderDestroyMe + * @uses platypus.Component + */ /*global platypus */ /*jslint plusplus:true */ (function () { @@ -22891,25 +23046,56 @@ This component will destroy the entity once an animation has finished. This is u return platypus.createComponentClass({ id: 'RenderDestroyMe', + + properties: { + /** + * This or animationIds required. This is a String identifying the animation that should destroy this entity on its completion. + * + * @property animationId + * @type String + * @default '' + */ + animationId: '', + + /** + * This or animationId required. This is an array of Strings identifying the animations that should destroy this entity on their completion. + * + * @property animationIds + * @type Array + * @default null + */ + animationIds: null + }, constructor: function (definition) { - this.animationIds = null; - - if (definition.animationId) { - this.animationIds = [definition.animationId]; - } else if (definition.animationIds) { - this.animationIds = definition.animationIds; + if (this.animationId) { + this.animationIds = Array.setUp(definition.animationId); + } else if (this.animationIds) { + this.animationIds = this.animationIds.greenSlice(); } }, events: {// These are messages that this component listens for + /** + * On receiving this message, the component matches the animation id with its animation id setting and destroys the entity if they match. + * + * @method 'animation-ended' + * @param animation {String} Animation id for the animation that just finished. + */ "animation-ended": function (animation) { - var id = animation.name; - - if (!this.animationIds || (this.animationIds.indexOf(id) >= 0)) { + if (!this.animationIds || (this.animationIds.indexOf(animation) >= 0)) { this.owner.parent.removeEntity(this.owner); } } + }, + + methods: { + destroy: function () { + if (this.animationIds) { + this.animationIds.recycle(); + delete this.animationIds; + } + } } }); }()); diff --git a/lib/platypus.min.js b/lib/platypus.min.js index 7b31b413..697067fc 100644 --- a/lib/platypus.min.js +++ b/lib/platypus.min.js @@ -6,12 +6,12 @@ * * This notice shall be included in all copies or substantial portions of the Software. */ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.pako=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],2:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":1}],3:[function(a,b,c){"use strict";function d(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=d},{}],4:[function(a,b,c){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=f,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^e[255&(a^b[h])];return-1^a}var f=d();b.exports=e},{}],6:[function(a,b,c){"use strict";function d(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=d},{}],7:[function(a,b,c){"use strict";var d=30,e=12;b.exports=function(a,b){var c,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;c=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=c.dmax,l=c.wsize,m=c.whave,n=c.wnext,o=c.window,p=c.hold,q=c.bits,r=c.lencode,s=c.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",c.mode=d;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&c.sane){a.msg="invalid distance too far back",c.mode=d;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),c.hold=p,c.bits=q}},{}],8:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(oa),b.distcode=b.distdyn=new r.Buf32(pa),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,ra)}function k(a){if(sa){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sa=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Ba,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=la;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=la;break}if(m>>>=4,n-=4,wa=(15&m)+8,0===c.wbits)c.wbits=wa;else if(wa>c.wbits){a.msg="invalid window size",c.mode=la;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Ba[2]=m>>>16&255,Ba[3]=m>>>24&255,c.check=t(c.check,Ba,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wa=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wa)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.name+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.comment+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ia;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=ba,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=la}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=la;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=la;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Ca[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,ya={bits:c.lenbits},xa=v(w,c.lens,0,19,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid code lengths set",c.mode=la;break}c.have=0,c.mode=aa;case aa:for(;c.have>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<sa)m>>>=qa,n-=qa,c.lens[c.have++]=sa;else{if(16===sa){for(za=qa+2;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,0===c.have){a.msg="invalid bit length repeat",c.mode=la;break}wa=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sa){for(za=qa+3;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=3+(7&m),m>>>=3,n-=3}else{for(za=qa+7;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=la;break}for(;q--;)c.lens[c.have++]=wa}}if(c.mode===la)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=la;break}if(c.lenbits=9,ya={bits:c.lenbits},xa=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid literal/lengths set",c.mode=la;break}if(c.distbits=6,c.distcode=c.distdyn,ya={bits:c.distbits},xa=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,ya),c.distbits=ya.bits,xa){a.msg="invalid distances set",c.mode=la;break}if(c.mode=ba,b===B)break a;case ba:c.mode=ca;case ca:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);break}for(c.back=0;Aa=c.lencode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,c.length=sa,0===ra){c.mode=ha;break}if(32&ra){c.back=-1,c.mode=V;break}if(64&ra){a.msg="invalid literal/length code",c.mode=la;break}c.extra=15&ra,c.mode=da;case da:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=ea;case ea:for(;Aa=c.distcode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,64&ra){a.msg="invalid distance code",c.mode=la;break}c.offset=sa,c.extra=15&ra,c.mode=fa;case fa:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=la;break}c.mode=ga;case ga:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=la;break}q>c.wnext?(q-=c.wnext,oa=c.wsize-q):oa=c.wnext-q,q>c.length&&(q=c.length),pa=c.window}else pa=f,oa=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pa[oa++];while(--q);0===c.length&&(c.mode=ca);break;case ha:if(0===j)break a;f[h++]=c.length,j--,c.mode=ca;break;case ia:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[c+E]]++;for(H=C,G=e;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;e>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===h||1!==G))return-1;for(Q[1]=0,D=1;e>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[c+E]&&(r[Q[b[c+E]]++]=E);if(a===h?(N=R=r,y=19):a===i?(N=k,O-=257,R=l,S-=257,y=256):(N=m,R=n,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<f||a===j&&L>g)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[c+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<f||a===j&&L>g)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":1}],10:[function(a,b,c){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(a,b,c){"use strict";function d(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=d},{}],"/lib/inflate.js":[function(a,b,c){"use strict";function d(a,b){var c=new n(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=Object.prototype.toString,n=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};n.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,n=this.options.chunkSize,o=!1;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,"string"==typeof a?l.input=h.binstring2buf(a):"[object ArrayBuffer]"===m.call(a)?l.input=new Uint8Array(a):l.input=a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(n),l.next_out=0,l.avail_out=n),c=f.inflate(l,i.Z_NO_FLUSH),c===i.Z_BUF_ERROR&&o===!0&&(c=i.Z_OK,o=!1),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&(d===i.Z_FINISH||d===i.Z_SYNC_FLUSH))&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=n-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out))),0===l.avail_in&&0===l.avail_out&&(o=!0)}while((l.avail_in>0||0===l.avail_out)&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):d===i.Z_SYNC_FLUSH?(this.onEnd(i.Z_OK),l.avail_out=0,!0):!0},n.prototype.onData=function(a){this.chunks.push(a)},n.prototype.onEnd=function(a){a===i.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=n,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate.js":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")}),this.platypus=this.platypus||{},function(){"use strict";var a=navigator.userAgent.toLowerCase(),b=a.search("edge")>-1,c=a.search("ipod")>-1,d=a.search("iphone")>-1,e=a.search("ipad")>-1,f=a.search("android")>-1,g=a.search("silk")>-1,h=c||d||e,i=h||f||g;platypus.supports={touch:"undefined"!==window.ontouchstart,edge:b,iPod:c,iPhone:d,iPad:e,safari:a.search("safari")>-1&&!b,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:f,chrome:a.search("chrome")>-1&&!b,silk:g,iOS:h,mobile:i,desktop:!i},platypus.version="0.7.3",platypus.buildDate="Fri, 19 Feb 2016 21:10:20 GMT"}(),function(){var a={enumerable:!1,value:!1,writable:!0},b={};platypus.setUpRecycle=function(c,d){var e=[],f=!!springroll.Debug;return b[d]=e,f?(c.setUp=function(){var b=null;return e.length?(b=e.pop(),b.recycled=!1):(b=Object.create(this.prototype),Object.defineProperty(b,"recycled",a)),this.apply(b,arguments),b},c.recycle=function(a){a.recycled?console.warn("WHOA! I have already been recycled!",a):(a.recycled=!0,e.push(a))}):(c.setUp=function(){var a=null;return a=e.length?e.pop():Object.create(this.prototype),this.apply(a,arguments),a},c.recycle=function(a){e.push(a)}),c.prototype.recycle=function(){c.recycle(this)},e},platypus.getObjectCaches=function(){return b}}(),function(a,b){var c=null,d=!!springroll.Debug,e=a.prototype,f={enumerable:!1,value:!1,writable:!0};e.union||b.defineProperty(e,"union",{enumerable:!1,writable:!1,value:function(a){var b=0,c=a.length;for(b=0;c>b;b++)-1===this.indexOf(a[b])&&this.push(a[b]);return this}}),e.greenSlice||b.defineProperty(e,"greenSlice",{enumerable:!1,writable:!1,value:function(){var b=a.setUp(),c=0,d=this.length;for(c=0;d>c;c++)b[c]=this[c];return b}}),e.greenSplice||b.defineProperty(e,"greenSplice",{enumerable:!1,writable:!1,value:function(a){var b=0,c=this[a],d=this.length;for(b=a+1;d>b;b++)this[b-1]=this[b];return d&&(this.length-=1),c}}),e.recycle||(c=platypus.setUpRecycle(a,"Array"),d?a.setUp=function(){var a=0,d=null;for(c.length?(d=c.pop(),d.recycled=!1):(d=[],b.defineProperty(d,"recycled",f)),a=0;a1)for(c=this.length,b-=1;c--;)this[c].recycle(b);this.length=0,a.recycle(this)}}))}(Array,Object),function(a,b){var c=a.prototype;c.greenSplit||b.defineProperty(c,"greenSplit",{enumerable:!1,writable:!1,value:function(a){var b=this,c=0,d=0,e=Array.setUp();if(a){for(d=b.indexOf(a),c=a.length;d>=0;)e.push(b.substr(0,d)),b=b.substr(d+c),d=b.indexOf(a);e.push(b)}else for(d=this.length,c=d-1;d--;)e.push(this[c-d]);return e}})}(String,Object),platypus.Data=function(){"use strict";var a=function(){var a=arguments.length,b=arguments[0],c="";if(b)if("string"==typeof b)for(a%2&&(this[a]=null,a-=1);a;)this[arguments[a-2]]=arguments[a-1],a-=2;else for(c in b)b.hasOwnProperty(c)&&(this[c]=b[c])},b=a.prototype;return platypus.setUpRecycle(a,"Data"),b.recycle=function(){var b="";for(b in this)this.hasOwnProperty(b)&&delete this[b];a.recycle(this)},a}(),platypus.Component=function(){"use strict";var a=include("platypus.Data"),b=function(a){return Array.setUp()},c=function(b,c){this.type=b,this.owner=c,this.publicMethods=a.setUp(),this.listener=a.setUp("events",Array.setUp(),"messages",Array.setUp())},d=c.prototype;return d.toString=function(){return"[Component "+this.type+"]"},d.destroy=function(){var a="";this._destroy&&this._destroy();for(a in this.publicMethods)this.publicMethods.hasOwnProperty(a)&&this.removeMethod(a);this.publicMethods.recycle(),this.removeEventListeners(),this.listener.events.recycle(),this.listener.messages.recycle(),this.listener.recycle()},d.removeEventListeners=function(a){var b=0,c=null,d=null;if(a)for(b=0;b=0;c--)d[c]!==a||b&&e[c]!==b||(this.owner.off(a,e[c]),this.listener.events.greenSplice(c),this.listener.messages.greenSplice(c))},d.removeMethod=function(a){this.owner[a]?delete this.owner[a]:console.warn(this.owner.type+': Entity does not have a method called "'+a+'".'),delete this.publicMethods[a]},c.getAssetList=b,c.getLateAssetList=b,c}(),platypus.Messenger=function(){"use strict";var a=include("springroll.EventDispatcher"),b=function(){a.call(this),this.loopCheck=Array.setUp()},c=!!springroll.Debug,d=extend(b,a);return d.toString=function(){return"[Messenger Object]"},d._trigger=d.trigger,d.trigger=function(a,b,c){var d=0,e=0;if("string"==typeof a)return this.triggerEvent(a,b,c);if(Array.isArray(a)){for(d=0;d1&&(f=Array.prototype.greenSlice.call(arguments),f.greenSplice(0)),b=c=e.length;c--;)d=e[c],d._eventDispatcherOnce&&(delete d._eventDispatcherOnce,this.off(a,d)),d.apply(this,f);f&&f.recycle(),e.recycle()}return b},c&&(d._triggerEvent=d.triggerEvent,d.triggerEvent=function(a,b,c){var d=0,e=c||b&&b.debug,f=0,g=0;if(e||this.debug){for(d=0;d5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}return this.loopCheck.push(a),window.performance&&window.performance.mark("a"),g=this._triggerEvent(a,b,c),window.performance&&(window.performance.mark("b"),window.performance.measure(this.type+":"+a,"a","b")),this.loopCheck.length=this.loopCheck.length-1,e&&(g?console.log('Entity "'+this.type+'": Event "'+a+'" has '+g+" subscriber"+(g>1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b)),g}return this._triggerEvent(a,b,c)}),d.getMessageIds=function(){return Object.keys(this._listeners)},d.eventDispatcherDestroy=d.destroy,d.destroy=function(){this.loopCheck.recycle(),this.eventDispatcherDestroy()},b}(),platypus.Entity=function(){"use strict";var a=include("platypus.Data"),b={},c=function(a,b){platypus.game.settings.debug&&console.warn(a,b)},d=function(d,e){var f=0,g=null,h=a.setUp(d),i=h.components,j=a.setUp(h.properties),k=a.setUp(e),l=a.setUp(k.properties),m=Array.setUp(),n=Array.setUp();if(platypus.Messenger.call(this),this.components=Array.setUp(),this.type=h.id||"none",this.id=k.id||l.id,this.id||(b[this.type]||(b[this.type]=0),this.id=this.type+"-"+b[this.type],b[this.type]+=1),this.setProperty(j),this.setProperty(l),this.on("set-property",function(a){this.setProperty(a)}.bind(this)),this.state=a.setUp(this.state),this.lastState=a.setUp(),this.trigger=this.triggerEvent=function(a,b){m.push(a),n.push(b)},i)for(f=0;f5&&".json"===a.src.substring(a.src.length-5).toLowerCase())d(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(f in a)a.hasOwnProperty(f)&&(g+=1);if(g)for(f in a)a.hasOwnProperty(f)&&i(a,f,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void c(a,function(a){"object"==typeof a?d(a,b):b(a)})}b(a)},e=function(c,e,f){var g=function(c){var d="",e="",g=this.app.states||{};platypus.game=this,this.currentScene=null,this.settings=c,this.stage=this.app.display.stage;for(e in c.scenes)c.scenes.hasOwnProperty(e)&&(d=c.scenes[e].id=c.scenes[e].id||e,g[d]=new b(new a,c.scenes[e]));this.app.states||(this.app.states=g),f&&f(this),window.getEntityById=function(a){return this.getEntityById(a)}.bind(this),window.getEntitiesByType=function(a){return this.getEntitiesByType(a)}.bind(this),window.getVisibleSprites=function(a,b){var c=0;if(b=b||Array.setUp(),a=a||this.stage,!a.texture&&a.visible){for(c=0;cc;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 platypus.Vector.setUp(this).normalize()},b.getInverse=function(){return platypus.Vector.setUp(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this: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 platypus.Vector.setUp(this).cross(a)},b.rotate=function(a,b){var c=b,d=null,e=Math.cos(a),f=Math.sin(a),g=1-e,h=0,i=0,j=0,k=platypus.Vector.setUp();return c?"x"===c?c=k.set(1,0,0):"y"===c?c=k.set(0,1,0):"z"===c&&(c=k.set(0,0,1)):c=k.set(0,0,1),h=c.x,i=c.y,j=c.z,d=Array.setUp(Array.setUp(e+h*h*g,h*i*g-j*f,h*j*g+i*f),Array.setUp(i*h*g+j*f,e+i*i*g,i*j*g-h*f),Array.setUp(j*h*g-i*f,j*i*g+h*f,e+j*j*g)),this.multiply(d),k.recycle(),d.recycle(2),this},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a)){for(e=this.matrix.greenSlice(),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];e.recycle()}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,e=this.matrix,f=a.matrix;for(d=b||e.length;d--;)c+=e[d]*(f[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit(),d=0;return b.magnitude()&&c.magnitude()?d=Math.acos(b.dot(c)):(console.warn("Vector: Attempted to find the angle of a zero-length vector."),d=void 0),b.recycle(),c.recycle(),d},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit(),e=c.getCrossProduct(d),f=0;return f=e.dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d)),c.recycle(),d.recycle(),e.recycle(),f},b.scalarProjection=function(b){var c=null,d=0;return"number"==typeof b?this.magnitude(2)*Math.cos(b):(c=a.setUp(b).normalize(),d=this.dot(c),c.recycle(),d)},b.copy=function(){return platypus.Vector.setUp(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]=platypus.Vector.setUp(),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)},b.getIntersectionArea=function(a){var b=Math.max,c=Math.min,d=c(this.bottom,a.bottom)-b(this.top,a.top),e=c(this.right,a.right)-b(this.left,a.left),f=d*e;return f},platypus.setUpRecycle(a,"AABB"),a}(),platypus.ActionState=function(){"use strict";var a=include("platypus.Data"),b=function(b,c,d){this.event=b,this.trigger=d,this.active=!1,this.wasActive=!1,this.valid=!0,this.wasValid=!0,this.states=a.setUp(c),this.inputs=Array.setUp(),this.stateSummary=a.setUp("pressed",!1,"released",!1,"triggered",!1)},c=function(a){return a},d=b.prototype;return d.update=function(a){var b=this.stateSummary;return this.valid=this.isStateValid(a),this.active=this.inputs.some(c),b.pressed=this.valid&&this.active,b.released=this.wasActive&&(!this.valid&&this.wasValid||this.valid&&!this.active),b.triggered=this.valid&&this.active&&!this.wasActive,this.wasValid=this.valid,this.wasActive=this.active,b.pressed||b.released||b.triggered},d.resolve=function(){this.trigger(this.event,this.stateSummary)},d.isStateValid=function(a){var b="",c=this.states;for(b in c)if(c.hasOwnProperty(b)&&a.hasOwnProperty(b)&&c[b]!==a[b])return!1;return!0},platypus.setUpRecycle(b,"ActionState"),d.recycle=function(){this.states.recycle(),this.stateSummary.recycle(),this.inputs.recycle(),b.recycle(this)},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=platypus.Vector.setUp(h),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.set(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.set(0,0,0),this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=Array.setUp(new platypus.CollisionData,new platypus.CollisionData),this.yData=Array.setUp(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=include("platypus.Vector"),b=function(b,c,d){var e=c.regX,f=c.regY,g=0,h=0;switch(this.owner=b,this.collisionType=d,this.width=c.width||2*c.radius||0,this.height=c.height||2*c.radius||0,this.radius=c.radius||0,"number"!=typeof e&&(e=this.width/2),"number"!=typeof f&&(f=this.height/2),a.assign(this,"offset","offsetX","offsetY"),this.offsetX=c.offsetX||this.width/2-e,this.offsetY=c.offsetY||this.height/2-f,a.assign(this,"position","x","y"),b?(this.x=b.x+this.offsetX,this.y=b.y+this.offsetY):(this.x=c.x+this.offsetX,this.y=c.y+this.offsetY),this.type=c.type||"rectangle",this.subType="",this.aABB=void 0,this.type){case"circle":g=h=2*this.radius;break;case"rectangle":g=this.width,h=this.height}a.assign(this,"size","width","height"),this.width=g,this.height=h,this.aABB=new platypus.AABB(this.x,this.y,g,h)},c=b.prototype;return c.update=function(a,b){var c=a+this.offsetX,d=b+this.offsetY;this.x=c,this.y=d,this.aABB.move(c,d)},c.moveX=function(a){this.x=a,this.aABB.moveX(a)},c.moveY=function(a){this.y=a,this.aABB.moveY(a)},c.getAABB=function(){return this.aABB},c.setXWithEntityX=function(a){this.x=a+this.offsetX,this.aABB.moveX(this.x)},c.setYWithEntityY=function(a){this.y=a+this.offsetY,this.aABB.moveY(this.y)},c.destroy=function(){this.aABB=void 0},c.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)},b}(),function(){"use strict";var a=include("platypus.Component"),b="",c=0,d=function(a,b,c){Object.defineProperty(b,a,{get:function(){return c[a]},set:function(b){c[a]=b},enumerable:!0})},e=function(a,b){return function(){a.apply(this,arguments),b.apply(this,arguments)}};platypus.components={},platypus.createComponentClass=function(f,g){var h=function(b,e){var h="",i="",j="",k="";if(a.call(this,f.id,b),g&&g.call(this),f.properties)for(h in f.properties)f.properties.hasOwnProperty(h)&&("undefined"!=typeof e[h]?this[h]=e[h]:"undefined"!=typeof this.owner[h]?this[h]=this.owner[h]:this[h]=f.properties[h]);if(f.publicProperties)for(h in f.publicProperties)f.publicProperties.hasOwnProperty(h)&&(d(h,this,b),"undefined"!=typeof e[h]?this[h]=e[h]:"undefined"!=typeof this.owner[h]?this[h]=this.owner[h]:this[h]=f.publicProperties[h]);if(f.events){c-=1;for(i in f.events)if(f.events.hasOwnProperty(i)&&(this.addEventListener(i,f.events[i],c),e.aliases))for(k in e.aliases)e.aliases.hasOwnProperty(k)&&e.aliases[k]===i&&this.addEventListener(k,f.events[i],c)}if(f.publicMethods)for(i in f.publicMethods)if(f.publicMethods.hasOwnProperty(i)){if(j=i,e.aliases)for(k in e.aliases)e.aliases.hasOwnProperty(k)&&e.aliases[k]===i&&(j=k);this.addMethod(j,f.publicMethods[i])}this.constructor&&this.constructor(e)},i=null,j=h.prototype;if(g){j=extend(h,g);for(b in a.prototype)j[b]?j[b]=e(j[b],a.prototype[b]):j[b]=a.prototype[b]}else j=extend(h,a);if(j.constructor=f.constructor,f.methods)for(i in f.methods)f.methods.hasOwnProperty(i)&&("destroy"===i?j._destroy=f.methods[i]:j[i]=f.methods[i]);if(f.publicMethods)for(i in f.publicMethods)f.publicMethods.hasOwnProperty(i)&&(j[i]=f.publicMethods[i]);h.getAssetList=f.getAssetList||a.getAssetList,h.getLateAssetList=f.getLateAssetList||a.getLateAssetList,platypus.components[f.id]=h}}(),function(){"use strict";var a=include("springroll.Application"),b={},c={},d=/[\[\]{},-]/g,e=function(a,b){var c=0,d=a.width,e=a.height,f=a.regX||0,g=a.regY||0,h=0,i=0,j=0,k=0,l=Array.setUp();for(c=0;c=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},f=function(b){var d=0,e=Array.setUp(),f=null,g=a.instance.assetManager.cache,h=c,i=null;for(d=0;dd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},n.destroy=function(){var a="";if(this.stop(),PIXI.Sprite.prototype.destroy.call(this),this.cacheId&&(b[this.cacheId].viable-=1,b[this.cacheId].viable<=0)){b[this.cacheId].textures.recycle();for(a in b[this.cacheId].animations)b[this.cacheId].animations.hasOwnProperty(a)&&b[this.cacheId].animations[a].frames.recycle();delete b[this.cacheId]}},m.destroyBaseTextures=function(){var a=c,b="";for(b in a)a.hasOwnProperty(b)&&(a[b].destroy(),delete a[b])}}(),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.Application"),b=include("springroll.ApplicationPlugin"),c=null,d=new b,e=null,f=function(){var b=function(a,b){return Math.floor(204*a/b)},c=function(a,c){var d=0,e=0,f="color: #ffffff; padding:3px 0; border-radius: 6px;",g=0,h=0,i=0,j=null;return c&&(j=c.greenSplit(".")),c&&3===j.length?(g=parseInt(j[0],10),h=parseInt(j[1],10),i=parseInt(j[2],10)):(g=a.charCodeAt(0)||0,h=a.charCodeAt(1)||0,i=a.charCodeAt(2)||0,e=Math.min(g,h,i),g-=e,h-=e,i-=e),j&&j.recycle(),d=Math.max(g,h,i,1),f+" background: rgb("+b(g,d)+","+b(h,d)+","+b(i,d)+");"};return function(b,d){var e=d.options,f=e.author?"by "+e.author:"",g=d.name||document.title||"",h=a.version||"(?)",i="Platypus "+platypus.version,j="Pixi.js "+PIXI.VERSION,k="SpringRoll "+h,l=e.version||"(?)";e.hideHello||("(?)"!==l&&(g+=" "+l),platypus.supports.firefox||platypus.supports.chrome?console.log("\n%c "+g+" %c "+f+" \n\nUsing %c "+k+" %c %c "+j+" %c %c "+i+" %c\n\n",c(g,l),"",c(k,h),"",c(j,PIXI.VERSION),"",c(i,platypus.version),""):console.log('--- "'+g+'" '+f+" - Using "+k+", "+j+", and "+i+" ---")),b.debug&&console.log("Game config loaded.",b)}}(),g=function(a){var b=null,c=null,d=null,e={};for(b in a)if(a[b].id)e[b]=a[b];else{c=g(a[b]);for(d in c)e[d]=c[d]}return e},h=function(a){var b="";for(b in a)a.hasOwnProperty(b)&&(a[b].id=b)};PIXI.utils._saidHello=!0,d.setup=function(){var a="",b=document.getElementsByName("author"),c=this.options;b.length&&(a=b[0].getAttribute("content")||""),c.add("author",a,!0),c.add("hideHello",!1,!0)},d.preload=function(a){var b=this.config.platypus||this.config,d=null,i={delta:0};b?(this.options.debug&&(b.debug=!0),f(b,this),b.entities=g(b.entities),b.spriteSheets&&h(b.spriteSheets),d=this.platypus=new platypus.Game(b,this),c=function(a){i.delta=a,d.tick(i)},this.on("update",c,320),e=function(a){d.currentScene&&d.currentScene.triggerOnChildren("resize",a)},this.on("resize",e)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},d.teardown=function(){this.platypus&&(this.off("update",c),this.off("resize",e),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(b){this.target=this.owner.target||null,this.offset=a.setUp(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=null,c=0,d=!1;this.target&&this.chasing&&(b=a.setUp(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)),b.recycle()),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,this.offset.recycle()}}})}(),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.greenSplice(b));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",e):(d[c].stop(),d.greenSplice(c)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.greenSplice(b))},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.greenSplice(0)},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.greenSplice(0),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",e):(d[c].stop(),d.greenSplice(c)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.greenSplice(b))},onComplete:function(a){this.owner.destroyed||(this.removeClip(a.audio),this.owner.triggerEvent("clip-complete"))},removeClip:function(a){var b=this.activeAudioClips.indexOf(a);b>=0&&this.activeAudioClips.greenSplice(b)},destroy:function(){this.stopAudio(),this.activeAudioClips.recycle(),this.checkStates&&this.checkStates.recycle()}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a,b){return a.time-b.time},c=function(a,c,d){return function(){var e=0,f=d.getElapsed();for(e=0;ethis.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},destroy:function(){this.parentContainer.removeChild(this.container),this.parentContainer=null,this.container=null,this.mouseVector&&(this.mouseVector.recycle(),this.mouseWorldOrigin.recycle()),this.boundingBox.recycle(),this.viewport.recycle(),this.worldCamera.viewport.recycle(),this.worldCamera.recycle(),this.message.viewport.recycle(),this.message.recycle(),this.forwardFollower.recycle(),this.lastFollow.recycle()}}})}(),function(){"use strict";var a=include("platypus.Data");return platypus.createComponentClass({id:"CameraFollowMe",properties:{camera:{},mode:"forward",pause:!1},constructor:function(b){this.pauseGame=this.pause&&this.camera.time?{time:this.camera.time}:null,this.camera=a.setUp("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(b){var c=null;c=b?a.setUp("entity",this.owner,"mode",b.mode||this.camera.mode,"top",b.top||this.camera.top,"left",b.left||this.camera.left,"offsetX",b.offsetX||this.camera.offsetX,"offsetY",b.offsetY||this.camera.offsetY,"width",b.width||this.camera.width,"height",b.height||this.camera.height,"time",b.time||this.camera.time):a.setUp(this.camera),this.pauseGame&&(this.owner.parent.triggerEvent("pause-logic",this.pauseGame),this.owner.parent.triggerEvent("pause-render",this.pauseGame)),this.owner.parent.triggerEvent("follow",c),c.recycle()}},methods:{destroy:function(){this.camera.recycle()}}})}(),function(){"use strict";var a=include("platypus.AABB"),b=include("platypus.CollisionShape"),c=include("platypus.Data"),d=include("platypus.Vector"),e=function(){var a=function(a,b,c,d){d.myType===b&&d.hitType===c&&this.owner.triggerEvent(a,d)},b=function(a,b,c,d){var e=0;if(d.myType===b&&d.hitType===c)for(e=0;e0&&a.bottom?this.owner.triggerEvent(a.bottom,d):0>f&&a.top&&this.owner.triggerEvent(a.top,d),e>0&&a.right?this.owner.triggerEvent(a.right,d):0>e&&a.left&&this.owner.triggerEvent(a.left,d),a.all&&this.owner.triggerEvent(a.all,d))};return function(d,e,f,g){return"string"==typeof e?a.bind(d,e,d.collisionType,f):Array.isArray(e)?b.bind(d,e,d.collisionType,f):c.bind(d,e,d.collisionType,f)}}(),f=function(){var b=function(a,b,c){var d="";if(c)return b[c]?b[c].getAABB():null;a.reset();for(d in b)b.hasOwnProperty(d)&&a.include(b[d].getAABB());return a},e=function(a,b){var c=a[b];return c?c.getPreviousAABB():null},f=function(a,b){var c=a[b];return c?c.getShapes():null},g=function(a,b){var c=a[b];return c?c.getPrevShapes():null},h=function(a,b,c){var d="";for(d in a)a.hasOwnProperty(d)&&a[d].prepareCollision(b,c)},i=function(){var a=function(a,b,c){var e=0,f=b.stuck;f&&(e=a.magnitude(),b.thatShape.owner&&Math.abs(f)>1&&(f*=.05),(!e||e>Math.abs(f))&&(b.vector.x&&(a.x=f,a.y=0),b.vector.y&&(a.x=0,a.y=f),c.stuckWith&&c.stuckWith.recycle(),c.stuckWith=d.setUp(b.thatShape.x,b.thatShape.y)))},b={position:null,unstick:null};return function(c,e){var f=b,g=null;e.xCount&&(g=d.setUp(0,0,0),a(g,e.getXEntry(0),this)),e.yCount&&(g=g||d.setUp(0,0,0),a(g,e.getYEntry(0),this)),f.position=c,f.unstick=g,this.triggerEvent("relocate-entity",f),g&&g.recycle()}}(),j=function(a,b){var c="";for(c in a)a.hasOwnProperty(c)&&a[c].movePreviousX(b)},k=function(){return this.collisionTypes},l=function(){return this.solidCollisionMap},m=function(){return this.getAABB()},n=function(){return this.getPreviousAABB()},o=function(){return this.getShapes()},p=function(){return this.getPrevShapes()},q=function(a,b){this.prepareCollision(a,b)},r=function(a){this.movePreviousX(a)};return function(d,s){var t=s.collisionFunctions;t||(t=s.collisionFunctions=c.setUp(),s.aabb=a.setUp(),s.getAABB=b.bind(s,s.aabb,t),s.getPreviousAABB=e.bind(s,t),s.getShapes=f.bind(s,t),s.getPrevShapes=g.bind(s,t),s.prepareCollision=h.bind(s,t),s.relocateEntity=i.bind(s),s.movePreviousX=j.bind(s,t),s.getCollisionTypes=k.bind(s),s.getSolidCollisions=l.bind(s)),t[d.collisionType]=c.setUp("getAABB",m.bind(d),"getPreviousAABB",n.bind(d),"getShapes",o.bind(d),"getPrevShapes",p.bind(d),"prepareCollision",q.bind(d),"movePreviousX",r.bind(d))}}();return platypus.createComponentClass({id:"CollisionBasic",properties:{collisionType:"none",shapeType:"rectangle",ignoreOrientation:!1,regX:null,regY:null,width:0,height:0,radius:0,softCollisions:null,solidCollisions:null,margin:0,shapes:null},publicProperties:{immobile:!1,bullet:!1,jumpThrough:!1},constructor:function(c){var g=0,h="",i=null,j=this.regX,k=this.regY,l=this.width,m=this.height,n=this.radius,o=0,p=0,q=0,r=0;for("number"==typeof this.margin?(o=this.margin,p=this.margin,q=this.margin,r=this.margin):(o=this.margin.left||0,p=this.margin.right||0,q=this.margin.top||0,r=this.margin.bottom||0),null===j&&(j=this.regX=l/2),null===k&&(k=this.regY=m/2),d.assign(this.owner,"position","x","y","z"),d.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=a.setUp(),this.prevAABB=a.setUp(),this.shapes?i=this.shapes:"circle"===this.shapeType?(n=n||((l||0)+(m||0))/4,i=[{regX:(isNaN(j)?n:j)-(p-o)/2,regY:(isNaN(k)?n:k)-(r-q)/2,radius:n,type:this.shapeType}]):i=[{regX:(isNaN(j)?(l||0)/2:j)+o,regY:(isNaN(k)?(m||0)/2:k)+q,points:c.points,width:(l||0)+o+p,height:(m||0)+q+r,type:this.shapeType}],this.owner.collisionTypes=this.owner.collisionTypes||Array.setUp(),this.owner.collisionTypes.push(this.collisionType),this.shapes=Array.setUp(),this.prevShapes=Array.setUp(),this.entities=void 0,g=0;g=0&&this.owner.collisionTypes.greenSplice(b),this.active=!1),this.owner.collisionTypes.length&&this.owner.parent.triggerEvent("add-collision-entity",this.owner)},"relocate-entity":function(a){var b=a.unstick,c=0,d=0,e=0,f=0,g=this.aabb,h=this.owner,i=null,j=this.shapes;for(b&&(c=b.magnitude()),this.move&&(this.move.recycle(),this.move=null),a.relative?h.position.set(h.previousPosition).add(a.position):h.position.set(a.position),this.stuck&&(c>0?h.position.add(b):this.stuck=!1),e=h.x,f=h.y,g.reset(),d=j.length;d--;)i=j[d],i.update(e,f),g.include(i.aABB);h.previousPosition.set(h.position),c>0&&(this.stuck||(this.stuck=!0),this.move=h.stuckWith.copy().add(-e,-f).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;b=0&&this.owner.collisionTypes.greenSplice(b),this.owner.solidCollisionMap[this.collisionType]&&(this.owner.solidCollisionMap[this.collisionType].recycle(),delete this.owner.solidCollisionMap[this.collisionType]),this.owner.softCollisionMap[this.collisionType]&&(this.owner.softCollisionMap[this.collisionType].recycle(),delete this.owner.softCollisionMap[this.collisionType]),a[this.collisionType].recycle(),delete a[this.collisionType],this.shapes.recycle(),this.prevShapes.recycle(),delete this.entities,this.owner.collisionTypes.length?this.owner.parent.triggerEvent("add-collision-entity",this.owner):(a.recycle(),this.owner.aabb.recycle())}}})}(),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=include("platypus.AABB"),b=include("platypus.Vector");return platypus.createComponentClass({id:"CollisionGroup",constructor:function(c){this.solidEntities=Array.setUp(),this.collisionTypes=Array.setUp(),this.shapes=Array.setUp(),this.prevShapes=Array.setUp(),this.terrain=void 0,this.aabb=a.setUp(this.owner.x,this.owner.y),this.prevAABB=a.setUp(this.owner.x,this.owner.y),this.filteredAABB=a.setUp(),b.assign(this.owner,"position","x","y","z"),b.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,b=0,c=null;for(a=0;a=0&&this.solidEntities.greenSplice(b));this.updateAABB()}},getCollisionTypes:function(){var a=0,b=null,c=this.collisionTypes;for(c.length=0,a=0;aa?(a=Math.abs(a)-2,b[a]):a},e=function(a,b,c,d,e){var f=0,g=0,h=Array.setUp();for(g=0;e>g;g++)for(h[g]=Array.setUp(),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=Array.setUp();for(g=0;e>g;g++)for(h[g]=Array.setUp(),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=Array.setUp(-5,-4,-3,-2);for(i=0;f>i;i++)for(j=0;g>j;j++)a[b+i][c+j]=d(h[i][j],k);return h.recycle(2),k.recycle(),a},"diagonal-inverse":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-3,-2,-5,-4);for(i=0;f>i;i++)for(j=0;g>j;j++)a[b+f-i-1][c+g-j-1]=d(h[i][j],k);return h.recycle(2),k.recycle(),a},horizontal:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-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 h.recycle(2),k.recycle(),a},vertical:function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-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 h.recycle(2),k.recycle(),a},"rotate-90":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-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 h.recycle(2),k.recycle(),a},"rotate-180":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-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 h.recycle(2),k.recycle(),a},"rotate-270":function(a,b,c,f,g){var h=e(a,b,c,f,g),i=0,j=0,k=Array.setUp(-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 h.recycle(2),k.recycle(),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 i.recycle(2),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){this.switches.push(a)};return platypus.createComponentClass({id:"ComponentSwitcher",properties:{componentMap:null},constructor:function(b){var c="";if(this.switches=Array.setUp(),this.componentMap)for(c in this.componentMap)this.componentMap.hasOwnProperty(c)&&this.addEventListener(c,a.bind(this,c))},events:{"prepare-logic":function(){var a=0;if(this.switches.length){for(a=0;a-1;c--)e[c].type===f[b]&&d.removeComponent(e[c]);else for(b=e.length-1;b>-1;b--)e[b].type===f&&d.removeComponent(e[b]);if(g)if(Array.isArray(g))for(b=0;b=0?(this.removeChildEventListeners(a),this.entities.greenSplice(b),this.triggerEventOnChildren("peer-entity-removed",a),this.owner.triggerEvent("child-entity-removed",a),a.destroy(),a.parent=null,a):!1},triggerEventOnChildren:function(a,b,c){return this.destroyed?0:(this._listeners[a]||this.addNewPrivateEvent(a),this.triggerEvent(a,b,c))},triggerOnChildren:function(a,b,c){return this.destroyed?0:(this._listeners[a]||this.addNewPrivateEvent(a),this.trigger(a,b,c))}},getAssetList:function(a,c,d){var e=0,f=Array.setUp(),g=Array.setUp(),h=null;for(a.entities&&g.union(a.entities),c&&c.entities?g.union(c.entities):d&&d.entities&&g.union(d.entities),e=0;ee&&(f=g-f),f):f},e=[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"]],f=["left-button","middle-button","right-button"],g=function(b){for(var c=b.greenSplit(","),d=c.length,e=a.setUp(),f="";d--;)f=c[d],f&&("!"===f.substr(0,1)?e[f.substr(1)]=!1:e[f]=!0);return c.recycle(),e},h=function(a,b){this.paused||this.owner.trigger(a,b)},i=function(a,b,c){!this.paused&&c[a]&&this.owner.trigger(b,c)};return platypus.createComponentClass({id:"EntityController",properties:{controlMap:{},stateMaps:{}},publicProperties:{paused:!1},constructor:function(b){var c="",d=null;if(this.actions=a.setUp(),this.stateMaps)for(c in this.stateMaps)this.stateMaps.hasOwnProperty(c)&&(d=g(c),this.addMap(this.stateMaps[c],d),d.recycle());this.addMap(this.controlMap),b.joystick&&(this.joystick=a.setUp("directions",b.joystick.directions||4,"handleEdge",b.joystick.handleEdge||!1,"innerRadius",b.joystick.innerRadius||0,"outerRadius",b.joystick.outerRadius||1/0))},events:{"handle-controller":function(){var a=0,b="",c=Array.setUp();for(b in this.actions)this.actions.hasOwnProperty(b)&&this.actions[b].update(this.owner.state)&&c.push(this.actions[b]);for(a=0;athis.joystick.outerRadius||f=b.right||a.right<=b.left||a.top>=b.bottom||a.bottom<=b.top)},i=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.aABB,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(g=0&&this.entitiesByType[d[c]].greenSplice(b));a.immobile||(c=this.allEntities.indexOf(a),c>=0&&this.allEntities.greenSplice(c)),this.updateLiveList=!0}},checkCamera:function(a,b){var c=2*a.buffer,d=0,e=0,f="",i=null,j=null,k=null,l=null,m=null,n=null,o=null,p=a.width+c,q=a.height+c,r=a.left+p/2,s=a.top+q/2,t=null,u=null,v=h,w=this.cameraLogicAABB,x=this.cameraCollisionAABB,y=null,z=!1;if(this.updateLiveList||!w.matches(r,s,p,q)){for(w.setAll(r,s,p,q),this.updateLiveList=!1,j=this.allEntities,k=this.allEntitiesLive,k.length=0,m=this.solidEntitiesLive,m.length=0,l=this.softEntitiesLive,l.length=0,n=this.nonColliders,n.length=0,o=this.groupsLive,o.length=0,d=j.length;d--;)if(z=!1,u=j[d],u.alwaysOn||u.checkCollision||v(u.getAABB(),w)){if(u.checkCollision=!1,k[k.length]=u,y=u.collisionTypes,u!==this.owner)for(e=0;e1){for(e.reset(),this.checkSolidEntityCollision(f,f.collisionGroup,e),b=e.xCount;b--;)g=e.getXEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,g.direction,0,"solid",g.vector);for(b=e.yCount;b--;)g=e.getYEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,0,g.direction,"solid",g.vector)}}}(),checkSolidCollisions:function(){var a=function(a,b,c,d,e,g,h,i){var j=f;j.entity=b,j.myType=c,j.type=d,j.x=e,j.y=g,j.direction=i,j.hitType=h,a.triggerEvent("hit-by-"+d,j),b&&(j.entity=a,j.type=c,j.myType=d,j.x=-e,j.y=-g,j.direction=i.getInverse(),j.hitType=h,b.triggerEvent("hit-by-"+c,j),j.direction.recycle())};return function(){for(var b=0,c=this.solidEntitiesLive,d=c.length,f=null,g=null;d--;){for(f=c[d],e.reset(),this.checkSolidEntityCollision(f,f,e),b=e.xCount;b--;)g=e.getXEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,g.direction,0,"solid",g.vector);for(b=e.yCount;b--;)g=e.getYEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,0,g.direction,"solid",g.vector)}}}(),checkSolidEntityCollision:function(a,b,c){var e=Math.abs,f=0,g=null,h=a.x-a.previousX,i=a.y-a.previousY,j=null,k=0,l=0,m=1/0,n=1/0,o=b.getCollisionTypes(),p=o.length,q=!1,r=Math.min;if(b.getSolidEntities&&(q=b.getSolidEntities()),g=d.setUp(a.position),h||i){if(a.bullet){for(;p--;)j=b.getAABB(o[p]),m=r(m,j.width),n=r(n,j.height);f=Math.ceil(Math.max(e(h)/m,e(i)/n)),f=r(f,100),k=h/f,l=i/f}else f=1,k=h,l=i;for(;f--;){if(b.prepareCollision(a.previousX+k,a.previousY+l),g.set(a.position),g=this.processCollisionStep(a,b,q,c,g,k,l,o),g.x===a.previousX&&g.y===a.previousY){b.relocateEntity(g,c);break}b.relocateEntity(g,c)}}g.recycle()},processCollisionStep:function(){var b=a.setUp(),c=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=e.length;f--;)if(c===e[f])return!1;return!0};return function(a,d,e,f,g,i,j,k){for(var l=k.length,m=0,n=0,o=0,p=!1,q=Array.setUp(),r=null,s=null,t=null,u=null,v=null,w="",x=null,y=this.entitiesByTypeLive,z=null,A=this.terrain,B=d.getSolidCollisions(),C=null,D=b;l--;)for(q[l]=r=Array.setUp(),u=k[l],s=d.getPreviousAABB(u),t=d.getAABB(u),D.set(t),D.include(s),C=B[u],m=C.length;m--;)if(w=C[m],z=y[w]){for(n=z.length;n--;)if(v=z[n],c(a,s,v,w,e)&&h(D,v.getAABB(w))){for(x=v.getShapes(w),o=x.length;o--;)r.push(x[o]);p=!0}}else if(A&&"tiles"===w)for(x=A.getTileShapes(D,s),n=x.length;n--;)r.push(x[n]),p=!0;return p&&(g=this.resolveCollisionPosition(a,d,g,q,f,k,i,j)),q.recycle(2),g}}(),resolveCollisionPosition:function(){var a=new b;return function(b,c,d,e,f,g,h,i){var j=0,k=a;if(0!==h)for(j=g.length;j--;)k.clear(),this.findMinAxisMovement(b,c,g[j],"x",e[j],k),k.occurred&&f.tryToAddX(k);if(f.xCount>0?(k.copy(f.getXEntry(0)),d.x=b.previousX+k.deltaMovement*k.direction):d.x=b.x,c.movePreviousX(d.x),0!==i)for(j=g.length;j--;)k.clear(),this.findMinAxisMovement(b,c,g[j],"y",e[j],k),k.occurred&&f.tryToAddY(k);return f.yCount>0?(k.copy(f.getYEntry(0)),d.y=b.previousY+k.deltaMovement*k.direction):d.y=b.y,d}}(),findMinAxisMovement:function(){var a=new b;return function(b,c,d,e,f,g){for(var h=c.getShapes(d),i=c.getPrevShapes(d),j=a,k=h.length;k--;)j.clear(),this.findMinShapeMovementCollision(i[k],h[k],e,f,j),j.occurred&&(!g.occurred||j.deltaMovement=j.top&&d.y<=j.bottom?j.halfWidth+d.radius:(h.y=c(d.y,e.y,j.halfHeight),i=j.halfWidth+b(h.y,d.radius),f===d?(h.x=-c(d.x-g*i,e.x,j.halfWidth)/2,h.y=-h.y):h.x=c(d.x,e.x-g*i,j.halfWidth)/2,h.normalize(),i):"y"===a?d.x>=j.left&&d.x<=j.right?j.halfHeight+d.radius:(h.x=c(d.x,e.x,j.halfWidth), -i=j.halfHeight+b(h.x,d.radius),f===d?(h.x=-h.x,h.y=-c(d.y-g*i,e.y,j.halfWidth)/2):h.y=c(d.y,e.y-g*i,j.halfWidth)/2,h.normalize(),i):void 0},g=function(a,c,d){return"x"===a?b(c.y-d.y,c.radius+d.radius):"y"===a?b(c.x-d.x,c.radius+d.radius):void 0};return function(b,c,d,h){var i=a,j=i.contactVector;if("rectangle"===d.type){if("rectangle"===h.type)return i.position=h[b]-c*e(b,d.aABB,h.aABB),j.x=0,j.y=0,j[b]=c,i;if("circle"===h.type)return j.x=0,j.y=0,j[b]=c,i.position=h[b]-c*f(b,h,d,d,c,j),i}else if("circle"===d.type){if("rectangle"===h.type)return j.x=0,j.y=0,j[b]=c,i.position=h[b]-c*f(b,d,h,d,c,j),i;if("circle"===h.type)return i.position=h[b]-c*g(b,d,h),j.x=h.x-d.x,j.y=h.y-d.y,j[b]=h[b]-i.position,j.normalize(),i}}}();return function(c,d,e,f,g){var j=f.length,k=c[e],l=d[e],m=c,n=l>k?1:-1,o=l,p=null,q=null,r=l;if(k!==l)for("x"===e?m.moveX(l):"y"===e&&m.moveY(l);j--;)p=f[j],o=l,h(m.aABB,p.aABB)&&i(m,p)&&(q=b(e,n,m,p),o=q.position,n>0?r>o&&(k>o&&(o=k),r=o,a(g,n,r,k,d,p,q.contactVector)):o>r&&(o>k&&(o=k),r=o,a(g,n,r,k,d,p,q.contactVector)))}}(),checkSoftCollisions:function(){var a=function(a){this.triggerEvent("hit-by-"+a.type,a)};return function(b){for(var c=this.softEntitiesLive,d=this.getWorldEntities(),e=null,f=c.length,g=a;f--;)e=c[f],this.checkEntityForSoftCollisions(e,d,g.bind(e))}}(),checkEntityForSoftCollisions:function(a,b,c){var d=null,e=f,g=a.collisionTypes.length,j=0,k=0,l=0,m=0,n=h,o=null,p=null,q=null,r=null,s=null,t=null,u=!1;for(e.x=0,e.y=0;g--;)for(o=a.collisionTypes[g],p=a.softCollisionMap[o],j=p.length;j--;)if(r=p[j],q=b[r])for(k=q.length;k--;)if(u=!1,d=q[k],d!==a&&n(a.getAABB(o),d.getAABB(r)))for(s=a.getShapes(o),t=d.getShapes(r),l=s.length;l--;){for(m=t.length;m--;)if(i(s[l],t[m])){e.entity=d,e.type=r,e.myType=o,e.shape=t[m],e.hitType="soft",c(e),u=!0;break}if(u)break}},destroy:function(){var a="";this.groupsLive.recycle(),this.nonColliders.recycle(),this.allEntities.recycle(),this.allEntitiesLive.recycle(),this.softEntitiesLive.recycle(),this.solidEntitiesLive.recycle(),this.relocationMessage.position.recycle();for(a in this.entitiesByType)this.entitiesByType.hasOwnProperty(a)&&this.entitiesByType[a].recycle();for(a in this.entitiesByTypeLive)this.entitiesByTypeLive.hasOwnProperty(a)&&this.entitiesByTypeLive[a].recycle();this.cameraLogicAABB.recycle(),this.cameraCollisionAABB.recycle()}},publicMethods:{getWorldEntities:function(){return this.entitiesByTypeLive},getWorldTerrain:function(){return this.terrain},getEntityCollisions:function(a,b){var c=Array.setUp();return this.checkEntityForSoftCollisions(a,b||this.entitiesByTypeLive,function(a){var b="",d={};for(b in a)a.hasOwnProperty(b)&&(d[b]=a[b]);c.push(d)}),c}}})}(),function(){"use strict";var a={kc0:"unknown",kc8:"backspace",kc9:"tab",kc12:"numpad-5-shift",kc13:"enter",kc16:"shift",kc17:"ctrl",kc18:"alt",kc19:"pause",kc20:"caps-lock",kc27:"esc",kc32:"space",kc33:"page-up",kc34:"page-down",kc35:"end",kc36:"home",kc37:"left-arrow",kc38:"up-arrow",kc39:"right-arrow",kc40:"down-arrow",kc42:"numpad-multiply",kc43:"numpad-add",kc44:"print-screen",kc45:"insert",kc46:"delete",kc47:"numpad-division",kc48:"0",kc49:"1",kc50:"2",kc51:"3",kc52:"4",kc53:"5",kc54:"6",kc55:"7",kc56:"8",kc57:"9",kc59:"semicolon",kc61:"equals",kc65:"a",kc66:"b",kc67:"c",kc68:"d",kc69:"e",kc70:"f",kc71:"g",kc72:"h",kc73:"i",kc74:"j",kc75:"k",kc76:"l",kc77:"m",kc78:"n",kc79:"o",kc80:"p",kc81:"q",kc82:"r",kc83:"s",kc84:"t",kc85:"u",kc86:"v",kc87:"w",kc88:"x",kc89:"y",kc90:"z",kc91:"left-windows-start",kc92:"right-windows-start",kc93:"windows-menu",kc96:"back-quote",kc106:"numpad-multiply",kc107:"numpad-add",kc109:"numpad-minus",kc110:"numpad-period",kc111:"numpad-division",kc112:"f1",kc113:"f2",kc114:"f3",kc115:"f4",kc116:"f5",kc117:"f6",kc118:"f7",kc119:"f8",kc120:"f9",kc121:"f10",kc122:"f11",kc123:"f12",kc144:"num-lock",kc145:"scroll-lock",kc186:"semicolon",kc187:"equals",kc188:"comma",kc189:"hyphen",kc190:"period",kc191:"forward-slash",kc192:"back-quote",kc219:"open-bracket",kc220:"back-slash",kc221:"close-bracket",kc222:"quote"};return platypus.createComponentClass({id:"HandlerController",constructor:function(a){this.callbackKeyUp=null,this.callbackKeyDown=null,platypus.game.settings.debug?(this.callbackKeyDown=function(a){this.keyDown(a)}.bind(this),this.callbackKeyUp=function(a){this.keyUp(a)}.bind(this)):(this.callbackKeyDown=function(a){this.keyDown(a),a.preventDefault()}.bind(this),this.callbackKeyUp=function(a){this.keyUp(a),a.preventDefault()}.bind(this)),window.addEventListener("keydown",this.callbackKeyDown,!0),window.addEventListener("keyup",this.callbackKeyUp,!0)},events:{tick:function(a){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-controller",a)}},methods:{keyDown:function(b){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("key:"+(a["kc"+b.keyCode]||"key-code-"+b.keyCode)+":down",b)},keyUp:function(b){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("key:"+(a["kc"+b.keyCode]||"key-code-"+b.keyCode)+":up",b)},destroy:function(){window.removeEventListener("keydown",this.callbackKeyDown),window.removeEventListener("keyup",this.callbackKeyUp)}}})}(),function(){"use strict";var a=function(a,b){var c=0;for(b.length=0,c=a.length-1;c>-1;c--)b.push(a[c])},b=function(a,b,c){var d=0,e=null;for(b.length=0,d=a.length-1;d>-1;d--)e=a[d],(e.alwaysOn||"undefined"==typeof e.x||e.x>=c.left-c.buffer&&e.x<=c.left+c.width+c.buffer&&e.y>=c.top-c.buffer&&e.y<=c.top+c.height+c.buffer)&&b.push(e)},c=function(a){var b=null,c=!1;for(b in a.state)a.state[b]!==a.lastState[b]&&(a.lastState[b]=a.state[b],c=!0);return c},d=function(a,b,c){return"handle-logic"===a||"handle-post-collision-logic"===a||"prepare-logic"===a};return platypus.createComponentClass({id:"HandlerLogic",properties:{alwaysOn:!1},publicProperties:{buffer:-1,stepLength:5,maxStepsPerTick:100,timeMultiplier:1},constructor:function(c){this.entities=Array.setUp(),this.activeEntities=Array.setUp(),this.alwaysOn?(this.updateList=a,this.camera=null):(this.updateList=b,this.camera={left:0,top:0,width:0,height:0,buffer:this.buffer,active:!1}),this.paused=0,this.leftoverTime=0,this.message={delta:this.stepLength,tick:null,camera:this.camera,movers:this.activeEntities}},events:{"child-entity-added":function(a){a.getMessageIds().some(d)&&this.entities.push(a)},"child-entity-removed":function(a){var b=this.entities.indexOf(a);b>=0&&this.entities.greenSplice(b)},"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&&(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)},tick:function(a){var b=0,d=0,e=null,f=this.message,g=c,h=this.activeEntities,i=this.stepLength;for(this.leftoverTime+=a.delta*this.timeMultiplier,d=Math.floor(this.leftoverTime/i)||1,f.delta=i,this.leftoverTime=Math.max(this.leftoverTime-d*i,0),f.tick=a,this.updateList(this.entities,h,this.camera),d=Math.min(d,this.maxStepsPerTick);d--;)if(this.paused>0&&(this.paused-=i,this.paused<0&&(this.paused=0)),!this.paused){for(this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-ai",f),b=h.length;b--;)e=h[b],e.triggerEvent("prepare-logic",f),e.triggerEvent("handle-logic",f),e.triggerEvent("handle-movement",f);if(b=h.length,this.owner.triggerEvent("check-collision-group",f))for(;b--;)e=h[b],e.triggerEvent("handle-post-collision-logic",f),g(e)&&e.triggerEvent("state-changed",e.state);else for(;b--;)e=h[b],g(e)&&e.triggerEvent("state-changed",e.state)}}},methods:{destroy:function(){this.entities.recycle(),this.activeEntities.recycle()}}})}(),function(){"use strict";var a=include("platypus.Vector");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.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;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,pixiEvent: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.triggerEvent("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(){this.container.mouseTarget?(this.container.visible=!1,this.container.removeDisplayObject=function(){this.container=null}.bind(this)):this.container=null}},publicMethods:{windowToWorld:function(b,c,d){var e=d||a.setUp();return e.x=b.x*this.worldPerWindowUnitWidth,e.y=b.y*this.worldPerWindowUnitHeight,c!==!1&&(e.x-=this.viewport.x*this.worldPerWindowUnitWidth,e.y-=this.viewport.y*this.worldPerWindowUnitHeight),e},worldToWindow:function(b,c,d){var e=d||a.setUp();return e.x=b.x*this.windowPerWorldUnitWidth,e.y=b.y*this.windowPerWorldUnitHeight,c!==!1&&(e.x+=this.viewport.x,e.y+=this.viewport.y),e}}})}(),function(){"use strict";var a=function(a,b,c,d,e,f){var g=0,h=0,i=0,j=a.greenSlice();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="",g=a.greenSlice(),h=null;for(e=0;e0?this.piOverTwo:this.v[1]<0?-this.piOverTwo:this.angle:(h=Math.atan(this.v[1]/this.v[0]),this.v[0]<0&&(h=b+h)),this.v[0]>=0?this.v[0]=e(this.v[0],this.maxVelocity*d(h)):this.v[0]=f(this.v[0],this.maxVelocity*d(h)),this.v[1]>=0?this.v[1]=e(this.v[1],this.maxVelocity*c(h)):this.v[1]=f(this.v[1],this.maxVelocity*c(h)),this.owner.x+=this.v[0],this.owner.y+=this.v[1],this.owner.rotation=h*(180/b)+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}},methods:{destroy:function(){this.v.recycle()}}})}(),function(){"use strict";var a=include("platypus.Entity"),b=0;return platypus.createComponentClass({id:"LogicAttachment",properties:{attachState:"attached",attachment:"",offsetX:0,offsetY:0,offsetZ:.01},publicProperties:{},constructor:function(a){this.state=this.owner.state,this.owner.linkId||(this.owner.linkId="attachment-link-"+b,b+=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}},getAssetList:function(b,c,d){var e=b.attachment||c.attachment||d.attachment;return e?a.getAssetList({type:e}):Array.setUp()}})}(),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(a){platypus.supports.mobile&&"touchstart"!==a.event.type||this.toggle||this.updateState("pressed")},pressup:function(a){platypus.supports.mobile&&"touchend"!==a.event.type&&"touchcancel"!==a.event.type||(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){var b=this.disabled===this.owner.state.disabled;this.last!==b&&(this.last=b)},mousedown:function(a){this.owner.state.down=!0,this.owner.state.disabled||this.useOnce&&this.used||this.onPress&&(this.owner.trigger(this.onPress),a.pixiEvent.stopPropagation(),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),a.pixiEvent.stopPropagation()),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.triggerEvent("add-collision-entity",this.owner)||(this.owner.addComponent(new platypus.components.CollisionGroup(this.owner,{})),this.owner.triggerEvent("add-collision-entity",this.owner))},"carry-me":function(a){this.owner.triggerEvent("add-collision-entity",a.entity)},"release-me":function(a){this.owner.triggerEvent("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.greenSplice(b),this.queue.greenSplice(b))}};return platypus.createComponentClass({id:"LogicDelayMessage",constructor:function(c){var d="";if(this.queueTimes=Array.setUp(),this.queue=Array.setUp(),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){for(var b=this.queue.length;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.greenSplice(b),this.queue.greenSplice(b))))}},methods:{destroy:function(){this.queueTimes.recycle(),this.queue.recycle()}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDestroyMe",properties:{delay:0,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]=!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",speed:.3},constructor:function(a){var d=this.state=this.owner.state;"number"==typeof this.speed&&(this.speed=[this.speed,0,0]),this.initialVector=platypus.Vector.setUp(this.speed),this.reorient=c[this.axis],this.reorient||(this.reorient=b),this.moving=d.moving=!1,this.left=d.left=!1,this.right=d.right=!1,this.up=d.up=!1,this.down=d.down=!1,this.upLeft=!1,this.upRight=!1,this.downLeft=!1,this.downRight=!1,this.heading=0,this.owner.heading=this.owner.heading||0},events:{"component-added":function(a){if(a===this){if(!this.owner.addMover)return void console.warn('The "LogicDirectionalMovement" component requires a "Mover" component to function correctly.');this.direction=this.owner.addMover({velocity:this.speed,drag:0,friction:0,stopOnCollision:!1,orient:!1,aliases:{moving:"control-velocity"}}).velocity,this.owner.heading!==this.heading&&(this.direction.set(this.initialVector).rotate(this.owner.heading/180*Math.PI),this.heading=this.owner.heading),this.owner.triggerEvent("moving",this.moving)}},"handle-logic":function(){var a=this.up||this.upLeft||this.downLeft,b=this.upLeft||this.up&&this.left,c=this.left||this.upLeft||this.downLeft,d=this.downLeft||this.down&&this.left,e=this.down||this.downLeft||this.downRight,f=this.downRight||this.down&&this.right,g=this.right||this.upRight||this.downRight,h=this.upRight||this.up&&this.right;if(c&&g||a&&e)this.moving=!1;else if(b)this.moving=!0,this.heading=225;else if(h)this.moving=!0,this.heading=315;else if(d)this.moving=!0,this.heading=135;else if(f)this.moving=!0,this.heading=45;else if(c)this.moving=!0,this.heading=180;else if(g)this.moving=!0,this.heading=0;else if(a)this.moving=!0,this.heading=270;else if(e)this.moving=!0,this.heading=90;else switch(this.moving=!1,this.heading){case 270:a=!0;break;case 90:e=!0;break;case 180:c=!0;break;case 225:a=!0,c=!0;break;case 315:a=!0,g=!0;break;case 135:e=!0,c=!0;break;case 45:e=!0,g=!0;break;case 0:default:g=!0}this.owner.heading!==this.heading&&(this.direction.set(this.initialVector).rotate(this.heading/180*Math.PI),this.reorient(this.heading,this.owner.heading),this.owner.heading=this.heading),this.state.moving!==this.moving&&(this.owner.triggerEvent("moving",this.moving),this.state.moving=this.moving),this.state.up!==a&&(this.state.up=a),this.state.right!==g&&(this.state.right=g),this.state.down!==e&&(this.state.down=e),this.state.left!==c&&(this.state.left=c)},"go-down":a("down"),"go-south":a("down"),"go-down-left":a("downLeft"),"go-southwest":a("downLeft"),"go-left":a("left"),"go-west":a("left"),"go-up-left":a("upLeft"),"go-northwest":a("upLeft"),"go-up":a("up"),"go-north":a("up"),"go-up-right":a("upRight"),"go-northeast":a("upRight"),"go-right":a("right"),"go-east":a("right"),"go-down-right":a("downRight"),"go-southeast":a("downRight"),stop:function(a){a&&a.pressed===!1||(this.left=!1,this.right=!1,this.up=!1,this.down=!1,this.upLeft=!1,this.upRight=!1,this.downLeft=!1,this.downRight=!1)},face:function(){var a={up:270,north:270,down:90,south:90,left:180,west:180,right:0,east:0,"up-left":225,northwest:225,"up-right":315,northeast:315,"down-left":135,southwest:135,"down-right":45,southeast:45};return function(b){this.heading=a[b]||0}}(),accelerate:function(a){this.initialVector.normalize().multiply(a),this.direction.normalize().multiply(a)}},methods:{destroy:function(){this.initialVector.recycle()}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDragDrop",constructor:function(a){this.nextX=this.owner.x,this.nextY=this.owner.y,this.grabOffsetX=0,this.grabOffsetY=0,this.owner.state.dragging=!1,this.owner.state.noDrop=!1,this.tryDrop=!1,this.hitSomething=!1},events:{"handle-logic":function(a){this.owner.x=this.nextX,this.owner.y=this.nextY,this.owner.state.noDrop=!1},"handle-post-collision-logic":function(a){this.tryDrop?(this.tryDrop=!1,this.hitSomething?(this.dropFailed=!1,this.owner.state.noDrop=!0,this.owner.state.dragging=!0):(this.owner.state.noDrop=!1,this.owner.state.dragging=!1)):this.hitSomething&&(this.owner.state.noDrop=!0),this.hitSomething=!1},mousedown:function(a){this.grabOffsetX=a.x-this.owner.x,this.grabOffsetY=a.y-this.owner.y,this.owner.state.dragging=!0},mouseup:function(a){this.tryDrop=!0},pressmove:function(a){this.nextX=a.x-this.grabOffsetX,this.nextY=a.y-this.grabOffsetY},"no-drop":function(a){this.hitSomething=!0}},methods:{destroy:function(){this.owner.state.dragging=null,this.owner.state.noDrop=null}},publicMethods:{}})}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"LogicImpactLaunch",properties:{accelerationX:-.3,accelerationY:-.8,flipX:!0,flipY:!1},constructor:function(a){this.stunState=a.state||"stunned",this.flipX=this.flipX?-1:1,this.flipY=this.flipY?-1:1,this.justJumped=!1,this.stunned=!1,this.state=this.owner.state,this.state.impact=!1,this.state[this.stunState]=!1},events:{"component-added":function(b){if(b===this){if(!this.owner.addMover)return void console.warn('The "LogicDirectionalMovement" component requires a "Mover" component to function correctly.');this.direction=this.owner.addMover({velocity:[0,0,0],orient:!1}).velocity,this.vector=a.setUp()}},"handle-logic":function(){this.state.impact!==this.justJumped&&(this.state.impact=this.justJumped),this.state[this.stunState]!==this.stunned&&(this.state[this.stunState]=this.stunned),this.justJumped&&(this.direction.set(this.vector),this.justJumped=!1,this.stunned=!0)},"impact-launch":function(a){var b=a.x,c=a.y;a.entity&&(b=a.entity.x-this.owner.x,c=a.entity.y-this.owner.y),this.stunned||(this.justJumped=!0,b>=0?this.vector.x=this.accelerationX:0>b&&(this.vector.x=this.accelerationX*this.flipX),c>=0?this.vector.y=this.accelerationY:0>c&&(this.vector.y=this.accelerationY*this.flipY))},"hit-solid":function(a){this.stunned&&a.y>0&&(this.direction.x=0,this.direction.y=0,this.stunned=!1)}},methods:{destroy:function(){this.vector.recycle()}}})}(),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.dX=this.dist*Math.cos(this.ang),this.dY=this.dist*Math.sin(this.ang),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=this.period,c=a.delta;this.time+=c,this.time>b&&(this.time=this.time%b),this.offset=this.time/b*2*Math.PI,this.owner.x=this.originX+Math.sin(this.offset+this.startPos)*this.dX,this.owner.y=this.originY+Math.sin(this.offset+this.startPos)*this.dY}}})}(),function(){"use strict";var a={down:!0};return platypus.createComponentClass({id:"LogicPortable",constructor:function(b){this.portableDirections=b.portableDirections||a,this.carrier=this.lastCarrier=null,this.message={entity:this.owner}},events:{"handle-logic":function(a){var b=this.message;this.carrierConnected?(this.carrier!==this.lastCarrier&&(this.lastCarrier&&this.lastCarrier.triggerEvent("release-me",b),this.carrier.triggerEvent("carry-me",b)),this.carrierConnected=!1):this.carrier&&(this.carrier.triggerEvent("release-me",b), -this.carrier=null),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}},methods:{destroy:function(){this.pushers.recycle()}}})}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"LogicRebounder",constructor:function(b){platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.owner.mass=this.owner.mass||b.mass||1,this.elasticity=b.elasticity||.8,this.v=a.setUp(0,0,0),this.incidentVector=a.setUp(0,0,0),this.staticCollisionOccurred=!1,this.nonStaticCollisionOccurred=!1,this.hitThisTick=Array.setUp(),this.otherV=a.setUp(0,0,0),this.otherVelocityData=Array.setUp()},events:{"handle-logic":function(a){var b=0;for(this.hitThisTick.length=0,b=0;b=0)){for(this.hitThisTick.push(c),b=0;bb;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))))}},methods:{destroy:function(){this.regions.recycle(),this.usedRegions.recycle()}},getAssetList:function(b,c,d){var e=b.spawn||c.spawn||d.spawn;return e?a.getAssetList({type:e}):Array.setUp()}})}(),function(){"use strict";var a=Math.cos,b=Math.sin,c=function(b,c){return b*a(c)},d=function(a,c){return a*b(c)};return platypus.createComponentClass({id:"LogicRotationalMovement",constructor:function(a){this.speed=a.speed||.3,this.magnitude=0,this.degree=a.degree||1,this.angle=a.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,e=0;this.turningRight&&(this.angle+=this.degree*a.delta/15),this.turningLeft&&(this.angle-=this.degree*a.delta/15),this.moving&&(b=c(this.magnitude,this.angle),e=d(this.magnitude,this.angle)),this.owner.x+=b*a.delta,this.owner.y+=e*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.rotation!==this.angle&&(this.owner.rotation=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";var a=include("platypus.Entity");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;d0&&a.entity.triggerEvent("teleport",this.destination);break;case"down":a.y>0&&a.entity.triggerEvent("teleport",this.destination);break;case"left":a.x<0&&a.entity.triggerEvent("teleport",this.destination);break;default:a.entity.triggerEvent("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.triggerEvent("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*a.delta,this.owner.triggerEvent("racing")):!this.blocked&&this.left&&this.state.left?(this.owner.x-=this.speed*a.delta,this.owner.triggerEvent("racing")):(this.racing=!1,this.owner.triggerEvent("stopped-racing")):this.winding?((this.right&&this.state.right||this.left&&this.state.left)&&(this.windProgress+=a.delta),this.owner.triggerEvent("winding")):this.windProgress&&(this.windProgress>this.windTime&&(this.racing=!0),this.windProgress=0,this.owner.triggerEvent("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.triggerEvent("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.triggerEvent("blocked",a))}},methods:{destroy:function(){this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1}}})}(),function(){"use strict";var a=include("platypus.Vector"),b=function(a,b,c,d){platypus.game.settings.debug&&console.warn('"'+a+'" Motion: The "'+b+'" property has been deprecated. Use "aliases": {"'+c+'": "'+d+'"} instead.')},c=function(){return!0},d=function(a,d){var e=c,f=c,g=c,h=a.owner.state,i=d.controlState,j=d.instantState,k=d.instantSuccess;i&&(a.accelerator?e=function(){return h[i]}:f=function(){return h[i]}),d.event&&(b(a.owner.type,"event",d.event,"control-"+(a.accelerator?"acceleration":"velocity")),a.addEventListener(d.event,function(a){this.active=a&&a.pressed!==!1})),a.instant||d.instantEvent||j||d.instantBegin||d.instantEnd?(j&&(g=function(){return h[j]}),a.instant=!0,(d.instantEvent||d.instantBegin||d.instantEnd)&&(d.instantEvent&&(b(a.owner.type,"instantEvent",d.instantEvent,"instant-motion"),a.addEventListener(d.instantEvent,function(a){this.enact=a&&a.pressed!==!1})),d.instantBegin&&(b(a.owner.type,"instantBegin",d.instantBegin,"instant-begin"),a.addEventListener(d.instantBegin,function(){this.enact=!0})),d.instantEnd&&(b(a.owner.type,"instantEnd",d.instantEnd,"instant-end"),a.addEventListener(d.instantEnd,function(){this.enact=!1}))),a.update=function(a){var b=g(),c=f();if(this.vector&&(this.accelerator?this.activeAcceleration=this.active:this.activeVelocity=this.active),this.activeVelocity){if(this.enact&&!c&&(this.ready=!1),this.ready&&this.enact&&b)this.ready=!1,this.velocity.set(this.instant),k&&this.owner.triggerEvent(k);else if(this.ready||this.enact&&b){if(c)return null}else this.ready=!0,this.decay();return this.velocity}return null}):a.update=function(a){return this.vector&&(this.accelerator?this.activeAcceleration=this.active:this.activeVelocity=this.active),this.activeVelocity&&f()?(this.activeAcceleration&&e()&&this.move(a),this.velocity):null}};return platypus.createComponentClass({id:"Motion",properties:{orient:!0,acceleration:0,accelerator:!1,active:!0,activeAcceleration:!0,activeVelocity:!0,maxMagnitude:1/0,event:"",controlState:"",instantEvent:"",instantBegin:"",instantEnd:"",instant:!1,instantState:"",instantSuccess:"",instantDecay:null,vector:0,velocity:0,stopOnCollision:!0,drag:-1,friction:-1},constructor:function(b){var c=this.vector;this.acceleration||(this.activeAcceleration=!1),this.acceleration=a.setUp(this.acceleration),this.velocity=a.setUp(this.velocity),this.triggered=!1,this.ready=!0,"number"==typeof this.instantDecay?this.capMagnitude=this.velocity.magnitude()*this.instantDecay:this.capMagnitude=-1,d(this,b),this.vector&&(this.accelerator&&!this.instant?(this.activeAcceleration=!0,platypus.game.settings.debug&&console.warn('"'+this.owner.type+'" Motion: "vector" and "accelerator" are deprecated. Set "acceleration" to "'+this.vector.toString()+'" instead.'),Object.defineProperty(this,"vector",{get:function(){return this.acceleration}.bind(this),set:function(a){this.acceleration=a}.bind(this)})):(this.activeAcceleration=!1,platypus.game.settings.debug&&console.warn('"'+this.owner.type+'" Motion: "vector" and "accelerator" are deprecated. Set "velocity" to "'+this.vector.toString()+'" instead.'),Object.defineProperty(this,"vector",{get:function(){return this.velocity}.bind(this),set:function(a){this.velocity=a}.bind(this)})),this.vector.set(c)),this.instant&&(this.enact=!1,this.instant=a.setUp(this.velocity),this.velocity.set(0,0,0)),this.orient&&(this.owner.triggerEvent("orient-vector",this.velocity),this.owner.triggerEvent("orient-vector",this.acceleration))},events:{"control-velocity":function(a){this.activeVelocity=a&&a.pressed!==!1},"stop-velocity":function(){this.activeVelocity=!1},"start-velocity":function(){this.activeVelocity=!0},"control-acceleration":function(a){this.activeAcceleration=a&&a.pressed!==!1},"stop-acceleration":function(){this.activeAcceleration=!1},"start-acceleration":function(){this.activeAcceleration=!0},"instant-motion":function(a){this.enact=a&&a.triggered!==!1},"instant-begin":function(){this.enact=!0},"instant-end":function(){this.enact=!1},"set-vector":function(a){this.vector.set(a),"number"==typeof this.instantDecay?this.capMagnitude=this.vector.magnitude()*this.instantDecay:this.capMagnitude=-1,platypus.game.settings.debug&&!this.setVectorWarning&&(this.setVectorWarning=!0,this.accelerator?console.warn('"'+this.owner.type+'" Motion: The "set-vector" message is deprecated. Trigger "set-motion" with a {"acceleration": '+JSON.stringify(a)+"} message instead."):console.warn('"'+this.owner.type+'" Motion: The "set-vector" message is deprecated. Trigger "set-motion" with a {"velocity": '+JSON.stringify(a)+"} message instead."))},"set-motion":function(a){a.acceleration&&this.acceleration.set(a.acceleration),a.velocity&&(this.velocity.set(a.velocity),"number"==typeof this.instantDecay?this.capMagnitude=this.velocity.magnitude()*this.instantDecay:this.capMagnitude=-1),"number"==typeof a.maxMagnitude&&(this.maxMagnitude=a.maxMagnitude)}},methods:{move:function(b){var c=a.setUp(this.acceleration).multiply(b);return this.velocity.add(c),c.recycle(),this.velocity.magnitude()>this.maxMagnitude&&this.velocity.normalize().multiply(this.maxMagnitude),this.velocity},decay:function(){this.capMagnitude>=0&&this.velocity.magnitude()>this.capMagnitude&&this.velocity.normalize().multiply(this.capMagnitude)},destroy:function(){this.orient&&(this.owner.triggerEvent("remove-vector",this.acceleration),this.owner.triggerEvent("remove-vector",this.velocity)),this.acceleration.recycle(),this.velocity.recycle(),this.instant&&this.instant.recycle()}},publicMethods:{}})}(),function(){"use strict";var a=include("platypus.Vector"),b=a.setUp(),c=function(a,b,c,d){return a&&b!==c?c>b?Math.min(b+a*d,c):Math.max(b-a*d,c):b},d=function(a,b){var d=this.maxMagnitudeInterim=c(this.maxMagnitudeDelta,this.maxMagnitudeInterim,this.maxMagnitude,b);a.magnitude()>d&&a.normalize().multiply(d)},e=function(a,b){var d=this.maxMagnitude,e=this.maxMagnitudeDelta,f=this.maxMagnitudeInterim;f.up=c(e,f.up,d.up,b),f.right=c(e,f.right,d.right,b),f.down=c(e,f.down,d.down,b),f.left=c(e,f.left,d.left,b),a.x>0?a.x>f.right&&(a.x=f.right):a.x<0&&a.x<-f.left&&(a.x=-f.left),a.y>0?a.y>f.down&&(a.y=f.down):a.y<0&&a.y<-f.up&&(a.y=-f.up)};return platypus.createComponentClass({id:"Mover",properties:{ground:[0,1]},publicProperties:{movers:[],gravity:0,jump:0,speed:0,drag:.01,friction:.06,maxMagnitude:1/0,maxMagnitudeDelta:0,reorientVelocities:!0},constructor:function(b){var c=1/0,f=this.maxMagnitude;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.lastVelocity=a.setUp(this.velocity),this.collision=null,this.pause=!1,this.moversCopy=this.movers,this.movers=Array.setUp(),this.velocityChanges=Array.setUp(),this.velocityDirections=Array.setUp(),this.ground=a.setUp(this.ground),Object.defineProperty(this.owner,"maxMagnitude",{get:function(){return c},set:function(a){"number"==typeof a?(this.clamp=d,c=a,this.maxMagnitudeDelta||(this.maxMagnitudeInterim=a)):(this.clamp=e,"number"==typeof c&&(c={up:c,right:c,down:c,left:c}),"number"==typeof a.up&&(c.up=a.up),"number"==typeof a.right&&(c.right=a.right),"number"==typeof a.down&&(c.down=a.down),"number"==typeof a.left&&(c.left=a.left),"number"==typeof this.maxMagnitudeInterim?this.maxMagnitudeDelta?this.maxMagnitudeInterim={up:this.maxMagnitudeInterim,right:this.maxMagnitudeInterim,down:this.maxMagnitudeInterim,left:this.maxMagnitudeInterim}:this.maxMagnitudeInterim={up:c.up,right:c.right,down:c.down,left:c.left}:this.maxMagnitudeDelta||(this.maxMagnitudeInterim.up=c.up,this.maxMagnitudeInterim.right=c.right,this.maxMagnitudeInterim.down=c.down,this.maxMagnitudeInterim.left=c.left))}.bind(this)}),this.maxMagnitudeInterim=0,this.maxMagnitude=f},events:{"component-added":function(a){"Motion"===a.type&&this.movers.push(a)},"component-removed":function(a){var b=0;"Motion"===a.type&&(b=this.movers.indexOf(a),b>=0&&this.movers.greenSplice(b))},load:function(){var a=0,b=this.moversCopy;for(delete this.moversCopy,a=0;a0&&(this.grounded=!0),c=this.velocity.scalarProjection(f),c>0){for(e?(d=Math.max(e.scalarProjection(f),0),c>d?c-=d:c=0):c=0;j--;)if(c0){h[j]=c,i[j].set(f),g=!1;break}this.aaa||(this.aaa=[]),g&&(h.push(c),i.push(a.setUp(f)),this.aaa.push(e))}},"handle-post-collision-logic":function(){var a=null,c=this.movers,d=this.velocityChanges,e=this.velocityDirections,f=d.length,g=c.length,h=null,i=0,j=0,k=null,l=b;if(f){for(k=Array.setUp();g--;)h=c[g],h.stopOnCollision&&k.push(h);for(;f--;){for(a=e[f],i=d[f],g=k.length,j=i/g;g--;)h=k[g],l.set(a).normalize().multiply(h.velocity.scalarProjection(a)-j),h.velocity.subtractVector(l);a.recycle()}d.length=0,e.length=0}},"set-mover":function(a){"number"==typeof a.maxMagnitudeDelta&&(this.maxMagnitudeDelta=a.maxMagnitudeDelta),a.maxMagnitude&&(this.maxMagnitude=a.maxMagnitude)},"pause-movement":function(){this.paused=!0},"unpause-movement":function(){this.paused=!1},"orientation-updated":function(a){this.reorientVelocities||this.lastVelocity.multiply(a)}},methods:{destroy:function(){var a=0,b=this.maxMagnitude;for(a=this.movers.length-1;a>=0;a--)this.removeMover(this.movers[a]);this.movers.recycle(),this.ground.recycle(),this.lastVelocity.recycle(),this.velocityChanges.recycle(),this.velocityDirections.recycle(),delete this.owner.maxMagnitude,this.owner.maxMagnitude=b}},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=Array.setUp(),this.edgesContain=this.owner.edgesContain=Array.setUp(),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.greenSplice(c),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))}},methods:{addNode:function(a){this.map.push(a),this.nodes[a.id]=a},destroy:function(){var a=0;for(a=0;ai){if(d&&(f=d.indexOf(j[e]),f>=0))break;l=i,k=j[e]}return g.recycle(),h.recycle(),k}}})}(),function(){"use strict";var a=function(a,b,c){return function(d){var e=b.getNode(a);return this.isPassable(e)?(this.destinationNodes.length=0,this.destinationNodes.push(e),this.node?this.onEdge(e):this.distance=0,this.progress=0,this.setState("going-"+c),!0):!1}},b=function(a,b){var c=b.x-a.x,d=b.y-a.y,e=b.z-a.z;return Math.sqrt(c*c+d*d+e*e)},c=function(a,b,c,d){var e=b.x-a.x,f=b.y-a.y,g=0;return a.rotation&&b.rotation?(e=(a.rotation+180)%360,f=(b.rotation+180)%360,(e*(1-d)+f*d+180)%360):c?(g=Math.acos(e/c),0>f&&(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=0;c=this.distance?(g=this.destinationNodes[0],f-=this.distance-this.progress,this.progress=0,this.destinationNodes.greenSplice(0),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.distance,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?(this.lag=e.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(e,i)):this.lag=0:this.setPath(e,i):e.blocked&&(this.blocked=!0),j.recycle())}}(),"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(e.neighbors.hasOwnProperty(b)&&(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?(this.lag=c.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(c),g=!0):this.lag=0:(this.setPath(c),g=!0):c.blocked&&(this.blocked=!0),f.recycle()),g}}(),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,c=1;ci.shortestPath&&(k=i),l=!1));return k.blocked=m&&l,k},setPath:function(a,b){a.nodes[0]===this.node&&a.nodes.greenSplice(0),this.destinationNodes.recycle(),this.destinationNodes=a.nodes.greenSlice(),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")},destroy:function(){this.destinationNodes.recycle()}}})}(),function(){"use strict";var a=include("platypus.Data"),b=include("platypus.Vector"),c=b.setUp(0,0,1),d=b.setUp(1,0,0),e={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]]},f=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 e=function(a,e){var h=b.setUp(1,0,0),i=a.owner,j=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1));return Object.defineProperty(i,"orientationMatrix",{get:function(){return f(a.matrixTween,a.matrix,g(j)),j},enumerable:!0}),delete i.orientation,Object.defineProperty(i,"orientation",{get:function(){return h.signedAngleTo(d,c)},set:function(a){h.set(d).rotate(a)},enumerable:!0}),e&&(isNaN(e)?h.set(e):h.rotate(e)),h};return function(b){this.loadedOrientationMatrix=this.orientationMatrix,this.matrix=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1)),this.matrixTween=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1)),this.relocationMessage=a.setUp("position",null),this.vectors=Array.setUp(),this.inverses=Array.setUp(),this.tweens=Array.setUp(),this.orientationVector=e(this,this.orientation),this.owner.triggerEvent("orient-vector",this.orientationVector)}}(),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=this.tweens.length,c=a.delta,d=this.owner.state,e=null,f=null,h=this.relocationMessage;if(b){for(e=Array.setUp(),d.reorienting=!0,g(this.matrixTween);b--;)this.updateTween(this.tweens[b],c)&&e.push(this.tweens.greenSplice(b));for(b=this.vectors.length;b--;)this.updateVector(this.vectors[b],this.inverses[b]);for(b=e.length;b--;)f=e[b],this.transform(f.endMatrix),f.anchor&&(f.offset.multiply(f.endMatrix).addVector(f.anchor),h.position=f.offset,this.owner.triggerEvent("relocate-entity",h),f.recycleOffset&&f.offset.recycle()),f.onFinished(f.endMatrix),f.recycle();e.recycle()}else d.reorienting&&(g(this.matrixTween),d.reorienting=!1)},"complete-tweens":function(){var a=0;for(a=0;a=0&&(this.vectors.greenSplice(b),this.inverses.greenSplice(b).recycle())},"tween-transform":function(){var b=function(){},c=function(){return!0},d=function(a){return a};return function(f){var g=null,h=f.angle||0,i=f.matrix,j=a.setUp("transform",f.transform,"anchor",f.anchor,"endTime",f.time||0,"time",0,"tween",f.tween||d,"onFinished",f.onFinished||b,"beforeTick",f.beforeTick||c,"afterTick",f.onTick||f.afterTick||b);if(i||(i=e[f.transform]),j.endMatrix=i,!h&&0===f.transform.indexOf("rotate"))switch(f.transform){case"rotate-90":h=Math.PI/2;break;case"rotate-180":h=Math.PI;break;case"rotate-270":h=-Math.PI/2;break;default:g=f.transform.greenSplit("-"),h=g[1]/180*Math.PI,g.recycle()}j.angle=h,f.anchor&&(j.offset=f.offset,j.offset||(j.offset=this.owner.position.copy().subtractVector(f.anchor,2),j.recycleOffset=!0)),this.tweens.push(j)}}(),transform:function(a){this.transform(a)},"prepend-transform":function(a){this.transform(a)},"append-transform":function(a){this.transform(a,!0)},"replace-transform":function(a){this.replace(a)}},methods:{transform:function(a,b){Array.isArray(a)?this.multiply(a,b):"string"==typeof a&&e[a]&&this.multiply(e[a],b)},multiply:function(){return function(a,b){var c=0;for(b?f(this.matrix,a,this.matrix):f(a,this.matrix,this.matrix),c=0;cb;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=Array.setUp(Array.setUp(),Array.setUp(),Array.setUp()),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){var b=c(this.matrix);this.multiply(b),this.multiply(a),b.recycle(2)}}(),updateTween:function(){var a=function(a,b,c){return a*(1-c)+b*c};return function(c,d){var e=0,g=1,h=0,i=0,j=1,k=1,l=0,m=c.endMatrix,n=null,o=null,p=null;return c.beforeTick(c.time)&&(c.time+=d),c.time>=c.endTime?!0:(e=c.tween(c.time/c.endTime),c.angle?(l=e*c.angle,g=j=Math.cos(l),h=Math.sin(l),i=-h):(g=a(g,m[0][0],e),h=a(h,m[1][0],e),i=a(i,m[0][1],e),j=a(j,m[1][1],e),k=a(k,m[2][2],e)),n=Array.setUp(Array.setUp(g,i,0),Array.setUp(h,j,0),Array.setUp(0,0,k)),f(n,this.matrixTween,this.matrixTween),c.anchor&&(o=b.setUp(c.offset).multiply(1-e),p=b.setUp(c.offset).multiply(e),this.owner.triggerEvent("relocate-entity",{position:o.add(p).multiply(n).addVector(c.anchor)}),o.recycle(),p.recycle()),c.afterTick(e,n),void n.recycle(2))}}(),updateVector:function(a,b){b.set(a.add(b)),a.multiply(this.matrixTween),b.subtractVector(a)},destroy:function(){this.vectors.recycle(),this.inverses.recycle(),this.tweens.recycle(),this.orientationVector.recycle(),this.orientationMatrix.recycle(2),this.matrix.recycle(2),this.matrixTween.recycle(2),this.relocationMessage.recycle()}}})}(),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=0&&this.owner.familyLinks.greenSplice(b),a(this.owner.familyLinks,"family-member-removed",this.owner),this.events=null}}})}(),function(){"use strict";var a=function(a){return function(b,c){platypus.game.currentScene.triggerOnChildren(a,b,c)}};return platypus.createComponentClass({id:"RelayGame",properties:{events:{}},constructor:function(){var b="";for(b in this.events)this.events.hasOwnProperty(b)&&this.addEventListener(b,a(this.events[b]))}})}(),function(){"use strict";var a=function(a){return function(b,c){var d=0;for(d=0;d=0&&this.links.greenSplice(b)}},methods:{resolveAdoption:function(a){for(var b=this.owner.parent;b.parent;)b=b.parent;this.linkMessage.reciprocate=!0,b.triggerOnChildren("link-entity",this.linkMessage,!0)},destroy:function(){var a=0;for(a=0;a=0)&&this.owner.parent.removeEntity(this.owner)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"RenderProgress",properties:{backgroundColor:0,color:16777215,rotate:!1,mirror:!1,flip:!1,width:100,height:20,regX:0,regY:0},publicProperties:{x:0,y:0,z:0},constructor:function(a){var b=new PIXI.Graphics,c=new PIXI.Graphics,d=new PIXI.Container;this.parentContainer=null,this.background=b,this.progress=c,this.container=d,"string"==typeof this.backgroundColor&&(this.backgroundColor=+this.backgroundColor.replace("#","0x")),"string"==typeof this.color&&(this.color=+this.color.replace("#","0x")),b.f(this.backgroundColor).r(-this.regX,-this.regY,this.width,this.height),c.f(this.color).r(-this.regX,-this.regY,this.width,this.height),c.scale=new PIXI.Point(1e-4,1),d.addChild(b),d.addChild(c)},events:{"handle-render-load":function(a){!this.parentContainer&&a&&a.container&&(this.parentContainer=a.container,this.parentContainer.addChild(this.container))},"handle-render":function(a){this.container&&(this.parentContainer||(a&&a.container?(this.parentContainer=a.container,this.parentContainer.addChild(this.container)):(console.warn('No PIXI Stage, removing ProgressRender component from "'+this.owner.type+'".'),this.owner.removeComponent(this))),this.container.x=this.x,this.container.y=this.y,this.container.z=this.z)},"update-progress":function(a){isNaN(a)?"number"==typeof a.fraction?this.progress.scale.x=a.fraction:"number"==typeof a.total&&"number"==typeof a.progress&&(this.progress.scale.x=a.progress/a.total):this.progress.scale.x=a}},methods:{destroy:function(){this.parentContainer&&(this.parentContainer.removeChild(this.container),this.parentContainer=null),this.container=null}}})}(),function(){"use strict";var a=include("platypus.Data"),b=new PIXI.Matrix,c=/ /g,d=function(a){return function(b){this.animationFinished||this.lastState>=-1?(this.currentAnimation=a,this.lastState=-1,this.animationFinished=!1,this.sprite.gotoAndPlay(a)):(this.waitingAnimation=a,this.waitingState=-1)}},e=function(a,b){var d=0,e=a.replace(c,"").greenSplit(",");return"default"===a?function(a){return b}:function(a){for(d=0;dthis.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(b,c){var d=null;this.container&&(d=a.setUp("event",b.data.originalEvent,"pixiEvent",b,"x",b.data.global.x/this.parentContainer.transformMatrix.a+this.camera.left,"y",b.data.global.y/this.parentContainer.transformMatrix.d+this.camera.top,"entity",this.owner),this.owner.trigger(c,d),d.recycle())},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){a||(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){a&&(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||Array.setUp(),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,b){this.id=b,this.instances=Array.setUp(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=Array.setUp(this.createMap(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=Array.setUp(),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]=Array.setUp()),c=f;g>c;c++)this.doMap[b][c]||(this.doMap[b][c]=Array.setUp()),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),o.setUp(c,a))},createMap:function(a){var b=0,c=0,d="",e=null,f=this.tiles,g=null;if("string"!=typeof a[0][0])return a;for(e=Array.setUp(),b=0;bb.bottom||db.right||cb.bottom||db.right||c>>0},b=function(a,b){return a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24)>>>0};return function(c,d){var e=4,f=[],g=atob(c.replace(/\\/g,""));if("zlib"===d)for(g=pako.inflate(g);e<=g.length;)f.push(b(g,e-4)),e+=4;else for(;e<=g.length;)f.push(a(g.substr(e-4,4))),e+=4;return f}}(),d=function(a){var b=!!(536870912&a),c=!!(1073741824&a),d=!!(2147483648&a);return b&&d?-3:b?-5:c?-4:-2},e={x:1,y:1,id:-1},f=function(a){var b=e,c=!!(1073741824&a),d=!!(2147483648&a);return b.id=268435455&a,b.x=1,b.y=1,c&&(b.y=-1),d&&(b.x=-1),b},g=function(a,b){var c=0,d=a.gid||-1,g={},i={gid:-1,transform:null,properties:g,type:""},j=null,k=null;for(-1!==d&&(i.transform=f(d),d=i.gid=e.id),c=0;cd);c++)k=b[c];return k&&k.tileproperties&&k.tileproperties[d-k.firstgid]&&(j=k.tileproperties[d-k.firstgid]),""!==a.type?i.type=a.type:""!==a.name?i.type=a.name:j&&(i.type=j.entity||j.type||""),i.type?(i.transform?(g.scaleX=i.transform.x,g.scaleY=i.transform.y):(g.scaleX=1,g.scaleY=1),h(j,i.properties),h(a.properties,i.properties),i):null},h=function(a,b){var c="";if(a&&b)for(c in a)a.hasOwnProperty(c)&&(b[c]=i(a[c]));return b},i=function(a){var b=0;if("string"==typeof a){if(b=parseFloat(a),0===b||b)return b;if("true"===a)return!0;if("false"===a)return!1;if(a.length>1&&("{"===a[0]&&"}"===a[a.length-1]||"["===a[0]&&"]"===a[a.length-1]))try{return JSON.parse(a)}catch(c){}}return a},j=function(a,c){var d=0,e=0,f=Array.setUp(),h=Array.setUp(),i=null,j=null;if("string"==typeof a&&(a=platypus.game.settings.levels[a]),a)if(a.tilesets=m(a.tilesets),a.assets)h.union(a.assets);else{for(d=0;db;b++)e.data.push(1);return this.assetCache.read(a.name)?(e.image=a.name,e.tileheight=this.assetCache.read(a.name).height,e.tilewidth=this.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}.bind(this),M=function(a,c){var g=null,m=c.width,n=c.height,o=c.tileheight||l,p=c.tilewidth||j,q=0,r=0,s=0,t=JSON.parse(JSON.stringify(platypus.game.settings.entities[a]||k[a])),u=null,v=null,w=null,x=!1,y=null,z=null,A=0,B=0,C=0,D="",E=null;if(this.decodeLayer(c),E=c.data,t.properties=t.properties||{},c.properties){if(c.properties.width&&(q=parseInt(c.properties.width,10)),c.properties.height&&(r=parseInt(c.properties.height,10)),q||r){for(q=q||m,r=r||n,E=[],B=0;q>B;B++)for(C=0;r>C;C++)m>B&&n>C?E[B+C*q]=c.data[B+C*m]:E[B+C*q]=0;m=q,n=r}h(c.properties,t.properties)}if(u={},v=[],w=[],"collision-layer"===a)for(z=[],B=0;BB;B++)u["tile"+B]=B;for(B=0;m>B;B++)for(v[B]=[],w[B]=[],C=0;n>C;C++)A=+E[B+C*m]-1,w[B][C]="tile"+A,z&&z.length&&z[0]===(268435455&A)&&(A=d(A)),v[B][C]=A;for(B=0;BC&&(C=I[p].x),I[p].xE&&(E=I[p].y),I[p].yf;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],2:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":1}],3:[function(a,b,c){"use strict";function d(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=d},{}],4:[function(a,b,c){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=f,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^e[255&(a^b[h])];return-1^a}var f=d();b.exports=e},{}],6:[function(a,b,c){"use strict";function d(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=d},{}],7:[function(a,b,c){"use strict";var d=30,e=12;b.exports=function(a,b){var c,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;c=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=c.dmax,l=c.wsize,m=c.whave,n=c.wnext,o=c.window,p=c.hold,q=c.bits,r=c.lencode,s=c.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",c.mode=d;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&c.sane){a.msg="invalid distance too far back",c.mode=d;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),c.hold=p,c.bits=q}},{}],8:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(oa),b.distcode=b.distdyn=new r.Buf32(pa),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,ra)}function k(a){if(sa){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sa=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Ba,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=la;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=la;break}if(m>>>=4,n-=4,wa=(15&m)+8,0===c.wbits)c.wbits=wa;else if(wa>c.wbits){a.msg="invalid window size",c.mode=la;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Ba[2]=m>>>16&255,Ba[3]=m>>>24&255,c.check=t(c.check,Ba,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Ba,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wa=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wa)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.name+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.comment+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ia;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=ba,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=la}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=la;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=la;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Ca[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,ya={bits:c.lenbits},xa=v(w,c.lens,0,19,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid code lengths set",c.mode=la;break}c.have=0,c.mode=aa;case aa:for(;c.have>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<sa)m>>>=qa,n-=qa,c.lens[c.have++]=sa;else{if(16===sa){for(za=qa+2;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,0===c.have){a.msg="invalid bit length repeat",c.mode=la;break}wa=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sa){for(za=qa+3;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=3+(7&m),m>>>=3,n-=3}else{for(za=qa+7;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=la;break}for(;q--;)c.lens[c.have++]=wa}}if(c.mode===la)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=la;break}if(c.lenbits=9,ya={bits:c.lenbits},xa=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid literal/lengths set",c.mode=la;break}if(c.distbits=6,c.distcode=c.distdyn,ya={bits:c.distbits},xa=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,ya),c.distbits=ya.bits,xa){a.msg="invalid distances set",c.mode=la;break}if(c.mode=ba,b===B)break a;case ba:c.mode=ca;case ca:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);break}for(c.back=0;Aa=c.lencode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,c.length=sa,0===ra){c.mode=ha;break}if(32&ra){c.back=-1,c.mode=V;break}if(64&ra){a.msg="invalid literal/length code",c.mode=la;break}c.extra=15&ra,c.mode=da;case da:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=ea;case ea:for(;Aa=c.distcode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,64&ra){a.msg="invalid distance code",c.mode=la;break}c.offset=sa,c.extra=15&ra,c.mode=fa;case fa:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=la;break}c.mode=ga;case ga:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=la;break}q>c.wnext?(q-=c.wnext,oa=c.wsize-q):oa=c.wnext-q,q>c.length&&(q=c.length),pa=c.window}else pa=f,oa=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pa[oa++];while(--q);0===c.length&&(c.mode=ca);break;case ha:if(0===j)break a;f[h++]=c.length,j--,c.mode=ca;break;case ia:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[c+E]]++;for(H=C,G=e;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;e>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===h||1!==G))return-1;for(Q[1]=0,D=1;e>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[c+E]&&(r[Q[b[c+E]]++]=E);if(a===h?(N=R=r,y=19):a===i?(N=k,O-=257,R=l,S-=257,y=256):(N=m,R=n,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<f||a===j&&L>g)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[c+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<f||a===j&&L>g)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":1}],10:[function(a,b,c){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(a,b,c){"use strict";function d(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=d},{}],"/lib/inflate.js":[function(a,b,c){"use strict";function d(a,b){var c=new n(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=Object.prototype.toString,n=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};n.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,n=this.options.chunkSize,o=!1;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,"string"==typeof a?l.input=h.binstring2buf(a):"[object ArrayBuffer]"===m.call(a)?l.input=new Uint8Array(a):l.input=a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(n),l.next_out=0,l.avail_out=n),c=f.inflate(l,i.Z_NO_FLUSH),c===i.Z_BUF_ERROR&&o===!0&&(c=i.Z_OK,o=!1),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&(d===i.Z_FINISH||d===i.Z_SYNC_FLUSH))&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=n-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out))),0===l.avail_in&&0===l.avail_out&&(o=!0)}while((l.avail_in>0||0===l.avail_out)&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):d===i.Z_SYNC_FLUSH?(this.onEnd(i.Z_OK),l.avail_out=0,!0):!0},n.prototype.onData=function(a){this.chunks.push(a)},n.prototype.onEnd=function(a){a===i.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=n,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate.js":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")}),this.platypus=this.platypus||{},function(){"use strict";var a=navigator.userAgent.toLowerCase(),b=a.search("edge")>-1,c=a.search("ipod")>-1,d=a.search("iphone")>-1,e=a.search("ipad")>-1,f=a.search("android")>-1,g=a.search("silk")>-1,h=c||d||e,i=h||f||g;platypus.supports={touch:"undefined"!==window.ontouchstart,edge:b,iPod:c,iPhone:d,iPad:e,safari:a.search("safari")>-1&&!b,ie:a.search("msie")>-1||a.search("trident")>-1,firefox:a.search("firefox")>-1,android:f,chrome:a.search("chrome")>-1&&!b,silk:g,iOS:h,mobile:i,desktop:!i},platypus.version="0.7.4",platypus.buildDate="Wed, 24 Feb 2016 21:58:39 GMT"}(),function(){var a={enumerable:!1,value:!1,writable:!0},b={};platypus.setUpRecycle=function(c,d){var e=[],f=!!springroll.Debug;return b[d]=e,f?(c.setUp=function(){var b=null;return e.length?(b=e.pop(),b.recycled=!1):(b=Object.create(this.prototype),Object.defineProperty(b,"recycled",a)),this.apply(b,arguments),b},c.recycle=function(a){a.recycled?console.warn("WHOA! I have already been recycled!",a):(a.recycled=!0,e.push(a))}):(c.setUp=function(){var a=null;return a=e.length?e.pop():Object.create(this.prototype),this.apply(a,arguments),a},c.recycle=function(a){e.push(a)}),c.prototype.recycle=function(){c.recycle(this)},e},platypus.getObjectCaches=function(){return b}}(),function(a,b){var c=null,d=!!springroll.Debug,e=a.prototype,f={enumerable:!1,value:!1,writable:!0};e.union||b.defineProperty(e,"union",{enumerable:!1,writable:!1,value:function(a){var b=0,c=a.length;for(b=0;c>b;b++)-1===this.indexOf(a[b])&&this.push(a[b]);return this}}),e.greenSlice||b.defineProperty(e,"greenSlice",{enumerable:!1,writable:!1,value:function(){var b=a.setUp(),c=0,d=this.length;for(c=0;d>c;c++)b[c]=this[c];return b}}),e.greenSplice||b.defineProperty(e,"greenSplice",{enumerable:!1,writable:!1,value:function(a){var b=0,c=this[a],d=this.length;for(b=a+1;d>b;b++)this[b-1]=this[b];return d&&(this.length-=1),c}}),e.recycle||(c=platypus.setUpRecycle(a,"Array"),d?a.setUp=function(){var a=0,d=null;for(c.length?(d=c.pop(),d.recycled=!1):(d=[],b.defineProperty(d,"recycled",f)),a=0;a1)for(c=this.length,b-=1;c--;)this[c].recycle(b);this.length=0,a.recycle(this)}}))}(Array,Object),function(a,b){var c=a.prototype;c.greenSplit||b.defineProperty(c,"greenSplit",{enumerable:!1,writable:!1,value:function(a){var b=this,c=0,d=0,e=Array.setUp();if(a){for(d=b.indexOf(a),c=a.length;d>=0;)e.push(b.substr(0,d)),b=b.substr(d+c),d=b.indexOf(a);e.push(b)}else for(d=this.length,c=d-1;d--;)e.push(this[c-d]);return e}})}(String,Object),platypus.Data=function(){"use strict";var a=function(){var a=arguments.length,b=arguments[0],c="";if(b)if("string"==typeof b)for(a%2&&(this[a]=null,a-=1);a;)this[arguments[a-2]]=arguments[a-1],a-=2;else for(c in b)b.hasOwnProperty(c)&&(this[c]=b[c])},b=a.prototype;return platypus.setUpRecycle(a,"Data"),b.recycle=function(){var b="";for(b in this)this.hasOwnProperty(b)&&delete this[b];a.recycle(this)},a}(),platypus.Component=function(){"use strict";var a=include("platypus.Data"),b=function(a){return Array.setUp()},c=function(b,c){this.type=b,this.owner=c,this.publicMethods=a.setUp(),this.listener=a.setUp("events",Array.setUp(),"messages",Array.setUp())},d=c.prototype;return d.toString=function(){return"[Component "+this.type+"]"},d.destroy=function(){var a="";if(this.listener){this._destroy&&this._destroy();for(a in this.publicMethods)this.publicMethods.hasOwnProperty(a)&&this.removeMethod(a);this.publicMethods.recycle(),this.removeEventListeners(),this.listener.events.recycle(),this.listener.messages.recycle(),this.listener.recycle(),this.listener=null}},d.removeEventListeners=function(a){var b=0,c=null,d=null;if(a)for(b=0;b=0;c--)d[c]!==a||b&&e[c]!==b||(this.owner.off(a,e[c]),this.listener.events.greenSplice(c),this.listener.messages.greenSplice(c))},d.removeMethod=function(a){this.owner[a]?delete this.owner[a]:console.warn(this.owner.type+': Entity does not have a method called "'+a+'".'),delete this.publicMethods[a]},c.getAssetList=b,c.getLateAssetList=b,c}(),platypus.Messenger=function(){"use strict";var a=include("springroll.EventDispatcher"),b=function(){a.call(this),this.loopCheck=Array.setUp()},c=!!springroll.Debug,d=c&&window.performance&&window.performance.mark&&window.performance.measure&&window.performance,e=extend(b,a);return e.toString=function(){return"[Messenger Object]"},e._trigger=e.trigger,e.trigger=function(a,b,c){var d=0,e=0;if("string"==typeof a)return this.triggerEvent(a,b,c);if(Array.isArray(a)){for(d=0;d1&&(f=Array.prototype.greenSlice.call(arguments),f.greenSplice(0)),b=c=e.length;c--;)d=e[c],d._eventDispatcherOnce&&(delete d._eventDispatcherOnce,this.off(a,d)),d.apply(this,f);f&&f.recycle(),e.recycle()}return b},c&&(e._triggerEvent=e.triggerEvent,e.triggerEvent=function(a,b,c){var e=0,f=c||b&&b.debug,g=0,h=0;if(f||this.debug){for(e=0;e5)throw"Endless loop detected for '"+a+"'.";console.warn("Event '"+a+"' is nested inside another '"+a+"' event.")}return this.loopCheck.push(a),d&&d.mark("a"),h=this._triggerEvent(a,b,c),d&&(d.mark("b"),d.measure(this.type+":"+a,"a","b")),this.loopCheck.length=this.loopCheck.length-1,f&&(h?console.log('Entity "'+this.type+'": Event "'+a+'" has '+h+" subscriber"+(h>1?"s":"")+".",b):console.warn('Entity "'+this.type+'": Event "'+a+'" has no subscribers.',b)),h}return this._triggerEvent(a,b,c)}),e.getMessageIds=function(){return Object.keys(this._listeners)},e.eventDispatcherDestroy=e.destroy,e.destroy=function(){this.loopCheck.recycle(),this.eventDispatcherDestroy()},b}(),platypus.Entity=function(){"use strict";var a=include("platypus.Data"),b={},c=function(a,b){platypus.game.settings.debug&&console.warn(a,b)},d=function(d,e){var f=0,g=null,h=a.setUp(d),i=h.components,j=a.setUp(h.properties),k=a.setUp(e),l=a.setUp(k.properties),m=Array.setUp(),n=Array.setUp();if(platypus.Messenger.call(this),this.components=Array.setUp(),this.type=h.id||"none",this.id=k.id||l.id,this.id||(b[this.type]||(b[this.type]=0),this.id=this.type+"-"+b[this.type],b[this.type]+=1),this.setProperty(j),this.setProperty(l),this.on("set-property",function(a){this.setProperty(a)}.bind(this)),this.state=a.setUp(this.state),this.lastState=a.setUp(),this.trigger=this.triggerEvent=function(a,b){m.push(a),n.push(b)},i)for(f=0;f5&&".json"===a.src.substring(a.src.length-5).toLowerCase())d(a.src,function(c){a.src!==c&&(a=c),b(a)});else{for(f in a)a.hasOwnProperty(f)&&(g+=1);if(g)for(f in a)a.hasOwnProperty(f)&&i(a,f,h);else b(a)}return}if("string"==typeof a&&a.length>5&&".json"===a.substring(a.length-5).toLowerCase())return void c(a,function(a){"object"==typeof a?d(a,b):b(a)})}b(a)},e=function(c,e,f){var g=function(c){var d="",e="",g=this.app.states||{};platypus.game=this,this.currentScene=null,this.settings=c,this.stage=this.app.display.stage;for(e in c.scenes)c.scenes.hasOwnProperty(e)&&(d=c.scenes[e].id=c.scenes[e].id||e,g[d]=new b(new a,c.scenes[e]));this.app.states||(this.app.states=g),f&&f(this),window.getEntityById=function(a){return this.getEntityById(a)}.bind(this),window.getEntitiesByType=function(a){return this.getEntitiesByType(a)}.bind(this),window.getVisibleSprites=function(a,b){var c=0;if(b=b||Array.setUp(),a=a||this.stage,!a.texture&&a.visible){for(c=0;cc;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 platypus.Vector.setUp(this).normalize()},b.getInverse=function(){return platypus.Vector.setUp(this).multiply(-1)},b.normalize=function(){var a=this.magnitude();return 0===a?this: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 platypus.Vector.setUp(this).cross(a)},b.rotate=function(a,b){var c=b,d=null,e=Math.cos(a),f=Math.sin(a),g=1-e,h=0,i=0,j=0,k=platypus.Vector.setUp();return c?"x"===c?c=k.setXYZ(1,0,0):"y"===c?c=k.setXYZ(0,1,0):"z"===c&&(c=k.setXYZ(0,0,1)):c=k.setXYZ(0,0,1),h=c.x,i=c.y,j=c.z,d=Array.setUp(Array.setUp(e+h*h*g,h*i*g-j*f,h*j*g+i*f),Array.setUp(i*h*g+j*f,e+i*i*g,i*j*g-h*f),Array.setUp(j*h*g-i*f,j*i*g+h*f,e+j*j*g)),this.multiply(d),k.recycle(),d.recycle(2),this},b.multiply=function(a,b){var c=0,d=0,e=null,f=0;if(Array.isArray(a)){for(e=this.matrix.greenSlice(),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];e.recycle()}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,e=this.matrix,f=a.matrix;for(d=b||e.length;d--;)c+=e[d]*(f[d]||0);return c},b.angleTo=function(a){var b=this.getUnit(),c=a.getUnit(),d=0;return b.magnitude()&&c.magnitude()?d=Math.acos(b.dot(c)):(console.warn("Vector: Attempted to find the angle of a zero-length vector."),d=void 0),b.recycle(),c.recycle(),d},b.signedAngleTo=function(a,b){var c=this.getUnit(),d=a.getUnit(),e=c.getCrossProduct(d),f=0;return f=e.dot(b)<0?-Math.acos(c.dot(d)):Math.acos(c.dot(d)),c.recycle(),d.recycle(),e.recycle(),f},b.scalarProjection=function(b){var c=null,d=0;return"number"==typeof b?this.magnitude(2)*Math.cos(b):(c=a.setUp(b).normalize(),d=this.dot(c),c.recycle(),d)},b.copy=function(){return platypus.Vector.setUp(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]=platypus.Vector.setUp(),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.collides=function(a){return a.bottom>this.top&&a.topthis.left&&a.leftthis.bottom||a.rightthis.right)},b.getIntersectionArea=function(a){var b=Math.max,c=Math.min,d=c(this.bottom,a.bottom)-b(this.top,a.top),e=c(this.right,a.right)-b(this.left,a.left),f=d*e;return f},platypus.setUpRecycle(a,"AABB"),a}(),platypus.ActionState=function(){"use strict";var a=include("platypus.Data"),b=function(b,c,d){this.event=b,this.trigger=d,this.active=!1,this.wasActive=!1,this.valid=!0,this.wasValid=!0,this.states=a.setUp(c),this.inputs=Array.setUp(),this.stateSummary=a.setUp("pressed",!1,"released",!1,"triggered",!1)},c=function(a){return a},d=b.prototype;return d.update=function(a){var b=this.stateSummary;return this.valid=this.isStateValid(a),this.active=this.inputs.some(c),b.pressed=this.valid&&this.active,b.released=this.wasActive&&(!this.valid&&this.wasValid||this.valid&&!this.active),b.triggered=this.valid&&this.active&&!this.wasActive,this.wasValid=this.valid,this.wasActive=this.active,b.pressed||b.released||b.triggered},d.resolve=function(){this.trigger(this.event,this.stateSummary)},d.isStateValid=function(a){var b="",c=this.states;for(b in c)if(c.hasOwnProperty(b)&&a.hasOwnProperty(b)&&c[b]!==a[b])return!1;return!0},platypus.setUpRecycle(b,"ActionState"),d.recycle=function(){this.states.recycle(),this.stateSummary.recycle(),this.inputs.recycle(),b.recycle(this)},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=platypus.Vector.setUp(h),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.setVector(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.setXYZ(0,0,0),this.stuck=0},a}(),platypus.CollisionDataContainer=function(){"use strict";var a=function(){this.xData=Array.setUp(new platypus.CollisionData,new platypus.CollisionData),this.yData=Array.setUp(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=include("platypus.AABB"),b=include("platypus.Vector"),c=function(a,b){var c=b.aABB,d=c.halfHeight,e=c.halfWidth,f=Math.abs,g=Math.pow,h=f(a.x-b.x),i=f(a.y-b.y),j=a.radius;return e>h||d>i||e+j>h&&d+j>i&&g(h-e,2)+g(i-d,2)=k;k+=e)for(j=0;h>=j;j+=d)l.push([j,k,d,e,c,f,g]);return l},f=function(b){var d=0,e=Array.setUp(),f=null,g=a.instance.assetManager.cache,h=c,i=null;for(d=0;dd&&(d=0),d=this._animation.frames.length&&(c=this._animation.id,this.gotoAndPlay(this._animation.next),this.onComplete&&this.onComplete(c))},n.destroy=function(){var a="";if(this.stop(),PIXI.Sprite.prototype.destroy.call(this),this.cacheId&&(b[this.cacheId].viable-=1,b[this.cacheId].viable<=0)){b[this.cacheId].textures.recycle();for(a in b[this.cacheId].animations)b[this.cacheId].animations.hasOwnProperty(a)&&b[this.cacheId].animations[a].frames.recycle();delete b[this.cacheId]}},m.destroyBaseTextures=function(){var a=c,b="";for(b in a)a.hasOwnProperty(b)&&(a[b].destroy(),delete a[b])}}(),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.Application"),b=include("springroll.ApplicationPlugin"),c=null,d=new b,e=null,f=function(){var b=function(a,b){return Math.floor(204*a/b)},c=function(a,c){var d=0,e=0,f="color: #ffffff; padding:3px 0; border-radius: 6px;",g=0,h=0,i=0,j=null;return c&&(j=c.greenSplit(".")),c&&3===j.length?(g=parseInt(j[0],10),h=parseInt(j[1],10),i=parseInt(j[2],10)):(g=a.charCodeAt(0)||0,h=a.charCodeAt(1)||0,i=a.charCodeAt(2)||0,e=Math.min(g,h,i),g-=e,h-=e,i-=e),j&&j.recycle(),d=Math.max(g,h,i,1),f+" background: rgb("+b(g,d)+","+b(h,d)+","+b(i,d)+");"};return function(b,d){var e=d.options,f=e.author?"by "+e.author:"",g=d.name||document.title||"",h=a.version||"(?)",i="Platypus "+platypus.version,j="Pixi.js "+PIXI.VERSION,k="SpringRoll "+h,l=e.version||"(?)";e.hideHello||("(?)"!==l&&(g+=" "+l),platypus.supports.firefox||platypus.supports.chrome?console.log("\n%c "+g+" %c "+f+" \n\nUsing %c "+k+" %c %c "+j+" %c %c "+i+" %c\n\n",c(g,l),"",c(k,h),"",c(j,PIXI.VERSION),"",c(i,platypus.version),""):console.log('--- "'+g+'" '+f+" - Using "+k+", "+j+", and "+i+" ---")),b.debug&&console.log("Game config loaded.",b)}}(),g=function(a){var b=null,c=null,d=null,e={};for(b in a)if(a[b].id)e[b]=a[b];else{c=g(a[b]);for(d in c)e[d]=c[d]}return e},h=function(a){var b="";for(b in a)a.hasOwnProperty(b)&&(a[b].id=b)};PIXI.utils._saidHello=!0,d.setup=function(){var a="",b=document.getElementsByName("author"),c=this.options;b.length&&(a=b[0].getAttribute("content")||""),c.add("author",a,!0),c.add("hideHello",!1,!0)},d.preload=function(a){var b=this.config.platypus||this.config,d=null,i={delta:0};b?(this.options.debug&&(b.debug=!0),f(b,this),b.entities=g(b.entities),b.spriteSheets&&h(b.spriteSheets),d=this.platypus=new platypus.Game(b,this),c=function(a){i.delta=a,d.tick(i)},this.on("update",c,320),e=function(a){d.currentScene&&d.currentScene.triggerOnChildren("resize",a)},this.on("resize",e)):console.warn("PlatypusPlugin: Platypus requires a game configuration."),a()},d.teardown=function(){this.platypus&&(this.off("update",c),this.off("resize",e),this.platypus.destroy(),delete this.platypus)}}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"AIChaser",properties:{accelerate:!1,chasing:!0},publicProperties:{speed:.3},constructor:function(b){this.target=this.owner.target||null,this.offset=a.setUp(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=null,c=0,d=!1;this.target&&this.chasing&&(b=a.setUp(this.offset).add(this.target.position).subtractVector(this.owner.position),c=b.magnitude(2),c&&(d=!0,this.direction.setVector(b).normalize().multiply(this.speed)),b.recycle()),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,this.offset.recycle()}}})}(),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.greenSplice(b));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",e):(d[c].stop(),d.greenSplice(c)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.greenSplice(b))},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.greenSplice(0)},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.greenSplice(0),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",e):(d[c].stop(),d.greenSplice(c)));else if(b)for(c=0;c=0;b--)c[b]===a&&(c[b].stop(),c.greenSplice(b))},onComplete:function(a){this.owner.destroyed||(this.removeClip(a.audio),this.owner.triggerEvent("clip-complete"))},removeClip:function(a){var b=this.activeAudioClips.indexOf(a);b>=0&&this.activeAudioClips.greenSplice(b)},destroy:function(){this.stopAudio(),this.activeAudioClips.recycle(),this.checkStates&&this.checkStates.recycle()}}})}(),function(){"use strict";var a=include("springroll.Application"),b=function(a,b){return a.time-b.time},c=function(a,c,d){return function(){var e=0,f=d.getElapsed();for(e=0;ethis.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},destroy:function(){this.parentContainer.removeChild(this.container),this.parentContainer=null,this.container=null,this.mouseVector&&(this.mouseVector.recycle(),this.mouseWorldOrigin.recycle()),this.boundingBox.recycle(),this.viewport.recycle(),this.worldCamera.viewport.recycle(),this.worldCamera.recycle(),this.message.viewport.recycle(),this.message.recycle(),this.forwardFollower.recycle(),this.lastFollow.recycle()}}})}(),function(){"use strict";var a=include("platypus.Data");return platypus.createComponentClass({id:"CameraFollowMe",properties:{camera:{},mode:"forward",pause:!1},constructor:function(b){this.pauseGame=this.pause&&this.camera.time?{time:this.camera.time}:null,this.camera=a.setUp("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(b){var c=null;c=b?a.setUp("entity",this.owner,"mode",b.mode||this.camera.mode,"top",b.top||this.camera.top,"left",b.left||this.camera.left,"offsetX",b.offsetX||this.camera.offsetX,"offsetY",b.offsetY||this.camera.offsetY,"width",b.width||this.camera.width,"height",b.height||this.camera.height,"time",b.time||this.camera.time):a.setUp(this.camera),this.pauseGame&&(this.owner.parent.triggerEvent("pause-logic",this.pauseGame),this.owner.parent.triggerEvent("pause-render",this.pauseGame)),this.owner.parent.triggerEvent("follow",c),c.recycle()}},methods:{destroy:function(){this.camera.recycle()}}})}(),function(){"use strict";var a=include("platypus.AABB"),b=include("platypus.CollisionShape"),c=include("platypus.Data"),d=include("platypus.Vector"),e=function(){var a=function(a,b,c,d){d.myType===b&&d.hitType===c&&this.owner.triggerEvent(a,d)},b=function(a,b,c,d){var e=0;if(d.myType===b&&d.hitType===c)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))};return function(d,e,f,g){return"string"==typeof e?a.bind(d,e,d.collisionType,f):Array.isArray(e)?b.bind(d,e,d.collisionType,f):c.bind(d,e,d.collisionType,f)}}(),f=function(){var b=function(a,b,c){var d="";if(c)return b[c]?b[c].getAABB():null;a.reset();for(d in b)b.hasOwnProperty(d)&&a.include(b[d].getAABB());return a},e=function(a,b){var c=a[b];return c?c.getPreviousAABB():null},f=function(a,b){var c=a[b];return c?c.getShapes():null},g=function(a,b){var c=a[b];return c?c.getPrevShapes():null},h=function(a,b,c){var d="";for(d in a)a.hasOwnProperty(d)&&a[d].prepareCollision(b,c)},i=function(){var a=function(a,b,c){var e=0,f=b.stuck;f&&(e=a.magnitude(),b.thatShape.owner&&Math.abs(f)>1&&(f*=.05),(!e||e>Math.abs(f))&&(b.vector.x&&(a.x=f,a.y=0),b.vector.y&&(a.x=0,a.y=f),c.stuckWith&&c.stuckWith.recycle(),c.stuckWith=d.setUp(b.thatShape.x,b.thatShape.y)))},b={position:null,unstick:null};return function(c,e){var f=b,g=null;e.xCount&&(g=d.setUp(0,0,0),a(g,e.getXEntry(0),this)),e.yCount&&(g=g||d.setUp(0,0,0),a(g,e.getYEntry(0),this)),f.position=c,f.unstick=g,this.triggerEvent("relocate-entity",f),g&&g.recycle()}}(),j=function(a,b){var c="";for(c in a)a.hasOwnProperty(c)&&a[c].movePreviousX(b)},k=function(){return this.collisionTypes},l=function(){return this.solidCollisionMap},m=function(){return this.getAABB()},n=function(){return this.getPreviousAABB()},o=function(){return this.getShapes()},p=function(){return this.getPrevShapes()},q=function(a,b){this.prepareCollision(a,b)},r=function(a){this.movePreviousX(a)};return function(d,s){var t=s.collisionFunctions;t||(t=s.collisionFunctions=c.setUp(),s.aabb=a.setUp(),s.getAABB=b.bind(s,s.aabb,t),s.getPreviousAABB=e.bind(s,t),s.getShapes=f.bind(s,t),s.getPrevShapes=g.bind(s,t),s.prepareCollision=h.bind(s,t),s.relocateEntity=i.bind(s),s.movePreviousX=j.bind(s,t),s.getCollisionTypes=k.bind(s),s.getSolidCollisions=l.bind(s)),t[d.collisionType]=c.setUp("getAABB",m.bind(d),"getPreviousAABB",n.bind(d),"getShapes",o.bind(d),"getPrevShapes",p.bind(d),"prepareCollision",q.bind(d),"movePreviousX",r.bind(d))}}();return platypus.createComponentClass({id:"CollisionBasic",properties:{collisionType:"none",shapeType:"rectangle",ignoreOrientation:!1,regX:null,regY:null,width:0,height:0,radius:0,softCollisions:null,solidCollisions:null,margin:0,shapes:null},publicProperties:{immobile:!1,bullet:!1,jumpThrough:!1},constructor:function(c){var g=0,h="",i=null,j=this.regX,k=this.regY,l=this.width,m=this.height,n=this.radius,o=0,p=0,q=0,r=0;for("number"==typeof this.margin?(o=this.margin,p=this.margin,q=this.margin,r=this.margin):(o=this.margin.left||0,p=this.margin.right||0,q=this.margin.top||0,r=this.margin.bottom||0),null===j&&(j=this.regX=l/2),null===k&&(k=this.regY=m/2),d.assign(this.owner,"position","x","y","z"),d.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=a.setUp(),this.prevAABB=a.setUp(),this.shapes?i=this.shapes:"circle"===this.shapeType?(n=n||((l||0)+(m||0))/4,i=[{regX:(isNaN(j)?n:j)-(p-o)/2,regY:(isNaN(k)?n:k)-(r-q)/2,radius:n,type:this.shapeType}]):i=[{regX:(isNaN(j)?(l||0)/2:j)+o,regY:(isNaN(k)?(m||0)/2:k)+q,points:c.points,width:(l||0)+o+p,height:(m||0)+q+r,type:this.shapeType}],this.owner.collisionTypes=this.owner.collisionTypes||Array.setUp(),this.owner.collisionTypes.push(this.collisionType),this.shapes=Array.setUp(),this.prevShapes=Array.setUp(),this.entities=void 0,g=0;g=0&&f.greenSplice(b),this.active=!1,f.length&&d.triggerEvent("add-collision-entity",c))},"relocate-entity":function(a){var b=a.unstick,c=0,d=0,e=0,f=0,g=this.aabb,h=this.owner,i=null,j=this.shapes;for(b&&(c=b.magnitude()),this.move&&(this.move.recycle(),this.move=null),a.relative?h.position.setVector(h.previousPosition).add(a.position):h.position.setVector(a.position),this.stuck&&(c>0?h.position.add(b):this.stuck=!1),e=h.x,f=h.y,g.reset(),d=j.length;d--;)i=j[d],i.update(e,f),g.include(i.aABB);h.previousPosition.setVector(h.position),c>0&&(this.stuck||(this.stuck=!0),this.move=h.stuckWith.copy().add(-e,-f).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;b=0&&this.owner.collisionTypes.greenSplice(b),this.owner.solidCollisionMap[this.collisionType]&&(this.owner.solidCollisionMap[this.collisionType].recycle(),delete this.owner.solidCollisionMap[this.collisionType]),this.owner.softCollisionMap[this.collisionType]&&(this.owner.softCollisionMap[this.collisionType].recycle(),delete this.owner.softCollisionMap[this.collisionType]),a[this.collisionType].recycle(),delete a[this.collisionType],b=this.shapes.length;b--;)this.shapes[b].recycle(),this.prevShapes[b].recycle();this.shapes.recycle(),this.prevShapes.recycle(),delete this.shapes,delete this.prevShapes,delete this.entities,this.owner.collisionTypes.length?this.owner.parent.triggerEvent("add-collision-entity",this.owner):(a.recycle(),this.owner.collisionFunctions=null,this.owner.aabb.recycle(),this.owner.aabb=null)}}})}(),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=include("platypus.AABB"),b=include("platypus.Vector");return platypus.createComponentClass({id:"CollisionGroup",constructor:function(c){this.solidEntities=Array.setUp(),this.collisionTypes=Array.setUp(),this.shapes=Array.setUp(),this.prevShapes=Array.setUp(),this.terrain=void 0,this.aabb=a.setUp(this.owner.x,this.owner.y),this.prevAABB=a.setUp(this.owner.x,this.owner.y),this.filteredAABB=a.setUp(),b.assign(this.owner,"position","x","y","z"),b.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,b=0,c=null;for(a=0;a=0&&this.solidEntities.greenSplice(b));this.updateAABB()}},getCollisionTypes:function(){var a=0,b=null,c=this.collisionTypes;for(c.length=0,a=0;aa?(a=Math.abs(a)-2,b[a]):a},d=function(a,b,c,d,e){var f=0,g=0,h=Array.setUp();for(g=0;e>g;g++)for(h[g]=Array.setUp(),f=0;d>f;f++)h[g][f]=a[b+f][c+g];return h},e=function(a,b,c,d,e){var f=0,g=0,h=Array.setUp();for(g=0;e>g;g++)for(h[g]=Array.setUp(),f=0;d>f;f++)h[g][f]=a[b+f][c+g],a[b+f][c+g]=-1;return h},f=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},g={diagonal:function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-5,-4,-3,-2);for(i=0;f>i;i++)for(j=0;g>j;j++)a[b+i][e+j]=c(h[i][j],k);return h.recycle(2),k.recycle(),a},"diagonal-inverse":function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-3,-2,-5,-4);for(i=0;f>i;i++)for(j=0;g>j;j++)a[b+f-i-1][e+g-j-1]=c(h[i][j],k);return h.recycle(2),k.recycle(),a},horizontal:function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-2,-5,-4,-3);for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][e+j]=c(h[j][i],k);return h.recycle(2),k.recycle(),a},vertical:function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-4,-3,-2,-5);for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+i][e+g-j-1]=c(h[j][i],k);return h.recycle(2),k.recycle(),a},"rotate-90":function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-3,-4,-5,-2);for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+g-j-1][e+i]=c(h[j][i],k);return h.recycle(2),k.recycle(),a},"rotate-180":function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-4,-5,-2,-3);for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+f-i-1][e+g-j-1]=c(h[j][i],k);return h.recycle(2),k.recycle(),a},"rotate-270":function(a,b,e,f,g){var h=d(a,b,e,f,g),i=0,j=0,k=Array.setUp(-5,-2,-3,-4);for(j=0;g>j;j++)for(i=0;f>i;i++)a[b+j][e+f-i-1]=c(h[j][i],k);return h.recycle(2),k.recycle(),a},translate:function(a,b,c,d,f,g,h){var i=e(a,b,c,d,f),j=0,k=0;for(k=0;f>k;k++)for(j=0;d>j;j++)a[b+j+g][c+k+h]=i[k][j];return i.recycle(2),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,this.shapeDefinition=b.setUp("x",0,"y",0,"type","rectangle","width",this.tileWidth,"height",this.tileHeight),this.storedTiles=Array.setUp(),this.serveTiles=Array.setUp(),this.storedTileIndex=0},events:{transform:function(a){this.transform(a)},translate:function(a){this.translate(a)}},methods:{getShape:function(b,c){var d=this.storedTileIndex,e=null,f=this.storedTiles;return d===f.length&&f.push(a.setUp(null,this.shapeDefinition,"tiles")),e=f[d],e.update(b*this.tileWidth+this.tileHalfWidth,c*this.tileHeight+this.tileHalfHeight),this.storedTileIndex+=1,e},addShape:function(a,b,c,d){var e=this.collisionMap[c][d];if(e>-1)a.push(this.getShape(c,d));else if(-1>e)switch(e){case-2:b.bottom<=d*this.tileHeight&&a.push(this.getShape(c,d));break;case-3:b.left>=(c+1)*this.tileWidth&&a.push(this.getShape(c,d));break;case-4:b.top>=(d+1)*this.tileHeight&&a.push(this.getShape(c,d));break;case-5:b.right<=c*this.tileWidth&&a.push(this.getShape(c,d))}return a},destroy:function(){var a=this.storedTiles,b=a.length;for(this.shapeDefinition.recycle(),delete this.shapeDefinition;b--;)a[b].recycle();a.recycle(),delete this.storedTiles,this.serveTiles.recycle(),delete this.serveTiles}},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,b){var c=Math.max(Math.floor(a.left/this.tileWidth),0),d=Math.max(Math.floor(a.top/this.tileHeight),0),e=Math.min(Math.ceil(a.right/this.tileWidth),this.collisionMap.length),f=Math.min(Math.ceil(a.bottom/this.tileHeight),this.collisionMap[0].length),g=0,h=0,i=this.serveTiles;for(i.length=0,this.storedTileIndex=0,g=c;e>g;g++)for(h=d;f>h;h++)this.addShape(i,b,g,h);return i},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,h=b.type||"horizontal";return g[h]?g[h](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,h=b.dx||0,i=b.dy||0;return g.translate(this.collisionMap,c,d,e,f,h,i)},getCollisionMatrix:function(a,b,c,e){return d(this.collisionMap,a,b,c,e)},setCollisionMatrix:function(a,b,c,d,e){return f(this.collisionMap,a,b,c,d,e)}}})}(),function(){"use strict";var a=function(a){this.switches.push(a)};return platypus.createComponentClass({id:"ComponentSwitcher",properties:{componentMap:null},constructor:function(b){var c="";if(this.switches=Array.setUp(),this.componentMap)for(c in this.componentMap)this.componentMap.hasOwnProperty(c)&&this.addEventListener(c,a.bind(this,c))},events:{"prepare-logic":function(){var a=0;if(this.switches.length){for(a=0;a-1;c--)e[c].type===f[b]&&d.removeComponent(e[c]);else for(b=e.length-1;b>-1;b--)e[b].type===f&&d.removeComponent(e[b]);if(g)if(Array.isArray(g))for(b=0;b=0?(this.removeChildEventListeners(a),this.entities.greenSplice(b),this.triggerEventOnChildren("peer-entity-removed",a),this.owner.triggerEvent("child-entity-removed",a),a.destroy(),a.parent=null,a):!1},triggerEventOnChildren:function(a,b,c){return this.destroyed?0:(this._listeners[a]||this.addNewPrivateEvent(a),this.triggerEvent(a,b,c))},triggerOnChildren:function(a,b,c){return this.destroyed?0:(this._listeners[a]||this.addNewPrivateEvent(a),this.trigger(a,b,c))}},getAssetList:function(a,c,d){var e=0,f=Array.setUp(),g=Array.setUp(),h=null;for(a.entities&&g.union(a.entities),c&&c.entities?g.union(c.entities):d&&d.entities&&g.union(d.entities),e=0;ee&&(f=g-f),f):f},e=[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"]],f=["left-button","middle-button","right-button"],g=function(b){for(var c=b.greenSplit(","),d=c.length,e=a.setUp(),f="";d--;)f=c[d],f&&("!"===f.substr(0,1)?e[f.substr(1)]=!1:e[f]=!0);return c.recycle(),e},h=function(a,b){this.paused||this.owner.trigger(a,b)},i=function(a,b,c){!this.paused&&c[a]&&this.owner.trigger(b,c)};return platypus.createComponentClass({id:"EntityController",properties:{controlMap:{},stateMaps:{}},publicProperties:{paused:!1},constructor:function(b){var c="",d=null;if(this.actions=a.setUp(),this.stateMaps)for(c in this.stateMaps)this.stateMaps.hasOwnProperty(c)&&(d=g(c),this.addMap(this.stateMaps[c],d),d.recycle());this.addMap(this.controlMap),b.joystick&&(this.joystick=a.setUp("directions",b.joystick.directions||4,"handleEdge",b.joystick.handleEdge||!1,"innerRadius",b.joystick.innerRadius||0,"outerRadius",b.joystick.outerRadius||1/0))},events:{"handle-controller":function(){var a=0,b="",c=Array.setUp();for(b in this.actions)this.actions.hasOwnProperty(b)&&this.actions[b].update(this.owner.state)&&c.push(this.actions[b]);for(a=0;athis.joystick.outerRadius||f=0&&this.entitiesByType[d[c]].greenSplice(b));a.immobile||(c=this.allEntities.indexOf(a),c>=0&&this.allEntities.greenSplice(c)),this.updateLiveList=!0}},checkCamera:function(a,b){var c=2*a.buffer,d=0,e=0,f="",h=null,i=null,j=null,k=null,l=null,m=null,n=null,o=a.width+c,p=a.height+c,q=a.left+o/2,r=a.top+p/2,s=null,t=null,u=this.cameraLogicAABB,v=this.cameraCollisionAABB,w=null,x=!1;if(this.updateLiveList||!u.matches(q,r,o,p)){for(u.setAll(q,r,o,p),this.updateLiveList=!1,i=this.allEntities,j=this.allEntitiesLive,j.length=0,l=this.solidEntitiesLive,l.length=0,k=this.softEntitiesLive,k.length=0,m=this.nonColliders,m.length=0,n=this.groupsLive,n.length=0,d=i.length;d--;)if(x=!1,t=i[d],t.alwaysOn||t.checkCollision||u.collides(t.getAABB())){if(t.checkCollision=!1,j[j.length]=t,w=t.collisionTypes,t!==this.owner)for(e=0;e1){for(h.reset(),this.checkSolidEntityCollision(f,f.collisionGroup,h),b=h.xCount;b--;)g=h.getXEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,g.direction,0,"solid",g.vector);for(b=h.yCount;b--;)g=h.getYEntry(b),a(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,0,g.direction,"solid",g.vector)}}}(),checkSolidCollisions:function(){var a=function(a,b,c,d,e,g,h,i){var j=f;j.entity=b,j.myType=c,j.type=d,j.x=e,j.y=g,j.direction=i,j.hitType=h,a.triggerEvent("hit-by-"+d,j),b&&(j.entity=a,j.type=c,j.myType=d,j.x=-e,j.y=-g,j.direction=i.getInverse(),j.hitType=h,b.triggerEvent("hit-by-"+c,j),j.direction.recycle())};return function(){for(var b=0,c=this.solidEntitiesLive,d=c.length,f=null,g=null,h=e,i=a;d--;){for(f=c[d],h.reset(),this.checkSolidEntityCollision(f,f,h),b=h.xCount;b--;)g=h.getXEntry(b),i(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,g.direction,0,"solid",g.vector);for(b=h.yCount;b--;)g=h.getYEntry(b),i(g.thisShape.owner,g.thatShape.owner,g.thisShape.collisionType,g.thatShape.collisionType,0,g.direction,"solid",g.vector)}}}(),checkSolidEntityCollision:function(a,b,c){var e=0,f=null,g=null,h=a.x-a.previousX,i=a.y-a.previousY,j=1/0,k=1/0,l=b.getCollisionTypes(),m=0,n=!1,o=null;if(b.getSolidEntities&&(n=b.getSolidEntities()),f=d.setUp(a.position),h||i)if(a.bullet){for(o=Math.min,m=l.length;m--;)g=b.getAABB(l[m]),j=o(j,g.width),k=o(k,g.height);for(e=Math.ceil(Math.max(Math.abs(h)/j,Math.abs(i)/k)),e=o(e,100),h/=e,i/=e;e--;){if(b.prepareCollision(a.previousX+h,a.previousY+i),f=this.processCollisionStep(a,b,n,c,f.setVector(a.position),h,i,l),f.x===a.previousX&&f.y===a.previousY){b.relocateEntity(f,c);break}b.relocateEntity(f,c)}}else b.prepareCollision(a.previousX+h,a.previousY+i),b.relocateEntity(this.processCollisionStep(a,b,n,c,f,h,i,l),c);f.recycle()},processCollisionStep:function(){var b=a.setUp(),c=function(a,b,c,d,e,f){var g=0;if(c===a)return!1;if(c.jumpThrough&&b.bottom>d.top)return!1;if(a.jumpThrough&&d.bottom>b.top)return!1;if(e)for(g=e.length;g--;)if(c===e[g])return!1;return f.collides(d)};return function(a,d,e,f,g,h,i,j){for(var k=j.length,l=0,m=0,n=0,o=c,p=!1,q=Array.setUp(),r=null,s=null,t=null,u=null,v=null,w="",x=null,y=null,z=this.entitiesByTypeLive,A=null,B=this.terrain,C=d.getSolidCollisions(),D=null,E=b;k--;)for(q[k]=r=Array.setUp(),u=j[k],s=d.getPreviousAABB(u),t=d.getAABB(u),E.set(t),E.include(s),D=C[u],l=D.length;l--;)if(w=D[l],A=z[w]){for(m=A.length;m--;)if(v=A[m],x=v.getAABB(w),o(a,s,v,x,e,E)){for(y=v.getShapes(w),n=y.length;n--;)r.push(y[n]);p=!0}}else if(B&&"tiles"===w)for(y=B.getTileShapes(E,s),m=y.length;m--;)r.push(y[m]),p=!0;return p&&(g=this.resolveCollisionPosition(a,d,g,q,f,j,h,i)),q.recycle(2),g}}(),resolveCollisionPosition:function(){var a=new b;return function(b,c,d,e,f,g,h,i){var j=0,k=a;if(0!==h)for(j=g.length;j--;)k.clear(),this.findMinAxisMovement(b,c,g[j],"x",e[j],k),k.occurred&&f.tryToAddX(k);if(f.xCount>0?(k.copy(f.getXEntry(0)),d.x=b.previousX+k.deltaMovement*k.direction):d.x=b.x,c.movePreviousX(d.x),0!==i)for(j=g.length;j--;)k.clear(),this.findMinAxisMovement(b,c,g[j],"y",e[j],k),k.occurred&&f.tryToAddY(k);return f.yCount>0?(k.copy(f.getYEntry(0)),d.y=b.previousY+k.deltaMovement*k.direction):d.y=b.y,d}}(),findMinAxisMovement:function(){var a=new b;return function(b,c,d,e,f,g){for(var h=c.getShapes(d),i=c.getPrevShapes(d),j=a,k=h.length;k--;)j.clear(),this.findMinShapeMovementCollision(i[k],h[k],e,f,j),j.occurred&&(!g.occurred||j.deltaMovement=i.top&&l<=i.bottom?j+a.radius:(l=e(l,b.y,i.halfHeight),h=j+c(l,a.radius),d===a?(g.x=-e(k-f*h,b.x,j)/2,l=-l):g.x=e(k,b.x-f*h,j)/2,g.y=l,g.normalize(),h)},g=function(a,b,d,f,g){var h=0,i=b.aABB,j=i.halfHeight,k=a.x,l=a.y;return k>=i.left&&k<=i.right?j+a.radius:(k=e(k,b.x,i.halfWidth),h=j+c(k,a.radius),d===a?(k=-k,g.y=-e(l-f*h,b.y,j)/2):g.y=e(l,b.y-f*h,j)/2,g.x=k,g.normalize(),h)},h={x:{rectangle:{rectangle:function(a,c,d){var e=b;return e.position=d.x-a*(d.aABB.halfWidth+c.aABB.halfWidth),e.contactVector.setXYZ(a,0),e},circle:function(a,c,d){var e=b;return e.position=d.x-a*f(d,c,c,a,e.contactVector.setXYZ(a,0)),e}},circle:{rectangle:function(a,c,d){var e=b;return e.position=d.x-a*f(c,d,c,a,e.contactVector.setXYZ(a,0)),e},circle:function(a,d,e){var f=e.y-d.y,g=e.x-a*c(f,d.radius+e.radius),h=b;return h.contactVector.setXYZ(e.x-g,f).normalize(),h.position=g,h}}},y:{rectangle:{rectangle:function(a,c,d){var e=b;return e.position=d.y-a*(d.aABB.halfHeight+c.aABB.halfHeight),e.contactVector.setXYZ(0,a),e},circle:function(a,c,d){var e=b;return e.position=d.y-a*g(d,c,c,a,e.contactVector.setXYZ(0,a)),e}},circle:{rectangle:function(a,c,d){var e=b;return e.position=d.y-a*g(c,d,c,a,e.contactVector.setXYZ(0,a)),e},circle:function(a,d,e){var f=e.x-d.x,g=e.y-a*c(f,d.radius+e.radius),h=b;return h.contactVector.setXYZ(f,e.y-g).normalize(),h.position=g,h}}}};return function(b,c,d,e,f){var g=0,i=b[d],j=c[d],k=b,l=j>i?1:-1,m=j,n=null,o=null,p=j,q=null;if(i!==j)for(q=h[d][k.type],"x"===d?k.moveX(j):"y"===d&&k.moveY(j),g=e.length;g--;)n=e[g],m=j,k.collides(n)&&(o=q[n.type](l,k,n),m=o.position,l>0?p>m&&(i>m&&(m=i),p=m,a(f,l,p,i,c,n,o.contactVector)):m>p&&(m>i&&(m=i),p=m,a(f,l,p,i,c,n,o.contactVector)))}}(),checkSoftCollisions:function(){var a=function(a){this.triggerEvent("hit-by-"+a.type,a)};return function(b){for(var c=this.softEntitiesLive,d=this.getWorldEntities(),e=null,f=c.length,g=a;f--;)e=c[f],this.checkEntityForSoftCollisions(e,d,g.bind(e))}}(),checkEntityForSoftCollisions:function(a,b,c){var d=null,e=f,g=a.collisionTypes.length,h=0,i=0,j=0,k=0,l=null,m=null,n=null,o=null,p=null,q=null,r=!1;for(e.x=0,e.y=0;g--;)for(l=a.collisionTypes[g],m=a.softCollisionMap[l],h=m.length;h--;)if(o=m[h],n=b[o])for(i=n.length;i--;)if(d=n[i],d!==a&&a.getAABB(l).collides(d.getAABB(o)))for(r=!1,p=a.getShapes(l),q=d.getShapes(o),j=p.length;j--;){for(k=q.length;k--;)if(p[j].collides(q[k])){e.entity=d,e.type=o,e.myType=l,e.shape=q[k],e.hitType="soft",c(e),r=!0;break}if(r)break}},destroy:function(){var a="";this.groupsLive.recycle(),this.nonColliders.recycle(),this.allEntities.recycle(),this.allEntitiesLive.recycle(),this.softEntitiesLive.recycle(),this.solidEntitiesLive.recycle(),this.relocationMessage.position.recycle();for(a in this.entitiesByType)this.entitiesByType.hasOwnProperty(a)&&this.entitiesByType[a].recycle();for(a in this.entitiesByTypeLive)this.entitiesByTypeLive.hasOwnProperty(a)&&this.entitiesByTypeLive[a].recycle();this.cameraLogicAABB.recycle(),this.cameraCollisionAABB.recycle()}},publicMethods:{getWorldEntities:function(){return this.entitiesByTypeLive},getWorldTerrain:function(){return this.terrain},getEntityCollisions:function(a,b){var c=Array.setUp();return this.checkEntityForSoftCollisions(a,b||this.entitiesByTypeLive,function(a){var b="",d={};for(b in a)a.hasOwnProperty(b)&&(d[b]=a[b]);c.push(d)}),c}}})}(),function(){"use strict";var a={kc0:"unknown",kc8:"backspace",kc9:"tab",kc12:"numpad-5-shift",kc13:"enter",kc16:"shift",kc17:"ctrl",kc18:"alt",kc19:"pause",kc20:"caps-lock",kc27:"esc",kc32:"space",kc33:"page-up",kc34:"page-down",kc35:"end",kc36:"home",kc37:"left-arrow",kc38:"up-arrow",kc39:"right-arrow",kc40:"down-arrow",kc42:"numpad-multiply",kc43:"numpad-add",kc44:"print-screen",kc45:"insert",kc46:"delete",kc47:"numpad-division",kc48:"0",kc49:"1",kc50:"2",kc51:"3",kc52:"4",kc53:"5",kc54:"6",kc55:"7",kc56:"8",kc57:"9",kc59:"semicolon",kc61:"equals",kc65:"a",kc66:"b",kc67:"c",kc68:"d",kc69:"e",kc70:"f",kc71:"g",kc72:"h",kc73:"i",kc74:"j",kc75:"k",kc76:"l",kc77:"m",kc78:"n",kc79:"o",kc80:"p",kc81:"q",kc82:"r",kc83:"s",kc84:"t",kc85:"u",kc86:"v",kc87:"w",kc88:"x",kc89:"y",kc90:"z",kc91:"left-windows-start",kc92:"right-windows-start",kc93:"windows-menu",kc96:"back-quote",kc106:"numpad-multiply",kc107:"numpad-add",kc109:"numpad-minus",kc110:"numpad-period",kc111:"numpad-division",kc112:"f1",kc113:"f2",kc114:"f3",kc115:"f4",kc116:"f5",kc117:"f6",kc118:"f7",kc119:"f8",kc120:"f9",kc121:"f10",kc122:"f11",kc123:"f12",kc144:"num-lock",kc145:"scroll-lock",kc186:"semicolon",kc187:"equals",kc188:"comma",kc189:"hyphen",kc190:"period",kc191:"forward-slash",kc192:"back-quote",kc219:"open-bracket",kc220:"back-slash",kc221:"close-bracket",kc222:"quote"};return platypus.createComponentClass({id:"HandlerController",constructor:function(a){this.callbackKeyUp=null,this.callbackKeyDown=null,platypus.game.settings.debug?(this.callbackKeyDown=function(a){this.keyDown(a)}.bind(this),this.callbackKeyUp=function(a){this.keyUp(a)}.bind(this)):(this.callbackKeyDown=function(a){this.keyDown(a),a.preventDefault()}.bind(this),this.callbackKeyUp=function(a){this.keyUp(a),a.preventDefault()}.bind(this)),window.addEventListener("keydown",this.callbackKeyDown,!0),window.addEventListener("keyup",this.callbackKeyUp,!0)},events:{tick:function(a){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-controller",a)}},methods:{keyDown:function(b){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("key:"+(a["kc"+b.keyCode]||"key-code-"+b.keyCode)+":down",b)},keyUp:function(b){this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("key:"+(a["kc"+b.keyCode]||"key-code-"+b.keyCode)+":up",b)},destroy:function(){window.removeEventListener("keydown",this.callbackKeyDown),window.removeEventListener("keyup",this.callbackKeyUp)}}})}(),function(){"use strict";var a=function(a,b){var c=0;for(b.length=0,c=a.length-1;c>-1;c--)b.push(a[c])},b=function(a,b,c){var d=0,e=null;for(b.length=0,d=a.length-1;d>-1;d--)e=a[d],(e.alwaysOn||"undefined"==typeof e.x||e.x>=c.left-c.buffer&&e.x<=c.left+c.width+c.buffer&&e.y>=c.top-c.buffer&&e.y<=c.top+c.height+c.buffer)&&b.push(e)},c=function(a){var b=null,c=!1;for(b in a.state)a.state[b]!==a.lastState[b]&&(a.lastState[b]=a.state[b],c=!0);return c},d=function(a,b,c){return"handle-logic"===a||"handle-post-collision-logic"===a||"prepare-logic"===a};return platypus.createComponentClass({id:"HandlerLogic",properties:{alwaysOn:!1},publicProperties:{buffer:-1,stepLength:5,maxStepsPerTick:100,timeMultiplier:1},constructor:function(c){this.entities=Array.setUp(),this.activeEntities=Array.setUp(),this.alwaysOn?(this.updateList=a,this.camera=null):(this.updateList=b,this.camera={left:0,top:0,width:0,height:0,buffer:this.buffer,active:!1}),this.paused=0,this.leftoverTime=0,this.message={delta:this.stepLength,tick:null,camera:this.camera,movers:this.activeEntities}},events:{"child-entity-added":function(a){a.getMessageIds().some(d)&&this.entities.push(a)},"child-entity-removed":function(a){var b=this.entities.indexOf(a);b>=0&&this.entities.greenSplice(b)},"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&&(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)},tick:function(a){var b=0,d=0,e=null,f=this.message,g=c,h=this.activeEntities,i=this.stepLength;for(this.leftoverTime+=a.delta*this.timeMultiplier,d=Math.floor(this.leftoverTime/i)||1,f.delta=i,this.leftoverTime=Math.max(this.leftoverTime-d*i,0),f.tick=a,this.updateList(this.entities,h,this.camera),d=Math.min(d,this.maxStepsPerTick);d--;)if(this.paused>0&&(this.paused-=i,this.paused<0&&(this.paused=0)),!this.paused){for(this.owner.triggerEventOnChildren&&this.owner.triggerEventOnChildren("handle-ai",f),b=h.length;b--;)e=h[b],e.triggerEvent("prepare-logic",f),e.triggerEvent("handle-logic",f),e.triggerEvent("handle-movement",f);if(b=h.length,this.owner.triggerEvent("check-collision-group",f))for(;b--;)e=h[b],e.triggerEvent("handle-post-collision-logic",f),g(e)&&e.triggerEvent("state-changed",e.state);else for(;b--;)e=h[b],g(e)&&e.triggerEvent("state-changed",e.state)}}},methods:{destroy:function(){this.entities.recycle(),this.activeEntities.recycle()}}})}(),function(){"use strict";var a=include("platypus.Vector");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.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;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,pixiEvent: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.triggerEvent("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(){this.container.mouseTarget?(this.container.visible=!1,this.container.removeDisplayObject=function(){this.container=null}.bind(this)):this.container=null}},publicMethods:{windowToWorld:function(b,c,d){var e=d||a.setUp();return e.x=b.x*this.worldPerWindowUnitWidth,e.y=b.y*this.worldPerWindowUnitHeight,c!==!1&&(e.x-=this.viewport.x*this.worldPerWindowUnitWidth,e.y-=this.viewport.y*this.worldPerWindowUnitHeight),e},worldToWindow:function(b,c,d){var e=d||a.setUp();return e.x=b.x*this.windowPerWorldUnitWidth,e.y=b.y*this.windowPerWorldUnitHeight,c!==!1&&(e.x+=this.viewport.x,e.y+=this.viewport.y),e}}})}(),function(){"use strict";var a=function(a,b,c,d,e,f){var g=0,h=0,i=0,j=a.greenSlice();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="",g=a.greenSlice(),h=null;for(e=0;e0?this.piOverTwo:this.v[1]<0?-this.piOverTwo:this.angle:(h=Math.atan(this.v[1]/this.v[0]),this.v[0]<0&&(h=b+h)),this.v[0]>=0?this.v[0]=e(this.v[0],this.maxVelocity*d(h)):this.v[0]=f(this.v[0],this.maxVelocity*d(h)),this.v[1]>=0?this.v[1]=e(this.v[1],this.maxVelocity*c(h)):this.v[1]=f(this.v[1],this.maxVelocity*c(h)),this.owner.x+=this.v[0],this.owner.y+=this.v[1],this.owner.rotation=h*(180/b)+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}},methods:{destroy:function(){this.v.recycle()}}})}(),function(){"use strict";var a=include("platypus.Entity"),b=0;return platypus.createComponentClass({id:"LogicAttachment",properties:{attachState:"attached",attachment:"",offsetX:0,offsetY:0,offsetZ:.01},publicProperties:{},constructor:function(a){this.state=this.owner.state,this.owner.linkId||(this.owner.linkId="attachment-link-"+b,b+=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}},getAssetList:function(b,c,d){var e=b.attachment||c.attachment||d.attachment;return e?a.getAssetList({type:e}):Array.setUp()}})}(),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(a){platypus.supports.mobile&&"touchstart"!==a.event.type||this.toggle||this.updateState("pressed")},pressup:function(a){platypus.supports.mobile&&"touchend"!==a.event.type&&"touchcancel"!==a.event.type||(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){var b=this.disabled===this.owner.state.disabled;this.last!==b&&(this.last=b)},mousedown:function(a){this.owner.state.down=!0,this.owner.state.disabled||this.useOnce&&this.used||this.onPress&&(this.owner.trigger(this.onPress),a.pixiEvent.stopPropagation(),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),a.pixiEvent.stopPropagation()),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.triggerEvent("add-collision-entity",this.owner)||(this.owner.addComponent(new platypus.components.CollisionGroup(this.owner,{})),this.owner.triggerEvent("add-collision-entity",this.owner))},"carry-me":function(a){this.owner.triggerEvent("add-collision-entity",a.entity)},"release-me":function(a){this.owner.triggerEvent("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.greenSplice(b),this.queue.greenSplice(b))}};return platypus.createComponentClass({id:"LogicDelayMessage",constructor:function(c){var d="";if(this.queueTimes=Array.setUp(),this.queue=Array.setUp(),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){for(var b=this.queue.length;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.greenSplice(b),this.queue.greenSplice(b))))}},methods:{destroy:function(){this.queueTimes.recycle(),this.queue.recycle()}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDestroyMe",properties:{delay:0,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]=!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",speed:.3},constructor:function(a){var d=this.state=this.owner.state;"number"==typeof this.speed&&(this.speed=[this.speed,0,0]),this.initialVector=platypus.Vector.setUp(this.speed),this.reorient=c[this.axis],this.reorient||(this.reorient=b),this.moving=d.moving=!1,this.left=d.left=!1,this.right=d.right=!1,this.up=d.up=!1,this.down=d.down=!1,this.upLeft=!1,this.upRight=!1,this.downLeft=!1,this.downRight=!1,this.heading=0,this.owner.heading=this.owner.heading||0},events:{"component-added":function(a){if(a===this){if(!this.owner.addMover)return void console.warn('The "LogicDirectionalMovement" component requires a "Mover" component to function correctly.');this.direction=this.owner.addMover({velocity:this.speed,drag:0,friction:0,stopOnCollision:!1,orient:!1,aliases:{moving:"control-velocity"}}).velocity,this.owner.heading!==this.heading&&(this.direction.setVector(this.initialVector).rotate(this.owner.heading/180*Math.PI),this.heading=this.owner.heading),this.owner.triggerEvent("moving",this.moving)}},"handle-logic":function(){var a=this.up||this.upLeft||this.downLeft,b=this.upLeft||this.up&&this.left,c=this.left||this.upLeft||this.downLeft,d=this.downLeft||this.down&&this.left,e=this.down||this.downLeft||this.downRight,f=this.downRight||this.down&&this.right,g=this.right||this.upRight||this.downRight,h=this.upRight||this.up&&this.right;if(c&&g||a&&e)this.moving=!1;else if(b)this.moving=!0,this.heading=225;else if(h)this.moving=!0,this.heading=315;else if(d)this.moving=!0,this.heading=135;else if(f)this.moving=!0,this.heading=45;else if(c)this.moving=!0,this.heading=180;else if(g)this.moving=!0,this.heading=0;else if(a)this.moving=!0,this.heading=270;else if(e)this.moving=!0,this.heading=90;else switch(this.moving=!1,this.heading){case 270:a=!0;break;case 90:e=!0;break;case 180:c=!0;break;case 225:a=!0,c=!0;break;case 315:a=!0,g=!0;break;case 135:e=!0,c=!0;break;case 45:e=!0,g=!0;break;case 0:default:g=!0}this.owner.heading!==this.heading&&(this.direction.setVector(this.initialVector).rotate(this.heading/180*Math.PI),this.reorient(this.heading,this.owner.heading),this.owner.heading=this.heading),this.state.moving!==this.moving&&(this.owner.triggerEvent("moving",this.moving),this.state.moving=this.moving),this.state.up!==a&&(this.state.up=a),this.state.right!==g&&(this.state.right=g),this.state.down!==e&&(this.state.down=e),this.state.left!==c&&(this.state.left=c)},"go-down":a("down"),"go-south":a("down"),"go-down-left":a("downLeft"),"go-southwest":a("downLeft"),"go-left":a("left"),"go-west":a("left"),"go-up-left":a("upLeft"),"go-northwest":a("upLeft"),"go-up":a("up"),"go-north":a("up"),"go-up-right":a("upRight"),"go-northeast":a("upRight"),"go-right":a("right"),"go-east":a("right"),"go-down-right":a("downRight"),"go-southeast":a("downRight"),stop:function(a){a&&a.pressed===!1||(this.left=!1,this.right=!1,this.up=!1,this.down=!1,this.upLeft=!1,this.upRight=!1,this.downLeft=!1,this.downRight=!1)},face:function(){var a={up:270,north:270,down:90,south:90,left:180,west:180,right:0,east:0,"up-left":225,northwest:225,"up-right":315,northeast:315,"down-left":135,southwest:135,"down-right":45,southeast:45};return function(b){this.heading=a[b]||0}}(),accelerate:function(a){this.initialVector.normalize().multiply(a),this.direction.normalize().multiply(a)}},methods:{destroy:function(){this.initialVector.recycle()}}})}(),function(){"use strict";return platypus.createComponentClass({id:"LogicDragDrop",constructor:function(a){this.nextX=this.owner.x,this.nextY=this.owner.y,this.grabOffsetX=0,this.grabOffsetY=0,this.owner.state.dragging=!1,this.owner.state.noDrop=!1,this.tryDrop=!1,this.hitSomething=!1},events:{"handle-logic":function(a){this.owner.x=this.nextX,this.owner.y=this.nextY,this.owner.state.noDrop=!1},"handle-post-collision-logic":function(a){this.tryDrop?(this.tryDrop=!1,this.hitSomething?(this.dropFailed=!1,this.owner.state.noDrop=!0,this.owner.state.dragging=!0):(this.owner.state.noDrop=!1,this.owner.state.dragging=!1)):this.hitSomething&&(this.owner.state.noDrop=!0),this.hitSomething=!1},mousedown:function(a){this.grabOffsetX=a.x-this.owner.x,this.grabOffsetY=a.y-this.owner.y,this.owner.state.dragging=!0},mouseup:function(a){this.tryDrop=!0},pressmove:function(a){this.nextX=a.x-this.grabOffsetX,this.nextY=a.y-this.grabOffsetY},"no-drop":function(a){this.hitSomething=!0}},methods:{destroy:function(){this.owner.state.dragging=null,this.owner.state.noDrop=null}},publicMethods:{}})}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"LogicImpactLaunch",properties:{accelerationX:-.3,accelerationY:-.8,flipX:!0,flipY:!1},constructor:function(a){this.stunState=a.state||"stunned",this.flipX=this.flipX?-1:1,this.flipY=this.flipY?-1:1,this.justJumped=!1,this.stunned=!1,this.state=this.owner.state,this.state.impact=!1,this.state[this.stunState]=!1},events:{"component-added":function(b){if(b===this){if(!this.owner.addMover)return void console.warn('The "LogicDirectionalMovement" component requires a "Mover" component to function correctly.');this.direction=this.owner.addMover({velocity:[0,0,0],orient:!1}).velocity,this.vector=a.setUp()}},"handle-logic":function(){this.state.impact!==this.justJumped&&(this.state.impact=this.justJumped),this.state[this.stunState]!==this.stunned&&(this.state[this.stunState]=this.stunned),this.justJumped&&(this.direction.setVector(this.vector),this.justJumped=!1,this.stunned=!0)},"impact-launch":function(a){var b=a.x,c=a.y;a.entity&&(b=a.entity.x-this.owner.x,c=a.entity.y-this.owner.y),this.stunned||(this.justJumped=!0,b>=0?this.vector.x=this.accelerationX:0>b&&(this.vector.x=this.accelerationX*this.flipX),c>=0?this.vector.y=this.accelerationY:0>c&&(this.vector.y=this.accelerationY*this.flipY))},"hit-solid":function(a){this.stunned&&a.y>0&&(this.direction.x=0,this.direction.y=0,this.stunned=!1)}},methods:{destroy:function(){this.vector.recycle()}}})}(),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.dX=this.dist*Math.cos(this.ang), +this.dY=this.dist*Math.sin(this.ang),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=this.period,c=a.delta;this.time+=c,this.time>b&&(this.time=this.time%b),this.offset=this.time/b*2*Math.PI,this.owner.x=this.originX+Math.sin(this.offset+this.startPos)*this.dX,this.owner.y=this.originY+Math.sin(this.offset+this.startPos)*this.dY}}})}(),function(){"use strict";var a={down:!0};return platypus.createComponentClass({id:"LogicPortable",constructor:function(b){this.portableDirections=b.portableDirections||a,this.carrier=this.lastCarrier=null,this.message={entity:this.owner}},events:{"handle-logic":function(a){var b=this.message;this.carrierConnected?(this.carrier!==this.lastCarrier&&(this.lastCarrier&&this.lastCarrier.triggerEvent("release-me",b),this.carrier.triggerEvent("carry-me",b)),this.carrierConnected=!1):this.carrier&&(this.carrier.triggerEvent("release-me",b),this.carrier=null),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}},methods:{destroy:function(){this.pushers.recycle()}}})}(),function(){"use strict";var a=include("platypus.Vector");return platypus.createComponentClass({id:"LogicRebounder",constructor:function(b){platypus.Vector.assign(this.owner,"velocity","dx","dy","dz"),this.owner.mass=this.owner.mass||b.mass||1,this.elasticity=b.elasticity||.8,this.v=a.setUp(0,0,0),this.incidentVector=a.setUp(0,0,0),this.staticCollisionOccurred=!1,this.nonStaticCollisionOccurred=!1,this.hitThisTick=Array.setUp(),this.otherV=a.setUp(0,0,0),this.otherVelocityData=Array.setUp()},events:{"handle-logic":function(a){var b=0;for(this.hitThisTick.length=0,b=0;b=0)){for(this.hitThisTick.push(c),b=0;bb;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))))}},methods:{destroy:function(){this.regions.recycle(),this.usedRegions.recycle()}},getAssetList:function(b,c,d){var e=b.spawn||c.spawn||d.spawn;return e?a.getAssetList({type:e}):Array.setUp()}})}(),function(){"use strict";var a=Math.cos,b=Math.sin,c=function(b,c){return b*a(c)},d=function(a,c){return a*b(c)};return platypus.createComponentClass({id:"LogicRotationalMovement",constructor:function(a){this.speed=a.speed||.3,this.magnitude=0,this.degree=a.degree||1,this.angle=a.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,e=0;this.turningRight&&(this.angle+=this.degree*a.delta/15),this.turningLeft&&(this.angle-=this.degree*a.delta/15),this.moving&&(b=c(this.magnitude,this.angle),e=d(this.magnitude,this.angle)),this.owner.x+=b*a.delta,this.owner.y+=e*a.delta,this.state&&(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.rotation!==this.angle&&(this.owner.rotation=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)}},methods:{destroy:function(){this.state=null}}})}(),function(){"use strict";var a=include("platypus.Entity");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;d0&&a.entity.triggerEvent("teleport",this.destination);break;case"down":a.y>0&&a.entity.triggerEvent("teleport",this.destination);break;case"left":a.x<0&&a.entity.triggerEvent("teleport",this.destination);break;default:a.entity.triggerEvent("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.triggerEvent("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*a.delta,this.owner.triggerEvent("racing")):!this.blocked&&this.left&&this.state.left?(this.owner.x-=this.speed*a.delta,this.owner.triggerEvent("racing")):(this.racing=!1,this.owner.triggerEvent("stopped-racing")):this.winding?((this.right&&this.state.right||this.left&&this.state.left)&&(this.windProgress+=a.delta),this.owner.triggerEvent("winding")):this.windProgress&&(this.windProgress>this.windTime&&(this.racing=!0),this.windProgress=0,this.owner.triggerEvent("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.triggerEvent("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.triggerEvent("blocked",a))}},methods:{destroy:function(){this.state.windingUp=!1,this.state.racing=!1,this.state.blocked=!1}}})}(),function(){"use strict";var a=include("platypus.Vector"),b=function(a,b,c,d){platypus.game.settings.debug&&console.warn('"'+a+'" Motion: The "'+b+'" property has been deprecated. Use "aliases": {"'+c+'": "'+d+'"} instead.')},c=function(){return!0},d=function(a,d){var e=c,f=c,g=c,h=a.owner.state,i=d.controlState,j=d.instantState,k=d.instantSuccess;i&&(a.accelerator?e=function(){return h[i]}:f=function(){return h[i]}),d.event&&(b(a.owner.type,"event",d.event,"control-"+(a.accelerator?"acceleration":"velocity")),a.addEventListener(d.event,function(a){this.active=a&&a.pressed!==!1})),a.instant||d.instantEvent||j||d.instantBegin||d.instantEnd?(j&&(g=function(){return h[j]}),a.instant=!0,(d.instantEvent||d.instantBegin||d.instantEnd)&&(d.instantEvent&&(b(a.owner.type,"instantEvent",d.instantEvent,"instant-motion"),a.addEventListener(d.instantEvent,function(a){this.enact=a&&a.pressed!==!1})),d.instantBegin&&(b(a.owner.type,"instantBegin",d.instantBegin,"instant-begin"),a.addEventListener(d.instantBegin,function(){this.enact=!0})),d.instantEnd&&(b(a.owner.type,"instantEnd",d.instantEnd,"instant-end"),a.addEventListener(d.instantEnd,function(){this.enact=!1}))),a.update=function(a){var b=g(),c=f();if(this.vector&&(this.accelerator?this.activeAcceleration=this.active:this.activeVelocity=this.active),this.activeVelocity){if(this.enact&&!c&&(this.ready=!1),this.ready&&this.enact&&b)this.ready=!1,this.velocity.setVector(this.instant),k&&this.owner.triggerEvent(k);else if(this.ready||this.enact&&b){if(c)return null}else this.ready=!0,this.decay();return this.velocity}return null}):a.update=function(a){return this.vector&&(this.accelerator?this.activeAcceleration=this.active:this.activeVelocity=this.active),this.activeVelocity&&f()?(this.activeAcceleration&&e()&&this.move(a),this.velocity):null}};return platypus.createComponentClass({id:"Motion",properties:{orient:!0,acceleration:0,accelerator:!1,active:!0,activeAcceleration:!0,activeVelocity:!0,maxMagnitude:1/0,event:"",controlState:"",instantEvent:"",instantBegin:"",instantEnd:"",instant:!1,instantState:"",instantSuccess:"",instantDecay:null,vector:0,velocity:0,stopOnCollision:!0,drag:-1,friction:-1},constructor:function(b){var c=this.vector;this.acceleration||(this.activeAcceleration=!1),this.acceleration=a.setUp(this.acceleration),this.velocity=a.setUp(this.velocity),this.triggered=!1,this.ready=!0,"number"==typeof this.instantDecay?this.capMagnitude=this.velocity.magnitude()*this.instantDecay:this.capMagnitude=-1,d(this,b),this.vector&&(this.accelerator&&!this.instant?(this.activeAcceleration=!0,platypus.game.settings.debug&&console.warn('"'+this.owner.type+'" Motion: "vector" and "accelerator" are deprecated. Set "acceleration" to "'+this.vector.toString()+'" instead.'),Object.defineProperty(this,"vector",{get:function(){return this.acceleration}.bind(this),set:function(a){this.acceleration=a}.bind(this)})):(this.activeAcceleration=!1,platypus.game.settings.debug&&console.warn('"'+this.owner.type+'" Motion: "vector" and "accelerator" are deprecated. Set "velocity" to "'+this.vector.toString()+'" instead.'),Object.defineProperty(this,"vector",{get:function(){return this.velocity}.bind(this),set:function(a){this.velocity=a}.bind(this)})),this.vector.set(c)),this.instant&&(this.enact=!1,this.instant=a.setUp(this.velocity),this.velocity.setXYZ(0,0,0)),this.orient&&(this.owner.triggerEvent("orient-vector",this.velocity),this.owner.triggerEvent("orient-vector",this.acceleration))},events:{"control-velocity":function(a){this.activeVelocity=a&&a.pressed!==!1},"stop-velocity":function(){this.activeVelocity=!1},"start-velocity":function(){this.activeVelocity=!0},"control-acceleration":function(a){this.activeAcceleration=a&&a.pressed!==!1},"stop-acceleration":function(){this.activeAcceleration=!1},"start-acceleration":function(){this.activeAcceleration=!0},"instant-motion":function(a){this.enact=a&&a.triggered!==!1},"instant-begin":function(){this.enact=!0},"instant-end":function(){this.enact=!1},"set-vector":function(a){this.vector.set(a),"number"==typeof this.instantDecay?this.capMagnitude=this.vector.magnitude()*this.instantDecay:this.capMagnitude=-1,platypus.game.settings.debug&&!this.setVectorWarning&&(this.setVectorWarning=!0,this.accelerator?console.warn('"'+this.owner.type+'" Motion: The "set-vector" message is deprecated. Trigger "set-motion" with a {"acceleration": '+JSON.stringify(a)+"} message instead."):console.warn('"'+this.owner.type+'" Motion: The "set-vector" message is deprecated. Trigger "set-motion" with a {"velocity": '+JSON.stringify(a)+"} message instead."))},"set-motion":function(a){a.acceleration&&this.acceleration.set(a.acceleration),a.velocity&&(this.velocity.set(a.velocity),"number"==typeof this.instantDecay?this.capMagnitude=this.velocity.magnitude()*this.instantDecay:this.capMagnitude=-1),"number"==typeof a.maxMagnitude&&(this.maxMagnitude=a.maxMagnitude)}},methods:{move:function(b){var c=a.setUp(this.acceleration).multiply(b);return this.velocity.add(c),c.recycle(),this.velocity.magnitude()>this.maxMagnitude&&this.velocity.normalize().multiply(this.maxMagnitude),this.velocity},decay:function(){this.capMagnitude>=0&&this.velocity.magnitude()>this.capMagnitude&&this.velocity.normalize().multiply(this.capMagnitude)},destroy:function(){this.orient&&(this.owner.triggerEvent("remove-vector",this.acceleration),this.owner.triggerEvent("remove-vector",this.velocity)),this.acceleration.recycle(),this.velocity.recycle(),this.instant&&this.instant.recycle()}},publicMethods:{}})}(),function(){"use strict";var a=include("platypus.Vector"),b=a.setUp(),c=function(a,b,c,d){return a&&b!==c?c>b?Math.min(b+a*d,c):Math.max(b-a*d,c):b},d=function(a,b){var d=this.maxMagnitudeInterim=c(this.maxMagnitudeDelta,this.maxMagnitudeInterim,this.maxMagnitude,b);a.magnitude()>d&&a.normalize().multiply(d)},e=function(a,b){var d=this.maxMagnitude,e=this.maxMagnitudeDelta,f=this.maxMagnitudeInterim;f.up=c(e,f.up,d.up,b),f.right=c(e,f.right,d.right,b),f.down=c(e,f.down,d.down,b),f.left=c(e,f.left,d.left,b),a.x>0?a.x>f.right&&(a.x=f.right):a.x<0&&a.x<-f.left&&(a.x=-f.left),a.y>0?a.y>f.down&&(a.y=f.down):a.y<0&&a.y<-f.up&&(a.y=-f.up)};return platypus.createComponentClass({id:"Mover",properties:{ground:[0,1]},publicProperties:{movers:[],gravity:0,jump:0,speed:0,drag:.01,friction:.06,maxMagnitude:1/0,maxMagnitudeDelta:0,reorientVelocities:!0},constructor:function(b){var c=1/0,f=this.maxMagnitude;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.lastVelocity=a.setUp(this.velocity),this.collision=null,this.pause=!1,this.moversCopy=this.movers,this.movers=Array.setUp(),this.velocityChanges=Array.setUp(),this.velocityDirections=Array.setUp(),this.ground=a.setUp(this.ground),Object.defineProperty(this.owner,"maxMagnitude",{get:function(){return c},set:function(a){"number"==typeof a?(this.clamp=d,c=a,this.maxMagnitudeDelta||(this.maxMagnitudeInterim=a)):(this.clamp=e,"number"==typeof c&&(c={up:c,right:c,down:c,left:c}),"number"==typeof a.up&&(c.up=a.up),"number"==typeof a.right&&(c.right=a.right),"number"==typeof a.down&&(c.down=a.down),"number"==typeof a.left&&(c.left=a.left),"number"==typeof this.maxMagnitudeInterim?this.maxMagnitudeDelta?this.maxMagnitudeInterim={up:this.maxMagnitudeInterim,right:this.maxMagnitudeInterim,down:this.maxMagnitudeInterim,left:this.maxMagnitudeInterim}:this.maxMagnitudeInterim={up:c.up,right:c.right,down:c.down,left:c.left}:this.maxMagnitudeDelta||(this.maxMagnitudeInterim.up=c.up,this.maxMagnitudeInterim.right=c.right,this.maxMagnitudeInterim.down=c.down,this.maxMagnitudeInterim.left=c.left))}.bind(this)}),this.maxMagnitudeInterim=0,this.maxMagnitude=f},events:{"component-added":function(a){"Motion"===a.type&&this.movers.push(a)},"component-removed":function(a){var b=0;"Motion"===a.type&&(b=this.movers.indexOf(a),b>=0&&this.movers.greenSplice(b))},load:function(){var a=0,b=this.moversCopy;for(delete this.moversCopy,a=0;a0&&(this.grounded=!0),c=this.velocity.scalarProjection(f),c>0){for(e?(d=Math.max(e.scalarProjection(f),0),c=c>d?d:0):c=0;j--;)if(c0){h[j]=c,i[j].setVector(f),g=!1;break}g&&(h.push(c),i.push(a.setUp(f)))}},"handle-post-collision-logic":function(){var a=null,c=this.movers,d=this.velocityChanges,e=this.velocityDirections,f=d.length,g=c.length,h=null,i=0,j=0,k=null,l=b;if(f){for(k=Array.setUp();g--;)h=c[g],h.stopOnCollision&&k.push(h);for(;f--;){for(a=e[f],i=d[f],g=k.length,j=i/g;g--;)h=k[g],l.setVector(a).normalize().multiply(j-h.velocity.scalarProjection(a)),h.velocity.add(l);a.recycle()}d.length=0,e.length=0}},"set-mover":function(a){"number"==typeof a.maxMagnitudeDelta&&(this.maxMagnitudeDelta=a.maxMagnitudeDelta),a.maxMagnitude&&(this.maxMagnitude=a.maxMagnitude)},"pause-movement":function(){this.paused=!0},"unpause-movement":function(){this.paused=!1},"orientation-updated":function(a){this.reorientVelocities||this.lastVelocity.multiply(a)}},methods:{destroy:function(){var a=0,b=this.maxMagnitude;for(a=this.movers.length-1;a>=0;a--)this.removeMover(this.movers[a]);this.movers.recycle(),this.ground.recycle(),this.lastVelocity.recycle(),this.velocityChanges.recycle(),this.velocityDirections.recycle(),delete this.owner.maxMagnitude,this.owner.maxMagnitude=b}},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=Array.setUp(),this.edgesContain=this.owner.edgesContain=Array.setUp(),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.greenSplice(c),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))}},methods:{addNode:function(a){this.map.push(a),this.nodes[a.id]=a},destroy:function(){var a=0;for(a=0;ai){if(d&&(f=d.indexOf(j[e]),f>=0))break;l=i,k=j[e]}return g.recycle(),h.recycle(),k}}})}(),function(){"use strict";var a=function(a,b,c){return function(d){var e=b.getNode(a);return this.isPassable(e)?(this.destinationNodes.length=0,this.destinationNodes.push(e),this.node?this.onEdge(e):this.distance=0,this.progress=0,this.setState("going-"+c),!0):!1}},b=function(a,b){var c=b.x-a.x,d=b.y-a.y,e=b.z-a.z;return Math.sqrt(c*c+d*d+e*e)},c=function(a,b,c,d){var e=b.x-a.x,f=b.y-a.y,g=0;return a.rotation&&b.rotation?(e=(a.rotation+180)%360,f=(b.rotation+180)%360,(e*(1-d)+f*d+180)%360):c?(g=Math.acos(e/c),0>f&&(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=0;c=this.distance?(g=this.destinationNodes[0],f-=this.distance-this.progress,this.progress=0,this.destinationNodes.greenSplice(0),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.distance,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?(this.lag=e.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(e,i)):this.lag=0:this.setPath(e,i):e.blocked&&(this.blocked=!0),j.recycle())}}(),"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(e.neighbors.hasOwnProperty(b)&&(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?(this.lag=c.distance+(this.followEntity.progress||0)-this.followDistance,this.setPath(c),g=!0):this.lag=0:(this.setPath(c),g=!0):c.blocked&&(this.blocked=!0),f.recycle()),g}}(),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,c=1;ci.shortestPath&&(k=i),l=!1));return k.blocked=m&&l,k},setPath:function(a,b){a.nodes[0]===this.node&&a.nodes.greenSplice(0),this.destinationNodes.recycle(),this.destinationNodes=a.nodes.greenSlice(),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")},destroy:function(){this.destinationNodes.recycle()}}})}(),function(){"use strict";var a=include("platypus.Data"),b=include("platypus.Vector"),c=b.setUp(0,0,1),d=b.setUp(1,0,0),e={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]]},f=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 e=function(a,e){var h=b.setUp(1,0,0),i=a.owner,j=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1));return Object.defineProperty(i,"orientationMatrix",{get:function(){return f(a.matrixTween,a.matrix,g(j)),j},enumerable:!0}),delete i.orientation,Object.defineProperty(i,"orientation",{get:function(){return h.signedAngleTo(d,c)},set:function(a){h.setVector(d).rotate(a)},enumerable:!0}),e&&("number"!=typeof e?h.set(e):h.rotate(e)),h};return function(b){this.loadedOrientationMatrix=this.orientationMatrix,this.matrix=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1)),this.matrixTween=Array.setUp(Array.setUp(1,0,0),Array.setUp(0,1,0),Array.setUp(0,0,1)),this.relocationMessage=a.setUp("position",null),this.vectors=Array.setUp(),this.inverses=Array.setUp(),this.tweens=Array.setUp(),this.orientationVector=e(this,this.orientation),this.owner.triggerEvent("orient-vector",this.orientationVector)}}(),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=this.tweens.length,c=a.delta,d=this.owner.state,e=null,f=null,h=this.relocationMessage;if(b){for(e=Array.setUp(),d.reorienting=!0,g(this.matrixTween);b--;)this.updateTween(this.tweens[b],c)&&e.push(this.tweens.greenSplice(b));for(b=this.vectors.length;b--;)this.updateVector(this.vectors[b],this.inverses[b]);for(b=e.length;b--;)f=e[b],this.transform(f.endMatrix),f.anchor&&(f.offset.multiply(f.endMatrix).addVector(f.anchor),h.position=f.offset,this.owner.triggerEvent("relocate-entity",h),f.recycleOffset&&f.offset.recycle()),f.onFinished(f.endMatrix),f.recycle();e.recycle()}else d.reorienting&&(g(this.matrixTween),d.reorienting=!1)},"complete-tweens":function(){var a=0;for(a=0;a=0&&(this.vectors.greenSplice(b),this.inverses.greenSplice(b).recycle())},"tween-transform":function(){var b=function(){},c=function(){return!0},d=function(a){return a};return function(f){var g=null,h=f.angle||0,i=f.matrix,j=a.setUp("transform",f.transform,"anchor",f.anchor,"endTime",f.time||0,"time",0,"tween",f.tween||d,"onFinished",f.onFinished||b,"beforeTick",f.beforeTick||c,"afterTick",f.onTick||f.afterTick||b);if(i||(i=e[f.transform]),j.endMatrix=i,!h&&0===f.transform.indexOf("rotate"))switch(f.transform){case"rotate-90":h=Math.PI/2;break;case"rotate-180":h=Math.PI;break;case"rotate-270":h=-Math.PI/2;break;default:g=f.transform.greenSplit("-"),h=g[1]/180*Math.PI,g.recycle()}j.angle=h,f.anchor&&(j.offset=f.offset,j.offset||(j.offset=this.owner.position.copy().subtractVector(f.anchor,2),j.recycleOffset=!0)),this.tweens.push(j)}}(),transform:function(a){this.transform(a)},"prepend-transform":function(a){this.transform(a)},"append-transform":function(a){this.transform(a,!0)},"replace-transform":function(a){this.replace(a)}},methods:{transform:function(a,b){Array.isArray(a)?this.multiply(a,b):"string"==typeof a&&e[a]&&this.multiply(e[a],b)},multiply:function(){return function(a,b){var c=0;for(b?f(this.matrix,a,this.matrix):f(a,this.matrix,this.matrix),c=0;cb;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=Array.setUp(Array.setUp(),Array.setUp(),Array.setUp()),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){var b=c(this.matrix);this.multiply(b),this.multiply(a),b.recycle(2)}}(),updateTween:function(){var a=function(a,b,c){return a*(1-c)+b*c};return function(c,d){var e=0,g=1,h=0,i=0,j=1,k=1,l=0,m=c.endMatrix,n=null,o=null,p=null;return c.beforeTick(c.time)&&(c.time+=d),c.time>=c.endTime?!0:(e=c.tween(c.time/c.endTime),c.angle?(l=e*c.angle,g=j=Math.cos(l),h=Math.sin(l),i=-h):(g=a(g,m[0][0],e),h=a(h,m[1][0],e),i=a(i,m[0][1],e),j=a(j,m[1][1],e),k=a(k,m[2][2],e)),n=Array.setUp(Array.setUp(g,i,0),Array.setUp(h,j,0),Array.setUp(0,0,k)),f(n,this.matrixTween,this.matrixTween),c.anchor&&(o=b.setUp(c.offset).multiply(1-e),p=b.setUp(c.offset).multiply(e),this.owner.triggerEvent("relocate-entity",{position:o.add(p).multiply(n).addVector(c.anchor)}),o.recycle(),p.recycle()),c.afterTick(e,n),void n.recycle(2))}}(),updateVector:function(a,b){b.setVector(a.add(b)),a.multiply(this.matrixTween),b.subtractVector(a)},destroy:function(){this.vectors.recycle(),this.inverses.recycle(),this.tweens.recycle(),this.orientationVector.recycle(),this.orientationMatrix.recycle(2),this.matrix.recycle(2),this.matrixTween.recycle(2),this.relocationMessage.recycle()}}})}(),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=0&&this.owner.familyLinks.greenSplice(b),a(this.owner.familyLinks,"family-member-removed",this.owner),this.events=null}}})}(),function(){"use strict";var a=function(a){return function(b,c){platypus.game.currentScene.triggerOnChildren(a,b,c)}};return platypus.createComponentClass({id:"RelayGame",properties:{events:{}},constructor:function(){var b="";for(b in this.events)this.events.hasOwnProperty(b)&&this.addEventListener(b,a(this.events[b]))}})}(),function(){"use strict";var a=function(a){return function(b,c){var d=0;for(d=0;d=0&&this.links.greenSplice(b)}},methods:{resolveAdoption:function(a){for(var b=this.owner.parent;b.parent;)b=b.parent;this.linkMessage.reciprocate=!0,b.triggerOnChildren("link-entity",this.linkMessage,!0)},destroy:function(){var a=0;for(a=0;a=0)&&this.owner.parent.removeEntity(this.owner)}},methods:{destroy:function(){this.animationIds&&(this.animationIds.recycle(),delete this.animationIds)}}})}(),function(){"use strict";return platypus.createComponentClass({id:"RenderProgress",properties:{backgroundColor:0,color:16777215,rotate:!1,mirror:!1,flip:!1,width:100,height:20,regX:0,regY:0},publicProperties:{x:0,y:0,z:0},constructor:function(a){var b=new PIXI.Graphics,c=new PIXI.Graphics,d=new PIXI.Container;this.parentContainer=null,this.background=b,this.progress=c,this.container=d,"string"==typeof this.backgroundColor&&(this.backgroundColor=+this.backgroundColor.replace("#","0x")),"string"==typeof this.color&&(this.color=+this.color.replace("#","0x")),b.f(this.backgroundColor).r(-this.regX,-this.regY,this.width,this.height),c.f(this.color).r(-this.regX,-this.regY,this.width,this.height),c.scale=new PIXI.Point(1e-4,1),d.addChild(b),d.addChild(c)},events:{"handle-render-load":function(a){!this.parentContainer&&a&&a.container&&(this.parentContainer=a.container,this.parentContainer.addChild(this.container))},"handle-render":function(a){this.container&&(this.parentContainer||(a&&a.container?(this.parentContainer=a.container,this.parentContainer.addChild(this.container)):(console.warn('No PIXI Stage, removing ProgressRender component from "'+this.owner.type+'".'),this.owner.removeComponent(this))),this.container.x=this.x,this.container.y=this.y,this.container.z=this.z)},"update-progress":function(a){isNaN(a)?"number"==typeof a.fraction?this.progress.scale.x=a.fraction:"number"==typeof a.total&&"number"==typeof a.progress&&(this.progress.scale.x=a.progress/a.total):this.progress.scale.x=a}},methods:{destroy:function(){this.parentContainer&&(this.parentContainer.removeChild(this.container),this.parentContainer=null),this.container=null}}})}(),function(){"use strict";var a=include("platypus.Data"),b=new PIXI.Matrix,c=/ /g,d=function(a){return function(b){this.animationFinished||this.lastState>=-1?(this.currentAnimation=a,this.lastState=-1,this.animationFinished=!1,this.sprite.gotoAndPlay(a)):(this.waitingAnimation=a,this.waitingState=-1)}},e=function(a,b){var d=0,e=a.replace(c,"").greenSplit(",");return"default"===a?function(a){return b}:function(a){for(d=0;dthis.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(b,c){var d=null;this.container&&(d=a.setUp("event",b.data.originalEvent,"pixiEvent",b,"x",b.data.global.x/this.parentContainer.transformMatrix.a+this.camera.left,"y",b.data.global.y/this.parentContainer.transformMatrix.d+this.camera.top,"entity",this.owner),this.owner.trigger(c,d),d.recycle())},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){a||(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){a&&(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||Array.setUp(),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,b){this.id=b,this.instances=Array.setUp(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=Array.setUp(this.createMap(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=Array.setUp(),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]=Array.setUp()),c=f;g>c;c++)this.doMap[b][c]||(this.doMap[b][c]=Array.setUp()),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),o.setUp(c,a))},createMap:function(a){var b=0,c=0,d="",e=null,f=this.tiles,g=null;if("string"!=typeof a[0][0])return a;for(e=Array.setUp(),b=0;bb.bottom||db.right||cb.bottom||db.right||c>>0},b=function(a,b){return a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24)>>>0};return function(c,d){var e=4,f=[],g=atob(c.replace(/\\/g,""));if("zlib"===d)for(g=pako.inflate(g);e<=g.length;)f.push(b(g,e-4)),e+=4;else for(;e<=g.length;)f.push(a(g.substr(e-4,4))),e+=4;return f}}(),d=function(a){var b=!!(536870912&a),c=!!(1073741824&a),d=!!(2147483648&a);return b&&d?-3:b?-5:c?-4:-2},e={x:1,y:1,id:-1},f=function(a){var b=e,c=!!(1073741824&a),d=!!(2147483648&a);return b.id=268435455&a,b.x=1,b.y=1,c&&(b.y=-1),d&&(b.x=-1),b},g=function(a,b){var c=0,d=a.gid||-1,g={},i={gid:-1,transform:null,properties:g,type:""},j=null,k=null;for(-1!==d&&(i.transform=f(d),d=i.gid=e.id),c=0;cd);c++)k=b[c];return k&&k.tileproperties&&k.tileproperties[d-k.firstgid]&&(j=k.tileproperties[d-k.firstgid]),""!==a.type?i.type=a.type:""!==a.name?i.type=a.name:j&&(i.type=j.entity||j.type||""),i.type?(i.transform?(g.scaleX=i.transform.x,g.scaleY=i.transform.y):(g.scaleX=1,g.scaleY=1),h(j,i.properties),h(a.properties,i.properties),i):null},h=function(a,b){var c="";if(a&&b)for(c in a)a.hasOwnProperty(c)&&(b[c]=i(a[c]));return b},i=function(a){var b=0;if("string"==typeof a){if(b=parseFloat(a),0===b||b)return b;if("true"===a)return!0;if("false"===a)return!1;if(a.length>1&&("{"===a[0]&&"}"===a[a.length-1]||"["===a[0]&&"]"===a[a.length-1]))try{return JSON.parse(a)}catch(c){}}return a},j=function(a,c){var d=0,e=0,f=Array.setUp(),h=Array.setUp(),i=null,j=null;if("string"==typeof a&&(a=platypus.game.settings.levels[a]),a)if(a.tilesets=m(a.tilesets),a.assets)h.union(a.assets);else{for(d=0;db;b++)e.data.push(1);return this.assetCache.read(a.name)?(e.image=a.name,e.tileheight=this.assetCache.read(a.name).height,e.tilewidth=this.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}.bind(this),M=function(a,c){var g=null,m=c.width,n=c.height,o=c.tileheight||l,p=c.tilewidth||j,q=0,r=0,s=0,t=JSON.parse(JSON.stringify(platypus.game.settings.entities[a]||k[a])),u=null,v=null,w=null,x=!1,y=null,z=null,A=0,B=0,C=0,D="",E=null;if(this.decodeLayer(c),E=c.data,t.properties=t.properties||{},c.properties){if(c.properties.width&&(q=parseInt(c.properties.width,10)),c.properties.height&&(r=parseInt(c.properties.height,10)),q||r){for(q=q||m,r=r||n,E=[],B=0;q>B;B++)for(C=0;r>C;C++)m>B&&n>C?E[B+C*q]=c.data[B+C*m]:E[B+C*q]=0;m=q,n=r}h(c.properties,t.properties)}if(u={},v=[],w=[],"collision-layer"===a)for(z=[],B=0;BB;B++)u["tile"+B]=B;for(B=0;m>B;B++)for(v[B]=[],w[B]=[],C=0;n>C;C++)A=+E[B+C*m]-1,w[B][C]="tile"+A,z&&z.length&&z[0]===(268435455&A)&&(A=d(A)),v[B][C]=A;for(B=0;BC&&(C=I[p].x),I[p].xE&&(E=I[p].y),I[p].y this.top) && (aabb.top < this.bottom) && (aabb.right > this.left) && (aabb.left < this.right); + }; + + /** + * Expresses whether this AABB intersects the given AABB. This is similar to `collides` but returns true for overlapping only, not touching edges. * * @method intersects * @param aabb {AABB} The AABB to check against diff --git a/src/CollisionDataContainer.js b/src/CollisionDataContainer.js index f144fdfd..ccbd14c4 100644 --- a/src/CollisionDataContainer.js +++ b/src/CollisionDataContainer.js @@ -30,7 +30,7 @@ platypus.CollisionData = (function () { this.aABB = dataToCopy.aABB; this.thisShape = dataToCopy.thisShape; this.thatShape = dataToCopy.thatShape; - this.vector.set(dataToCopy.vector); + this.vector.setVector(dataToCopy.vector); this.stuck = dataToCopy.stuck; }; proto.clear = function () { @@ -41,7 +41,7 @@ platypus.CollisionData = (function () { this.aABB = null; this.thisShape = null; this.thatShape = null; - this.vector.set(0, 0, 0); + this.vector.setXYZ(0, 0, 0); this.stuck = 0; }; return collisionData; diff --git a/src/CollisionShape.js b/src/CollisionShape.js index e13a014e..cd10cfc7 100644 --- a/src/CollisionShape.js +++ b/src/CollisionShape.js @@ -22,61 +22,100 @@ platypus.CollisionShape = (function () { "use strict"; - var Vector = include('platypus.Vector'), - collisionShape = function (owner, definition, collisionType) { + var AABB = include('platypus.AABB'), + Vector = include('platypus.Vector'), + circleRectCollision = function (circle, rect) { + var rectAabb = rect.aABB, + hh = rectAabb.halfHeight, + hw = rectAabb.halfWidth, + abs = Math.abs, + pow = Math.pow, + shapeDistanceX = abs(circle.x - rect.x), + shapeDistanceY = abs(circle.y - rect.y), + radius = circle.radius; + + /* This checks the following in order: + - Is the x or y distance between shapes less than half the width or height respectively of the rectangle? If so, we know they're colliding. + - Is the x or y distance between the shapes greater than the half width/height plus the radius of the circle? Then we know they're not colliding. + - Otherwise, we check the distance between a corner of the rectangle and the center of the circle. If that distance is less than the radius of the circle, we know that there is a collision; otherwise there is not. + */ + return (shapeDistanceX < hw) || (shapeDistanceY < hh) || ((shapeDistanceX < (hw + radius)) && (shapeDistanceY < (hh + radius)) && ((pow((shapeDistanceX - hw), 2) + pow((shapeDistanceY - hh), 2)) < pow(radius, 2))); + }, + collidesCircle = function (shape) { + var pow = Math.pow; + + return this.aABB.collides(shape.aABB) && ( + ((shape.type === 'rectangle') && circleRectCollision(this, shape)) || + ((shape.type === 'circle') && ((pow((this.x - shape.x), 2) + pow((this.y - shape.y), 2)) <= pow((this.radius + shape.radius), 2))) + ); + }, + collidesDefault = function () { + return false; + }, + collidesRectangle = function (shape) { + return this.aABB.collides(shape.aABB) && ( + (shape.type === 'rectangle') || + ((shape.type === 'circle') && circleRectCollision(shape, this)) + ); + }, + CollisionShape = function (owner, definition, collisionType) { var regX = definition.regX, regY = definition.regY, - width = 0, - height = 0; + width = definition.width || definition.radius * 2 || 0, + height = definition.height || definition.radius * 2 || 0, + radius = definition.radius || 0, + type = definition.type || 'rectangle'; + + // If this shape is recycled, the vectors will already be in place. + if (!this.initialized) { + this.initialized = true; + Vector.assign(this, 'offset', 'offsetX', 'offsetY'); + Vector.assign(this, 'position', 'x', 'y'); + Vector.assign(this, 'size', 'width', 'height'); + this.aABB = AABB.setUp(); + } this.owner = owner; this.collisionType = collisionType; - - this.width = definition.width || definition.radius * 2 || 0; - this.height = definition.height || definition.radius * 2 || 0; - this.radius = definition.radius || 0; + this.type = type; + this.subType = ''; + + /** + * Determines whether shapes collide. + * + * @method collides + * @param shape {platypus.CollisionShape} The shape to check against for collision. + * @return {Boolean} Whether the shapes collide. + * @since 0.7.4 + */ + if (type === 'circle') { + width = height = radius * 2; + this.collides = collidesCircle; + } else if (type === 'rectangle') { + this.collides = collidesRectangle; + } else { + this.collides = collidesDefault; + } + this.size.setXYZ(width, height); + this.radius = radius; if (typeof regX !== 'number') { - regX = this.width / 2; + regX = width / 2; } if (typeof regY !== 'number') { - regY = this.height / 2; + regY = height / 2; } + this.offset.setXYZ(definition.offsetX || ((width / 2) - regX), definition.offsetY || ((height / 2) - regY)); - Vector.assign(this, 'offset', 'offsetX', 'offsetY'); - this.offsetX = definition.offsetX || ((this.width / 2) - regX); - this.offsetY = definition.offsetY || ((this.height / 2) - regY); - - Vector.assign(this, 'position', 'x', 'y'); if (owner) { - this.x = owner.x + this.offsetX; - this.y = owner.y + this.offsetY; + this.position.setXYZ(owner.x, owner.y).add(this.offset); } else { - this.x = definition.x + this.offsetX; - this.y = definition.y + this.offsetY; - } - - this.type = definition.type || 'rectangle'; - this.subType = ''; - this.aABB = undefined; - - switch (this.type) { - case 'circle': //need TL and BR points - width = height = this.radius * 2; - break; - case 'rectangle': //need TL and BR points - width = this.width; - height = this.height; - break; + this.position.setXYZ(definition.x, definition.y).add(this.offset); } - Vector.assign(this, 'size', 'width', 'height'); - this.width = width; - this.height = height; - - this.aABB = new platypus.AABB(this.x, this.y, width, height); + this.aABB.setAll(this.x, this.y, width, height); }, - proto = collisionShape.prototype; + proto = CollisionShape.prototype; /** * Updates the location of the shape and AABB. The position you send should be that of the owner, the offset of the shape is added inside the function. @@ -89,8 +128,7 @@ platypus.CollisionShape = (function () { var x = ownerX + this.offsetX, y = ownerY + this.offsetY; - this.x = x; - this.y = y; + this.position.setXYZ(x, y); this.aABB.move(x, y); }; @@ -152,9 +190,10 @@ platypus.CollisionShape = (function () { * Destroys the shape so that it can be memory collected safely. * * @method destroy + * @deprecated since 0.7.4 - Use `recycle()` instead. */ proto.destroy = function () { - this.aABB = undefined; + this.recycle(); }; /** @@ -164,18 +203,43 @@ platypus.CollisionShape = (function () { * @param matrix {Array} A matrix used to transform the shape. */ proto.multiply = function (m) { - this.position.subtractVector(this.owner.position); + var pos = this.position, + own = this.owner.position; + + pos.subtractVector(own); - this.position.multiply(m); + pos.multiply(m); this.offset.multiply(m); this.size.multiply(m); - this.position.addVector(this.owner.position); + pos.addVector(own); this.width = Math.abs(this.width); this.height = Math.abs(this.height); this.aABB.setAll(this.x, this.y, this.width, this.height); }; - return collisionShape; + /** + * Returns an CollisionShape from cache or creates a new one if none are available. + * + * @method CollisionShape.setUp + * @return {platypus.CollisionShape} The instantiated CollisionShape. + * @since 0.7.4 + */ + /** + * Returns a CollisionShape back to the cache. + * + * @method CollisionShape.recycle + * @param {platypus.CollisionShape} The CollisionShape to be recycled. + * @since 0.7.4 + */ + /** + * Relinquishes properties of the CollisionShape and recycles it. + * + * @method recycle + * @since 0.7.4 + */ + platypus.setUpRecycle(CollisionShape, 'CollisionShape'); + + return CollisionShape; }()); diff --git a/src/Component.js b/src/Component.js index f2a45109..25ace8af 100644 --- a/src/Component.js +++ b/src/Component.js @@ -50,22 +50,26 @@ platypus.Component = (function () { proto.destroy = function () { var func = ''; - // Handle component's destroy method before removing messaging and methods. - if (this._destroy) { - this._destroy(); - } - - // Now remove event listeners and methods. - for (func in this.publicMethods) { - if (this.publicMethods.hasOwnProperty(func)) { - this.removeMethod(func); + if (this.listener) { + // Handle component's destroy method before removing messaging and methods. + if (this._destroy) { + this._destroy(); + } + + // Now remove event listeners and methods. + for (func in this.publicMethods) { + if (this.publicMethods.hasOwnProperty(func)) { + this.removeMethod(func); + } } + this.publicMethods.recycle(); + + this.removeEventListeners(); + this.listener.events.recycle(); + this.listener.messages.recycle(); + this.listener.recycle(); + this.listener = null; } - this.publicMethods.recycle(); - this.removeEventListeners(); - this.listener.events.recycle(); - this.listener.messages.recycle(); - this.listener.recycle(); }; /** diff --git a/src/Entity.js b/src/Entity.js index cea1e22d..fa663bf7 100644 --- a/src/Entity.js +++ b/src/Entity.js @@ -226,17 +226,23 @@ platypus.Entity = (function () { **/ proto.messengerDestroy = proto.destroy; proto.destroy = function () { - var i = 0; + var components = this.components, + i = components.length; - for (i = 0; i < this.components.length; i++) { - this.components[i].destroy(); + if (!this._destroyed) { + while (i--) { + components[i].destroy(); + } + components.recycle(); + + this.state.recycle(); + this.state = null; + + this.lastState.recycle(); + this.lastState = null; + + this.messengerDestroy(); } - this.components.recycle(); - - this.state.recycle(); - this.lastState.recycle(); - - this.messengerDestroy(); }; /** diff --git a/src/Game.js b/src/Game.js index 397f3776..c3a98bda 100644 --- a/src/Game.js +++ b/src/Game.js @@ -212,7 +212,7 @@ platypus.Game = (function () { sceneInstance.data = data; this.app.manager.addState(id, sceneInstance); this.stage.addChild(sceneInstance.panel); - this.app.triggerEvent('stateAdded', id, sceneInstance); + this.app.trigger('stateAdded', id, sceneInstance); this.app.manager.state = id; } }; diff --git a/src/Messenger.js b/src/Messenger.js index f727a4d0..e1400b58 100644 --- a/src/Messenger.js +++ b/src/Messenger.js @@ -5,7 +5,7 @@ * @class Messenger * @extends springroll.EventDispatcher */ -/*global console, platypus */ +/*global console, extend, platypus */ /*jslint plusplus:true */ platypus.Messenger = (function () { "use strict"; @@ -17,6 +17,7 @@ platypus.Messenger = (function () { this.loopCheck = Array.setUp(); }, debug = !!springroll.Debug, + perfTools = debug && window.performance && window.performance.mark && window.performance.measure && window.performance, // End with this to set perfTools to window.performance proto = extend(Messenger, EventDispatcher); /** @@ -71,12 +72,12 @@ platypus.Messenger = (function () { var count = 0, i = 0, listener = null, - listeners = null, + listeners = this._listeners, args = null; - if (!this._destroyed && this._listeners.hasOwnProperty(type) && (this._listeners[type] !== undefined)) { - // copy the listeners array - listeners = this._listeners[type].greenSlice(); + if (!this._destroyed && listeners.hasOwnProperty(type) && (listeners[type] !== undefined)) { + // copy the listeners array; reusing `listeners` variable + listeners = listeners[type].greenSlice(); if (arguments.length > 1) { args = Array.prototype.greenSlice.call(arguments); @@ -123,13 +124,13 @@ platypus.Messenger = (function () { } this.loopCheck.push(event); - if (window.performance) { - window.performance.mark("a"); + if (perfTools) { + perfTools.mark("a"); } count = this._triggerEvent(event, value, debug); - if (window.performance) { - window.performance.mark("b"); - window.performance.measure(this.type + ":" + event, 'a', 'b'); + if (perfTools) { + perfTools.mark("b"); + perfTools.measure(this.type + ":" + event, 'a', 'b'); } this.loopCheck.length = this.loopCheck.length - 1; if (debugLogging) { diff --git a/src/Vector.js b/src/Vector.js index f43ae5b9..07eaafac 100644 --- a/src/Vector.js +++ b/src/Vector.js @@ -14,7 +14,9 @@ platypus.Vector = (function () { "use strict"; var Vector = function (x, y, z) { - this.matrix = Array.setUp(0, 0, 0); + if (!this.matrix) { // Recycled vectors will already have a matrix array + this.matrix = Array.setUp(); + } this.set(x, y, z); }, proto = Vector.prototype; @@ -87,27 +89,65 @@ platypus.Vector = (function () { * @chainable */ proto.set = function (x, y, z) { - var m = null, - q = 0, + if (x && x.matrix) { // Passing in a vector. + return this.setVector(x, y); + } else if (x && Array.isArray(x)) { // Passing in an array. + return this.setArray(x, y); + } else { // Passing in coordinates. + return this.setXYZ(x, y, z); + } + }; + + /** + * Sets the coordinates of the vector. + * + * @method setXYZ + * @param x {number} The x coordinate. + * @param [y] {number} The y coordinate. + * @param [z] {number} The z coordinate. + * @chainable + * @since 0.7.4 + */ + proto.setXYZ = function (x, y, z) { + var matrix = this.matrix; + + matrix[0] = x || 0; + matrix[1] = y || 0; + matrix[2] = z || 0; + + return this; + }; + + /** + * Sets the coordinates of the vector. + * + * @method setVector + * @param vector {Vector} The Vector to copy. + * @param [dimensions] {number} The number of elements to copy from the Vector. + * @chainable + * @since 0.7.4 + */ + proto.setVector = function (vector, dimensions) { + return this.setArray(vector.matrix, dimensions); + }; + + /** + * Sets the coordinates of the vector. + * + * @method setArray + * @param arr {Array} The array to copy. + * @param [dimensions] {number} The number of elements to copy from the Array. + * @chainable + * @since 0.7.4 + */ + proto.setArray = function (arr, dimensions) { + var q = dimensions || arr.length, matrix = this.matrix; - if (x && Array.isArray(x)) { // Passing in an array. - q = y || x.length; - while (q--) { - matrix[q] = x[q]; - } - } else if (x && x.matrix) { // Passing in a vector. - m = x.matrix; - q = y || m.length; - while (q--) { - matrix[q] = m[q]; - } - } else { // Passing in coordinates. - matrix[0] = x || 0; - matrix[1] = y || 0; - matrix[2] = z || 0; + while (q--) { + matrix[q] = arr[q]; } - + return this; }; @@ -153,10 +193,9 @@ platypus.Vector = (function () { * * @param otherVector {platypus.Vector} The other vector. * @chainable + * @deprecated since 0.7.4 - Use `setVector` instead. */ - proto.copyValues = function (otherVector) { - return this.set(otherVector); - }; + proto.copyValues = proto.setVector; /** * Returns the magnitude of the vector. @@ -290,14 +329,14 @@ platypus.Vector = (function () { if (a) { if (a === 'x') { - a = temp.set(1, 0, 0); + a = temp.setXYZ(1, 0, 0); } else if (a === 'y') { - a = temp.set(0, 1, 0); + a = temp.setXYZ(0, 1, 0); } else if (a === 'z') { - a = temp.set(0, 0, 1); + a = temp.setXYZ(0, 0, 1); } } else { - a = temp.set(0, 0, 1); + a = temp.setXYZ(0, 0, 1); } x = a.x; @@ -607,7 +646,7 @@ platypus.Vector = (function () { * @since 0.7.1 */ proto.recycle = function () { - this.matrix.recycle(); + this.matrix.length = 0; Vector.recycle(this); }; diff --git a/src/components/AIChaser.js b/src/components/AIChaser.js index 1ac56e4a..0c0e45dc 100644 --- a/src/components/AIChaser.js +++ b/src/components/AIChaser.js @@ -86,7 +86,7 @@ if (m) { c = true; - this.direction.set(v).normalize().multiply(this.speed); + this.direction.setVector(v).normalize().multiply(this.speed); } v.recycle(); diff --git a/src/components/CollisionBasic.js b/src/components/CollisionBasic.js index ad1793c7..0cd24954 100644 --- a/src/components/CollisionBasic.js +++ b/src/components/CollisionBasic.js @@ -54,17 +54,17 @@ if (collisionInfo.myType === collisionType) { if (collisionInfo.hitType === solidOrSoft) { if ((dy > 0) && event.bottom) { - this.owner.triggerEvent(event.bottom, collisionInfo); + this.owner.trigger(event.bottom, collisionInfo); } else if ((dy < 0) && event.top) { - this.owner.triggerEvent(event.top, collisionInfo); + this.owner.trigger(event.top, collisionInfo); } if ((dx > 0) && event.right) { - this.owner.triggerEvent(event.right, collisionInfo); + this.owner.trigger(event.right, collisionInfo); } else if ((dx < 0) && event.left) { - this.owner.triggerEvent(event.left, collisionInfo); + this.owner.trigger(event.left, collisionInfo); } if (event.all) { - this.owner.triggerEvent(event.all, collisionInfo); + this.owner.trigger(event.all, collisionInfo); } } } @@ -479,8 +479,8 @@ this.prevShapes = Array.setUp(); this.entities = undefined; for (x = 0; x < shapes.length; x++) { - this.shapes.push(new CollisionShape(this.owner, shapes[x], this.collisionType)); - this.prevShapes.push(new CollisionShape(this.owner, shapes[x], this.collisionType)); + this.shapes.push(CollisionShape.setUp(this.owner, shapes[x], this.collisionType)); + this.prevShapes.push(CollisionShape.setUp(this.owner, shapes[x], this.collisionType)); this.prevAABB.include(this.prevShapes[x].aABB); this.aabb.include(this.shapes[x].aABB); } @@ -521,17 +521,24 @@ * On receiving this message, the component triggers `add-collision-entity` on the parent. * * @method 'collide-on' + * @param type {String} If specified, only collision components of this type are added to the collision list. */ "collide-on": function (type) { + var owner = this.owner, + colType = this.collisionType, + colTypes = owner.collisionTypes; + /** * On receiving 'collide-on', this message is triggered on the parent to turn on collision. * * @event 'add-collision-entity' * @param entity {platypus.Entity} The entity this component is attached to. */ - if (!type || (type === this.collisionType)) { - this.owner.collisionTypes.union([this.collisionType]); - this.owner.parent.triggerEvent('add-collision-entity', this.owner); + if ((typeof type !== 'string') || (type === colType)) { + if (colTypes.indexOf(colType) === -1) { + colTypes.push(colType); + } + owner.parent.triggerEvent('add-collision-entity', owner); this.active = true; } }, @@ -540,9 +547,14 @@ * On receiving this message, the component triggers `remove-collision-entity` on the parent. * * @method 'collide-off' + * @param type {String} If specified, only collision components of this type are removed from the collision list. */ "collide-off": function (type) { - var index = 0; + var index = 0, + owner = this.owner, + parent = owner.parent, + colType = this.collisionType, + colTypes = owner.collisionTypes; /** * On receiving 'collide-off', this message is triggered on the parent to turn off collision. @@ -550,17 +562,17 @@ * @event 'remove-collision-entity' * @param entity {platypus.Entity} The entity this component is attached to. */ - if (!type || (type === this.collisionType)) { - this.owner.parent.triggerEvent('remove-collision-entity', this.owner); - index = this.owner.collisionTypes.indexOf(this.collisionType); + if ((typeof type !== 'string') || (type === colType)) { + parent.triggerEvent('remove-collision-entity', owner); + index = colTypes.indexOf(colType); if (index >= 0) { - this.owner.collisionTypes.greenSplice(index); + colTypes.greenSplice(index); } this.active = false; - } - if (this.owner.collisionTypes.length) { - this.owner.parent.triggerEvent('add-collision-entity', this.owner); + if (colTypes.length) { + parent.triggerEvent('add-collision-entity', owner); + } } }, @@ -592,9 +604,9 @@ } if (resp.relative) { - owner.position.set(owner.previousPosition).add(resp.position); + owner.position.setVector(owner.previousPosition).add(resp.position); } else { - owner.position.set(resp.position); + owner.position.setVector(resp.position); } if (this.stuck) { @@ -616,7 +628,7 @@ aabb.include(shape.aABB); } - owner.previousPosition.set(owner.position); + owner.previousPosition.setVector(owner.position); if (um > 0) { // to force check in all directions for ultimate stuck resolution (esp. for stationary entities) if (!this.stuck) { @@ -734,15 +746,25 @@ colFuncs[this.collisionType].recycle(); delete colFuncs[this.collisionType]; + i = this.shapes.length; + while (i--) { + this.shapes[i].recycle(); + this.prevShapes[i].recycle(); + } this.shapes.recycle(); this.prevShapes.recycle(); + delete this.shapes; + delete this.prevShapes; + delete this.entities; if (this.owner.collisionTypes.length) { this.owner.parent.triggerEvent('add-collision-entity', this.owner); } else { //remove collision functions colFuncs.recycle(); + this.owner.collisionFunctions = null; this.owner.aabb.recycle(); + this.owner.aabb = null; } } } diff --git a/src/components/CollisionGroup.js b/src/components/CollisionGroup.js index eca4c915..15c20bf9 100644 --- a/src/components/CollisionGroup.js +++ b/src/components/CollisionGroup.js @@ -135,7 +135,7 @@ * @method 'relocate-entity' */ "relocate-entity": function () { - this.owner.previousPosition.set(this.owner.position); + this.owner.previousPosition.setVector(this.owner.position); this.updateAABB(); } }, @@ -221,6 +221,7 @@ var i = 0, aabb = this.filteredAABB, childEntity = null, + incAABB = null, sE = this.solidEntities; if (!collisionType) { @@ -233,8 +234,10 @@ if ((childEntity !== this.owner) && childEntity.collisionGroup) { childEntity = childEntity.collisionGroup; } - - aabb.include(childEntity.getAABB(collisionType)); + incAABB = childEntity.getAABB(collisionType); + if (incAABB) { + aabb.include(incAABB); + } } return aabb; } @@ -244,6 +247,7 @@ var i = 0, aabb = this.filteredAABB, childEntity = null, + incAABB = null, sE = this.solidEntities; if (!collisionType) { @@ -257,7 +261,10 @@ childEntity = childEntity.collisionGroup; } - aabb.include(childEntity.getPreviousAABB(collisionType)); + incAABB = childEntity.getPreviousAABB(collisionType); + if (incAABB) { + aabb.include(incAABB); + } } return aabb; } diff --git a/src/components/CollisionTiles.js b/src/components/CollisionTiles.js index 74391026..aa5e2a15 100644 --- a/src/components/CollisionTiles.js +++ b/src/components/CollisionTiles.js @@ -5,15 +5,13 @@ * @class CollisionTiles * @uses platypus.Component */ -// Requires: ["../CollisionShape.js"] -/*global platypus */ +/*global include, platypus */ /*jslint plusplus:true */ (function () { "use strict"; - var storedTiles = Array.setUp(), - storedTileIndex = 0, - serveTiles = Array.setUp(), + var CollisionShape = include('platypus.CollisionShape'), + Data = include('platypus.Data'), flip = function (num, arr) { if (num < -1) { num = Math.abs(num) - 2; @@ -215,6 +213,16 @@ constructor: function (definition) { this.tileHalfWidth = this.tileWidth / 2; this.tileHalfHeight = this.tileHeight / 2; + this.shapeDefinition = Data.setUp( + "x", 0, + "y", 0, + "type", 'rectangle', + "width", this.tileWidth, + "height", this.tileHeight + ); + this.storedTiles = Array.setUp(); + this.serveTiles = Array.setUp(); + this.storedTileIndex = 0; }, events: { @@ -251,55 +259,70 @@ }, methods: { - getShape: function (prevAABB, x, y) { - var shape = null; + getShape: function (x, y) { + var i = this.storedTileIndex, + shape = null, + storedTiles = this.storedTiles; - if (storedTileIndex < storedTiles.length) { - shape = storedTiles[storedTileIndex]; - shape.update(x * this.tileWidth + this.tileHalfWidth, y * this.tileHeight + this.tileHalfHeight); - } else { - storedTiles.push(new platypus.CollisionShape(null, { - x: x * this.tileWidth + this.tileHalfWidth, - y: y * this.tileHeight + this.tileHalfHeight, - type: 'rectangle', - width: this.tileWidth, - height: this.tileHeight - }, 'tiles')); - shape = storedTiles[storedTileIndex]; + if (i === storedTiles.length) { + storedTiles.push(CollisionShape.setUp(null, this.shapeDefinition, 'tiles')); } - storedTileIndex += 1; + + shape = storedTiles[i]; + shape.update(x * this.tileWidth + this.tileHalfWidth, y * this.tileHeight + this.tileHalfHeight); + + this.storedTileIndex += 1; return shape; }, addShape: function (shapes, prevAABB, x, y) { - if (this.collisionMap[x][y] > -1) { - shapes.push(this.getShape(prevAABB, x, y)); - } else if (this.collisionMap[x][y] < -1) { - switch (this.collisionMap[x][y]) { + var xy = this.collisionMap[x][y]; + + if (xy > -1) { + shapes.push(this.getShape(x, y)); + } else if (xy < -1) { + switch (xy) { case -2: //Top if (prevAABB.bottom <= y * this.tileHeight) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -3: //Right if (prevAABB.left >= (x + 1) * this.tileWidth) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -4: //Bottom if (prevAABB.top >= (y + 1) * this.tileHeight) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; case -5: //Left if (prevAABB.right <= x * this.tileWidth) { - shapes.push(this.getShape(prevAABB, x, y)); + shapes.push(this.getShape(x, y)); } break; } } return shapes; + }, + + destroy: function () { + var store = this.storedTiles, + i = store.length; + + this.shapeDefinition.recycle(); + delete this.shapeDefinition; + + while (i--) { + store[i].recycle(); + } + store.recycle(); + delete this.storedTiles; + + this.serveTiles.recycle(); + delete this.serveTiles; } }, @@ -346,10 +369,10 @@ bottom = Math.min(Math.ceil(aabb.bottom / this.tileHeight), this.collisionMap[0].length), x = 0, y = 0, - shapes = serveTiles; + shapes = this.serveTiles; - serveTiles.length = 0; - storedTileIndex = 0; + shapes.length = 0; + this.storedTileIndex = 0; for (x = left; x < right; x++) { for (y = top; y < bottom; y++) { diff --git a/src/components/HandlerCollision.js b/src/components/HandlerCollision.js index 82c9e38d..80e311b9 100644 --- a/src/components/HandlerCollision.js +++ b/src/components/HandlerCollision.js @@ -5,7 +5,7 @@ * @class HandlerCollision * @uses platypus.Component */ -/*global platypus */ +/*global include, platypus */ /*jslint plusplus:true */ (function () { "use strict"; @@ -38,53 +38,6 @@ }, groupSortBySize = function (a, b) { return a.collisionGroup.getAllEntities() - b.collisionGroup.getAllEntities(); - }, - isAABBCollision = function (boxX, boxY) { - return !((boxX.left >= boxY.right) || (boxX.right <= boxY.left) || (boxX.top >= boxY.bottom) || (boxX.bottom <= boxY.top)); - }, - shapeCollision = function (shapeA, shapeB) { - var distSquared = 0, - radiiSquared = 0, - circle = null, - rect = null, - shapeDistanceX = 0, - shapeDistanceY = 0, - rectAabb = null, - cornerDistanceSq = 0; - - if (shapeA.type === 'rectangle' && shapeB.type === 'rectangle') { - return true; - } else if (shapeA.type === 'circle' && shapeB.type === 'circle') { - distSquared = Math.pow((shapeA.x - shapeB.x), 2) + Math.pow((shapeA.y - shapeB.y), 2); - radiiSquared = Math.pow((shapeA.radius + shapeB.radius), 2); - if (distSquared <= radiiSquared) { - return true; - } - } else if ((shapeA.type === 'circle' && shapeB.type === 'rectangle') || (shapeA.type === 'rectangle' && shapeB.type === 'circle')) { - if (shapeA.type === 'circle') { - circle = shapeA; - rect = shapeB; - } else { - circle = shapeB; - rect = shapeA; - } - rectAabb = rect.aABB; - - shapeDistanceX = Math.abs(circle.x - rect.x); - shapeDistanceY = Math.abs(circle.y - rect.y); - - if (shapeDistanceX >= (rectAabb.halfWidth + circle.radius)) { return false; } - if (shapeDistanceY >= (rectAabb.halfHeight + circle.radius)) { return false; } - - if (shapeDistanceX < (rectAabb.halfWidth)) { return true; } - if (shapeDistanceY < (rectAabb.halfHeight)) { return true; } - - cornerDistanceSq = Math.pow((shapeDistanceX - rectAabb.halfWidth), 2) + Math.pow((shapeDistanceY - rectAabb.halfHeight), 2); - if (cornerDistanceSq < Math.pow(circle.radius, 2)) { - return true; - } - } - return false; }; return platypus.createComponentClass({ @@ -273,7 +226,6 @@ y = camera.top + height / 2, entities = null, entity = null, - check = isAABBCollision, aabbLogic = this.cameraLogicAABB, aabbCollision = this.cameraCollisionAABB, types = null, @@ -308,7 +260,7 @@ while (i--) { collides = false; entity = all[i]; - if (entity.alwaysOn || entity.checkCollision || check(entity.getAABB(), aabbLogic)) { + if (entity.alwaysOn || entity.checkCollision || aabbLogic.collides(entity.getAABB())) { entity.checkCollision = false; allLive[allLive.length] = entity; @@ -352,7 +304,7 @@ j = entities.length; while (j--) { entity = entities[j]; - if (entity.alwaysOn || check(entity.getAABB(), aabbCollision)) { + if (entity.alwaysOn || aabbCollision.collides(entity.getAABB())) { list[list.length] = entity; } } @@ -457,7 +409,7 @@ msg.relative = false; while (i--) { entity = nons[i]; - msg.position.set(entity.position); + msg.position.setVector(entity.position); /** * This message is triggered on an entity that has been repositioned due to a solid collision. @@ -502,23 +454,24 @@ entities = this.groupsLive, x = entities.length, entity = null, - messageData = null; + messageData = null, + entityCDC = entityCollisionDataContainer; while (x--) { entity = entities[x]; if (entity.collisionGroup.getSize() > 1) { - entityCollisionDataContainer.reset(); - this.checkSolidEntityCollision(entity, entity.collisionGroup, entityCollisionDataContainer); + entityCDC.reset(); + this.checkSolidEntityCollision(entity, entity.collisionGroup, entityCDC); - i = entityCollisionDataContainer.xCount; + i = entityCDC.xCount; while (i--) { - messageData = entityCollisionDataContainer.getXEntry(i); + messageData = entityCDC.getXEntry(i); triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); } - i = entityCollisionDataContainer.yCount; + i = entityCDC.yCount; while (i--) { - messageData = entityCollisionDataContainer.getYEntry(i); + messageData = entityCDC.getYEntry(i); triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); } } @@ -558,43 +511,42 @@ entities = this.solidEntitiesLive, x = entities.length, entity = null, - messageData = null; + messageData = null, + entityCDC = entityCollisionDataContainer, + trigger = triggerCollisionMessages; while (x--) { entity = entities[x]; - entityCollisionDataContainer.reset(); - this.checkSolidEntityCollision(entity, entity, entityCollisionDataContainer); + entityCDC.reset(); + this.checkSolidEntityCollision(entity, entity, entityCDC); - i = entityCollisionDataContainer.xCount; + i = entityCDC.xCount; while (i--) { - messageData = entityCollisionDataContainer.getXEntry(i); - triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); + messageData = entityCDC.getXEntry(i); + trigger(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, messageData.direction, 0, 'solid', messageData.vector); } - i = entityCollisionDataContainer.yCount; + i = entityCDC.yCount; while (i--) { - messageData = entityCollisionDataContainer.getYEntry(i); - triggerCollisionMessages(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); + messageData = entityCDC.getYEntry(i); + trigger(messageData.thisShape.owner, messageData.thatShape.owner, messageData.thisShape.collisionType, messageData.thatShape.collisionType, 0, messageData.direction, 'solid', messageData.vector); } } }; }()), checkSolidEntityCollision: function (ent, entityOrGroup, collisionDataCollection) { - var abs = Math.abs, - step = 0, + var step = 0, finalMovementInfo = null, - entityDeltaX = ent.x - ent.previousX, - entityDeltaY = ent.y - ent.previousY, aabb = null, - dX = 0, - dY = 0, + dX = ent.x - ent.previousX, + dY = ent.y - ent.previousY, sW = Infinity, sH = Infinity, collisionTypes = entityOrGroup.getCollisionTypes(), - i = collisionTypes.length, + i = 0, ignoredEntities = false, - min = Math.min; + min = null; if (entityOrGroup.getSolidEntities) { ignoredEntities = entityOrGroup.getSolidEntities(); @@ -602,9 +554,12 @@ finalMovementInfo = Vector.setUp(ent.position); - if (entityDeltaX || entityDeltaY) { + if (dX || dY) { if (ent.bullet) { + min = Math.min; + + i = collisionTypes.length; while (i--) { aabb = entityOrGroup.getAABB(collisionTypes[i]); sW = min(sW, aabb.width); @@ -612,31 +567,27 @@ } //Stepping to catch really fast entities - this is not perfect, but should prevent the majority of fallthrough cases. - step = Math.ceil(Math.max(abs(entityDeltaX) / sW, abs(entityDeltaY) / sH)); + step = Math.ceil(Math.max(Math.abs(dX) / sW, Math.abs(dY) / sH)); step = min(step, 100); //Prevent memory overflow if things move exponentially far. - dX = entityDeltaX / step; - dY = entityDeltaY / step; - } else { - step = 1; - dX = entityDeltaX; - dY = entityDeltaY; - } - - while (step--) { - entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + dX = dX / step; + dY = dY / step; - finalMovementInfo.set(ent.position); - - finalMovementInfo = this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, dX, dY, collisionTypes); - - - if ((finalMovementInfo.x === ent.previousX) && (finalMovementInfo.y === ent.previousY)) { - entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); - //No more movement so we bail! - break; - } else { - entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + while (step--) { + entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + + finalMovementInfo = this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo.setVector(ent.position), dX, dY, collisionTypes); + + if ((finalMovementInfo.x === ent.previousX) && (finalMovementInfo.y === ent.previousY)) { + entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + //No more movement so we bail! + break; + } else { + entityOrGroup.relocateEntity(finalMovementInfo, collisionDataCollection); + } } + } else { + entityOrGroup.prepareCollision(ent.previousX + dX, ent.previousY + dY); + entityOrGroup.relocateEntity(this.processCollisionStep(ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, dX, dY, collisionTypes), collisionDataCollection); } } @@ -645,10 +596,10 @@ processCollisionStep: (function () { var sweeper = AABB.setUp(), - includeEntity = function (thisEntity, aabb, otherEntity, otherCollisionType, ignoredEntities) { - var i = 0, - otherAABB = otherEntity.getAABB(otherCollisionType); + includeEntity = function (thisEntity, aabb, otherEntity, otherAABB, ignoredEntities, sweepAABB) { + var i = 0; + //Chop out all the special case entities we don't want to check against. if (otherEntity === thisEntity) { return false; } else if (otherEntity.jumpThrough && (aabb.bottom > otherAABB.top)) { @@ -663,7 +614,8 @@ } } } - return true; + + return sweepAABB.collides(otherAABB); }; return function (ent, entityOrGroup, ignoredEntities, collisionDataCollection, finalMovementInfo, entityDeltaX, entityDeltaY, collisionTypes) { @@ -671,6 +623,7 @@ j = 0, k = 0, l = 0, + isIncluded = includeEntity, potentialCollision = false, potentialCollidingShapes = Array.setUp(), pcsGroup = null, @@ -679,6 +632,7 @@ collisionType = null, otherEntity = null, otherCollisionType = '', + otherAABB = null, otherShapes = null, entitiesByTypeLive = this.entitiesByTypeLive, otherEntities = null, @@ -708,12 +662,11 @@ if (otherEntities) { k = otherEntities.length; while (k--) { - - //Chop out all the special case entities we don't want to check against. otherEntity = otherEntities[k]; + otherAABB = otherEntity.getAABB(otherCollisionType); //Do our sweep check against the AABB of the other object and add potentially colliding shapes to our list. - if (includeEntity(ent, previousAABB, otherEntity, otherCollisionType, ignoredEntities) && (isAABBCollision(sweepAABB, otherEntity.getAABB(otherCollisionType)))) { + if (isIncluded(ent, previousAABB, otherEntity, otherAABB, ignoredEntities, sweepAABB)) { otherShapes = otherEntity.getShapes(otherCollisionType); l = otherShapes.length; @@ -816,7 +769,7 @@ cd.clear(); this.findMinShapeMovementCollision(prevShapes[i], shapes[i], axis, potentialCollidingShapes, cd); - if (cd.occurred && (!bestCollisionData.occurred //if a collision occurred and we haven't already have a collision. + if (cd.occurred && (!bestCollisionData.occurred //if a collision occurred and we haven't already had a collision. || (cd.deltaMovement < bestCollisionData.deltaMovement))) { //if a collision occurred and the diff is smaller than our best diff. bestCollisionData.copy(cd); } @@ -845,115 +798,149 @@ collisionData.aABB = thatShape.aABB; collisionData.thisShape = thisShape; collisionData.thatShape = thatShape; - collisionData.vector.set(vector); + collisionData.vector.setVector(vector); }, - findAxisCollisionPosition = (function () { - var returnInfo = { - position: 0, - contactVector: Vector.setUp() - }, - getMovementDistance = function (currentDistance, minimumDistance) { - var pow = Math.pow; - - return Math.sqrt(pow(minimumDistance, 2) - pow(currentDistance, 2)); - }, - getCorner = function (circlePos, rectanglePos, half) { - var diff = circlePos - rectanglePos; - - return diff - (diff / Math.abs(diff)) * half; - }, - getOffsetForAABB = function (axis, thisAABB, thatAABB) { - if (axis === 'x') { - return thatAABB.halfWidth + thisAABB.halfWidth; - } else if (axis === 'y') { - return thatAABB.halfHeight + thisAABB.halfHeight; - } - }, - getOffsetForCircleVsAABB = function (axis, circle, rect, moving, direction, v) { - var newAxisPosition = 0, - aabb = rect.aABB; + returnInfo = { + position: 0, + contactVector: Vector.setUp() + }, + getMovementDistance = function (currentDistance, minimumDistance) { + var pow = Math.pow; + + return Math.sqrt(pow(minimumDistance, 2) - pow(currentDistance, 2)); + }, + getCorner = function (circlePos, rectanglePos, half) { + var diff = circlePos - rectanglePos; + + return diff - (diff / Math.abs(diff)) * half; + }, + getOffsetForCircleVsAABBX = function (circle, rect, moving, direction, v) { + var newAxisPosition = 0, + aabb = rect.aABB, + hw = aabb.halfWidth, + x = circle.x, + y = circle.y; - if (axis === 'x') { - if (circle.y >= aabb.top && circle.y <= aabb.bottom) { - return aabb.halfWidth + circle.radius; - } else { - v.y = getCorner(circle.y, rect.y, aabb.halfHeight); - newAxisPosition = aabb.halfWidth + getMovementDistance(v.y, circle.radius); - if (moving === circle) { - v.x = -getCorner(circle.x - direction * newAxisPosition, rect.x, aabb.halfWidth) / 2; - v.y = -v.y; - } else { - v.x = getCorner(circle.x, rect.x - direction * newAxisPosition, aabb.halfWidth) / 2; - } - v.normalize(); - return newAxisPosition; - } - } else if (axis === 'y') { - if (circle.x >= aabb.left && circle.x <= aabb.right) { - return aabb.halfHeight + circle.radius; - } else { - v.x = getCorner(circle.x, rect.x, aabb.halfWidth); - newAxisPosition = aabb.halfHeight + getMovementDistance(v.x, circle.radius); - if (moving === circle) { - v.x = -v.x; - v.y = -getCorner(circle.y - direction * newAxisPosition, rect.y, aabb.halfWidth) / 2; - } else { - v.y = getCorner(circle.y, rect.y - direction * newAxisPosition, aabb.halfWidth) / 2; - } - v.normalize(); - return newAxisPosition; - } + if (y >= aabb.top && y <= aabb.bottom) { + return hw + circle.radius; + } else { + y = getCorner(y, rect.y, aabb.halfHeight); // reusing y. + newAxisPosition = hw + getMovementDistance(y, circle.radius); + if (moving === circle) { + v.x = -getCorner(x - direction * newAxisPosition, rect.x, hw) / 2; + y = -y; + } else { + v.x = getCorner(x, rect.x - direction * newAxisPosition, hw) / 2; + } + v.y = y; + v.normalize(); + return newAxisPosition; + } + }, + getOffsetForCircleVsAABBY = function (circle, rect, moving, direction, v) { + var newAxisPosition = 0, + aabb = rect.aABB, + hh = aabb.halfHeight, + x = circle.x, + y = circle.y; + + if (x >= aabb.left && x <= aabb.right) { + return hh + circle.radius; + } else { + x = getCorner(x, rect.x, aabb.halfWidth); // reusing x. + newAxisPosition = hh + getMovementDistance(x, circle.radius); + if (moving === circle) { + x = -x; + v.y = -getCorner(y - direction * newAxisPosition, rect.y, hh) / 2; + } else { + v.y = getCorner(y, rect.y - direction * newAxisPosition, hh) / 2; + } + v.x = x; + v.normalize(); + return newAxisPosition; + } + }, + findAxisCollisionPosition = { // Decision tree for quicker access, optimized for mobile devices. + x: { + rectangle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.x - direction * (thatShape.aABB.halfWidth + thisShape.aABB.halfWidth); + ri.contactVector.setXYZ(direction, 0); + + return ri; + }, + circle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.x - direction * getOffsetForCircleVsAABBX(thatShape, thisShape, thisShape, direction, ri.contactVector.setXYZ(direction, 0)); + + return ri; } }, - getOffsetForCircles = function (axis, thisShape, thatShape) { - if (axis === 'x') { - return getMovementDistance(thisShape.y - thatShape.y, thisShape.radius + thatShape.radius); - } else if (axis === 'y') { - return getMovementDistance(thisShape.x - thatShape.x, thisShape.radius + thatShape.radius); - } - }; + circle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; - return function (axis, direction, thisShape, thatShape) { - //Returns the value of the axis at which point thisShape collides with thatShape - var ri = returnInfo, - v = ri.contactVector; + ri.position = thatShape.x - direction * getOffsetForCircleVsAABBX(thisShape, thatShape, thisShape, direction, ri.contactVector.setXYZ(direction, 0)); - if (thisShape.type === 'rectangle') { - if (thatShape.type === 'rectangle') { - ri.position = thatShape[axis] - direction * getOffsetForAABB(axis, thisShape.aABB, thatShape.aABB); - v.x = 0; - v.y = 0; - v[axis] = direction; return ri; - } else if (thatShape.type === 'circle') { - v.x = 0; - v.y = 0; - v[axis] = direction; - ri.position = thatShape[axis] - direction * getOffsetForCircleVsAABB(axis, thatShape, thisShape, thisShape, direction, v); + }, + circle: function (direction, thisShape, thatShape) { + var y = thatShape.y - thisShape.y, + position = thatShape.x - direction * getMovementDistance(y, thisShape.radius + thatShape.radius), + ri = returnInfo; + + ri.contactVector.setXYZ(thatShape.x - position, y).normalize(); + ri.position = position; + return ri; } - } else if (thisShape.type === 'circle') { - if (thatShape.type === 'rectangle') { - v.x = 0; - v.y = 0; - v[axis] = direction; - ri.position = thatShape[axis] - direction * getOffsetForCircleVsAABB(axis, thisShape, thatShape, thisShape, direction, v); + } + }, + y: { + rectangle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * (thatShape.aABB.halfHeight + thisShape.aABB.halfHeight); + ri.contactVector.setXYZ(0, direction); + return ri; - } else if (thatShape.type === 'circle') { - ri.position = thatShape[axis] - direction * getOffsetForCircles(axis, thisShape, thatShape); - v.x = thatShape.x - thisShape.x; - v.y = thatShape.y - thisShape.y; + }, + circle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * getOffsetForCircleVsAABBY(thatShape, thisShape, thisShape, direction, ri.contactVector.setXYZ(0, direction)); + + return ri; + } + }, + circle: { + rectangle: function (direction, thisShape, thatShape) { + var ri = returnInfo; + + ri.position = thatShape.y - direction * getOffsetForCircleVsAABBY(thisShape, thatShape, thisShape, direction, ri.contactVector.setXYZ(0, direction)); + + return ri; + }, + circle: function (direction, thisShape, thatShape) { + var x = thatShape.x - thisShape.x, + position = thatShape.y - direction * getMovementDistance(x, thisShape.radius + thatShape.radius), + ri = returnInfo; + + ri.contactVector.setXYZ(x, thatShape.y - position).normalize(); + ri.position = position; - v[axis] = thatShape[axis] - ri.position; - v.normalize(); return ri; } } - }; - }()); + } + }; return function (prevShape, currentShape, axis, potentialCollidingShapes, collisionData) { - var i = potentialCollidingShapes.length, + var i = 0, initialPoint = prevShape[axis], goalPoint = currentShape[axis], translatedShape = prevShape, @@ -961,39 +948,39 @@ position = goalPoint, pcShape = null, collisionInfo = null, - finalPosition = goalPoint; + finalPosition = goalPoint, + findACP = null; if (initialPoint !== goalPoint) { + findACP = findAxisCollisionPosition[axis][translatedShape.type]; + if (axis === 'x') { translatedShape.moveX(goalPoint); } else if (axis === 'y') { translatedShape.moveY(goalPoint); } + i = potentialCollidingShapes.length; while (i--) { pcShape = potentialCollidingShapes[i]; position = goalPoint; - if (isAABBCollision(translatedShape.aABB, pcShape.aABB)) { //TML - Could potentially shove this back into the rectangle shape check, but I'll leave it here. - if (shapeCollision(translatedShape, pcShape)) { - collisionInfo = findAxisCollisionPosition(axis, direction, translatedShape, pcShape); - position = collisionInfo.position; - if (direction > 0) { - if (position < finalPosition) { - if (position < initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD - position = initialPoint; - } - finalPosition = position; - storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); - } - } else { - if (position > finalPosition) { - if (position > initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD - position = initialPoint; - } - finalPosition = position; - storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); + if (translatedShape.collides(pcShape)) { + collisionInfo = findACP[pcShape.type](direction, translatedShape, pcShape); + position = collisionInfo.position; + if (direction > 0) { + if (position < finalPosition) { + if (position < initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD + position = initialPoint; } + finalPosition = position; + storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); + } + } else if (position > finalPosition) { + if (position > initialPoint) { // Reality check: I think this is necessary due to floating point inaccuracies. - DDD + position = initialPoint; } + finalPosition = position; + storeCollisionData(collisionData, direction, finalPosition, initialPoint, currentShape, pcShape, collisionInfo.contactVector); } } } @@ -1028,7 +1015,6 @@ k = 0, l = 0, m = 0, - checkAABBCollision = isAABBCollision, collisionType = null, softCollisionMap = null, otherEntities = null, @@ -1050,16 +1036,16 @@ if (otherEntities) { k = otherEntities.length; while (k--) { - collisionFound = false; otherEntity = otherEntities[k]; - if ((otherEntity !== ent) && (checkAABBCollision(ent.getAABB(collisionType), otherEntity.getAABB(otherCollisionType)))) { + if ((otherEntity !== ent) && (ent.getAABB(collisionType).collides(otherEntity.getAABB(otherCollisionType)))) { + collisionFound = false; shapes = ent.getShapes(collisionType); otherShapes = otherEntity.getShapes(otherCollisionType); l = shapes.length; while (l--) { m = otherShapes.length; while (m--) { - if (shapeCollision(shapes[l], otherShapes[m])) { + if (shapes[l].collides(otherShapes[m])) { //TML - We're only reporting the first shape we hit even though there may be multiple that we could be hitting. message.entity = otherEntity; message.type = otherCollisionType; diff --git a/src/components/LogicDirectionalMovement.js b/src/components/LogicDirectionalMovement.js index 55b7804b..0e9a734b 100644 --- a/src/components/LogicDirectionalMovement.js +++ b/src/components/LogicDirectionalMovement.js @@ -113,7 +113,7 @@ }).velocity; if (this.owner.heading !== this.heading) { - this.direction.set(this.initialVector).rotate((this.owner.heading / 180) * Math.PI); + this.direction.setVector(this.initialVector).rotate((this.owner.heading / 180) * Math.PI); this.heading = this.owner.heading; } @@ -200,7 +200,7 @@ } if (this.owner.heading !== this.heading) { - this.direction.set(this.initialVector).rotate((this.heading / 180) * Math.PI); + this.direction.setVector(this.initialVector).rotate((this.heading / 180) * Math.PI); this.reorient(this.heading, this.owner.heading); this.owner.heading = this.heading; } diff --git a/src/components/LogicImpactLaunch.js b/src/components/LogicImpactLaunch.js index 1297cdb3..963f9227 100644 --- a/src/components/LogicImpactLaunch.js +++ b/src/components/LogicImpactLaunch.js @@ -88,7 +88,7 @@ This component will cause the entity to move in a certain direction on colliding } if (this.justJumped) { - this.direction.set(this.vector); + this.direction.setVector(this.vector); this.justJumped = false; this.stunned = true; } diff --git a/src/components/LogicRebounder.js b/src/components/LogicRebounder.js index 80cd5fbf..95a37daa 100644 --- a/src/components/LogicRebounder.js +++ b/src/components/LogicRebounder.js @@ -83,8 +83,8 @@ Requires: ["../Vector.js"] } this.hitThisTick.push(other); - this.v.set(this.owner.velocity); - this.incidentVector.set(collData.direction); + this.v.setVector(this.owner.velocity); + this.incidentVector.setVector(collData.direction); magnitude = this.v.scalarProjection(this.incidentVector); if (!isNaN(magnitude)) { @@ -92,7 +92,7 @@ Requires: ["../Vector.js"] this.v.subtractVector(this.incidentVector); } - this.owner.velocity.set(this.v); + this.owner.velocity.setVector(this.v); }, "hit-non-static": function (collData) { var x = 0, @@ -110,19 +110,19 @@ Requires: ["../Vector.js"] for (x = 0; x < this.otherVelocityData.length; x++) { if (other === this.otherVelocityData[x].entity) { - this.otherV.set(this.otherVelocityData[x].velocity); + this.otherV.setVector(this.otherVelocityData[x].velocity); otherVSet = true; break; } } if (!otherVSet) { - this.otherV.set(other.velocity); + this.otherV.setVector(other.velocity); other.triggerEvent('share-velocity', this.owner); } - this.v.set(this.owner.velocity); - this.incidentVector.set(collData.direction); + this.v.setVector(this.owner.velocity); + this.incidentVector.setVector(collData.direction); relevantV = this.v.scalarProjection(this.incidentVector); @@ -134,7 +134,7 @@ Requires: ["../Vector.js"] this.incidentVector.scale(reboundV - relevantV); - this.owner.velocity.set(this.incidentVector); + this.owner.velocity.setVector(this.incidentVector); }, "share-velocity": function (other) { diff --git a/src/components/LogicRotationalMovement.js b/src/components/LogicRotationalMovement.js index 6127e73c..50533f6e 100644 --- a/src/components/LogicRotationalMovement.js +++ b/src/components/LogicRotationalMovement.js @@ -86,17 +86,19 @@ This component changes the (x, y) position of an object according to its current this.owner.x += (vX * resp.delta); this.owner.y += (vY * resp.delta); - if (this.state.moving !== this.moving) { - this.state.moving = this.moving; - } - if (this.state.turningLeft !== this.turningLeft) { - this.state.turningLeft = this.turningLeft; - } - if (this.state.turningRight !== this.turningRight) { - this.state.turningRight = this.turningRight; - } - if (this.owner.rotation !== this.angle) { - this.owner.rotation = this.angle; + if (this.state) { + if (this.state.moving !== this.moving) { + this.state.moving = this.moving; + } + if (this.state.turningLeft !== this.turningLeft) { + this.state.turningLeft = this.turningLeft; + } + if (this.state.turningRight !== this.turningRight) { + this.state.turningRight = this.turningRight; + } + if (this.owner.rotation !== this.angle) { + this.owner.rotation = this.angle; + } } }, "turn-right": function (state) { @@ -147,6 +149,12 @@ This component changes the (x, y) position of an object according to its current this.turningRight = false; } } + }, + + methods: { + destroy: function () { + this.state = null; + } } }); }()); diff --git a/src/components/LogicTeleportee.js b/src/components/LogicTeleportee.js index 11b30aed..b10c42d6 100644 --- a/src/components/LogicTeleportee.js +++ b/src/components/LogicTeleportee.js @@ -69,7 +69,7 @@ Requires: ["../Vector.js"] methods: { setDestination: function (position) { - this.teleportDestination.set(position.x, position.y, this.owner.z); + this.teleportDestination.setXYZ(position.x, position.y, this.owner.z); this.destinationSet = true; }, diff --git a/src/components/Motion.js b/src/components/Motion.js index 6f0587e0..0678465d 100644 --- a/src/components/Motion.js +++ b/src/components/Motion.js @@ -123,7 +123,7 @@ if (this.ready && this.enact && state) { this.ready = false; // to insure a single instance until things are reset - this.velocity.set(this.instant); + this.velocity.setVector(this.instant); if (instantSuccess) { this.owner.triggerEvent(instantSuccess); } @@ -406,7 +406,7 @@ if (this.instant) { this.enact = false; this.instant = Vector.setUp(this.velocity); - this.velocity.set(0, 0, 0); + this.velocity.setXYZ(0, 0, 0); } if (this.orient) { // Orient vectors in case the entity is in a transformed position. diff --git a/src/components/Mover.js b/src/components/Mover.js index 4b9cbc97..f857ed4e 100644 --- a/src/components/Mover.js +++ b/src/components/Mover.js @@ -369,7 +369,7 @@ this.externalForces.addVector(velocity).subtractVector(this.lastVelocity); } - velocity.set(0, 0, 0); + velocity.setXYZ(0, 0, 0); while (i--) { m = movers[i].update(delta); @@ -392,7 +392,7 @@ } this.clamp(velocity, delta); - this.lastVelocity.set(velocity); + this.lastVelocity.setVector(velocity); vect = Vector.setUp(velocity).multiply(delta); position.add(vect); @@ -431,7 +431,7 @@ if (entityV) { e = Math.max(entityV.scalarProjection(direction), 0); if (e < s) { - s -= e; + s = e; } else { s = 0; } @@ -442,17 +442,15 @@ while (i--) { if ((s < vc[i]) && (vd[i].dot(direction) > 0)) { vc[i] = s; - vd[i].set(direction); + vd[i].setVector(direction); add = false; break; } } - if(!this.aaa) {this.aaa = [];} if (add) { vc.push(s); vd.push(Vector.setUp(direction)); - this.aaa.push(entityV); } } }, @@ -487,8 +485,8 @@ sdi = s / j; while (j--) { m = soc[j]; - v.set(direction).normalize().multiply(m.velocity.scalarProjection(direction) - sdi); - m.velocity.subtractVector(v); + v.setVector(direction).normalize().multiply(sdi - m.velocity.scalarProjection(direction)); + m.velocity.add(v); } direction.recycle(); } diff --git a/src/components/NodeMap.js b/src/components/NodeMap.js index 6e76afcf..4f51aa93 100644 --- a/src/components/NodeMap.js +++ b/src/components/NodeMap.js @@ -269,7 +269,7 @@ d = Infinity; for (i = 0; i < list.length; i++) { - m = p2.set(p1).subtractVector(list[i].position).magnitude(); + m = p2.setVector(p1).subtractVector(list[i].position).magnitude(); if (m < d) { if (excluding) { j = excluding.indexOf(list[i]); diff --git a/src/components/Orientation.js b/src/components/Orientation.js index 4267c6c3..378d835f 100644 --- a/src/components/Orientation.js +++ b/src/components/Orientation.js @@ -174,13 +174,13 @@ return vector.signedAngleTo(origin, normal); }, set: function (value) { - vector.set(origin).rotate(value); + vector.setVector(origin).rotate(value); }, enumerable: true }); if (orientation) { - if (isNaN(orientation)) { + if (typeof orientation !== 'number') { vector.set(orientation); } else { vector.rotate(orientation); @@ -648,7 +648,7 @@ }()), updateVector: function (vector, inverse) { - inverse.set(vector.add(inverse)); // Inverses are stored to return to the original postion, *but* also allow outside changes on the vectors to be retained. This introduces floating point errors on tweened vectors. - DDD 2/10/2016 + inverse.setVector(vector.add(inverse)); // Inverses are stored to return to the original postion, *but* also allow outside changes on the vectors to be retained. This introduces floating point errors on tweened vectors. - DDD 2/10/2016 vector.multiply(this.matrixTween); inverse.subtractVector(vector); }, diff --git a/src/components/RenderDestroyMe.js b/src/components/RenderDestroyMe.js index a86528ca..ded2ef37 100644 --- a/src/components/RenderDestroyMe.js +++ b/src/components/RenderDestroyMe.js @@ -1,25 +1,10 @@ /** -# COMPONENT **RenderDestroyMe** -This component will destroy the entity once an animation has finished. This is useful for explosions or similar animations where the entity is no longer needed once the animation completes. - -## Dependencies: -- [[RenderSprite]] (component on entity) - This component listens for the "animation-complete" event triggered by RenderSprite. - -### Listens for: -- **animation-complete** - On receiving this message, the component match the animation id with its animation id setting and destroy the entity if they match. - - @param animationId (string) - animation id for the animation that just finished. - -## JSON Definition: - { - "type": "RenderDestroyMe", - - "animationId": "bigExplosion" - //This or animationIds Required. String identifying the animation that should destroy this entity on its completion. - - "animationIds": ["bigExplosion", "lessBigExplosion"] - //This or animationIds Required. Array of Strings identifying the animations that should destroy this entity on their completion. - } -*/ + * This component will destroy the entity once an animation has finished. This is useful for explosions or similar animations where the entity is no longer needed once the animation completes. + * + * @namespace platypus.components + * @class RenderDestroyMe + * @uses platypus.Component + */ /*global platypus */ /*jslint plusplus:true */ (function () { @@ -27,25 +12,56 @@ This component will destroy the entity once an animation has finished. This is u return platypus.createComponentClass({ id: 'RenderDestroyMe', + + properties: { + /** + * This or animationIds required. This is a String identifying the animation that should destroy this entity on its completion. + * + * @property animationId + * @type String + * @default '' + */ + animationId: '', + + /** + * This or animationId required. This is an array of Strings identifying the animations that should destroy this entity on their completion. + * + * @property animationIds + * @type Array + * @default null + */ + animationIds: null + }, constructor: function (definition) { - this.animationIds = null; - - if (definition.animationId) { - this.animationIds = [definition.animationId]; - } else if (definition.animationIds) { - this.animationIds = definition.animationIds; + if (this.animationId) { + this.animationIds = Array.setUp(definition.animationId); + } else if (this.animationIds) { + this.animationIds = this.animationIds.greenSlice(); } }, events: {// These are messages that this component listens for + /** + * On receiving this message, the component matches the animation id with its animation id setting and destroys the entity if they match. + * + * @method 'animation-ended' + * @param animation {String} Animation id for the animation that just finished. + */ "animation-ended": function (animation) { - var id = animation.name; - - if (!this.animationIds || (this.animationIds.indexOf(id) >= 0)) { + if (!this.animationIds || (this.animationIds.indexOf(animation) >= 0)) { this.owner.parent.removeEntity(this.owner); } } + }, + + methods: { + destroy: function () { + if (this.animationIds) { + this.animationIds.recycle(); + delete this.animationIds; + } + } } }); }());