angry-pixel 1.1.3 → 1.1.4
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/.vscode/settings.json +2 -0
- package/lib/component/Button.d.ts +1 -1
- package/lib/component/Camera.d.ts +7 -15
- package/lib/component/RigidBody.d.ts +1 -1
- package/lib/component/Sprite.d.ts +9 -18
- package/lib/component/Transform.d.ts +1 -3
- package/lib/component/collider/BoxCollider.d.ts +1 -1
- package/lib/component/collider/EdgeCollider.d.ts +2 -3
- package/lib/component/collider/PolygonCollider.d.ts +12 -2
- package/lib/component/collider/TilemapCollider.d.ts +14 -3
- package/lib/component/rendering/MaskRenderer.d.ts +2 -4
- package/lib/component/rendering/SpriteRenderer.d.ts +5 -9
- package/lib/component/rendering/TextRenderer.d.ts +13 -16
- package/lib/component/rendering/TiledTilemapRenderer.d.ts +78 -0
- package/lib/component/rendering/TilemapRenderer.d.ts +55 -0
- package/lib/core/Game.d.ts +1 -2
- package/lib/core/facades/AssetManagerFacade.d.ts +11 -0
- package/lib/core/managers/AssetManager.d.ts +3 -2
- package/lib/core/managers/IterationManager.d.ts +3 -2
- package/lib/core/managers/SceneManager.d.ts +2 -2
- package/lib/gameObject/GameCamera.d.ts +1 -2
- package/lib/index.cjs.js +15 -1
- package/lib/index.d.ts +3 -7
- package/lib/index.esm.js +15 -1
- package/lib/index.js +15 -1
- package/lib/input/GamepadController.d.ts +1 -1
- package/lib/input/MouseController.d.ts +1 -1
- package/lib/input/TouchController.d.ts +1 -1
- package/lib/physics/collision/CollisionManager.d.ts +1 -1
- package/lib/physics/collision/QuadTree.d.ts +1 -1
- package/lib/physics/collision/resolver/CollisionResolver.d.ts +1 -1
- package/lib/physics/collision/shape/Circumference.d.ts +1 -2
- package/lib/physics/collision/shape/Line.d.ts +1 -2
- package/lib/physics/collision/shape/Polygon.d.ts +1 -2
- package/lib/physics/collision/shape/Rectangle.d.ts +1 -1
- package/lib/physics/collision/shape/Shape.d.ts +1 -2
- package/lib/physics/rigodBody/RigidBodyData.d.ts +1 -1
- package/package.json +3 -2
- package/lib/Engine/Animation.d.ts +0 -12
- package/lib/Engine/Component.d.ts +0 -130
- package/lib/Engine/Components/Animator.d.ts +0 -20
- package/lib/Engine/Components/AudioPlayer.d.ts +0 -27
- package/lib/Engine/Components/Camera.d.ts +0 -30
- package/lib/Engine/Components/Colliders/AbstractColliderComponent.d.ts +0 -22
- package/lib/Engine/Components/Colliders/BoxCollider.d.ts +0 -32
- package/lib/Engine/Components/Colliders/TilemapCollider.d.ts +0 -15
- package/lib/Engine/Components/ComponentTypes.d.ts +0 -13
- package/lib/Engine/Components/Renderer/CsvTilemapRenderer.d.ts +0 -13
- package/lib/Engine/Components/Renderer/SpriteRenderer.d.ts +0 -46
- package/lib/Engine/Components/Renderer/TextRenderer.d.ts +0 -49
- package/lib/Engine/Components/Renderer/TiledTilemapRenderer.d.ts +0 -43
- package/lib/Engine/Components/Renderer/TilemapRenderer.d.ts +0 -72
- package/lib/Engine/Components/RigidBody.d.ts +0 -42
- package/lib/Engine/Components/Transform.d.ts +0 -30
- package/lib/Engine/Core/Asset/AssetManager.d.ts +0 -17
- package/lib/Engine/Core/Collision/Collider/ICollider.d.ts +0 -13
- package/lib/Engine/Core/Collision/Collider/RectangleCollider.d.ts +0 -31
- package/lib/Engine/Core/Collision/CollisionData.d.ts +0 -8
- package/lib/Engine/Core/Collision/CollisionManager.d.ts +0 -31
- package/lib/Engine/Core/Collision/QuadTree.d.ts +0 -32
- package/lib/Engine/Core/Collision/Resolver/AABBResolver.d.ts +0 -14
- package/lib/Engine/Core/Collision/Resolver/ICollisionResolver.d.ts +0 -5
- package/lib/Engine/Core/Collision/Resolver/SatResolver.d.ts +0 -14
- package/lib/Engine/Core/Collision/Shape/Rectangle.d.ts +0 -13
- package/lib/Engine/Core/Collision/Shape/Shape.d.ts +0 -28
- package/lib/Engine/Core/DependencyInjection/Config.d.ts +0 -3
- package/lib/Engine/Core/DependencyInjection/Container.d.ts +0 -12
- package/lib/Engine/Core/Dom/DomManager.d.ts +0 -9
- package/lib/Engine/Core/Exception/GameEngineException.d.ts +0 -4
- package/lib/Engine/Core/Exception/MiniEngineException.d.ts +0 -4
- package/lib/Engine/Core/GameLoop/IterationManager.d.ts +0 -18
- package/lib/Engine/Core/GameLoop/TimeManager.d.ts +0 -18
- package/lib/Engine/Core/GameObject/GameObjectManager.d.ts +0 -17
- package/lib/Engine/Core/Input/GamepadController.d.ts +0 -40
- package/lib/Engine/Core/Input/InputManager.d.ts +0 -11
- package/lib/Engine/Core/Input/KeyboardController.d.ts +0 -7
- package/lib/Engine/Core/Input/MouseController.d.ts +0 -21
- package/lib/Engine/Core/Input/TouchController.d.ts +0 -13
- package/lib/Engine/Core/Physics/PhysicsIterationManager.d.ts +0 -13
- package/lib/Engine/Core/Rendering/CameraData.d.ts +0 -9
- package/lib/Engine/Core/Rendering/Context2D/Context2DRenderer.d.ts +0 -19
- package/lib/Engine/Core/Rendering/CullingService.d.ts +0 -11
- package/lib/Engine/Core/Rendering/FontAtlasFactory.d.ts +0 -19
- package/lib/Engine/Core/Rendering/IContextRenderer.d.ts +0 -6
- package/lib/Engine/Core/Rendering/RenderData/ColliderRenderData.d.ts +0 -7
- package/lib/Engine/Core/Rendering/RenderData/GeometricRenderData.d.ts +0 -12
- package/lib/Engine/Core/Rendering/RenderData/ImageRenderData.d.ts +0 -22
- package/lib/Engine/Core/Rendering/RenderData/RenderData.d.ts +0 -22
- package/lib/Engine/Core/Rendering/RenderData/TextRenderData.d.ts +0 -22
- package/lib/Engine/Core/Rendering/RenderData/TilemapRenderData.d.ts +0 -22
- package/lib/Engine/Core/Rendering/RenderManager.d.ts +0 -22
- package/lib/Engine/Core/Rendering/WebGL/ProgramFactory.d.ts +0 -7
- package/lib/Engine/Core/Rendering/WebGL/ProgramManager.d.ts +0 -26
- package/lib/Engine/Core/Rendering/WebGL/Renderer/GeometricRenderer.d.ts +0 -22
- package/lib/Engine/Core/Rendering/WebGL/Renderer/ImageRenderer.d.ts +0 -16
- package/lib/Engine/Core/Rendering/WebGL/Renderer/TextRenderer.d.ts +0 -21
- package/lib/Engine/Core/Rendering/WebGL/Renderer/TilemapRenderer.d.ts +0 -19
- package/lib/Engine/Core/Rendering/WebGL/Shader/Legacy/imageFragmentShader.d.ts +0 -1
- package/lib/Engine/Core/Rendering/WebGL/Shader/Legacy/imageVertexShader.d.ts +0 -1
- package/lib/Engine/Core/Rendering/WebGL/Shader/imageFragmentShader.d.ts +0 -1
- package/lib/Engine/Core/Rendering/WebGL/Shader/imageVertexShader.d.ts +0 -1
- package/lib/Engine/Core/Rendering/WebGL/ShaderLoader.d.ts +0 -3
- package/lib/Engine/Core/Rendering/WebGL/TextureFactory.d.ts +0 -8
- package/lib/Engine/Core/Rendering/WebGL/TextureManager.d.ts +0 -11
- package/lib/Engine/Core/Rendering/WebGL/Utils.d.ts +0 -7
- package/lib/Engine/Core/Rendering/WebGL/WebGLRenderer.d.ts +0 -34
- package/lib/Engine/Core/Scene/SceneManager.d.ts +0 -18
- package/lib/Engine/Core/Tilemap/Tile.d.ts +0 -7
- package/lib/Engine/Core/Tilemap/TileData.d.ts +0 -10
- package/lib/Engine/Core/Time/GameIterationManager.d.ts +0 -11
- package/lib/Engine/Core/Time/GameLoopManager.d.ts +0 -10
- package/lib/Engine/Core/Time/TimeManager.d.ts +0 -18
- package/lib/Engine/Facades/AssetManagerFacade.d.ts +0 -28
- package/lib/Engine/Facades/DomManagerFacade.d.ts +0 -7
- package/lib/Engine/Facades/GameObjectManagerFacade.d.ts +0 -58
- package/lib/Engine/Facades/InputManagerFacade.d.ts +0 -12
- package/lib/Engine/Facades/SceneManagerFacade.d.ts +0 -17
- package/lib/Engine/Facades/TimeManagerFacade.d.ts +0 -9
- package/lib/Engine/Game.d.ts +0 -88
- package/lib/Engine/GameObject.d.ts +0 -157
- package/lib/Engine/GameObjects/GameCamera.d.ts +0 -17
- package/lib/Engine/GameObjects/SpacePointer.d.ts +0 -8
- package/lib/Engine/Math/Rectangle.d.ts +0 -50
- package/lib/Engine/Math/Rotation.d.ts +0 -16
- package/lib/Engine/Math/Utils.d.ts +0 -26
- package/lib/Engine/Math/Vector2.d.ts +0 -114
- package/lib/Engine/Scene.d.ts +0 -71
- package/lib/Engine/Sprite.d.ts +0 -31
- package/lib/Engine/Tileset.d.ts +0 -25
- package/lib/Engine/Utils/uuid.d.ts +0 -1
- package/lib/component/ComponentTypes.d.ts +0 -17
- package/lib/component/RigidBodyOld.d.ts +0 -39
- package/lib/component/colliderComponent/AbstractColliderComponent.d.ts +0 -22
- package/lib/component/colliderComponent/BoxCollider.d.ts +0 -32
- package/lib/component/colliderComponent/PolygonCollider.d.ts +0 -32
- package/lib/component/colliderComponent/TilemapCollider.d.ts +0 -15
- package/lib/component/colliderComponent/TriangleCollider.d.ts +0 -32
- package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +0 -13
- package/lib/component/rendering/tilemap/Tile.d.ts +0 -7
- package/lib/component/rendering/tilemap/TileData.d.ts +0 -13
- package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +0 -48
- package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +0 -74
- package/lib/component/rendering/tilemap/Tileset.d.ts +0 -25
- package/lib/component/renderingComponent/MaskRenderer.d.ts +0 -29
- package/lib/component/renderingComponent/SpriteRenderer.d.ts +0 -46
- package/lib/component/renderingComponent/TextRenderer.d.ts +0 -49
- package/lib/component/renderingComponent/tilemap/CsvTilemapRenderer.d.ts +0 -13
- package/lib/component/renderingComponent/tilemap/Tile.d.ts +0 -7
- package/lib/component/renderingComponent/tilemap/TileData.d.ts +0 -10
- package/lib/component/renderingComponent/tilemap/TiledTilemapRenderer.d.ts +0 -43
- package/lib/component/renderingComponent/tilemap/TilemapRenderer.d.ts +0 -72
- package/lib/component/renderingComponent/tilemap/Tileset.d.ts +0 -25
- package/lib/core/managers/IterationManager copy.d.ts +0 -42
- package/lib/core/managers/IterationManagerOld.d.ts +0 -42
- package/lib/core/managers/headless/HeadlessIterationManager.d.ts +0 -29
- package/lib/core/managers/headless/HeadlessRenderManager.d.ts +0 -10
- package/lib/core/managers/iteration/BrowserIterationManager.d.ts +0 -35
- package/lib/core/managers/iteration/FrameEvent.d.ts +0 -13
- package/lib/core/managers/iteration/HeadlessIterationManager.d.ts +0 -29
- package/lib/core/managers/iteration/IIterationManager.d.ts +0 -7
- package/lib/math/Rectangle.d.ts +0 -57
- package/lib/math/Rotation.d.ts +0 -13
- package/lib/math/Utils.d.ts +0 -39
- package/lib/math/Vector2.d.ts +0 -114
- package/lib/physics/PhysicsManager.d.ts +0 -24
- package/lib/physics/PhysicsManagerOld2.d.ts +0 -34
- package/lib/physics/collision/CollisionData.d.ts +0 -8
- package/lib/physics/collision/CollisionManagerOld.d.ts +0 -27
- package/lib/physics/collision/collider/ICollider.d.ts +0 -13
- package/lib/physics/collision/collider/RectangleCollider.d.ts +0 -31
- package/lib/physics/collision/resolver/CircumferenceCircumferenceResolver.d.ts +0 -7
- package/lib/physics/collision/resolver/CircumferencePolygonResolver.d.ts +0 -23
- package/lib/physics/collision/resolver/CircumferenceRectangleResolver.d.ts +0 -9
- package/lib/physics/collision/resolver/CollisionResolution.d.ts +0 -6
- package/lib/physics/collision/resolver/ICollisionResolver.d.ts +0 -5
- package/lib/physics/collision/resolver/PolygonPolygonResolver.d.ts +0 -15
- package/lib/physics/collision/resolver/RectangleRectangleResolver.d.ts +0 -11
- package/lib/physics/collision-old/CollisionData.d.ts +0 -8
- package/lib/physics/collision-old/CollisionManager.d.ts +0 -30
- package/lib/physics/collision-old/QuadTree.d.ts +0 -32
- package/lib/physics/collision-old/collider/ICollider.d.ts +0 -14
- package/lib/physics/collision-old/collider/RectangleCollider.d.ts +0 -32
- package/lib/physics/collision-old/resolver/AABBResolver.d.ts +0 -14
- package/lib/physics/collision-old/resolver/ICollisionResolver.d.ts +0 -5
- package/lib/physics/collision-old/resolver/SatResolver.d.ts +0 -14
- package/lib/physics/collision-old/shape/Rectangle.d.ts +0 -13
- package/lib/physics/collision-old/shape/Shape.d.ts +0 -28
- package/lib/rendering/CameraData.d.ts +0 -9
- package/lib/rendering/ContextRenderer.d.ts +0 -6
- package/lib/rendering/CullingService.d.ts +0 -10
- package/lib/rendering/FontAtlasFactory.d.ts +0 -24
- package/lib/rendering/RenderManager.d.ts +0 -29
- package/lib/rendering/context2D/Context2DRenderer.d.ts +0 -19
- package/lib/rendering/renderData/ColliderRenderData.d.ts +0 -7
- package/lib/rendering/renderData/GeometricRenderData.d.ts +0 -17
- package/lib/rendering/renderData/ImageRenderData.d.ts +0 -22
- package/lib/rendering/renderData/MaskRenderData.d.ts +0 -9
- package/lib/rendering/renderData/RenderData.d.ts +0 -22
- package/lib/rendering/renderData/TextRenderData.d.ts +0 -22
- package/lib/rendering/renderData/TilemapRenderData.d.ts +0 -28
- package/lib/rendering/webGL/ProgramFactory.d.ts +0 -7
- package/lib/rendering/webGL/ProgramManager.d.ts +0 -26
- package/lib/rendering/webGL/ShaderLoader.d.ts +0 -3
- package/lib/rendering/webGL/TextureFactory.d.ts +0 -8
- package/lib/rendering/webGL/TextureManager.d.ts +0 -11
- package/lib/rendering/webGL/Utils.d.ts +0 -7
- package/lib/rendering/webGL/WebGLRenderer.d.ts +0 -36
- package/lib/rendering/webGL/renderer/GeometricRenderer.d.ts +0 -21
- package/lib/rendering/webGL/renderer/ImageRenderer.d.ts +0 -16
- package/lib/rendering/webGL/renderer/MaskRenderer.d.ts +0 -14
- package/lib/rendering/webGL/renderer/TextRenderer.d.ts +0 -21
- package/lib/rendering/webGL/renderer/TilemapRenderer.d.ts +0 -19
- package/lib/rendering/webGL/shader/imageFragmentShader.d.ts +0 -1
- package/lib/rendering/webGL/shader/imageVertexShader.d.ts +0 -1
- package/lib/rendering/webGL/shader/legacy/imageFragmentShader.d.ts +0 -1
- package/lib/rendering/webGL/shader/legacy/imageVertexShader.d.ts +0 -1
package/lib/index.esm.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
var t=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._x=t,this._y=e}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"magnitude",{get:function(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))},enumerable:!1,configurable:!0}),t.prototype.set=function(t,e){this._x=t,this._y=e},t.prototype.copy=function(t){this.set(t.x,t.y)},t.prototype.equals=function(t){return this._x===t.x&&this._y===t.y},t.prototype.clone=function(){return new t(this._x,this._y)},t.prototype.distance=function(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))},t.add=function(t,e,i){return t.set(e.x+i.x,e.y+i.y),t},t.subtract=function(t,e,i){return t.set(e.x-i.x,e.y-i.y),t},t.unit=function(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t},t.normal=function(t,e){return t.set(-e.y,e.x),this.unit(t,t)},t.scale=function(t,e,i){return t.set(e.x*i,e.y*i),t},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.round=function(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t},t}(),e=function(t,e,i){return Math.min(i,Math.max(e,t))},i=function(t,e){return Math.round(Math.random()*(e-t))+t},n=function(t,e,i){return void 0===i&&(i=2),r(Math.random()*(e-t)+t,i)},r=function(t,e){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)},o=function(t,e,i){void 0===i&&(i=1);for(var n=[],r=t;r<=e;r+=i)n.push(r);return n},s=function(t,e,i){return t>=e&&t<=i},a=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.overlapRectangle=function(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1},e.prototype.overlapVector=function(t){return s(t.x,this.x,this.x1)&&s(t.y,this.y,this.y1)},e}(),h=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}(),c=function(t,e){return c=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])},c(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var u,p=function(){return p=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},p.apply(this,arguments)};function d(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(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(s,a)}h((n=n.apply(t,e||[])).next())}))}function f(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}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,a])}}}function g(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}!function(t){t.Image="Image",t.Audio="Audio",t.Video="Video"}(u||(u={}));var m,y=function(){this.type=null,this.url=null,this.loaded=!1,this.element=null},b=function(){function t(){this.assets=[]}return t.prototype.getAssetsLoaded=function(){return this.assets.reduce((function(t,e){return t&&e.loaded}),!0)},t.prototype.loadImage=function(t){var e=this.createAsset(t,u.Image);return e.element=new Image,e.element.crossOrigin="",e.element.src=t,e.element.naturalWidth?e.loaded=!0:e.element.addEventListener("load",(function(){return e.loaded=!0})),e.element},t.prototype.loadAudio=function(t){var e=this.createAsset(t,u.Audio);return e.element=new Audio,e.element.src=t,e.element.duration?e.loaded=!0:e.element.addEventListener("canplaythrough",(function(){return e.loaded=!0})),e.element},t.prototype.getImage=function(t){return this.getAsset(t,u.Image)},t.prototype.getAudio=function(t){return this.getAsset(t,u.Audio)},t.prototype.getAsset=function(t,e){return void 0===e&&(e=null),this.assets.reduce((function(i,n){return n.url!==t||null!==e&&e!==n.type?i:n}),null).element},t.prototype.createAsset=function(t,e){var i=new y;return i.type=e,i.url=t,this.assets.push(i),i},t}(),v=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return l(e,t),e}(Error),x=function(){function e(e,i,n,r){void 0===n&&(n=6),void 0===r&&(r=15),this._bounds=new a(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=e,this._bounds.updateFromRect(i),this.maxLevels=n,this.maxItems=r,this.updateCache()}return Object.defineProperty(e.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),e.prototype.updateBounds=function(t){this._bounds.updateFromRect(t),this.updateCache()},e.prototype.clearItems=function(){this._items=[],this._quadrants.forEach((function(t){return t.clearItems()}))},e.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},e.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())},e.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},e.prototype.splitQuad=function(){var t=this;this._quadrants=[new a(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new a(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new a(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new a(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(i){return new e(t.level+1,i,t.maxLevels,t.maxItems)}));for(var i=0,n=this._items;i<n.length;i++){var r=n[i];this.insertItemIntoChildrenQuads(r)}this._items=[]},e.prototype.getChildrenQuadrantForItem=function(t){if(0===this._quadrants.length)throw new v("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 v("Item does not fit in any children quadrant");return this.quadsForItem},e.prototype.insertItemIntoChildrenQuads=function(t){this.getChildrenQuadrantForItem(t).forEach((function(e){return e.addItem(t)}))},e.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},e}(),M=function(){function e(e,i,n,r,o){this.collisions=[],this.minBounds=new t,this.maxBounds=new t,this.newBounds=new a(0,0,0,0),this.method=e,this.colliders=[],this.collisionMatrix=o,this.setupQuadTree(i,n,r)}return e.prototype.setupQuadTree=function(t,e,i){i?(this.bounds=i,this.fixedQuadTree=!0):(this.bounds=new a(0,0,0,0),this.fixedQuadTree=!1),this.quadTree=new x(0,this.bounds,t,e)},e.prototype.addCollider=function(t){this.colliders.push(t)},e.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},e.prototype.getCollisionsForCollider=function(t){return this.collisions.filter((function(e){return e.localCollider===t}))},e.prototype.refreshCollisionsForCollider=function(t){-1!==this.colliders.indexOf(t)&&(this.collisions=this.collisions.filter((function(e){return e.localCollider!==t&&e.remoteCollider!==t})),this.narrowPhase(t,this.broadPhase(t)))},e.prototype.clear=function(){this.colliders=[]},e.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()}},e.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)},e.prototype.updateCollisions=function(){var t=this;this.colliders.filter((function(t){return t.updateCollisions})).forEach((function(e){return t.narrowPhase(e,t.broadPhase(e))}))},e.prototype.broadPhase=function(t){var e=this;return this.collisionMatrix?this.quadTree.retrieve(t).filter((function(i){return e.collisionMatrix.some((function(e){return e[0]===t.layer&&e[1]===i.layer||e[1]===t.layer&&e[0]===i.layer}))})):this.quadTree.retrieve(t)},e.prototype.narrowPhase=function(t,e){var i=this;e.filter((function(e){return e.id!==t.id})).forEach((function(e){if(!i.isResolved(t,e)){var n=i.method.getCollisionResolution(t.shape,e.shape);null!==n&&i.collisions.push({localCollider:t,remoteCollider:e,resolution:n},{localCollider:e,remoteCollider:t,resolution:{direction:n.displacementDirection,displacementDirection:n.direction,penetration:n.penetration}})}}))},e.prototype.isResolved=function(t,e){for(var i=0,n=this.collisions;i<n.length;i++){var r=n[i];if(r.localCollider===t&&r.remoteCollider===e)return!0}return!1},e}(),w=function(){function t(t,e,i){if(this._canvas=null,!t)throw new v("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"}(m||(m={}));var _,O=function(){function t(t,e,i,n,r,o,s){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.renderManager=n,this.inputManager=r,this.gameObjectManager=o,this.sceneManager=s,this.running=!1,this.gameLoopAccumulator=0,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene(),this.renderManager.clearCanvas()},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.requestAnimationLoop(window.performance.now()),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.requestAnimationLoop=function(t){var e=this;this.running&&(this.timeManager.updateForBrowser(.001*t),this.gameLoopAccumulator+=this.timeManager.browserDeltaTime,this.gameLoopAccumulator>=this.timeManager.minGameDeltatime&&(this.gameLogicIteration(.001*t),this.gameLoopAccumulator-=this.timeManager.minGameDeltatime),this.renderIteration(),window.requestAnimationFrame((function(t){return e.requestAnimationLoop(t)})))},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(m.Start),this.inputManager.update(),this.dispatchFrameEvent(m.Update),this.dispatchFrameEvent(m.UpdateEngine),this.dispatchFrameEvent(m.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.dispatchFrameEvent(m.UpdatePreRender),this.sceneManager.update()},t.prototype.renderIteration=function(){this.dispatchFrameEvent(m.UpdatePreRender),this.dispatchFrameEvent(m.UpdateCamera),this.dispatchFrameEvent(m.UpdateRender),this.renderManager.clearCanvas(),this.renderManager.render()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(m.UpdatePhysics),this.dispatchFrameEvent(m.UpdateCollider),this.dispatchFrameEvent(m.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=.001*window.performance.now();document.hidden||this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(.001*window.performance.now()-e);window.setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return g(g([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==m.Start&&t!==m.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}(),j=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i,n){var r=new t(n,i);return this.gameObjects.push(r),r.dispatch(m.Init,e),r},t.prototype.findGameObjects=function(t){return t?this.gameObjects.filter((function(e){return e instanceof t})):g([],this.gameObjects,!0)},t.prototype.findGameObjectById=function(t){return this.gameObjects.find((function(e){return e.id===t}))},t.prototype.findGameObject=function(t){return"string"==typeof t?this.gameObjects.find((function(e){return e.name===t})):this.gameObjects.find((function(e){return e instanceof t}))},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParent=function(t,e){return"string"==typeof e?this.gameObjects.find((function(i){return i.name===e&&i.parent===t})):this.gameObjects.find((function(i){return i instanceof e&&i.parent===t}))},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},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(m.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){return e.destroyGameObject(t)}))},t}(),C=function(){function t(){var t=this;this.gamepads=new Map,this.eventHandler=function(e){"gamepadconnected"===e.type?t.gamepadConnected(e.gamepad):"gamepaddisconnected"===e.type&&t.gamepadDisconected(e.gamepad)},window.addEventListener("gamepadconnected",this.eventHandler),window.addEventListener("gamepaddisconnected",this.eventHandler)}return t.prototype.getGamepad=function(t){var e;return null!==(e=this.gamepads.get(t))&&void 0!==e?e:null},t.prototype.gamepadConnected=function(t){this.gamepads.set(t.index,new P),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}(),P=function(){function e(){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._gamepad=t,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._gamepad.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._gamepad.connected},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,"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.prototype.vibrate=function(t,e,i,n){void 0===t&&(t=200),void 0===e&&(e=.2),void 0===i&&(i=.2),void 0===n&&(n=0),this._gamepad.vibrationActuator&&this._gamepad.vibrationActuator.playEffect(this._gamepad.vibrationActuator.type,{duration:t,weakMagnitude:e,strongMagnitude:i,startDelay:n})},e}(),R=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}(),D=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),S=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}();!function(t){t[t.Image=0]="Image",t[t.Text=1]="Text",t[t.Tilemap=2]="Tilemap",t[t.Mask=3]="Mask",t[t.Geometric=4]="Geometric"}(_||(_={}));var A=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}(),T=function(){function t(t,e,i,n){void 0===n&&(n=!1),this.debug=!1,this.renderData=[],this.cameraData=[],this.renderer=t,this.cullingService=e,this.canvasColor=i,this.debug=n}return t.prototype.clearCanvas=function(){this.renderer.clearCanvas(this.canvasColor)},t.prototype.addRenderData=function(t){!1===this.debug&&t.debug||this.renderData.push(t)},t.prototype.addCameraData=function(t){this.cameraData.push(t)},t.prototype.render=function(){var t=this;this.cameraData.sort((function(t,e){return t.depth-e.depth})).forEach((function(e){return t.renderByCamera(e)})),this.clearData()},t.prototype.clearData=function(){this.renderData=[],this.cameraData=[]},t.prototype.renderByCamera=function(t){var e=this;this.orderRendeData(t),this.cullingService.applyCulling(t,this.renderData).forEach((function(i){e.updateFromCameraViewport(t,i),e.renderer.render(t,i)}))},t.prototype.orderRendeData=function(t){this.renderData.sort((function(e,i){return t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer)}))},t.prototype.updateFromCameraViewport=function(t,e){var i=this;!0!==e.ui?e.type===_.Tilemap?e.tilesToRender.forEach((function(e){return i.setPositionInViewport(t,e)})):this.setPositionInViewport(t,e):e.positionInViewport=e.position},t.prototype.setPositionInViewport=function(t,e){e.positionInViewport.set(Math.round(e.position.x-t.worldSpaceRect.x-t.worldSpaceRect.width/2),Math.round(e.position.y-t.worldSpaceRect.y-t.worldSpaceRect.height/2))},t}(),F="undefined"!=typeof Float32Array?Float32Array:Array;function E(){var t=new F(16);return F!=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 B(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 I(t,e,i){var n,r,o,s,a,h,c,l,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],s=e[3],a=e[4],h=e[5],c=e[6],l=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]=s,t[4]=a,t[5]=h,t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=n*g+a*m+u*y+e[12],t[13]=r*g+h*m+p*y+e[13],t[14]=o*g+c*m+d*y+e[14],t[15]=s*g+l*m+f*y+e[15]),t}function V(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 U(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],h=e[3],c=e[4],l=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+c*n,t[1]=s*r+l*n,t[2]=a*r+u*n,t[3]=h*r+p*n,t[4]=c*r-o*n,t[5]=l*r-s*n,t[6]=u*r-a*n,t[7]=p*r-h*n,t}function L(t,e,i,n,r,o,s){var a=1/(e-i),h=1/(n-r),c=1/(o-s);return t[0]=-2*a,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*c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+n)*h,t[14]=(s+o)*c,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 G,k=function(t){var e=/^#?([a-f\d]{2})?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[2],16)/256,g:parseInt(e[3],16)/256,b:parseInt(e[4],16)/256,a:void 0!==e[1]?parseInt(e[1],16)/256:1}:null},z=function(){function t(t,e,i){this.lastTexture=null,this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=E(),this.modelMatrix=E(),this.textureMatrix=E(),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=B(this.modelMatrix),I(this.modelMatrix,this.modelMatrix,[i.positionInViewport.x,i.positionInViewport.y,0]),U(this.modelMatrix,this.modelMatrix,i.rotation),V(this.modelMatrix,this.modelMatrix,[i.width*(i.flipHorizontal?-1:1),i.height*(i.flipVertical?-1:1),1]),this.textureMatrix=B(this.textureMatrix),i.slice&&(I(this.textureMatrix,this.textureMatrix,[i.slice.x/i.image.naturalWidth,i.slice.y/i.image.naturalHeight,0]),V(this.textureMatrix,this.textureMatrix,[i.slice.width/i.image.naturalWidth,i.slice.height/i.image.naturalHeight,1])),this.projectionMatrix=B(this.projectionMatrix),L(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=k(i.tintColor),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.tintColorUniform,s,a,h,c)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,i.maskColor?1:0),i.maskColor){var l=k(i.maskColor);s=l.r,a=l.g,h=l.b;this.gl.uniform4f(this.programManager.maskColorUniform,s,a,h,i.alpha),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(r=i.maskColorMix)&&void 0!==r?r:0)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}(),W=function(){function t(t){this.shaderLoader=t}return t.prototype.create=function(t,e,i){var n=t.createProgram(),r=this.shaderLoader.load(t,t.VERTEX_SHADER,e),o=this.shaderLoader.load(t,t.FRAGMENT_SHADER,i);return this.link(t,n,r,o),n},t.prototype.link=function(t,e,i,n){t.attachShader(e,i),t.attachShader(e,n),t.linkProgram(e);var r=t.LINK_STATUS;if(!t.getProgramParameter(e,r)){var o=t.getProgramInfoLog(e);throw t.deleteProgram(e),new v("Unable to initialize the Program: "+o)}},t}(),H=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 v("Unable to initialize the shader program: "+o)}return n},t}(),Y=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"}(G||(G={}));var N,X=function(){function t(t,e,i,n,r,o,s,a,h,c){this.canvas=e,this.gl=this.canvas.getContext(t),i.loadProgram(),this.textureManager=n,this.imageRenderer=o,this.tilemapRenderer=s,this.textRenderer=a,this.geometricRenderer=h,this.maskRenderer=c,this.fontAtlasFactory=r}return t.prototype.clearCanvas=function(t){var e=k(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)},t.prototype.render=function(t,e){e.type===_.Image&&(this.renderImage(t,e),this.lastRender="image"),e.type===_.Tilemap&&(this.renderTilemap(t,e),this.lastRender="tilemap"),e.type===_.Text&&(this.renderText(t,e),this.lastRender="text"),e.type===_.Geometric&&(this.geometricRenderer.render(t.viewportRect,e,this.lastRender),this.lastRender="geometric"),e.type===_.Mask&&(this.renderMask(t,e),this.lastRender="mask")},t.prototype.renderImage=function(t,e){this.imageRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderTilemap=function(t,e){this.tilemapRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,this.textureManager.getOrCreateTextureFromImage(e.image,e.smooth),e,this.lastRender)},t.prototype.renderText=function(t,e){this.fontAtlasFactory.loadingFontAtlas(e.fontFamily)||(this.fontAtlasFactory.hasFontAtlas(e.fontFamily)?this.fontAtlasLoaded(this.fontAtlasFactory.getFontAtlas(e.fontFamily),t,e):this.fontAtlasFactory.asyncCreate(e.charRanges,e.fontFamily,e.fontUrl,e.bitmapSize))},t.prototype.renderMask=function(t,e){this.maskRenderer.render(!0===e.ui?t.originalViewportRect:t.viewportRect,e,this.lastRender)},t.prototype.fontAtlasLoaded=function(t,e,i){this.textRenderer.render(!0===i.ui?e.originalViewportRect:e.viewportRect,this.textureManager.getOrCreateTextureFromCanvas(i.fontFamily,t.canvas,i.smooth),t,i,this.lastRender)},t}(),q=function(){function t(t,e){this.game=t,this.renderManager=e,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.sceneToLoad=null}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i,n){var r=this;if(void 0===n&&(n=!1),this.scenes.has(e))throw new v("There is already a scene with the name '"+e+"'");this.scenes.set(e,(function(){var n=new t(e,r.game);return r.currentScene=n,n.dispatch(m.Init,i),n})),!0!==n&&null!==this.openingSceneName||(this.openingSceneName=e)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new v("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new v("Game not initialized.");if(!1===this.scenes.has(t))throw new v("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.scenes.get(t)()},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(m.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager&&this.renderManager.clearData())},t}(),Q=[60,120,180,240],K=function(){function t(t){if(this.minGameDeltatime=0,this.minPhysicsDeltaTime=0,this.gameFramerate=60,this.physicsFramerate=180,this.timeScale=1,this.browserDeltaTime=0,this.gameDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.maxDeltaTime=1/15,this.thenForGame=0,this.thenForPhysics=0,this.thenForBrowser=0,!Q.includes(t))throw new v("Invalid Physics frame rate. Allowed: ["+Q.join(", ")+"]");this.physicsFramerate=t,this.minGameDeltatime=parseFloat((1/this.gameFramerate).toFixed(6)),this.minPhysicsDeltaTime=parseFloat((1/this.physicsFramerate).toFixed(6))}return t.prototype.updateForGame=function(t){this.unscaledGameDeltaTime=Math.min(Math.max(this.minGameDeltatime,t-this.thenForGame),this.maxDeltaTime),this.thenForGame=t},t.prototype.updateForBrowser=function(t){this.browserDeltaTime=Math.min(Math.max(0,t-this.thenForBrowser),this.maxDeltaTime),this.thenForBrowser=t},t.prototype.updateForPhysics=function(t){this.unscaledPhysicsDeltaTime=Math.min(Math.max(0,t-this.thenForPhysics),this.maxDeltaTime),this.thenForPhysics=t},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}(),$=function(){function t(t){this.textures=new Map,this.textureFactory=t}return t.prototype.getTexture=function(t){var e;return null!==(e=this.textures.get(Symbol.for(t)))&&void 0!==e?e:null},t.prototype.getOrCreateTextureFromImage=function(t,e){var i;return void 0===e&&(e=!0),null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)},t.prototype.createTextureFromImage=function(t,e){void 0===e&&(e=!0);var i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i},t.prototype.getOrCreateTextureFromCanvas=function(t,e,i){var n;return void 0===i&&(i=!0),null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)},t.prototype.createTextureFromCanvas=function(t,e,i){void 0===i&&(i=!0);var n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n},t}(),J=function(){function t(t,e,i){this.gl=i.getContext(e),this.programFactory=t,this.contextVersion=e}return t.prototype.loadProgram=function(){this.program=this.contextVersion===G.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}(),Z=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 tt(e);this.chars=[];for(var s=0;s<t.length;s+=2)for(var a=t[s];a<=t[s+1];a++)this.chars.push(String.fromCharCode(a));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 d(this,void 0,void 0,(function(){var i;return f(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}(),tt=function(t){this.canvas=document.createElement("canvas"),this.glyphsData=new Map,this.name=t},et=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=E(),this.modelMatrix=E(),this.textureMatrix=E()}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=B(this.modelMatrix),I(this.modelMatrix,this.modelMatrix,this.getTranslationForOrientation(n)),U(this.modelMatrix,this.modelMatrix,n.rotation),this.textureMatrix=B(this.textureMatrix),V(this.textureMatrix,this.textureMatrix,[1/i.canvas.width,1/i.canvas.height,1]),this.projectionMatrix=B(this.projectionMatrix),L(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=k(n.color),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.maskColorUniform,s,a,h,c),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 s=e.text[o];if("\n"!==s)if(" "!==s){var a=t.glyphsData.get(s);a&&(n.x2=n.x1+e.fontSize,r.x1=a.x+e.bitmapOffset.x,r.y1=a.y+e.bitmapOffset.y,r.x2=a.x+a.width-1,r.y2=a.y+a.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 it,nt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Geometric,e}return l(e,t),e}(A),rt=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=E(),this.modelMatrix=E(),this.textureMatrix=E();var n=2*Math.PI/60;this.circumferenceVertices=new Float32Array(o(1,60,1).reduce((function(t,e){return g(g([],t,!0),[Math.cos(e*n),Math.sin(e*n)],!1)}),[]))}return t.prototype.render=function(t,e,i){switch(this.lastRender=i,e.shape){case N.Polygon:this.renderLines(t,e,this.gl.LINE_LOOP);break;case N.Line:this.renderLines(t,e,this.gl.LINES);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,s=e.color,a=this.generateVerticesKey(n);!1===this.vertices.has(a)&&this.vertices.set(a,new Float32Array(this.generatePolygonVertices(n)));var h=this.vertices.get(a);this.lastVertices===a&&"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.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW)),this.lastVertices=a,this.modelMatrix=B(this.modelMatrix),I(this.modelMatrix,this.modelMatrix,[r.x,r.y,0]),U(this.modelMatrix,this.modelMatrix,o),this.projectionMatrix=B(this.projectionMatrix),L(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 c=k(s),l=c.r,u=c.g,p=c.b,d=c.a;this.gl.uniform4f(this.programManager.solidColorUniform,l,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.lastVertices=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),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=B(this.modelMatrix),I(this.modelMatrix,this.modelMatrix,[n.x,n.y,0]),V(this.modelMatrix,this.modelMatrix,[i,i,1]),this.projectionMatrix=B(this.projectionMatrix),L(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=k(r),s=o.r,a=o.g,h=o.b,c=o.a;this.gl.uniform4f(this.programManager.solidColorUniform,s,a,h,c),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"}(it||(it={}));var ot,st=function(){function t(t,e){this.circumferenceResolver=t,this.satResolver=e}return t.prototype.getCollisionResolution=function(t,e){return t.type===it.Circumference&&e.type===it.Circumference?this.circumferenceResolver.resolve(t,e):this.satResolver.resolve(t,e)},t}(),at=function(){function e(e){var i=this;this._touching=!1,this._positionInViewport=new t(0,0),this._radius=new t(0,0),this.eventHandler=function(t){"touchstart"===t.type&&(i._touching=!0,i.updatePosition(t)),"touchmove"===t.type&&i.updatePosition(t),"touchend"!==t.type&&"touchcancel"!==t.type||(i._touching=!1)},this.canvas=e,this.canvas.addEventListener("touchstart",this.eventHandler),this.canvas.addEventListener("touchend",this.eventHandler),this.canvas.addEventListener("touchcancel",this.eventHandler),this.canvas.addEventListener("touchmove",this.eventHandler)}return Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touching",{get:function(){return this._touching},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},enumerable:!1,configurable:!0}),e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),0!==t.targetTouches.length&&(this._positionInViewport.set((t.targetTouches[0].clientX-this.canvas.offsetLeft)/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-(t.targetTouches[0].clientY-this.canvas.offsetTop)/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2),this._radius.set(t.targetTouches[0].radiusX,t.targetTouches[0].radiusY))},e}(),ht=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===it.Polygon&&e.type===it.Polygon?this.AABBResolver.resolve(t,e):t.type===it.Circumference&&e.type===it.Polygon?this.circumferenceAABBResolver.resolve(t,e):t.type===it.Polygon&&e.type===it.Circumference?this.circumferenceAABBResolver.resolve(e,t,!0):t.type===it.Circumference&&e.type===it.Circumference?this.circumferenceResolver.resolve(t,e):null},t}(),ct=function(){function t(){}return t.prototype.applyCulling=function(t,e){var i=this;return e.filter((function(e){if(!1===t.layers.includes(e.layer))return!1;var n=e.ui?t.viewportRect:t.worldSpaceRect;switch(e.type){case _.Image:return i.cullSprite(n,e);case _.Tilemap:return i.cullTilemap(n,e);case _.Geometric:return i.cullGeometric(n,e);case _.Text:return i.cullText(n,e);case _.Mask:return i.cullSprite(n,e)}}))},t.prototype.cullSprite=function(t,e){return this.isTargetVisible(t,{x:e.position.x-e.width/2,x1:e.position.x+e.width/2,y:e.position.y-e.height/2,y1:e.position.y+e.height/2})},t.prototype.cullTilemap=function(t,e){var i=this;return e.tilesToRender=e.tilesData.filter((function(n){return i.isTargetVisible(t,{x:n.position.x-e.tileWidth/2,x1:n.position.x+e.tileWidth/2,y:n.position.y-e.tileHeight/2,y1:n.position.y+e.tileHeight/2})})),e.tilesData.length>0},t.prototype.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}(),lt=function(){function t(t,e,i){this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.p={x1:0,y1:0,x2:0,y2:0},this.t={x1:0,y1:0,x2:0,y2:0},this.gl=e.getContext(t),this.programManager=i,this.projectionMatrix=E(),this.modelMatrix=E(),this.textureMatrix=E()}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=B(this.modelMatrix),this.textureMatrix=B(this.textureMatrix),V(this.textureMatrix,this.textureMatrix,[1/i.image.naturalWidth,1/i.image.naturalHeight,1]),this.projectionMatrix=B(this.projectionMatrix),L(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=k(i.tintColor),o=r.r,s=r.g,a=r.b,h=r.a;this.gl.uniform4f(this.programManager.tintColorUniform,o,s,a,h)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)},t.prototype.generateVertices=function(t){var e=this;this.posVertices=[],this.texVertices=[],t.tilesToRender.forEach((function(i){var n,r;e.p.x1=i.positionInViewport.x-t.tileWidth/2,e.p.x2=i.positionInViewport.x+t.tileWidth/2,e.p.y1=i.positionInViewport.y-t.tileHeight/2,e.p.y2=i.positionInViewport.y+t.tileHeight/2,e.posVertices.push(e.p.x1,e.p.y1,e.p.x2,e.p.y1,e.p.x1,e.p.y2,e.p.x1,e.p.y2,e.p.x2,e.p.y1,e.p.x2,e.p.y2),e.t.x1=i.tile.x,e.t.y1=i.tile.y,e.t.x2=i.tile.x+i.tile.width-(null!==(n=t.textureCorrection)&&void 0!==n?n:0),e.t.y2=i.tile.y+i.tile.height-(null!==(r=t.textureCorrection)&&void 0!==r?r:0),e.texVertices.push(e.t.x1,e.t.y2,e.t.x2,e.t.y2,e.t.x1,e.t.y1,e.t.x1,e.t.y1,e.t.x2,e.t.y2,e.t.x2,e.t.y1)}))},t}(),ut=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.loadImage(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}(),pt=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}(),dt=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}(),ft=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}(),gt=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}),Object.defineProperty(t,"browserDeltaTime",{get:function(){return this.timeManager.browserDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),mt=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i,n){return this.manager.addGameObject(t,e,i,n)},t.findAllGameObjects=function(){return this.manager.findGameObjects()},t.findGameObjects=function(t){return this.manager.findGameObjects(t)},t.findGameObject=function(t){return this.manager.findGameObject(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParent=function(t,e){return this.manager.findGameObjectByParent(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t}(),yt=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=E(),this.modelMatrix=E(),this.textureMatrix=E()}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=B(this.modelMatrix),I(this.modelMatrix,this.modelMatrix,[e.positionInViewport.x,e.positionInViewport.y,0]),U(this.modelMatrix,this.modelMatrix,e.rotation),V(this.modelMatrix,this.modelMatrix,[e.width,e.height,1]),this.projectionMatrix=B(this.projectionMatrix),L(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=k(e.color),r=n.r,o=n.g,s=n.b,a=n.a;this.gl.uniform4f(this.programManager.solidColorUniform,r,o,s,a),this.gl.uniform1f(this.programManager.alphaUniform,e.alpha),this.gl.drawArrays(this.gl.TRIANGLES,0,6)},t}();!function(t){t[t.Static=0]="Static",t[t.Dynamic=1]="Dynamic",t[t.Kinematic=2]="Kinematic"}(ot||(ot={}));var bt,vt=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){i.type===ot.Dynamic?e.dynamicUpdate(i,t):i.type===ot.Kinematic&&e.kinematicUpdate(i,t)}))},e.prototype.dynamicUpdate=function(t,e){this.applyGravity(t,e),this.applyVelocity(t,e,"x"),this.applyReposition(t,"x",!0),this.applyVelocity(t,e,"y"),this.applyReposition(t,"y",!0)},e.prototype.kinematicUpdate=function(e,i){t.add(e.position,e.position,t.scale(this.cacheVelocity,e.velocity,i))},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,n){var r=this;this.cacheCollisions=this.getCollisions(e),0!==this.cacheCollisions.length&&(this.cacheDisplacement.set(0,0),this.cacheCollisions.forEach((function(t){r.cacheNewDisplacement=t.resolution.displacementDirection[i]*t.resolution.penetration,r.cacheDisplacement[i]=Math.abs(r.cacheDisplacement[i])>Math.abs(r.cacheNewDisplacement)?r.cacheDisplacement[i]:r.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,r.cacheDisplacement),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)})),n&&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(t,i){return t.push.apply(t,e.collisionManager.getCollisionsForCollider(i).filter((function(t){return t.remoteCollider.physics&&t.remoteCollider.rigidBody}))),t}),[])},e.prototype.clear=function(){this.rigidBodyData=[]},e}(),xt=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.resolve=function(e,i){var n=e.boundingBox,r=i.boundingBox;return this.overlapX=Math.min(n.x1,r.x1)-Math.max(n.x,r.x),this.overlapY=Math.min(n.y1,r.y1)-Math.max(n.y,r.y),this.overlapX<0||this.overlapY<0?null:(this.direction.set(Math.sign(r.x1-n.x1),Math.sign(r.y1-n.y1)),this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displacementDirection.set(0,-this.direction.y),this.preventContainment(n.y,n.y1,r.y,r.y1)):(this.minOverlap=this.overlapX,this.displacementDirection.set(-this.direction.x,this.overlapY===this.overlapX?-this.direction.y:0),this.preventContainment(n.x,n.x1,r.x,r.x1)),t.unit(this.displacementDirection,this.displacementDirection),{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)})},e.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),s=Math.abs(i-r);o<s?this.minOverlap+=o:(this.minOverlap+=s,t.scale(this.displacementDirection,this.displacementDirection,-1))}},e}(),Mt=function(){function i(){this.closestPoint=new t,this.distance=new t,this.direction=new t}return i.prototype.resolve=function(i,n,r){return void 0===r&&(r=!1),this.closestPoint.set(e(i.position.x,n.boundingBox.x,n.boundingBox.x1),e(i.position.y,n.boundingBox.y,n.boundingBox.y1)),t.subtract(this.distance,this.closestPoint,i.position),this.distance.magnitude>i.radius?null:(t.unit(this.direction,this.distance),{penetration:i.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)})},i}(),wt=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}(),_t=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displacementDirection=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===it.Circumference?this.setCircumferenceAxis(e,i):i.type===it.Circumference&&this.setCircumferenceAxis(i,e),this.axes=g(g([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(e.type===it.Circumference?this.setCircumferenceVertices(e,this.axes[n]):i.type===it.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.displacementDirection.copy(this.axes[n]),this.projA.max<this.projB.max&&t.scale(this.displacementDirection,this.displacementDirection,-1))}return{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)}},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}(),Ot=function(){function t(t,e,i,n,r){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.gameObjectManager=n,this.sceneManager=r,this.running=!1,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene()},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.asyncGameLoop(),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(m.Start),this.dispatchFrameEvent(m.Update),this.dispatchFrameEvent(m.UpdateEngine),this.dispatchFrameEvent(m.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.sceneManager.update()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(m.UpdatePhysics),this.dispatchFrameEvent(m.UpdateCollider),this.dispatchFrameEvent(m.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncGameLoop=function(){var t=this;if(this.running){var e=process.uptime();this.gameLogicIteration(e);var i=1/this.timeManager.gameFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncGameLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=process.uptime();this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return g(g([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==m.Start&&t!==m.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}(),jt=function(t,e){if(e.collisions.method===bt.AABB)t.add("CollisionMethod",(function(){return new ht(new xt,new Mt,new wt)}));else{if(e.collisions.method!==bt.SAT)throw new v("Invalid collision method.");t.add("CollisionMethod",(function(){return new st(new wt,new _t)}))}t.add("CollisionManager",(function(){return new M(t.getSingleton("CollisionMethod"),e.collisions.quadMaxLevel,e.collisions.collidersPerQuad,e.collisions.quadTreeBounds,e.collisions.collisionMatrix)})),t.add("RigidBodyManager",(function(){return new vt(t.getSingleton("CollisionManager"))}))},Ct=function(t,e){var i=t.getSingleton("DomManager"),n=Dt();if(null===n)throw new v("WebGL not suported in your browser.");Pt(n,t,i),e.debugEnabled&&console.log("Using WebGL rendering context (version: "+n+")"),t.add("FontAtlasFactory",(function(){return new Z})),t.add("CullingService",(function(){return new ct})),t.add("RenderManager",(function(){return new T(t.getSingleton("Renderer"),t.getSingleton("CullingService"),e.canvasColor,e.debugEnabled)}))},Pt=function(t,e,i){e.add("ShaderLoader",(function(){return new H})),e.add("ProgramFactory",(function(){return new W(e.getSingleton("ShaderLoader"))})),e.add("ProgramManager",(function(){return new J(e.getSingleton("ProgramFactory"),t,i.canvas)})),e.add("TextureFactory",(function(){return new Y(t,i.canvas)})),e.add("TextureManager",(function(){return new $(e.getSingleton("TextureFactory"))})),e.add("WebGLImageRenderer",(function(){return new z(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTextRenderer",(function(){return new et(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLGeometricRenderer",(function(){return new rt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLTilemapRenderer",(function(){return new lt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("WebGLMaskRenderer",(function(){return new yt(t,i.canvas,e.getSingleton("ProgramManager"))})),e.add("Renderer",(function(){return new X(t,i.canvas,e.getSingleton("ProgramManager"),e.getSingleton("TextureManager"),e.getSingleton("FontAtlasFactory"),e.getSingleton("WebGLImageRenderer"),e.getSingleton("WebGLTilemapRenderer"),e.getSingleton("WebGLTextRenderer"),e.getSingleton("WebGLGeometricRenderer"),e.getSingleton("WebGLMaskRenderer"))}))},Rt=function(t){var e=t.getSingleton("DomManager");t.add("InputManager",(function(){return new R(new S(e.canvas),new D(e.canvas),new C,new at(e.canvas))}))},Dt=function(){return null!==document.createElement("canvas").getContext(G.WebGL2)?G.WebGL2:null!==document.createElement("canvas").getContext(G.LegacyWebGL)?G.LegacyWebGL:null},St=function(t,e){e.headless||(ut.initialize(t.getSingleton("AssetManager")),pt.initialize(t.getSingleton("DomManager")),dt.initialize(t.getSingleton("InputManager"))),ft.initialize(t.getSingleton("SceneManager")),gt.initialize(t.getSingleton("TimeManager")),mt.initialize(t.getSingleton("GameObjectManager"))},At=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 v("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 v("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 v("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new v("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 v("Invalid constant name: "+t);return this.constants.get(t)},t}());!function(t){t.AABB="aabb",t.SAT="sat"}(bt||(bt={}));var Tt,Ft={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:180,headless:!1,collisions:{method:bt.AABB,quadMaxLevel:6,collidersPerQuad:15}},Et=function(){function t(t){this._config=p(p({},Ft),t),this._config.collisions=p(p({},Ft.collisions),t.collisions),At.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){!function(t,e){t.addConstant("GameConfig",e),t.add("TimeManager",(function(){return new K(e.physicsFramerate)})),t.add("GameObjectManager",(function(){return new j})),jt(t,e),e.headless?t.add("IterationManager",(function(){return new Ot(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})):(t.add("DomManager",(function(){return new w(e.containerNode,e.gameWidth,e.gameHeight)})),Ct(t,e),Rt(t),t.add("AssetManager",(function(){return new b})),t.add("IterationManager",(function(){return new O(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))}))),t.add("SceneManager",(function(){return new q(t.getConstant("Game"),e.headless?void 0:t.getSingleton("RenderManager"))})),St(t,e)}(At,this._config),this.sceneManager=At.getSingleton("SceneManager"),this.iterationManager=At.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.iterationManager.running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i,n){void 0===n&&(n=!1),this.sceneManager.addScene(t,e,i,n)},t.prototype.run=function(){this.iterationManager.start()},t.prototype.stop=function(){this.iterationManager.stop()},t.prototype.pause=function(){this.iterationManager.pause()},t.prototype.resume=function(){this.iterationManager.resume()},t}(),Bt=function(){var t=(new Date).getTime(),e="undefined"!=typeof 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)}))},It=function(){function t(){this.gameObjectManager=At.getSingleton("GameObjectManager"),this.updateEvent=m.Update,this.started=!1}return t.prototype.dispatch=function(t,e){t===m.Init&&this.init?this.init(e):t!==m.Start||this.started?t===this.updateEvent&&this.started&&this.update?this.update():t===m.Destroy&&(this.onDestroy&&this.onDestroy(),this._destroy()):(this.start&&this.start(),this.started=!0)},t.prototype.addGameObject=function(t,e,i){return"string"==typeof e&&(i=e,e={}),this.gameObjectManager.addGameObject(t,e,void 0,i)},t.prototype.findGameObjects=function(t){return t?this.gameObjectManager.findGameObjects(t):this.gameObjectManager.findGameObjects()},t.prototype.findGameObject=function(t){return this.gameObjectManager.findGameObject(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t}(),Vt=function(t){function e(e,i){void 0===i&&(i="");var n=t.call(this)||this;return n.sceneManager=At.getSingleton("SceneManager"),n.id=Bt(),n.allowMultiple=!0,n._active=!0,n.gameObject=e,n.name=i,n}return l(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active=t,this.onActiveChange()},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.getGameObject=function(){return this.gameObject},e.prototype.getComponents=function(t){return t?this.gameObject.getComponents(t):this.gameObject.getComponents()},e.prototype.getComponent=function(t){return this.gameObject.getComponent(t)},e.prototype.hasComponent=function(t){return this.gameObject.hasComponent(t)},e.prototype.removeComponent=function(t){this.gameObject.removeComponent(t)},e.prototype._destroy=function(){var t=this;Object.keys(this).forEach((function(e){return delete t[e]}))},e}(It),Ut=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdateEngine,e}return l(e,t),e}(Vt),Lt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdateCollider,e}return l(e,t),e}(Vt),Gt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdatePhysics,e}return l(e,t),e}(Vt),kt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdateTransform,e}return l(e,t),e}(Vt),zt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdatePreRender,e}return l(e,t),e}(Vt),Wt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdateCamera,e}return l(e,t),e}(Vt),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=m.UpdateRender,e}return l(e,t),e}(Vt),Yt=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.parentScale=!0,i.parentRotation=!0,i._position=new t,i._scale=new t(1,1),i._rotation=new h,i._innerPosition=new t,i._parent=null,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i}return l(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(t){this._scale.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._rotation.direction},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"innerPosition",{get:function(){return this._innerPosition},set:function(t){this._innerPosition.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e,null!==this._parent&&t.subtract(this._innerPosition,this._position,this._parent.position)},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent&&this.setPositionFromParent(),this.lastPosition.copy(this._position)},i.prototype.setParent=function(){null!==this.gameObject.parent&&this._parent!==this.gameObject.parent.transform?(this._parent=this.gameObject.parent.transform,t.subtract(this._innerPosition,this._position,this._parent.position)):null===this.gameObject.parent&&(this._parent=null)},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._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}(kt),Nt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=At.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return l(e,t),e.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return t.collisionManager.addCollider(e)}))},e.prototype.collidesWithLayer=function(t){return null!==this.getCollisionWithLayer(t)},e.prototype.getCollisionWithLayer=function(t){for(var e=0,i=this.colliders;e<i.length;e++)for(var n=i[e],r=0,o=this.collisionManager.getCollisionsForCollider(n);r<o.length;r++){var s=o[r];if(s.remoteCollider.layer===t)return this.createCollisionData(s)}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,s=this.collisionManager.getCollisionsForCollider(r);o<s.length;o++){var a=s[o];a.remoteCollider.layer===t&&e.push(this.createCollisionData(a))}return e},e.prototype.createCollisionData=function(t){return{gameObject:this.gameObjectManager.findGameObjectById(t.remoteCollider.id),collider:t.remoteCollider,resolution:t.resolution,getGameObject:function(){return this.gameObject}}},e.prototype.onActiveChange=function(){this.renderer&&(this.renderer.active=this.active)},e}(Lt),Xt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMultiple=!1,t.rigidBodyManager=At.getSingleton("RigidBodyManager"),t}return l(i,e),Object.defineProperty(i.prototype,"velocity",{get:function(){return this.data.velocity},set:function(t){this.data.velocity.set(t.x,t.y)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gravity",{get:function(){return this.data.gravity},set:function(t){this.data.gravity=Math.abs(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rigidBodyType",{get:function(){return this.data.type},enumerable:!1,configurable:!0}),i.prototype.init=function(e){var i,n=e.rigidBodyType,r=e.gravity;this.data={type:n,position:null,gravity:null!==(i=Math.abs(r))&&void 0!==i?i:10,velocity:new t,colliders:[]}},i.prototype.start=function(){if(0===this.getColliders().length)throw new v("RigidBody needs at least one Collider with physics")},i.prototype.update=function(){this.data.type!==ot.Static&&(this.data.position=this.gameObject.transform.parent?this.gameObject.transform.innerPosition:this.gameObject.transform.position,this.data.colliders=this.getColliders(),this.rigidBodyManager.addRigidBodyData(this.data))},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Nt&&e.physics?g(g([],t,!0),e.colliders,!0):t}),[])},i}(Ut),qt="Default",Qt=function(t){function e(e,i){void 0===e&&(e="");var n=t.call(this)||this;return n.id=Bt(),n.layer="Default",n.ui=!1,n.keep=!1,n._parent=null,n._active=!0,n.sceneManager=At.getSingleton("SceneManager"),n.components=[],n.activeComponentsCache=[],n.activeChildrenCache=[],n.name=e,n.addComponent(Yt),n.parent=null!=i?i:null,n}return l(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active!==t&&(this._active=t,this.onActiveChange(),this.updateComponentsActiveStatus(),this.updateChildrenActiveStatus())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=null!==t?t.transform:null},enumerable:!1,configurable:!0}),e.prototype.updateComponentsActiveStatus=function(){var t=this;!1===this.active&&(this.activeComponentsCache=this.components.filter((function(t){return t.active}))),this.activeComponentsCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeComponentsCache=[])},e.prototype.updateChildrenActiveStatus=function(){var t=this;!1===this.active&&(this.activeChildrenCache=this.getChildren().filter((function(t){return t.active}))),this.activeChildrenCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeChildrenCache=[])},Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(Yt)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rigidBody",{get:function(){return this.getComponent(Xt)},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.addComponent=function(t,e,i){var n="string"==typeof e?void 0:e,r=new t(this,"string"==typeof e?e:i);return this.checkMultipleComponent(r,t),this.components.push(r),r.dispatch(m.Init,n),r},e.prototype.checkMultipleComponent=function(t,e){if(!1===t.allowMultiple&&this.hasComponent(e))throw new v("GameObject only allows one component of type "+e.name)},e.prototype.getComponents=function(t){return t?this.components.filter((function(e){return e instanceof t})):this.components},e.prototype.getComponent=function(t){return"string"==typeof t?this.components.find((function(e){return e.name===t})):this.components.find((function(e){return e instanceof t}))},e.prototype.hasComponent=function(t){return"string"==typeof t?this.components.some((function(e){return e.name===t})):this.components.some((function(e){return e instanceof t}))},e.prototype.removeComponent=function(t){var e=this.components.indexOf(t);-1!==e&&this.components.splice(e,1)[0].dispatch(m.Destroy)},e.prototype.addChild=function(t,e,i){var n=this.gameObjectManager.addGameObject(t,e,this,i);return n.transform.innerPosition.set(0,0),n.transform.position.copy(this.transform.position),n},e.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},e.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParent(this,t)},e.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},e.prototype._destroy=function(){var t=this;this.destroyComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},e.prototype.destroyComponents=function(){for(var t=0;t<this.components.length;t++)this.components[t].dispatch(m.Destroy),delete this.components[t];this.components=[]},e}(It),Kt=function(){this.depth=0,this.layers=[],this.originalViewportRect=null,this.viewportRect=null,this.worldSpaceRect=null,this.zoom=0},$t=["Default"],Jt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMultiple=!1,e.renderManager=At.getSingleton("RenderManager"),e._layers=$t,e._depth=0,e._zoom=1,e._originalViewportRect=new a(0,0,0,0),e._viewportRect=new a(0,0,0,0),e._worldSpaceRect=new a(0,0,0,0),e.canvas=At.getSingleton("DomManager").canvas,e.cameraData=new Kt,e}return l(e,t),Object.defineProperty(e.prototype,"layers",{get:function(){return this._layers},set:function(t){this._layers=g(g([],$t,!0),t,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depth",{get:function(){return this._depth},set:function(t){this._depth=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new v("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalViewportRect",{get:function(){return this._originalViewportRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"worldSpaceRect",{get:function(){return this._worldSpaceRect},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportRect",{get:function(){return this._viewportRect},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){this._layers.push(t)},e.prototype.update=function(){this.updateOriginalViewportRect(),this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},e.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},e.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},e.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},e.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)},e}(Wt),Zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e.prototype.init=function(){this.transform.position.set(0,0),this.camera=this.addComponent(Jt)},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}(Qt),te=function(t){function e(e,i){var n=t.call(this)||this;return n.name=e,n.game=i,n.game.config.headless||n.addGameObject(Zt),n}return l(e,t),Object.defineProperty(e.prototype,"gameCamera",{get:function(){return this.findGameObject(Zt)},enumerable:!1,configurable:!0}),e.prototype._destroy=function(){var t=this;this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},e}(It),ee=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}(),ie=function(){function e(e){this._type=it.Polygon,this._vertices=[],this._boundingBox=new a(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=e;for(var i=0;i<this._vertexModel.length;i++)this._vertices.push(new t),this._projectionAxes.push(new t)}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boundingBox",{get:function(){return this._boundingBox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"projectionAxes",{get:function(){return this._projectionAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexModel",{get:function(){return this._vertexModel},set:function(t){this._vertexModel=t},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},e.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)},e.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)},e.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]))},e}(),ne=function(e){function i(i,n,r){var o=e.call(this,[new t(-i/2,-n/2),new t(-i/2,n/2),new t(i/2,n/2),new t(i/2,-n/2)])||this;return o.width=i,o.height=n,o._position.copy(r),o._projectionAxes=[new t,new t],o.update(),o}return l(i,e),i.prototype.updateSize=function(t,e){this.width=t,this.height=e,this.vertexModel[0].set(-t/2,-e/2),this.vertexModel[1].set(-t/2,e/2),this.vertexModel[2].set(t/2,e/2),this.vertexModel[3].set(t/2,-e/2)},i.prototype.updateProjectionAxes=function(){t.unit(this._projectionAxes[0],t.subtract(this.projectionAxes[0],this._vertices[1],this._vertices[0])),t.normal(this._projectionAxes[1],this._projectionAxes[0])},i}(ie),re=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realWidth=0,i.realHeight=0,i.realOffset=new t,i.realPosition=new t,i.realRotation=0,i.applyRotation=At.getConstant("GameConfig").collisions.method===bt.SAT,i.innerPosition=new t,i}return l(i,e),i.prototype.init=function(t){var e,i,n,r,o;this.width=t.width,this.height=t.height,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&At.getConstant("GameConfig").debugEnabled,this.rotation=null!==(o=t.rotation)&&void 0!==o?o:new h,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new ee(new ne(this.realWidth,this.realHeight,this.realPosition),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Xt))),this.debug&&(this.renderer=this.gameObject.addComponent(oe,{collider:this.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}(Nt),oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=At.getSingleton("RenderManager"),e}return l(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new nt,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},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}(Ht),se=function(){function e(e){this.type=it.Circumference,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new a(0,0,0,0),this.angle=0,this.vertexModel=[],this.radius=0,this._position=new t,this.vertices=[new t,new t],this.radius=e}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateBoundingBox()},e.prototype.updateBoundingBox=function(){this.boundingBox.set(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},e}(),ae=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realRadius=0,i.realOffset=new t,i.realPosition=new t,i.innerPosition=new t,i}return l(i,e),i.prototype.init=function(t){var e,i,n,r;this.radius=t.radius,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&At.getConstant("GameConfig").debugEnabled,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new ee(new se(this.radius),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Xt))),this.debug&&(this.renderer=this.gameObject.addComponent(he,{collider:this.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}(Nt),he=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=At.getSingleton("RenderManager"),e}return l(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new nt,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},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}(Ht),ce=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.debug=!1,t.needsCollider=function(e){t.cacheVertex[0].set(e.position.x,e.position.y+e.height),t.cacheVertex[1].set(e.position.x+e.width,e.position.y),t.cacheVertex[2].set(e.position.x,e.position.y-e.height),t.cacheVertex[3].set(e.position.x-e.width,e.position.y);for(var i=function(e){if(void 0===t.tilemapRenderer.tilesData.find((function(i){return i.position.equals(t.cacheVertex[e])})))return{value:!0}},n=0;n<t.cacheVertex.length;n++){var r=i(n);if("object"==typeof r)return r.value}return!1},t}return l(i,e),i.prototype.init=function(e){var i;this.tilemapRenderer=e.tilemapRenderer,this.layer=e.layer,this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&At.getConstant("GameConfig").debugEnabled,this.physics=!0,this.cacheVertex=[new t,new t,new t,new t]},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 ee(new ne(t.width,t.height,t.position),e.layer,e.gameObject.id,!1,e.physics,e.hasComponent(Xt)))})),this.debug&&(this.renderer=this.gameObject.addComponent(le,{colliders:this.colliders}))},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return e.layer=t.layer})),e.prototype.update.call(this)},i}(Nt),le=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=At.getSingleton("RenderManager"),e.renderData=[],e.colliders=[],e}return l(e,t),e.prototype.init=function(t){var e=this,i=t.colliders;this.colliders=i,this.colliders.forEach((function(t,i){e.renderData[i]=new nt,e.renderData[i].debug=!0,e.renderData[i].color="#00FF00"}))},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}(Ht),ue=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,At.getConstant("GameConfig").collisions.method!==bt.SAT)throw new v("Polygon Colliders need SAT collision method.");return r}return l(i,e),i.prototype.init=function(e){var i,n,r,o,s;if(e.vertexModel.length<3)throw new v("Polygon Collider needs at least 3 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&At.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(s=e.rotation)&&void 0!==s?s:new h,this.layer=e.layer;for(var a=0;a<this.vertexModel.length;a++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){var t;this.colliders.push(new ee(new ie(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Xt))),this.debug&&(this.renderer=this.gameObject.addComponent(pe,{collider:this.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}(Nt),pe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=At.getSingleton("RenderManager"),e}return l(e,t),e.prototype.init=function(t){var e=t.collider;this.renderData=new nt,this.renderData.debug=!0,this.renderData.color="#00FF00",this.collider=e},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}(Ht),de=function(){function e(e){this.vertexModel=e,this.type=it.Polygon,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new a(0,0,0,0),this.angle=0,this._position=new t}return e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.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)},e.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},e.prototype.updateProjectionAxes=function(){t.normal(this.projectionAxes[0],t.subtract(this.projectionAxes[0],this.vertices[1],this.vertices[0]))},e}(),fe=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,At.getConstant("GameConfig").collisions.method!==bt.SAT)throw new v("Edge Colliders need SAT collision method.");return r}return l(i,e),i.prototype.config=function(e){var i,n,r,o,s;if(e.vertexModel.length<2)throw new v("Edge Collider needs at least 2 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&At.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(s=e.rotation)&&void 0!==s?s:new h,this.layer=e.layer;for(var a=0;a<this.vertexModel.length;a++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders.push(new ee(new de([this.scaledVertexModel[e],this.scaledVertexModel[e+1]]),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Xt)));this.debug&&(this.renderer=this.gameObject.addComponent(ge,{colliders:this.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}(Nt),ge=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderManager=At.getSingleton("RenderManager"),e.renderData=[],e.colliders=[],e}return l(e,t),e.prototype.init=function(t){var e=this,i=t.colliders;this.colliders=i,this.colliders.forEach((function(t,i){e.renderData[i]=new nt,e.renderData[i].debug=!0,e.renderData[i].color="#00FF00",e.renderData[i].shape=N.Line}))},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}(Ht),me=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Image,e}return l(e,t),e}(A),ye=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=At.getSingleton("RenderManager"),i.sprite=null,i.offset=new t,i.flipHorizontal=!1,i.flipVertical=!1,i.rotation=new h,i.smooth=!1,i.opacity=1,i._tiled=new t(1,1),i.maskColor=null,i.maskColorMix=0,i.tintColor=null,i.renderData=[],i.innerPosition=new t,i.cachePosition=new t,i.cacheRenderPosition=new t,i.scaledOffset=new t,i}return l(i,e),i.prototype.init=function(t){var e,i,n,r,o,s,a,h,c,l,u,p;void 0===t&&(t={}),this.sprite=null!==(e=t.sprite)&&void 0!==e?e:this.sprite,this.offset=null!==(i=t.offset)&&void 0!==i?i:this.offset,this.smooth=null!==(n=t.smooth)&&void 0!==n?n:this.smooth,this.rotation=null!==(r=t.rotation)&&void 0!==r?r:this.rotation,this.flipHorizontal=null!==(o=t.flipHorizontal)&&void 0!==o?o:this.flipHorizontal,this.flipVertical=null!==(s=t.flipVertical)&&void 0!==s?s:this.flipVertical,this.opacity=null!==(a=t.opacity)&&void 0!==a?a:this.opacity,this.tiled=null!==(h=t.tiled)&&void 0!==h?h:this._tiled,this.maskColor=null!==(c=t.maskColor)&&void 0!==c?c:this.maskColor,this.maskColorMix=null!==(l=t.maskColorMix)&&void 0!==l?l:this.maskColorMix,this.tintColor=null!==(u=t.tintColor)&&void 0!==u?u:this.tintColor,this.layer=null!==(p=t.layer)&&void 0!==p?p:this.layer},Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new v("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 me}},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}(Ht),be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Text,e}return l(e,t),e}(A),ve=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.fontFamily="Sans",i.fontUrl=null,i.fontSize=12,i.width=100,i.height=100,i.offset=new t,i.color="#000000",i.lineSeparation=0,i.letterSpacing=0,i.bitmapSize=64,i.charRanges=[32,126,161,255],i.smooth=!1,i.bitmapOffset=new t,i.rotation=new h,i.opacity=1,i.orientation="center",i.renderManager=At.getSingleton("RenderManager"),i.renderData=new be,i.lastFrameText="",i}return l(i,e),i.prototype.init=function(t){var e,i,n,r,o,s,a,h,c,l,u,p,d,f,g;if(this.text=t.text,this.fontFamily=t.fontFamily,this.fontUrl=null!==(e=t.fontUrl)&&void 0!==e?e:this.fontUrl,this.fontSize=null!==(i=t.fontSize)&&void 0!==i?i:this.fontSize,this.width=null!==(n=t.width)&&void 0!==n?n:this.width,this.height=null!==(r=t.height)&&void 0!==r?r:this.height,this.offset=null!==(o=t.offset)&&void 0!==o?o:this.offset,this.color=null!==(s=t.color)&&void 0!==s?s:this.color,this.lineSeparation=null!==(a=t.lineSeparation)&&void 0!==a?a:this.lineSeparation,this.letterSpacing=null!==(h=t.letterSpacing)&&void 0!==h?h:this.letterSpacing,this.bitmapSize=null!==(c=t.bitmapSize)&&void 0!==c?c:this.bitmapSize,this.charRanges=null!==(l=t.charRanges)&&void 0!==l?l:this.charRanges,this.smooth=null!==(u=t.smooth)&&void 0!==u?u:this.smooth,this.bitmapOffset=null!==(p=t.bitmapOffset)&&void 0!==p?p:this.bitmapOffset,this.rotation=null!==(d=t.rotation)&&void 0!==d?d:this.rotation,this.opacity=null!==(f=t.opacity)&&void 0!==f?f:this.opacity,this.orientation=null!==(g=t.orientation)&&void 0!==g?g:this.orientation,this.charRanges.length%2!=0)throw new v("TextRenderer.charRanges must be a 2 column matrix");if(this.lineSeparation%2!=0)throw new v("TextRenderer.lineSeparation must be multiple of 2")},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,s=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<s.length;o++){var a=s[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(a)}return e.join("\n")},i}(Ht),xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Mask,e}return l(e,t),e}(A),Me=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=At.getSingleton("RenderManager"),i.offset=new t,i.rotation=new h,i.opacity=1,i.renderData=new xe,i.innerPosition=new t,i.scaledOffset=new t,i}return l(i,e),i.prototype.init=function(t){var e,i,n,r;this.width=t.width,this.height=t.height,this.color=t.color,this.offset=null!==(e=t.offset)&&void 0!==e?e:this.offset,this.rotation=null!==(i=t.rotation)&&void 0!==i?i:this.rotation,this.opacity=null!==(n=t.opacity)&&void 0!==n?n:this.opacity,this.layer=null!==(r=t.layer)&&void 0!==r?r:this.layer},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}(Ht),we=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,"x",{get:function(){return this.position.x-this.halfWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this.position.x+this.halfWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this.position.y-this.halfHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this.position.y+this.halfHeight},enumerable:!1,configurable:!0}),e}(),_e=function(){this.position=new t,this.positionInViewport=new t},Oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=_.Tilemap,e.tilesData=[],e.tilesToRender=[],e}return l(e,t),e}(A),je=function(e){function i(){var i,n=e.apply(this,arguments)||this;return n.allowMultiple=!1,n.renderOrder="center",n.smooth=!1,n.textureCorrection=null,n.tileScale=null!==(i=At.getConstant("GameConfig").spriteDefaultScale)&&void 0!==i?i:new t(1,1),n.tileWidth=0,n.tileHeight=0,n.orientation=new t(1,1),n.renderManager=At.getSingleton("RenderManager"),n.tilemapProcessed=!1,n.renderData=new Map,n.cols=[],n.rows=[],n._width=0,n._height=0,n.tiles=[],n._realWidth=0,n._realHeight=0,n.cacheV2=new t,n}return l(i,e),i.prototype.init=function(t){var e,i,n,r;this.tileset=t.tileset,this.tileScale=null!==(e=t.tileScale)&&void 0!==e?e:this.tileScale,this.smooth=null!==(i=t.smooth)&&void 0!==i?i:this.smooth,this.renderOrder=null!==(n=t.renderOrder)&&void 0!==n?n:this.renderOrder,this.textureCorrection=null!==(r=t.textureCorrection)&&void 0!==r?r:this.textureCorrection},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 Oe;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 _e;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 we(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}(Ht),Ce=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e.prototype.init=function(e){var i,n;e.renderOrder=null!==(i=e.renderOrder)&&void 0!==i?i:e.tilemapData.renderorder,t.prototype.init.call(this,e),this.tiledTilemap=e.tilemapData,this.layerName=null!==(n=e.layerName)&&void 0!==n?n:null,this.tilesetTileIds=[]},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.tilesetTileIds=[],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 s=this.tileset.getTile(this.getTilesetTileId(e.data[n]));this.processTile({layer:t,tile:s,col:o+e.x,row:r+e.y,flip:{h:!1,v:!1},offset:i}),n++}},e.prototype.getTilesetTileId=function(t){return this.tilesetTileIds[t]||(this.tilesetTileIds[t]=this.tiledTilemap.tilesets.reduce((function(e,i){return t>=i.firstgid?t-i.firstgid:e}),-1)),this.tilesetTileIds[t]},e}(je),Pe=1,Re=2,De=3,Se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alpha=1,e.tintColor=null,e}return l(e,t),e.prototype.init=function(e){var i,n;t.prototype.init.call(this,e),this.tilemapData=e.tilemapData,this.alpha=null!==(i=e.alpha)&&void 0!==i?i:this.alpha,this.tintColor=null!==(n=e.tintColor)&&void 0!==n?n:this.tintColor},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,s={h:!1,v:!1};if(!1===isNaN(r)){var a=r>999?r%1e3:r,h=Math.round(r/1e3);o=t.tileset.getTile(a),s.h=[Pe,De].includes(h),s.v=[Re,De].includes(h)}t.processTile({layer:"csv",tile:o,col:n,row:i,flip:s,offset:{x:0,y:0}})}))})),this.tilemapProcessed=!0},e}(je),Ae=function(t,e,i,n){this.x=t,this.y=e,this.width=i,this.height=n},Te=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 Ae(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}(),Fe=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},Ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeManager=At.getSingleton("TimeManager"),e.spriteRenderer=null,e.animations=new Map,e.currentAnimation=null,e.paused=!1,e}return l(e,t),e.prototype.init=function(t){var e=t.spriteRenderer;this.spriteRenderer=e},e.prototype.update=function(){null===this.currentAnimation||this.paused||(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.currentAnimation=null:this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return void 0===e&&(e="default"),t.framerate=null!=i?i:t.framerate,this.animations.set(e,new Be(t)),this},e.prototype.playAnimation=function(t){if(void 0===t&&(t="default"),!1!==this.active){if(!1===this.animations.has(t))throw new v("Animation with name "+t+" does not exist.");this.stopAnimation(),this.currentAnimation=this.animations.get(t)}},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused=!1},e.prototype.stopAnimation=function(){null!==this.currentAnimation&&(this.currentAnimation.reset(),this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(Ut),Be=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.reset=function(){this.currentFrame=0,this.frameTime=0,this._restarted=!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}(),Ie=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Ve=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMultiple=!1,e.volume=1,e.loop=!1,e.audio=null,e.clones=new Map,e._playing=!1,e._paused=!1,e.audioEventHandler=function(t){"ended"===t.type&&(e._playing=!1,e.audio.removeEventListener("ended",e.audioEventHandler))},e.userinputEventHandler=function(){Ie.forEach((function(t){window.removeEventListener(t,e.userinputEventHandler)})),e.audio.play()},e}return l(e,t),e.prototype.init=function(t){var e,i,n;void 0===t&&(t={}),this.audio=null!==(e=t.audio)&&void 0!==e?e:this.audio,this.volume=null!==(i=t.volume)&&void 0!==i?i:this.volume,this.loop=null!==(n=t.loop)&&void 0!==n?n:this.loop},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 Ie.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.onActiveChange=function(){!1===this.active&&this.stop()},e.prototype.onDestroy=function(){this.stop()},e}(Ut),Ue=function(){function e(e){var i,n,r,o,s=this;this._image=null,this._slice=null,this._scale=null!==(i=At.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 s.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)*Math.abs(this._scale.x),this._height=(null!==(e=this._height)&&void 0!==e?e:this._image.naturalHeight)*Math.abs(this._scale.y),this._loaded=!0},e}();!function(t){t[t.Rectangle=0]="Rectangle",t[t.Circumference=1]="Circumference"}(Tt||(Tt={}));var Le=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.width=100,i.height=100,i.radius=50,i.touchEnabled=!0,i._offset=new t,i.pressed=!1,i.mouse=At.getSingleton("InputManager").mouse,i.touch=At.getSingleton("InputManager").touch,i.position=new t,i.distance=new t,i.pressedLastFrame=!1,i.scaled={width:0,height:0,radius:0,offset:new t},i}return l(i,e),Object.defineProperty(i.prototype,"offset",{get:function(){return this._offset},set:function(t){this._offset=t},enumerable:!1,configurable:!0}),i.prototype.init=function(t){var e=t.type,i=t.height,n=t.radius,r=t.touchEnabled,o=t.width,s=t.offset;this.type=e,this.width=null!=o?o:this.width,this.height=null!=i?i:this.height,this.radius=null!=n?n:this.radius,this.touchEnabled=null!=r?r:this.touchEnabled,this._offset=null!=s?s:this._offset},i.prototype.update=function(){this.scale(),t.add(this.position,this.gameObject.transform.position,this.scaled.offset),this.pressedLastFrame=this.pressed,this.pressed=!1,this.mouse.leftButtonPressed&&(this.resolveMouseAndRectangle(),this.resolveMouseAndCircumference()),this.touchEnabled&&this.touch.touching&&(this.resolveTouchAndRectangle(),this.resolveTouchAndCircumference()),this.onClick&&!this.pressedLastFrame&&this.pressed&&this.onClick(),this.onPressed&&this.pressed&&this.onPressed()},i.prototype.scale=function(){this.scaled.width=this.width*this.gameObject.transform.scale.x,this.scaled.height=this.width*this.gameObject.transform.scale.y,this.scaled.offset.x=this._offset.x*this.gameObject.transform.scale.x,this.scaled.offset.y=this._offset.y*this.gameObject.transform.scale.y,this.scaled.radius=this.radius*this.gameObject.transform.scale.magnitude},i.prototype.resolveMouseAndRectangle=function(){this.type===Tt.Rectangle&&(this.pressed||(this.pressed=s(this.mouse.positionInViewport.x,this.position.x-this.scaled.width/2,this.position.x+this.scaled.width/2)&&s(this.mouse.positionInViewport.y,this.position.y-this.scaled.height/2,this.position.y+this.scaled.height/2)))},i.prototype.resolveMouseAndCircumference=function(){this.type===Tt.Circumference&&(t.subtract(this.distance,this.position,this.mouse.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius))},i.prototype.resolveTouchAndRectangle=function(){this.type===Tt.Rectangle&&(this.pressed||(this.pressed=this.position.x+this.scaled.width/2>=this.touch.positionInViewport.x-this.touch.radius.x&&this.position.x-this.scaled.width/2<=this.touch.positionInViewport.x+this.touch.radius.x&&this.position.y+this.scaled.height/2>=this.touch.positionInViewport.y-this.touch.radius.y&&this.position.y-this.scaled.height/2<=this.touch.positionInViewport.y+this.touch.radius.y))},i.prototype.resolveTouchAndCircumference=function(){this.type===Tt.Circumference&&(t.subtract(this.distance,this.position,this.touch.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius+this.touch.radius.x))},i}(Vt),Ge=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return l(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){dt.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.scale(this.position,dt.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=dt.mouse.leftButtonPressed},i}(Qt);export{Fe as Animation,Ee as Animator,ut as AssetManager,Ve as AudioPlayer,ae as BallCollider,re as BoxCollider,Le as Button,Tt as ButtonType,Jt as Camera,ee as ColliderData,bt as CollisionMethodConfig,Vt as Component,Se as CsvTilemapRenderer,pt as DomManager,fe as EdgeCollider,Et as Game,Zt as GameCamera,Qt as GameObject,mt as GameObjectManager,C as GamepadController,P as GamepadData,dt as InputManager,D as KeyboardController,qt as LAYER_DEFAULT,Me as MaskRenderer,S as MouseController,Gt as PhysicsComponent,ue as PolygonCollider,zt as PreRenderComponent,a as Rectangle,Xt as RigidBody,ot as RigidBodyType,h as Rotation,te as Scene,ft as SceneManager,Ge as SpacePointer,Ue as Sprite,ye as SpriteRenderer,ve as TextRenderer,Ce as TiledTilemapRenderer,ce as TilemapCollider,Te as Tileset,gt as TimeManager,at as TouchController,Yt as Transform,t as Vector2,s as between,e as clamp,r as fixedRound,n as randomFloat,i as randomInt,o as range};
|
|
1
|
+
class t{constructor(t=0,e=0){this._x=t,this._y=e}get x(){return this._x}set x(t){this._x=t}get y(){return this._y}set y(t){this._y=t}get magnitude(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))}set(t,e){this._x=t,this._y=e}copy(t){this.set(t.x,t.y)}equals(t){return this._x===t.x&&this._y===t.y}clone(){return new t(this._x,this._y)}distance(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))}static add(t,e,i){return t.set(e.x+i.x,e.y+i.y),t}static subtract(t,e,i){return t.set(e.x-i.x,e.y-i.y),t}static unit(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t}static normal(t,e){return t.set(-e.y,e.x),this.unit(t,t)}static scale(t,e,i){return t.set(e.x*i,e.y*i),t}static dot(t,e){return t.x*e.x+t.y*e.y}static cross(t,e){return t.x*e.y-t.y*e.x}static round(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t}}const e=(t,e,i)=>Math.min(i,Math.max(e,t)),i=(t,e)=>Math.round(Math.random()*(e-t))+t,n=(t,e,i=2)=>r(Math.random()*(e-t)+t,i),r=(t,e)=>Math.round(t*Math.pow(10,e))/Math.pow(10,e),o=(t,e,i=1)=>{const n=[];for(let r=t;r<=e;r+=i)n.push(r);return n},s=(t,e,i)=>t>=e&&t<=i;class a{constructor(e,i,n,r){this._position=new t,this._center=new t,this._width=0,this._height=0,this.set(e,i,n,r)}get x(){return this._position.x}set x(t){this._position.set(t,this._position.y)}get y(){return this._position.y}set y(t){this._position.set(this._position.x,t)}get x1(){return this._position.x+this._width}get y1(){return this._position.y+this._height}get position(){return this._position}set position(t){this._position.set(t.x,t.y)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}get center(){return this._center.set(this.x+this.width/2,this.y+this.height/2),this._center}set(t,e,i,n){this._position.set(t,e),this._width=i,this._height=n}equals(t){return this.position.equals(t.position)&&this.width===t.width&&this.height===t.height}copy(t){this.set(t.x,t.y,t.width,t.height)}overlapRectangle(t){return this.x1>=t.x&&this.x<=t.x1&&this.y1>=t.y&&this.y<=t.y1}overlapVector(t){return s(t.x,this.x,this.x1)&&s(t.y,this.y,this.y1)}}class h{constructor(e=null,i=null){this._degrees=0,this._radians=0,this._direction=new t,e?this.radians=e:i&&(this.degrees=i)}set degrees(t){this._degrees=t,this._radians=t*Math.PI/180,this.updateDirection()}get degrees(){return this._degrees}set radians(t){this._radians=t,this._degrees=180*t/Math.PI,this.updateDirection()}get radians(){return this._radians}get direction(){return this._direction}updateDirection(){this._direction.set(Math.cos(this._radians),Math.sin(this._radians))}}
|
|
2
|
+
/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */var l=function(t,e){return l=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])},l(t,e)};function c(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}l(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var u,d=function(){return d=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},d.apply(this,arguments)};function p(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.Font="Font"}(u||(u={}));var g,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.loadImage=function(t){var e=new Image;e.crossOrigin="",e.src=t;var i=this.createAsset(t,u.Image,e);return e.naturalWidth?i.loaded=!0:e.addEventListener("load",(function(){return i.loaded=!0})),e},t.prototype.loadAudio=function(t){var e=new Audio;e.src=t;var i=this.createAsset(t,u.Audio,e);return e.duration?i.loaded=!0:e.addEventListener("canplaythrough",(function(){return i.loaded=!0})),e},t.prototype.loadFont=function(t,e){var i=new FontFace(t,"url("+e+")"),n=this.createAsset(e,u.Font,i);return n.family=t,i.load().then((function(t){document.fonts.add(t),n.loaded=!0})),i},t.prototype.getImage=function(t){var e;return null===(e=this.assets.find((function(e){return e.type===u.Image&&e.url===t})))||void 0===e?void 0:e.element},t.prototype.getAudio=function(t){var e;return null===(e=this.assets.find((function(e){return e.type===u.Audio&&e.url===t})))||void 0===e?void 0:e.element},t.prototype.getFont=function(t){var e;return null===(e=this.assets.find((function(e){return e.type===u.Font&&e.family===t})))||void 0===e?void 0:e.element},t.prototype.createAsset=function(t,e,i){var n={type:e,url:t,element:i,loaded:!1};return this.assets.push(n),n},t}(),m=function(t){function e(e){var i=t.call(this,e)||this;return i.name="AngryPixelException",i}return c(e,t),e}(Error),y=function(){function e(e,i,n,r){void 0===n&&(n=6),void 0===r&&(r=15),this._bounds=new a(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=e,this._bounds.copy(i),this.maxLevels=n,this.maxItems=r,this.updateCache()}return Object.defineProperty(e.prototype,"bounds",{get:function(){return this._bounds},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quadrants",{get:function(){return this._quadrants},enumerable:!1,configurable:!0}),e.prototype.updateBounds=function(t){this._bounds.copy(t),this.updateCache()},e.prototype.clearItems=function(){this._items=[],this._quadrants.forEach((function(t){return t.clearItems()}))},e.prototype.clearQuadrants=function(){this._quadrants.forEach((function(t){return t.clearQuadrants()})),this._quadrants=[]},e.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())},e.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},e.prototype.splitQuad=function(){var t=this;this._quadrants=[new a(this.center.x-this.childrenWidth,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new a(this.center.x,this.center.y-this.childrenHeight,this.childrenWidth,this.childrenHeight),new a(this.center.x-this.childrenWidth,this.center.y,this.childrenWidth,this.childrenHeight),new a(this.center.x,this.center.y,this.childrenWidth,this.childrenHeight)].map((function(i){return new e(t.level+1,i,t.maxLevels,t.maxItems)}));for(var i=0,n=this._items;i<n.length;i++){var r=n[i];this.insertItemIntoChildrenQuads(r)}this._items=[]},e.prototype.getChildrenQuadrantForItem=function(t){if(0===this._quadrants.length)throw new m("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 m("Item does not fit in any children quadrant");return this.quadsForItem},e.prototype.insertItemIntoChildrenQuads=function(t){this.getChildrenQuadrantForItem(t).forEach((function(e){return e.addItem(t)}))},e.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},e}(),x=function(){function e(e,i,n,r,o){this.collisions=[],this.minBounds=new t,this.maxBounds=new t,this.newBounds=new a(0,0,0,0),this.method=e,this.colliders=[],this.collisionMatrix=o,this.setupQuadTree(i,n,r)}return e.prototype.setupQuadTree=function(t,e,i){i?(this.bounds=i,this.fixedQuadTree=!0):(this.bounds=new a(0,0,0,0),this.fixedQuadTree=!1),this.quadTree=new y(0,this.bounds,t,e)},e.prototype.addCollider=function(t){this.colliders.push(t)},e.prototype.removeCollider=function(t){var e=this.colliders.indexOf(t);-1!==e&&(delete this.colliders[e],this.colliders.splice(e,1))},e.prototype.getCollisionsForCollider=function(t){return this.collisions.filter((function(e){return e.localCollider===t}))},e.prototype.refreshCollisionsForCollider=function(t){-1!==this.colliders.indexOf(t)&&(this.collisions=this.collisions.filter((function(e){return e.localCollider!==t&&e.remoteCollider!==t})),this.narrowPhase(t,this.broadPhase(t)))},e.prototype.clear=function(){this.colliders=[]},e.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.copy(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()}},e.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)},e.prototype.updateCollisions=function(){var t=this;this.colliders.filter((function(t){return t.updateCollisions})).forEach((function(e){return t.narrowPhase(e,t.broadPhase(e))}))},e.prototype.broadPhase=function(t){var e=this;return this.collisionMatrix?this.quadTree.retrieve(t).filter((function(i){return e.collisionMatrix.some((function(e){return e[0]===t.layer&&e[1]===i.layer||e[1]===t.layer&&e[0]===i.layer}))})):this.quadTree.retrieve(t)},e.prototype.narrowPhase=function(t,e){var i=this;e.filter((function(e){return e.id!==t.id})).forEach((function(e){if(!i.isResolved(t,e)){var n=i.method.getCollisionResolution(t.shape,e.shape);null!==n&&i.collisions.push({localCollider:t,remoteCollider:e,resolution:n},{localCollider:e,remoteCollider:t,resolution:{direction:n.displacementDirection,displacementDirection:n.direction,penetration:n.penetration}})}}))},e.prototype.isResolved=function(t,e){for(var i=0,n=this.collisions;i<n.length;i++){var r=n[i];if(r.localCollider===t&&r.remoteCollider===e)return!0}return!1},e}(),v=function(){function t(t,e,i){if(this._canvas=null,!t)throw new m("containerNode cannot be empty or null.");this.containerNode=t,this.gameWidth=e,this.gameHeight=i,this.setupCanvas()}return Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),t.prototype.setupCanvas=function(){this._canvas=document.createElement("canvas"),this._canvas.id="angryPixelGameCanvas",this._canvas.width=Math.floor(this.gameWidth),this._canvas.height=Math.floor(this.gameHeight),this.canvas.tabIndex=0,this._canvas.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this.containerNode.appendChild(this._canvas),this.canvas.focus()},t}();!function(t){t[t.Init=0]="Init",t[t.Start=1]="Start",t[t.Update=2]="Update",t[t.UpdateEngine=3]="UpdateEngine",t[t.UpdateCollider=4]="UpdateCollider",t[t.UpdatePhysics=5]="UpdatePhysics",t[t.UpdateTransform=6]="UpdateTransform",t[t.UpdatePreRender=7]="UpdatePreRender",t[t.UpdateCamera=8]="UpdateCamera",t[t.UpdateRender=9]="UpdateRender",t[t.Destroy=10]="Destroy"}(g||(g={}));var b,M=function(){function t(t,e,i,n,r,o,s,a){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.renderManager=n,this.inputManager=r,this.gameObjectManager=o,this.sceneManager=s,this.canvasColor=a,this.running=!1,this.gameLoopAccumulator=0,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene(),this.renderManager.clearScreen(this.canvasColor)},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.requestAnimationLoop(window.performance.now()),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.requestAnimationLoop=function(t){var e=this;this.running&&(this.timeManager.updateForBrowser(.001*t),this.gameLoopAccumulator+=this.timeManager.browserDeltaTime,this.gameLoopAccumulator>=this.timeManager.minGameDeltatime&&(this.gameLogicIteration(.001*t),this.gameLoopAccumulator-=this.timeManager.minGameDeltatime),this.renderIteration(),window.requestAnimationFrame((function(t){return e.requestAnimationLoop(t)})))},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(g.Start),this.inputManager.update(),this.dispatchFrameEvent(g.Update),this.dispatchFrameEvent(g.UpdateEngine),this.dispatchFrameEvent(g.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.dispatchFrameEvent(g.UpdatePreRender),this.sceneManager.update()},t.prototype.renderIteration=function(){this.dispatchFrameEvent(g.UpdatePreRender),this.dispatchFrameEvent(g.UpdateCamera),this.dispatchFrameEvent(g.UpdateRender),this.renderManager.clearScreen(this.canvasColor),this.renderManager.render(),this.renderManager.clearData()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(g.UpdatePhysics),this.dispatchFrameEvent(g.UpdateCollider),this.dispatchFrameEvent(g.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=.001*window.performance.now();document.hidden||this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(.001*window.performance.now()-e);window.setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return p(p([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==g.Start&&t!==g.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}(),w=function(){function t(){this.gameObjects=[]}return t.prototype.addGameObject=function(t,e,i,n){var r=new t(n,i);return this.gameObjects.push(r),r.dispatch(g.Init,e),r},t.prototype.findGameObjects=function(t){return t?this.gameObjects.filter((function(e){return e instanceof t})):p([],this.gameObjects,!0)},t.prototype.findGameObjectById=function(t){return this.gameObjects.find((function(e){return e.id===t}))},t.prototype.findGameObject=function(t){return"string"==typeof t?this.gameObjects.find((function(e){return e.name===t})):this.gameObjects.find((function(e){return e instanceof t}))},t.prototype.findGameObjectsByParent=function(t){return this.gameObjects.filter((function(e){return e.parent===t}))},t.prototype.findGameObjectByParent=function(t,e){return"string"==typeof e?this.gameObjects.find((function(i){return i.name===e&&i.parent===t})):this.gameObjects.find((function(i){return i instanceof e&&i.parent===t}))},t.prototype.findGameObjectsByTag=function(t){return this.gameObjects.filter((function(e){return e.tag===t}))},t.prototype.destroyAllGameObjects=function(){var t=this;this.gameObjects.filter((function(t){return!t.keep})).forEach((function(e){return t.destroy(e,!1)}))},t.prototype.destroyGameObject=function(t){this.destroy(t,!0)},t.prototype.destroy=function(t,e){var i=this.gameObjects.indexOf(t);if(-1!==i){var n=this.gameObjects.splice(i,1)[0];e&&this.destroyChildren(n),n.dispatch(g.Destroy)}},t.prototype.destroyChildren=function(t){var e=this;this.findGameObjectsByParent(t).forEach((function(t){return e.destroyGameObject(t)}))},t}(),_=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 j),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}(),j=function(){function e(){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._gamepad=t,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._gamepad.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connected",{get:function(){return this._gamepad.connected},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,"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.prototype.vibrate=function(t,e,i,n){void 0===t&&(t=200),void 0===e&&(e=.2),void 0===i&&(i=.2),void 0===n&&(n=0),this._gamepad.vibrationActuator&&this._gamepad.vibrationActuator.playEffect(this._gamepad.vibrationActuator.type,{duration:t,weakMagnitude:e,strongMagnitude:i,startDelay:n})},e}(),C=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}(),O=function(){function t(t){var e=this;this.keyPresses=new Map,this.eventHandler=function(t){"keydown"===t.type&&e.keyPresses.set(t.code,!0),"keyup"===t.type&&e.keyPresses.set(t.code,!1)},this.canvas=t,this.canvas.addEventListener("keydown",this.eventHandler),this.canvas.addEventListener("keyup",this.eventHandler)}return t.prototype.isPressed=function(t){var e;return null!==(e=this.keyPresses.get(t))&&void 0!==e&&e},t.prototype.orPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t||null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!1)},t.prototype.andPressed=function(t){var e=this;return t.reduce((function(t,i){var n;return t&&null!==(n=e.keyPresses.get(i))&&void 0!==n&&n}),!0)},t.prototype.isPressedReturn=function(t,e,i){return this.keyPresses.get(t)?e:i},t.prototype.orPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t||null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!1)?e:i},t.prototype.andPressedReturn=function(t,e,i){var n=this;return t.reduce((function(t,e){var i;return t&&null!==(i=n.keyPresses.get(e))&&void 0!==i&&i}),!0)?e:i},t}(),P=function(){function e(e){this._leftButtonPressed=!1,this._scrollButtonPressed=!1,this._rightButtonPressed=!1,this._positionInViewport=new t(0,0),this._hasMoved=!1,this.lastPositionInViewport=new t(0,0),this.canvas=e,this.setup()}return Object.defineProperty(e.prototype,"leftButtonPressed",{get:function(){return this._leftButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollButtonPressed",{get:function(){return this._scrollButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightButtonPressed",{get:function(){return this._rightButtonPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionInViewport",{get:function(){return this._positionInViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),e.prototype.update=function(){!1===this._positionInViewport.equals(this.lastPositionInViewport)?(this._hasMoved=!0,this.lastPositionInViewport.copy(this._positionInViewport)):this._hasMoved=!1},e.prototype.setup=function(){var t=this;this.canvas.addEventListener("mousemove",(function(e){return t.updatePosition(e)})),this.canvas.addEventListener("mousedown",(function(e){return t.updateButtonDown(e)})),this.canvas.addEventListener("mouseup",(function(e){return t.updateButtonUp(e)}))},e.prototype.updateButtonDown=function(t){this.canvas.focus(),t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0===t.button,this._scrollButtonPressed=1===t.button,this._rightButtonPressed=2===t.button},e.prototype.updateButtonUp=function(t){t.preventDefault(),t.stopPropagation(),this._leftButtonPressed=0!==t.button&&this._leftButtonPressed,this._scrollButtonPressed=1!==t.button&&this._scrollButtonPressed,this._rightButtonPressed=2!==t.button&&this._rightButtonPressed},e.prototype.updatePosition=function(t){t.preventDefault(),t.stopPropagation(),this._positionInViewport.set(t.offsetX/(this.canvas.clientWidth/this.canvas.width)-this.canvas.width/2,-t.offsetY/(this.canvas.clientHeight/this.canvas.height)+this.canvas.height/2)},e}(),R=function(){function t(t,e){this.game=t,this.renderManager=e,this.scenes=new Map,this.currentScene=null,this.openingSceneName=null,this.sceneToLoad=null}return t.prototype.getCurrentScene=function(){return this.currentScene},t.prototype.addScene=function(t,e,i,n){var r=this;if(void 0===n&&(n=!1),this.scenes.has(e))throw new m("There is already a scene with the name '"+e+"'");this.scenes.set(e,(function(){var n=new t(e,r.game);return r.currentScene=n,n.dispatch(g.Init,i),n})),!0!==n&&null!==this.openingSceneName||(this.openingSceneName=e)},t.prototype.loadOpeningScene=function(){if(null===this.openingSceneName)throw new m("There is no opening scene");this._loadScene(this.openingSceneName)},t.prototype.loadScene=function(t){if(null===this.game)throw new m("Game not initialized.");if(!1===this.scenes.has(t))throw new m("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.scenes.get(t)()},t.prototype.unloadCurrentScene=function(){null!==this.currentScene&&(this.currentScene.dispatch(g.Destroy),this.currentScene=null,this.currentSceneName=null,this.renderManager&&this.renderManager.clearData())},t}(),S=[60,120,180,240],D=function(){function t(t){if(this.minGameDeltatime=0,this.minPhysicsDeltaTime=0,this.gameFramerate=60,this.physicsFramerate=180,this.timeScale=1,this.browserDeltaTime=0,this.gameDeltaTime=0,this.unscaledGameDeltaTime=0,this.unscaledPhysicsDeltaTime=0,this.maxDeltaTime=1/15,this.thenForGame=0,this.thenForPhysics=0,this.thenForBrowser=0,!S.includes(t))throw new m("Invalid Physics frame rate. Allowed: ["+S.join(", ")+"]");this.physicsFramerate=t,this.minGameDeltatime=parseFloat((1/this.gameFramerate).toFixed(6)),this.minPhysicsDeltaTime=parseFloat((1/this.physicsFramerate).toFixed(6))}return t.prototype.updateForGame=function(t){this.unscaledGameDeltaTime=Math.min(Math.max(this.minGameDeltatime,t-this.thenForGame),this.maxDeltaTime),this.thenForGame=t},t.prototype.updateForBrowser=function(t){this.browserDeltaTime=Math.min(Math.max(0,t-this.thenForBrowser),this.maxDeltaTime),this.thenForBrowser=t},t.prototype.updateForPhysics=function(t){this.unscaledPhysicsDeltaTime=Math.min(Math.max(0,t-this.thenForPhysics),this.maxDeltaTime),this.thenForPhysics=t},Object.defineProperty(t.prototype,"deltaTime",{get:function(){return this.unscaledGameDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"physicsDeltaTime",{get:function(){return this.unscaledPhysicsDeltaTime*this.timeScale},enumerable:!1,configurable:!0}),t}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}(b||(b={}));var A,T=function(){function t(t,e){this.circumferenceResolver=t,this.satResolver=e}return t.prototype.getCollisionResolution=function(t,e){return t.type===b.Circumference&&e.type===b.Circumference?this.circumferenceResolver.resolve(t,e):this.satResolver.resolve(t,e)},t}(),F=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}(),E=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===b.Polygon&&e.type===b.Polygon?this.AABBResolver.resolve(t,e):t.type===b.Circumference&&e.type===b.Polygon?this.circumferenceAABBResolver.resolve(t,e):t.type===b.Polygon&&e.type===b.Circumference?this.circumferenceAABBResolver.resolve(e,t,!0):t.type===b.Circumference&&e.type===b.Circumference?this.circumferenceResolver.resolve(t,e):null},t}(),B=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.loadImage(t)},t.loadAudio=function(t){return this.assetManager.loadAudio(t)},t.loadFont=function(t,e){return this.assetManager.loadFont(t,e)},t.getImage=function(t){return this.assetManager.getImage(t)},t.getAudio=function(t){return this.assetManager.getAudio(t)},t.getFont=function(t){return this.assetManager.getFont(t)},t.assetManager=null,t}(),U=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}(),I=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}(),L=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}(),G=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}),Object.defineProperty(t,"browserDeltaTime",{get:function(){return this.timeManager.browserDeltaTime},enumerable:!1,configurable:!0}),t.timeManager=null,t}(),V=function(){function t(){}return t.initialize=function(t){this.manager=t},t.addGameObject=function(t,e,i,n){return this.manager.addGameObject(t,e,i,n)},t.findAllGameObjects=function(){return this.manager.findGameObjects()},t.findGameObjects=function(t){return this.manager.findGameObjects(t)},t.findGameObject=function(t){return this.manager.findGameObject(t)},t.findGameObjectsByParent=function(t){return this.manager.findGameObjectsByParent(t)},t.findGameObjectByParent=function(t,e){return this.manager.findGameObjectByParent(t,e)},t.findGameObjectsByTag=function(t){return this.manager.findGameObjectsByTag(t)},t.destroyGameObject=function(t){this.manager.destroyGameObject(t)},t}();!function(t){t[t.Static=0]="Static",t[t.Dynamic=1]="Dynamic",t[t.Kinematic=2]="Kinematic"}(A||(A={}));var W,k,H,z,N=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){i.type===A.Dynamic?e.dynamicUpdate(i,t):i.type===A.Kinematic&&e.kinematicUpdate(i,t)}))},e.prototype.dynamicUpdate=function(t,e){this.applyGravity(t,e),this.applyVelocity(t,e,"x"),this.applyReposition(t,"x",!0),this.applyVelocity(t,e,"y"),this.applyReposition(t,"y",!0)},e.prototype.kinematicUpdate=function(e,i){t.add(e.position,e.position,t.scale(this.cacheVelocity,e.velocity,i))},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,n){var r=this;this.cacheCollisions=this.getCollisions(e),0!==this.cacheCollisions.length&&(this.cacheDisplacement.set(0,0),this.cacheCollisions.forEach((function(t){r.cacheNewDisplacement=t.resolution.displacementDirection[i]*t.resolution.penetration,r.cacheDisplacement[i]=Math.abs(r.cacheDisplacement[i])>Math.abs(r.cacheNewDisplacement)?r.cacheDisplacement[i]:r.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,r.cacheDisplacement),e.shape.update(),r.collisionManager.refreshCollisionsForCollider(e)})),n&&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(t,i){return t.push.apply(t,e.collisionManager.getCollisionsForCollider(i).filter((function(t){return t.remoteCollider.physics&&t.remoteCollider.rigidBody}))),t}),[])},e.prototype.clear=function(){this.rigidBodyData=[]},e}(),Y=function(){function e(){this.direction=new t,this.displacementDirection=new t}return e.prototype.resolve=function(e,i){var n=e.boundingBox,r=i.boundingBox;return this.overlapX=Math.min(n.x1,r.x1)-Math.max(n.x,r.x),this.overlapY=Math.min(n.y1,r.y1)-Math.max(n.y,r.y),this.overlapX<0||this.overlapY<0?null:(this.direction.set(Math.sign(r.x1-n.x1),Math.sign(r.y1-n.y1)),this.overlapY<this.overlapX?(this.minOverlap=this.overlapY,this.displacementDirection.set(0,-this.direction.y),this.preventContainment(n.y,n.y1,r.y,r.y1)):(this.minOverlap=this.overlapX,this.displacementDirection.set(-this.direction.x,this.overlapY===this.overlapX?-this.direction.y:0),this.preventContainment(n.x,n.x1,r.x,r.x1)),t.unit(this.displacementDirection,this.displacementDirection),{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)})},e.prototype.preventContainment=function(e,i,n,r){if(e>n&&i<r||n>e&&r<i){var o=Math.abs(e-n),s=Math.abs(i-r);o<s?this.minOverlap+=o:(this.minOverlap+=s,t.scale(this.displacementDirection,this.displacementDirection,-1))}},e}(),X=function(){function i(){this.closestPoint=new t,this.distance=new t,this.direction=new t}return i.prototype.resolve=function(i,n,r){return void 0===r&&(r=!1),this.closestPoint.set(e(i.position.x,n.boundingBox.x,n.boundingBox.x1),e(i.position.y,n.boundingBox.y,n.boundingBox.y1)),t.subtract(this.distance,this.closestPoint,i.position),this.distance.magnitude>i.radius?null:(t.unit(this.direction,this.distance),{penetration:i.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)})},i}(),q=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}(),Q=function(){function e(){this.projA={min:0,max:0},this.projB={min:0,max:0},this.displacementDirection=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===b.Circumference?this.setCircumferenceAxis(e,i):i.type===b.Circumference&&this.setCircumferenceAxis(i,e),this.axes=p(p([],e.projectionAxes,!0),i.projectionAxes,!0);for(var n=0;n<this.axes.length;n++){if(e.type===b.Circumference?this.setCircumferenceVertices(e,this.axes[n]):i.type===b.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.displacementDirection.copy(this.axes[n]),this.projA.max<this.projB.max&&t.scale(this.displacementDirection,this.displacementDirection,-1))}return{penetration:this.minOverlap,displacementDirection:this.displacementDirection.clone(),direction:t.scale(new t,this.displacementDirection,-1)}},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}(),$=function(){function t(t,e,i,n,r){this.timeManager=t,this.collisionManager=e,this.physicsManager=i,this.gameObjectManager=n,this.sceneManager=r,this.running=!1,this.gameObjects=[],this.components=[]}return t.prototype.start=function(){this.startLoop(!0)},t.prototype.pause=function(){this.running=!1},t.prototype.resume=function(){this.startLoop(!1)},t.prototype.stop=function(){this.running=!1,this.sceneManager.unloadCurrentScene()},t.prototype.startLoop=function(t){this.running||(this.running=!0,t&&this.sceneManager.loadOpeningScene(),this.asyncGameLoop(),this.timeManager.gameFramerate!==this.timeManager.physicsFramerate&&this.asyncPhysicsLoop())},t.prototype.gameLogicIteration=function(t){this.timeManager.updateForGame(t),this.load(),this.physicsManager.clear(),this.dispatchFrameEvent(g.Start),this.dispatchFrameEvent(g.Update),this.dispatchFrameEvent(g.UpdateEngine),this.dispatchFrameEvent(g.UpdateTransform),this.timeManager.gameFramerate===this.timeManager.physicsFramerate&&this.physicsIteration(t),this.sceneManager.update()},t.prototype.physicsIteration=function(t){this.timeManager.timeScale<=0||(this.timeManager.updateForPhysics(t),this.dispatchFrameEvent(g.UpdatePhysics),this.dispatchFrameEvent(g.UpdateCollider),this.dispatchFrameEvent(g.UpdateTransform),this.collisionManager.update(),this.physicsManager.update(this.timeManager.physicsDeltaTime),this.collisionManager.clear())},t.prototype.asyncGameLoop=function(){var t=this;if(this.running){var e=process.uptime();this.gameLogicIteration(e);var i=1/this.timeManager.gameFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncGameLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.asyncPhysicsLoop=function(){var t=this;if(this.running){var e=process.uptime();this.physicsIteration(e);var i=1/this.timeManager.physicsFramerate-(process.uptime()-e);setTimeout((function(){return t.asyncPhysicsLoop()}),1e3*Math.max(1e-4,i))}},t.prototype.load=function(){this.currentScene=this.sceneManager.getCurrentScene(),this.gameObjects=this.gameObjectManager.findGameObjects().filter((function(t){return t.active})),this.components=this.gameObjects.reduce((function(t,e){return p(p([],t,!0),e.getComponents().filter((function(t){return t.active})),!0)}),[])},t.prototype.dispatchFrameEvent=function(t){t!==g.Start&&t!==g.Update||(this.currentScene.dispatch(t),this.gameObjects.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))),this.components.filter((function(t){return t.active})).forEach((function(e){return e.dispatch(t)}))},t}();!function(t){t[t.Polygon=0]="Polygon",t[t.Circumference=1]="Circumference",t[t.Line=2]="Line"}(W||(W={})),function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ViewPort=1]="ViewPort"}(k||(k={})),function(t){t[t.Sprite=0]="Sprite",t[t.Text=1]="Text",t[t.Tilemap=2]="Tilemap",t[t.Mask=3]="Mask",t[t.Geometric=4]="Geometric"}(H||(H={}));class K{constructor(t){this.gl=t,this.viewport={x:0,x1:0,y:0,y1:0},this.object={x:0,x1:0,y:0,y1:0}}setViewport({position:t,zoom:e},i){i===k.WorldSpace?(this.viewport.x=t.x-this.gl.canvas.width/e/2,this.viewport.x1=t.x+this.gl.canvas.width/e/2,this.viewport.y=t.y-this.gl.canvas.height/e/2,this.viewport.y1=t.y+this.gl.canvas.height/e/2):(this.viewport.x=-this.gl.canvas.width/2,this.viewport.x1=this.gl.canvas.width/2,this.viewport.y=-this.gl.canvas.height/2,this.viewport.y1=this.gl.canvas.height/2)}setObjectForResizeable({position:t,width:e,height:i,rotation:n=0}){const r=Math.sin(n)*i+Math.cos(n)*e,o=Math.sin(n)*e+Math.cos(n)*i;this.object.x=t.x-r/2,this.object.x1=t.x+r/2,this.object.y=t.y-o/2,this.object.y1=t.y+o/2}setObjectForText({position:t,text:e,fontSize:i,lineSeparation:n,letterSpacing:r,rotation:o}){const s=e.split("\n").reduce(((t,e)=>Math.max(t,e.length)),0)*(i+(null!=r?r:0))*2,a=e.split("\n").length*(i+(null!=n?n:0));this.setObjectForResizeable({position:t,width:s,height:a,rotation:o})}setObjectForGeometric({position:t,vertexModel:e,shape:i,radius:n}){i===W.Circumference?(this.object.x=t.x-n,this.object.y=t.y-n,this.object.x1=t.x+n,this.object.y1=t.y+n):(this.object.x=Number.MAX_SAFE_INTEGER,this.object.y=Number.MAX_SAFE_INTEGER,this.object.x1=Number.MIN_SAFE_INTEGER,this.object.y1=Number.MIN_SAFE_INTEGER,e.forEach((e=>{this.object.x=Math.min(e.x+t.x,this.object.x),this.object.y=Math.min(e.y+t.y,this.object.y),this.object.x1=Math.max(e.x+t.x,this.object.x1),this.object.y1=Math.max(e.y+t.y,this.object.y1)})))}setObjectForTilemap(t){t.tilemap.height=Math.ceil(t.tiles.length/t.tilemap.width),this.setObjectForResizeable({position:t.renderPosition,width:t.tilemap.width*t.tilemap.tileWidth,height:t.tilemap.height*t.tilemap.tileHeight,rotation:t.rotation})}applyCullingInTiles(t){const{tiles:e,tilemap:{width:i,tileWidth:n,tileHeight:r}}=t;t.culledTiles=e.map(((t,e)=>this.viewport.x1>=this.object.x+e%i*n&&this.viewport.x<=this.object.x+e%i*n+n&&this.viewport.y1>=this.object.y1-((e/i|0)*r+r)&&this.viewport.y<=this.object.y1-(e/i|0)*r?t:0))}isInViewPort(t,e){switch(this.setViewport(e,t.location),t.type){case H.Mask:case H.Sprite:this.setObjectForResizeable(t);break;case H.Geometric:this.setObjectForGeometric(t);break;case H.Text:this.setObjectForText(t);break;case H.Tilemap:this.setObjectForTilemap(t)}return this.viewport.x1>=this.object.x&&this.viewport.x<=this.object.x1&&this.viewport.y1>=this.object.y&&this.viewport.y<=this.object.y1}applyCulling(t,e){return e.filter((e=>!!this.isInViewPort(e,t)&&(e.type===H.Tilemap&&this.applyCullingInTiles(e),!0)))}}class J{constructor(t=0,e=0){this._x=t,this._y=e}get x(){return this._x}set x(t){this._x=t}get y(){return this._y}set y(t){this._y=t}get magnitude(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))}set(t,e){this._x=t,this._y=e}copy(t){this.set(t.x,t.y)}equals(t){return this._x===t.x&&this._y===t.y}clone(){return new J(this._x,this._y)}distance(t){return Math.sqrt(Math.pow(this._x-t.x,2)+Math.pow(this._y-t.y,2))}static add(t,e,i){return t.set(e.x+i.x,e.y+i.y),t}static subtract(t,e,i){return t.set(e.x-i.x,e.y-i.y),t}static unit(t,e){return 0===e.magnitude?t.set(0,0):t.set(e.x/e.magnitude,e.y/e.magnitude),t}static normal(t,e){return t.set(-e.y,e.x),this.unit(t,t)}static scale(t,e,i){return t.set(e.x*i,e.y*i),t}static dot(t,e){return t.x*e.x+t.y*e.y}static cross(t,e){return t.x*e.y-t.y*e.x}static round(t,e){return t.set(Math.round(e.x),Math.round(e.y)),t}}!function(t){t[t.Center=0]="Center",t[t.RightUp=1]="RightUp",t[t.RightDown=2]="RightDown",t[t.RightCenter=3]="RightCenter"}(z||(z={}));class Z{constructor(t,e){this.webglManager=t,this.cullingManager=e,this.renderData=[],this.cameraData=[]}addRenderData(t){this.renderData.push(t)}addCameraData(t){this.cameraData.push(t)}render(){this.cameraData.sort(((t,e)=>t.depth-e.depth)).forEach((t=>this.renderByCamera(t)))}renderByCamera(t){this.cullingManager.applyCulling(t,this.renderData.filter((e=>t.layers.includes(e.layer))).sort(((e,i)=>t.layers.indexOf(e.layer)-t.layers.indexOf(i.layer))).map((t=>t.type===H.Tilemap?(t=>{const e=Object.assign(Object.assign({},t),{culledTiles:[],tilemap:Object.assign(Object.assign({},t.tilemap),{height:Math.ceil(t.tiles.length/t.tilemap.width),realWidth:t.tilemap.width*t.tilemap.tileWidth,realHeight:0}),renderPosition:new J});return e.tilemap.realHeight=e.tilemap.height*e.tilemap.tileHeight,(t=>{t.renderPosition.set(t.position.x+(t.orientation!==z.Center?t.tilemap.realWidth/2:0),t.position.y+(t.orientation===z.RightDown?-t.tilemap.realHeight/2:t.orientation===z.RightUp?t.tilemap.realHeight/2:0))})(e),e})(t):t))).forEach((e=>this.webglManager.render(e,t)))}clearData(){this.renderData=[],this.cameraData=[]}clearScreen(t){this.webglManager.clearCanvas(t)}}var tt;!function(t){t.LegacyWebGL="webgl",t.WebGL2="webgl2"}(tt||(tt={}));class et{constructor(t){if(this.canvas=t,this.contextVersion=this.getContextVersion(),!this.contextVersion)throw new Error("Your browser does not support WebGL.");this.gl=this.canvas.getContext(this.contextVersion)}getContextVersion(){return null!==this.canvas.getContext(tt.WebGL2)?tt.WebGL2:null!==this.canvas.getContext(tt.LegacyWebGL)?tt.LegacyWebGL:void 0}}class it{constructor(){this.fontAtlas=new Map}hasFontAtlas(t){return this.fontAtlas.has(Symbol.for(t instanceof FontFace?t.family:t))}getFontAtlas(t){return this.fontAtlas.get(Symbol.for(t instanceof FontFace?t.family:t))}getOrCreate(t,e,i){var n;return null!==(n=this.getFontAtlas(e))&&void 0!==n?n:this.create(t,e,i)}create(t,e,i){this.bitmapSize=i,this.chars=[];for(let e=0;e<t.length;e+=2)for(let i=t[e];i<=t[e+1];i++)this.chars.push(String.fromCharCode(i));const n=this.renderAtlas(e instanceof FontFace?e.family:e);return this.fontAtlas.set(Symbol.for(e instanceof FontFace?e.family:e),n),n}renderAtlas(t){const e=new nt(t,this.bitmapSize,Math.ceil(Math.sqrt(this.chars.length))),i=e.canvas.getContext("2d");i.clearRect(0,0,e.canvas.width,e.canvas.height),i.textBaseline="top",i.fillStyle="#000",i.font=`${this.bitmapSize}px ${t}`;let n=0,r=0;for(let t=0;t<this.chars.length;t++)i.fillText(this.chars[t],n,r),e.glyphs.set(this.chars[t],{id:t,width:i.measureText(this.chars[t]).width}),(n+=this.bitmapSize)>e.canvas.width-this.bitmapSize&&(n=0,r+=this.bitmapSize);return e}}class nt{constructor(t,e,i){this.fontFaceFamily=t,this.bitmapFontSize=e,this.gridSize=i,this.canvas=document.createElement("canvas"),this.glyphs=new Map,this.canvas.width=this.gridSize*this.bitmapFontSize,this.canvas.height=this.canvas.width}}class rt{constructor(t,e){this.gl=t,this.shaderLoader=e}create(t,e){const i=this.gl.createProgram(),n=this.shaderLoader.load(this.gl.VERTEX_SHADER,t),r=this.shaderLoader.load(this.gl.FRAGMENT_SHADER,e);this.gl.attachShader(i,n),this.gl.attachShader(i,r),this.gl.linkProgram(i);const o=this.gl.LINK_STATUS;if(!this.gl.getProgramParameter(i,o)){const t=this.gl.getProgramInfoLog(i);throw this.gl.deleteProgram(i),new Error(`Unable to initialize the Program: ${t}`)}return i}}class ot{constructor(t,e,i){this.gl=t,this.contextVersion=e,this.programFactory=i}loadProgram(){this.program=this.contextVersion===tt.WebGL2?this.programFactory.create("#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("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)}}class st{constructor(t){this.gl=t}load(t,e){const i=this.gl.createShader(t);this.gl.shaderSource(i,e),this.gl.compileShader(i);const n=this.gl.COMPILE_STATUS;if(!this.gl.getShaderParameter(i,n)){const t=this.gl.getShaderInfoLog(i);throw this.gl.deleteShader(i),new Error(`Unable to initialize the shader program: ${t}`)}return i}}var at="undefined"!=typeof Float32Array?Float32Array:Array;function ht(){var t=new at(16);return at!=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 lt(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 ct(t,e,i){var n,r,o,s,a,h,l,c,u,d,p,g,f=i[0],m=i[1],y=i[2];return e===t?(t[12]=e[0]*f+e[4]*m+e[8]*y+e[12],t[13]=e[1]*f+e[5]*m+e[9]*y+e[13],t[14]=e[2]*f+e[6]*m+e[10]*y+e[14],t[15]=e[3]*f+e[7]*m+e[11]*y+e[15]):(n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=e[6],c=e[7],u=e[8],d=e[9],p=e[10],g=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=h,t[6]=l,t[7]=c,t[8]=u,t[9]=d,t[10]=p,t[11]=g,t[12]=n*f+a*m+u*y+e[12],t[13]=r*f+h*m+d*y+e[13],t[14]=o*f+l*m+p*y+e[14],t[15]=s*f+c*m+g*y+e[15]),t}function ut(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 dt(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],h=e[3],l=e[4],c=e[5],u=e[6],d=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]=s*r+c*n,t[2]=a*r+u*n,t[3]=h*r+d*n,t[4]=l*r-o*n,t[5]=c*r-s*n,t[6]=u*r-a*n,t[7]=d*r-h*n,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var pt;function gt(){var t=new at(3);return at!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ft(t,e,i){var n=new at(3);return n[0]=t,n[1]=e,n[2]=i,n}function mt(){var t=new at(4);return at!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}gt(),function(){var t;t=new at(4),at!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}(),gt(),ft(1,0,0),ft(0,1,0),mt(),mt(),pt=new at(9),at!=Float32Array&&(pt[1]=0,pt[2]=0,pt[3]=0,pt[5]=0,pt[6]=0,pt[7]=0),pt[0]=1,pt[4]=1,pt[8]=1,function(){var t=new at(2);at!=Float32Array&&(t[0]=0,t[1]=0)}();const yt=t=>{const 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},xt=(t,e,i,n)=>{var r,o;(function(t,e,i,n,r,o,s){var a=1/(e-i),h=1/(n-r),l=1/(o-s);t[0]=-2*a,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)*a,t[13]=(r+n)*h,t[14]=(s+o)*l,t[15]=1})(t=lt(t),-e.canvas.width/2,e.canvas.width/2,-e.canvas.height/2,e.canvas.height/2,-1,1),ct(t,t,[0,0,0]),n===k.WorldSpace&&ut(t,t,[null!==(r=i.zoom)&&void 0!==r?r:1,null!==(o=i.zoom)&&void 0!==o?o:1,1])};class vt{constructor(t,e){this.gl=t,this.programManager=e,this.vertices=new Map,this.lastVertices=null,this.modelPosition=new J,this.projectionMatrix=ht(),this.modelMatrix=ht(),this.textureMatrix=ht();const i=2*Math.PI/60;this.circumferenceVertices=new Float32Array(((t,e,i=1)=>{const n=[];for(let t=1;t<=e;t+=i)n.push(t);return n})(0,60,1).reduce(((t,e)=>[...t,Math.cos(e*i),Math.sin(e*i)]),[]))}render(t,e,i){switch(t.shape){case W.Polygon:this.renderLines(t,e,this.gl.LINE_LOOP,i);break;case W.Line:this.renderLines(t,e,this.gl.LINES,i);break;case W.Circumference:this.renderCircumference(t,e)}}renderLines(t,e,i,n){var r;const o=this.generateVerticesKey(t.vertexModel);!1===this.vertices.has(o)&&this.vertices.set(o,new Float32Array(this.generatePolygonVertices(t.vertexModel)));const s=this.vertices.get(o);this.lastVertices===o&&n===H.Geometric||(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.textureBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW)),this.lastVertices=o,this.modelMatrix=lt(this.modelMatrix),J.round(this.modelPosition,t.location===k.WorldSpace?J.subtract(this.modelPosition,t.position,e.position):t.position),ct(this.modelMatrix,this.modelMatrix,[this.modelPosition.x,this.modelPosition.y,0]),dt(this.modelMatrix,this.modelMatrix,null!==(r=t.rotation)&&void 0!==r?r:0),xt(this.projectionMatrix,this.gl,e,t.location),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);const{r:a,g:h,b:l,a:c}=yt(t.color);this.gl.uniform4f(this.programManager.solidColorUniform,a,h,l,c),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(i,0,s.length/2)}generateVerticesKey(t){return Symbol.for(t.reduce(((t,e)=>`${t}${e.x}${e.y}`),t.length.toString()))}generatePolygonVertices(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x,t[i].y);return e}renderCircumference(t,e){this.lastVertices=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.programManager.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.circumferenceVertices,this.gl.DYNAMIC_DRAW),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=lt(this.modelMatrix),ct(this.modelMatrix,this.modelMatrix,[t.position.x,t.position.y,0]),ut(this.modelMatrix,this.modelMatrix,[t.radius,t.radius,1]),xt(this.projectionMatrix,this.gl,e,t.location),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);const{r:i,g:n,b:r,a:o}=yt(t.color);this.gl.uniform4f(this.programManager.solidColorUniform,i,n,r,o),this.gl.uniform1f(this.programManager.alphaUniform,1),this.gl.drawArrays(this.gl.LINE_LOOP,0,this.circumferenceVertices.length/2)}}class bt{constructor(t,e){this.gl=t,this.programManager=e,this.type=H.Mask,this.vertices=new Float32Array([-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,.5,.5,.5]),this.modelPosition=new J,this.projectionMatrix=ht(),this.modelMatrix=ht(),this.textureMatrix=ht()}render(t,e,i){var n,r;i!==H.Mask&&(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=lt(this.modelMatrix),J.round(this.modelPosition,t.location===k.WorldSpace?J.subtract(this.modelPosition,t.position,e.position):t.position),ct(this.modelMatrix,this.modelMatrix,[this.modelPosition.x,this.modelPosition.y,0]),dt(this.modelMatrix,this.modelMatrix,null!==(n=t.rotation)&&void 0!==n?n:0),ut(this.modelMatrix,this.modelMatrix,[t.width,t.height,1]),xt(this.projectionMatrix,this.gl,e,t.location),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),t.alpha&&t.alpha<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this.gl.uniform1i(this.programManager.renderTextureUniform,0);const{r:o,g:s,b:a,a:h}=yt(t.color);this.gl.uniform4f(this.programManager.solidColorUniform,o,s,a,h),this.gl.uniform1f(this.programManager.alphaUniform,null!==(r=t.alpha)&&void 0!==r?r:1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}}class Mt{constructor(t,e,i){this.gl=t,this.programManager=e,this.textureManager=i,this.lastTexture=null,this.modelPosition=new J,this.projectionMatrix=ht(),this.modelMatrix=ht(),this.textureMatrix=ht(),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])}render(t,e,i){var n,r,o,s;i!==t.type&&(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=lt(this.modelMatrix),J.round(this.modelPosition,t.location===k.WorldSpace?J.subtract(this.modelPosition,t.position,e.position):t.position),ct(this.modelMatrix,this.modelMatrix,[this.modelPosition.x,this.modelPosition.y,0]),dt(this.modelMatrix,this.modelMatrix,null!==(n=t.rotation)&&void 0!==n?n:0),ut(this.modelMatrix,this.modelMatrix,[t.width*(t.flipHorizontal?-1:1),t.height*(t.flipVertical?-1:1),1]),this.textureMatrix=lt(this.textureMatrix),t.slice&&(ct(this.textureMatrix,this.textureMatrix,[t.slice.x/t.image.naturalWidth,t.slice.y/t.image.naturalHeight,0]),ut(this.textureMatrix,this.textureMatrix,[t.slice.width/t.image.naturalWidth,t.slice.height/t.image.naturalHeight,1])),xt(this.projectionMatrix,this.gl,e,t.location),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);const a=this.textureManager.getOrCreateTextureFromImage(t.image,t.smooth);if(this.lastTexture===a&&i===t.type||(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=a),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,null!==(r=t.alpha)&&void 0!==r?r:1),this.gl.uniform1i(this.programManager.useTintColorUniform,t.tintColor?1:0),t.tintColor){const{r:e,g:i,b:n,a:r}=yt(t.tintColor);this.gl.uniform4f(this.programManager.tintColorUniform,e,i,n,r)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,t.maskColor?1:0),t.maskColor){const{r:e,g:i,b:n}=yt(t.maskColor);this.gl.uniform4f(this.programManager.maskColorUniform,e,i,n,null!==(o=t.alpha)&&void 0!==o?o:1),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(s=t.maskColorMix)&&void 0!==s?s:1)}this.gl.drawArrays(this.gl.TRIANGLES,0,6)}}var wt;!function(t){t[t.Center=0]="Center",t[t.RightUp=1]="RightUp",t[t.RightDown=2]="RightDown",t[t.RightCenter=3]="RightCenter"}(wt||(wt={}));const _t=new J,jt=new J,Ct=[32,126,161,255],Ot=wt.Center;class Pt{constructor(t,e,i,n){this.gl=t,this.programManager=e,this.textureManager=i,this.fontAtlasFactory=n,this.type=H.Text,this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.textSize=new J,this.modelPosition=new J,this.projectionMatrix=ht(),this.modelMatrix=ht(),this.textureMatrix=ht()}render(t,e,i){var n;if(!t.text)return;this.setDefaultValues(t);const r=this.fontAtlasFactory.getOrCreate(t.bitmap.charRanges,t.font,t.bitmap.fontSize);this.generateTextVertices(r,t),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=lt(this.modelMatrix),this.setPositionFromOrientation(t),J.round(this.modelPosition,t.location===k.WorldSpace?J.subtract(this.modelPosition,this.modelPosition,e.position):this.modelPosition),ct(this.modelMatrix,this.modelMatrix,[this.modelPosition.x,this.modelPosition.y,0]),dt(this.modelMatrix,this.modelMatrix,null!==(n=t.rotation)&&void 0!==n?n:0),ut(this.modelMatrix,this.modelMatrix,[t.fontSize,t.fontSize,1]),this.textureMatrix=lt(this.textureMatrix),xt(this.projectionMatrix,this.gl,e,t.location),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),t.opacity<1?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND);const o=this.textureManager.getOrCreateTextureFromCanvas(r.fontFaceFamily,r.canvas,t.smooth);this.lastTexture===o&&i===H.Text||(this.gl.bindTexture(this.gl.TEXTURE_2D,o),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=o),this.gl.uniform1i(this.programManager.useTintColorUniform,0),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,t.opacity);const{r:s,g:a,b:h,a:l}=yt(t.color);this.gl.uniform4f(this.programManager.maskColorUniform,s,a,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)}setDefaultValues(t){var e,i,n,r,o,s,a,h,l,c;t.bitmap?(t.bitmap.margin=null!==(e=t.bitmap.margin)&&void 0!==e?e:_t,t.bitmap.spacing=null!==(i=t.bitmap.spacing)&&void 0!==i?i:jt,t.bitmap.fontSize=null!==(n=t.bitmap.fontSize)&&void 0!==n?n:64,t.bitmap.charRanges=null!==(r=t.bitmap.charRanges)&&void 0!==r?r:Ct):t.bitmap={margin:_t,spacing:jt,fontSize:64,charRanges:Ct},t.color=null!==(o=t.color)&&void 0!==o?o:"#000000",t.letterSpacing=null!==(s=t.letterSpacing)&&void 0!==s?s:0,t.lineSeparation=null!==(a=t.lineSeparation)&&void 0!==a?a:0,t.opacity=null!==(h=t.opacity)&&void 0!==h?h:1,t.orientation=null!==(l=t.orientation)&&void 0!==l?l:Ot,t.rotation=null!==(c=t.rotation)&&void 0!==c?c:0}generateTextVertices(t,{text:e,fontSize:i,bitmap:n,letterSpacing:r,lineSeparation:o}){this.posVertices=[],this.texVertices=[];let s=0,a=0,h=0;r/=i,o/=i;for(let i=0;i<e.length;i++){const l=e[i];if("\n"===l){h=Math.max(h,s),s=0,a-=1+o;continue}const c=t.glyphs.get(l);if(c){const e=c.width/t.bitmapFontSize;this.posVertices.push(s,a-1,s+e,a-1,s,a,s,a,s+e,a-1,s+e,a);const i=c.id%t.gridSize*t.bitmapFontSize,o=(c.id/t.gridSize|0)*t.bitmapFontSize,h=(i+n.margin.x)/t.canvas.width,l=(o+n.margin.y)/t.canvas.width,u=(i+c.width+n.spacing.x)/t.canvas.width,d=(o+t.bitmapFontSize+n.spacing.y)/t.canvas.width;this.texVertices.push(h,d,u,d,h,l,h,l,u,d,u,l),s+=e+r}}this.textSize.set(Math.max(h,s)*i,Math.abs(a-1)*i)}setPositionFromOrientation(t){this.modelPosition.set(t.position.x+(t.orientation===wt.Center?-this.textSize.x/2:0),t.position.y+(t.orientation===wt.Center||t.orientation===wt.RightCenter?this.textSize.y/2:t.orientation===wt.RightUp?this.textSize.y:0))}}class Rt{constructor(t,e,i){this.gl=t,this.programManager=e,this.textureManager=i,this.posVertices=[],this.texVertices=[],this.lastTexture=null,this.tileset={width:0,tileWidth:0,tileHeight:0,texMargin:new J,texSpacing:new J,texWidth:0,texHeight:0,texCorrection:new J},this.modelPosition=new J,this.projectionMatrix=ht(),this.modelMatrix=ht(),this.textureMatrix=ht()}render(t,e,i){var n,r,o,s;this.processTileset(t),this.generateVertices(t),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=lt(this.modelMatrix),J.round(this.modelPosition,t.location===k.WorldSpace?J.subtract(this.modelPosition,t.renderPosition,e.position):t.renderPosition),ct(this.modelMatrix,this.modelMatrix,[this.modelPosition.x,this.modelPosition.y,0]),dt(this.modelMatrix,this.modelMatrix,null!==(n=t.rotation)&&void 0!==n?n:0),ut(this.modelMatrix,this.modelMatrix,[t.tilemap.tileWidth*(t.flipHorizontal?-1:1),t.tilemap.tileHeight*(t.flipVertical?-1:1),1]),this.textureMatrix=lt(this.textureMatrix),ut(this.textureMatrix,this.textureMatrix,[this.tileset.tileWidth/t.tileset.image.naturalWidth,this.tileset.tileHeight/t.tileset.image.naturalHeight,1]),xt(this.projectionMatrix,this.gl,e,t.location),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);const a=this.textureManager.getOrCreateTextureFromImage(t.tileset.image,t.smooth);if(this.lastTexture===a&&i===H.Tilemap||(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.uniform1i(this.programManager.textureUniform,0),this.lastTexture=a),this.gl.uniform1i(this.programManager.renderTextureUniform,1),this.gl.uniform1f(this.programManager.alphaUniform,null!==(r=t.alpha)&&void 0!==r?r:1),this.gl.uniform1i(this.programManager.useTintColorUniform,t.tintColor?1:0),t.tintColor){const{r:e,g:i,b:n,a:r}=yt(t.tintColor);this.gl.uniform4f(this.programManager.tintColorUniform,e,i,n,r)}if(this.gl.uniform1i(this.programManager.useMaskColorUniform,t.maskColor?1:0),t.maskColor){const{r:e,g:i,b:n}=yt(t.maskColor);this.gl.uniform4f(this.programManager.maskColorUniform,e,i,n,null!==(o=t.alpha)&&void 0!==o?o:1),this.gl.uniform1f(this.programManager.maskColorMixUniform,null!==(s=t.maskColorMix)&&void 0!==s?s:1)}this.gl.drawArrays(this.gl.TRIANGLES,0,this.posVertices.length/2)}processTileset({tileset:t}){var e,i,n,r,o,s,a;t.margin=null!==(e=t.margin)&&void 0!==e?e:new J,t.spacing=null!==(i=t.spacing)&&void 0!==i?i:new J,t.correction=null!==(n=t.correction)&&void 0!==n?n:new J,this.tileset.width=t.width,this.tileset.tileWidth=t.tileWidth+(null!==(r=t.margin.x)&&void 0!==r?r:0)+(null!==(o=t.spacing.x)&&void 0!==o?o:0),this.tileset.tileHeight=t.tileHeight+(null!==(s=t.margin.y)&&void 0!==s?s:0)+(null!==(a=t.spacing.y)&&void 0!==a?a:0),this.tileset.texMargin.set(t.margin.x/this.tileset.tileWidth,t.margin.y/this.tileset.tileHeight),this.tileset.texSpacing.set(t.spacing.x/this.tileset.tileWidth,t.spacing.y/this.tileset.tileHeight),this.tileset.texCorrection.set(t.correction.x/this.tileset.tileWidth,t.correction.y/this.tileset.tileHeight),this.tileset.texWidth=1-this.tileset.texMargin.x-this.tileset.texSpacing.x-2*this.tileset.texCorrection.x,this.tileset.texHeight=1-this.tileset.texMargin.y-this.tileset.texSpacing.y-2*this.tileset.texCorrection.y}generateVertices({culledTiles:t,tilemap:e}){this.posVertices=[],this.texVertices=[];const i=Math.floor(t.length/e.width);t.forEach(((t,n)=>{if(0===t)return;const r=n%e.width-e.width/2,o=i/2-Math.floor(n/e.width);this.posVertices.push(r,o-1,r+1,o-1,r,o,r,o,r+1,o-1,r+1,o);const s=(t-1)%this.tileset.width+this.tileset.texMargin.x+this.tileset.texCorrection.x,a=Math.floor((t-1)/this.tileset.width)+this.tileset.texMargin.y+this.tileset.texCorrection.y;this.texVertices.push(s,a+this.tileset.texHeight,s+this.tileset.texWidth,a+this.tileset.texHeight,s,a,s,a,s+this.tileset.texWidth,a+this.tileset.texHeight,s+this.tileset.texWidth,a)}))}}class St{constructor(t){this.gl=t}createFromImage(t,e=!0,i=null){return i=null!=i?i:this.gl.createTexture(),t.naturalWidth?this.create(t,i,e):t.addEventListener("load",(()=>this.create(t,i,e))),i}createFromCanvas(t,e=!0,i=null){return i=null!=i?i:this.gl.createTexture(),this.create(t,i,e),i}create(t,e,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)}}class Dt{constructor(t){this.textureFactory=t,this.textures=new Map}getOrCreateTextureFromImage(t,e=!0){var i;return null!==(i=this.textures.get(Symbol.for(t.src)))&&void 0!==i?i:this.createTextureFromImage(t,e)}createTextureFromImage(t,e=!0){const i=this.textureFactory.createFromImage(t,e);return this.textures.set(Symbol.for(t.src),i),i}getOrCreateTextureFromCanvas(t,e,i=!0){var n;return null!==(n=this.textures.get(Symbol.for(t)))&&void 0!==n?n:this.createTextureFromCanvas(t,e,i)}createTextureFromCanvas(t,e,i=!0){const n=this.textureFactory.createFromCanvas(e,i);return this.textures.set(Symbol.for(t),n),n}}class At{constructor(t,e,i){this.gl=t,this.renderers=i,e.loadProgram()}render(t,e){this.renderers.get(t.type).render(t,e,this.lastRender),this.lastRender=t.type}clearCanvas(t){const e=yt(t);this.gl.clearColor(e.r,e.g,e.b,e.a),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}}var Tt,Ft=function(t,e){t.addConstant("GameConfig",e),t.add("TimeManager",(function(){return new D(e.physicsFramerate)})),t.add("GameObjectManager",(function(){return new w})),Et(t,e),e.headless?t.add("IterationManager",(function(){return new $(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"))})):(t.add("DomManager",(function(){return new v(e.containerNode,e.gameWidth,e.gameHeight)})),t.add("RenderManager",(function(){return(t=>{const e=new et(t),i=e.gl,n=e.contextVersion,r=new ot(i,n,new rt(i,new st(i))),o=new Dt(new St(i)),s=new At(i,r,new Map([[H.Sprite,new Mt(i,r,o)],[H.Text,new Pt(i,r,o,new it)],[H.Tilemap,new Rt(i,r,o)],[H.Geometric,new vt(i,r)],[H.Mask,new bt(i,r)]]));return new Z(s,new K(i))})(t.getSingleton("DomManager").canvas)})),Bt(t),t.add("AssetManager",(function(){return new f})),t.add("IterationManager",(function(){return new M(t.getSingleton("TimeManager"),t.getSingleton("CollisionManager"),t.getSingleton("RigidBodyManager"),t.getSingleton("RenderManager"),t.getSingleton("InputManager"),t.getSingleton("GameObjectManager"),t.getSingleton("SceneManager"),e.canvasColor)}))),t.add("SceneManager",(function(){return new R(t.getConstant("Game"),e.headless?void 0:t.getSingleton("RenderManager"))})),Ut(t,e)},Et=function(t,e){if(e.collisions.method===Tt.AABB)t.add("CollisionMethod",(function(){return new E(new Y,new X,new q)}));else{if(e.collisions.method!==Tt.SAT)throw new m("Invalid collision method.");t.add("CollisionMethod",(function(){return new T(new q,new Q)}))}t.add("CollisionManager",(function(){return new x(t.getSingleton("CollisionMethod"),e.collisions.quadMaxLevel,e.collisions.collidersPerQuad,e.collisions.quadTreeBounds,e.collisions.collisionMatrix)})),t.add("RigidBodyManager",(function(){return new N(t.getSingleton("CollisionManager"))}))},Bt=function(t){var e=t.getSingleton("DomManager");t.add("InputManager",(function(){return new C(new P(e.canvas),new O(e.canvas),new _,new F(e.canvas))}))},Ut=function(t,e){e.headless||(B.initialize(t.getSingleton("AssetManager")),U.initialize(t.getSingleton("DomManager")),I.initialize(t.getSingleton("InputManager"))),L.initialize(t.getSingleton("SceneManager")),G.initialize(t.getSingleton("TimeManager")),V.initialize(t.getSingleton("GameObjectManager"))},It=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 m("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 m("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 m("Invalid object constructor name: "+t);return this.constructors.get(t)()},t.prototype.addConstant=function(t,e){if(this.constants.has(t))throw new m("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 m("Invalid constant name: "+t);return this.constants.get(t)},t}());!function(t){t.AABB="aabb",t.SAT="sat"}(Tt||(Tt={}));var Lt,Gt={containerNode:null,gameWidth:320,gameHeight:180,debugEnabled:!1,canvasColor:"#000000",spriteDefaultScale:null,physicsFramerate:180,headless:!1,collisions:{method:Tt.AABB,quadMaxLevel:6,collidersPerQuad:15}},Vt=function(){function t(t){this._config=d(d({},Gt),t),this._config.collisions=d(d({},Gt.collisions),t.collisions),It.addConstant("Game",this),this.setupManagers()}return t.prototype.setupManagers=function(){Ft(It,this._config),this.sceneManager=It.getSingleton("SceneManager"),this.iterationManager=It.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.iterationManager.running},enumerable:!1,configurable:!0}),t.prototype.addScene=function(t,e,i,n){void 0===n&&(n=!1),this.sceneManager.addScene(t,e,i,n)},t.prototype.run=function(){this.iterationManager.start()},t.prototype.stop=function(){this.iterationManager.stop()},t.prototype.pause=function(){this.iterationManager.pause()},t.prototype.resume=function(){this.iterationManager.resume()},t}(),Wt=function(){var t=(new Date).getTime(),e="undefined"!=typeof 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)}))},kt=function(){function t(){this.gameObjectManager=It.getSingleton("GameObjectManager"),this.updateEvent=g.Update,this.started=!1}return t.prototype.dispatch=function(t,e){t===g.Init&&this.init?this.init(e):t!==g.Start||this.started?t===this.updateEvent&&this.started&&this.update?this.update():t===g.Destroy&&(this.onDestroy&&this.onDestroy(),this._destroy()):(this.start&&this.start(),this.started=!0)},t.prototype.addGameObject=function(t,e,i){return"string"==typeof e&&(i=e,e={}),this.gameObjectManager.addGameObject(t,e,void 0,i)},t.prototype.findGameObjects=function(t){return t?this.gameObjectManager.findGameObjects(t):this.gameObjectManager.findGameObjects()},t.prototype.findGameObject=function(t){return this.gameObjectManager.findGameObject(t)},t.prototype.findGameObjectsByTag=function(t){return this.gameObjectManager.findGameObjectsByTag(t)},t.prototype.destroyGameObject=function(t){this.gameObjectManager.destroyGameObject(t)},t}(),Ht=function(t){function e(e,i){void 0===i&&(i="");var n=t.call(this)||this;return n.sceneManager=It.getSingleton("SceneManager"),n.id=Wt(),n.allowMultiple=!0,n._active=!0,n.gameObject=e,n.name=i,n}return c(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active=t,this.onActiveChange()},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.getGameObject=function(){return this.gameObject},e.prototype.getComponents=function(t){return t?this.gameObject.getComponents(t):this.gameObject.getComponents()},e.prototype.getComponent=function(t){return this.gameObject.getComponent(t)},e.prototype.hasComponent=function(t){return this.gameObject.hasComponent(t)},e.prototype.removeComponent=function(t){this.gameObject.removeComponent(t)},e.prototype._destroy=function(){var t=this;Object.keys(this).forEach((function(e){return delete t[e]}))},e}(kt),zt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdateEngine,e}return c(e,t),e}(Ht),Nt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdateCollider,e}return c(e,t),e}(Ht),Yt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdatePhysics,e}return c(e,t),e}(Ht),Xt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdateTransform,e}return c(e,t),e}(Ht),qt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdatePreRender,e}return c(e,t),e}(Ht),Qt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdateCamera,e}return c(e,t),e}(Ht),$t=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateEvent=g.UpdateRender,e}return c(e,t),e}(Ht),Kt=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.parentScale=!0,i.parentRotation=!0,i._position=new t,i._scale=new t(1,1),i._rotation=new h,i._innerPosition=new t,i._parent=null,i.cache=new t,i.lastParentRadians=0,i.lastPosition=new t,i.scaledInnerPosition=new t,i}return c(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(e){this._parent=e,null!==this._parent&&t.subtract(this._innerPosition,this._position,this._parent.position)},enumerable:!1,configurable:!0}),i.prototype.update=function(){null!==this._parent&&this.setPositionFromParent(),this.lastPosition.copy(this._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._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}(Xt),Jt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.collisionManager=It.getSingleton("CollisionManager"),e.renderer=null,e.colliders=[],e.physics=!0,e}return c(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.getCollisionsForCollider(n);r<o.length;r++){var s=o[r];if(s.remoteCollider.layer===t)return this.createCollisionData(s)}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,s=this.collisionManager.getCollisionsForCollider(r);o<s.length;o++){var a=s[o];a.remoteCollider.layer===t&&e.push(this.createCollisionData(a))}return e},e.prototype.createCollisionData=function(t){return{gameObject:this.gameObjectManager.findGameObjectById(t.remoteCollider.id),collider:t.remoteCollider,resolution:t.resolution,getGameObject:function(){return this.gameObject}}},e.prototype.onActiveChange=function(){this.renderer&&(this.renderer.active=this.active)},e}(Nt),Zt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMultiple=!1,t.rigidBodyManager=It.getSingleton("RigidBodyManager"),t}return c(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}),Object.defineProperty(i.prototype,"rigidBodyType",{get:function(){return this.data.type},enumerable:!1,configurable:!0}),i.prototype.init=function(e){var i,n=e.rigidBodyType,r=e.gravity;this.data={type:n,position:null,gravity:null!==(i=Math.abs(r))&&void 0!==i?i:10,velocity:new t,colliders:[]}},i.prototype.start=function(){if(0===this.getColliders().length)throw new m("RigidBody needs at least one Collider with physics")},i.prototype.update=function(){this.data.type!==A.Static&&(this.data.position=this.gameObject.transform.parent?this.gameObject.transform.innerPosition:this.gameObject.transform.position,this.data.colliders=this.getColliders(),this.rigidBodyManager.addRigidBodyData(this.data))},i.prototype.getColliders=function(){return this.gameObject.getComponents().reduce((function(t,e){return e instanceof Jt&&e.physics?p(p([],t,!0),e.colliders,!0):t}),[])},i}(zt),te="Default",ee=function(t){function e(e,i){void 0===e&&(e="");var n=t.call(this)||this;return n.id=Wt(),n.layer="Default",n.ui=!1,n.keep=!1,n._parent=null,n._active=!0,n.sceneManager=It.getSingleton("SceneManager"),n.components=[],n.activeComponentsCache=[],n.activeChildrenCache=[],n.name=e,n.addComponent(Kt),n.parent=null!=i?i:null,n}return c(e,t),Object.defineProperty(e.prototype,"active",{get:function(){return this._active},set:function(t){this._active!==t&&(this._active=t,this.onActiveChange(),this.updateComponentsActiveStatus(),this.updateChildrenActiveStatus())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t,this.transform.parent=null!==t?t.transform:null},enumerable:!1,configurable:!0}),e.prototype.updateComponentsActiveStatus=function(){var t=this;!1===this.active&&(this.activeComponentsCache=this.components.filter((function(t){return t.active}))),this.activeComponentsCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeComponentsCache=[])},e.prototype.updateChildrenActiveStatus=function(){var t=this;!1===this.active&&(this.activeChildrenCache=this.getChildren().filter((function(t){return t.active}))),this.activeChildrenCache.forEach((function(e){return e.active=t.active})),!0===this.active&&(this.activeChildrenCache=[])},Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(Kt)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rigidBody",{get:function(){return this.getComponent(Zt)},enumerable:!1,configurable:!0}),e.prototype.onActiveChange=function(){},e.prototype.getCurrentScene=function(){return this.sceneManager.getCurrentScene()},e.prototype.addComponent=function(t,e,i){var n="string"==typeof e?void 0:e,r=new t(this,"string"==typeof e?e:i);return this.checkMultipleComponent(r,t),this.components.push(r),r.dispatch(g.Init,n),r},e.prototype.checkMultipleComponent=function(t,e){if(!1===t.allowMultiple&&this.hasComponent(e))throw new m("GameObject only allows one component of type "+e.name)},e.prototype.getComponents=function(t){return t?this.components.filter((function(e){return e instanceof t})):this.components},e.prototype.getComponent=function(t){return"string"==typeof t?this.components.find((function(e){return e.name===t})):this.components.find((function(e){return e instanceof t}))},e.prototype.hasComponent=function(t){return"string"==typeof t?this.components.some((function(e){return e.name===t})):this.components.some((function(e){return e instanceof t}))},e.prototype.removeComponent=function(t){var e=this.components.indexOf(t);-1!==e&&this.components.splice(e,1)[0].dispatch(g.Destroy)},e.prototype.addChild=function(t,e,i){var n=this.gameObjectManager.addGameObject(t,e,this,i);return n.transform.innerPosition.set(0,0),n.transform.position.copy(this.transform.position),n},e.prototype.getChildren=function(){return this.gameObjectManager.findGameObjectsByParent(this)},e.prototype.getChild=function(t){return this.gameObjectManager.findGameObjectByParent(this,t)},e.prototype.destroyChildren=function(){var t=this;this.gameObjectManager.findGameObjectsByParent(this).forEach((function(e){return t.gameObjectManager.destroyGameObject(e)}))},e.prototype._destroy=function(){var t=this;this.destroyComponents(),Object.keys(this).forEach((function(e){return delete t[e]}))},e.prototype.destroyComponents=function(){for(var t=0;t<this.components.length;t++)this.components[t].dispatch(g.Destroy),delete this.components[t];this.components=[]},e}(kt),ie=["Default"],ne=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMultiple=!1,t.renderManager=It.getSingleton("RenderManager"),t.canvas=It.getSingleton("DomManager").canvas,t.viewportRect=new a(0,0,0,0),t.worldSpaceRect=new a(0,0,0,0),t.depth=0,t.layers=ie,t._zoom=1,t}return c(i,e),Object.defineProperty(i.prototype,"zoom",{get:function(){return this._zoom},set:function(t){if(this.zoom<=0)throw new m("zoom must be greather than 0");this._zoom=t},enumerable:!1,configurable:!0}),i.prototype.addLayer=function(t){this.layers.push(t)},i.prototype.init=function(){this.cameraData={position:new t,layers:[],depth:1}},i.prototype.update=function(){this.updateViewportRect(),this.updateWorldSpaceRect(),this.updateCameraData()},i.prototype.updateViewportRect=function(){this.viewportRect.x=-this.canvas.width/2,this.viewportRect.y=-this.canvas.height/2,this.viewportRect.width=this.canvas.width,this.viewportRect.height=this.canvas.height},i.prototype.updateWorldSpaceRect=function(){this.worldSpaceRect.x=(this.gameObject.transform.position.x-this.viewportRect.width/2)/this._zoom,this.worldSpaceRect.y=(this.gameObject.transform.position.y-this.viewportRect.height/2)/this._zoom,this.worldSpaceRect.width=this.viewportRect.width/this._zoom,this.worldSpaceRect.height=this.viewportRect.height/this._zoom},i.prototype.updateCameraData=function(){this.cameraData.position.copy(this.gameObject.transform.position),this.cameraData.depth=this.depth,this.cameraData.layers=this.layers,this.cameraData.zoom=this._zoom,this.renderManager.addCameraData(this.cameraData)},i}(Qt),re=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return c(e,t),e.prototype.init=function(){this.transform.position.set(0,0),this.camera=this.addComponent(ne)},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,"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}(ee),oe=function(t){function e(e,i){var n=t.call(this)||this;return n.name=e,n.game=i,n.game.config.headless||n.addGameObject(re),n}return c(e,t),Object.defineProperty(e.prototype,"gameCamera",{get:function(){return this.findGameObject(re)},enumerable:!1,configurable:!0}),e.prototype._destroy=function(){var t=this;this.gameObjectManager.destroyAllGameObjects(),Object.keys(this).forEach((function(e){return delete t[e]}))},e}(kt),se=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}(),ae=function(){function e(e){this._type=b.Polygon,this._vertices=[],this._boundingBox=new a(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=e;for(var i=0;i<this._vertexModel.length;i++)this._vertices.push(new t),this._projectionAxes.push(new t)}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boundingBox",{get:function(){return this._boundingBox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"projectionAxes",{get:function(){return this._projectionAxes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexModel",{get:function(){return this._vertexModel},set:function(t){this._vertexModel=t},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},e.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)},e.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)},e.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]))},e}(),he=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 c(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}(ae),le=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,It.getConstant("GameConfig").collisions.method!==Tt.SAT)throw new m("Polygon Colliders need SAT collision method.");return r}return c(i,e),i.prototype.init=function(e){var i,n,r,o,s;if(e.vertexModel.length<3)throw new m("Polygon Collider needs at least 3 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&It.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(s=e.rotation)&&void 0!==s?s:new h,this.layer=e.layer;for(var a=0;a<this.vertexModel.length;a++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){var t;this.colliders.push(new se(new ae(this.scaledVertexModel),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Zt))),this.debug&&(this.renderer=this.gameObject.addComponent(ce,{collider:this.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}(Jt),ce=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t}return c(i,e),i.prototype.init=function(e){var i=e.collider;this.renderData={type:H.Geometric,layer:this.gameObject.layer,location:k.WorldSpace,position:new t,shape:W.Polygon,color:"#00FF00"},this.collider=i},i.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.position.copy(this.collider.shape.position),this.renderData.rotation=this.collider.shape.angle,this.renderData.vertexModel=this.collider.shape.vertexModel,this.renderManager.addRenderData(this.renderData)},i}($t),ue=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realWidth=0,i.realHeight=0,i.realOffset=new t,i.realPosition=new t,i.realRotation=0,i.applyRotation=It.getConstant("GameConfig").collisions.method===Tt.SAT,i.innerPosition=new t,i}return c(i,e),i.prototype.init=function(t){var e,i,n,r,o;this.width=t.width,this.height=t.height,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&It.getConstant("GameConfig").debugEnabled,this.rotation=null!==(o=t.rotation)&&void 0!==o?o:new h,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new se(new he(this.realWidth,this.realHeight,this.realPosition),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Zt))),this.debug&&(this.renderer=this.gameObject.addComponent(ce,{collider:this.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}(Jt),de=function(){function e(e){this.type=b.Circumference,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new a(0,0,0,0),this.angle=0,this.vertexModel=[],this.radius=0,this._position=new t,this.vertices=[new t,new t],this.radius=e}return Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.updateBoundingBox()},e.prototype.updateBoundingBox=function(){this.boundingBox.set(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},e}(),pe=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.offsetX=0,i.offsetY=0,i.realRadius=0,i.realOffset=new t,i.realPosition=new t,i.innerPosition=new t,i}return c(i,e),i.prototype.init=function(t){var e,i,n,r;this.radius=t.radius,this.offsetX=null!==(e=t.offsetX)&&void 0!==e?e:this.offsetX,this.offsetY=null!==(i=t.offsetY)&&void 0!==i?i:this.offsetY,this.physics=null!==(n=t.physics)&&void 0!==n?n:this.physics,this.debug=(null!==(r=t.debug)&&void 0!==r?r:this.debug)&&It.getConstant("GameConfig").debugEnabled,this.layer=t.layer},i.prototype.start=function(){var t;this.colliders.push(new se(new de(this.radius),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Zt))),this.debug&&(this.renderer=this.gameObject.addComponent(ge,{collider:this.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}(Jt),ge=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t}return c(i,e),i.prototype.init=function(e){var i=e.collider;this.renderData={type:H.Geometric,location:k.WorldSpace,layer:this.gameObject.layer,position:new t,shape:W.Circumference,color:"#00FF00"},this.renderData.color="#00FF00",this.collider=i},i.prototype.update=function(){this.renderData.layer=this.gameObject.layer,this.renderData.shape=W.Circumference,this.renderData.position.copy(this.collider.shape.position),this.renderData.radius=this.collider.shape.radius,this.renderManager.addRenderData(this.renderData)},i}($t),fe=function(){function e(e){this.vertexModel=e,this.type=b.Polygon,this.vertices=[new t,new t],this.projectionAxes=[new t],this.boundingBox=new a(0,0,0,0),this.angle=0,this._position=new t}return e.prototype.update=function(){this.updateVertices(),this.updateBoundingBox(),this.updateProjectionAxes()},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(t){this._position.copy(t)},enumerable:!1,configurable:!0}),e.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)},e.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},e.prototype.updateProjectionAxes=function(){t.normal(this.projectionAxes[0],t.subtract(this.projectionAxes[0],this.vertices[1],this.vertices[0]))},e}(),me=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.debug=!1,i.position=new t,i}return c(i,e),i.prototype.init=function(t){var e,i;this.tilemapRenderer=t.tilemapRenderer,this.layer=t.layer,this.debug=(null!==(e=t.debug)&&void 0!==e?e:this.debug)&&It.getConstant("GameConfig").debugEnabled,this.physics=!0,this.composite=null!==(i=t.composite)&&void 0!==i&&i},i.prototype.start=function(){var t;this.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.scaledTileWidth=this.tilemapRenderer.tileWidth*this.gameObject.transform.scale.x,this.scaledTileHeight=this.tilemapRenderer.tileHeight*this.gameObject.transform.scale.y,this.scaledWidth=this.tilemapRenderer.width*this.scaledTileWidth,this.scaledHeight=this.tilemapRenderer.height*this.scaledTileHeight,this.position.set(this.gameObject.transform.position.x+(this.tilemapRenderer.orientation===z.Center?-this.scaledWidth/2:0),this.gameObject.transform.position.y+([z.Center,z.RightCenter].includes(this.tilemapRenderer.orientation)?this.scaledHeight/2:this.tilemapRenderer.orientation==z.RightUp?this.scaledHeight:0)),this.composite?this.useLineColliders():this.useBoxColliders(),this.debug&&(this.renderer=this.gameObject.addComponent(ye,{colliders:this.colliders}))},i.prototype.useBoxColliders=function(){var e=this;this.tilemapRenderer.tiles.forEach((function(i,n){e.needsCollider(i,n)&&e.colliders.push(new se(new he(e.scaledTileWidth,e.scaledTileHeight,new t(e.position.x+(n%e.tilemapRenderer.width+.5)*e.scaledTileWidth,e.position.y-(Math.floor(n/e.tilemapRenderer.width)+.5)*e.scaledTileHeight)),e.layer,e.gameObject.id,!1,e.physics,e.hasComponent(Zt)))}))},i.prototype.useLineColliders=function(){var e,i,n=this,r=[],o=[];this.tilemapRenderer.tiles.forEach((function(t,e){if(0!==t){var i=e%n.tilemapRenderer.width,s=Math.floor(e/n.tilemapRenderer.width);r[s]||(r[s]=[]),r[s+1]||(r[s+1]=[]),o[s]||(o[s]=[]),o[s+1]||(o[s+1]=[]);var a=n.getNeighbors(e);n.hasTile(a[0])||(r[s][i]=!0,r[s][i+1]=!0),n.hasTile(a[2])||(r[s+1][i]=!0,r[s+1][i+1]=!0),n.hasTile(a[1])||(o[s][i]=!0,o[s+1][i]=!0),n.hasTile(a[3])||(o[s][i+1]=!0,o[s+1][i+1]=!0)}}));for(var s=0;s<r.length;s++)for(var a=0;a<r[s].length;a++)!e||!i||s*-this.scaledTileHeight===i.y&&r[s][a]||(this.addLineCollider(e,i),e=void 0,i=void 0),r[s][a]&&(e?i=new t(a*this.scaledTileWidth,s*-this.scaledTileHeight):e=new t(a*this.scaledTileWidth,s*-this.scaledTileHeight));e&&i&&this.addLineCollider(e,i),e=void 0,i=void 0;for(a=0;a<=this.tilemapRenderer.width;a++)for(s=0;s<o.length;s++)!e||!i||a*this.scaledTileWidth===i.x&&o[s][a]||(this.addLineCollider(e,i),e=void 0,i=void 0),o[s][a]&&(e?i=new t(a*this.scaledTileWidth,s*-this.scaledTileHeight):e=new t(a*this.scaledTileWidth,s*-this.scaledTileHeight));e&&i&&this.addLineCollider(e,i)},i.prototype.hasTile=function(t){return void 0!==t&&this.tilemapRenderer.tiles[t]&&this.tilemapRenderer.tiles[t]>0},i.prototype.addLineCollider=function(t,e){var i=new se(new fe([t.clone(),e.clone()]),this.layer,this.gameObject.id,!1,this.physics,this.hasComponent(Zt));i.shape.position=this.position,i.shape.update(),this.colliders.push(i)},i.prototype.needsCollider=function(t,e){var i=this;return 0!==t&&this.getNeighbors(e).some((function(t){return!t||!i.tilemapRenderer.tiles[t]||0===i.tilemapRenderer.tiles[t]}))},i.prototype.getNeighbors=function(t){return[t-this.tilemapRenderer.width>=0?t-this.tilemapRenderer.width:void 0,t%this.tilemapRenderer.width>0?t-1:void 0,t+this.tilemapRenderer.width<=this.tilemapRenderer.width*this.tilemapRenderer.height?t+this.tilemapRenderer.width:void 0,t%this.tilemapRenderer.width<this.tilemapRenderer.width-1?t+1:void 0]},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e){return e.layer=t.layer})),e.prototype.update.call(this)},i}(Jt),ye=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t.renderData=[],t.colliders=[],t}return c(i,e),i.prototype.init=function(e){var i=this,n=e.colliders;this.colliders=n,this.colliders.forEach((function(e,n){i.renderData[n]={type:H.Geometric,layer:i.gameObject.layer,location:k.WorldSpace,position:new t,shape:W.Polygon,color:"#00FF00"}}))},i.prototype.update=function(){var t=this;this.colliders.forEach((function(e,i){t.renderData[i].layer=t.gameObject.layer,t.renderData[i].position.copy(e.shape.position),t.renderData[i].rotation=e.shape.angle,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},i}($t),xe=function(e){function i(i,n){var r=e.call(this,i,n)||this;if(r.debug=!1,r.offsetX=0,r.offsetY=0,r.scaledVertexModel=[],r.scaledOffset=new t,r.scaledPosition=new t,r.finalRotation=0,r.innerPosition=new t,It.getConstant("GameConfig").collisions.method!==Tt.SAT)throw new m("Edge Colliders need SAT collision method.");return r}return c(i,e),i.prototype.init=function(e){var i,n,r,o,s;if(e.vertexModel.length<2)throw new m("Edge Collider needs at least 2 vertices.");this.debug=(null!==(i=e.debug)&&void 0!==i?i:this.debug)&&It.getConstant("GameConfig").debugEnabled,this.vertexModel=e.vertexModel,this.offsetX=null!==(n=e.offsetX)&&void 0!==n?n:this.offsetX,this.offsetY=null!==(r=e.offsetY)&&void 0!==r?r:this.offsetY,this.physics=null!==(o=e.physics)&&void 0!==o?o:this.physics,this.rotation=null!==(s=e.rotation)&&void 0!==s?s:new h,this.layer=e.layer;for(var a=0;a<this.vertexModel.length;a++)this.scaledVertexModel.push(new t)},i.prototype.start=function(){for(var t,e=0;e<this.scaledVertexModel.length-1;e++)this.colliders.push(new se(new fe([this.scaledVertexModel[e],this.scaledVertexModel[e+1]]),null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.gameObject.id,!0,this.physics,this.hasComponent(Zt)));this.debug&&(this.renderer=this.gameObject.addComponent(ve,{colliders:this.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}(Jt),ve=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t.renderData=[],t.colliders=[],t}return c(i,e),i.prototype.init=function(e){var i=this,n=e.colliders;this.colliders=n,this.colliders.forEach((function(e,n){i.renderData[n]={type:H.Geometric,layer:i.gameObject.layer,location:k.WorldSpace,position:new t,shape:W.Line,color:"#00FF00"}}))},i.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].rotation=e.shape.angle,t.renderData[i].vertexModel=e.shape.vertexModel,t.renderManager.addRenderData(t.renderData[i])}))},i}($t),be=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=It.getSingleton("RenderManager"),i.renderData=[],i.innerPosition=new t,i.cachePosition=new t,i.cacheRenderPosition=new t,i.scaledOffset=new t,i}return c(i,e),i.prototype.init=function(e){var i,n,r,o,s,a,l;void 0===e&&(e={}),this.sprite=e.sprite,this.offset=null!==(i=e.offset)&&void 0!==i?i:new t,this.rotation=null!==(n=e.rotation)&&void 0!==n?n:new h,this.flipHorizontal=null!==(r=e.flipHorizontal)&&void 0!==r&&r,this.flipVertical=null!==(o=e.flipVertical)&&void 0!==o&&o,this.opacity=null!==(s=e.opacity)&&void 0!==s?s:1,this._tiled=null!==(a=e.tiled)&&void 0!==a?a:new t(1,1),this.maskColor=e.maskColor,this.maskColorMix=null!==(l=e.maskColorMix)&&void 0!==l?l:0,this.tintColor=e.tintColor,this.layer=e.layer},Object.defineProperty(i.prototype,"tiled",{get:function(){return this._tiled},set:function(t){if(t.x%1!=0||t.y%1!=0)throw new m("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 e=0;e<this._tiled.x*this._tiled.y;e++)this.renderData[e]={type:H.Sprite,location:k.WorldSpace,layer:"",position:new t,image:this.sprite.image,width:0,height:0}}},i.prototype.updateRenderData=function(t,e,i){var n;this.renderData[t].location=this.gameObject.ui?k.ViewPort:k.WorldSpace,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.renderData[e].position,this.cachePosition,this.cacheRenderPosition),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}($t),Me=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t.lastFrameText="",t}return c(i,e),i.prototype.init=function(e){var i,n,r,o,s,a,l,c,u,d;if(this.text=e.text,this.font=null!==(i=e.font)&&void 0!==i?i:"Sans",this.fontSize=null!==(n=e.fontSize)&&void 0!==n?n:12,this.width=null!==(r=e.width)&&void 0!==r?r:100,this.height=null!==(o=e.height)&&void 0!==o?o:100,this.offset=null!==(s=e.offset)&&void 0!==s?s:new t,this.color=null!==(a=e.color)&&void 0!==a?a:"#000000",this.charRanges=null!==(l=e.charRanges)&&void 0!==l?l:[32,126,161,255],this.lineSeparation=null!==(c=e.lineSeparation)&&void 0!==c?c:0,this.letterSpacing=null!==(u=e.letterSpacing)&&void 0!==u?u:0,this.smooth=e.smooth,this.rotation=null!==(d=e.rotation)&&void 0!==d?d:new h,this.opacity=e.opacity,this.orientation=e.orientation,this.bitmapMargin=e.bitmapMargin,this.bitmapSpacing=e.bitmapSpacing,this.charRanges.length%2!=0)throw new m("TextRenderer.charRanges must be a 2 column matrix");if(this.lineSeparation%2!=0)throw new m("TextRenderer.lineSeparation must be multiple of 2")},i.prototype.start=function(){this.renderData={type:H.Text,location:k.WorldSpace,position:new t,layer:this.gameObject.layer,text:"",font:this.font,fontSize:this.fontSize,bitmap:{charRanges:this.charRanges,margin:this.bitmapMargin,spacing:this.bitmapSpacing},smooth:this.smooth}},i.prototype.update=function(){var e,i;this.text&&(this.renderData.layer=this.gameObject.layer,this.renderData.location=this.gameObject.ui?k.ViewPort:k.WorldSpace,this.renderData.text=this.text!==this.lastFrameText?this.crop():this.renderData.text,this.renderData.fontSize=this.fontSize,this.renderData.color=this.color,this.renderData.orientation=this.orientation,this.renderData.lineSeparation=this.lineSeparation,this.renderData.letterSpacing=this.letterSpacing,this.renderData.rotation=null!==(i=this.gameObject.transform.rotation.radians+(null===(e=this.rotation)||void 0===e?void 0:e.radians))&&void 0!==i?i:0,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,s=null!==(t=r[n].match(new RegExp(".{1,"+Math.floor(this.width/(this.fontSize+this.letterSpacing))+"}","g")))&&void 0!==t?t:[""];o<s.length;o++){var a=s[o];if((i+=this.fontSize+this.lineSeparation)>this.height)return e.join("\n");e.push(a)}return e.join("\n")},i}($t),we=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.renderManager=It.getSingleton("RenderManager"),i.offset=new t,i.rotation=new h,i.opacity=1,i.innerPosition=new t,i.scaledOffset=new t,i}return c(i,e),i.prototype.init=function(e){var i,n,r,o;this.width=e.width,this.height=e.height,this.color=e.color,this.offset=null!==(i=e.offset)&&void 0!==i?i:this.offset,this.rotation=null!==(n=e.rotation)&&void 0!==n?n:this.rotation,this.opacity=null!==(r=e.opacity)&&void 0!==r?r:this.opacity,this.layer=e.layer,this.renderData={type:H.Mask,layer:null!==(o=this.layer)&&void 0!==o?o:this.gameObject.layer,location:this.gameObject.ui?k.ViewPort:k.WorldSpace,position:new t,width:0,height:0,color:""}},i.prototype.update=function(){var t;this.renderData.location=this.gameObject.ui?k.ViewPort:k.WorldSpace,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}($t),_e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t.tiles=[],t.tilesetTileIds=[],t.chunks=[],t.scaledTileWidth=0,t.scaledTileHeight=0,t.renderData=[],t}return c(i,e),i.prototype.init=function(t){var e=t.tiledData,i=t.tilemapLayer,n=t.tileset,r=t.tileWidth,o=t.tileHeight,s=t.layer,a=t.orientation,h=t.smooth;this.tiledData=e,this.tilemapLayer=i,this.tileset=n,this.tileWidth=r,this.tileHeight=o,this.layer=s,this.smooth=null!=h&&h,this.width=this.tiledData.width,this.height=this.tiledData.height,this.orientation=a,this.processTilemap()},i.prototype.update=function(){var t=this;this.updateRenderData(),this.renderData.forEach((function(e){return t.renderManager.addRenderData(e)}))},i.prototype.processTilemap=function(){var t=this;this.tiledData.layers.forEach((function(e){!0===e.visible&&t.tilemapLayer===e.name&&(t.alpha=e.opacity,t.tintColor=e.tintcolor,!0===t.tiledData.infinite?e.chunks.forEach((function(i){return t.processChunk(i,e)})):t.processChunk(e,e))})),this.updateRenderData(),this.tilesetTileIds=[]},i.prototype.processChunk=function(e,i){var n,r=this,o={type:H.Tilemap,layer:null!==(n=this.layer)&&void 0!==n?n:this.gameObject.layer,location:this.gameObject.ui?k.ViewPort:k.WorldSpace,position:new t,tileset:this.tileset,tilemap:{width:e.width,tileWidth:this.tileWidth,tileHeight:this.tileHeight},tiles:e.data.map((function(t){return r.getTilesetTileId(t)})),orientation:this.orientation,smooth:this.smooth};e.type&&"tilelayer"===e.type?this.tiles=o.tiles:o.tiles.forEach((function(t,i){r.tiles[r.tiledData.width*(e.y+Math.floor(i/e.width))+e.x+i%e.width]=t})),this.renderData.push(o),this.chunks.push(e)},i.prototype.getTilesetTileId=function(t){return this.tilesetTileIds[t]||(this.tilesetTileIds[t]=this.tiledData.tilesets.reduce((function(e,i){return t>=i.firstgid?t-i.firstgid+1:e}),0)),this.tilesetTileIds[t]},i.prototype.updateRenderData=function(){var t=this;this.scaledTileWidth=this.tileWidth*this.gameObject.transform.scale.x,this.scaledTileHeight=this.tileHeight*this.gameObject.transform.scale.y,this.realWidth=this.tiledData.width*this.scaledTileWidth,this.realHeight=this.tiledData.height*this.scaledTileHeight,this.renderData.forEach((function(e,i){var n;e.layer=null!==(n=t.layer)&&void 0!==n?n:t.gameObject.layer,e.position.set(t.gameObject.transform.position.x+t.chunks[i].x*t.scaledTileWidth,t.gameObject.transform.position.y+t.chunks[i].y*t.scaledTileHeight),e.tilemap.tileWidth=t.scaledTileWidth,e.tilemap.tileHeight=t.scaledTileHeight,e.tintColor=t.tintColor,e.alpha=t.alpha}))},i}($t),je=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.renderManager=It.getSingleton("RenderManager"),t.scaledTileWidth=0,t.scaledTileHeight=0,t}return c(i,e),i.prototype.init=function(e){var i,n=this,r=e.tiles,o=e.tileset,s=e.tileWidth,a=e.tileHeight,h=e.width,l=e.layer,c=e.orientation,u=e.alpha,d=e.tintColor,p=e.smooth;r.split("\n").forEach((function(t){t.split(",").forEach((function(t){return t.trim().length>0?n.tiles.push(Number(t)):null}))})),this.tileset=o,this.width=h,this.tileWidth=s,this.tileHeight=a,this.layer=l,this.height=Math.ceil(this.tiles.length/this.width),this.orientation=c,this.alpha=u,this.tintColor=d,this.renderData={type:H.Tilemap,layer:null!==(i=this.layer)&&void 0!==i?i:this.gameObject.layer,location:this.gameObject.ui?k.ViewPort:k.WorldSpace,position:new t,tileset:this.tileset,tilemap:{width:this.width,tileWidth:this.tileWidth,tileHeight:this.tileHeight},tiles:this.tiles,orientation:this.orientation,smooth:p},this.updateRenderData()},i.prototype.update=function(){this.updateRenderData(),this.renderManager.addRenderData(this.renderData)},i.prototype.updateRenderData=function(){var t;this.scaledTileWidth=this.tileWidth*this.gameObject.transform.scale.x,this.scaledTileHeight=this.tileHeight*this.gameObject.transform.scale.y,this.realWidth=this.width*this.scaledTileWidth,this.realHeight=this.height*this.scaledTileHeight,this.renderData.layer=null!==(t=this.layer)&&void 0!==t?t:this.gameObject.layer,this.renderData.position.copy(this.gameObject.transform.position),this.renderData.tintColor=this.tintColor,this.renderData.alpha=this.alpha,this.renderData.tilemap.tileWidth=this.scaledTileWidth,this.renderData.tilemap.tileHeight=this.scaledTileHeight},i}($t),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},Oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeManager=It.getSingleton("TimeManager"),e.spriteRenderer=null,e.animations=new Map,e.currentAnimation=null,e.paused=!1,e}return c(e,t),e.prototype.init=function(t){var e=t.spriteRenderer;this.spriteRenderer=e},e.prototype.update=function(){null===this.currentAnimation||this.paused||(this.currentAnimation.playFrame(this.timeManager.deltaTime),!0===this.currentAnimation.restarted&&!1===this.currentAnimation.loop?this.currentAnimation=null:this.spriteRenderer.sprite=this.currentAnimation.sprite)},e.prototype.addAnimation=function(t,e,i){return void 0===e&&(e="default"),t.framerate=null!=i?i:t.framerate,this.animations.set(e,new Pe(t)),this},e.prototype.playAnimation=function(t){if(void 0===t&&(t="default"),!1!==this.active){if(!1===this.animations.has(t))throw new m("Animation with name "+t+" does not exist.");this.stopAnimation(),this.currentAnimation=this.animations.get(t)}},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused=!1},e.prototype.stopAnimation=function(){null!==this.currentAnimation&&(this.currentAnimation.reset(),this.currentAnimation=null)},e.prototype.isPlayingAnimation=function(t){return this.animations.get(t)&&this.animations.get(t)===this.currentAnimation},e}(zt),Pe=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.reset=function(){this.currentFrame=0,this.frameTime=0,this._restarted=!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}(),Re=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","pointerup","touchend","keydown","keyup"],Se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMultiple=!1,e.volume=1,e.loop=!1,e.audio=null,e.clones=new Map,e._playing=!1,e._paused=!1,e.audioEventHandler=function(t){"ended"===t.type&&(e._playing=!1,e.audio.removeEventListener("ended",e.audioEventHandler))},e.userinputEventHandler=function(){Re.forEach((function(t){window.removeEventListener(t,e.userinputEventHandler)})),e.audio.play()},e}return c(e,t),e.prototype.init=function(t){var e,i,n;void 0===t&&(t={}),this.audio=null!==(e=t.audio)&&void 0!==e?e:this.audio,this.volume=null!==(i=t.volume)&&void 0!==i?i:this.volume,this.loop=null!==(n=t.loop)&&void 0!==n?n:this.loop},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 Re.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.onActiveChange=function(){!1===this.active&&this.stop()},e.prototype.onDestroy=function(){this.stop()},e}(zt),De=function(){function e(e){var i,n,r,o=this;this._width=null,this._height=null,this._loaded=!1,this.image=e.image,this.smooth=null!==(i=e.smooth)&&void 0!==i&&i,this.scale=null!==(r=null!==(n=e.scale)&&void 0!==n?n:It.getConstant("GameConfig").spriteDefaultScale)&&void 0!==r?r:new t(1,1),this.slice=e.slice,this.slice&&(this._width=this.slice.width,this._height=this.slice.height);var s=function(){var t,e;o._width=(null!==(t=o._width)&&void 0!==t?t:o.image.naturalWidth)*Math.abs(o.scale.x),o._height=(null!==(e=o._height)&&void 0!==e?e:o.image.naturalHeight)*Math.abs(o.scale.y),o._loaded=!0};this.image.naturalWidth?s():this.image.addEventListener("load",(function(){return s()}))}return 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}),Object.defineProperty(e.prototype,"loaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),e}();!function(t){t[t.Rectangle=0]="Rectangle",t[t.Circumference=1]="Circumference"}(Lt||(Lt={}));var Ae=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.allowMultiple=!1,i.width=100,i.height=100,i.radius=50,i.touchEnabled=!0,i._offset=new t,i.pressed=!1,i.mouse=It.getSingleton("InputManager").mouse,i.touch=It.getSingleton("InputManager").touch,i.position=new t,i.distance=new t,i.pressedLastFrame=!1,i.scaled={width:0,height:0,radius:0,offset:new t},i}return c(i,e),Object.defineProperty(i.prototype,"offset",{get:function(){return this._offset},set:function(t){this._offset=t},enumerable:!1,configurable:!0}),i.prototype.init=function(t){var e=t.type,i=t.height,n=t.radius,r=t.touchEnabled,o=t.width,s=t.offset;this.type=e,this.width=null!=o?o:this.width,this.height=null!=i?i:this.height,this.radius=null!=n?n:this.radius,this.touchEnabled=null!=r?r:this.touchEnabled,this._offset=null!=s?s:this._offset},i.prototype.update=function(){this.scale(),t.add(this.position,this.gameObject.transform.position,this.scaled.offset),this.pressedLastFrame=this.pressed,this.pressed=!1,this.mouse.leftButtonPressed&&(this.resolveMouseAndRectangle(),this.resolveMouseAndCircumference()),this.touchEnabled&&this.touch.touching&&(this.resolveTouchAndRectangle(),this.resolveTouchAndCircumference()),this.onClick&&!this.pressedLastFrame&&this.pressed&&this.onClick(),this.onPressed&&this.pressed&&this.onPressed()},i.prototype.scale=function(){this.scaled.width=this.width*this.gameObject.transform.scale.x,this.scaled.height=this.width*this.gameObject.transform.scale.y,this.scaled.offset.x=this._offset.x*this.gameObject.transform.scale.x,this.scaled.offset.y=this._offset.y*this.gameObject.transform.scale.y,this.scaled.radius=this.radius*this.gameObject.transform.scale.magnitude},i.prototype.resolveMouseAndRectangle=function(){this.type===Lt.Rectangle&&(this.pressed||(this.pressed=s(this.mouse.positionInViewport.x,this.position.x-this.scaled.width/2,this.position.x+this.scaled.width/2)&&s(this.mouse.positionInViewport.y,this.position.y-this.scaled.height/2,this.position.y+this.scaled.height/2)))},i.prototype.resolveMouseAndCircumference=function(){this.type===Lt.Circumference&&(t.subtract(this.distance,this.position,this.mouse.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius))},i.prototype.resolveTouchAndRectangle=function(){this.type===Lt.Rectangle&&(this.pressed||(this.pressed=this.position.x+this.scaled.width/2>=this.touch.positionInViewport.x-this.touch.radius.x&&this.position.x-this.scaled.width/2<=this.touch.positionInViewport.x+this.touch.radius.x&&this.position.y+this.scaled.height/2>=this.touch.positionInViewport.y-this.touch.radius.y&&this.position.y-this.scaled.height/2<=this.touch.positionInViewport.y+this.touch.radius.y))},i.prototype.resolveTouchAndCircumference=function(){this.type===Lt.Circumference&&(t.subtract(this.distance,this.position,this.touch.positionInViewport),this.pressed||(this.pressed=this.distance.magnitude<=this.scaled.radius+this.touch.radius.x))},i}(Ht),Te=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.mousePressed=!1,i.position=new t,i}return c(i,e),i.prototype.start=function(){this.camera=this.getCurrentScene().gameCamera},i.prototype.update=function(){I.mouse.leftButtonPressed&&!1===this.mousePressed&&(t.round(this.position,t.add(this.position,this.camera.transform.position,t.scale(this.position,I.mouse.positionInViewport,1/this.camera.zoom))),console.log("Space position: {x: "+this.position.x+", y: "+this.position.y+"}")),this.mousePressed=I.mouse.leftButtonPressed},i}(ee);export{Ce as Animation,Oe as Animator,B as AssetManager,Se as AudioPlayer,pe as BallCollider,ue as BoxCollider,Ae as Button,Lt as ButtonType,ne as Camera,se as ColliderData,Tt as CollisionMethodConfig,Ht as Component,U as DomManager,xe as EdgeCollider,Vt as Game,re as GameCamera,ee as GameObject,V as GameObjectManager,_ as GamepadController,j as GamepadData,I as InputManager,O as KeyboardController,te as LAYER_DEFAULT,we as MaskRenderer,P as MouseController,Yt as PhysicsComponent,le as PolygonCollider,ce as PolygonColliderRenderer,qt as PreRenderComponent,a as Rectangle,Zt as RigidBody,A as RigidBodyType,h as Rotation,oe as Scene,L as SceneManager,Te as SpacePointer,De as Sprite,be as SpriteRenderer,wt as TextOrientation,Me as TextRenderer,_e as TiledTilemapRenderer,me as TilemapCollider,z as TilemapOrientation,je as TilemapRenderer,G as TimeManager,F as TouchController,Kt as Transform,t as Vector2,s as between,e as clamp,r as fixedRound,n as randomFloat,i as randomInt,o as range};
|