angry-pixel 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/Animator.d.ts +1 -1
- package/lib/component/AudioPlayer.d.ts +2 -5
- package/lib/component/ComponentTypes.d.ts +1 -0
- package/lib/component/RigidBody.d.ts +8 -25
- package/lib/component/RigidBodyOld.d.ts +39 -0
- package/lib/component/collider/BoxCollider.d.ts +34 -0
- package/lib/component/collider/Collider.d.ts +22 -0
- package/lib/component/collider/PolygonCollider.d.ts +32 -0
- package/lib/component/collider/TilemapCollider.d.ts +16 -0
- package/lib/component/colliderComponent/AbstractColliderComponent.d.ts +15 -10
- package/lib/component/colliderComponent/BoxCollider.d.ts +3 -1
- package/lib/component/colliderComponent/PolygonCollider.d.ts +32 -0
- package/lib/component/colliderComponent/TilemapCollider.d.ts +2 -0
- package/lib/component/colliderComponent/TriangleCollider.d.ts +32 -0
- package/lib/component/rendering/MaskRenderer.d.ts +29 -0
- package/lib/component/rendering/SpriteRenderer.d.ts +46 -0
- package/lib/component/rendering/TextRenderer.d.ts +49 -0
- package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +13 -0
- package/lib/component/rendering/tilemap/Tile.d.ts +7 -0
- package/lib/component/rendering/tilemap/TileData.d.ts +10 -0
- package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +43 -0
- package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +72 -0
- package/lib/component/rendering/tilemap/Tileset.d.ts +25 -0
- package/lib/core/Component.d.ts +25 -25
- package/lib/core/Game.d.ts +0 -8
- package/lib/core/GameObject.d.ts +16 -23
- package/lib/core/Scene.d.ts +10 -8
- package/lib/core/managers/GameObjectManager.d.ts +1 -1
- package/lib/core/managers/IterationManager.d.ts +24 -11
- package/lib/core/managers/SceneManager.d.ts +3 -0
- package/lib/core/managers/TimeManager.d.ts +6 -4
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +12 -12
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/input/GamepadController.d.ts +1 -1
- package/lib/math/Rotation.d.ts +1 -4
- package/lib/physics/PhysicsManager.d.ts +24 -0
- package/lib/physics/PhysicsManagerOld2.d.ts +34 -0
- package/lib/physics/collision/ColliderData.d.ts +15 -0
- package/lib/physics/collision/CollisionManager.d.ts +16 -12
- package/lib/physics/collision/CollisionManagerOld.d.ts +27 -0
- package/lib/physics/collision/QuadTree.d.ts +16 -11
- package/lib/physics/collision/collider/ICollider.d.ts +1 -0
- package/lib/physics/collision/collider/RectangleCollider.d.ts +2 -1
- package/lib/physics/collision/resolver/AABBResolver.d.ts +6 -8
- package/lib/physics/collision/resolver/CollisionResolution.d.ts +6 -0
- package/lib/physics/collision/resolver/CollisionResolver.d.ts +5 -0
- package/lib/physics/collision/resolver/SatResolver.d.ts +7 -6
- package/lib/physics/collision/shape/Polygon.d.ts +31 -0
- package/lib/physics/collision/shape/Rectangle.d.ts +7 -11
- package/lib/physics/collision/shape/Shape.d.ts +13 -24
- package/lib/physics/collision-old/CollisionData.d.ts +8 -0
- package/lib/physics/collision-old/CollisionManager.d.ts +30 -0
- package/lib/physics/collision-old/QuadTree.d.ts +32 -0
- package/lib/physics/collision-old/collider/ICollider.d.ts +14 -0
- package/lib/physics/collision-old/collider/RectangleCollider.d.ts +32 -0
- package/lib/physics/collision-old/resolver/AABBResolver.d.ts +14 -0
- package/lib/physics/collision-old/resolver/ICollisionResolver.d.ts +5 -0
- package/lib/physics/collision-old/resolver/SatResolver.d.ts +14 -0
- package/lib/physics/collision-old/shape/Rectangle.d.ts +13 -0
- package/lib/physics/collision-old/shape/Shape.d.ts +28 -0
- package/lib/physics/rigodBody/RigidBodyData.d.ts +9 -0
- package/lib/physics/rigodBody/RigidBodyManager.d.ts +23 -0
- package/lib/rendering/CullingService.d.ts +0 -1
- package/lib/rendering/context2D/Context2DRenderer.d.ts +0 -1
- package/lib/rendering/renderData/RenderData.d.ts +3 -4
- package/lib/rendering/renderData/TilemapRenderData.d.ts +1 -1
- package/lib/rendering/webGL/renderer/GeometricRenderer.d.ts +3 -5
- package/lib/rendering/webGL/renderer/MaskRenderer.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"magnitude",{get:function(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){this._x=t,this._y=e},t.prototype.copy=function(t){this.set(t.x,t.y)},t.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},t.prototype.clone=function(){return new t(this._x,this._y)},t.prototype.distance=function(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))},t.add=function(t,e,i){return t.set(e.x+i.x,e.y+i.y),t},t.subtract=function(t,e,i){return t.set(e.x-i.x,e.y-i.y),t},t.unit=function(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t},t.normal=function(t,e){return t.set(-e.y,e.x),this.unit(t,t)},t.scale=function(t,e,i){return t.set(e.x*i,e.y*i),t},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.round=function(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t},t}(),e=function(){function e(e,i,n,r){this._position=new t,this._center=new t,this._width=0,this._height=0,this.set(e,i,n,r)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._position.x},set:function(t){this._position.set(t,this._position.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._position.y},set:function(t){this._position.set(this._position.x,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._position.x+this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._position.y+this._height},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"center",{get:function(){return this._center.set(this.x+this.width/2,this.y+this.height/2),this._center},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e,i,n){this._position.set(t,e),this._width=i,this._height=n},e.prototype.equals=function(t){return this.position.equals(t.position)&&this.width===t.width&&this.height===t.height},e.prototype.updateFromRect=function(t){this.set(t.x,t.y,t.width,t.height)},e.prototype.overlappingRectangle=function(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1},e}(),i=function(t,e,i){return Math.min(i,Math.max(e,t))},n=function(t,e){return Math.floor(Math.random()*(e-t))+t},r=function(t,e){return Math.round(t*(10^e))/(10^e)},o=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},a=function(t,e,i){return t>=e&&t<=i},s=function(){function e(e){this._degrees=0,this._radians=0,this._direction=new t,e&&e.radians?this.radians=e.radians:e&&e.degrees&&(this.degrees=e.degrees)}return Object.defineProperty(e.prototype,"degrees",{get:function(){return this._degrees},set:function(t){this._degrees=t,this._radians=t*Math.PI/180,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radians",{get:function(){return this._radians},set:function(t){this._radians=t,this._degrees=180*t/Math.PI,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),e.prototype.updateDirection=function(){this._direction.set(Math.cos(this._radians),Math.sin(this._radians))},e}(),h=function(t,e){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},h(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var u,c=function(){return c=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},c.apply(this,arguments)};function p(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}h((n=n.apply(t,e||[])).next())}))}function d(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}!function(t){t.Image="Image",t.Audio="Audio",t.Video="Video"}(u||(u={}));var g,m=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},y=function(){function t(){this.assets=[]}return t.prototype.getAssetsLoaded=function(){return this.assets.reduce((function(t,e){return t&&e.loaded}),!0)},t.prototype.laadImage=function(t){var e=this.createAsset(t,u.Image);return e.element=new Image,e.element.src=t,e.element.naturalWidth?e.loaded=!0:e.element.addEventListener("load",(function(){return e.loaded=!0})),e.element},t.prototype.loadAudio=function(t){var e=this.createAsset(t,u.Audio);return e.element=new Audio,e.element.src=t,e.element.duration?e.loaded=!0:e.element.addEventListener("canplaythrough",(function(){return e.loaded=!0})),e.element},t.prototype.getImage=function(t){return this.getAsset(t,u.Image)},t.prototype.getVideo=function(t){return this.getAsset(t,u.Video)},t.prototype.getAudio=function(t){return this.getAsset(t,u.Audio)},t.prototype.getAsset=function(t,e){return void 0===e&&(e=null),this.assets.reduce((function(i,n){return n.url!==t||null!==e&&e!==n.type?i:n}),null).element},t.prototype.createAsset=function(t,e){var i=new m;return i.type=e,i.url=t,this.assets.push(i),i},t}(),x="AngryPixelException",b=function(t){function e(e){var i=t.call(this,e)||this;return i.name=x,i}return l(e,t),e}(Error),v=function(){function i(i,n,r,o){void 0===r&&(r=6),void 0===o&&(o=15),this._bounds=new e(0,0,0,0),this._quadrants=[],this.colliders=[],this.sw=0,this.se=1,this.nw=2,this.ne=3,this.center=new t,this.childrenWidth=0,this.childrenHeight=0,this.quadrantsForCollider=[],this.level=i,this._bounds.updateFromRect(n),this.maxLevels=r,this.maxColliders=o,this.updateCache()}return Object.defineProperty(i.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),i.prototype.updateBounds=function(t){this._bounds.updateFromRect(t),this.updateCache()},i.prototype.clearColliders=function(){this.colliders=[],this._quadrants.forEach((function(t){return t.clearColliders()}))},i.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},i.prototype.addCollider=function(t){this._quadrants.length>0?this.insertColliderIntoChildrenQuads(t):(this.colliders.push(t),this.colliders.length>this.maxColliders&&this.level<this.maxLevels&&this.splitQuad())},i.prototype.retrieve=function(t){var e=[];this._quadrants.length>0&&this.getChildrenQuadrantForCollider(t).forEach((function(i){return e.push.apply(e,i.retrieve(t))})),e.push.apply(e,this.colliders);var i=e.indexOf(t);return-1!==i&&e.splice(i,1),e},i.prototype.splitQuad=function(){var t=this;this._quadrants=[new e(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(e){return new i(t.level+1,e,t.maxLevels,t.maxColliders)}));for(var n=0,r=this.colliders;n<r.length;n++){var o=r[n];this.insertColliderIntoChildrenQuads(o)}this.colliders=[]},i.prototype.getChildrenQuadrantForCollider=function(t){if(0===this._quadrants.length)throw new b("Current quadrant does not have quadrant children.");if(this.quadrantsForCollider=[],t.bottomLeftQuadVertex.x<=this.center.x&&t.bottomLeftQuadVertex.y<=this.center.y&&this.quadrantsForCollider.push(this._quadrants[this.sw]),t.bottomRightQuadVertex.x>=this.center.x&&t.bottomRightQuadVertex.y<=this.center.y&&this.quadrantsForCollider.push(this._quadrants[this.se]),t.topLeftQuadVertex.x<=this.center.x&&t.topLeftQuadVertex.y>=this.center.y&&this.quadrantsForCollider.push(this._quadrants[this.nw]),t.topRightQuadVertex.x>=this.center.x&&t.topRightQuadVertex.y>=this.center.y&&this.quadrantsForCollider.push(this._quadrants[this.ne]),0===this.quadrantsForCollider.length)throw new b("Children does not fit in any children quadrant");return this.quadrantsForCollider},i.prototype.insertColliderIntoChildrenQuads=function(t){this.getChildrenQuadrantForCollider(t).forEach((function(e){return e.addCollider(t)}))},i.prototype.updateCache=function(){this.center.set(this._bounds.width/2+this._bounds.x,this._bounds.height/2+this._bounds.y),this.childrenWidth=this._bounds.width/2,this.childrenHeight=this._bounds.height/2},i}(),_=function(){function i(i,n,r,o){void 0===n&&(n=null),this.minBounds=new t,this.maxBounds=new t,this.newBounds=new e(0,0,0,0),this.fixedQuadTree=null!==n,this.resolver=i,this.colliders=[],this.fixedQuadTree?this.bounds=n:this.bounds=new e(0,0,0,0),this.quadTree=new v(0,this.bounds,r,o)}return i.prototype.addCollider=function(t){this.colliders.push(t)},i.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},i.prototype.getCollisionsForCollider=function(t){return-1===this.colliders.indexOf(t)?[]:this.narrowPhase(t,this.broadPhase(t))},i.prototype.broadPhase=function(t){return this.quadTree.retrieve(t)},i.prototype.narrowPhase=function(t,e){var i=this,n=[];return e.filter((function(e){return e.gameObject!==t.gameObject})).forEach((function(e){var r=i.resolver.getCollisionData(t.shape,e.shape);null!==r&&n.push({localCollider:t,remoteCollider:e,collisionData:r})})),n},i.prototype.update=function(){if(0!==this.colliders.length){this.quadTree.clearColliders(),this.quadTree.clearQuadrants(),!1===this.fixedQuadTree&&(this.updateNewBounds(),!1===this.newBounds.equals(this.bounds)&&(this.bounds.updateFromRect(this.newBounds),this.quadTree.updateBounds(this.bounds)));for(var t=0,e=this.colliders;t<e.length;t++){var i=e[t];this.quadTree.addCollider(i)}}},i.prototype.updateNewBounds=function(){var t=this;this.colliders.forEach((function(e){t.minBounds.set(Math.min(e.bottomLeftQuadVertex.x,t.minBounds.x),Math.min(e.bottomLeftQuadVertex.y,t.minBounds.y)),t.maxBounds.set(Math.max(e.topRightQuadVertex.x,t.maxBounds.x),Math.max(e.topRightQuadVertex.y,t.maxBounds.y))})),this.newBounds.set(this.minBounds.x,this.minBounds.y,this.maxBounds.x-this.minBounds.x,this.maxBounds.y-this.minBounds.y)},i}(),w=function(){function t(t,e,i){if(this._canvas=null,!t)throw new b("containerNode cannot be empty or null.");this.containerNode=t,this.gameWidth=e,this.gameHeight=i,this.setupCanvas()}return Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),t.prototype.setupCanvas=function(){this._canvas=document.createElement("canvas"),this._canvas.id="angryPixelGameCanvas",this._canvas.width=Math.floor(this.gameWidth),this._canvas.height=Math.floor(this.gameHeight),this.canvas.tabIndex=0,this._canvas.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.containerNode.appendChild(this._canvas),this.canvas.focus()},t}(),M=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i){void 0===i&&(i=null);var n=this.findGameObjectByName(e);if(n&&!1===n.keep)throw new b("There is already a GameObject with the name "+e);if(n&&n.keep)return n;var r=t();return r.name=e,r.parent=i,this.gameObjects.push(r),r.init(),r},t.prototype.getGameObjects=function(){return this.gameObjects},t.prototype.findGameObjectById=function(t){return this.gameObjects.reduce((function(e,i){return i.id===t?i:e}),null)},t.prototype.findGameObjectByName=function(t){return this.gameObjects.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParentAndName=function(t,e){return this.gameObjects.reduce((function(i,n){return n.name===e&&n.parent===t?n:i}),null)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},t.prototype.findGameObjectByTag=function(t){var e;return null!==(e=this.findGameObjectsByTag(t)[0])&&void 0!==e?e:null},t.prototype.destroyAllGameObjects=function(){var t=this;this.gameObjects.forEach((function(e){return e.keep?null:t._destroyGameObject(e,!1)})),this.gameObjects=[]},t.prototype.destroyGameObject=function(t){this._destroyGameObject(t,!0)},t.prototype._destroyGameObject=function(t,e){var i=this.gameObjects.indexOf(t);-1!==i&&(e&&this.destroyChildren(t),t.destroy(),delete this.gameObjects[i])},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){e.destroyChildren(t),e.destroyGameObject(t)}))},t}(),C=function(){function t(){var t=this;this.gamepads=new Map,this.eventHandler=function(e){"gamepadconnected"===e.type?t.gamepadConnected(e.gamepad):"gamepaddisconnected"===e.type&&t.gamepadDisconected(e.gamepad)},window.addEventListener("gamepadconnected",this.eventHandler),window.addEventListener("gamepaddisconnected",this.eventHandler)}return t.prototype.getGamepad=function(t){var e;return null!==(e=this.gamepads.get(t))&&void 0!==e?e:null},t.prototype.gamepadConnected=function(t){this.gamepads.set(t.index,new O),this.gamepads.get(t.index).updateFromGamepad(t)},t.prototype.gamepadDisconected=function(t){this.gamepads.delete(t.index)},t.prototype.update=function(){for(var t=0,e=this.getGamepads();t<e.length;t++){var i=e[t];null!==i&&(!1===this.gamepads.has(i.index)&&this.gamepadConnected(i),this.gamepads.get(i.index).updateFromGamepad(i))}},t.prototype.getGamepads=function(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads:[]},t}(),O=function(){function e(){this._connected=!1,this._id=null,this.buttons=new Map,this.axes=new Map,this._dpadAxes=new t,this._leftStickAxes=new t,this._rightStickAxes=new t}return e.prototype.updateFromGamepad=function(t){var e=this;this._id=t.id,this._connected=t.connected,t.buttons.forEach((function(t,i){return e.buttons.set(i,t.pressed)})),t.axes.forEach((function(t,i){return e.axes.set(i,t)}))},Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),e.prototype.getButtonPressed=function(t){return this.buttons.get(t)},e.prototype.getAxis=function(t){return this.axes.get(t)},Object.defineProperty(e.prototype,"dpadAxes",{get:function(){return this._dpadAxes.set(this.dpadRight?1:this.dpadLeft?-1:0,this.dpadUp?1:this.dpadDown?-1:0),this._dpadAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickAxes",{get:function(){return this._leftStickAxes.set(this.leftStickHorizontal,this.leftStickVertical),this._leftStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickAxes",{get:function(){return this._rightStickAxes.set(this.rightStickHorizontal,this.rightStickVertical),this._rightStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._connected},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadUp",{get:function(){var t;return null!==(t=this.buttons.get(12))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadDown",{get:function(){var t;return null!==(t=this.buttons.get(13))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadLeft",{get:function(){var t;return null!==(t=this.buttons.get(14))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadRight",{get:function(){var t;return null!==(t=this.buttons.get(15))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomFace",{get:function(){var t;return null!==(t=this.buttons.get(0))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightFace",{get:function(){var t;return null!==(t=this.buttons.get(1))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftFace",{get:function(){var t;return null!==(t=this.buttons.get(2))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topFace",{get:function(){var t;return null!==(t=this.buttons.get(3))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftShoulder",{get:function(){var t;return null!==(t=this.buttons.get(4))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightShoulder",{get:function(){var t;return null!==(t=this.buttons.get(5))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftTrigger",{get:function(){var t;return null!==(t=this.buttons.get(6))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightTrigger",{get:function(){var t;return null!==(t=this.buttons.get(7))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"back",{get:function(){var t;return null!==(t=this.buttons.get(8))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){var t;return null!==(t=this.buttons.get(9))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickButton",{get:function(){var t;return null!==(t=this.buttons.get(10))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickButton",{get:function(){var t;return null!==(t=this.buttons.get(11))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(0))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(1))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(2))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(3))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),e}(),j=function(){function t(t,e,i,n){this.mouse=t,this.keyboard=e,this.gamepad=i,this.touch=n}return t.prototype.update=function(){this.mouse.update(),this.gamepad.update()},t}(),R=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),P=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}();!function(t){t[t.Rectangle=0]="Rectangle"}(g||(g={}));var T,S=function(){function e(){this._model=[],this._vertices=[],this._position=new t,this._direction=new t,this._height=0,this._width=0,this._angle=0}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),e}();!function(t){t[t.Image=0]="Image",t[t.Text=1]="Text",t[t.Geometric=2]="Geometric",t[t.Collider=3]="Collider",t[t.Tilemap=4]="Tilemap",t[t.Mask=5]="Mask"}(T||(T={}));var D=function(){function e(){this.ui=!1,this.debug=!1,this.layer=null,this._position=new t(0,0),this._positionInViewport=new t(0,0)}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},set:function(t){this._positionInViewport.set(t.x,t.y)},enumerable:!1,configurable:!0}),e}(),A=function(){function e(e){this.canvas=null,this.canvasContext=null,this.imagePosition=new t(0,0),this.canvas=e,this.canvasContext=e.getContext("2d")}return e.prototype.clearCanvas=function(t){void 0===t&&(t=null),this.canvasContext.clearRect(0,0,this.canvas.width,this.canvas.height),null!==t&&(this.canvasContext.fillStyle=t,this.canvasContext.fillRect(0,0,this.canvas.width,this.canvas.height))},e.prototype.render=function(t,e){switch(e.type){case T.Image:this.renderImage(e,t.zoom);break;case T.Tilemap:this.renderTilemap(e,t.zoom);break;case T.Text:this.renderText(e);break;case T.Geometric:this.renderGeometric(e,t.zoom);break;case T.Collider:this.renderCollider(e,t.zoom)}},e.prototype.renderImage=function(t,e){this.updateRenderPosition(t),this.imagePosition.set(0,0),this.canvasContext.save(),this.applyZoom(t,e),0!==t.rotation?(this.canvasContext.translate(t.positionInViewport.x+t.width/2,t.positionInViewport.y+t.height/2),this.imagePosition.set(-t.width/2,-t.height/2),this.canvasContext.rotate(-t.rotation)):(this.canvasContext.translate(t.positionInViewport.x,t.positionInViewport.y),this.imagePosition.set(t.flipHorizontal?-t.width:this.imagePosition.x,t.flipVertical?-t.height:this.imagePosition.y)),this.canvasContext.globalAlpha=t.alpha,this.canvasContext.imageSmoothingEnabled=t.smooth,this.canvasContext.scale(t.flipHorizontal?-1:1,t.flipVertical?-1:1),void 0!==t.slice&&null!==t.slice?this.canvasContext.drawImage(t.image,t.slice.x,t.slice.y,t.slice.width,t.slice.height,this.imagePosition.x,this.imagePosition.y,t.width,t.height):this.canvasContext.drawImage(t.image,this.imagePosition.x,this.imagePosition.y,t.width,t.height),this.canvasContext.restore()},e.prototype.renderTilemap=function(t,e){var i=this;t.tilesToRender.forEach((function(n){i.canvasContext.save(),i.applyZoom(t,e),i.imagePosition.set(0,0),i.canvasContext.translate(i.canvas.width/2+n.positionInViewport.x-t.tileWidth/2,i.canvas.height/2-n.positionInViewport.y-t.tileHeight/2),i.imagePosition.set(n.flipHorizontal?-n.tile.width:i.imagePosition.x,n.flipVertical?-n.tile.height:i.imagePosition.y),i.canvasContext.globalAlpha=t.alpha,i.canvasContext.imageSmoothingEnabled=t.smooth,i.canvasContext.scale(n.flipHorizontal?-1:1,n.flipVertical?-1:1),i.canvasContext.drawImage(t.image,n.tile.x,n.tile.y,n.tile.width,n.tile.height,i.imagePosition.x,i.imagePosition.y,t.tileWidth,t.tileHeight),i.canvasContext.restore()}))},e.prototype.renderText=function(t){var e=this;this.updateRenderPosition(t),this.canvasContext.save(),this.canvasContext.font=t.fontSize+"px "+t.fontFamily,this.canvasContext.fillStyle=t.color,this.canvasContext.textBaseline="middle",t.text.split("\n").length>1?t.text.split("\n").forEach((function(i,n){e.canvasContext.fillText(i,t.positionInViewport.x,t.positionInViewport.y+(t.lineSeparation+t.fontSize)*n)})):this.canvasContext.fillText(t.text,t.positionInViewport.x,t.positionInViewport.y),this.canvasContext.restore()},e.prototype.renderGeometric=function(t,e){this.canvasContext.save(),this.applyZoom(t,e),this.updateRenderPosition(t),"Rectangle"===t.geometricType&&(this.canvasContext.strokeStyle=t.color,this.canvasContext.strokeRect(t.positionInViewport.x-t.getGeometric().width/2,t.positionInViewport.y-t.getGeometric().height/2,t.getGeometric().width,t.getGeometric().height)),this.canvasContext.restore()},e.prototype.renderCollider=function(t,e){if(this.canvasContext.save(),this.applyZoom(t,e),this.updateRenderPosition(t),this.canvasContext.beginPath(),this.canvasContext.strokeStyle=t.color,0!==t.shape.angle?(this.canvasContext.translate(t.positionInViewport.x,t.positionInViewport.y),this.canvasContext.rotate(-t.shape.angle),this.imagePosition.set(-t.shape.width/2,-t.shape.height/2)):(this.canvasContext.translate(t.positionInViewport.x-t.shape.width/2,t.positionInViewport.y-t.shape.height/2),this.imagePosition.set(0,0)),t.shape.type===g.Rectangle)this.canvasContext.strokeRect(this.imagePosition.x,this.imagePosition.y,t.shape.width,t.shape.height);this.canvasContext.restore()},e.prototype.applyZoom=function(t,e){t.ui||this.canvasContext.setTransform(e,0,0,e,this.canvas.width*(1-e)/2,this.canvas.height*(1-e)/2)},e.prototype.updateRenderPosition=function(t){t.type===T.Image&&this.centerImage(t),t.positionInViewport.set(Number((t.positionInViewport.x+this.canvas.width/2).toFixed(0)),Number((this.canvas.height/2-t.positionInViewport.y).toFixed(0)))},e.prototype.centerImage=function(t){t.positionInViewport.set(t.positionInViewport.x-Math.floor(t.width/2),t.positionInViewport.y+Math.floor(t.height/2))},e}(),E=function(){function t(t,e,i,n){void 0===n&&(n=!1),this.debug=!1,this.renderData=[],this.cameraData=[],this.renderer=t,this.cullingService=e,this.canvasColor=i,this.debug=n}return t.prototype.clearCanvas=function(){this.renderer.clearCanvas(this.canvasColor)},t.prototype.addRenderData=function(t){!1===this.debug&&t.debug||this.renderData.push(t)},t.prototype.addCameraData=function(t){this.cameraData.push(t)},t.prototype.render=function(){var t=this;this.cameraData.sort((function(t,e){return t.depth-e.depth})).forEach((function(e){return t.renderByCamera(e)})),this.clearData()},t.prototype.clearData=function(){this.renderData=[],this.cameraData=[]},t.prototype.renderByCamera=function(t){var e=this;this.orderRendeData(t),this.cullingService.applyCulling(t,this.renderData).forEach((function(i){e.updateFromCameraViewport(t,i),e.renderer.render(t,i)}))},t.prototype.orderRendeData=function(t){this.renderData.sort((function(e,i){return t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer)}))},t.prototype.updateFromCameraViewport=function(t,e){var i=this;!0!==e.ui?e.type===T.Tilemap?e.tilesToRender.forEach((function(e){return i.setPositionInViewport(t,e)})):this.setPositionInViewport(t,e):e.positionInViewport=e.position},t.prototype.setPositionInViewport=function(t,e){e.positionInViewport.set(Math.round(e.position.x-t.worldSpaceRect.x-t.worldSpaceRect.width/2),Math.round(e.position.y-t.worldSpaceRect.y-t.worldSpaceRect.height/2))},t}(),B="undefined"!=typeof Float32Array?Float32Array:Array;function V(){var t=new B(16);return B!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function F(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function G(t,e,i){var n,r,o,a,s,h,l,u,c,p,d,f,g=i[0],m=i[1],y=i[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*y+e[12],t[13]=e[1]*g+e[5]*m+e[9]*y+e[13],t[14]=e[2]*g+e[6]*m+e[10]*y+e[14],t[15]=e[3]*g+e[7]*m+e[11]*y+e[15]):(n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=e[5],l=e[6],u=e[7],c=e[8],p=e[9],d=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=h,t[6]=l,t[7]=u,t[8]=c,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+s*m+c*y+e[12],t[13]=r*g+h*m+p*y+e[13],t[14]=o*g+l*m+d*y+e[14],t[15]=a*g+u*m+f*y+e[15]),t}function I(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function L(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],a=e[1],s=e[2],h=e[3],l=e[4],u=e[5],c=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+l*n,t[1]=a*r+u*n,t[2]=s*r+c*n,t[3]=h*r+p*n,t[4]=l*r-o*n,t[5]=u*r-a*n,t[6]=c*r-s*n,t[7]=p*r-h*n,t}function k(t,e,i,n,r,o,a){var s=1/(e-i),h=1/(n-r),l=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+i)*s,t[13]=(r+n)*h,t[14]=(a+o)*l,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var U,H=function(t){var e=/^#?([a-f\d]{2})?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[2],16)/256,g:parseInt(e[3],16)/256,b:parseInt(e[4],16)/256,a:void 0!==e[1]?parseInt(e[1],16)/256:1}:null},z=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=V(),this.modelMatrix=V(),this.textureMatrix=V(),this.posVertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.texVertices=new Float32Array([0,1,0,0,1,1,1,1,0,0,1,0])}return t.prototype.render=function(t,e,i,n){var r;if("image"!==n&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.posVertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.STATIC_DRAW)),this.modelMatrix=F(this.modelMatrix),G(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),L(this.modelMatrix,this.modelMatrix,i.rotation),I(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=F(this.textureMatrix),i.slice&&(G(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),I(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=F(this.projectionMatrix),k(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"image"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var o=H(i.tintColor),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.tintColorUniform,a,s,h,l)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,i.maskColor?1:0),i.maskColor){var u=H(i.maskColor);a=u.r,s=u.g,h=u.b;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,i.alpha),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(r=i.maskColorMix)&&void 0!==r?r:0)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),W=function(){function t(t){this.shaderLoader=t}return t.prototype.create=function(t,e,i){var n=t.createProgram(),r=this.shaderLoader.load(t,t.VERTEX_SHADER,e),o=this.shaderLoader.load(t,t.FRAGMENT_SHADER,i);return this.link(t,n,r,o),n},t.prototype.link=function(t,e,i,n){t.attachShader(e,i),t.attachShader(e,n),t.linkProgram(e);var r=t.LINK_STATUS;if(!t.getProgramParameter(e,r)){var o=t.getProgramInfoLog(e);throw t.deleteProgram(e),new b("Unable to initialize the Program: "+o)}},t}(),N=function(){function t(){}return t.prototype.load=function(t,e,i){var n=t.createShader(e);t.shaderSource(n,i),t.compileShader(n);var r=t.COMPILE_STATUS;if(!t.getShaderParameter(n,r)){var o=t.getShaderInfoLog(n);throw t.deleteShader(n),new b("Unable to initialize the shader program: "+o)}return n},t}(),q=function(){function t(t,e){this.gl=e.getContext(t)}return t.prototype.createFromImage=function(t,e,i){var n=this;return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),t.naturalWidth?this.create(t,i,e):t.addEventListener("load",(function(){return n.create(t,i,e)})),i},t.prototype.createFromCanvas=function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),this.create(t,i,e),i},t.prototype.create=function(t,e,i){void 0===i&&(i=!0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),!1===i?(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST)):(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR)),this.gl.bindTexture(this.gl.TEXTURE_2D,null)},t}();!function(t){t.LegacyWebGL="webgl",t.WebGL2="webgl2"}(U||(U={}));var Y,Q,X=function(){function t(t,e,i,n,r,o,a,s,h,l){this.canvas=e,this.gl=this.canvas.getContext(t),i.loadProgram(),this.textureManager=n,this.imageRenderer=o,this.tilemapRenderer=a,this.textRenderer=s,this.geometricRenderer=h,this.maskRenderer=l,this.fontAtlasFactory=r}return t.prototype.clearCanvas=function(t){var e=H(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)},t.prototype.render=function(t,e){e.type===T.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===T.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===T.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===T.Collider&&(this.geometricRenderer.renderCollider(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===T.Geometric&&(this.geometricRenderer.renderGeometric(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===T.Mask&&(this.renderMask(t,e),this.lastRender="mask")},t.prototype.renderImage=function(t,e){this.imageRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderTilemap=function(t,e){this.tilemapRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderText=function(t,e){this.fontAtlasFactory.loadingFontAtlas(e.fontFamily)||(this.fontAtlasFactory.hasFontAtlas(e.fontFamily)?this.fontAtlasLoaded(this.fontAtlasFactory.getFontAtlas(e.fontFamily),t,e):this.fontAtlasFactory.asyncCreate(e.charRanges,e.fontFamily,e.fontUrl,e.bitmapSize))},t.prototype.renderMask=function(t,e){this.maskRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,e,this.lastRender)},t.prototype.fontAtlasLoaded=function(t,e,i){this.textRenderer.render(!0===i.ui?e.originalViewportRect:e.viewportRect,this.textureManager.getOrCreateTextureFromCanvas(i.fontFamily,t.canvas,i.smooth),t,i,this.lastRender)},t}(),Z=function(){function t(t,e){this.game=null,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.game=t,this.renderManager=e}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i){if(void 0===i&&(i=!1),this.scenes.has(t))throw new b("There is already a scene with the name '"+t+"'");this.scenes.set(t,e),!0!==i&&null!==this.openingSceneName||(this.openingSceneName=t)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new b("There is no opening scene");this.loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new b("Game not initialized.");if(!1===this.scenes.has(t))throw new b("Scene with name "+t+" does not exists");this.unloadCurrentScene(),this.currentScene=this.scenes.get(t)(),this.currentScene.name=t,this.currentScene.game=this.game,this.currentScene.init()},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.destroy(),this.currentScene=null,this.currentSceneName=null,this.renderManager.clearData())},t}(),K=function(){function t(t,e){if(this.maxGameDeltatime=0,this.maxPhysicsDeltaTime=0,this.timeScale=1,this.browserDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.max=1/15,this.then=0,t<15)throw new b("Game framerate cannot be less than 15");if(e<60)throw new b("Physics framerate cannot be less than 60");if(e<t)throw new b("Physics framerate cannot be less than game framerate");this.maxGameDeltatime=parseFloat((1/t).toFixed(6)),this.maxPhysicsDeltaTime=parseFloat((1/e).toFixed(6))}return t.prototype.update=function(t){var e=.001*t;this.browserDeltaTime=Math.min(Math.max(0,e-this.then),this.max),this.then=e},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}(),$=function(){function t(t){this.textures=new Map,this.textureFactory=t}return t.prototype.getTexture=function(t){var e;return null!==(e=this.textures.get(Symbol.for(t)))&&void 0!==e?e:null},t.prototype.getOrCreateTextureFromImage=function(t,e){var i;return void 0===e&&(e=!0),null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)},t.prototype.createTextureFromImage=function(t,e){void 0===e&&(e=!0);var i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i},t.prototype.getOrCreateTextureFromCanvas=function(t,e,i){var n;return void 0===i&&(i=!0),null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)},t.prototype.createTextureFromCanvas=function(t,e,i){void 0===i&&(i=!0);var n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n},t}(),J=function(){function t(t,e,i){this.gl=i.getContext(e),this.programFactory=t,this.contextVersion=e}return t.prototype.loadProgram=function(){this.program=this.contextVersion===U.WebGL2?this.programFactory.create(this.gl,"#version 300 es\nprecision mediump float;\n\nin vec2 positionCoords;\nin vec2 textureCoords;\n\nout vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","#version 300 es\nprecision mediump float;\n\nout vec4 fragColor;\n\nin vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n fragColor = vec4(texColor.rgb, u_alpha * texColor.a); \n } else {\n fragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"):this.programFactory.create(this.gl,"precision mediump float;\n\nattribute vec2 positionCoords;\nattribute vec2 textureCoords;\n\nvarying vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","precision mediump float;\n\nvarying vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture2D(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n gl_FragColor = vec4(texColor.rgb, u_alpha * texColor.a);\n } else {\n gl_FragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"),this.positionBuffer=this.gl.createBuffer(),this.textureBuffer=this.gl.createBuffer(),this.positionCoordsAttr=this.gl.getAttribLocation(this.program,"positionCoords"),this.texCoordsAttr=this.gl.getAttribLocation(this.program,"textureCoords"),this.modelMatrixUniform=this.gl.getUniformLocation(this.program,"modelMatrix"),this.projectionMatrixUniform=this.gl.getUniformLocation(this.program,"projectionMatrix"),this.textureMatrixUniform=this.gl.getUniformLocation(this.program,"textureMatrix"),this.renderTextureUniform=this.gl.getUniformLocation(this.program,"u_renderTexture"),this.textureUniform=this.gl.getUniformLocation(this.program,"u_texImage"),this.solidColorUniform=this.gl.getUniformLocation(this.program,"u_solidColor"),this.useTintColorUniform=this.gl.getUniformLocation(this.program,"u_useTintColor"),this.tintColorUniform=this.gl.getUniformLocation(this.program,"u_tintColor"),this.useMaskColorUniform=this.gl.getUniformLocation(this.program,"u_useMaskColor"),this.maskColorUniform=this.gl.getUniformLocation(this.program,"u_maskColor"),this.maskColorMixUniform=this.gl.getUniformLocation(this.program,"u_maskColorMix"),this.alphaUniform=this.gl.getUniformLocation(this.program,"u_alpha"),this.gl.useProgram(this.program),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enableVertexAttribArray(this.positionCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(this.positionCoordsAttr,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.texCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureBuffer),this.gl.vertexAttribPointer(this.texCoordsAttr,2,this.gl.FLOAT,!1,0,0)},t}(),tt=function(){function t(){this.bitmapSize=64,this.fontAtlas=new Map,this.loading=new Map}return t.prototype.hasFontAtlas=function(t){return this.fontAtlas.has(Symbol.for(t))},t.prototype.loadingFontAtlas=function(t){var e;return null!==(e=this.loading.get(Symbol.for(t)))&&void 0!==e&&e},t.prototype.getFontAtlas=function(t){return this.fontAtlas.get(Symbol.for(t))},t.prototype.asyncCreate=function(t,e,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),this.bitmapSize=null!=n?n:this.bitmapSize;var o=new et(e);this.chars=[];for(var a=0;a<t.length;a+=2)for(var s=t[a];s<=t[a+1];s++)this.chars.push(String.fromCharCode(s));o.canvas.width=Math.round(Math.sqrt(this.chars.length))*this.bitmapSize,o.canvas.height=o.canvas.width,null!==i?this.loadFont(e,i).then((function(){return r.renderAtlas(o,e)})):this.renderAtlas(o,e)},t.prototype.loadFont=function(t,e){return p(this,void 0,void 0,(function(){var i;return d(this,(function(n){switch(n.label){case 0:return this.loading.set(Symbol.for(t),!0),[4,(i=new FontFace(t,"url("+e+")")).load()];case 1:return n.sent(),document.fonts.add(i),this.loading.set(Symbol.for(t),!1),[2]}}))}))},t.prototype.renderAtlas=function(t,e){var i=t.canvas.getContext("2d");i.clearRect(0,0,t.canvas.width,t.canvas.height),i.textBaseline="top",i.fillStyle="#000",i.font=this.bitmapSize+"px "+e;for(var n=0,r=0,o=0;o<this.chars.length;o++)i.fillText(this.chars[o],n,r),t.glyphsData.set(this.chars[o],{x:n,y:r,width:this.bitmapSize,height:this.bitmapSize}),(n+=this.bitmapSize)>t.canvas.width-this.bitmapSize&&(n=0,r+=this.bitmapSize);this.fontAtlas.set(Symbol.for(e),t)},t}(),et=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},it=function(){function e(e,i,n){this.posVertices=[],this.texVertices=[],this.posVerticesSize=new t,this.lastTexture=null,this.gl=i.getContext(e),this.programManager=n,this.projectionMatrix=V(),this.modelMatrix=V(),this.textureMatrix=V()}return e.prototype.render=function(t,e,i,n,r){if(n.text){this.generateTextVertices(i,n),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=F(this.modelMatrix),G(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),L(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=F(this.textureMatrix),I(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=F(this.projectionMatrix),k(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),n.opacity<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.lastTexture===e&&"text"===r||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useTintColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,n.opacity);var o=H(n.color),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,l),this.gl.uniform1f(this.programManager.maskColorMixUniform,1),this.gl.uniform1i(this.programManager.useMaskColorUniform,1),this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)}},e.prototype.generateTextVertices=function(t,e){this.posVertices=[],this.texVertices=[];for(var i=this.getDimensions(e),n={x1:-i.width/2,y1:i.height/2-e.fontSize,x2:0,y2:i.height/2},r={x1:0,y1:0,x2:0,y2:0},o=0;o<e.text.length;o++){var a=e.text[o];if("\n"!==a)if(" "!==a){var s=t.glyphsData.get(a);s&&(n.x2=n.x1+e.fontSize,r.x1=s.x+e.bitmapOffset.x,r.y1=s.y+e.bitmapOffset.y,r.x2=s.x+s.width-1,r.y2=s.y+s.height-1,this.posVertices.push(n.x1,n.y1,n.x2,n.y1,n.x1,n.y2,n.x1,n.y2,n.x2,n.y1,n.x2,n.y2),this.texVertices.push(r.x1,r.y2,r.x2,r.y2,r.x1,r.y1,r.x1,r.y1,r.x2,r.y2,r.x2,r.y1)),n.x1+=e.fontSize+e.letterSpacing}else n.x1+=e.fontSize+e.letterSpacing;else n.y1-=e.fontSize+e.lineSeparation,n.y2=n.y1+e.fontSize,n.x1=-i.width/2}this.posVerticesSize.set(i.width,i.height)},e.prototype.getTranslationForOrientation=function(t){return[t.positionInViewport.x+("center"===t.orientation?0:this.posVerticesSize.x/2),t.positionInViewport.y+("rightDown"===t.orientation?-this.posVerticesSize.y/2:"rightUp"===t.orientation?this.posVerticesSize.y:0),0]},e.prototype.getDimensions=function(t){return t.text.split("\n").reduce((function(e,i,n){return e.width=Math.max(e.width,i.length*(t.fontSize+t.letterSpacing)),e.height+=t.fontSize+Math.min(n,1)*t.lineSeparation,e}),{width:0,height:0})},e}(),nt=function(){function t(t,e,i){this.vertices=new Map,this.texVertices=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),this.lastVertices=null,this.lastRender=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=V(),this.modelMatrix=V(),this.textureMatrix=V()}return t.prototype.renderCollider=function(t,e,i){this.lastRender=i,e.shape.type===g.Rectangle&&this.renderRectangle(t,e.positionInViewport,{width:e.shape.width,height:e.shape.height},e.color,e.shape.angle)},t.prototype.renderGeometric=function(t,e,i){this.lastRender=i,"Rectangle"===e.geometricType&&this.renderRectangle(t,e.positionInViewport,{width:e.getGeometric().width,height:e.getGeometric().height},e.color)},t.prototype.renderRectangle=function(t,e,i,n,r){void 0===r&&(r=0);var o=Symbol.for("RW"+i.width+"H"+i.height);!1===this.vertices.has(o)&&this.vertices.set(o,new Float32Array(this.generateRectangleVertices(i.width,i.height,1)));var a=this.vertices.get(o);this.lastVertices===o&&"geometric"===this.lastRender||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW)),this.lastVertices=o,"geometric"!==this.lastRender&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.DYNAMIC_DRAW)),this.modelMatrix=F(this.modelMatrix),G(this.modelMatrix,this.modelMatrix,[e.x,e.y,0]),L(this.modelMatrix,this.modelMatrix,r),this.projectionMatrix=F(this.projectionMatrix),k(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var s=H(n),h=s.r,l=s.g,u=s.b,c=s.a;this.gl.uniform4f(this.programManager.solidColorUniform,h,l,u,c),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.TRIANGLES,0,a.length/2)},t.prototype.generateRectangleVertices=function(t,e,i){var n=e/2,r=t/2;return f(f(f(f([],this.generateLineVertices(-r,-n,r,-n+i),!0),this.generateLineVertices(r-i,-n,r,n),!0),this.generateLineVertices(-r,n-i,r,n),!0),this.generateLineVertices(-r,-n,-r+i,n),!0)},t.prototype.generateLineVertices=function(t,e,i,n){return[t,e,i,e,t,n,t,n,i,e,i,n]},t}(),rt=function(){function e(e,i){this._displacementDirection=new t,this._penetration=e,this._displacementDirection.set(i.x,i.y)}return Object.defineProperty(e.prototype,"penetration",{get:function(){return this._penetration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displacementDirection",{get:function(){return this._displacementDirection},enumerable:!1,configurable:!0}),e}(),ot=function(){function e(){this.proj1={min:0,max:0},this.proj2={min:0,max:0}}return e.prototype.getCollisionData=function(e,i){this.currentOverlap=null,this.minOverlap=null,this.displaceDirection=null,this.axes=f(f([],e.getAxes(),!0),i.getAxes(),!0);for(var n=0;n<this.axes.length;n++){if(this.projectShapeOntoAxis(this.proj1,this.axes[n],e),this.projectShapeOntoAxis(this.proj2,this.axes[n],i),this.currentOverlap=Math.min(this.proj1.max,this.proj2.max)-Math.max(this.proj1.min,this.proj2.min),this.currentOverlap<0)return null;this.preventContainment(n),(this.currentOverlap<this.minOverlap||null===this.minOverlap)&&(this.minOverlap=this.currentOverlap,this.displaceDirection=this.axes[n],this.proj1.max<this.proj2.max&&t.scale(this.displaceDirection,this.displaceDirection,-1))}return new rt(this.minOverlap,this.displaceDirection)},e.prototype.projectShapeOntoAxis=function(e,i,n){return e.min=t.dot(i,n.vertices[0]),e.max=e.min,n.vertices.forEach((function(n){e.min=Math.min(t.dot(i,n),e.min),e.max=Math.max(t.dot(i,n),e.max)})),e},e.prototype.preventContainment=function(e){if(this.proj1.max>this.proj2.max&&this.proj1.min<this.proj2.min||this.proj1.max<this.proj2.max&&this.proj1.min>this.proj2.min){var i=Math.abs(this.proj1.min-this.proj2.min),n=Math.abs(this.proj1.max-this.proj2.max);i<n?this.currentOverlap+=i:(this.currentOverlap+=n,t.scale(this.axes[e],this.axes[e],-1))}},e}(),at=function(){function e(e){var i=this;this._touching=!1,this._positionInViewport=new t(0,0),this._radius=new t(0,0),this.eventHandler=function(t){"touchstart"===t.type&&(i._touching=!0,i.updatePosition(t)),"touchmove"===t.type&&i.updatePosition(t),"touchend"!==t.type&&"touchcancel"!==t.type||(i._touching=!1)},this.canvas=e,this.canvas.addEventListener("touchstart",this.eventHandler),this.canvas.addEventListener("touchend",this.eventHandler),this.canvas.addEventListener("touchcancel",this.eventHandler),this.canvas.addEventListener("touchmove",this.eventHandler)}return Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touching",{get:function(){return this._touching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},enumerable:!1,configurable:!0}),e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),0!==t.targetTouches.length&&(this._positionInViewport.set((t.targetTouches[0].clientX-this.canvas.offsetLeft)/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-(t.targetTouches[0].clientY-this.canvas.offsetTop)/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2),this._radius.set(t.targetTouches[0].radiusX,t.targetTouches[0].radiusY))},e}(),st=function(){function i(){this.shape1Rect=new e(0,0,0,0),this.shape2Rect=new e(0,0,0,0),this.displaceDirection=new t}return i.prototype.getCollisionData=function(t,e){return this.setShapeRect(t,this.shape1Rect),this.setShapeRect(e,this.shape2Rect),this.overlapX=Math.min(this.shape1Rect.x1,this.shape2Rect.x1)-Math.max(this.shape1Rect.x,this.shape2Rect.x),this.overlapY=Math.min(this.shape1Rect.y1,this.shape2Rect.y1)-Math.max(this.shape1Rect.y,this.shape2Rect.y),this.overlapX<0||this.overlapY<0?null:(this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displaceDirection.set(0,Math.sign(this.shape1Rect.y1-this.shape2Rect.y1)),this.preventContainment(this.shape1Rect.y,this.shape2Rect.y,this.shape1Rect.y1,this.shape2Rect.y1)):(this.minOverlap=this.overlapX,this.displaceDirection.set(Math.sign(this.shape1Rect.x1-this.shape2Rect.x1),this.overlapY===this.overlapX?Math.sign(this.shape1Rect.y1-this.shape2Rect.y1):0),this.preventContainment(this.shape1Rect.x,this.shape2Rect.x,this.shape1Rect.x1,this.shape2Rect.x1)),new rt(this.minOverlap,this.displaceDirection))},i.prototype.setShapeRect=function(t,e){e.set(t.position.x-t.width/2,t.position.y-t.height/2,t.width,t.height)},i.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),a=Math.abs(i-r);o<a?this.minOverlap+=o:(this.minOverlap+=a,t.scale(this.displaceDirection,this.displaceDirection,-1))}},i}(),ht=function(){function t(){}return t.prototype.applyCulling=function(t,e){var i=this;return e.filter((function(e){if(!1===t.layers.includes(e.layer))return!1;var n=e.ui?t.viewportRect:t.worldSpaceRect;switch(e.type){case T.Image:return i.cullSprite(n,e);case T.Tilemap:return i.cullTilemap(n,e);case T.Collider:return i.cullCollider(n,e);case T.Geometric:return i.cullGeometric(n,e);case T.Text:return i.cullText(n,e);case T.Mask:return i.cullSprite(n,e)}}))},t.prototype.cullSprite=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.cullTilemap=function(t,e){var i=this;return e.tilesToRender=e.tilesData.filter((function(n){return i.isTargetVisible(t,{x:n.position.x-e.tileWidth/2,x1:n.position.x+e.tileWidth/2,y:n.position.y-e.tileHeight/2,y1:n.position.y+e.tileHeight/2})})),e.tilesData.length>0},t.prototype.cullCollider=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.shape.width/2,x1:e.position.x+e.shape.width/2,y:e.position.y-e.shape.height/2,y1:e.position.y+e.shape.height/2})},t.prototype.cullGeometric=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.geometric.width/2,x1:e.position.x+e.geometric.width/2,y:e.position.y-e.geometric.height/2,y1:e.position.y+e.geometric.height/2})},t.prototype.cullText=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.isTargetVisible=function(t,e){return t.x1>=e.x&&t.x<=e.x1&&t.y1>=e.y&&t.y<=e.y1},t}(),lt=function(){function t(t,e,i){this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.p={x1:0,y1:0,x2:0,y2:0},this.t={x1:0,y1:0,x2:0,y2:0},this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=V(),this.modelMatrix=V(),this.textureMatrix=V()}return t.prototype.render=function(t,e,i,n){if(this.generateVertices(i),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=F(this.modelMatrix),this.textureMatrix=F(this.textureMatrix),I(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=F(this.projectionMatrix),k(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"tilemap"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useMaskColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var r=H(i.tintColor),o=r.r,a=r.g,s=r.b,h=r.a;this.gl.uniform4f(this.programManager.tintColorUniform,o,a,s,h)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)},t.prototype.generateVertices=function(t){var e=this;this.posVertices=[],this.texVertices=[],t.tilesToRender.forEach((function(i){var n,r;e.p.x1=i.positionInViewport.x-t.tileWidth/2,e.p.x2=i.positionInViewport.x+t.tileWidth/2,e.p.y1=i.positionInViewport.y-t.tileHeight/2,e.p.y2=i.positionInViewport.y+t.tileHeight/2,e.posVertices.push(e.p.x1,e.p.y1,e.p.x2,e.p.y1,e.p.x1,e.p.y2,e.p.x1,e.p.y2,e.p.x2,e.p.y1,e.p.x2,e.p.y2),e.t.x1=i.tile.x,e.t.y1=i.tile.y,e.t.x2=i.tile.x+i.tile.width-(null!==(n=t.textureCorrection)&&void 0!==n?n:0),e.t.y2=i.tile.y+i.tile.height-(null!==(r=t.textureCorrection)&&void 0!==r?r:0),e.texVertices.push(e.t.x1,e.t.y2,e.t.x2,e.t.y2,e.t.x1,e.t.y1,e.t.x1,e.t.y1,e.t.x2,e.t.y2,e.t.x2,e.t.y1)}))},t}(),ut="angry-pixel-start",ct="angry-pixel-update",pt=function(){function t(t,e,i,n){this.timeManager=t,this.collisionManager=e,this.renderManager=i,this.inputManager=n,this.gameLoopAccumulator=0,this.physicsLoopAccumulator=0,this.deltaAux=0}return t.prototype.update=function(t){for(this.timeManager.update(t),this.deltaAux=Math.min(this.timeManager.browserDeltaTime,this.timeManager.maxGameDeltatime),this.gameLoopAccumulator+=this.deltaAux,this.physicsLoopAccumulator+=this.timeManager.browserDeltaTime,this.timeManager.unscaledGameDeltaTime=Math.max(this.timeManager.maxGameDeltatime,this.timeManager.browserDeltaTime),this.timeManager.unscaledPhysicsDeltaTime=this.timeManager.maxPhysicsDeltaTime,this.gameLoopAccumulator>this.timeManager.maxGameDeltatime&&(this.mainIteration(),this.gameLoopAccumulator-=this.timeManager.maxGameDeltatime);this.physicsLoopAccumulator>this.timeManager.maxPhysicsDeltaTime;)this.timeManager.timeScale>0&&this.physicsIteration(),this.physicsLoopAccumulator-=this.timeManager.maxPhysicsDeltaTime;this.preRenderIteration(),this.renderIteration()},t.prototype.mainIteration=function(){this.dispatchFrameEvent(ut),this.inputManager.update(),this.dispatchFrameEvent(ct),this.dispatchFrameEvent("angry-pixel-update-engine"),this.dispatchFrameEvent("angry-pixel-update-transform"),this.dispatchFrameEvent("angry-pixel-update-collider"),this.collisionManager.update()},t.prototype.physicsIteration=function(){this.dispatchFrameEvent("angry-pixel-update-physics"),this.dispatchFrameEvent("angry-pixel-update-collider")},t.prototype.preRenderIteration=function(){this.dispatchFrameEvent("angry-pixel-update-transform"),this.dispatchFrameEvent("angry-pixel-update-prerender"),this.dispatchFrameEvent("angry-pixel-update-camera")},t.prototype.renderIteration=function(){this.dispatchFrameEvent("angry-pixel-update-render"),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.dispatchFrameEvent=function(t){window.dispatchEvent(new CustomEvent(t))},t}(),dt=function(){function t(){}return t.initialize=function(t){this.assetManager=t},t.getAssetsLoaded=function(){return this.assetManager.getAssetsLoaded()},t.loadImage=function(t){return this.assetManager.laadImage(t)},t.loadAudio=function(t){return this.assetManager.loadAudio(t)},t.getImage=function(t){return this.assetManager.getImage(t)},t.getAudio=function(t){return this.assetManager.getAudio(t)},t.assetManager=null,t}(),ft=function(){function t(){}return t.initialize=function(t){this.domManager=t},Object.defineProperty(t,"gameWidth",{get:function(){return this.domManager.canvas.width},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gameHeight",{get:function(){return this.domManager.canvas.height},enumerable:!1,configurable:!0}),Object.defineProperty(t,"canvas",{get:function(){return this.domManager.canvas},enumerable:!1,configurable:!0}),t.domManager=null,t}(),gt=function(){function t(){}return t.initialize=function(t){this.inputManager=t},Object.defineProperty(t,"mouse",{get:function(){return this.inputManager.mouse},enumerable:!1,configurable:!0}),Object.defineProperty(t,"keyboard",{get:function(){return this.inputManager.keyboard},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gamepad",{get:function(){return this.inputManager.gamepad},enumerable:!1,configurable:!0}),Object.defineProperty(t,"touch",{get:function(){return this.inputManager.touch},enumerable:!1,configurable:!0}),t.inputManager=null,t}(),mt=function(){function t(){}return t.initialize=function(t){this.sceneManager=t},t.loadScene=function(t){this.sceneManager.loadScene(t)},t.getCurrentSceneName=function(){return this.sceneManager.currentSceneName},t.loadOpeningScene=function(){this.sceneManager.loadOpeningScene()},t.sceneManager=null,t}(),yt=function(){function t(){}return t.initialize=function(t){this.timeManager=t},Object.defineProperty(t,"deltaTime",{get:function(){return this.timeManager.deltaTime},enumerable:!1,configurable:!0}),t.getTimeScale=function(){return this.timeManager.timeScale},t.setTimeScale=function(t){this.timeManager.timeScale=t},Object.defineProperty(t,"unscaledDeltaTime",{get:function(){return this.timeManager.unscaledGameDeltaTime},enumerable:!1,configurable:!0}),Object.defineProperty(t,"physicsDeltaTime",{get:function(){return this.timeManager.physicsDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),xt=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i){return void 0===i&&(i=null),this.manager.addGameObject(t,e,i)},t.getGameObjects=function(){return this.manager.getGameObjects()},t.findGameObjectByName=function(t){return this.manager.findGameObjectByName(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParentAndName=function(t,e){return this.manager.findGameObjectByParentAndName(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.findGameObjectByTag=function(t){return this.manager.findGameObjectByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t}(),bt=function(){function t(t,e,i){this.vertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=V(),this.modelMatrix=V(),this.textureMatrix=V()}return t.prototype.render=function(t,e,i){"mask"!==i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW)),this.modelMatrix=F(this.modelMatrix),G(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),L(this.modelMatrix,this.modelMatrix,e.rotation),I(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=F(this.projectionMatrix),k(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),e.alpha<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var n=H(e.color),r=n.r,o=n.g,a=n.b,s=n.a;this.gl.uniform4f(this.programManager.solidColorUniform,r,o,a,s),this.gl.uniform1f(this.programManager.alphaUniform,e.alpha),this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),vt=function(t,e){if(e.collisions.method===Q.AABB)t.add("CollisionResolver",(function(){return new st}));else{if(e.collisions.method!==Q.SAT)throw new b("Invalid collision method.");t.add("CollisionResolver",(function(){return new ot}))}t.add("CollisionManager",(function(){return new _(t.getSingleton("CollisionResolver"),e.collisions.quadTreeBounds,e.collisions.quadMaxLevel,e.collisions.collidersPerQuad)}))},_t=function(t,e,i){var n=Ct();if(e.context2d===Y.Default||e.context2d===Y.Fallback&&null===n)t.add("Renderer",(function(){return new A(i.canvas)})),e.debugEnabled&&console.log("Using 2d rendering context");else{if(null===n)throw new b("WebGL is not supported, use context2d instead.");wt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")")}t.add("FontAtlasFactory",(function(){return new tt})),t.add("CullingService",(function(){return new ht})),t.add("RenderManager",(function(){return new E(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},wt=function(t,e,i){e.add("ShaderLoader",(function(){return new N})),e.add("ProgramFactory",(function(){return new W(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new J(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new q(t,i.canvas)})),e.add("TextureManager",(function(){return new $(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new it(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new nt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new lt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new bt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new X(t,i.canvas,e.getSingleton("ProgramManager"),e.getSingleton("TextureManager"),e.getSingleton("FontAtlasFactory"),e.getSingleton("WebGLImageRenderer"),e.getSingleton("WebGLTilemapRenderer"),e.getSingleton("WebGLTextRenderer"),e.getSingleton("WebGLGeometricRenderer"),e.getSingleton("WebGLMaskRenderer"))}))},Mt=function(t,e){t.add("Mouse",(function(){return new P(e.canvas)})),t.add("Keyboard",(function(){return new R(e.canvas)})),t.add("Gamepad",(function(){return new C})),t.add("Touch",(function(){return new at(e.canvas)})),t.add("InputManager",(function(){return new j(t.getSingleton("Mouse"),t.getSingleton("Keyboard"),t.getSingleton("Gamepad"),t.getSingleton("Touch"))}))},Ct=function(){return null!==document.createElement("canvas").getContext(U.WebGL2)?U.WebGL2:null!==document.createElement("canvas").getContext(U.LegacyWebGL)?U.LegacyWebGL:null},Ot=function(t){dt.initialize(t.getSingleton("AssetManager")),ft.initialize(t.getSingleton("DomManager")),gt.initialize(t.getSingleton("InputManager")),mt.initialize(t.getSingleton("SceneManager")),yt.initialize(t.getSingleton("TimeManager")),xt.initialize(t.getSingleton("GameObjectManager"))},jt=new(function(){function t(){this.instances=new Map,this.constructors=new Map,this.constants=new Map}return t.prototype.add=function(t,e){if(this.constructors.has(t))throw new b("There is already an object constructor with the name "+t);this.constructors.set(t,e)},t.prototype.getSingleton=function(t){if(!1===this.constructors.has(t))throw new b("Invalid object constructor name: "+t);return!1===this.instances.has(t)&&this.instances.set(t,this.constructors.get(t)()),this.instances.get(t)},t.prototype.getTranscient=function(t){if(!1===this.constructors.has(t))throw new b("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new b("There is already a constant value with the name "+t);this.constants.set(t,e)},t.prototype.getConstant=function(t){if(!1===this.constants.has(t))throw new b("Invalid constant name: "+t);return this.constants.get(t)},t}());!function(t){t.Default="default",t.Disabled="disabled",t.Fallback="fallback"}(Y||(Y={})),function(t){t.AABB="aabb",t.SAT="sat"}(Q||(Q={}));var Rt,Pt={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",context2d:Y.Fallback,spriteDefaultScale:null,gameFrameRate:60,physicsFramerate:240,collisions:{method:Q.AABB,quadTreeBounds:null,quadMaxLevel:6,collidersPerQuad:15}},Tt=function(){function t(t){var e=this;this._running=!1,this._stop=!1,this.frameRequestId=null,this.errorEventHandler=function(t){t.error.name===x&&(e.stop(),t.stopPropagation(),t.preventDefault(),console.error(t.error.message+"\n"+t.filename+":"+t.lineno))},this._config=c(c({},Pt),t),this._config.collisions=c(c({},Pt.collisions),t.collisions),window.addEventListener("error",this.errorEventHandler),jt.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("DomManager",(function(){return new w(e.containerNode,e.gameWidth,e.gameHeight)}));var i=t.getSingleton("DomManager");_t(t,e,i),Mt(t,i),vt(t,e),t.add("SceneManager",(function(){return new Z(t.getConstant("Game"),t.getSingleton("RenderManager"))})),t.add("GameObjectManager",(function(){return new M})),t.add("AssetManager",(function(){return new y})),t.add("TimeManager",(function(){return new K(e.gameFrameRate,e.physicsFramerate)})),t.add("IterationManager",(function(){return new pt(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"))})),Ot(t)}(jt,this._config),this.renderManager=jt.getSingleton("RenderManager"),this.sceneManager=jt.getSingleton("SceneManager"),this.iterationManager=jt.getSingleton("IterationManager")},Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"running",{get:function(){return this._running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i){void 0===i&&(i=!1),this.sceneManager.addScene(t,e,i)},t.prototype.run=function(){this.sceneManager.loadOpeningScene(),this.requestAnimationFrame()},t.prototype.stop=function(){this.pauseLoop(),this.sceneManager.unloadCurrentScene(),this.renderManager.clearCanvas()},t.prototype.gameLoop=function(t){!0!==this._stop&&(this._running=!0,this.iterationManager.update(t),this.requestAnimationFrame())},t.prototype.pauseLoop=function(){this._stop=!0,this._running=!1,null!==this.frameRequestId&&(window.cancelAnimationFrame(this.frameRequestId),this.frameRequestId=null)},t.prototype.resumeLoop=function(){0==this._running&&null===this.frameRequestId&&(this._stop=!1,this.requestAnimationFrame())},t.prototype.requestAnimationFrame=function(){var t=this;this.frameRequestId=window.requestAnimationFrame((function(e){return t.gameLoop(e)}))},t}(),St=function(){var t=(new Date).getTime(),e=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(i){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"==i?n:7&n|8).toString(16)}))},Dt=function(){function t(){var t=this;this.sceneManager=jt.getSingleton("SceneManager"),this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.id=St(),this.allowMultiple=!0,this.type=null,this.name=null,this.gameObject=null,this._active=!0,this.started=!1,this.gameLoopEventHandler=function(e){if(!1!==t._active)try{t.started||e.type!==ut?t.started&&e.type===t.updateEvent&&t.update():(t.start(),t.started=!0)}catch(t){throw t.name===x?t:new b(t.message)}},window.addEventListener(ut,this.gameLoopEventHandler),window.addEventListener(this.updateEvent,this.gameLoopEventHandler)}return Object.defineProperty(t.prototype,"updateEvent",{get:function(){return ct},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),t.prototype.setActive=function(t){this._active=t},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getComponentByName=function(t){return this.gameObject.getComponentByName(t)},t.prototype.getComponentByType=function(t){return this.gameObject.getComponentByType(t)},t.prototype.getComponentsByType=function(t){return this.gameObject.getComponentsByType(t)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){this.gameObject.removeComponentByName(t)},t.prototype.removeComponentByType=function(t){this.gameObject.removeComponentByType(t)},t.prototype.destroy=function(){var t=this;window.removeEventListener(ut,this.gameLoopEventHandler),window.removeEventListener(this.updateEvent,this.gameLoopEventHandler),Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),At=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-engine"},enumerable:!1,configurable:!0}),e}(Dt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-collider"},enumerable:!1,configurable:!0}),e}(Dt),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-physics"},enumerable:!1,configurable:!0}),e}(Dt),Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-transform"},enumerable:!1,configurable:!0}),e}(Dt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-prerender"},enumerable:!1,configurable:!0}),e}(Dt),Gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-camera"},enumerable:!1,configurable:!0}),e}(Dt),It=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return"angry-pixel-update-render"},enumerable:!1,configurable:!0}),e}(Dt),Lt={Animator:"Animator",AudioPlayer:"AudioPlayer",Camera:"camera",RigidBody:"RigidBody",Transform:"Transform",BoxCollider:"BoxCollider",TilemapCollider:"TilemapCollider",CsvTilemapRenderer:"CsvTilemapRenderer",SpriteRenderer:"SpriteRenderer",TextRenderer:"TextRenderer",TiledTilemapRenderer:"TiledTilemapRenderer",MaskRenderer:"MaskRenderer"},kt=function(e){function i(){var i=e.call(this)||this;return i._position=new t,i._scale=new t(1,1),i._rotation=new s,i._innerPosition=new t,i._parent=null,i.parentScale=!0,i.parentRotation=!0,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i.allowMultiple=!1,i.type=Lt.Transform,i}return l(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,null!==this._parent&&this.updateInnerPositionFromParent()},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent?(!1===this.lastPosition.equals(this._position)&&this.updateInnerPositionFromParent(),this.setPositionFromParent()):this._innerPosition.copy(this._position),this.lastPosition.copy(this._position)},i.prototype.updateInnerPositionFromParent=function(){t.subtract(this._innerPosition,this._position,this._parent.position)},i.prototype.setPositionFromParent=function(){this._innerPosition.magnitude>0?(0!==this._parent.rotation.radians&&this.lastParentRadians!==this._parent.rotation.radians&&(this.translateInnerPosition(),this.lastParentRadians=this._parent.rotation.radians),this.updateScaledInnerPosition(),t.add(this._position,this._parent.position,this.scaledInnerPosition)):this._position.copy(this._parent.position),this._rotation.radians=this.parentRotation?this._parent.rotation.radians:this.rotation.radians,this.parentScale&&this._scale.copy(this._parent.scale)},i.prototype.translateInnerPosition=function(){var e=Math.atan2(this._innerPosition.y,this._innerPosition.x)+(this._parent.rotation.radians-this.lastParentRadians);this.cache.set(Math.cos(e),Math.sin(e)),t.scale(this._innerPosition,this.cache,this._innerPosition.magnitude)},i.prototype.updateScaledInnerPosition=function(){this.scaledInnerPosition.set(this._innerPosition.x*this._parent.scale.x,this._innerPosition.y*this._parent.scale.y)},i}(Vt),Ut="Default",Ht=function(){function t(){var t=this;this.id=St(),this.name=null,this.tag=null,this.layer="Default",this.ui=!1,this.keep=!1,this._active=!0,this._parent=null,this.started=!1,this.sceneManager=jt.getSingleton("SceneManager"),this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.components=[],this.inactiveComponents=[],this.inactiveChildren=[],this.gameLoopEventHandler=function(e){if(!1!==t._active)try{t.started||e.type!==ut?t.started&&e.type===ct&&t.update():(t.start(),t.started=!0)}catch(t){throw t.name===x?t:new b(t.message)}},this.addComponent((function(){return new kt})),window.addEventListener(ut,this.gameLoopEventHandler),window.addEventListener(ct,this.gameLoopEventHandler)}return Object.defineProperty(t.prototype,"transform",{get:function(){return this.getComponentByType(Lt.Transform)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=t?t.transform:null},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.addComponent=function(t,e){void 0===e&&(e=null);var i=t();return this.checkMultipleComponent(i),i.name=e,i.gameObject=this,i.init(),this.components.push(i),i},t.prototype.checkMultipleComponent=function(t){if(!1===t.allowMultiple&&this.hasComponentOfType(t.type))throw new b("GameObject only allows one component of type "+t.type)},t.prototype.getComponents=function(){return this.components},t.prototype.getComponentByName=function(t){return this.components.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.getComponentByType=function(t){return this.components.reduce((function(e,i){return i.type===t?i:e}),null)},t.prototype.getComponentsByType=function(t){return this.components.filter((function(e){return e.type===t}))},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){var e=this;this.components.every((function(i,n){if(i.name===t)return i.destroy(),delete e.components[n],!1}))},t.prototype.removeComponentByType=function(t){var e=this;this.components.every((function(i,n){if(i.type===t)return i.destroy(),delete e.components[n],!1}))},t.prototype.removeComponents=function(){var t=this;this.components.every((function(e,i){return e.destroy(),delete t.components[i]})),this.components=[]},t.prototype.addChild=function(t,e){return this.gameObjectManager.addGameObject(t,e,this)},t.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},t.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParentAndName(this,t)},t.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},t.prototype.setActive=function(t){var e=this;!1===t&&this.updateInactiveCache(),this.components.filter((function(t){return-1===e.inactiveComponents.indexOf(t.id)})).forEach((function(e){return e.setActive(t)})),this.getChildren().filter((function(t){return-1===e.inactiveChildren.indexOf(t.id)})).forEach((function(e){return e.setActive(t)})),this._active=t},t.prototype.updateInactiveCache=function(){var t=this;this.inactiveComponents=[],this.inactiveChildren=[],this.components.filter((function(t){return!1===t.active})).forEach((function(e){return t.inactiveComponents.push(e.id)})),this.getChildren().filter((function(t){return!1===t.active})).forEach((function(e){return t.inactiveChildren.push(e.id)}))},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype.destroy=function(){var t=this;window.removeEventListener(ut,this.gameLoopEventHandler),window.removeEventListener(ct,this.gameLoopEventHandler),this.removeComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),zt=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},Wt=["Default"],Nt=function(t){function i(){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.domManager=jt.getSingleton("DomManager"),i._layers=Wt,i._depth=0,i._zoom=1,i._originalViewportRect=new e(0,0,0,0),i._viewportRect=new e(0,0,0,0),i._worldSpaceRect=new e(0,0,0,0),i.cameraData=new zt,i.allowMultiple=!1,i.type=Lt.Camera,i.canvas=i.domManager.canvas,i}return l(i,t),Object.defineProperty(i.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=f(f([],Wt,!0),t,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new b("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"originalViewportRect",{get:function(){return this._originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"worldSpaceRect",{get:function(){return this._worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"viewportRect",{get:function(){return this._viewportRect},enumerable:!1,configurable:!0}),i.prototype.addLayer=function(t){this._layers.push(t)},i.prototype.update=function(){this.updateOriginalViewportRect(),this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},i.prototype.updateOriginalViewportRect=function(){this._originalViewportRect.x=-this.canvas.width/2,this._originalViewportRect.y=-this.canvas.height/2,this._originalViewportRect.width=this.canvas.width,this._originalViewportRect.height=this.canvas.height},i.prototype.updateViewportRect=function(){var t=1/this._zoom;this._viewportRect.x=this._originalViewportRect.x*t,this._viewportRect.y=this._originalViewportRect.y*t,this._viewportRect.width=this._originalViewportRect.width*t,this._viewportRect.height=this._originalViewportRect.height*t},i.prototype.updateWorldSpaceRect=function(){this._worldSpaceRect.x=this.gameObject.transform.position.x-this._viewportRect.width/2,this._worldSpaceRect.y=this.gameObject.transform.position.y-this._viewportRect.height/2,this._worldSpaceRect.width=this._viewportRect.width,this._worldSpaceRect.height=this._viewportRect.height},i.prototype.updateCameraData=function(){this.cameraData.depth=this._depth,this.cameraData.layers=this._layers,this.cameraData.originalViewportRect=this._originalViewportRect,this.cameraData.viewportRect=this._viewportRect,this.cameraData.worldSpaceRect=this._worldSpaceRect,this.cameraData.zoom=this._zoom,this.renderManager.addCameraData(this.cameraData)},i}(Gt),qt=function(t){function e(){var e=t.call(this)||this;return e.transform.position.set(0,0),e.camera=e.addComponent((function(){return new Nt})),e}return l(e,t),Object.defineProperty(e.prototype,"layers",{get:function(){return this.camera.layers},set:function(t){this.camera.layers=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this.camera.depth},set:function(t){this.camera.depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this.camera.zoom},set:function(t){this.camera.zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewporRect",{get:function(){return this.camera.originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this.camera.worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this.camera.viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this.camera.layers.push(t)},e}(Ht),Yt="GameCamera",Qt=function(){function t(){var t=this;this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.game=null,this.name=null,this.started=!1,this.gameLoopEventHandler=function(e){try{t.started||e.type!==ut?t.started&&e.type===ct&&t.update():(t.start(),t.started=!0)}catch(t){throw t.name===x?t:new b(t.message)}},window.addEventListener(ut,this.gameLoopEventHandler),window.addEventListener(ct,this.gameLoopEventHandler),this.addGameObject((function(){return new qt}),"GameCamera")}return Object.defineProperty(t.prototype,"gameCamera",{get:function(){return this.findGameObjectByName("GameCamera")},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getGameObjects=function(){return this.gameObjectManager.getGameObjects()},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype.destroy=function(){var t=this;window.removeEventListener(ut,this.gameLoopEventHandler),window.removeEventListener(ct,this.gameLoopEventHandler),this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),Xt=function(e){function i(i,n,r,o){void 0===o&&(o=0);var a=e.call(this)||this;return a.cacheVector=new t,a.axes=[],a._type=g.Rectangle,a._position.set(i.x,i.y),a._width=n,a._height=r,a._angle=o,a._model=[new t(-n/2,-r/2),new t(-n/2,r/2),new t(n/2,r/2),new t(n/2,-r/2)],a._vertices=[new t,new t,new t,new t],a.axes=[new t,new t],a.update(),a}return l(i,e),i.prototype.update=function(){this.updateModel();for(var t=0;t<this._model.length;t++)this._vertices[t].set(this._model[t].x*Math.cos(this._angle)-this._model[t].y*Math.sin(this._angle)+this._position.x,this._model[t].x*Math.sin(this._angle)+this._model[t].y*Math.cos(this._angle)+this._position.y);this.updateDirection(),this.updateAxes()},i.prototype.updateModel=function(){this._model[0].set(-this._width/2,-this._height/2),this._model[1].set(-this._width/2,this._height/2),this._model[2].set(this._width/2,this._height/2),this._model[3].set(this._width/2,-this._height/2)},i.prototype.updateDirection=function(){t.unit(this._direction,t.subtract(this.cacheVector,this._vertices[1],this._vertices[0]))},i.prototype.updateAxes=function(){t.normal(this.axes[0],this._direction),this.axes[1].set(this._direction.x,this._direction.y)},i.prototype.clone=function(){return new i(this._position,this._width,this._height,this._angle)},i.prototype.getAxes=function(){return this.axes},i}(S),Zt=function(){function e(e,i,n,r,o,a){void 0===a&&(a=0),this._position=new t,this._width=0,this._height=0,this._angle=0,this._quadMaxBounds=new t,this._quadMinBounds=new t,this._position.set(e.x,e.y),this._quadVertices=[new t,new t,new t,new t],this._width=i,this._height=n,this._angle=a,this.gameObject=o,this.physics=r,this.shape=new Xt(this._position,this._width,this._height),this.updateQuadVertices()}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y),this.updateShape(),this.updateQuadVertices()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t,this.updateShape(),this.updateQuadVertices()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t,this.updateShape(),this.updateQuadVertices()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomLeftQuadVertex",{get:function(){return this._quadVertices[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomRightQuadVertex",{get:function(){return this._quadVertices[3]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topLeftQuadVertex",{get:function(){return this._quadVertices[1]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topRightQuadVertex",{get:function(){return this._quadVertices[2]},enumerable:!1,configurable:!0}),e.prototype.updateShape=function(){this.shape.position=this._position,this.shape.width=this._width,this.shape.height=this.height,this.shape.angle=this._angle,this.shape.update()},e.prototype.updateQuadVertices=function(){var t=this;this._quadMaxBounds.set(this.shape.vertices[0].x,this.shape.vertices[0].y),this._quadMinBounds.set(this.shape.vertices[0].x,this.shape.vertices[0].y),this.shape.vertices.forEach((function(e){t._quadMaxBounds.set(Math.max(e.x,t._quadMaxBounds.x),Math.max(e.y,t._quadMaxBounds.y)),t._quadMinBounds.set(Math.min(e.x,t._quadMinBounds.x),Math.min(e.y,t._quadMinBounds.y))})),this._quadVertices[0].set(this._quadMinBounds.x,this._quadMinBounds.y),this._quadVertices[1].set(this._quadMinBounds.x,this._quadMaxBounds.y),this._quadVertices[2].set(this._quadMaxBounds.x,this._quadMaxBounds.y),this._quadVertices[3].set(this._quadMaxBounds.x,this._quadMinBounds.y)},e}(),Kt=function(t){function e(){var e=t.call(this)||this;return e.collisionManager=jt.getSingleton("CollisionManager"),e.colliders=[],e._physics=!0,e.renderer=null,e.collisionsCache=[],e}return l(e,t),Object.defineProperty(e.prototype,"physics",{get:function(){return this._physics},enumerable:!1,configurable:!0}),e.prototype.addCollider=function(t){this.colliders.push(t),this.collisionManager.addCollider(t)},e.prototype.collidesWithLayer=function(t){return null!==this.getCollisionWithLayer(t)},e.prototype.getCollisionWithLayer=function(t){this.updatePosition();for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getCollisionsForCollider(n);r<o.length;r++){var a=o[r];if(a.remoteCollider.gameObject.layer===t)return a}return null},e.prototype.getCollisionsWithLayer=function(t){this.updatePosition(),this.collisionsCache=[];for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getCollisionsForCollider(n);r<o.length;r++){var a=o[r];a.remoteCollider.gameObject.layer===t&&this.collisionsCache.push(a)}return f([],this.collisionsCache,!0)},e.prototype.setActive=function(e){var i=this;!0===e&&!1===this.active?this.colliders.forEach((function(t){return i.collisionManager.addCollider(t)})):!1===e&&!0===this.active&&this.colliders.forEach((function(t){return i.collisionManager.removeCollider(t)})),this.renderer&&this.renderer.setActive(e),t.prototype.setActive.call(this,e)},e.prototype.destroy=function(){var e=this;this.colliders.forEach((function(t){return e.collisionManager.removeCollider(t)})),t.prototype.destroy.call(this)},e}(Et),$t=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=T.Collider,e.color=null,e.shape=null,e}return l(e,t),e}(D),Jt=function(e){function i(i){var n,r,o,a,h,l=e.call(this)||this;return l.debug=!1,l.offsetX=0,l.offsetY=0,l.realWidth=0,l.realHeight=0,l.realOffset=new t,l.realPosition=new t,l.realRotation=0,l.applyRotation=jt.getConstant("GameConfig").collisions.method===Q.SAT,l.innerPosition=new t,l.type=Lt.BoxCollider,l.width=i.width,l.height=i.height,l.offsetX=null!==(n=i.offsetX)&&void 0!==n?n:l.offsetX,l.offsetY=null!==(r=i.offsetY)&&void 0!==r?r:l.offsetY,l._physics=null!==(o=i.physics)&&void 0!==o?o:l._physics,l.debug=(null!==(a=i.debug)&&void 0!==a?a:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new s,l}return l(i,e),i.prototype.start=function(){var t=this;this.updateRealSize(),this.addCollider(new Zt(this.gameObject.transform.position,this.realWidth,this.realHeight,this._physics,this.gameObject,this.realRotation)),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new te(t.colliders[0])})))},i.prototype.update=function(){this.updatePosition()},i.prototype.updatePosition=function(){this.updateRealSize(),this.colliders[0].width=this.realWidth,this.colliders[0].height=this.realHeight,this.colliders[0].position=t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.realRotation&&this.applyRotation&&(this.colliders[0].angle=this.realRotation),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.updateRealSize=function(){this.realWidth=this.width*Math.abs(this.gameObject.transform.scale.x),this.realHeight=this.height*Math.abs(this.gameObject.transform.scale.y),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.realRotation=this.gameObject.transform.rotation.radians+this.rotation.radians},i.prototype.translate=function(){t.subtract(this.innerPosition,this.colliders[0].position,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e)),this.colliders[0].position=this.realPosition},i}(Kt),te=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="BoxColliderRenderer",i.renderData=new $t,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return l(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.position=this.collider.position,this.renderData.shape=this.collider.shape,this.renderManager.addRenderData(this.renderData)},e}(It),ee=function(e){function i(i){var n,r=e.call(this)||this;return r.tilemapRenderer=null,r.debug=!1,r.needsCollider=function(t){r.cacheVertex[0].set(t.position.x,t.position.y+t.height),r.cacheVertex[1].set(t.position.x+t.width,t.position.y),r.cacheVertex[2].set(t.position.x,t.position.y-t.height),r.cacheVertex[3].set(t.position.x-t.width,t.position.y);for(var e=function(t){if(void 0===r.tilemapRenderer.tilesData.find((function(e){return e.position.equals(r.cacheVertex[t])})))return{value:!0}},i=0;i<r.cacheVertex.length;i++){var n=e(i);if("object"==typeof n)return n.value}return!1},r.type=Lt.TilemapCollider,r.tilemapRenderer=i.tilemapRenderer,r.debug=(null!==(n=i.debug)&&void 0!==n?n:r.debug)&&jt.getConstant("GameConfig").debugEnabled,r._physics=!0,r.cacheVertex=[new t,new t,new t,new t],r}return l(i,e),i.prototype.start=function(){var t=this;this.tilemapRenderer.tilesData.filter(this.needsCollider).forEach((function(e){t.addCollider(new Zt(e.position,e.width,e.height,t._physics,t.gameObject))})),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ie(t.colliders)})))},i.prototype.updatePosition=function(){},i}(Kt),ie=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="TilemapColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new $t,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00"})),i}return l(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].position=e.position,t.renderData[i].shape=e.shape,t.renderManager.addRenderData(t.renderData[i])}))},e}(It),ne=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=T.Image,e}return l(e,t),e}(D),re=function(e){function i(i){var n,r,o,a,h,l,u,c,p,d,f;void 0===i&&(i={sprite:null});var g=e.call(this)||this;return g.renderManager=jt.getSingleton("RenderManager"),g.sprite=null,g.offset=new t,g.flipHorizontal=!1,g.flipVertical=!1,g.rotation=new s,g.smooth=!1,g.opacity=1,g._tiled=new t(1,1),g.maskColor=null,g.maskColorMix=0,g.tintColor=null,g.renderData=[],g.innerPosition=new t,g.cachePosition=new t,g.cacheRenderPosition=new t,g.scaledOffset=new t,g.type=Lt.SpriteRenderer,g.sprite=i.sprite,g.offset=null!==(n=i.offset)&&void 0!==n?n:g.offset,g.smooth=null!==(r=i.smooth)&&void 0!==r?r:g.smooth,g.rotation=null!==(o=i.rotation)&&void 0!==o?o:g.rotation,g.flipHorizontal=null!==(a=i.flipHorizontal)&&void 0!==a?a:g.flipHorizontal,g.flipVertical=null!==(h=i.flipVertical)&&void 0!==h?h:g.flipVertical,g.opacity=null!==(l=i.opacity)&&void 0!==l?l:g.opacity,g.tiled=null!==(u=i.tiled)&&void 0!==u?u:g._tiled,g.maskColor=null!==(c=i.maskColor)&&void 0!==c?c:g.maskColor,g.maskColorMix=null!==(p=i.maskColorMix)&&void 0!==p?p:g.maskColorMix,g.tintColor=null!==(d=i.tintColor)&&void 0!==d?d:g.tintColor,g.layer=null!==(f=i.layer)&&void 0!==f?f:g.layer,g}return l(i,e),Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new b("SpriteRenderer.tiled: Vector2 components must be integers");this._tiled.set(t.x,t.y)},enumerable:!1,configurable:!0}),i.prototype.update=function(){if(this.sprite&&!0===this.sprite.loaded){this.updateRenderDataArray();for(var t=0,e=0;e<this._tiled.x;e++)for(var i=0;i<this._tiled.y;i++)this.updateRenderData(t,e,i),t++}},i.prototype.updateRenderDataArray=function(){if(this.renderData.length!==this._tiled.x*this._tiled.y){this.renderData=[];for(var t=0;t<=this._tiled.x*this._tiled.y;t++)this.renderData[t]=new ne}},i.prototype.updateRenderData=function(t,e,i){var n;this.renderData[t].ui=this.gameObject.ui,this.renderData[t].layer=null!==(n=this.layer)&&void 0!==n?n:this.gameObject.layer,this.renderData[t].image=this.sprite.image,this.renderData[t].width=this.sprite.width*Math.abs(this.gameObject.transform.scale.x),this.renderData[t].height=this.sprite.height*Math.abs(this.gameObject.transform.scale.y),this.renderData[t].slice=this.sprite.slice,this.renderData[t].flipHorizontal=this.flipHorizontal!==this.gameObject.transform.scale.x<0,this.renderData[t].flipVertical=this.flipVertical!==this.gameObject.transform.scale.y<0,this.renderData[t].rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData[t].smooth=this.sprite.smooth,this.renderData[t].alpha=this.opacity,this.renderData[t].maskColor=this.maskColor,this.renderData[t].maskColorMix=this.maskColorMix,this.renderData[t].tintColor=this.tintColor,this.calculateRenderPosition(t,e,i),this.renderManager.addRenderData(this.renderData[t])},i.prototype.calculateRenderPosition=function(e,i,n){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.cachePosition,this.gameObject.transform.position,this.scaledOffset),this.cacheRenderPosition.set(this.renderData[e].width/2*(this.tiled.x-1),this.renderData[e].height/2*(this.tiled.y-1)),t.subtract(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.cacheRenderPosition.set(i*this.renderData[e].width,n*this.renderData[e].height),t.add(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.renderData[e].position=this.cachePosition,0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition(e)},i.prototype.translateRenderPosition=function(e){t.subtract(this.innerPosition,this.renderData[e].position,this.gameObject.transform.position);var i=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData[e].position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(i),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(i))},i}(It),oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=T.Text,e}return l(e,t),e}(D),ae=function(e){function i(i){var n,r,o,a,h,l,u,c,p,d,f,g,m,y,x,v=e.call(this)||this;if(v.fontFamily="Sans",v.fontUrl=null,v.fontSize=12,v.width=100,v.height=100,v.offset=new t,v.color="#000000",v.lineSeparation=0,v.letterSpacing=0,v.bitmapSize=64,v.charRanges=[32,126,161,255],v.smooth=!1,v.bitmapOffset=new t,v.rotation=new s,v.opacity=1,v.orientation="center",v.renderManager=jt.getSingleton("RenderManager"),v.renderData=new oe,v.lastFrameText="",v.type=Lt.TextRenderer,v.text=i.text,v.fontFamily=i.fontFamily,v.fontUrl=null!==(n=i.fontUrl)&&void 0!==n?n:v.fontUrl,v.fontSize=null!==(r=i.fontSize)&&void 0!==r?r:v.fontSize,v.width=null!==(o=i.width)&&void 0!==o?o:v.width,v.height=null!==(a=i.height)&&void 0!==a?a:v.height,v.offset=null!==(h=i.offset)&&void 0!==h?h:v.offset,v.color=null!==(l=i.color)&&void 0!==l?l:v.color,v.lineSeparation=null!==(u=i.lineSeparation)&&void 0!==u?u:v.lineSeparation,v.letterSpacing=null!==(c=i.letterSpacing)&&void 0!==c?c:v.letterSpacing,v.bitmapSize=null!==(p=i.bitmapSize)&&void 0!==p?p:v.bitmapSize,v.charRanges=null!==(d=i.charRanges)&&void 0!==d?d:v.charRanges,v.smooth=null!==(f=i.smooth)&&void 0!==f?f:v.smooth,v.bitmapOffset=null!==(g=i.bitmapOffset)&&void 0!==g?g:v.bitmapOffset,v.rotation=null!==(m=i.rotation)&&void 0!==m?m:v.rotation,v.opacity=null!==(y=i.opacity)&&void 0!==y?y:v.opacity,v.orientation=null!==(x=i.orientation)&&void 0!==x?x:v.orientation,v.charRanges.length%2!=0)throw new b("TextRenderer.charRanges must be a 2 column matrix");if(v.lineSeparation%2!=0)throw new b("TextRenderer.lineSeparation must be multiple of 2");return v}return l(i,e),i.prototype.start=function(){this.renderData.layer=this.gameObject.layer,this.renderData.ui=this.gameObject.ui,this.renderData.fontFamily=this.fontFamily,this.renderData.fontUrl=this.fontUrl,this.renderData.fontSize=this.fontSize,this.renderData.lineSeparation=this.lineSeparation,this.renderData.letterSpacing=this.letterSpacing,this.renderData.bitmapSize=this.bitmapSize,this.renderData.charRanges=this.charRanges,this.renderData.smooth=this.smooth,this.renderData.bitmapOffset=this.bitmapOffset,this.renderData.orientation=this.orientation,this.renderData.width=this.width,this.renderData.height=this.height},i.prototype.update=function(){this.text&&(this.renderData.text=this.text!==this.lastFrameText?this.crop():this.renderData.text,this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.opacity=this.opacity,t.add(this.renderData.position,this.gameObject.transform.position,this.offset),this.renderManager.addRenderData(this.renderData),this.lastFrameText=this.text)},i.prototype.crop=function(){var t;if(this.fontSize>this.height)return"";for(var e=[],i=0,n=0,r=this.text.split("\n");n<r.length;n++)for(var o=0,a=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<a.length;o++){var s=a[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(s)}return e.join("\n")},i}(It),se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=T.Mask,e}return l(e,t),e}(D),he=function(e){function i(i){var n,r,o,a,h=e.call(this)||this;return h.renderManager=jt.getSingleton("RenderManager"),h.offset=new t,h.rotation=new s,h.opacity=1,h.renderData=new se,h.innerPosition=new t,h.scaledOffset=new t,h.type=Lt.MaskRenderer,h.width=i.width,h.height=i.height,h.color=i.color,h.offset=null!==(n=i.offset)&&void 0!==n?n:h.offset,h.rotation=null!==(r=i.rotation)&&void 0!==r?r:h.rotation,h.opacity=null!==(o=i.opacity)&&void 0!==o?o:h.opacity,h.layer=null!==(a=i.layer)&&void 0!==a?a:h.layer,h}return l(i,e),i.prototype.update=function(){var t;this.renderData.ui=this.gameObject.ui,this.renderData.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.renderData.width=this.width*Math.abs(this.gameObject.transform.scale.x),this.renderData.height=this.height*Math.abs(this.gameObject.transform.scale.y),this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.alpha=this.opacity,this.calculateRenderPosition(),this.renderManager.addRenderData(this.renderData)},i.prototype.calculateRenderPosition=function(){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.renderData.position,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition()},i.prototype.translateRenderPosition=function(){t.subtract(this.innerPosition,this.renderData.position,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData.position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i}(It),le=function(){function e(e,i,n){this._position=new t,this._position.set(e.x,e.y),this._width=i,this._height=n}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e}(),ue=function(){this.position=new t,this.positionInViewport=new t},ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=T.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return l(e,t),e}(D),pe=function(e){function i(i){var n,r,o,a,s,h=e.call(this)||this;return h.renderOrder="center",h.smooth=!1,h.textureCorrection=null,h.tileScale=null!==(n=jt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==n?n:new t(1,1),h.tileWidth=0,h.tileHeight=0,h.orientation=new t(1,1),h.renderManager=jt.getSingleton("RenderManager"),h.tilemapProcessed=!1,h.renderData=new Map,h.cols=[],h.rows=[],h._width=0,h._height=0,h.tiles=[],h._realWidth=0,h._realHeight=0,h.cacheV2=new t,h.allowMultiple=!1,h.tileset=i.tileset,h.tileScale=null!==(r=i.tileScale)&&void 0!==r?r:h.tileScale,h.smooth=null!==(o=i.smooth)&&void 0!==o?o:h.smooth,h.renderOrder=null!==(a=i.renderOrder)&&void 0!==a?a:h.renderOrder,h.textureCorrection=null!==(s=i.textureCorrection)&&void 0!==s?s:h.textureCorrection,h}return l(i,e),i.prototype.start=function(){this.tileWidth=this.tileset.tileWidth*this.tileScale.x*Math.abs(this.gameObject.transform.scale.x),this.tileHeight=this.tileset.tileHeight*this.tileScale.y*Math.abs(this.gameObject.transform.scale.y),this.orientation.set(Math.sign(this.gameObject.transform.scale.x),Math.sign(this.gameObject.transform.scale.y)),this.processTilemap(),this.updatePosition()},i.prototype.update=function(){var t=this;this.renderData.forEach((function(e){return t.renderManager.addRenderData(e)}))},i.prototype.processLayer=function(t){var e=new ce;e.ui=!1,e.alpha=t.alpha,e.image=this.tileset.image,e.layer=this.gameObject.layer,e.smooth=this.smooth,e.tileWidth=this.tileWidth,e.tileHeight=this.tileHeight,e.textureCorrection=this.textureCorrection,e.tintColor=t.tintColor,this.renderData.set(t.layer,e)},i.prototype.processTile=function(t){null!==t.tile&&this.addTileToRenderData(t),this.updateSizeInfo(t.col,t.row)},i.prototype.addTileToRenderData=function(t){if(this.renderData.has(t.layer)){var e=new ue;e.tile=t.tile,e.position.set(this.gameObject.transform.position.x+t.col*this.tileWidth*this.orientation.x+t.offset.x*Math.abs(this.gameObject.transform.scale.x)+this.tileWidth*this.orientation.x/2,this.gameObject.transform.position.y-t.row*this.tileHeight*this.orientation.y-t.offset.y*Math.abs(this.gameObject.transform.scale.y)-this.tileHeight*this.orientation.y/2),e.flipHorizontal=t.flip.h!==this.orientation.x<0,e.flipVertical=t.flip.v!==this.orientation.y<0,this.renderData.get(t.layer).tilesData.push(e)}},i.prototype.updateSizeInfo=function(t,e){this._width=!1===this.cols.includes(t)?this.cols.push(t):this._width,this._height=!1===this.rows.includes(e)?this.rows.push(e):this._height,this._realWidth=this._width*this.tileWidth,this._realHeight=this._height*this.tileHeight},i.prototype.updatePosition=function(){var e=this;this.cacheV2.set(("center"===this.renderOrder?-Math.round(this._realWidth/2):["left-down","left-up"].includes(this.renderOrder)?-this._realWidth:0)*this.orientation.x,("center"===this.renderOrder?Math.round(this._realHeight/2):["right-up","left-up"].includes(this.renderOrder)?this._realHeight:0)*this.orientation.y),this.renderData.forEach((function(i){return i.tilesData.forEach((function(i){t.add(i.position,i.position,e.cacheV2),e.addTileData(i)}))}))},i.prototype.addTileData=function(t){this.tiles.push(new le(t.position,this.tileWidth,this.tileHeight))},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realWidth",{get:function(){return this._realWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realHeight",{get:function(){return this._realHeight},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tilesData",{get:function(){return this.tiles},enumerable:!1,configurable:!0}),i}(It),de=function(t){function e(e){var i,n,r=this;return e.renderOrder=null!==(i=e.renderOrder)&&void 0!==i?i:e.tilemapData.renderorder,(r=t.call(this,e)||this).type=Lt.TiledTilemapRenderer,r.tiledTilemap=e.tilemapData,r.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,r}return l(e,t),e.prototype.processTilemap=function(){var t=this;this.tiledTilemap.layers.forEach((function(e){var i,n,r;!0!==e.visible||null!==t.layerName&&t.layerName!==e.name||(t.renderData.has(e.name)||t.processLayer({layer:e.name,alpha:e.opacity,tintColor:null!==(i=e.tintcolor)&&void 0!==i?i:null}),!0===t.tiledTilemap.infinite?e.chunks.forEach((function(i){var n,r;return t.processChunk(e.name,i,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0})})):t.processChunk(e.name,e,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0}))})),this.tilemapProcessed=!0},e.prototype.processChunk=function(t,e,i){void 0===i&&(i={x:0,y:0});for(var n=0,r=0;r<e.height;r++)for(var o=0;o<e.width;o++){var a=this.tileset.getTile(e.data[n]-1);this.processTile({layer:t,tile:a,col:o+e.x,row:r+e.y,flip:{h:!1,v:!1},offset:i}),n++}},e}(pe),fe=1,ge=2,me=3,ye=function(t){function e(e){var i,n,r=t.call(this,e)||this;return r.alpha=1,r.tintColor=null,r.type=Lt.CsvTilemapRenderer,r.tilemapData=e.tilemapData,r.alpha=null!==(i=e.alpha)&&void 0!==i?i:r.alpha,r.tintColor=null!==(n=e.tintColor)&&void 0!==n?n:r.tintColor,r}return l(e,t),e.prototype.processTilemap=function(){var t=this;this.processLayer({layer:"csv",alpha:this.alpha,tintColor:this.tintColor}),this.tilemapData.trim().split("\n").forEach((function(e,i){e.split(",").forEach((function(e,n){var r=parseInt(e.trim()),o=null,a={h:!1,v:!1};if(!1===isNaN(r)){var s=r>999?r%1e3:r,h=Math.round(r/1e3);o=t.tileset.getTile(s),a.h=[fe,me].includes(h),a.v=[ge,me].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:a,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(pe),xe=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},be=function(){function e(e){var i,n;this.image=null,this.offset=new t(0,0),this.tileSpacing=new t(0,0),this._tiles=[],this.image=e.image,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.gridWidth=e.gridWidth,this.gridHeight=e.gridHeight,this.offset=null!==(i=e.offset)&&void 0!==i?i:this.offset,this.tileSpacing=null!==(n=e.spacing)&&void 0!==n?n:this.tileSpacing,this.generateTiles()}return e.prototype.generateTiles=function(){for(var t=0,e=0;e<this.gridHeight;e++)for(var i=0;i<this.gridWidth;i++)this._tiles[t]=new xe(i*this.tileWidth+i*this.tileSpacing.x+this.offset.x,e*this.tileHeight+e*this.tileSpacing.y+this.offset.y,this.tileWidth,this.tileHeight),t++},e.prototype.getTile=function(t){return this._tiles[t]?this._tiles[t]:null},Object.defineProperty(e.prototype,"tiles",{get:function(){return this._tiles},enumerable:!1,configurable:!0}),e}(),ve=function(t){var e,i;this.sprites=[],this.framerate=10,this.loop=!1,this.sprites=t.sprites,this.framerate=null!==(e=t.framerate)&&void 0!==e?e:this.framerate,this.loop=null!==(i=t.loop)&&void 0!==i?i:this.loop},_e=function(t){function e(e){var i=t.call(this)||this;return i.timeManager=jt.getSingleton("TimeManager"),i.spriteRenderer=null,i.animations=new Map,i.currentAnimation=null,i.type=Lt.Animator,i.spriteRenderer=e.spriteRenderer,i}return l(e,t),e.prototype.update=function(){null!==this.currentAnimation&&(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.stopAnimation():this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return i&&(e.framerate=i),this.animations.set(t,new we(e)),this},e.prototype.playAnimation=function(t){if(!1!==this.active){if(!1===this.animations.has(t))throw new b("Animation with name "+t+" does not exist.");this.currentAnimation=this.animations.get(t)}},e.prototype.stopAnimation=function(){!1!==this.active&&null!==this.currentAnimation&&(this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(At),we=function(){function t(t){this._sprite=null,this._restarted=!1,this.currentFrame=0,this.frameTime=0,this._animation=t}return Object.defineProperty(t.prototype,"sprite",{get:function(){return this._sprite},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"restarted",{get:function(){return this._restarted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this._animation.loop},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),t.prototype.playFrame=function(t){this._restarted=!1,this.frameTime>=1/this._animation.framerate&&(this.frameTime=0,this.currentFrame=this.currentFrame+1===this._animation.sprites.length?0:this.currentFrame+1,this._restarted=0===this.currentFrame),this._sprite=this._animation.sprites[this.currentFrame],this.frameTime+=t},t}(),Me=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Ce=function(t){function e(e){var i,n,r;void 0===e&&(e={audio:null,volume:1,loop:!1});var o=t.call(this)||this;return o.volume=1,o.loop=!1,o.audio=null,o.clones=new Map,o._playing=!1,o._paused=!1,o.audioEventHandler=function(t){"ended"===t.type&&(o._playing=!1,o.audio.removeEventListener("ended",o.audioEventHandler))},o.userinputEventHandler=function(){Me.forEach((function(t){window.removeEventListener(t,o.userinputEventHandler)})),o.audio.play()},o.allowMultiple=!1,o.type=Lt.AudioPlayer,o.audio=null!==(i=e.audio)&&void 0!==i?i:o.audio,o.volume=null!==(n=e.volume)&&void 0!==n?n:o.volume,o.loop=null!==(r=e.loop)&&void 0!==r?r:o.loop,o}return l(e,t),e.prototype.playAudio=function(t,e){void 0===e&&(e=null),!1===this.clones.has(Symbol.for(t.src))&&this.cloneAudio(t);var i=this.clones.get(Symbol.for(t.src));i.currentTime>0&&(i.currentTime=0),i.volume=null!=e?e:this.volume,i.play()},e.prototype.cloneAudio=function(t){var e=t.cloneNode();this.clones.set(Symbol.for(t.src),e)},e.prototype.play=function(){var t=this;if(null!==this.audio&&(!this._playing||!1!==this._paused)){if(this._paused)return this._paused=!1,void this.audio.play();this.audio.volume=this.volume,this.audio.loop=this.loop,this.audio.addEventListener("ended",this.audioEventHandler),this._playing=!0,this.audio.play().then((function(){})).catch((function(){return Me.forEach((function(e){return window.addEventListener(e,t.userinputEventHandler)}))}))}},e.prototype.stop=function(){this._playing&&(this.audio.pause(),this.audio.currentTime=0,this.audio.removeEventListener("ended",this.audioEventHandler),this._playing=!1,this._paused=!1)},e.prototype.pause=function(){this._playing&&!1===this._paused&&(this.audio.pause(),this._paused=!0)},e.prototype.setActive=function(e){!1===e&&this.stop(),t.prototype.setActive.call(this,e)},e.prototype.destroy=function(){this.stop(),t.prototype.destroy.call(this)},e}(At);!function(t){t[t.Static=0]="Static",t[t.Dynamic=1]="Dynamic"}(Rt||(Rt={}));var Oe=function(e){function i(i){var n,r,o=e.call(this)||this;return o.timeManager=jt.getSingleton("TimeManager"),o._colliderComponents=[],o._layersToCollide=[],o._velocity=new t,o._gravity=new t(0,10),o.deltaGravity=new t,o.deltaVelocity=new t,o.collisions=[],o.penetrationPerDirection={x:new Map,y:new Map},o.updatePosition=!1,o.penetrationResolution=new t,o.type=Lt.RigidBody,o.allowMultiple=!1,o._rigidBodyType=i.rigidBodyType,o._layersToCollide=null!==(n=i.layersToCollide)&&void 0!==n?n:o._layersToCollide,o._gravity.set(0,null!==(r=i.gravity)&&void 0!==r?r:o._gravity.y),o}return l(i,e),Object.defineProperty(i.prototype,"rigidBodyType",{get:function(){return this._rigidBodyType},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"velocity",{get:function(){return this._velocity},set:function(t){this._velocity.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gravity",{get:function(){return this._gravity.y},set:function(t){this._gravity.set(this._gravity.x,Math.abs(t))},enumerable:!1,configurable:!0}),i.prototype.start=function(){var t=this;if(this.gameObject.getComponents().forEach((function(e){return e instanceof Kt&&e.physics?t._colliderComponents.push(e):null})),0===this._colliderComponents.length)throw new b("RigidBody needs at least one Collider")},i.prototype.update=function(){this._rigidBodyType!==Rt.Static&&(this.applyGravity(),this.deltaVelocity.set(0,0),this.applyVelocity("x"),this.applyReposition("x"),this.deltaVelocity.set(0,0),this.applyVelocity("y"),this.applyReposition("y"))},i.prototype.applyGravity=function(){this._gravity.y<=0||(this._velocity=t.add(this._velocity,this._velocity,t.scale(this.deltaGravity,this._gravity,-this.timeManager.physicsDeltaTime)))},i.prototype.applyVelocity=function(e){this.deltaVelocity[e]=this._velocity[e]*this.timeManager.physicsDeltaTime,0===this.deltaVelocity.x&&0===this.deltaVelocity.y||t.add(this.gameObject.transform.position,this.gameObject.transform.position,this.deltaVelocity)},i.prototype.applyReposition=function(t){var e=this;0!==this._layersToCollide.length&&(this.updatePosition=!1,this.penetrationResolution.set(this.gameObject.transform.position.x,this.gameObject.transform.position.y),this.penetrationPerDirection[t].clear(),this.updateCollisions(),0!==this.collisions.length&&(this.collisions.forEach((function(i){!0===i.remoteCollider.physics&&null!==i.remoteCollider.gameObject.getComponentByType(Lt.RigidBody)&&0!==i.collisionData.displacementDirection[t]&&e.setPenetrationPerDirectionPerAxis(t,i)})),this.setPenetrationResolution(t),this.updatePosition&&(this.gameObject.transform.position=this.penetrationResolution)))},i.prototype.setPenetrationPerDirectionPerAxis=function(t,e){var i;this.penetrationPerDirection[t].set(e.collisionData.displacementDirection[t],Math.max(null!==(i=this.penetrationPerDirection[t].get(e.collisionData.displacementDirection[t]))&&void 0!==i?i:0,e.collisionData.penetration))},i.prototype.setPenetrationResolution=function(t){var e=this;this.penetrationPerDirection[t].forEach((function(i,n){e.penetrationResolution[t]+=n*i,0!==e._velocity[t]&&Math.sign(e._velocity[t])!==Math.sign(n)&&(e._velocity[t]=0),e.updatePosition=!0}))},i.prototype.updateCollisions=function(){var t=this;this.collisions=[],this._colliderComponents.forEach((function(e){return t._layersToCollide.forEach((function(i){return e.getCollisionsWithLayer(i).forEach((function(e){return t.collisions.push(e)}))}))}))},i}(Bt),je=function(){function e(e){var i,n,r,o,a=this;this._image=null,this._slice=null,this._scale=null!==(i=jt.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),this._smooth=!1,this._width=null,this._height=null,this._loaded=!1,this._image=e.image,this._slice=null!==(n=e.slice)&&void 0!==n?n:this._slice,null!==this._slice&&(this._width=this._slice.width,this._height=this._slice.height),this._scale=null!==(r=e.scale)&&void 0!==r?r:this._scale,this._smooth=null!==(o=e.smooth)&&void 0!==o?o:this._smooth,this._image.naturalWidth?this.onLoad():this._image.addEventListener("load",(function(){return a.onLoad()}))}return Object.defineProperty(e.prototype,"loaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"slice",{get:function(){return this._slice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"smooth",{get:function(){return this._smooth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.onLoad=function(){var t,e;this._width=(null!==(t=this._width)&&void 0!==t?t:this._image.naturalWidth)*this._scale.x,this._height=(null!==(e=this._height)&&void 0!==e?e:this._image.naturalHeight)*this._scale.y,this._loaded=!0},e}(),Re=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return l(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){gt.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,gt.mouse.positionInViewport,1/this.camera.zoom),t.add(this.position,this.position,this.camera.worldSpaceRect.center),t.round(this.position,this.position),console.log("Space position: {x: "+this.position.x+", y: "+this.position.y+"}")),this.mousePressed=gt.mouse.leftButtonPressed},i}(Ht);export{ve as Animation,_e as Animator,dt as AssetManager,Ce as AudioPlayer,Jt as BoxCollider,Nt as Camera,rt as CollisionData,Q as CollisionMethodConfig,Dt as Component,Lt as ComponentTypes,Y as Context2DConfig,ye as CsvTilemapRenderer,ft as DomManager,Yt as GAME_CAMERA_ID,Tt as Game,qt as GameCamera,Ht as GameObject,xt as GameObjectManager,C as GamepadController,O as GamepadData,gt as InputManager,R as KeyboardController,Ut as LAYER_DEFAULT,he as MaskRenderer,P as MouseController,Bt as PhysicsComponent,Ft as PreRenderComponent,e as Rectangle,Oe as RigidBody,Rt as RigidBodyType,s as Rotation,Qt as Scene,mt as SceneManager,Re as SpacePointer,je as Sprite,re as SpriteRenderer,ae as TextRenderer,de as TiledTilemapRenderer,ee as TilemapCollider,be as Tileset,yt as TimeManager,at as TouchController,kt as Transform,t as Vector2,a as between,i as clamp,r as fixedRound,n as random,o as range};
|
|
1
|
+
var t=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"magnitude",{get:function(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){this._x=t,this._y=e},t.prototype.copy=function(t){this.set(t.x,t.y)},t.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},t.prototype.clone=function(){return new t(this._x,this._y)},t.prototype.distance=function(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))},t.add=function(t,e,i){return t.set(e.x+i.x,e.y+i.y),t},t.subtract=function(t,e,i){return t.set(e.x-i.x,e.y-i.y),t},t.unit=function(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t},t.normal=function(t,e){return t.set(-e.y,e.x),this.unit(t,t)},t.scale=function(t,e,i){return t.set(e.x*i,e.y*i),t},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.round=function(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t},t}(),e=function(){function e(e,i,n,r){this._position=new t,this._center=new t,this._width=0,this._height=0,this.set(e,i,n,r)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._position.x},set:function(t){this._position.set(t,this._position.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._position.y},set:function(t){this._position.set(this._position.x,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._position.x+this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._position.y+this._height},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"center",{get:function(){return this._center.set(this.x+this.width/2,this.y+this.height/2),this._center},enumerable:!1,configurable:!0}),e.prototype.set=function(t,e,i,n){this._position.set(t,e),this._width=i,this._height=n},e.prototype.equals=function(t){return this.position.equals(t.position)&&this.width===t.width&&this.height===t.height},e.prototype.updateFromRect=function(t){this.set(t.x,t.y,t.width,t.height)},e.prototype.overlappingRectangle=function(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1},e}(),i=function(t,e,i){return Math.min(i,Math.max(e,t))},n=function(t,e){return Math.floor(Math.random()*(e-t))+t},r=function(t,e){return Math.round(t*(10^e))/(10^e)},o=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},a=function(t,e,i){return t>=e&&t<=i},s=function(){function e(e,i){void 0===e&&(e=null),void 0===i&&(i=null),this._degrees=0,this._radians=0,this._direction=new t,e?this.radians=e:i&&(this.degrees=i)}return Object.defineProperty(e.prototype,"degrees",{get:function(){return this._degrees},set:function(t){this._degrees=t,this._radians=t*Math.PI/180,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radians",{get:function(){return this._radians},set:function(t){this._radians=t,this._degrees=180*t/Math.PI,this.updateDirection()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),e.prototype.updateDirection=function(){this._direction.set(Math.cos(this._radians),Math.sin(this._radians))},e}(),h=function(t,e){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},h(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var u,c=function(){return c=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},c.apply(this,arguments)};function p(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}h((n=n.apply(t,e||[])).next())}))}function d(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}!function(t){t.Image="Image",t.Audio="Audio",t.Video="Video"}(u||(u={}));var g,m=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},y=function(){function t(){this.assets=[]}return t.prototype.getAssetsLoaded=function(){return this.assets.reduce((function(t,e){return t&&e.loaded}),!0)},t.prototype.laadImage=function(t){var e=this.createAsset(t,u.Image);return e.element=new Image,e.element.src=t,e.element.naturalWidth?e.loaded=!0:e.element.addEventListener("load",(function(){return e.loaded=!0})),e.element},t.prototype.loadAudio=function(t){var e=this.createAsset(t,u.Audio);return e.element=new Audio,e.element.src=t,e.element.duration?e.loaded=!0:e.element.addEventListener("canplaythrough",(function(){return e.loaded=!0})),e.element},t.prototype.getImage=function(t){return this.getAsset(t,u.Image)},t.prototype.getVideo=function(t){return this.getAsset(t,u.Video)},t.prototype.getAudio=function(t){return this.getAsset(t,u.Audio)},t.prototype.getAsset=function(t,e){return void 0===e&&(e=null),this.assets.reduce((function(i,n){return n.url!==t||null!==e&&e!==n.type?i:n}),null).element},t.prototype.createAsset=function(t,e){var i=new m;return i.type=e,i.url=t,this.assets.push(i),i},t}(),b=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return l(e,t),e}(Error),x=function(){function i(i,n,r,o){void 0===r&&(r=6),void 0===o&&(o=15),this._bounds=new e(0,0,0,0),this._items=[],this._quadrants=[],this.sw=0,this.se=1,this.nw=2,this.ne=3,this.center=new t,this.childrenWidth=0,this.childrenHeight=0,this.quadsForItem=[],this.level=i,this._bounds.updateFromRect(n),this.maxLevels=r,this.maxItems=o,this.updateCache()}return Object.defineProperty(i.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),i.prototype.updateBounds=function(t){this._bounds.updateFromRect(t),this.updateCache()},i.prototype.clearItems=function(){this._items=[],this._quadrants.forEach((function(t){return t.clearItems()}))},i.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},i.prototype.addItem=function(t){this._quadrants.length>0?this.insertItemIntoChildrenQuads(t):(this._items.push(t),this._items.length>this.maxItems&&this.level<this.maxLevels&&this.splitQuad())},i.prototype.retrieve=function(t){var e=[];this._quadrants.length>0&&this.getChildrenQuadrantForItem(t).forEach((function(i){return e.push.apply(e,i.retrieve(t))})),e.push.apply(e,this._items);var i=e.indexOf(t);return-1!==i&&e.splice(i,1),e},i.prototype.splitQuad=function(){var t=this;this._quadrants=[new e(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new e(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new e(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(e){return new i(t.level+1,e,t.maxLevels,t.maxItems)}));for(var n=0,r=this._items;n<r.length;n++){var o=r[n];this.insertItemIntoChildrenQuads(o)}this._items=[]},i.prototype.getChildrenQuadrantForItem=function(t){if(0===this._quadrants.length)throw new b("Current quadrant does not have quadrant children.");if(this.quadsForItem=[],t.x<=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.sw]),t.x1>=this.center.x&&t.y<=this.center.y&&this.quadsForItem.push(this._quadrants[this.se]),t.x<=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.nw]),t.x1>=this.center.x&&t.y1>=this.center.y&&this.quadsForItem.push(this._quadrants[this.ne]),0===this.quadsForItem.length)throw new b("Item does not fit in any children quadrant");return this.quadsForItem},i.prototype.insertItemIntoChildrenQuads=function(t){this.getChildrenQuadrantForItem(t).forEach((function(e){return e.addItem(t)}))},i.prototype.updateCache=function(){this.center.set(this._bounds.width/2+this._bounds.x,this._bounds.height/2+this._bounds.y),this.childrenWidth=this._bounds.width/2,this.childrenHeight=this._bounds.height/2},i}(),v=function(){function i(i,n,r,o){void 0===n&&(n=null),this.collisions=[],this.minBounds=new t,this.maxBounds=new t,this.newBounds=new e(0,0,0,0),this.fixedQuadTree=null!==n,this.resolver=i,this.colliders=[],this.fixedQuadTree?this.bounds=n:this.bounds=new e(0,0,0,0),this.quadTree=new x(0,this.bounds,r,o)}return i.prototype.addCollider=function(t){this.colliders.push(t)},i.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},i.prototype.getFrameCollisionsForCollider=function(t){return this.collisions.filter((function(e){return e.localCollider===t}))},i.prototype.refreshCollisionsForCollider=function(t){var e;if(-1===this.colliders.indexOf(t))return[];var i=this.narrowPhase(t,this.broadPhase(t));return this.collisions=this.collisions.filter((function(e){return e.localCollider!==t})),(e=this.collisions).push.apply(e,i),i},i.prototype.clear=function(){this.colliders=[]},i.prototype.update=function(){if(this.collisions=[],0!==this.colliders.length){this.quadTree.clearItems(),this.quadTree.clearQuadrants(),!1===this.fixedQuadTree&&(this.updateNewBounds(),!1===this.newBounds.equals(this.bounds)&&(this.bounds.updateFromRect(this.newBounds),this.quadTree.updateBounds(this.bounds)));for(var t=0,e=this.colliders;t<e.length;t++){var i=e[t];this.quadTree.addItem(i)}this.updateCollisions()}},i.prototype.updateNewBounds=function(){var t=this;this.colliders.forEach((function(e){t.minBounds.set(Math.min(e.x,t.minBounds.x),Math.min(e.y,t.minBounds.y)),t.maxBounds.set(Math.max(e.x1,t.maxBounds.x),Math.max(e.y1,t.maxBounds.y))})),this.newBounds.set(this.minBounds.x,this.minBounds.y,this.maxBounds.x-this.minBounds.x,this.maxBounds.y-this.minBounds.y)},i.prototype.updateCollisions=function(){var t=this;this.colliders.filter((function(t){return t.updateCollisions})).forEach((function(e){var i;return(i=t.collisions).push.apply(i,t.narrowPhase(e,t.broadPhase(e)))}))},i.prototype.broadPhase=function(t){return this.quadTree.retrieve(t)},i.prototype.narrowPhase=function(t,e){var i=this,n=[];return e.filter((function(e){return e.id!==t.id})).forEach((function(e){var r=i.resolver.getCollisionResolution(t.shape,e.shape);null!==r&&n.push({localCollider:t,remoteCollider:e,resolution:r})})),n},i}(),M=function(){function t(t,e,i){if(this._canvas=null,!t)throw new b("containerNode cannot be empty or null.");this.containerNode=t,this.gameWidth=e,this.gameHeight=i,this.setupCanvas()}return Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),t.prototype.setupCanvas=function(){this._canvas=document.createElement("canvas"),this._canvas.id="angryPixelGameCanvas",this._canvas.width=Math.floor(this.gameWidth),this._canvas.height=Math.floor(this.gameHeight),this.canvas.tabIndex=0,this._canvas.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.containerNode.appendChild(this._canvas),this.canvas.focus()},t}();!function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Update=2]="Update",t[t.UpdateEngine=3]="UpdateEngine",t[t.UpdateCollider=4]="UpdateCollider",t[t.UpdatePhysics=5]="UpdatePhysics",t[t.UpdateTransform=6]="UpdateTransform",t[t.UpdatePreRender=7]="UpdatePreRender",t[t.UpdateCamera=8]="UpdateCamera",t[t.UpdateRender=9]="UpdateRender",t[t.Destroy=10]="Destroy"}(g||(g={}));var _,w=function(){function t(t,e,i,n,r,o,a){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.renderManager=n,this.inputManager=r,this.gameObjectManager=o,this.sceneManager=a,this.gameLoopAccumulator=0,this.physicsLoopAccumulator=0,this.gameObjects=[],this.components=[]}return t.prototype.update=function(t){if(this.timeManager.update(t),this.gameLoopAccumulator+=this.timeManager.browserDeltaTime,this.load(),this.gameLoopAccumulator>=this.timeManager.minGameDeltatime&&(this.mainIteration(),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(),this.gameLoopAccumulator-=this.timeManager.minGameDeltatime),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate)for(this.physicsLoopAccumulator+=this.timeManager.browserDeltaTime;this.physicsLoopAccumulator>=this.timeManager.minPhysicsDeltaTime;)this.physicsLoopAccumulator-=this.timeManager.minPhysicsDeltaTime,this.timeManager.timeScale>0&&this.physicsIteration();this.preRenderIteration(),this.renderIteration(),this.sceneManager.update()},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.getGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return f(f([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.mainIteration=function(){this.dispatchFrameEvent(g.Start),this.inputManager.update(),this.dispatchFrameEvent(g.Update),this.dispatchFrameEvent(g.UpdateEngine),this.dispatchFrameEvent(g.UpdateTransform)},t.prototype.physicsIteration=function(){this.dispatchFrameEvent(g.UpdatePhysics),this.dispatchFrameEvent(g.UpdateCollider),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear()},t.prototype.preRenderIteration=function(){this.physicsManager.clear(),this.dispatchFrameEvent(g.UpdateTransform),this.dispatchFrameEvent(g.UpdatePreRender),this.dispatchFrameEvent(g.UpdateCamera)},t.prototype.renderIteration=function(){this.dispatchFrameEvent(g.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.dispatchFrameEvent=function(t){t!==g.Start&&t!==g.Update||(this.currentScene.dispatch(t),this.gameObjects.forEach((function(e){return e.dispatch(t)}))),this.components.forEach((function(e){return e.dispatch(t)}))},t}(),O=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i){void 0===i&&(i=null);var n=this.findGameObjectByName(e);if(n&&!1===n.keep)throw new b("There is already a GameObject with the name "+e);if(n&&n.keep)return n;var r=t();return this.gameObjects.push(r),r.name=e,r.parent=i,r.dispatch(g.Init),r},t.prototype.getGameObjects=function(){return this.gameObjects},t.prototype.findGameObjectById=function(t){return this.gameObjects.reduce((function(e,i){return i.id===t?i:e}),null)},t.prototype.findGameObjectByName=function(t){return this.gameObjects.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParentAndName=function(t,e){return this.gameObjects.reduce((function(i,n){return n.name===e&&n.parent===t?n:i}),null)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},t.prototype.findGameObjectByTag=function(t){var e;return null!==(e=this.findGameObjectsByTag(t)[0])&&void 0!==e?e:null},t.prototype.destroyAllGameObjects=function(){var t=this;this.gameObjects.filter((function(t){return!t.keep})).forEach((function(e){return t.destroy(e,!1)}))},t.prototype.destroyGameObject=function(t){this.destroy(t,!0)},t.prototype.destroy=function(t,e){var i=this.gameObjects.indexOf(t);if(-1!==i){var n=this.gameObjects.splice(i,1)[0];e&&this.destroyChildren(n),n.dispatch(g.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){e.destroyChildren(t),e.destroyGameObject(t)}))},t}(),j=function(){function t(){var t=this;this.gamepads=new Map,this.eventHandler=function(e){"gamepadconnected"===e.type?t.gamepadConnected(e.gamepad):"gamepaddisconnected"===e.type&&t.gamepadDisconected(e.gamepad)},window.addEventListener("gamepadconnected",this.eventHandler),window.addEventListener("gamepaddisconnected",this.eventHandler)}return t.prototype.getGamepad=function(t){var e;return null!==(e=this.gamepads.get(t))&&void 0!==e?e:null},t.prototype.gamepadConnected=function(t){this.gamepads.set(t.index,new C),this.gamepads.get(t.index).updateFromGamepad(t)},t.prototype.gamepadDisconected=function(t){this.gamepads.delete(t.index)},t.prototype.update=function(){for(var t=0,e=this.getGamepads();t<e.length;t++){var i=e[t];null!==i&&(!1===this.gamepads.has(i.index)&&this.gamepadConnected(i),this.gamepads.get(i.index).updateFromGamepad(i))}},t.prototype.getGamepads=function(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads:[]},t}(),C=function(){function e(){this._connected=!1,this._id=null,this.buttons=new Map,this.axes=new Map,this._dpadAxes=new t,this._leftStickAxes=new t,this._rightStickAxes=new t}return e.prototype.updateFromGamepad=function(t){var e=this;this._id=t.id,this._connected=t.connected,t.buttons.forEach((function(t,i){return e.buttons.set(i,t.pressed)})),t.axes.forEach((function(t,i){return e.axes.set(i,t)}))},Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),e.prototype.getButtonPressed=function(t){return this.buttons.get(t)},e.prototype.getAxis=function(t){return this.axes.get(t)},Object.defineProperty(e.prototype,"dpadAxes",{get:function(){return this._dpadAxes.set(this.dpadRight?1:this.dpadLeft?-1:0,this.dpadUp?1:this.dpadDown?-1:0),this._dpadAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickAxes",{get:function(){return this._leftStickAxes.set(this.leftStickHorizontal,this.leftStickVertical),this._leftStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickAxes",{get:function(){return this._rightStickAxes.set(this.rightStickHorizontal,this.rightStickVertical),this._rightStickAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._connected},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadUp",{get:function(){var t;return null!==(t=this.buttons.get(12))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadDown",{get:function(){var t;return null!==(t=this.buttons.get(13))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadLeft",{get:function(){var t;return null!==(t=this.buttons.get(14))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpadRight",{get:function(){var t;return null!==(t=this.buttons.get(15))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomFace",{get:function(){var t;return null!==(t=this.buttons.get(0))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightFace",{get:function(){var t;return null!==(t=this.buttons.get(1))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftFace",{get:function(){var t;return null!==(t=this.buttons.get(2))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topFace",{get:function(){var t;return null!==(t=this.buttons.get(3))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftShoulder",{get:function(){var t;return null!==(t=this.buttons.get(4))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightShoulder",{get:function(){var t;return null!==(t=this.buttons.get(5))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftTrigger",{get:function(){var t;return null!==(t=this.buttons.get(6))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightTrigger",{get:function(){var t;return null!==(t=this.buttons.get(7))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"back",{get:function(){var t;return null!==(t=this.buttons.get(8))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){var t;return null!==(t=this.buttons.get(9))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickButton",{get:function(){var t;return null!==(t=this.buttons.get(10))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickButton",{get:function(){var t;return null!==(t=this.buttons.get(11))&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(0))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(1))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickHorizontal",{get:function(){var t;return null!==(t=this.axes.get(2))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightStickVertical",{get:function(){var t;return null!==(t=-this.axes.get(3))&&void 0!==t?t:0},enumerable:!1,configurable:!0}),e}(),P=function(){function t(t,e,i,n){this.mouse=t,this.keyboard=e,this.gamepad=i,this.touch=n}return t.prototype.update=function(){this.mouse.update(),this.gamepad.update()},t}(),R=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),S=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}();!function(t){t[t.Image=0]="Image",t[t.Text=1]="Text",t[t.Collider=2]="Collider",t[t.Tilemap=3]="Tilemap",t[t.Mask=4]="Mask"}(_||(_={}));var T=function(){function e(){this.ui=!1,this.debug=!1,this.layer=null,this._position=new t(0,0),this._positionInViewport=new t(0,0)}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},set:function(t){this._positionInViewport.set(t.x,t.y)},enumerable:!1,configurable:!0}),e}(),D=function(){function t(t,e,i,n){void 0===n&&(n=!1),this.debug=!1,this.renderData=[],this.cameraData=[],this.renderer=t,this.cullingService=e,this.canvasColor=i,this.debug=n}return t.prototype.clearCanvas=function(){this.renderer.clearCanvas(this.canvasColor)},t.prototype.addRenderData=function(t){!1===this.debug&&t.debug||this.renderData.push(t)},t.prototype.addCameraData=function(t){this.cameraData.push(t)},t.prototype.render=function(){var t=this;this.cameraData.sort((function(t,e){return t.depth-e.depth})).forEach((function(e){return t.renderByCamera(e)})),this.clearData()},t.prototype.clearData=function(){this.renderData=[],this.cameraData=[]},t.prototype.renderByCamera=function(t){var e=this;this.orderRendeData(t),this.cullingService.applyCulling(t,this.renderData).forEach((function(i){e.updateFromCameraViewport(t,i),e.renderer.render(t,i)}))},t.prototype.orderRendeData=function(t){this.renderData.sort((function(e,i){return t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer)}))},t.prototype.updateFromCameraViewport=function(t,e){var i=this;!0!==e.ui?e.type===_.Tilemap?e.tilesToRender.forEach((function(e){return i.setPositionInViewport(t,e)})):this.setPositionInViewport(t,e):e.positionInViewport=e.position},t.prototype.setPositionInViewport=function(t,e){e.positionInViewport.set(Math.round(e.position.x-t.worldSpaceRect.x-t.worldSpaceRect.width/2),Math.round(e.position.y-t.worldSpaceRect.y-t.worldSpaceRect.height/2))},t}(),A="undefined"!=typeof Float32Array?Float32Array:Array;function B(){var t=new A(16);return A!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function F(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function E(t,e,i){var n,r,o,a,s,h,l,u,c,p,d,f,g=i[0],m=i[1],y=i[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*y+e[12],t[13]=e[1]*g+e[5]*m+e[9]*y+e[13],t[14]=e[2]*g+e[6]*m+e[10]*y+e[14],t[15]=e[3]*g+e[7]*m+e[11]*y+e[15]):(n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=e[5],l=e[6],u=e[7],c=e[8],p=e[9],d=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=s,t[5]=h,t[6]=l,t[7]=u,t[8]=c,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+s*m+c*y+e[12],t[13]=r*g+h*m+p*y+e[13],t[14]=o*g+l*m+d*y+e[14],t[15]=a*g+u*m+f*y+e[15]),t}function I(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function G(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],a=e[1],s=e[2],h=e[3],l=e[4],u=e[5],c=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+l*n,t[1]=a*r+u*n,t[2]=s*r+c*n,t[3]=h*r+p*n,t[4]=l*r-o*n,t[5]=u*r-a*n,t[6]=c*r-s*n,t[7]=p*r-h*n,t}function U(t,e,i,n,r,o,a){var s=1/(e-i),h=1/(n-r),l=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+i)*s,t[13]=(r+n)*h,t[14]=(a+o)*l,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var V,L=function(t){var e=/^#?([a-f\d]{2})?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[2],16)/256,g:parseInt(e[3],16)/256,b:parseInt(e[4],16)/256,a:void 0!==e[1]?parseInt(e[1],16)/256:1}:null},k=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=B(),this.modelMatrix=B(),this.textureMatrix=B(),this.posVertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.texVertices=new Float32Array([0,1,0,0,1,1,1,1,0,0,1,0])}return t.prototype.render=function(t,e,i,n){var r;if("image"!==n&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.posVertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.STATIC_DRAW)),this.modelMatrix=F(this.modelMatrix),E(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),G(this.modelMatrix,this.modelMatrix,i.rotation),I(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=F(this.textureMatrix),i.slice&&(E(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),I(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=F(this.projectionMatrix),U(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"image"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var o=L(i.tintColor),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.tintColorUniform,a,s,h,l)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,i.maskColor?1:0),i.maskColor){var u=L(i.maskColor);a=u.r,s=u.g,h=u.b;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,i.alpha),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(r=i.maskColorMix)&&void 0!==r?r:0)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),N=function(){function t(t){this.shaderLoader=t}return t.prototype.create=function(t,e,i){var n=t.createProgram(),r=this.shaderLoader.load(t,t.VERTEX_SHADER,e),o=this.shaderLoader.load(t,t.FRAGMENT_SHADER,i);return this.link(t,n,r,o),n},t.prototype.link=function(t,e,i,n){t.attachShader(e,i),t.attachShader(e,n),t.linkProgram(e);var r=t.LINK_STATUS;if(!t.getProgramParameter(e,r)){var o=t.getProgramInfoLog(e);throw t.deleteProgram(e),new b("Unable to initialize the Program: "+o)}},t}(),z=function(){function t(){}return t.prototype.load=function(t,e,i){var n=t.createShader(e);t.shaderSource(n,i),t.compileShader(n);var r=t.COMPILE_STATUS;if(!t.getShaderParameter(n,r)){var o=t.getShaderInfoLog(n);throw t.deleteShader(n),new b("Unable to initialize the shader program: "+o)}return n},t}(),W=function(){function t(t,e){this.gl=e.getContext(t)}return t.prototype.createFromImage=function(t,e,i){var n=this;return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),t.naturalWidth?this.create(t,i,e):t.addEventListener("load",(function(){return n.create(t,i,e)})),i},t.prototype.createFromCanvas=function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=null),i=null!=i?i:this.gl.createTexture(),this.create(t,i,e),i},t.prototype.create=function(t,e,i){void 0===i&&(i=!0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),!1===i?(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST)):(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR)),this.gl.bindTexture(this.gl.TEXTURE_2D,null)},t}();!function(t){t.LegacyWebGL="webgl",t.WebGL2="webgl2"}(V||(V={}));var H,q=function(){function t(t,e,i,n,r,o,a,s,h,l){this.canvas=e,this.gl=this.canvas.getContext(t),i.loadProgram(),this.textureManager=n,this.imageRenderer=o,this.tilemapRenderer=a,this.textRenderer=s,this.geometricRenderer=h,this.maskRenderer=l,this.fontAtlasFactory=r}return t.prototype.clearCanvas=function(t){var e=L(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)},t.prototype.render=function(t,e){e.type===_.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===_.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===_.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===_.Collider&&(this.geometricRenderer.renderCollider(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===_.Mask&&(this.renderMask(t,e),this.lastRender="mask")},t.prototype.renderImage=function(t,e){this.imageRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderTilemap=function(t,e){this.tilemapRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderText=function(t,e){this.fontAtlasFactory.loadingFontAtlas(e.fontFamily)||(this.fontAtlasFactory.hasFontAtlas(e.fontFamily)?this.fontAtlasLoaded(this.fontAtlasFactory.getFontAtlas(e.fontFamily),t,e):this.fontAtlasFactory.asyncCreate(e.charRanges,e.fontFamily,e.fontUrl,e.bitmapSize))},t.prototype.renderMask=function(t,e){this.maskRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,e,this.lastRender)},t.prototype.fontAtlasLoaded=function(t,e,i){this.textRenderer.render(!0===i.ui?e.originalViewportRect:e.viewportRect,this.textureManager.getOrCreateTextureFromCanvas(i.fontFamily,t.canvas,i.smooth),t,i,this.lastRender)},t}(),Y=function(){function t(t,e){this.game=null,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.sceneToLoad=null,this.game=t,this.renderManager=e}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i){if(void 0===i&&(i=!1),this.scenes.has(t))throw new b("There is already a scene with the name '"+t+"'");this.scenes.set(t,e),!0!==i&&null!==this.openingSceneName||(this.openingSceneName=t)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new b("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new b("Game not initialized.");if(!1===this.scenes.has(t))throw new b("Scene with name "+t+" does not exists");this.sceneToLoad=t},t.prototype.update=function(){null!==this.sceneToLoad&&(this._loadScene(this.sceneToLoad),this.sceneToLoad=null)},t.prototype._loadScene=function(t){this.unloadCurrentScene(),this.currentScene=this.scenes.get(t)(),this.currentScene.name=t,this.currentScene.game=this.game,this.currentScene.dispatch(g.Init)},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(g.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager.clearData())},t}(),X=function(){function t(t){if(this.minGameDeltatime=0,this.minPhysicsDeltaTime=0,this.gameFramerate=60,this.physicsFramerate=240,this.timeScale=1,this.browserDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.max=1/15,this.then=0,t<60)throw new b("Physics framerate cannot be less than 60");if(t%60!=0)throw new b("Physics framerate must be multiple of 60");this.physicsFramerate=t,this.minGameDeltatime=parseFloat((1/this.gameFramerate).toFixed(6)),this.minPhysicsDeltaTime=parseFloat((1/this.physicsFramerate).toFixed(6))}return t.prototype.update=function(t){var e=.001*t;this.browserDeltaTime=Math.min(Math.max(0,e-this.then),this.max),this.unscaledGameDeltaTime=Math.max(this.minGameDeltatime,this.browserDeltaTime),this.unscaledPhysicsDeltaTime=this.gameFramerate===this.physicsFramerate?this.unscaledGameDeltaTime:this.minPhysicsDeltaTime,this.then=e},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}(),Q=function(){function t(t){this.textures=new Map,this.textureFactory=t}return t.prototype.getTexture=function(t){var e;return null!==(e=this.textures.get(Symbol.for(t)))&&void 0!==e?e:null},t.prototype.getOrCreateTextureFromImage=function(t,e){var i;return void 0===e&&(e=!0),null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)},t.prototype.createTextureFromImage=function(t,e){void 0===e&&(e=!0);var i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i},t.prototype.getOrCreateTextureFromCanvas=function(t,e,i){var n;return void 0===i&&(i=!0),null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)},t.prototype.createTextureFromCanvas=function(t,e,i){void 0===i&&(i=!0);var n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n},t}(),K=function(){function t(t,e,i){this.gl=i.getContext(e),this.programFactory=t,this.contextVersion=e}return t.prototype.loadProgram=function(){this.program=this.contextVersion===V.WebGL2?this.programFactory.create(this.gl,"#version 300 es\nprecision mediump float;\n\nin vec2 positionCoords;\nin vec2 textureCoords;\n\nout vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","#version 300 es\nprecision mediump float;\n\nout vec4 fragColor;\n\nin vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n fragColor = vec4(texColor.rgb, u_alpha * texColor.a); \n } else {\n fragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"):this.programFactory.create(this.gl,"precision mediump float;\n\nattribute vec2 positionCoords;\nattribute vec2 textureCoords;\n\nvarying vec2 texCoords;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 textureMatrix;\n\nvoid main()\n{\n gl_Position = projectionMatrix * modelMatrix * vec4(positionCoords, 0, 1);\n texCoords = (textureMatrix * vec4(textureCoords, 0, 1)).xy;\n}","precision mediump float;\n\nvarying vec2 texCoords;\n\nuniform int u_renderTexture;\nuniform sampler2D u_texImage;\nuniform vec4 u_solidColor;\n\nuniform int u_useTintColor;\nuniform vec4 u_tintColor;\n\nuniform int u_useMaskColor;\nuniform vec4 u_maskColor;\nuniform float u_maskColorMix;\n\nuniform float u_alpha;\n\nvoid main()\n{\n if (u_renderTexture == 1) {\n vec4 texColor = texture2D(u_texImage, texCoords);\n\n if (texColor.a < 0.0001) {\n discard;\n }\n\n if (u_useTintColor == 1) {\n texColor = u_tintColor * texColor;\n }\n\n if (u_useMaskColor == 1) {\n texColor = mix(texColor, u_maskColor, clamp(u_maskColorMix, 0.0, 1.0));\n }\n\n gl_FragColor = vec4(texColor.rgb, u_alpha * texColor.a);\n } else {\n gl_FragColor = vec4(u_solidColor.rgb, u_alpha);\n }\n}"),this.positionBuffer=this.gl.createBuffer(),this.textureBuffer=this.gl.createBuffer(),this.positionCoordsAttr=this.gl.getAttribLocation(this.program,"positionCoords"),this.texCoordsAttr=this.gl.getAttribLocation(this.program,"textureCoords"),this.modelMatrixUniform=this.gl.getUniformLocation(this.program,"modelMatrix"),this.projectionMatrixUniform=this.gl.getUniformLocation(this.program,"projectionMatrix"),this.textureMatrixUniform=this.gl.getUniformLocation(this.program,"textureMatrix"),this.renderTextureUniform=this.gl.getUniformLocation(this.program,"u_renderTexture"),this.textureUniform=this.gl.getUniformLocation(this.program,"u_texImage"),this.solidColorUniform=this.gl.getUniformLocation(this.program,"u_solidColor"),this.useTintColorUniform=this.gl.getUniformLocation(this.program,"u_useTintColor"),this.tintColorUniform=this.gl.getUniformLocation(this.program,"u_tintColor"),this.useMaskColorUniform=this.gl.getUniformLocation(this.program,"u_useMaskColor"),this.maskColorUniform=this.gl.getUniformLocation(this.program,"u_maskColor"),this.maskColorMixUniform=this.gl.getUniformLocation(this.program,"u_maskColorMix"),this.alphaUniform=this.gl.getUniformLocation(this.program,"u_alpha"),this.gl.useProgram(this.program),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enableVertexAttribArray(this.positionCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(this.positionCoordsAttr,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.texCoordsAttr),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureBuffer),this.gl.vertexAttribPointer(this.texCoordsAttr,2,this.gl.FLOAT,!1,0,0)},t}(),$=function(){function t(){this.bitmapSize=64,this.fontAtlas=new Map,this.loading=new Map}return t.prototype.hasFontAtlas=function(t){return this.fontAtlas.has(Symbol.for(t))},t.prototype.loadingFontAtlas=function(t){var e;return null!==(e=this.loading.get(Symbol.for(t)))&&void 0!==e&&e},t.prototype.getFontAtlas=function(t){return this.fontAtlas.get(Symbol.for(t))},t.prototype.asyncCreate=function(t,e,i,n){var r=this;void 0===i&&(i=null),void 0===n&&(n=null),this.bitmapSize=null!=n?n:this.bitmapSize;var o=new J(e);this.chars=[];for(var a=0;a<t.length;a+=2)for(var s=t[a];s<=t[a+1];s++)this.chars.push(String.fromCharCode(s));o.canvas.width=Math.round(Math.sqrt(this.chars.length))*this.bitmapSize,o.canvas.height=o.canvas.width,null!==i?this.loadFont(e,i).then((function(){return r.renderAtlas(o,e)})):this.renderAtlas(o,e)},t.prototype.loadFont=function(t,e){return p(this,void 0,void 0,(function(){var i;return d(this,(function(n){switch(n.label){case 0:return this.loading.set(Symbol.for(t),!0),[4,(i=new FontFace(t,"url("+e+")")).load()];case 1:return n.sent(),document.fonts.add(i),this.loading.set(Symbol.for(t),!1),[2]}}))}))},t.prototype.renderAtlas=function(t,e){var i=t.canvas.getContext("2d");i.clearRect(0,0,t.canvas.width,t.canvas.height),i.textBaseline="top",i.fillStyle="#000",i.font=this.bitmapSize+"px "+e;for(var n=0,r=0,o=0;o<this.chars.length;o++)i.fillText(this.chars[o],n,r),t.glyphsData.set(this.chars[o],{x:n,y:r,width:this.bitmapSize,height:this.bitmapSize}),(n+=this.bitmapSize)>t.canvas.width-this.bitmapSize&&(n=0,r+=this.bitmapSize);this.fontAtlas.set(Symbol.for(e),t)},t}(),J=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},Z=function(){function e(e,i,n){this.posVertices=[],this.texVertices=[],this.posVerticesSize=new t,this.lastTexture=null,this.gl=i.getContext(e),this.programManager=n,this.projectionMatrix=B(),this.modelMatrix=B(),this.textureMatrix=B()}return e.prototype.render=function(t,e,i,n,r){if(n.text){this.generateTextVertices(i,n),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=F(this.modelMatrix),E(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),G(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=F(this.textureMatrix),I(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=F(this.projectionMatrix),U(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),n.opacity<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.lastTexture===e&&"text"===r||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useTintColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,n.opacity);var o=L(n.color),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.maskColorUniform,a,s,h,l),this.gl.uniform1f(this.programManager.maskColorMixUniform,1),this.gl.uniform1i(this.programManager.useMaskColorUniform,1),this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)}},e.prototype.generateTextVertices=function(t,e){this.posVertices=[],this.texVertices=[];for(var i=this.getDimensions(e),n={x1:-i.width/2,y1:i.height/2-e.fontSize,x2:0,y2:i.height/2},r={x1:0,y1:0,x2:0,y2:0},o=0;o<e.text.length;o++){var a=e.text[o];if("\n"!==a)if(" "!==a){var s=t.glyphsData.get(a);s&&(n.x2=n.x1+e.fontSize,r.x1=s.x+e.bitmapOffset.x,r.y1=s.y+e.bitmapOffset.y,r.x2=s.x+s.width-1,r.y2=s.y+s.height-1,this.posVertices.push(n.x1,n.y1,n.x2,n.y1,n.x1,n.y2,n.x1,n.y2,n.x2,n.y1,n.x2,n.y2),this.texVertices.push(r.x1,r.y2,r.x2,r.y2,r.x1,r.y1,r.x1,r.y1,r.x2,r.y2,r.x2,r.y1)),n.x1+=e.fontSize+e.letterSpacing}else n.x1+=e.fontSize+e.letterSpacing;else n.y1-=e.fontSize+e.lineSeparation,n.y2=n.y1+e.fontSize,n.x1=-i.width/2}this.posVerticesSize.set(i.width,i.height)},e.prototype.getTranslationForOrientation=function(t){return[t.positionInViewport.x+("center"===t.orientation?0:this.posVerticesSize.x/2),t.positionInViewport.y+("rightDown"===t.orientation?-this.posVerticesSize.y/2:"rightUp"===t.orientation?this.posVerticesSize.y:0),0]},e.prototype.getDimensions=function(t){return t.text.split("\n").reduce((function(e,i,n){return e.width=Math.max(e.width,i.length*(t.fontSize+t.letterSpacing)),e.height+=t.fontSize+Math.min(n,1)*t.lineSeparation,e}),{width:0,height:0})},e}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circle=1]="Circle",t[t.Line=2]="Line"}(H||(H={}));var tt,et=function(){function t(t,e,i){this.vertices=new Map,this.texVertices=new Float32Array([]),this.lastVertices=null,this.lastRender=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=B(),this.modelMatrix=B(),this.textureMatrix=B()}return t.prototype.renderCollider=function(t,e,i){this.lastRender=i,e.shape.type===H.Polygon&&this.renderPolygon(t,e.positionInViewport,e.shape.vertexModel,e.color,e.shape.angle)},t.prototype.renderPolygon=function(t,e,i,n,r){void 0===r&&(r=0);var o=this.generateVerticesKey(i);!1===this.vertices.has(o)&&this.vertices.set(o,new Float32Array(this.generatePolygonVertices(i)));var a=this.vertices.get(o);this.lastVertices===o&&"geometric"===this.lastRender||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,a,this.gl.DYNAMIC_DRAW)),this.lastVertices=o,"geometric"!==this.lastRender&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.texVertices,this.gl.DYNAMIC_DRAW)),this.modelMatrix=F(this.modelMatrix),E(this.modelMatrix,this.modelMatrix,[e.x,e.y,0]),G(this.modelMatrix,this.modelMatrix,r),this.projectionMatrix=F(this.projectionMatrix),U(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var s=L(n),h=s.r,l=s.g,u=s.b,c=s.a;this.gl.uniform4f(this.programManager.solidColorUniform,h,l,u,c),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.LINE_LOOP,0,a.length/2)},t.prototype.generateVerticesKey=function(t){return Symbol.for(t.reduce((function(t,e){return""+t+e.x+e.y}),t.length.toString()))},t.prototype.generatePolygonVertices=function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i].x,t[i].y);return e},t}(),it=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displaceDirection=new t,this.direction=new t}return e.prototype.getCollisionResolution=function(e,i){this.currentOverlap=null,this.minOverlap=null,this.axes=f(f([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(this.projectShapeOntoAxis(this.projA,e,this.axes[n]),this.projectShapeOntoAxis(this.projB,i,this.axes[n]),this.currentOverlap=Math.min(this.projA.max,this.projB.max)-Math.max(this.projA.min,this.projB.min),this.currentOverlap<0)return null;this.preventContainment(n),(this.currentOverlap<this.minOverlap||null===this.minOverlap)&&(this.minOverlap=this.currentOverlap,this.displaceDirection.copy(this.axes[n]),this.projA.max<this.projB.max&&t.scale(this.displaceDirection,this.displaceDirection,-1))}return t.scale(this.direction,this.displaceDirection,-1),{penetration:this.minOverlap,displacementDirection:this.displaceDirection.clone(),direction:this.direction.clone()}},e.prototype.projectShapeOntoAxis=function(e,i,n){return e.min=t.dot(n,i.vertices[0]),e.max=e.min,i.vertices.forEach((function(i){e.min=Math.min(t.dot(n,i),e.min),e.max=Math.max(t.dot(n,i),e.max)})),e},e.prototype.preventContainment=function(e){if(this.projA.max>this.projB.max&&this.projA.min<this.projB.min||this.projA.max<this.projB.max&&this.projA.min>this.projB.min){var i=Math.abs(this.projA.min-this.projB.min),n=Math.abs(this.projA.max-this.projB.max);i<n?this.currentOverlap+=i:(this.currentOverlap+=n,t.scale(this.axes[e],this.axes[e],-1))}},e}(),nt=function(){function e(e){var i=this;this._touching=!1,this._positionInViewport=new t(0,0),this._radius=new t(0,0),this.eventHandler=function(t){"touchstart"===t.type&&(i._touching=!0,i.updatePosition(t)),"touchmove"===t.type&&i.updatePosition(t),"touchend"!==t.type&&"touchcancel"!==t.type||(i._touching=!1)},this.canvas=e,this.canvas.addEventListener("touchstart",this.eventHandler),this.canvas.addEventListener("touchend",this.eventHandler),this.canvas.addEventListener("touchcancel",this.eventHandler),this.canvas.addEventListener("touchmove",this.eventHandler)}return Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touching",{get:function(){return this._touching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},enumerable:!1,configurable:!0}),e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),0!==t.targetTouches.length&&(this._positionInViewport.set((t.targetTouches[0].clientX-this.canvas.offsetLeft)/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-(t.targetTouches[0].clientY-this.canvas.offsetTop)/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2),this._radius.set(t.targetTouches[0].radiusX,t.targetTouches[0].radiusY))},e}(),rt=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.getCollisionResolution=function(t,e){return this.overlapX=Math.min(t.boundingBox.x1,e.boundingBox.x1)-Math.max(t.boundingBox.x,e.boundingBox.x),this.overlapY=Math.min(t.boundingBox.y1,e.boundingBox.y1)-Math.max(t.boundingBox.y,e.boundingBox.y),this.overlapX<0||this.overlapY<0?null:(this.direction.set(Math.sign(e.boundingBox.x1-t.boundingBox.x1),Math.sign(e.boundingBox.y1-t.boundingBox.y1)),this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displacementDirection.set(0,-this.direction.y),this.preventContainment(t.boundingBox.y,e.boundingBox.y,t.boundingBox.y1,e.boundingBox.y1)):(this.minOverlap=this.overlapX,this.displacementDirection.set(-this.direction.x,this.overlapY===this.overlapX?-this.direction.y:0),this.preventContainment(t.boundingBox.x,e.boundingBox.x,t.boundingBox.x1,e.boundingBox.x1)),{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:this.direction.clone()})},e.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),a=Math.abs(i-r);o<a?this.minOverlap+=o:(this.minOverlap+=a,t.scale(this.displacementDirection,this.displacementDirection,-1))}},e}(),ot=function(){function t(){}return t.prototype.applyCulling=function(t,e){var i=this;return e.filter((function(e){if(!1===t.layers.includes(e.layer))return!1;var n=e.ui?t.viewportRect:t.worldSpaceRect;switch(e.type){case _.Image:return i.cullSprite(n,e);case _.Tilemap:return i.cullTilemap(n,e);case _.Collider:return i.cullCollider(n,e);case _.Text:return i.cullText(n,e);case _.Mask:return i.cullSprite(n,e)}}))},t.prototype.cullSprite=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.cullTilemap=function(t,e){var i=this;return e.tilesToRender=e.tilesData.filter((function(n){return i.isTargetVisible(t,{x:n.position.x-e.tileWidth/2,x1:n.position.x+e.tileWidth/2,y:n.position.y-e.tileHeight/2,y1:n.position.y+e.tileHeight/2})})),e.tilesData.length>0},t.prototype.cullCollider=function(t,e){return this.isTargetVisible(t,e.shape.boundingBox)},t.prototype.cullText=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.isTargetVisible=function(t,e){return t.x1>=e.x&&t.x<=e.x1&&t.y1>=e.y&&t.y<=e.y1},t}(),at=function(){function t(t,e,i){this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.p={x1:0,y1:0,x2:0,y2:0},this.t={x1:0,y1:0,x2:0,y2:0},this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=B(),this.modelMatrix=B(),this.textureMatrix=B()}return t.prototype.render=function(t,e,i,n){if(this.generateVertices(i),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.posVertices),this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.texVertices),this.gl.DYNAMIC_DRAW),this.modelMatrix=F(this.modelMatrix),this.textureMatrix=F(this.textureMatrix),I(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=F(this.projectionMatrix),U(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),this.gl.enable(this.gl.BLEND),this.lastTexture===e&&"tilemap"===n||(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=e),this.gl.uniform1i(this.programManager.useMaskColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,i.alpha),this.gl.uniform1i(this.programManager.useTintColorUniform,i.tintColor?1:0),i.tintColor){var r=L(i.tintColor),o=r.r,a=r.g,s=r.b,h=r.a;this.gl.uniform4f(this.programManager.tintColorUniform,o,a,s,h)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)},t.prototype.generateVertices=function(t){var e=this;this.posVertices=[],this.texVertices=[],t.tilesToRender.forEach((function(i){var n,r;e.p.x1=i.positionInViewport.x-t.tileWidth/2,e.p.x2=i.positionInViewport.x+t.tileWidth/2,e.p.y1=i.positionInViewport.y-t.tileHeight/2,e.p.y2=i.positionInViewport.y+t.tileHeight/2,e.posVertices.push(e.p.x1,e.p.y1,e.p.x2,e.p.y1,e.p.x1,e.p.y2,e.p.x1,e.p.y2,e.p.x2,e.p.y1,e.p.x2,e.p.y2),e.t.x1=i.tile.x,e.t.y1=i.tile.y,e.t.x2=i.tile.x+i.tile.width-(null!==(n=t.textureCorrection)&&void 0!==n?n:0),e.t.y2=i.tile.y+i.tile.height-(null!==(r=t.textureCorrection)&&void 0!==r?r:0),e.texVertices.push(e.t.x1,e.t.y2,e.t.x2,e.t.y2,e.t.x1,e.t.y1,e.t.x1,e.t.y1,e.t.x2,e.t.y2,e.t.x2,e.t.y1)}))},t}(),st=function(){function t(){}return t.initialize=function(t){this.assetManager=t},t.getAssetsLoaded=function(){return this.assetManager.getAssetsLoaded()},t.loadImage=function(t){return this.assetManager.laadImage(t)},t.loadAudio=function(t){return this.assetManager.loadAudio(t)},t.getImage=function(t){return this.assetManager.getImage(t)},t.getAudio=function(t){return this.assetManager.getAudio(t)},t.assetManager=null,t}(),ht=function(){function t(){}return t.initialize=function(t){this.domManager=t},Object.defineProperty(t,"gameWidth",{get:function(){return this.domManager.canvas.width},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gameHeight",{get:function(){return this.domManager.canvas.height},enumerable:!1,configurable:!0}),Object.defineProperty(t,"canvas",{get:function(){return this.domManager.canvas},enumerable:!1,configurable:!0}),t.domManager=null,t}(),lt=function(){function t(){}return t.initialize=function(t){this.inputManager=t},Object.defineProperty(t,"mouse",{get:function(){return this.inputManager.mouse},enumerable:!1,configurable:!0}),Object.defineProperty(t,"keyboard",{get:function(){return this.inputManager.keyboard},enumerable:!1,configurable:!0}),Object.defineProperty(t,"gamepad",{get:function(){return this.inputManager.gamepad},enumerable:!1,configurable:!0}),Object.defineProperty(t,"touch",{get:function(){return this.inputManager.touch},enumerable:!1,configurable:!0}),t.inputManager=null,t}(),ut=function(){function t(){}return t.initialize=function(t){this.sceneManager=t},t.loadScene=function(t){this.sceneManager.loadScene(t)},t.getCurrentSceneName=function(){return this.sceneManager.currentSceneName},t.loadOpeningScene=function(){this.sceneManager.loadOpeningScene()},t.sceneManager=null,t}(),ct=function(){function t(){}return t.initialize=function(t){this.timeManager=t},Object.defineProperty(t,"deltaTime",{get:function(){return this.timeManager.deltaTime},enumerable:!1,configurable:!0}),t.getTimeScale=function(){return this.timeManager.timeScale},t.setTimeScale=function(t){this.timeManager.timeScale=t},Object.defineProperty(t,"unscaledDeltaTime",{get:function(){return this.timeManager.unscaledGameDeltaTime},enumerable:!1,configurable:!0}),Object.defineProperty(t,"physicsDeltaTime",{get:function(){return this.timeManager.physicsDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),pt=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i){return void 0===i&&(i=null),this.manager.addGameObject(t,e,i)},t.getGameObjects=function(){return this.manager.getGameObjects()},t.findGameObjectByName=function(t){return this.manager.findGameObjectByName(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParentAndName=function(t,e){return this.manager.findGameObjectByParentAndName(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.findGameObjectByTag=function(t){return this.manager.findGameObjectByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t}(),dt=function(){function t(t,e,i){this.vertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=B(),this.modelMatrix=B(),this.textureMatrix=B()}return t.prototype.render=function(t,e,i){"mask"!==i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW)),this.modelMatrix=F(this.modelMatrix),E(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),G(this.modelMatrix,this.modelMatrix,e.rotation),I(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=F(this.projectionMatrix),U(this.projectionMatrix,t.x,t.x1,t.y,t.y1,-1,1),this.gl.uniformMatrix4fv(this.programManager.projectionMatrixUniform,!1,this.projectionMatrix),this.gl.uniformMatrix4fv(this.programManager.modelMatrixUniform,!1,this.modelMatrix),this.gl.uniformMatrix4fv(this.programManager.textureMatrixUniform,!1,this.textureMatrix),e.alpha<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.gl.uniform1i(this.programManager.renderTextureUniform,0);var n=L(e.color),r=n.r,o=n.g,a=n.b,s=n.a;this.gl.uniform4f(this.programManager.solidColorUniform,r,o,a,s),this.gl.uniform1f(this.programManager.alphaUniform,e.alpha),this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}();!function(t){t[t.Static=0]="Static",t[t.Dynamic=1]="Dynamic"}(tt||(tt={}));var ft,gt=function(){function e(e){this.collisionManager=e,this.rigidBodyData=[],this.cacheVelocity=new t,this.cacheDisplacement=new t,this.cacheNewDisplacement=0}return e.prototype.addRigidBodyData=function(t){this.rigidBodyData.push(t)},e.prototype.removeRigidBodyData=function(t){var e=this.rigidBodyData.indexOf(t);-1!==e&&(delete this.rigidBodyData[e],this.rigidBodyData.splice(e,1))},e.prototype.update=function(t){var e=this;this.rigidBodyData.forEach((function(i){e.applyGravity(i,t),e.applyVelocity(i,t,"x"),e.applyReposition(i,"x"),e.applyVelocity(i,t,"y"),e.applyReposition(i,"y")}))},e.prototype.applyGravity=function(t,e){t.gravity>0&&(t.velocity.y-=t.gravity*e)},e.prototype.applyVelocity=function(e,i,n){var r=this;this.cacheVelocity.set(0,0),this.cacheVelocity[n]=e.velocity[n]*i,t.add(e.position,e.position,this.cacheVelocity),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,r.cacheVelocity),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)}))},e.prototype.applyReposition=function(e,i){var n=this;this.cacheCollisions=this.getCollisions(e),0!==this.cacheCollisions.length&&(this.cacheDisplacement.set(0,0),this.cacheCollisions.forEach((function(t){n.cacheNewDisplacement=t.resolution.displacementDirection[i]*t.resolution.penetration,n.cacheDisplacement[i]=Math.abs(n.cacheDisplacement[i])>Math.abs(n.cacheNewDisplacement)?n.cacheDisplacement[i]:n.cacheNewDisplacement})),this.cacheDisplacement.magnitude<=0||(t.add(e.position,e.position,this.cacheDisplacement),e.colliders.forEach((function(e){t.add(e.shape.position,e.shape.position,n.cacheDisplacement),e.shape.update(),n.collisionManager.refreshCollisionsForCollider(e)})),0!==this.cacheDisplacement[i]&&Math.sign(this.cacheDisplacement[i])!==Math.sign(e.velocity[i])&&(e.velocity[i]=0)))},e.prototype.getCollisions=function(t){var e=this;return t.colliders.reduce((function(i,n){return i.push.apply(i,e.collisionManager.getFrameCollisionsForCollider(n).filter((function(e){return e.remoteCollider.physics&&e.remoteCollider.rigidBody&&t.layersToCollider.includes(e.remoteCollider.layer)}))),i}),[])},e.prototype.clear=function(){this.rigidBodyData=[]},e}(),mt=function(t,e){if(e.collisions.method===ft.AABB)t.add("CollisionResolver",(function(){return new rt}));else{if(e.collisions.method!==ft.SAT)throw new b("Invalid collision method.");t.add("CollisionResolver",(function(){return new it}))}t.add("CollisionManager",(function(){return new v(t.getSingleton("CollisionResolver"),e.collisions.quadTreeBounds,e.collisions.quadMaxLevel,e.collisions.collidersPerQuad)})),t.add("RigidBodyManager",(function(){return new gt(t.getSingleton("CollisionManager"))}))},yt=function(t,e,i){var n=vt();if(null===n)throw new b("WebGL not suported in your browser.");bt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new $})),t.add("CullingService",(function(){return new ot})),t.add("RenderManager",(function(){return new D(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},bt=function(t,e,i){e.add("ShaderLoader",(function(){return new z})),e.add("ProgramFactory",(function(){return new N(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new K(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new W(t,i.canvas)})),e.add("TextureManager",(function(){return new Q(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new k(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new Z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new et(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new at(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new dt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new q(t,i.canvas,e.getSingleton("ProgramManager"),e.getSingleton("TextureManager"),e.getSingleton("FontAtlasFactory"),e.getSingleton("WebGLImageRenderer"),e.getSingleton("WebGLTilemapRenderer"),e.getSingleton("WebGLTextRenderer"),e.getSingleton("WebGLGeometricRenderer"),e.getSingleton("WebGLMaskRenderer"))}))},xt=function(t,e){t.add("Mouse",(function(){return new S(e.canvas)})),t.add("Keyboard",(function(){return new R(e.canvas)})),t.add("Gamepad",(function(){return new j})),t.add("Touch",(function(){return new nt(e.canvas)})),t.add("InputManager",(function(){return new P(t.getSingleton("Mouse"),t.getSingleton("Keyboard"),t.getSingleton("Gamepad"),t.getSingleton("Touch"))}))},vt=function(){return null!==document.createElement("canvas").getContext(V.WebGL2)?V.WebGL2:null!==document.createElement("canvas").getContext(V.LegacyWebGL)?V.LegacyWebGL:null},Mt=function(t){st.initialize(t.getSingleton("AssetManager")),ht.initialize(t.getSingleton("DomManager")),lt.initialize(t.getSingleton("InputManager")),ut.initialize(t.getSingleton("SceneManager")),ct.initialize(t.getSingleton("TimeManager")),pt.initialize(t.getSingleton("GameObjectManager"))},_t=new(function(){function t(){this.instances=new Map,this.constructors=new Map,this.constants=new Map}return t.prototype.add=function(t,e){if(this.constructors.has(t))throw new b("There is already an object constructor with the name "+t);this.constructors.set(t,e)},t.prototype.getSingleton=function(t){if(!1===this.constructors.has(t))throw new b("Invalid object constructor name: "+t);return!1===this.instances.has(t)&&this.instances.set(t,this.constructors.get(t)()),this.instances.get(t)},t.prototype.getTranscient=function(t){if(!1===this.constructors.has(t))throw new b("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new b("There is already a constant value with the name "+t);this.constants.set(t,e)},t.prototype.getConstant=function(t){if(!1===this.constants.has(t))throw new b("Invalid constant name: "+t);return this.constants.get(t)},t}());!function(t){t.AABB="aabb",t.SAT="sat"}(ft||(ft={}));var wt={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:240,collisions:{method:ft.AABB,quadTreeBounds:null,quadMaxLevel:6,collidersPerQuad:15}},Ot=function(){function t(t){this._running=!1,this._stop=!1,this.frameRequestId=null,this._config=c(c({},wt),t),this._config.collisions=c(c({},wt.collisions),t.collisions),_t.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("DomManager",(function(){return new M(e.containerNode,e.gameWidth,e.gameHeight)}));var i=t.getSingleton("DomManager");t.add("TimeManager",(function(){return new X(e.physicsFramerate)})),yt(t,e,i),xt(t,i),mt(t,e),t.add("SceneManager",(function(){return new Y(t.getConstant("Game"),t.getSingleton("RenderManager"))})),t.add("GameObjectManager",(function(){return new O})),t.add("AssetManager",(function(){return new y})),t.add("IterationManager",(function(){return new w(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})),Mt(t)}(_t,this._config),this.renderManager=_t.getSingleton("RenderManager"),this.sceneManager=_t.getSingleton("SceneManager"),this.iterationManager=_t.getSingleton("IterationManager")},Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"running",{get:function(){return this._running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i){void 0===i&&(i=!1),this.sceneManager.addScene(t,e,i)},t.prototype.run=function(){this.sceneManager.loadOpeningScene(),this.requestAnimationFrame()},t.prototype.stop=function(){this.pauseLoop(),this.sceneManager.unloadCurrentScene(),this.renderManager.clearCanvas()},t.prototype.gameLoop=function(t){!0!==this._stop&&(this._running=!0,this.iterationManager.update(t),this.requestAnimationFrame())},t.prototype.pauseLoop=function(){this._stop=!0,this._running=!1,null!==this.frameRequestId&&(window.cancelAnimationFrame(this.frameRequestId),this.frameRequestId=null)},t.prototype.resumeLoop=function(){0==this._running&&null===this.frameRequestId&&(this._stop=!1,this.requestAnimationFrame())},t.prototype.requestAnimationFrame=function(){var t=this;this.frameRequestId=window.requestAnimationFrame((function(e){return t.gameLoop(e)}))},t}(),jt=function(){var t=(new Date).getTime(),e=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(i){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"==i?n:7&n|8).toString(16)}))},Ct=function(){function t(){this.sceneManager=_t.getSingleton("SceneManager"),this.gameObjectManager=_t.getSingleton("GameObjectManager"),this.id=jt(),this.allowMultiple=!0,this._active=!0,this.started=!1}return Object.defineProperty(t.prototype,"updateEvent",{get:function(){return g.Update},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),t.prototype.setActive=function(t){this._active=t,this.activeStateChange()},t.prototype.dispatch=function(t){!1!==this._active&&!1!==this.gameObject.active&&(t===g.Init?this.init():t===g.Start&&!1===this.started?(this.start(),this.started=!0):t===this.updateEvent&&!0===this.started?this.update():t===g.Destroy&&(this.destroy(),this._destroy()))},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.activeStateChange=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getComponentByName=function(t){return this.gameObject.getComponentByName(t)},t.prototype.getComponentByType=function(t){return this.gameObject.getComponentByType(t)},t.prototype.getComponentsByType=function(t){return this.gameObject.getComponentsByType(t)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){this.gameObject.removeComponentByName(t)},t.prototype.removeComponentByType=function(t){this.gameObject.removeComponentByType(t)},t.prototype._destroy=function(){var t=this;Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),Pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdateEngine},enumerable:!1,configurable:!0}),e}(Ct),Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdateCollider},enumerable:!1,configurable:!0}),e}(Ct),St=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdatePhysics},enumerable:!1,configurable:!0}),e}(Ct),Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdateTransform},enumerable:!1,configurable:!0}),e}(Ct),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdatePreRender},enumerable:!1,configurable:!0}),e}(Ct),At=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdateCamera},enumerable:!1,configurable:!0}),e}(Ct),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return g.UpdateRender},enumerable:!1,configurable:!0}),e}(Ct),Ft={Animator:"Animator",AudioPlayer:"AudioPlayer",Camera:"camera",RigidBody:"RigidBody",Transform:"Transform",BoxCollider:"BoxCollider",TilemapCollider:"TilemapCollider",PolygonCollider:"PolygonCollider",CsvTilemapRenderer:"CsvTilemapRenderer",SpriteRenderer:"SpriteRenderer",TextRenderer:"TextRenderer",TiledTilemapRenderer:"TiledTilemapRenderer",MaskRenderer:"MaskRenderer"},Et=function(e){function i(){var i=e.call(this)||this;return i._position=new t,i._scale=new t(1,1),i._rotation=new s,i._innerPosition=new t,i._parent=null,i.parentScale=!0,i.parentRotation=!0,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i.allowMultiple=!1,i.type=Ft.Transform,i}return l(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,null!==this._parent&&this.updateInnerPositionFromParent()},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent?(!1===this.lastPosition.equals(this._position)&&this.updateInnerPositionFromParent(),this.setPositionFromParent()):this._innerPosition.copy(this._position),this.lastPosition.copy(this._position)},i.prototype.updateInnerPositionFromParent=function(){t.subtract(this._innerPosition,this._position,this._parent.position)},i.prototype.setPositionFromParent=function(){this._innerPosition.magnitude>0?(0!==this._parent.rotation.radians&&this.lastParentRadians!==this._parent.rotation.radians&&(this.translateInnerPosition(),this.lastParentRadians=this._parent.rotation.radians),this.parentScale?(this.updateScaledInnerPosition(),t.add(this._position,this._parent.position,this.scaledInnerPosition)):t.add(this._position,this._parent.position,this._innerPosition)):this._position.copy(this._parent.position),this._rotation.radians=this.parentRotation?this._parent.rotation.radians:this.rotation.radians,this.parentScale&&this._scale.copy(this._parent.scale)},i.prototype.translateInnerPosition=function(){var e=Math.atan2(this._innerPosition.y,this._innerPosition.x)+(this._parent.rotation.radians-this.lastParentRadians);this.cache.set(Math.cos(e),Math.sin(e)),t.scale(this._innerPosition,this.cache,this._innerPosition.magnitude)},i.prototype.updateScaledInnerPosition=function(){this.scaledInnerPosition.set(this._innerPosition.x*this._parent.scale.x,this._innerPosition.y*this._parent.scale.y)},i}(Tt),It="Default",Gt=function(){function t(){this.id=jt(),this.layer="Default",this.ui=!1,this.keep=!1,this._active=!0,this._parent=null,this.started=!1,this.sceneManager=_t.getSingleton("SceneManager"),this.gameObjectManager=_t.getSingleton("GameObjectManager"),this.components=[],this.addComponent((function(){return new Et}))}return Object.defineProperty(t.prototype,"active",{get:function(){return this._active},enumerable:!1,configurable:!0}),t.prototype.setActive=function(t){this._active=t},Object.defineProperty(t.prototype,"transform",{get:function(){return this.getComponentByType(Ft.Transform)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigidBody",{get:function(){return this.getComponentByType(Ft.RigidBody)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=t?t.transform:null},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){!1===this.active||this.parent&&!1===this.parent.active||(t===g.Init?this.init():t===g.Start&&!1===this.started?(this.start(),this.started=!0):t===g.Update&&this.started?this.update():t===g.Destroy&&(this.destroy(),this._destroy()))},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.addComponent=function(t,e){void 0===e&&(e=null);var i=t();return this.checkMultipleComponent(i),i.name=e,i.gameObject=this,i.dispatch(g.Init),this.components.push(i),i},t.prototype.checkMultipleComponent=function(t){if(!1===t.allowMultiple&&this.hasComponentOfType(t.type))throw new b("GameObject only allows one component of type "+t.type)},t.prototype.getComponents=function(){return this.components},t.prototype.getComponentByName=function(t){return this.components.reduce((function(e,i){return i.name===t?i:e}),null)},t.prototype.getComponentByType=function(t){return this.components.reduce((function(e,i){return i.type===t?i:e}),null)},t.prototype.getComponentsByType=function(t){return this.components.filter((function(e){return e.type===t}))},t.prototype.hasComponentOfName=function(t){return null!==this.getComponentByName(t)},t.prototype.hasComponentOfType=function(t){return null!==this.getComponentByType(t)},t.prototype.removeComponentByName=function(t){var e=this;this.components.every((function(i,n){if(i.name===t)return i.dispatch(g.Destroy),delete e.components[n],!1}))},t.prototype.removeComponentByType=function(t){var e=this;this.components.every((function(i,n){if(i.type===t)return i.dispatch(g.Destroy),delete e.components[n],!1}))},t.prototype.addChild=function(t,e){return this.gameObjectManager.addGameObject(t,e,this)},t.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},t.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParentAndName(this,t)},t.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype._destroy=function(){var t=this;this.destroyComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},t.prototype.destroyComponents=function(){for(var t=0;t<this.components.length;t++)this.components[t].dispatch(g.Destroy),delete this.components[t];this.components=[]},t}(),Ut=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},Vt=["Default"],Lt=function(t){function i(){var i=t.call(this)||this;return i.renderManager=_t.getSingleton("RenderManager"),i.domManager=_t.getSingleton("DomManager"),i._layers=Vt,i._depth=0,i._zoom=1,i._originalViewportRect=new e(0,0,0,0),i._viewportRect=new e(0,0,0,0),i._worldSpaceRect=new e(0,0,0,0),i.cameraData=new Ut,i.allowMultiple=!1,i.type=Ft.Camera,i.canvas=i.domManager.canvas,i}return l(i,t),Object.defineProperty(i.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=f(f([],Vt,!0),t,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new b("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"originalViewportRect",{get:function(){return this._originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"worldSpaceRect",{get:function(){return this._worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"viewportRect",{get:function(){return this._viewportRect},enumerable:!1,configurable:!0}),i.prototype.addLayer=function(t){this._layers.push(t)},i.prototype.update=function(){this.updateOriginalViewportRect(),this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},i.prototype.updateOriginalViewportRect=function(){this._originalViewportRect.x=-this.canvas.width/2,this._originalViewportRect.y=-this.canvas.height/2,this._originalViewportRect.width=this.canvas.width,this._originalViewportRect.height=this.canvas.height},i.prototype.updateViewportRect=function(){var t=1/this._zoom;this._viewportRect.x=this._originalViewportRect.x*t,this._viewportRect.y=this._originalViewportRect.y*t,this._viewportRect.width=this._originalViewportRect.width*t,this._viewportRect.height=this._originalViewportRect.height*t},i.prototype.updateWorldSpaceRect=function(){this._worldSpaceRect.x=this.gameObject.transform.position.x-this._viewportRect.width/2,this._worldSpaceRect.y=this.gameObject.transform.position.y-this._viewportRect.height/2,this._worldSpaceRect.width=this._viewportRect.width,this._worldSpaceRect.height=this._viewportRect.height},i.prototype.updateCameraData=function(){this.cameraData.depth=this._depth,this.cameraData.layers=this._layers,this.cameraData.originalViewportRect=this._originalViewportRect,this.cameraData.viewportRect=this._viewportRect,this.cameraData.worldSpaceRect=this._worldSpaceRect,this.cameraData.zoom=this._zoom,this.renderManager.addCameraData(this.cameraData)},i}(At),kt=function(t){function e(){var e=t.call(this)||this;return e.transform.position.set(0,0),e.camera=e.addComponent((function(){return new Lt})),e}return l(e,t),Object.defineProperty(e.prototype,"layers",{get:function(){return this.camera.layers},set:function(t){this.camera.layers=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this.camera.depth},set:function(t){this.camera.depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this.camera.zoom},set:function(t){this.camera.zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewporRect",{get:function(){return this.camera.originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this.camera.worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this.camera.viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this.camera.layers.push(t)},e}(Gt),Nt="GameCamera",zt=function(){function t(){this.gameObjectManager=_t.getSingleton("GameObjectManager"),this.game=null,this.name=null,this.started=!1,this.addGameObject((function(){return new kt}),"GameCamera")}return Object.defineProperty(t.prototype,"gameCamera",{get:function(){return this.findGameObjectByName("GameCamera")},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){t===g.Init?this.init():t!==g.Start||this.started?t===g.Update&&this.started?this.update():t===g.Destroy&&(this.destroy(),this._destroy()):(this.start(),this.started=!0)},t.prototype.init=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.destroy=function(){},t.prototype.addGameObject=function(t,e){return this.gameObjectManager.addGameObject(t,e)},t.prototype.getGameObjects=function(){return this.gameObjectManager.getGameObjects()},t.prototype.findGameObjectByName=function(t){return this.gameObjectManager.findGameObjectByName(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.findGameObjectByTag=function(t){return this.gameObjectManager.findGameObjectByTag(t)},t.prototype.destroyGameObjectByName=function(t){this.destroyGameObject(this.findGameObjectByName(t))},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t.prototype._destroy=function(){var t=this;this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},t}(),Wt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=_t.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return l(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return t.collisionManager.addCollider(e)}))},e.prototype.collidesWithLayer=function(t){return null!==this.getCollisionWithLayer(t)},e.prototype.getCollisionWithLayer=function(t){for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getFrameCollisionsForCollider(n);r<o.length;r++){var a=o[r];if(a.remoteCollider.layer===t)return{gameObject:this.gameObjectManager.findGameObjectById(a.remoteCollider.id),collider:a.remoteCollider,resolution:a.resolution}}return null},e.prototype.getCollisionsWithLayer=function(t){for(var e=[],i=0,n=this.colliders;i<n.length;i++)for(var r=n[i],o=0,a=this.collisionManager.getFrameCollisionsForCollider(r);o<a.length;o++){var s=a[o];s.remoteCollider.layer===t&&e.push({gameObject:this.gameObjectManager.findGameObjectById(s.remoteCollider.id),collider:s.remoteCollider,resolution:s.resolution})}return e},e.prototype.activeStateChange=function(){this.renderer&&this.renderer.setActive(this.active)},e}(Rt),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Collider,e.color=null,e.shape=null,e}return l(e,t),e}(T),qt=function(){function t(t,e,i,n,r,o){this.shape=t,this.layer=e,this.id=i,this.updateCollisions=n,this.physics=r,this.rigidBody=o}return Object.defineProperty(t.prototype,"x",{get:function(){return this.shape.boundingBox.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.shape.boundingBox.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x1",{get:function(){return this.shape.boundingBox.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y1",{get:function(){return this.shape.boundingBox.y1},enumerable:!1,configurable:!0}),t}(),Yt=function(){function i(i){this._type=H.Polygon,this._vertices=[],this._boundingBox=new e(0,0,0,0),this._projectionAxes=[],this._position=new t,this._angle=0,this.boxMinX=Number.MAX_SAFE_INTEGER,this.boxMinY=Number.MAX_SAFE_INTEGER,this.boxMaxX=-Number.MAX_SAFE_INTEGER,this.boxMaxY=-Number.MAX_SAFE_INTEGER,this._vertexModel=i;for(var n=0;n<this._vertexModel.length;n++)this._vertices.push(new t),this._projectionAxes.push(new t)}return Object.defineProperty(i.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"boundingBox",{get:function(){return this._boundingBox},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"projectionAxes",{get:function(){return this._projectionAxes},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"vertexModel",{get:function(){return this._vertexModel},set:function(t){this._vertexModel=t},enumerable:!1,configurable:!0}),i.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},i.prototype.updateVertices=function(){for(var t=0;t<this._vertexModel.length;t++)this._vertices[t].set(this._vertexModel[t].x*Math.cos(this._angle)-this._vertexModel[t].y*Math.sin(this._angle)+this._position.x,this._vertexModel[t].x*Math.sin(this._angle)+this._vertexModel[t].y*Math.cos(this._angle)+this._position.y)},i.prototype.updateBoundingBox=function(){var t=this;this.boxMinX=this.vertices[0].x,this.boxMinY=this.vertices[0].y,this.boxMaxX=this.vertices[0].x,this.boxMaxY=this.vertices[0].y,this.vertices.forEach((function(e){t.boxMinX=Math.min(e.x,t.boxMinX),t.boxMinY=Math.min(e.y,t.boxMinY),t.boxMaxX=Math.max(e.x,t.boxMaxX),t.boxMaxY=Math.max(e.y,t.boxMaxY)})),this.boundingBox.set(this.boxMinX,this.boxMinY,this.boxMaxX-this.boxMinX,this.boxMaxY-this.boxMinY)},i.prototype.updateProjectionAxes=function(){for(var e,i=0;i<this._vertices.length;i++)t.normal(this.projectionAxes[i],t.subtract(this.projectionAxes[i],null!==(e=this._vertices[i+1])&&void 0!==e?e:this._vertices[0],this._vertices[i]))},i}(),Xt=function(e){function i(i,n,r){var o=e.call(this,[new t(-i/2,-n/2),new t(-i/2,n/2),new t(i/2,n/2),new t(i/2,-n/2)])||this;return o.width=i,o.height=n,o._position.copy(r),o._projectionAxes=[new t,new t],o.update(),o}return l(i,e),i.prototype.updateSize=function(t,e){this.width=t,this.height=e,this.vertexModel[0].set(-t/2,-e/2),this.vertexModel[1].set(-t/2,e/2),this.vertexModel[2].set(t/2,e/2),this.vertexModel[3].set(t/2,-e/2)},i.prototype.updateProjectionAxes=function(){t.unit(this._projectionAxes[0],t.subtract(this.projectionAxes[0],this._vertices[1],this._vertices[0])),t.normal(this._projectionAxes[1],this._projectionAxes[0])},i}(Yt),Qt=function(e){function i(i){var n,r,o,a,h,l=e.call(this)||this;return l.debug=!1,l.offsetX=0,l.offsetY=0,l.realWidth=0,l.realHeight=0,l.realOffset=new t,l.realPosition=new t,l.realRotation=0,l.applyRotation=_t.getConstant("GameConfig").collisions.method===ft.SAT,l.innerPosition=new t,l.type=Ft.BoxCollider,l.width=i.width,l.height=i.height,l.offsetX=null!==(n=i.offsetX)&&void 0!==n?n:l.offsetX,l.offsetY=null!==(r=i.offsetY)&&void 0!==r?r:l.offsetY,l.physics=null!==(o=i.physics)&&void 0!==o?o:l.physics,l.debug=(null!==(a=i.debug)&&void 0!==a?a:l.debug)&&_t.getConstant("GameConfig").debugEnabled,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new s,l.layer=i.layer,l}return l(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new qt(new Xt(this.realWidth,this.realHeight,this.realPosition),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Ft.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Kt(e.colliders[0])})))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realWidth=this.width*Math.abs(this.gameObject.transform.scale.x),this.realHeight=this.height*Math.abs(this.gameObject.transform.scale.y),this.realOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.realOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.realRotation=this.applyRotation?this.gameObject.transform.rotation.radians+this.rotation.radians:0},i.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.realPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.realPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.realPosition,this.colliders[0].shape.angle=this.realRotation,this.colliders[0].shape.updateSize(this.realWidth,this.realHeight),this.colliders[0].shape.update()},i}(Wt),Kt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=_t.getSingleton("RenderManager"),i.type="BoxColliderRenderer",i.renderData=new Ht,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return l(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.position=this.collider.shape.position,this.renderData.shape=this.collider.shape,this.renderManager.addRenderData(this.renderData)},e}(Bt),$t=function(e){function i(i){var n,r=e.call(this)||this;return r.debug=!1,r.needsCollider=function(t){r.cacheVertex[0].set(t.position.x,t.position.y+t.height),r.cacheVertex[1].set(t.position.x+t.width,t.position.y),r.cacheVertex[2].set(t.position.x,t.position.y-t.height),r.cacheVertex[3].set(t.position.x-t.width,t.position.y);for(var e=function(t){if(void 0===r.tilemapRenderer.tilesData.find((function(e){return e.position.equals(r.cacheVertex[t])})))return{value:!0}},i=0;i<r.cacheVertex.length;i++){var n=e(i);if("object"==typeof n)return n.value}return!1},r.type=Ft.TilemapCollider,r.tilemapRenderer=i.tilemapRenderer,r.layer=i.layer,r.debug=(null!==(n=i.debug)&&void 0!==n?n:r.debug)&&_t.getConstant("GameConfig").debugEnabled,r.physics=!0,r.cacheVertex=[new t,new t,new t,new t],r}return l(i,e),i.prototype.start=function(){var t,e=this;this.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.tilemapRenderer.tilesData.filter(this.needsCollider).forEach((function(t){return e.colliders.push(new qt(new Xt(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponentOfType(Ft.RigidBody)))})),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Jt(e.colliders)})))},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return e.layer=t.layer})),e.prototype.update.call(this)},i}(Wt),Jt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=_t.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="TilemapColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new Ht,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00"})),i}return l(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].position=e.shape.position,t.renderData[i].shape=e.shape,t.renderManager.addRenderData(t.renderData[i])}))},e}(Bt),Zt=function(e){function i(i){var n,r,o,a,h,l=e.call(this)||this;l.debug=!1,l.offsetX=0,l.offsetY=0,l.scaledVertexModel=[],l.scaledOffset=new t,l.scaledPosition=new t,l.finalRotation=0,l.applyRotation=_t.getConstant("GameConfig").collisions.method===ft.SAT,l.innerPosition=new t,l.type=Ft.PolygonCollider,l.debug=(null!==(n=i.debug)&&void 0!==n?n:l.debug)&&_t.getConstant("GameConfig").debugEnabled,l.vertexModel=i.vertexModel,l.offsetX=null!==(r=i.offsetX)&&void 0!==r?r:l.offsetX,l.offsetY=null!==(o=i.offsetY)&&void 0!==o?o:l.offsetY,l.physics=null!==(a=i.physics)&&void 0!==a?a:l.physics,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new s,l.layer=i.layer;for(var u=0;u<l.vertexModel.length;u++)l.scaledVertexModel.push(new t);return l}return l(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new qt(new Yt(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Ft.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new te(e.colliders[0])})))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateSize=function(){var t=this;this.vertexModel.forEach((function(e,i){return t.scaledVertexModel[i].set(e.x*t.gameObject.transform.scale.x,e.y*t.gameObject.transform.scale.y)})),this.scaledOffset.x=this.offsetX*this.gameObject.transform.scale.x,this.scaledOffset.y=this.offsetY*this.gameObject.transform.scale.y,this.finalRotation=this.applyRotation?this.gameObject.transform.rotation.radians+this.rotation.radians:0},i.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},i.prototype.translate=function(){t.subtract(this.innerPosition,this.scaledPosition,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.scaledPosition.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i.prototype.updateShape=function(){var t;this.colliders[0].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[0].shape.position=this.scaledPosition,this.colliders[0].shape.angle=this.finalRotation,this.colliders[0].shape.vertexModel=this.vertexModel,this.colliders[0].shape.update()},i}(Wt),te=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=_t.getSingleton("RenderManager"),i.type="PolygonColliderRenderer",i.renderData=new Ht,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return l(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.position=this.collider.shape.position,this.renderData.shape=this.collider.shape,this.renderManager.addRenderData(this.renderData)},e}(Bt),ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Image,e}return l(e,t),e}(T),ie=function(e){function i(i){var n,r,o,a,h,l,u,c,p,d,f;void 0===i&&(i={sprite:null});var g=e.call(this)||this;return g.renderManager=_t.getSingleton("RenderManager"),g.sprite=null,g.offset=new t,g.flipHorizontal=!1,g.flipVertical=!1,g.rotation=new s,g.smooth=!1,g.opacity=1,g._tiled=new t(1,1),g.maskColor=null,g.maskColorMix=0,g.tintColor=null,g.renderData=[],g.innerPosition=new t,g.cachePosition=new t,g.cacheRenderPosition=new t,g.scaledOffset=new t,g.type=Ft.SpriteRenderer,g.sprite=i.sprite,g.offset=null!==(n=i.offset)&&void 0!==n?n:g.offset,g.smooth=null!==(r=i.smooth)&&void 0!==r?r:g.smooth,g.rotation=null!==(o=i.rotation)&&void 0!==o?o:g.rotation,g.flipHorizontal=null!==(a=i.flipHorizontal)&&void 0!==a?a:g.flipHorizontal,g.flipVertical=null!==(h=i.flipVertical)&&void 0!==h?h:g.flipVertical,g.opacity=null!==(l=i.opacity)&&void 0!==l?l:g.opacity,g.tiled=null!==(u=i.tiled)&&void 0!==u?u:g._tiled,g.maskColor=null!==(c=i.maskColor)&&void 0!==c?c:g.maskColor,g.maskColorMix=null!==(p=i.maskColorMix)&&void 0!==p?p:g.maskColorMix,g.tintColor=null!==(d=i.tintColor)&&void 0!==d?d:g.tintColor,g.layer=null!==(f=i.layer)&&void 0!==f?f:g.layer,g}return l(i,e),Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new b("SpriteRenderer.tiled: Vector2 components must be integers");this._tiled.set(t.x,t.y)},enumerable:!1,configurable:!0}),i.prototype.update=function(){if(this.sprite&&!0===this.sprite.loaded){this.updateRenderDataArray();for(var t=0,e=0;e<this._tiled.x;e++)for(var i=0;i<this._tiled.y;i++)this.updateRenderData(t,e,i),t++}},i.prototype.updateRenderDataArray=function(){if(this.renderData.length!==this._tiled.x*this._tiled.y){this.renderData=[];for(var t=0;t<=this._tiled.x*this._tiled.y;t++)this.renderData[t]=new ee}},i.prototype.updateRenderData=function(t,e,i){var n;this.renderData[t].ui=this.gameObject.ui,this.renderData[t].layer=null!==(n=this.layer)&&void 0!==n?n:this.gameObject.layer,this.renderData[t].image=this.sprite.image,this.renderData[t].width=this.sprite.width*Math.abs(this.gameObject.transform.scale.x),this.renderData[t].height=this.sprite.height*Math.abs(this.gameObject.transform.scale.y),this.renderData[t].slice=this.sprite.slice,this.renderData[t].flipHorizontal=this.flipHorizontal!==this.gameObject.transform.scale.x<0,this.renderData[t].flipVertical=this.flipVertical!==this.gameObject.transform.scale.y<0,this.renderData[t].rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData[t].smooth=this.sprite.smooth,this.renderData[t].alpha=this.opacity,this.renderData[t].maskColor=this.maskColor,this.renderData[t].maskColorMix=this.maskColorMix,this.renderData[t].tintColor=this.tintColor,this.calculateRenderPosition(t,e,i),this.renderManager.addRenderData(this.renderData[t])},i.prototype.calculateRenderPosition=function(e,i,n){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.cachePosition,this.gameObject.transform.position,this.scaledOffset),this.cacheRenderPosition.set(this.renderData[e].width/2*(this.tiled.x-1),this.renderData[e].height/2*(this.tiled.y-1)),t.subtract(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.cacheRenderPosition.set(i*this.renderData[e].width,n*this.renderData[e].height),t.add(this.cachePosition,this.cachePosition,this.cacheRenderPosition),this.renderData[e].position=this.cachePosition,0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition(e)},i.prototype.translateRenderPosition=function(e){t.subtract(this.innerPosition,this.renderData[e].position,this.gameObject.transform.position);var i=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData[e].position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(i),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(i))},i}(Bt),ne=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Text,e}return l(e,t),e}(T),re=function(e){function i(i){var n,r,o,a,h,l,u,c,p,d,f,g,m,y,x,v=e.call(this)||this;if(v.fontFamily="Sans",v.fontUrl=null,v.fontSize=12,v.width=100,v.height=100,v.offset=new t,v.color="#000000",v.lineSeparation=0,v.letterSpacing=0,v.bitmapSize=64,v.charRanges=[32,126,161,255],v.smooth=!1,v.bitmapOffset=new t,v.rotation=new s,v.opacity=1,v.orientation="center",v.renderManager=_t.getSingleton("RenderManager"),v.renderData=new ne,v.lastFrameText="",v.type=Ft.TextRenderer,v.text=i.text,v.fontFamily=i.fontFamily,v.fontUrl=null!==(n=i.fontUrl)&&void 0!==n?n:v.fontUrl,v.fontSize=null!==(r=i.fontSize)&&void 0!==r?r:v.fontSize,v.width=null!==(o=i.width)&&void 0!==o?o:v.width,v.height=null!==(a=i.height)&&void 0!==a?a:v.height,v.offset=null!==(h=i.offset)&&void 0!==h?h:v.offset,v.color=null!==(l=i.color)&&void 0!==l?l:v.color,v.lineSeparation=null!==(u=i.lineSeparation)&&void 0!==u?u:v.lineSeparation,v.letterSpacing=null!==(c=i.letterSpacing)&&void 0!==c?c:v.letterSpacing,v.bitmapSize=null!==(p=i.bitmapSize)&&void 0!==p?p:v.bitmapSize,v.charRanges=null!==(d=i.charRanges)&&void 0!==d?d:v.charRanges,v.smooth=null!==(f=i.smooth)&&void 0!==f?f:v.smooth,v.bitmapOffset=null!==(g=i.bitmapOffset)&&void 0!==g?g:v.bitmapOffset,v.rotation=null!==(m=i.rotation)&&void 0!==m?m:v.rotation,v.opacity=null!==(y=i.opacity)&&void 0!==y?y:v.opacity,v.orientation=null!==(x=i.orientation)&&void 0!==x?x:v.orientation,v.charRanges.length%2!=0)throw new b("TextRenderer.charRanges must be a 2 column matrix");if(v.lineSeparation%2!=0)throw new b("TextRenderer.lineSeparation must be multiple of 2");return v}return l(i,e),i.prototype.start=function(){this.renderData.layer=this.gameObject.layer,this.renderData.ui=this.gameObject.ui,this.renderData.fontFamily=this.fontFamily,this.renderData.fontUrl=this.fontUrl,this.renderData.fontSize=this.fontSize,this.renderData.lineSeparation=this.lineSeparation,this.renderData.letterSpacing=this.letterSpacing,this.renderData.bitmapSize=this.bitmapSize,this.renderData.charRanges=this.charRanges,this.renderData.smooth=this.smooth,this.renderData.bitmapOffset=this.bitmapOffset,this.renderData.orientation=this.orientation,this.renderData.width=this.width,this.renderData.height=this.height},i.prototype.update=function(){this.text&&(this.renderData.text=this.text!==this.lastFrameText?this.crop():this.renderData.text,this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.opacity=this.opacity,t.add(this.renderData.position,this.gameObject.transform.position,this.offset),this.renderManager.addRenderData(this.renderData),this.lastFrameText=this.text)},i.prototype.crop=function(){var t;if(this.fontSize>this.height)return"";for(var e=[],i=0,n=0,r=this.text.split("\n");n<r.length;n++)for(var o=0,a=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<a.length;o++){var s=a[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(s)}return e.join("\n")},i}(Bt),oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Mask,e}return l(e,t),e}(T),ae=function(e){function i(i){var n,r,o,a,h=e.call(this)||this;return h.renderManager=_t.getSingleton("RenderManager"),h.offset=new t,h.rotation=new s,h.opacity=1,h.renderData=new oe,h.innerPosition=new t,h.scaledOffset=new t,h.type=Ft.MaskRenderer,h.width=i.width,h.height=i.height,h.color=i.color,h.offset=null!==(n=i.offset)&&void 0!==n?n:h.offset,h.rotation=null!==(r=i.rotation)&&void 0!==r?r:h.rotation,h.opacity=null!==(o=i.opacity)&&void 0!==o?o:h.opacity,h.layer=null!==(a=i.layer)&&void 0!==a?a:h.layer,h}return l(i,e),i.prototype.update=function(){var t;this.renderData.ui=this.gameObject.ui,this.renderData.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.renderData.width=this.width*Math.abs(this.gameObject.transform.scale.x),this.renderData.height=this.height*Math.abs(this.gameObject.transform.scale.y),this.renderData.color=this.color,this.renderData.rotation=this.gameObject.transform.rotation.radians+this.rotation.radians,this.renderData.alpha=this.opacity,this.calculateRenderPosition(),this.renderManager.addRenderData(this.renderData)},i.prototype.calculateRenderPosition=function(){this.scaledOffset.set(this.offset.x*this.gameObject.transform.scale.x,this.offset.y*this.gameObject.transform.scale.y),t.add(this.renderData.position,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translateRenderPosition()},i.prototype.translateRenderPosition=function(){t.subtract(this.innerPosition,this.renderData.position,this.gameObject.transform.position);var e=Math.atan2(this.innerPosition.y,this.innerPosition.x)+this.gameObject.transform.rotation.radians;this.renderData.position.set(this.gameObject.transform.position.x+this.innerPosition.magnitude*Math.cos(e),this.gameObject.transform.position.y+this.innerPosition.magnitude*Math.sin(e))},i}(Bt),se=function(){function e(e,i,n){this._position=new t,this._position.set(e.x,e.y),this._width=i,this._height=n}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e}(),he=function(){this.position=new t,this.positionInViewport=new t},le=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return l(e,t),e}(T),ue=function(e){function i(i){var n,r,o,a,s,h=e.call(this)||this;return h.renderOrder="center",h.smooth=!1,h.textureCorrection=null,h.tileScale=null!==(n=_t.getConstant("GameConfig").spriteDefaultScale)&&void 0!==n?n:new t(1,1),h.tileWidth=0,h.tileHeight=0,h.orientation=new t(1,1),h.renderManager=_t.getSingleton("RenderManager"),h.tilemapProcessed=!1,h.renderData=new Map,h.cols=[],h.rows=[],h._width=0,h._height=0,h.tiles=[],h._realWidth=0,h._realHeight=0,h.cacheV2=new t,h.allowMultiple=!1,h.tileset=i.tileset,h.tileScale=null!==(r=i.tileScale)&&void 0!==r?r:h.tileScale,h.smooth=null!==(o=i.smooth)&&void 0!==o?o:h.smooth,h.renderOrder=null!==(a=i.renderOrder)&&void 0!==a?a:h.renderOrder,h.textureCorrection=null!==(s=i.textureCorrection)&&void 0!==s?s:h.textureCorrection,h}return l(i,e),i.prototype.start=function(){this.tileWidth=this.tileset.tileWidth*this.tileScale.x*Math.abs(this.gameObject.transform.scale.x),this.tileHeight=this.tileset.tileHeight*this.tileScale.y*Math.abs(this.gameObject.transform.scale.y),this.orientation.set(Math.sign(this.gameObject.transform.scale.x),Math.sign(this.gameObject.transform.scale.y)),this.processTilemap(),this.updatePosition()},i.prototype.update=function(){var t=this;this.renderData.forEach((function(e){return t.renderManager.addRenderData(e)}))},i.prototype.processLayer=function(t){var e=new le;e.ui=!1,e.alpha=t.alpha,e.image=this.tileset.image,e.layer=this.gameObject.layer,e.smooth=this.smooth,e.tileWidth=this.tileWidth,e.tileHeight=this.tileHeight,e.textureCorrection=this.textureCorrection,e.tintColor=t.tintColor,this.renderData.set(t.layer,e)},i.prototype.processTile=function(t){null!==t.tile&&this.addTileToRenderData(t),this.updateSizeInfo(t.col,t.row)},i.prototype.addTileToRenderData=function(t){if(this.renderData.has(t.layer)){var e=new he;e.tile=t.tile,e.position.set(this.gameObject.transform.position.x+t.col*this.tileWidth*this.orientation.x+t.offset.x*Math.abs(this.gameObject.transform.scale.x)+this.tileWidth*this.orientation.x/2,this.gameObject.transform.position.y-t.row*this.tileHeight*this.orientation.y-t.offset.y*Math.abs(this.gameObject.transform.scale.y)-this.tileHeight*this.orientation.y/2),e.flipHorizontal=t.flip.h!==this.orientation.x<0,e.flipVertical=t.flip.v!==this.orientation.y<0,this.renderData.get(t.layer).tilesData.push(e)}},i.prototype.updateSizeInfo=function(t,e){this._width=!1===this.cols.includes(t)?this.cols.push(t):this._width,this._height=!1===this.rows.includes(e)?this.rows.push(e):this._height,this._realWidth=this._width*this.tileWidth,this._realHeight=this._height*this.tileHeight},i.prototype.updatePosition=function(){var e=this;this.cacheV2.set(("center"===this.renderOrder?-Math.round(this._realWidth/2):["left-down","left-up"].includes(this.renderOrder)?-this._realWidth:0)*this.orientation.x,("center"===this.renderOrder?Math.round(this._realHeight/2):["right-up","left-up"].includes(this.renderOrder)?this._realHeight:0)*this.orientation.y),this.renderData.forEach((function(i){return i.tilesData.forEach((function(i){t.add(i.position,i.position,e.cacheV2),e.addTileData(i)}))}))},i.prototype.addTileData=function(t){this.tiles.push(new se(t.position,this.tileWidth,this.tileHeight))},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realWidth",{get:function(){return this._realWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realHeight",{get:function(){return this._realHeight},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tilesData",{get:function(){return this.tiles},enumerable:!1,configurable:!0}),i}(Bt),ce=function(t){function e(e){var i,n,r=this;return e.renderOrder=null!==(i=e.renderOrder)&&void 0!==i?i:e.tilemapData.renderorder,(r=t.call(this,e)||this).type=Ft.TiledTilemapRenderer,r.tiledTilemap=e.tilemapData,r.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,r}return l(e,t),e.prototype.processTilemap=function(){var t=this;this.tiledTilemap.layers.forEach((function(e){var i,n,r;!0!==e.visible||null!==t.layerName&&t.layerName!==e.name||(t.renderData.has(e.name)||t.processLayer({layer:e.name,alpha:e.opacity,tintColor:null!==(i=e.tintcolor)&&void 0!==i?i:null}),!0===t.tiledTilemap.infinite?e.chunks.forEach((function(i){var n,r;return t.processChunk(e.name,i,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0})})):t.processChunk(e.name,e,{x:null!==(n=e.offsetx)&&void 0!==n?n:0,y:null!==(r=e.offsety)&&void 0!==r?r:0}))})),this.tilemapProcessed=!0},e.prototype.processChunk=function(t,e,i){void 0===i&&(i={x:0,y:0});for(var n=0,r=0;r<e.height;r++)for(var o=0;o<e.width;o++){var a=this.tileset.getTile(e.data[n]-1);this.processTile({layer:t,tile:a,col:o+e.x,row:r+e.y,flip:{h:!1,v:!1},offset:i}),n++}},e}(ue),pe=1,de=2,fe=3,ge=function(t){function e(e){var i,n,r=t.call(this,e)||this;return r.alpha=1,r.tintColor=null,r.type=Ft.CsvTilemapRenderer,r.tilemapData=e.tilemapData,r.alpha=null!==(i=e.alpha)&&void 0!==i?i:r.alpha,r.tintColor=null!==(n=e.tintColor)&&void 0!==n?n:r.tintColor,r}return l(e,t),e.prototype.processTilemap=function(){var t=this;this.processLayer({layer:"csv",alpha:this.alpha,tintColor:this.tintColor}),this.tilemapData.trim().split("\n").forEach((function(e,i){e.split(",").forEach((function(e,n){var r=parseInt(e.trim()),o=null,a={h:!1,v:!1};if(!1===isNaN(r)){var s=r>999?r%1e3:r,h=Math.round(r/1e3);o=t.tileset.getTile(s),a.h=[pe,fe].includes(h),a.v=[de,fe].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:a,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(ue),me=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},ye=function(){function e(e){var i,n;this.image=null,this.offset=new t(0,0),this.tileSpacing=new t(0,0),this._tiles=[],this.image=e.image,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.gridWidth=e.gridWidth,this.gridHeight=e.gridHeight,this.offset=null!==(i=e.offset)&&void 0!==i?i:this.offset,this.tileSpacing=null!==(n=e.spacing)&&void 0!==n?n:this.tileSpacing,this.generateTiles()}return e.prototype.generateTiles=function(){for(var t=0,e=0;e<this.gridHeight;e++)for(var i=0;i<this.gridWidth;i++)this._tiles[t]=new me(i*this.tileWidth+i*this.tileSpacing.x+this.offset.x,e*this.tileHeight+e*this.tileSpacing.y+this.offset.y,this.tileWidth,this.tileHeight),t++},e.prototype.getTile=function(t){return this._tiles[t]?this._tiles[t]:null},Object.defineProperty(e.prototype,"tiles",{get:function(){return this._tiles},enumerable:!1,configurable:!0}),e}(),be=function(t){var e,i;this.sprites=[],this.framerate=10,this.loop=!1,this.sprites=t.sprites,this.framerate=null!==(e=t.framerate)&&void 0!==e?e:this.framerate,this.loop=null!==(i=t.loop)&&void 0!==i?i:this.loop},xe=function(t){function e(e){var i=t.call(this)||this;return i.timeManager=_t.getSingleton("TimeManager"),i.spriteRenderer=null,i.animations=new Map,i.currentAnimation=null,i.type=Ft.Animator,i.spriteRenderer=e.spriteRenderer,i}return l(e,t),e.prototype.update=function(){null!==this.currentAnimation&&(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.stopAnimation():this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return i&&(e.framerate=i),this.animations.set(t,new ve(e)),this},e.prototype.playAnimation=function(t){if(!1!==this.active){if(!1===this.animations.has(t))throw new b("Animation with name "+t+" does not exist.");this.currentAnimation=this.animations.get(t)}},e.prototype.stopAnimation=function(){!1!==this.active&&null!==this.currentAnimation&&(this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(Pt),ve=function(){function t(t){this._sprite=null,this._restarted=!1,this.currentFrame=0,this.frameTime=0,this._animation=t}return Object.defineProperty(t.prototype,"sprite",{get:function(){return this._sprite},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"restarted",{get:function(){return this._restarted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this._animation.loop},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),t.prototype.playFrame=function(t){this._restarted=!1,this.frameTime>=1/this._animation.framerate&&(this.frameTime=0,this.currentFrame=this.currentFrame+1===this._animation.sprites.length?0:this.currentFrame+1,this._restarted=0===this.currentFrame),this._sprite=this._animation.sprites[this.currentFrame],this.frameTime+=t},t}(),Me=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],_e=function(t){function e(e){var i,n,r;void 0===e&&(e={audio:null,volume:1,loop:!1});var o=t.call(this)||this;return o.volume=1,o.loop=!1,o.audio=null,o.clones=new Map,o._playing=!1,o._paused=!1,o.audioEventHandler=function(t){"ended"===t.type&&(o._playing=!1,o.audio.removeEventListener("ended",o.audioEventHandler))},o.userinputEventHandler=function(){Me.forEach((function(t){window.removeEventListener(t,o.userinputEventHandler)})),o.audio.play()},o.allowMultiple=!1,o.type=Ft.AudioPlayer,o.audio=null!==(i=e.audio)&&void 0!==i?i:o.audio,o.volume=null!==(n=e.volume)&&void 0!==n?n:o.volume,o.loop=null!==(r=e.loop)&&void 0!==r?r:o.loop,o}return l(e,t),e.prototype.playAudio=function(t,e){void 0===e&&(e=null),!1===this.clones.has(Symbol.for(t.src))&&this.cloneAudio(t);var i=this.clones.get(Symbol.for(t.src));i.currentTime>0&&(i.currentTime=0),i.volume=null!=e?e:this.volume,i.play()},e.prototype.cloneAudio=function(t){var e=t.cloneNode();this.clones.set(Symbol.for(t.src),e)},e.prototype.play=function(){var t=this;if(null!==this.audio&&(!this._playing||!1!==this._paused)){if(this._paused)return this._paused=!1,void this.audio.play();this.audio.volume=this.volume,this.audio.loop=this.loop,this.audio.addEventListener("ended",this.audioEventHandler),this._playing=!0,this.audio.play().then((function(){})).catch((function(){return Me.forEach((function(e){return window.addEventListener(e,t.userinputEventHandler)}))}))}},e.prototype.stop=function(){this._playing&&(this.audio.pause(),this.audio.currentTime=0,this.audio.removeEventListener("ended",this.audioEventHandler),this._playing=!1,this._paused=!1)},e.prototype.pause=function(){this._playing&&!1===this._paused&&(this.audio.pause(),this._paused=!0)},e.prototype.activeStateChange=function(){!1===this.active&&this.stop()},e.prototype.destroy=function(){this.stop()},e}(Pt),we=function(e){function i(i){var n,r,o=e.call(this)||this;return o.rigidBodyManager=_t.getSingleton("RigidBodyManager"),o.type=Ft.RigidBody,o.allowMultiple=!1,o.rigidBodyType=i.rigidBodyType,o.data={position:null,gravity:null!==(n=Math.abs(i.gravity))&&void 0!==n?n:10,velocity:new t,layersToCollider:null!==(r=i.layersToCollide)&&void 0!==r?r:[],colliders:[]},o}return l(i,e),Object.defineProperty(i.prototype,"velocity",{get:function(){return this.data.velocity},set:function(t){this.data.velocity.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gravity",{get:function(){return this.data.gravity},set:function(t){this.data.gravity=Math.abs(t)},enumerable:!1,configurable:!0}),i.prototype.start=function(){if(0===this.getColliders().length)throw new b("RigidBody needs at least one Collider with physics");this.data.position=this.gameObject.transform.position},i.prototype.update=function(){this.data.colliders=this.getColliders(),this.rigidBodyType===tt.Dynamic&&this.rigidBodyManager.addRigidBodyData(this.data)},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Wt&&e.physics?f(f([],t,!0),e.colliders,!0):t}),[])},i}(Pt),Oe=function(){function e(e){var i,n,r,o,a=this;this._image=null,this._slice=null,this._scale=null!==(i=_t.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),this._smooth=!1,this._width=null,this._height=null,this._loaded=!1,this._image=e.image,this._slice=null!==(n=e.slice)&&void 0!==n?n:this._slice,null!==this._slice&&(this._width=this._slice.width,this._height=this._slice.height),this._scale=null!==(r=e.scale)&&void 0!==r?r:this._scale,this._smooth=null!==(o=e.smooth)&&void 0!==o?o:this._smooth,this._image.naturalWidth?this.onLoad():this._image.addEventListener("load",(function(){return a.onLoad()}))}return Object.defineProperty(e.prototype,"loaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"slice",{get:function(){return this._slice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"smooth",{get:function(){return this._smooth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.onLoad=function(){var t,e;this._width=(null!==(t=this._width)&&void 0!==t?t:this._image.naturalWidth)*this._scale.x,this._height=(null!==(e=this._height)&&void 0!==e?e:this._image.naturalHeight)*this._scale.y,this._loaded=!0},e}(),je=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return l(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){lt.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,lt.mouse.positionInViewport,1/this.camera.zoom),t.add(this.position,this.position,this.camera.worldSpaceRect.center),t.round(this.position,this.position),console.log("Space position: {x: "+this.position.x+", y: "+this.position.y+"}")),this.mousePressed=lt.mouse.leftButtonPressed},i}(Gt);export{be as Animation,xe as Animator,st as AssetManager,_e as AudioPlayer,Qt as BoxCollider,Lt as Camera,qt as ColliderData,ft as CollisionMethodConfig,Ct as Component,Ft as ComponentTypes,ge as CsvTilemapRenderer,ht as DomManager,Nt as GAME_CAMERA_ID,Ot as Game,kt as GameCamera,Gt as GameObject,pt as GameObjectManager,j as GamepadController,C as GamepadData,lt as InputManager,R as KeyboardController,It as LAYER_DEFAULT,ae as MaskRenderer,S as MouseController,St as PhysicsComponent,Zt as PolygonCollider,Dt as PreRenderComponent,e as Rectangle,we as RigidBody,tt as RigidBodyType,s as Rotation,zt as Scene,ut as SceneManager,je as SpacePointer,Oe as Sprite,ie as SpriteRenderer,re as TextRenderer,ce as TiledTilemapRenderer,$t as TilemapCollider,ye as Tileset,ct as TimeManager,nt as TouchController,Et as Transform,t as Vector2,a as between,i as clamp,r as fixedRound,n as random,o as range};
|