angry-pixel 1.1.0 → 1.1.1
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/ComponentTypes.d.ts +2 -0
- package/lib/component/collider/BallCollider.d.ts +26 -0
- package/lib/component/collider/Collider.d.ts +1 -1
- package/lib/component/collider/EdgeCollider.d.ts +31 -0
- package/lib/component/collider/PolygonCollider.d.ts +0 -1
- package/lib/component/colliderComponent/AbstractColliderComponent.d.ts +10 -15
- package/lib/component/colliderComponent/BoxCollider.d.ts +1 -3
- package/lib/component/colliderComponent/TilemapCollider.d.ts +0 -2
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/physics/collision/CollisionManager.d.ts +4 -4
- package/lib/physics/collision/collider/ICollider.d.ts +0 -1
- package/lib/physics/collision/collider/RectangleCollider.d.ts +1 -2
- package/lib/physics/collision/method/AABBMethod.d.ts +13 -0
- package/lib/physics/collision/method/CollisionMethod.d.ts +5 -0
- package/lib/physics/collision/method/SatMethod.d.ts +11 -0
- package/lib/physics/collision/resolver/AABBResolver.d.ts +3 -4
- package/lib/physics/collision/resolver/CircumferenceAABBResolver.d.ts +9 -0
- package/lib/physics/collision/resolver/CircumferenceCircumferenceResolver.d.ts +7 -0
- package/lib/physics/collision/resolver/CircumferencePolygonResolver.d.ts +23 -0
- package/lib/physics/collision/resolver/CircumferenceRectangleResolver.d.ts +9 -0
- package/lib/physics/collision/resolver/CircumferenceResolver.d.ts +7 -0
- package/lib/physics/collision/resolver/CollisionResolver.d.ts +7 -2
- package/lib/physics/collision/resolver/PolygonPolygonResolver.d.ts +15 -0
- package/lib/physics/collision/resolver/RectangleRectangleResolver.d.ts +11 -0
- package/lib/physics/collision/resolver/SatResolver.d.ts +6 -3
- package/lib/physics/collision/shape/Circumference.d.ts +18 -0
- package/lib/physics/collision/shape/Line.d.ts +19 -0
- package/lib/physics/collision/shape/Shape.d.ts +1 -1
- package/lib/physics/rigodBody/RigidBodyData.d.ts +1 -0
- package/lib/rendering/CullingService.d.ts +1 -1
- package/lib/rendering/context2D/Context2DRenderer.d.ts +1 -0
- package/lib/rendering/renderData/GeometricRenderData.d.ts +11 -6
- package/lib/rendering/renderData/RenderData.d.ts +3 -3
- package/lib/rendering/renderData/TilemapRenderData.d.ts +7 -1
- package/lib/rendering/webGL/renderer/GeometricRenderer.d.ts +5 -4
- package/package.json +1 -1
package/lib/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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(){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}(),n=function(t,e){return n=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])},n(t,e)};function r(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}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var o,a=function(){return a=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},a.apply(this,arguments)};function s(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 h(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 l(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"}(o||(o={}));var u,c=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},p=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,o.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,o.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,o.Image)},t.prototype.getVideo=function(t){return this.getAsset(t,o.Video)},t.prototype.getAudio=function(t){return this.getAsset(t,o.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 c;return i.type=e,i.url=t,this.assets.push(i),i},t}(),d=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return r(e,t),e}(Error),f=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 d("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 d("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}(),g=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 f(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 d("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"}(u||(u={}));var y,b=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 l(l([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.mainIteration=function(){this.dispatchFrameEvent(u.Start),this.inputManager.update(),this.dispatchFrameEvent(u.Update),this.dispatchFrameEvent(u.UpdateEngine),this.dispatchFrameEvent(u.UpdateTransform)},t.prototype.physicsIteration=function(){this.dispatchFrameEvent(u.UpdatePhysics),this.dispatchFrameEvent(u.UpdateCollider),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear()},t.prototype.preRenderIteration=function(){this.physicsManager.clear(),this.dispatchFrameEvent(u.UpdateTransform),this.dispatchFrameEvent(u.UpdatePreRender),this.dispatchFrameEvent(u.UpdateCamera)},t.prototype.renderIteration=function(){this.dispatchFrameEvent(u.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.dispatchFrameEvent=function(t){t!==u.Start&&t!==u.Update||(this.currentScene.dispatch(t),this.gameObjects.forEach((function(e){return e.dispatch(t)}))),this.components.forEach((function(e){return e.dispatch(t)}))},t}(),x=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 d("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(u.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(u.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){e.destroyChildren(t),e.destroyGameObject(t)}))},t}(),v=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 M),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}(),M=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}(),_=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}(),w=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}(),O=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"}(y||(y={}));var j=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}(),C=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===y.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}(),P="undefined"!=typeof Float32Array?Float32Array:Array;function R(){var t=new P(16);return P!=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 T(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 S(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 D(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 A(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 B(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 E,F=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},I=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=R(),this.modelMatrix=R(),this.textureMatrix=R(),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=T(this.modelMatrix),S(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),A(this.modelMatrix,this.modelMatrix,i.rotation),D(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=T(this.textureMatrix),i.slice&&(S(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),D(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=T(this.projectionMatrix),B(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=F(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=F(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}(),G=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 d("Unable to initialize the Program: "+o)}},t}(),U=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 d("Unable to initialize the shader program: "+o)}return n},t}(),V=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"}(E||(E={}));var L,k=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=F(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===y.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===y.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===y.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===y.Collider&&(this.geometricRenderer.renderCollider(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===y.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}(),N=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 d("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 d("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new d("Game not initialized.");if(!1===this.scenes.has(t))throw new d("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(u.Init)},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(u.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager.clearData())},t}(),z=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 d("Physics framerate cannot be less than 60");if(t%60!=0)throw new d("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}(),W=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}(),H=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===E.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}(),q=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 Y(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 s(this,void 0,void 0,(function(){var i;return h(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}(),Y=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},X=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=R(),this.modelMatrix=R(),this.textureMatrix=R()}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=T(this.modelMatrix),S(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),A(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=T(this.textureMatrix),D(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=T(this.projectionMatrix),B(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=F(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"}(L||(L={}));var Q,K=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=R(),this.modelMatrix=R(),this.textureMatrix=R()}return t.prototype.renderCollider=function(t,e,i){this.lastRender=i,e.shape.type===L.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=T(this.modelMatrix),S(this.modelMatrix,this.modelMatrix,[e.x,e.y,0]),A(this.modelMatrix,this.modelMatrix,r),this.projectionMatrix=T(this.projectionMatrix),B(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=F(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}(),$=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=l(l([],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}(),J=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}(),Z=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}(),tt=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 y.Image:return i.cullSprite(n,e);case y.Tilemap:return i.cullTilemap(n,e);case y.Collider:return i.cullCollider(n,e);case y.Text:return i.cullText(n,e);case y.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}(),et=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=R(),this.modelMatrix=R(),this.textureMatrix=R()}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=T(this.modelMatrix),this.textureMatrix=T(this.textureMatrix),D(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=T(this.projectionMatrix),B(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=F(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}(),it=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}(),nt=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}(),rt=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}(),ot=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}(),at=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}(),st=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}(),ht=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=R(),this.modelMatrix=R(),this.textureMatrix=R()}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=T(this.modelMatrix),S(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),A(this.modelMatrix,this.modelMatrix,e.rotation),D(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=T(this.projectionMatrix),B(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=F(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}();exports.RigidBodyType=void 0,(Q=exports.RigidBodyType||(exports.RigidBodyType={}))[Q.Static=0]="Static",Q[Q.Dynamic=1]="Dynamic";var lt,ut=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}(),ct=function(t,e){if(e.collisions.method===exports.CollisionMethodConfig.AABB)t.add("CollisionResolver",(function(){return new Z}));else{if(e.collisions.method!==exports.CollisionMethodConfig.SAT)throw new d("Invalid collision method.");t.add("CollisionResolver",(function(){return new $}))}t.add("CollisionManager",(function(){return new g(t.getSingleton("CollisionResolver"),e.collisions.quadTreeBounds,e.collisions.quadMaxLevel,e.collisions.collidersPerQuad)})),t.add("RigidBodyManager",(function(){return new ut(t.getSingleton("CollisionManager"))}))},pt=function(t,e,i){var n=gt();if(null===n)throw new d("WebGL not suported in your browser.");dt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new q})),t.add("CullingService",(function(){return new tt})),t.add("RenderManager",(function(){return new C(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},dt=function(t,e,i){e.add("ShaderLoader",(function(){return new U})),e.add("ProgramFactory",(function(){return new G(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new H(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new V(t,i.canvas)})),e.add("TextureManager",(function(){return new W(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new I(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new X(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new K(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new et(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new ht(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new k(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"))}))},ft=function(t,e){t.add("Mouse",(function(){return new O(e.canvas)})),t.add("Keyboard",(function(){return new w(e.canvas)})),t.add("Gamepad",(function(){return new v})),t.add("Touch",(function(){return new J(e.canvas)})),t.add("InputManager",(function(){return new _(t.getSingleton("Mouse"),t.getSingleton("Keyboard"),t.getSingleton("Gamepad"),t.getSingleton("Touch"))}))},gt=function(){return null!==document.createElement("canvas").getContext(E.WebGL2)?E.WebGL2:null!==document.createElement("canvas").getContext(E.LegacyWebGL)?E.LegacyWebGL:null},mt=function(t){it.initialize(t.getSingleton("AssetManager")),nt.initialize(t.getSingleton("DomManager")),rt.initialize(t.getSingleton("InputManager")),ot.initialize(t.getSingleton("SceneManager")),at.initialize(t.getSingleton("TimeManager")),st.initialize(t.getSingleton("GameObjectManager"))},yt=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 d("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 d("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 d("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new d("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 d("Invalid constant name: "+t);return this.constants.get(t)},t}());exports.CollisionMethodConfig=void 0,(lt=exports.CollisionMethodConfig||(exports.CollisionMethodConfig={})).AABB="aabb",lt.SAT="sat";var bt={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:240,collisions:{method:exports.CollisionMethodConfig.AABB,quadTreeBounds:null,quadMaxLevel:6,collidersPerQuad:15}},xt=function(){function t(t){this._running=!1,this._stop=!1,this.frameRequestId=null,this._config=a(a({},bt),t),this._config.collisions=a(a({},bt.collisions),t.collisions),yt.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 z(e.physicsFramerate)})),pt(t,e,i),ft(t,i),ct(t,e),t.add("SceneManager",(function(){return new N(t.getConstant("Game"),t.getSingleton("RenderManager"))})),t.add("GameObjectManager",(function(){return new x})),t.add("AssetManager",(function(){return new p})),t.add("IterationManager",(function(){return new b(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})),mt(t)}(yt,this._config),this.renderManager=yt.getSingleton("RenderManager"),this.sceneManager=yt.getSingleton("SceneManager"),this.iterationManager=yt.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}(),vt=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)}))},Mt=function(){function t(){this.sceneManager=yt.getSingleton("SceneManager"),this.gameObjectManager=yt.getSingleton("GameObjectManager"),this.id=vt(),this.allowMultiple=!0,this._active=!0,this.started=!1}return Object.defineProperty(t.prototype,"updateEvent",{get:function(){return u.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===u.Init?this.init():t===u.Start&&!1===this.started?(this.start(),this.started=!0):t===this.updateEvent&&!0===this.started?this.update():t===u.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}(),_t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdateEngine},enumerable:!1,configurable:!0}),e}(Mt),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdateCollider},enumerable:!1,configurable:!0}),e}(Mt),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdatePhysics},enumerable:!1,configurable:!0}),e}(Mt),jt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdateTransform},enumerable:!1,configurable:!0}),e}(Mt),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdatePreRender},enumerable:!1,configurable:!0}),e}(Mt),Pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdateCamera},enumerable:!1,configurable:!0}),e}(Mt),Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return u.UpdateRender},enumerable:!1,configurable:!0}),e}(Mt),Tt={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"},St=function(e){function n(){var n=e.call(this)||this;return n._position=new t,n._scale=new t(1,1),n._rotation=new i,n._innerPosition=new t,n._parent=null,n.parentScale=!0,n.parentRotation=!0,n.cache=new t,n.lastParentRadians=0,n.lastPosition=new t,n.scaledInnerPosition=new t,n.allowMultiple=!1,n.type=Tt.Transform,n}return r(n,e),Object.defineProperty(n.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,null!==this._parent&&this.updateInnerPositionFromParent()},enumerable:!1,configurable:!0}),n.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)},n.prototype.updateInnerPositionFromParent=function(){t.subtract(this._innerPosition,this._position,this._parent.position)},n.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)},n.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)},n.prototype.updateScaledInnerPosition=function(){this.scaledInnerPosition.set(this._innerPosition.x*this._parent.scale.x,this._innerPosition.y*this._parent.scale.y)},n}(jt),Dt=function(){function t(){this.id=vt(),this.layer="Default",this.ui=!1,this.keep=!1,this._active=!0,this._parent=null,this.started=!1,this.sceneManager=yt.getSingleton("SceneManager"),this.gameObjectManager=yt.getSingleton("GameObjectManager"),this.components=[],this.addComponent((function(){return new St}))}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(Tt.Transform)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigidBody",{get:function(){return this.getComponentByType(Tt.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===u.Init?this.init():t===u.Start&&!1===this.started?(this.start(),this.started=!0):t===u.Update&&this.started?this.update():t===u.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(u.Init),this.components.push(i),i},t.prototype.checkMultipleComponent=function(t){if(!1===t.allowMultiple&&this.hasComponentOfType(t.type))throw new d("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(u.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(u.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(u.Destroy),delete this.components[t];this.components=[]},t}(),At=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},Bt=["Default"],Et=function(t){function i(){var i=t.call(this)||this;return i.renderManager=yt.getSingleton("RenderManager"),i.domManager=yt.getSingleton("DomManager"),i._layers=Bt,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 At,i.allowMultiple=!1,i.type=Tt.Camera,i.canvas=i.domManager.canvas,i}return r(i,t),Object.defineProperty(i.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=l(l([],Bt,!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 d("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}(Pt),Ft=function(t){function e(){var e=t.call(this)||this;return e.transform.position.set(0,0),e.camera=e.addComponent((function(){return new Et})),e}return r(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}(Dt),It=function(){function t(){this.gameObjectManager=yt.getSingleton("GameObjectManager"),this.game=null,this.name=null,this.started=!1,this.addGameObject((function(){return new Ft}),"GameCamera")}return Object.defineProperty(t.prototype,"gameCamera",{get:function(){return this.findGameObjectByName("GameCamera")},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){t===u.Init?this.init():t!==u.Start||this.started?t===u.Update&&this.started?this.update():t===u.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}(),Gt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=yt.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return r(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}(wt),Ut=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=y.Collider,e.color=null,e.shape=null,e}return r(e,t),e}(j),Vt=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}(),Lt=function(){function i(i){this._type=L.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}(),kt=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 r(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}(Lt),Nt=function(e){function n(n){var r,o,a,s,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=yt.getConstant("GameConfig").collisions.method===exports.CollisionMethodConfig.SAT,l.innerPosition=new t,l.type=Tt.BoxCollider,l.width=n.width,l.height=n.height,l.offsetX=null!==(r=n.offsetX)&&void 0!==r?r:l.offsetX,l.offsetY=null!==(o=n.offsetY)&&void 0!==o?o:l.offsetY,l.physics=null!==(a=n.physics)&&void 0!==a?a:l.physics,l.debug=(null!==(s=n.debug)&&void 0!==s?s:l.debug)&&yt.getConstant("GameConfig").debugEnabled,l.rotation=null!==(h=n.rotation)&&void 0!==h?h:new i,l.layer=n.layer,l}return r(n,e),n.prototype.start=function(){var t,e=this;this.colliders.push(new Vt(new kt(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(Tt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new zt(e.colliders[0])})))},n.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},n.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},n.prototype.updatePosition=function(){t.add(this.realPosition,this.gameObject.transform.position,this.realOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},n.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))},n.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()},n}(Gt),zt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=yt.getSingleton("RenderManager"),i.type="BoxColliderRenderer",i.renderData=new Ut,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return r(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}(Rt),Wt=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=Tt.TilemapCollider,r.tilemapRenderer=i.tilemapRenderer,r.layer=i.layer,r.debug=(null!==(n=i.debug)&&void 0!==n?n:r.debug)&&yt.getConstant("GameConfig").debugEnabled,r.physics=!0,r.cacheVertex=[new t,new t,new t,new t],r}return r(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 Vt(new kt(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponentOfType(Tt.RigidBody)))})),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Ht(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}(Gt),Ht=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=yt.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="TilemapColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new Ut,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00"})),i}return r(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}(Rt),qt=function(e){function n(n){var r,o,a,s,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=yt.getConstant("GameConfig").collisions.method===exports.CollisionMethodConfig.SAT,l.innerPosition=new t,l.type=Tt.PolygonCollider,l.debug=(null!==(r=n.debug)&&void 0!==r?r:l.debug)&&yt.getConstant("GameConfig").debugEnabled,l.vertexModel=n.vertexModel,l.offsetX=null!==(o=n.offsetX)&&void 0!==o?o:l.offsetX,l.offsetY=null!==(a=n.offsetY)&&void 0!==a?a:l.offsetY,l.physics=null!==(s=n.physics)&&void 0!==s?s:l.physics,l.rotation=null!==(h=n.rotation)&&void 0!==h?h:new i,l.layer=n.layer;for(var u=0;u<l.vertexModel.length;u++)l.scaledVertexModel.push(new t);return l}return r(n,e),n.prototype.start=function(){var t,e=this;this.colliders.push(new Vt(new Lt(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Tt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Yt(e.colliders[0])})))},n.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},n.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},n.prototype.updatePosition=function(){t.add(this.scaledPosition,this.gameObject.transform.position,this.scaledOffset),0!==this.gameObject.transform.rotation.radians&&this.translate()},n.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))},n.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()},n}(Gt),Yt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=yt.getSingleton("RenderManager"),i.type="PolygonColliderRenderer",i.renderData=new Ut,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return r(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}(Rt),Xt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=y.Image,e}return r(e,t),e}(j),Qt=function(e){function n(n){var r,o,a,s,h,l,u,c,p,d,f;void 0===n&&(n={sprite:null});var g=e.call(this)||this;return g.renderManager=yt.getSingleton("RenderManager"),g.sprite=null,g.offset=new t,g.flipHorizontal=!1,g.flipVertical=!1,g.rotation=new i,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=Tt.SpriteRenderer,g.sprite=n.sprite,g.offset=null!==(r=n.offset)&&void 0!==r?r:g.offset,g.smooth=null!==(o=n.smooth)&&void 0!==o?o:g.smooth,g.rotation=null!==(a=n.rotation)&&void 0!==a?a:g.rotation,g.flipHorizontal=null!==(s=n.flipHorizontal)&&void 0!==s?s:g.flipHorizontal,g.flipVertical=null!==(h=n.flipVertical)&&void 0!==h?h:g.flipVertical,g.opacity=null!==(l=n.opacity)&&void 0!==l?l:g.opacity,g.tiled=null!==(u=n.tiled)&&void 0!==u?u:g._tiled,g.maskColor=null!==(c=n.maskColor)&&void 0!==c?c:g.maskColor,g.maskColorMix=null!==(p=n.maskColorMix)&&void 0!==p?p:g.maskColorMix,g.tintColor=null!==(d=n.tintColor)&&void 0!==d?d:g.tintColor,g.layer=null!==(f=n.layer)&&void 0!==f?f:g.layer,g}return r(n,e),Object.defineProperty(n.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new d("SpriteRenderer.tiled: Vector2 components must be integers");this._tiled.set(t.x,t.y)},enumerable:!1,configurable:!0}),n.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++}},n.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 Xt}},n.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])},n.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)},n.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))},n}(Rt),Kt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=y.Text,e}return r(e,t),e}(j),$t=function(e){function n(n){var r,o,a,s,h,l,u,c,p,f,g,m,y,b,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 i,v.opacity=1,v.orientation="center",v.renderManager=yt.getSingleton("RenderManager"),v.renderData=new Kt,v.lastFrameText="",v.type=Tt.TextRenderer,v.text=n.text,v.fontFamily=n.fontFamily,v.fontUrl=null!==(r=n.fontUrl)&&void 0!==r?r:v.fontUrl,v.fontSize=null!==(o=n.fontSize)&&void 0!==o?o:v.fontSize,v.width=null!==(a=n.width)&&void 0!==a?a:v.width,v.height=null!==(s=n.height)&&void 0!==s?s:v.height,v.offset=null!==(h=n.offset)&&void 0!==h?h:v.offset,v.color=null!==(l=n.color)&&void 0!==l?l:v.color,v.lineSeparation=null!==(u=n.lineSeparation)&&void 0!==u?u:v.lineSeparation,v.letterSpacing=null!==(c=n.letterSpacing)&&void 0!==c?c:v.letterSpacing,v.bitmapSize=null!==(p=n.bitmapSize)&&void 0!==p?p:v.bitmapSize,v.charRanges=null!==(f=n.charRanges)&&void 0!==f?f:v.charRanges,v.smooth=null!==(g=n.smooth)&&void 0!==g?g:v.smooth,v.bitmapOffset=null!==(m=n.bitmapOffset)&&void 0!==m?m:v.bitmapOffset,v.rotation=null!==(y=n.rotation)&&void 0!==y?y:v.rotation,v.opacity=null!==(b=n.opacity)&&void 0!==b?b:v.opacity,v.orientation=null!==(x=n.orientation)&&void 0!==x?x:v.orientation,v.charRanges.length%2!=0)throw new d("TextRenderer.charRanges must be a 2 column matrix");if(v.lineSeparation%2!=0)throw new d("TextRenderer.lineSeparation must be multiple of 2");return v}return r(n,e),n.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},n.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)},n.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")},n}(Rt),Jt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=y.Mask,e}return r(e,t),e}(j),Zt=function(e){function n(n){var r,o,a,s,h=e.call(this)||this;return h.renderManager=yt.getSingleton("RenderManager"),h.offset=new t,h.rotation=new i,h.opacity=1,h.renderData=new Jt,h.innerPosition=new t,h.scaledOffset=new t,h.type=Tt.MaskRenderer,h.width=n.width,h.height=n.height,h.color=n.color,h.offset=null!==(r=n.offset)&&void 0!==r?r:h.offset,h.rotation=null!==(o=n.rotation)&&void 0!==o?o:h.rotation,h.opacity=null!==(a=n.opacity)&&void 0!==a?a:h.opacity,h.layer=null!==(s=n.layer)&&void 0!==s?s:h.layer,h}return r(n,e),n.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)},n.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()},n.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))},n}(Rt),te=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}(),ee=function(){this.position=new t,this.positionInViewport=new t},ie=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=y.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return r(e,t),e}(j),ne=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=yt.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=yt.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 r(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 ie;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 ee;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 te(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}(Rt),re=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=Tt.TiledTilemapRenderer,r.tiledTilemap=e.tilemapData,r.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,r}return r(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}(ne),oe=1,ae=2,se=3,he=function(t){function e(e){var i,n,r=t.call(this,e)||this;return r.alpha=1,r.tintColor=null,r.type=Tt.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 r(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=[oe,se].includes(h),a.v=[ae,se].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:a,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(ne),le=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},ue=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 le(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}(),ce=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},pe=function(t){function e(e){var i=t.call(this)||this;return i.timeManager=yt.getSingleton("TimeManager"),i.spriteRenderer=null,i.animations=new Map,i.currentAnimation=null,i.type=Tt.Animator,i.spriteRenderer=e.spriteRenderer,i}return r(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 de(e)),this},e.prototype.playAnimation=function(t){if(!1!==this.active){if(!1===this.animations.has(t))throw new d("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}(_t),de=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}(),fe=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],ge=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(){fe.forEach((function(t){window.removeEventListener(t,o.userinputEventHandler)})),o.audio.play()},o.allowMultiple=!1,o.type=Tt.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 r(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 fe.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}(_t),me=function(e){function i(i){var n,r,o=e.call(this)||this;return o.rigidBodyManager=yt.getSingleton("RigidBodyManager"),o.type=Tt.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 r(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 d("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===exports.RigidBodyType.Dynamic&&this.rigidBodyManager.addRigidBodyData(this.data)},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Gt&&e.physics?l(l([],t,!0),e.colliders,!0):t}),[])},i}(_t),ye=function(){function e(e){var i,n,r,o,a=this;this._image=null,this._slice=null,this._scale=null!==(i=yt.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}(),be=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return r(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){rt.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,rt.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=rt.mouse.leftButtonPressed},i}(Dt);exports.Animation=ce,exports.Animator=pe,exports.AssetManager=it,exports.AudioPlayer=ge,exports.BoxCollider=Nt,exports.Camera=Et,exports.ColliderData=Vt,exports.Component=Mt,exports.ComponentTypes=Tt,exports.CsvTilemapRenderer=he,exports.DomManager=nt,exports.GAME_CAMERA_ID="GameCamera",exports.Game=xt,exports.GameCamera=Ft,exports.GameObject=Dt,exports.GameObjectManager=st,exports.GamepadController=v,exports.GamepadData=M,exports.InputManager=rt,exports.KeyboardController=w,exports.LAYER_DEFAULT="Default",exports.MaskRenderer=Zt,exports.MouseController=O,exports.PhysicsComponent=Ot,exports.PolygonCollider=qt,exports.PreRenderComponent=Ct,exports.Rectangle=e,exports.RigidBody=me,exports.Rotation=i,exports.Scene=It,exports.SceneManager=ot,exports.SpacePointer=be,exports.Sprite=ye,exports.SpriteRenderer=Qt,exports.TextRenderer=$t,exports.TiledTilemapRenderer=re,exports.TilemapCollider=Wt,exports.Tileset=ue,exports.TimeManager=at,exports.TouchController=J,exports.Transform=St,exports.Vector2=t,exports.between=function(t,e,i){return t>=e&&t<=i},exports.clamp=function(t,e,i){return Math.min(i,Math.max(e,t))},exports.fixedRound=function(t,e){return Math.round(t*(10^e))/(10^e)},exports.random=function(t,e){return Math.floor(Math.random()*(e-t))+t},exports.range=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},r=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}(),o=function(t,e){return o=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])},o(t,e)};function a(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}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var s,h=function(){return h=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},h.apply(this,arguments)};function l(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 c(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 u(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"}(s||(s={}));var p,d=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},f=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,s.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,s.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,s.Image)},t.prototype.getVideo=function(t){return this.getAsset(t,s.Video)},t.prototype.getAudio=function(t){return this.getAsset(t,s.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 d;return i.type=e,i.url=t,this.assets.push(i),i},t}(),g=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return a(e,t),e}(Error),m=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 g("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 g("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}(),y=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.method=i,this.colliders=[],this.fixedQuadTree?this.bounds=n:this.bounds=new e(0,0,0,0),this.quadTree=new m(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.method.getCollisionResolution(t.shape,e.shape);null!==r&&n.push({localCollider:t,remoteCollider:e,resolution:r})})),n},i}(),b=function(){function t(t,e,i){if(this._canvas=null,!t)throw new g("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"}(p||(p={}));var x,v=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 u(u([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.mainIteration=function(){this.physicsManager.clear(),this.dispatchFrameEvent(p.Start),this.inputManager.update(),this.dispatchFrameEvent(p.Update),this.dispatchFrameEvent(p.UpdateEngine),this.dispatchFrameEvent(p.UpdateTransform)},t.prototype.physicsIteration=function(){this.dispatchFrameEvent(p.UpdatePhysics),this.dispatchFrameEvent(p.UpdateCollider),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear()},t.prototype.preRenderIteration=function(){this.dispatchFrameEvent(p.UpdateTransform),this.dispatchFrameEvent(p.UpdatePreRender),this.dispatchFrameEvent(p.UpdateCamera)},t.prototype.renderIteration=function(){this.dispatchFrameEvent(p.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.dispatchFrameEvent=function(t){t!==p.Start&&t!==p.Update||(this.currentScene.dispatch(t),this.gameObjects.forEach((function(e){return e.dispatch(t)}))),this.components.forEach((function(e){return e.dispatch(t)}))},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 g("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(p.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(p.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){e.destroyChildren(t),e.destroyGameObject(t)}))},t}(),w=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 _),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}(),_=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}(),O=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}(),j=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}(),C=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.Tilemap=2]="Tilemap",t[t.Mask=3]="Mask",t[t.Geometric=4]="Geometric"}(x||(x={}));var P=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}(),R=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===x.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}(),D="undefined"!=typeof Float32Array?Float32Array:Array;function S(){var t=new D(16);return D!=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 T(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 B(t,e,i){var n,r,o,a,s,h,l,c,u,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],c=e[7],u=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]=c,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+s*m+u*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+c*m+f*y+e[15]),t}function A(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 E(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],c=e[5],u=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+c*n,t[2]=s*r+u*n,t[3]=h*r+p*n,t[4]=l*r-o*n,t[5]=c*r-a*n,t[6]=u*r-s*n,t[7]=p*r-h*n,t}function F(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 I,G=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},V=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S(),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=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),E(this.modelMatrix,this.modelMatrix,i.rotation),A(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=T(this.textureMatrix),i.slice&&(B(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),A(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=T(this.projectionMatrix),F(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=G(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 c=G(i.maskColor);a=c.r,s=c.g,h=c.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}(),U=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 g("Unable to initialize the Program: "+o)}},t}(),L=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 g("Unable to initialize the shader program: "+o)}return n},t}(),k=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"}(I||(I={}));var N,z=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=G(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===x.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===x.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===x.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===x.Geometric&&(this.geometricRenderer.render(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===x.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}(),W=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 g("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 g("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new g("Game not initialized.");if(!1===this.scenes.has(t))throw new g("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(p.Init)},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(p.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager.clearData())},t}(),H=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 g("Physics framerate cannot be less than 60");if(t%60!=0)throw new g("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}(),Y=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}(),X=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===I.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}(),q=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 Q(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 l(this,void 0,void 0,(function(){var i;return c(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}(),Q=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},K=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=S(),this.modelMatrix=S(),this.textureMatrix=S()}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=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),E(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=T(this.textureMatrix),A(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=T(this.projectionMatrix),F(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=G(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.Circumference=1]="Circumference",t[t.Line=2]="Line"}(N||(N={}));var $,J=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Geometric,e}return a(e,t),e}(P),Z=function(){function t(t,e,i){this.vertices=new Map,this.lastVertices=null,this.lastRender=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=S(),this.modelMatrix=S(),this.textureMatrix=S();var r=2*Math.PI/60;this.circumferenceVertices=new Float32Array(n(1,60,1).reduce((function(t,e){return u(u([],t,!0),[Math.cos(e*r),Math.sin(e*r)],!1)}),[]))}return t.prototype.render=function(t,e,i){switch(this.lastRender=i,e.shape){case N.Polygon:case N.Line:this.renderLines(t,e,this.gl.LINE_LOOP);break;case N.Circumference:this.renderCircumference(t,e)}},t.prototype.renderLines=function(t,e,i){var n=e.vertexModel,r=e.positionInViewport,o=e.angle,a=e.color,s=this.generateVerticesKey(n);!1===this.vertices.has(s)&&this.vertices.set(s,new Float32Array(this.generatePolygonVertices(n)));var h=this.vertices.get(s);this.lastVertices===s&&"geometric"===this.lastRender||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW)),this.lastVertices=s,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[r.x,r.y,0]),E(this.modelMatrix,this.modelMatrix,o),this.projectionMatrix=T(this.projectionMatrix),F(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 l=G(a),c=l.r,u=l.g,p=l.b,d=l.a;this.gl.uniform4f(this.programManager.solidColorUniform,c,u,p,d),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(i,0,h.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.prototype.renderCircumference=function(t,e){var i=e.radius,n=e.positionInViewport,r=e.color;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.lastVertices=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),this.modelMatrix=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[n.x,n.y,0]),A(this.modelMatrix,this.modelMatrix,[i,i,1]),this.projectionMatrix=T(this.projectionMatrix),F(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 o=G(r),a=o.r,s=o.g,h=o.b,l=o.a;this.gl.uniform4f(this.programManager.solidColorUniform,a,s,h,l),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.LINE_LOOP,0,this.circumferenceVertices.length/2)},t}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}($||($={}));var tt,et=function(){function t(t,e){this.circumferenceResolver=t,this.satResolver=e}return t.prototype.getCollisionResolution=function(t,e){return t.type===$.Circumference&&e.type===$.Circumference?this.circumferenceResolver.resolve(t,e):this.satResolver.resolve(t,e)},t}(),it=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}(),nt=function(){function t(t,e,i){this.AABBResolver=t,this.circumferenceAABBResolver=e,this.circumferenceResolver=i}return t.prototype.getCollisionResolution=function(t,e){return t.type===$.Polygon&&e.type===$.Polygon?this.AABBResolver.resolve(t,e):t.type===$.Circumference&&e.type===$.Polygon?this.circumferenceAABBResolver.resolve(t,e):t.type===$.Polygon&&e.type===$.Circumference?this.circumferenceAABBResolver.resolve(e,t,!0):t.type===$.Circumference&&e.type===$.Circumference?this.circumferenceResolver.resolve(t,e):null},t}(),rt=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 x.Image:return i.cullSprite(n,e);case x.Tilemap:return i.cullTilemap(n,e);case x.Geometric:return i.cullGeometric(n,e);case x.Text:return i.cullText(n,e);case x.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.cullGeometric=function(t,e){return this.isTargetVisible(t,e.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}(),ot=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=S(),this.modelMatrix=S(),this.textureMatrix=S()}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=T(this.modelMatrix),this.textureMatrix=T(this.textureMatrix),A(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=T(this.projectionMatrix),F(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=G(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}(),at=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}(),st=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}(),ht=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}(),lt=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}(),ut=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}(),pt=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=S(),this.modelMatrix=S(),this.textureMatrix=S()}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=T(this.modelMatrix),B(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),E(this.modelMatrix,this.modelMatrix,e.rotation),A(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=T(this.projectionMatrix),F(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=G(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}();exports.RigidBodyType=void 0,(tt=exports.RigidBodyType||(exports.RigidBodyType={}))[tt.Static=0]="Static",tt[tt.Dynamic=1]="Dynamic";var dt,ft=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(e){e.cacheVelocity?e.cacheVelocity.set(0,0):e.cacheVelocity=new t,this.rigidBodyData.push(e)},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]=(0!==e.cacheVelocity[n]?e.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.cacheVelocity[i]=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}(),gt=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.resolve=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}(),mt=function(){function e(){this.closestPoint=new t,this.distance=new t,this.direction=new t}return e.prototype.resolve=function(e,n,r){return void 0===r&&(r=!1),this.closestPoint.set(i(e.position.x,n.boundingBox.x,n.boundingBox.x1),i(e.position.y,n.boundingBox.y,n.boundingBox.y1)),t.subtract(this.distance,this.closestPoint,e.position),this.distance.magnitude>e.radius?null:(t.unit(this.direction,this.distance),{penetration:e.radius-this.distance.magnitude,direction:r?t.scale(new t,this.direction,-1):this.direction.clone(),displacementDirection:r?this.direction.clone():t.scale(new t,this.direction,-1)})},e}(),yt=function(){function e(){this.distance=new t,this.direction=new t}return e.prototype.resolve=function(e,i){return t.subtract(this.distance,i.position,e.position),this.distance.magnitude>e.radius+i.radius?null:(t.unit(this.direction,this.distance),{penetration:e.radius+i.radius-this.distance.magnitude,direction:this.direction.clone(),displacementDirection:t.scale(new t,this.direction,-1)})},e}(),bt=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displaceDirection=new t,this.direction=new t,this.distance=new t(1/0,1/0),this.cache=new t}return e.prototype.resolve=function(e,i){this.currentOverlap=null,this.minOverlap=null,e.type===$.Circumference?this.setCircumferenceAxis(e,i):i.type===$.Circumference&&this.setCircumferenceAxis(i,e),this.axes=u(u([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(e.type===$.Circumference?this.setCircumferenceVertices(e,this.axes[n]):i.type===$.Circumference&&this.setCircumferenceVertices(i,this.axes[n]),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.prototype.setCircumferenceAxis=function(e,i){var n=this;this.distance.set(1/0,1/0),i.vertices.forEach((function(i){t.subtract(n.cache,i,e.position),n.cache.magnitude<n.distance.magnitude&&n.distance.copy(n.cache)})),t.unit(e.projectionAxes[0],this.distance)},e.prototype.setCircumferenceVertices=function(e,i){t.add(e.vertices[0],e.position,t.scale(this.cache,t.unit(this.cache,i),-e.radius)),t.add(e.vertices[1],e.position,t.scale(this.cache,t.unit(this.cache,i),e.radius))},e}(),xt=function(t,e){if(e.collisions.method===exports.CollisionMethodConfig.AABB)t.add("CollisionMethod",(function(){return new nt(new gt,new mt,new yt)}));else{if(e.collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Invalid collision method.");t.add("CollisionMethod",(function(){return new et(new yt,new bt)}))}t.add("CollisionManager",(function(){return new y(t.getSingleton("CollisionMethod"),e.collisions.quadTreeBounds,e.collisions.quadMaxLevel,e.collisions.collidersPerQuad)})),t.add("RigidBodyManager",(function(){return new ft(t.getSingleton("CollisionManager"))}))},vt=function(t,e,i){var n=_t();if(null===n)throw new g("WebGL not suported in your browser.");Mt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new q})),t.add("CullingService",(function(){return new rt})),t.add("RenderManager",(function(){return new R(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},Mt=function(t,e,i){e.add("ShaderLoader",(function(){return new L})),e.add("ProgramFactory",(function(){return new U(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new X(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new k(t,i.canvas)})),e.add("TextureManager",(function(){return new Y(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new V(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new K(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new Z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new ot(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new pt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new z(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"))}))},wt=function(t,e){t.add("InputManager",(function(){return new O(new C(e.canvas),new j(e.canvas),new w,new it(e.canvas))}))},_t=function(){return null!==document.createElement("canvas").getContext(I.WebGL2)?I.WebGL2:null!==document.createElement("canvas").getContext(I.LegacyWebGL)?I.LegacyWebGL:null},Ot=function(t){at.initialize(t.getSingleton("AssetManager")),st.initialize(t.getSingleton("DomManager")),ht.initialize(t.getSingleton("InputManager")),lt.initialize(t.getSingleton("SceneManager")),ct.initialize(t.getSingleton("TimeManager")),ut.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 g("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 g("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 g("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new g("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 g("Invalid constant name: "+t);return this.constants.get(t)},t}());exports.CollisionMethodConfig=void 0,(dt=exports.CollisionMethodConfig||(exports.CollisionMethodConfig={})).AABB="aabb",dt.SAT="sat";var Ct={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:240,collisions:{method:exports.CollisionMethodConfig.AABB,quadTreeBounds:null,quadMaxLevel:6,collidersPerQuad:15}},Pt=function(){function t(t){this._running=!1,this._stop=!1,this.frameRequestId=null,this._config=h(h({},Ct),t),this._config.collisions=h(h({},Ct.collisions),t.collisions),jt.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("DomManager",(function(){return new b(e.containerNode,e.gameWidth,e.gameHeight)}));var i=t.getSingleton("DomManager");t.add("TimeManager",(function(){return new H(e.physicsFramerate)})),vt(t,e,i),wt(t,i),xt(t,e),t.add("SceneManager",(function(){return new W(t.getConstant("Game"),t.getSingleton("RenderManager"))})),t.add("GameObjectManager",(function(){return new M})),t.add("AssetManager",(function(){return new f})),t.add("IterationManager",(function(){return new v(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})),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}(),Rt=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(){this.sceneManager=jt.getSingleton("SceneManager"),this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.id=Rt(),this.allowMultiple=!0,this._active=!0,this.started=!1}return Object.defineProperty(t.prototype,"updateEvent",{get:function(){return p.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===p.Init?this.init():t===p.Start&&!1===this.started?(this.start(),this.started=!0):t===this.updateEvent&&!0===this.started?this.update():t===p.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}(),St=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateEngine},enumerable:!1,configurable:!0}),e}(Dt),Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateCollider},enumerable:!1,configurable:!0}),e}(Dt),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdatePhysics},enumerable:!1,configurable:!0}),e}(Dt),At=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateTransform},enumerable:!1,configurable:!0}),e}(Dt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdatePreRender},enumerable:!1,configurable:!0}),e}(Dt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateCamera},enumerable:!1,configurable:!0}),e}(Dt),It=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),Object.defineProperty(e.prototype,"updateEvent",{get:function(){return p.UpdateRender},enumerable:!1,configurable:!0}),e}(Dt),Gt={Animator:"Animator",AudioPlayer:"AudioPlayer",Camera:"camera",RigidBody:"RigidBody",Transform:"Transform",BoxCollider:"BoxCollider",TilemapCollider:"TilemapCollider",PolygonCollider:"PolygonCollider",BallCollider:"BallCollider",EdgeCollider:"EdgeCollider",CsvTilemapRenderer:"CsvTilemapRenderer",SpriteRenderer:"SpriteRenderer",TextRenderer:"TextRenderer",TiledTilemapRenderer:"TiledTilemapRenderer",MaskRenderer:"MaskRenderer"},Vt=function(e){function i(){var i=e.call(this)||this;return i._position=new t,i._scale=new t(1,1),i._rotation=new r,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=Gt.Transform,i}return a(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}(At),Ut=function(){function t(){this.id=Rt(),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.addComponent((function(){return new Vt}))}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(Gt.Transform)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigidBody",{get:function(){return this.getComponentByType(Gt.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===p.Init?this.init():t===p.Start&&!1===this.started?(this.start(),this.started=!0):t===p.Update&&this.started?this.update():t===p.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(p.Init),this.components.push(i),i},t.prototype.checkMultipleComponent=function(t){if(!1===t.allowMultiple&&this.hasComponentOfType(t.type))throw new g("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(p.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(p.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(p.Destroy),delete this.components[t];this.components=[]},t}(),Lt=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},kt=["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=kt,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 Lt,i.allowMultiple=!1,i.type=Gt.Camera,i.canvas=i.domManager.canvas,i}return a(i,t),Object.defineProperty(i.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=u(u([],kt,!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 g("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}(Ft),zt=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 a(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}(Ut),Wt=function(){function t(){this.gameObjectManager=jt.getSingleton("GameObjectManager"),this.game=null,this.name=null,this.started=!1,this.addGameObject((function(){return new zt}),"GameCamera")}return Object.defineProperty(t.prototype,"gameCamera",{get:function(){return this.findGameObjectByName("GameCamera")},enumerable:!1,configurable:!0}),t.prototype.dispatch=function(t){t===p.Init?this.init():t!==p.Start||this.started?t===p.Update&&this.started?this.update():t===p.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}(),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=jt.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return a(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}(Tt),Yt=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}(),Xt=function(){function i(i){this._type=$.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}(),qt=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 a(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}(Xt),Qt=function(e){function i(i){var n,o,a,s,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===exports.CollisionMethodConfig.SAT,l.innerPosition=new t,l.type=Gt.BoxCollider,l.width=i.width,l.height=i.height,l.offsetX=null!==(n=i.offsetX)&&void 0!==n?n: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.debug=(null!==(s=i.debug)&&void 0!==s?s:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer,l}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new qt(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(Gt.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}(Ht),Kt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="BoxColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(It),$t=function(){function i(i){this.type=$.Circumference,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new e(0,0,0,0),this.angle=0,this.vertexModel=[],this.radius=0,this._position=new t,this.vertices=[new t,new t],this.radius=i}return Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),i.prototype.update=function(){this.updateBoundingBox()},i.prototype.updateBoundingBox=function(){this.boundingBox.set(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},i}(),Jt=function(e){function i(i){var n,r,o,a,s=e.call(this)||this;return s.debug=!1,s.offsetX=0,s.offsetY=0,s.realRadius=0,s.realOffset=new t,s.realPosition=new t,s.innerPosition=new t,s.type=Gt.BallCollider,s.radius=i.radius,s.offsetX=null!==(n=i.offsetX)&&void 0!==n?n:s.offsetX,s.offsetY=null!==(r=i.offsetY)&&void 0!==r?r:s.offsetY,s.physics=null!==(o=i.physics)&&void 0!==o?o:s.physics,s.debug=(null!==(a=i.debug)&&void 0!==a?a:s.debug)&&jt.getConstant("GameConfig").debugEnabled,s.layer=i.layer,s}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new $t(this.radius),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new Zt(e.colliders[0])})))},i.prototype.update=function(){this.updateRealSize(),this.updatePosition(),this.updateShape(),e.prototype.update.call(this)},i.prototype.updateRealSize=function(){this.realRadius=this.radius*Math.max(Math.abs(this.gameObject.transform.scale.x),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},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.radius=this.realRadius,this.colliders[0].shape.update()},i}(Ht),Zt=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="BallColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Circumference,this.renderData.position=this.collider.shape.position,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.radius=this.collider.shape.radius,this.renderManager.addRenderData(this.renderData)},e}(It),te=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=Gt.TilemapCollider,r.tilemapRenderer=i.tilemapRenderer,r.layer=i.layer,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 a(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 Yt(new qt(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponentOfType(Gt.RigidBody)))})),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ee(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}(Ht),ee=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 J,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00"})),i}return a(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].shape=N.Polygon,t.renderData[i].position=e.shape.position,t.renderData[i].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(It),ie=function(e){function i(i){var n,o,a,s,h,l=e.call(this)||this;if(l.debug=!1,l.offsetX=0,l.offsetY=0,l.scaledVertexModel=[],l.scaledOffset=new t,l.scaledPosition=new t,l.finalRotation=0,l.innerPosition=new t,jt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Polygon Colliders need SAT collision method.");if(i.vertexModel.length<3)throw new g("Polygon Collider needs at least 3 vertices.");l.type=Gt.PolygonCollider,l.debug=(null!==(n=i.debug)&&void 0!==n?n:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.vertexModel=i.vertexModel,l.offsetX=null!==(o=i.offsetX)&&void 0!==o?o:l.offsetX,l.offsetY=null!==(a=i.offsetY)&&void 0!==a?a:l.offsetY,l.physics=null!==(s=i.physics)&&void 0!==s?s:l.physics,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer;for(var c=0;c<l.vertexModel.length;c++)l.scaledVertexModel.push(new t);return l}return a(i,e),i.prototype.start=function(){var t,e=this;this.colliders.push(new Yt(new Xt(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody))),this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ne(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.gameObject.transform.rotation.radians+this.rotation.radians},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.scaledVertexModel,this.colliders[0].shape.update()},i}(Ht),ne=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.type="PolygonColliderRenderer",i.renderData=new J,i.renderData.debug=!0,i.renderData.color="#00FF00",i.collider=e,i}return a(e,t),e.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=N.Polygon,this.renderData.position=this.collider.shape.position,this.renderData.angle=this.collider.shape.angle,this.renderData.boundingBox=this.collider.shape.boundingBox,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},e}(It),re=function(){function i(i){this.vertexModel=i,this.type=$.Polygon,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new e(0,0,0,0),this.angle=0,this._position=new t}return i.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),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(){this.boundingBox.x=Math.min(this.vertices[0].x,this.vertices[1].x),this.boundingBox.y=Math.min(this.vertices[0].y,this.vertices[1].y),this.boundingBox.width=Math.max(this.vertices[0].x,this.vertices[1].x)-this.boundingBox.x,this.boundingBox.height=Math.max(this.vertices[0].y,this.vertices[1].y)-this.boundingBox.y},i.prototype.updateProjectionAxes=function(){t.normal(this.projectionAxes[0],t.subtract(this.projectionAxes[0],this.vertices[1],this.vertices[0]))},i}(),oe=function(e){function i(i){var n,o,a,s,h,l=e.call(this)||this;if(l.debug=!1,l.offsetX=0,l.offsetY=0,l.scaledVertexModel=[],l.scaledOffset=new t,l.scaledPosition=new t,l.finalRotation=0,l.innerPosition=new t,jt.getConstant("GameConfig").collisions.method!==exports.CollisionMethodConfig.SAT)throw new g("Edge Colliders need SAT collision method.");if(i.vertexModel.length<2)throw new g("Edge Collider needs at least 2 vertices.");l.type=Gt.EdgeCollider,l.debug=(null!==(n=i.debug)&&void 0!==n?n:l.debug)&&jt.getConstant("GameConfig").debugEnabled,l.vertexModel=i.vertexModel,l.offsetX=null!==(o=i.offsetX)&&void 0!==o?o:l.offsetX,l.offsetY=null!==(a=i.offsetY)&&void 0!==a?a:l.offsetY,l.physics=null!==(s=i.physics)&&void 0!==s?s:l.physics,l.rotation=null!==(h=i.rotation)&&void 0!==h?h:new r,l.layer=i.layer;for(var c=0;c<l.vertexModel.length;c++)l.scaledVertexModel.push(new t);return l}return a(i,e),i.prototype.start=function(){for(var t,e=this,i=0;i<this.scaledVertexModel.length-1;i++)this.colliders.push(new Yt(new re([this.scaledVertexModel[i],this.scaledVertexModel[i+1]]),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponentOfType(Gt.RigidBody)));this.debug&&(this.renderer=this.gameObject.addComponent((function(){return new ae(e.colliders)})))},i.prototype.update=function(){this.updateSize(),this.updatePosition(),this.updateColliders(),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.gameObject.transform.rotation.radians+this.rotation.radians},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.updateColliders=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders[e].layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.colliders[e].shape.position=this.scaledPosition,this.colliders[e].shape.angle=this.finalRotation,this.colliders[e].shape.vertexModel=[this.scaledVertexModel[e],this.scaledVertexModel[e+1]],this.colliders[e].shape.update()},i}(Ht),ae=function(t){function e(e){var i=t.call(this)||this;return i.renderManager=jt.getSingleton("RenderManager"),i.renderData=[],i.colliders=[],i.type="EdgeColliderRenderer",i.colliders=e,i.colliders.forEach((function(t,e){i.renderData[e]=new J,i.renderData[e].debug=!0,i.renderData[e].color="#00FF00",i.renderData[e].shape=N.Line})),i}return a(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].angle=e.shape.angle,t.renderData[i].boundingBox=e.shape.boundingBox,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},e}(It),se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Image,e}return a(e,t),e}(P),he=function(e){function i(i){var n,o,a,s,h,l,c,u,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 r,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=Gt.SpriteRenderer,g.sprite=i.sprite,g.offset=null!==(n=i.offset)&&void 0!==n?n:g.offset,g.smooth=null!==(o=i.smooth)&&void 0!==o?o:g.smooth,g.rotation=null!==(a=i.rotation)&&void 0!==a?a:g.rotation,g.flipHorizontal=null!==(s=i.flipHorizontal)&&void 0!==s?s: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!==(c=i.tiled)&&void 0!==c?c:g._tiled,g.maskColor=null!==(u=i.maskColor)&&void 0!==u?u: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 a(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 g("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 se}},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),le=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Text,e}return a(e,t),e}(P),ce=function(e){function i(i){var n,o,a,s,h,l,c,u,p,d,f,m,y,b,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 r,v.opacity=1,v.orientation="center",v.renderManager=jt.getSingleton("RenderManager"),v.renderData=new le,v.lastFrameText="",v.type=Gt.TextRenderer,v.text=i.text,v.fontFamily=i.fontFamily,v.fontUrl=null!==(n=i.fontUrl)&&void 0!==n?n:v.fontUrl,v.fontSize=null!==(o=i.fontSize)&&void 0!==o?o:v.fontSize,v.width=null!==(a=i.width)&&void 0!==a?a:v.width,v.height=null!==(s=i.height)&&void 0!==s?s: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!==(c=i.lineSeparation)&&void 0!==c?c:v.lineSeparation,v.letterSpacing=null!==(u=i.letterSpacing)&&void 0!==u?u: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!==(m=i.bitmapOffset)&&void 0!==m?m:v.bitmapOffset,v.rotation=null!==(y=i.rotation)&&void 0!==y?y:v.rotation,v.opacity=null!==(b=i.opacity)&&void 0!==b?b:v.opacity,v.orientation=null!==(x=i.orientation)&&void 0!==x?x:v.orientation,v.charRanges.length%2!=0)throw new g("TextRenderer.charRanges must be a 2 column matrix");if(v.lineSeparation%2!=0)throw new g("TextRenderer.lineSeparation must be multiple of 2");return v}return a(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),ue=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Mask,e}return a(e,t),e}(P),pe=function(e){function i(i){var n,o,a,s,h=e.call(this)||this;return h.renderManager=jt.getSingleton("RenderManager"),h.offset=new t,h.rotation=new r,h.opacity=1,h.renderData=new ue,h.innerPosition=new t,h.scaledOffset=new t,h.type=Gt.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!==(o=i.rotation)&&void 0!==o?o:h.rotation,h.opacity=null!==(a=i.opacity)&&void 0!==a?a:h.opacity,h.layer=null!==(s=i.layer)&&void 0!==s?s:h.layer,h}return a(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),de=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}(),fe=function(){this.position=new t,this.positionInViewport=new t},ge=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=x.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return a(e,t),e}(P),me=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 a(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 ge;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 fe;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 de(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),ye=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=Gt.TiledTilemapRenderer,r.tiledTilemap=e.tilemapData,r.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,r}return a(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}(me),be=1,xe=2,ve=3,Me=function(t){function e(e){var i,n,r=t.call(this,e)||this;return r.alpha=1,r.tintColor=null,r.type=Gt.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 a(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=[be,ve].includes(h),a.v=[xe,ve].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:a,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(me),we=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},_e=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 we(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}(),Oe=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},je=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=Gt.Animator,i.spriteRenderer=e.spriteRenderer,i}return a(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 Ce(e)),this},e.prototype.playAnimation=function(t){if(!1!==this.active){if(!1===this.animations.has(t))throw new g("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}(St),Ce=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}(),Pe=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Re=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(){Pe.forEach((function(t){window.removeEventListener(t,o.userinputEventHandler)})),o.audio.play()},o.allowMultiple=!1,o.type=Gt.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 a(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 Pe.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}(St),De=function(e){function i(i){var n,r,o=e.call(this)||this;return o.rigidBodyManager=jt.getSingleton("RigidBodyManager"),o.type=Gt.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 a(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 g("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===exports.RigidBodyType.Dynamic&&this.rigidBodyManager.addRigidBodyData(this.data)},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Ht&&e.physics?u(u([],t,!0),e.colliders,!0):t}),[])},i}(St),Se=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}(),Te=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return a(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){ht.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,ht.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=ht.mouse.leftButtonPressed},i}(Ut);exports.Animation=Oe,exports.Animator=je,exports.AssetManager=at,exports.AudioPlayer=Re,exports.BallCollider=Jt,exports.BoxCollider=Qt,exports.Camera=Nt,exports.ColliderData=Yt,exports.Component=Dt,exports.ComponentTypes=Gt,exports.CsvTilemapRenderer=Me,exports.DomManager=st,exports.EdgeCollider=oe,exports.GAME_CAMERA_ID="GameCamera",exports.Game=Pt,exports.GameCamera=zt,exports.GameObject=Ut,exports.GameObjectManager=ut,exports.GamepadController=w,exports.GamepadData=_,exports.InputManager=ht,exports.KeyboardController=j,exports.LAYER_DEFAULT="Default",exports.MaskRenderer=pe,exports.MouseController=C,exports.PhysicsComponent=Bt,exports.PolygonCollider=ie,exports.PreRenderComponent=Et,exports.Rectangle=e,exports.RigidBody=De,exports.Rotation=r,exports.Scene=Wt,exports.SceneManager=lt,exports.SpacePointer=Te,exports.Sprite=Se,exports.SpriteRenderer=he,exports.TextRenderer=ce,exports.TiledTilemapRenderer=ye,exports.TilemapCollider=te,exports.Tileset=_e,exports.TimeManager=ct,exports.TouchController=it,exports.Transform=Vt,exports.Vector2=t,exports.between=function(t,e,i){return t>=e&&t<=i},exports.clamp=i,exports.fixedRound=function(t,e){return Math.round(t*(10^e))/(10^e)},exports.random=function(t,e){return Math.floor(Math.random()*(e-t))+t},exports.range=n;
|