gdcore-tools 2.0.0-gd-v5.5.241-autobuild → 2.0.0-gd-v5.5.243-autobuild

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.
Files changed (132) hide show
  1. package/dist/Runtime/AsyncTasksManager.js +2 -2
  2. package/dist/Runtime/AsyncTasksManager.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  6. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +47 -0
  12. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  16. package/dist/Runtime/Extensions/3D/Skybox.js +2 -0
  17. package/dist/Runtime/Extensions/3D/Skybox.js.map +7 -0
  18. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  19. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  20. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  21. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  22. package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
  23. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  24. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  25. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
  26. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  27. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  28. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  29. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  30. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  31. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  32. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  34. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  35. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  38. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  39. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  40. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  41. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  42. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  43. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  44. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  45. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  46. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  47. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
  48. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  49. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  50. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  51. package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
  52. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
  53. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
  54. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
  55. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
  56. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  57. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  58. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  59. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  60. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  61. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  62. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
  63. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  64. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  65. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  66. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  67. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  68. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  69. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  70. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  71. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  74. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  75. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
  76. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  78. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  79. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js +1 -1
  80. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
  81. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  82. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  83. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  84. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  85. package/dist/Runtime/RuntimeLayer.js +1 -1
  86. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  87. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  88. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  89. package/dist/Runtime/events-tools/objecttools.js +1 -1
  90. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  91. package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
  92. package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
  93. package/dist/Runtime/gd.js +1 -1
  94. package/dist/Runtime/gd.js.map +2 -2
  95. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  96. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  97. package/dist/Runtime/indexeddb.js +2 -0
  98. package/dist/Runtime/indexeddb.js.map +7 -0
  99. package/dist/Runtime/oncetriggers.js +1 -1
  100. package/dist/Runtime/oncetriggers.js.map +2 -2
  101. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  102. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  103. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js +2 -2
  104. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  105. package/dist/Runtime/runtimebehavior.js +1 -1
  106. package/dist/Runtime/runtimebehavior.js.map +2 -2
  107. package/dist/Runtime/runtimegame.js +1 -1
  108. package/dist/Runtime/runtimegame.js.map +2 -2
  109. package/dist/Runtime/runtimeobject.js +1 -1
  110. package/dist/Runtime/runtimeobject.js.map +2 -2
  111. package/dist/Runtime/runtimescene.js +1 -1
  112. package/dist/Runtime/runtimescene.js.map +2 -2
  113. package/dist/Runtime/scenestack.js +1 -1
  114. package/dist/Runtime/scenestack.js.map +2 -2
  115. package/dist/Runtime/spriteruntimeobject.js +1 -1
  116. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  117. package/dist/Runtime/timemanager.js +1 -1
  118. package/dist/Runtime/timemanager.js.map +2 -2
  119. package/dist/Runtime/timer.js +1 -1
  120. package/dist/Runtime/timer.js.map +2 -2
  121. package/dist/Runtime/types/global-types.d.ts +29 -0
  122. package/dist/Runtime/types/project-data.d.ts +144 -3
  123. package/dist/Runtime/types/save-state.d.ts +9 -0
  124. package/dist/Runtime/variable.js +1 -1
  125. package/dist/Runtime/variable.js.map +2 -2
  126. package/dist/Runtime/variablescontainer.js +1 -1
  127. package/dist/Runtime/variablescontainer.js.map +2 -2
  128. package/dist/lib/libGD.cjs +1 -1
  129. package/dist/lib/libGD.wasm +0 -0
  130. package/dist/loaders.cjs +1 -1
  131. package/gd.d.ts +1 -0
  132. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/runtimescene-pixi-renderer.ts"],
4
- "sourcesContent": ["namespace gdjs {\n /**\n * The renderer for a gdjs.RuntimeScene using Pixi.js.\n */\n export class RuntimeScenePixiRenderer\n implements gdjs.RuntimeInstanceContainerPixiRenderer\n {\n private _runtimeGameRenderer: gdjs.RuntimeGamePixiRenderer | null;\n private _runtimeScene: gdjs.RuntimeScene;\n private _pixiContainer: PIXI.Container;\n private _profilerText: PIXI.Text | null = null;\n private _showCursorAtNextRender: boolean = false;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _layerRenderingMetrics: {\n rendered2DLayersCount: number;\n rendered3DLayersCount: number;\n } = {\n rendered2DLayersCount: 0,\n rendered3DLayersCount: 0,\n };\n\n constructor(\n runtimeScene: gdjs.RuntimeScene,\n runtimeGameRenderer: gdjs.RuntimeGamePixiRenderer | null\n ) {\n this._runtimeGameRenderer = runtimeGameRenderer;\n this._runtimeScene = runtimeScene;\n this._pixiContainer = new PIXI.Container();\n\n // Contains the layers of the scene (and, optionally, debug PIXI objects).\n this._pixiContainer.sortableChildren = true;\n\n this._threeRenderer = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getThreeRenderer()\n : null;\n }\n\n onGameResolutionResized() {\n const pixiRenderer = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getPIXIRenderer()\n : null;\n if (!pixiRenderer) {\n return;\n }\n const runtimeGame = this._runtimeScene.getGame();\n\n // TODO (3D): should this be done for each individual layer?\n // Especially if we remove _pixiContainer entirely.\n this._pixiContainer.scale.x =\n pixiRenderer.width / runtimeGame.getGameResolutionWidth();\n this._pixiContainer.scale.y =\n pixiRenderer.height / runtimeGame.getGameResolutionHeight();\n\n for (const runtimeLayer of this._runtimeScene._orderedLayers) {\n runtimeLayer.getRenderer().onGameResolutionResized();\n }\n }\n\n onSceneUnloaded() {\n // TODO (3D): call the method with the same name on RuntimeLayers so they can dispose?\n }\n\n render() {\n const runtimeGameRenderer = this._runtimeGameRenderer;\n if (!runtimeGameRenderer) return;\n\n const pixiRenderer = runtimeGameRenderer.getPIXIRenderer();\n if (!pixiRenderer) return;\n\n const threeRenderer = this._threeRenderer;\n\n // If we are in VR, we cannot render like this: we must use the special VR\n // rendering method to not display a black screen.\n //\n // We cannot call it here either - the headset will request a frame to be rendered\n // whenever it wants and we must oblige, however this will be called whenever\n // we do a step - and we may step multiple times or none at all depending on the\n // min/max FPS and possibly other factors, and the headset will not allow that.\n //\n // It is therefore left to the VR extension to call the VR rendering method whenever\n // the headset require a new image, we'll just disable rendering when stepping to\n // not interfere with the headset's rendering.\n if (threeRenderer && threeRenderer.xr.isPresenting) return;\n\n this._layerRenderingMetrics.rendered2DLayersCount = 0;\n this._layerRenderingMetrics.rendered3DLayersCount = 0;\n\n if (threeRenderer) {\n // Layered 2D, 3D or 2D+3D rendering.\n threeRenderer.info.autoReset = false;\n threeRenderer.info.reset();\n\n /** Useful to render the background color. */\n let isFirstRender = true;\n\n /**\n * true if the last layer rendered 3D objects using Three.js, false otherwise.\n * Useful to avoid needlessly resetting the WebGL states between layers (which can be expensive).\n */\n let lastRenderWas3D = true;\n\n // Even if no rendering at all has been made already, setting up the Three.js/PixiJS renderers\n // might have changed some WebGL states already. Reset the state for the very first frame.\n // And, out of caution, keep doing it for every frame.\n // TODO (3D): optimization - check if this can be done only on the very first frame.\n threeRenderer.resetState();\n\n // Render each layer one by one.\n for (let i = 0; i < this._runtimeScene._orderedLayers.length; ++i) {\n const runtimeLayer = this._runtimeScene._orderedLayers[i];\n if (!runtimeLayer.isVisible()) continue;\n\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n const runtimeLayerRenderingType = runtimeLayer.getRenderingType();\n const layerHas3DObjectsToRender = runtimeLayerRenderer.has3DObjects();\n if (\n runtimeLayerRenderingType ===\n gdjs.RuntimeLayerRenderingType.TWO_D ||\n !layerHas3DObjectsToRender\n ) {\n // Render a layer with 2D rendering (PixiJS) only if layer is configured as is\n // or if there is no 3D object to render.\n\n if (lastRenderWas3D) {\n // Ensure the state is clean for PixiJS to render.\n threeRenderer.resetState();\n pixiRenderer.reset();\n }\n\n if (isFirstRender) {\n // Render the background color.\n pixiRenderer.background.color =\n this._runtimeScene.getBackgroundColor();\n pixiRenderer.background.alpha = 1;\n if (this._runtimeScene.getClearCanvas()) pixiRenderer.clear();\n\n isFirstRender = false;\n }\n\n if (runtimeLayer.isLightingLayer()) {\n // Render the lights on the render texture used then by the lighting Sprite.\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n }\n\n // TODO (2d lights): refactor to remove the need for `getLightingSprite`.\n const pixiContainer =\n (runtimeLayer.isLightingLayer() &&\n runtimeLayerRenderer.getLightingSprite()) ||\n runtimeLayerRenderer.getRendererObject();\n\n pixiRenderer.render(pixiContainer, { clear: false });\n this._layerRenderingMetrics.rendered2DLayersCount++;\n\n lastRenderWas3D = false;\n } else {\n // Render a layer with 3D rendering, and possibly some 2D rendering too.\n const threeScene = runtimeLayerRenderer.getThreeScene();\n const threeCamera = runtimeLayerRenderer.getThreeCamera();\n const threeEffectComposer =\n runtimeLayerRenderer.getThreeEffectComposer();\n\n // Render the 3D objects of this layer.\n if (threeScene && threeCamera && threeEffectComposer) {\n // TODO (3D) - optimization: do this at the beginning for all layers that are 2d+3d?\n // So the second pass is clearer (just rendering 2d or 3d layers without doing PixiJS renders in between).\n if (\n runtimeLayerRenderingType ===\n gdjs.RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D\n ) {\n const layerHas2DObjectsToRender =\n runtimeLayerRenderer.has2DObjects();\n\n if (layerHas2DObjectsToRender) {\n if (lastRenderWas3D) {\n // Ensure the state is clean for PixiJS to render.\n threeRenderer.resetState();\n pixiRenderer.reset();\n }\n\n // Do the rendering of the PixiJS objects of the layer on the render texture.\n // Then, update the texture of the plane showing the PixiJS rendering,\n // so that the 2D rendering made by PixiJS can be shown in the 3D world.\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n runtimeLayerRenderer.updateThreePlaneTextureFromPixiRenderTexture(\n // The renderers are needed to find the internal WebGL texture.\n threeRenderer,\n pixiRenderer\n );\n this._layerRenderingMetrics.rendered2DLayersCount++;\n\n lastRenderWas3D = false;\n }\n runtimeLayerRenderer.show2DRenderingPlane(\n layerHas2DObjectsToRender\n );\n }\n\n if (!lastRenderWas3D) {\n // It's important to reset the internal WebGL state of PixiJS, then Three.js\n // to ensure the 3D rendering is made properly by Three.js\n pixiRenderer.reset();\n threeRenderer.resetState();\n }\n\n if (isFirstRender) {\n // Render the background color.\n threeRenderer.setClearColor(\n this._runtimeScene.getBackgroundColor()\n );\n threeRenderer.resetState();\n if (this._runtimeScene.getClearCanvas()) threeRenderer.clear();\n threeScene.background = new THREE.Color(\n this._runtimeScene.getBackgroundColor()\n );\n\n isFirstRender = false;\n } else {\n // It's important to set the background to null, as maybe the first rendered\n // layer has changed and so the Three.js scene background must be reset.\n threeScene.background = null;\n }\n\n // Clear the depth as each layer is independent and display on top of the previous one,\n // even 3D objects.\n threeRenderer.clearDepth();\n if (runtimeLayerRenderer.hasPostProcessingPass()) {\n threeEffectComposer.render();\n } else {\n threeRenderer.render(threeScene, threeCamera);\n }\n\n this._layerRenderingMetrics.rendered3DLayersCount++;\n\n lastRenderWas3D = true;\n }\n }\n }\n\n const debugContainer = this._runtimeScene\n .getDebuggerRenderer()\n .getRendererObject();\n\n if (debugContainer) {\n threeRenderer.resetState();\n pixiRenderer.reset();\n pixiRenderer.render(debugContainer);\n lastRenderWas3D = false;\n }\n\n if (!lastRenderWas3D) {\n // Out of caution, reset the WebGL states from PixiJS to start again\n // with a 3D rendering on the next frame.\n pixiRenderer.reset();\n }\n\n // Uncomment to display some debug metrics from Three.js.\n // console.log(threeRenderer.info);\n } else {\n // 2D only rendering.\n\n // Render lights in render textures first.\n for (const runtimeLayer of this._runtimeScene._orderedLayers) {\n if (runtimeLayer.isLightingLayer()) {\n // Render the lights on the render texture used then by the lighting Sprite.\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n }\n }\n\n // this._renderProfileText(); //Uncomment to display profiling times\n\n // Render all the layers then.\n // TODO: replace by a loop like in 3D?\n pixiRenderer.background.color = this._runtimeScene.getBackgroundColor();\n pixiRenderer.render(this._pixiContainer, {\n clear: this._runtimeScene.getClearCanvas(),\n });\n this._layerRenderingMetrics.rendered2DLayersCount++;\n }\n\n // synchronize showing the cursor with rendering (useful to reduce\n // blinking while switching from in-game cursor)\n if (this._showCursorAtNextRender) {\n const canvas = runtimeGameRenderer.getCanvas();\n if (canvas) canvas.style.cursor = '';\n this._showCursorAtNextRender = false;\n }\n\n // Uncomment to check the number of 2D&3D rendering done\n // console.log(this._layerRenderingMetrics);\n }\n\n /**\n * Unless you know what you are doing, use the VR extension instead of this function directly.\n *\n * In VR, only 3D elements can be rendered, 2D cannot.\n * This rendering method skips over all 2D layers and elements, and simply renders the 3D content.\n * This method is to be called by the XRSession's `requestAnimationFrame` for rendering to\n * the headset whenever the headset requests the screen to be drawn. Note that while an XRSession\n * is in progress, the regular `requestAnimationFrame` will be disabled. Make sure that whenever you\n * enter an XRSession, you:\n * - Call this function first and foremost when the XRSession's requestAnimationFrame fires,\n * as it is necessary to draw asap as the headset will eventually stop waiting and just draw the\n * framebuffer as it is to maintain a constant screen refresh rate, which can be in the middle of\n * or even before rendering if we aren't fast enough, leading to screen flashes and bugs.\n * - Call GDevelop's step function to give the scene a chance to step after having drawn to the screen\n * to allow the game to actually progress, since GDevelop will no longer step by itself with\n * `requestAnimationFrame` disabled.\n *\n * Note to engine developers: `threeRenderer.resetState()` may NOT be called in this function,\n * as WebXR modifies the WebGL state in a way that resetting it will cause an improper render\n * that will lead to a black screen being displayed in VR mode.\n */\n renderForVR() {\n const runtimeGameRenderer = this._runtimeGameRenderer;\n if (!runtimeGameRenderer) return;\n\n const threeRenderer = this._threeRenderer;\n // VR rendering relies on ThreeJS\n if (!threeRenderer)\n throw new Error('Cannot render a scene with no 3D elements in VR!');\n\n // Render each layer one by one.\n let isFirstRender = true;\n for (let i = 0; i < this._runtimeScene._orderedLayers.length; ++i) {\n const runtimeLayer = this._runtimeScene._orderedLayers[i];\n if (!runtimeLayer.isVisible()) continue;\n\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n const runtimeLayerRenderingType = runtimeLayer.getRenderingType();\n if (\n runtimeLayerRenderingType === gdjs.RuntimeLayerRenderingType.TWO_D ||\n !runtimeLayerRenderer.has3DObjects()\n )\n continue;\n\n // Render a layer with 3D rendering, and no 2D rendering at all for VR.\n const threeScene = runtimeLayerRenderer.getThreeScene();\n const threeCamera = runtimeLayerRenderer.getThreeCamera();\n if (!threeScene || !threeCamera) continue;\n\n if (isFirstRender) {\n // Render the background color.\n threeRenderer.setClearColor(this._runtimeScene.getBackgroundColor());\n if (this._runtimeScene.getClearCanvas()) threeRenderer.clear();\n threeScene.background = new THREE.Color(\n this._runtimeScene.getBackgroundColor()\n );\n\n isFirstRender = false;\n } else {\n // It's important to set the background to null, as maybe the first rendered\n // layer has changed and so the Three.js scene background must be reset.\n threeScene.background = null;\n }\n\n // Clear the depth as each layer is independent and display on top of the previous one,\n // even 3D objects.\n threeRenderer.clearDepth();\n threeRenderer.render(threeScene, threeCamera);\n }\n }\n\n _renderProfileText() {\n const profiler = this._runtimeScene.getProfiler();\n if (!profiler) {\n return;\n }\n if (!this._profilerText) {\n this._profilerText = new PIXI.Text(' ', {\n align: 'left',\n stroke: '#FFF',\n strokeThickness: 1,\n });\n\n // Add on top of all layers:\n this._pixiContainer.addChild(this._profilerText);\n }\n const average = profiler.getFramesAverageMeasures();\n const outputs = [];\n gdjs.Profiler.getProfilerSectionTexts('All', average, outputs);\n this._profilerText.text = outputs.join('\\n');\n }\n\n hideCursor(): void {\n this._showCursorAtNextRender = false;\n\n const canvas = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getCanvas()\n : null;\n if (canvas) canvas.style.cursor = 'none';\n }\n\n showCursor(): void {\n this._showCursorAtNextRender = true;\n }\n\n getPIXIContainer() {\n return this._pixiContainer;\n }\n\n getRendererObject() {\n return this._pixiContainer;\n }\n\n get3DRendererObject() {\n // There is no notion of a container for all 3D objects. Each 3D object is\n // added to their layer container.\n return null;\n }\n\n /** @deprecated use `runtimeGame.getRenderer().getPIXIRenderer()` instead */\n getPIXIRenderer() {\n return this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getPIXIRenderer()\n : null;\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();\n let layerPixiObject: PIXI.Container | PIXI.Sprite | null =\n layerPixiRenderer.getRendererObject();\n if (layer.isLightingLayer()) {\n // TODO (2d lights): refactor to remove the need for `getLightingSprite`.\n layerPixiObject = layerPixiRenderer.getLightingSprite();\n }\n if (!layerPixiObject) {\n return;\n }\n if (this._pixiContainer.children.indexOf(layerPixiObject) === index) {\n return;\n }\n this._pixiContainer.removeChild(layerPixiObject);\n this._pixiContainer.addChildAt(layerPixiObject, index);\n }\n }\n\n // Register the class to let the engine use it.\n export type RuntimeSceneRenderer = gdjs.RuntimeScenePixiRenderer;\n export const RuntimeSceneRenderer = gdjs.RuntimeScenePixiRenderer;\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAIS,OAEP,CAeE,YACE,EACA,EACA,CAdM,mBAAkC,KAClC,6BAAmC,GACnC,oBAA6C,KAC7C,4BAGJ,CACF,sBAAuB,EACvB,sBAAuB,GAOvB,KAAK,qBAAuB,EAC5B,KAAK,cAAgB,EACrB,KAAK,eAAiB,GAAI,MAAK,UAG/B,KAAK,eAAe,iBAAmB,GAEvC,KAAK,eAAiB,KAAK,qBACvB,KAAK,qBAAqB,mBAC1B,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eAAe,SAAS,QAAQ,KAAqB,GAG9D,MAAK,eAAe,YAAY,GAChC,KAAK,eAAe,WAAW,EAAiB,KA7a7C,EAAM,2BAmbA,uBAAuB,EAAK,2BAvbjC",
4
+ "sourcesContent": ["namespace gdjs {\n /**\n * The renderer for a gdjs.RuntimeScene using Pixi.js.\n */\n export class RuntimeScenePixiRenderer\n implements gdjs.RuntimeInstanceContainerPixiRenderer\n {\n private _runtimeGameRenderer: gdjs.RuntimeGamePixiRenderer | null;\n private _runtimeScene: gdjs.RuntimeScene;\n private _pixiContainer: PIXI.Container;\n private _profilerText: PIXI.Text | null = null;\n private _showCursorAtNextRender: boolean = false;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _layerRenderingMetrics: {\n rendered2DLayersCount: number;\n rendered3DLayersCount: number;\n } = {\n rendered2DLayersCount: 0,\n rendered3DLayersCount: 0,\n };\n private _backgroundColor: THREE.Color | null = null;\n\n constructor(\n runtimeScene: gdjs.RuntimeScene,\n runtimeGameRenderer: gdjs.RuntimeGamePixiRenderer | null\n ) {\n this._runtimeGameRenderer = runtimeGameRenderer;\n this._runtimeScene = runtimeScene;\n this._pixiContainer = new PIXI.Container();\n\n // Contains the layers of the scene (and, optionally, debug PIXI objects).\n this._pixiContainer.sortableChildren = true;\n\n this._threeRenderer = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getThreeRenderer()\n : null;\n }\n\n onGameResolutionResized() {\n const pixiRenderer = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getPIXIRenderer()\n : null;\n if (!pixiRenderer) {\n return;\n }\n const runtimeGame = this._runtimeScene.getGame();\n\n // TODO (3D): should this be done for each individual layer?\n // Especially if we remove _pixiContainer entirely.\n this._pixiContainer.scale.x =\n pixiRenderer.width / runtimeGame.getGameResolutionWidth();\n this._pixiContainer.scale.y =\n pixiRenderer.height / runtimeGame.getGameResolutionHeight();\n\n for (const runtimeLayer of this._runtimeScene._orderedLayers) {\n runtimeLayer.getRenderer().onGameResolutionResized();\n }\n }\n\n onSceneUnloaded() {\n // TODO (3D): call the method with the same name on RuntimeLayers so they can dispose?\n }\n\n render() {\n const runtimeGameRenderer = this._runtimeGameRenderer;\n if (!runtimeGameRenderer) return;\n\n const pixiRenderer = runtimeGameRenderer.getPIXIRenderer();\n if (!pixiRenderer) return;\n\n const threeRenderer = this._threeRenderer;\n\n // If we are in VR, we cannot render like this: we must use the special VR\n // rendering method to not display a black screen.\n //\n // We cannot call it here either - the headset will request a frame to be rendered\n // whenever it wants and we must oblige, however this will be called whenever\n // we do a step - and we may step multiple times or none at all depending on the\n // min/max FPS and possibly other factors, and the headset will not allow that.\n //\n // It is therefore left to the VR extension to call the VR rendering method whenever\n // the headset require a new image, we'll just disable rendering when stepping to\n // not interfere with the headset's rendering.\n if (threeRenderer && threeRenderer.xr.isPresenting) return;\n\n this._layerRenderingMetrics.rendered2DLayersCount = 0;\n this._layerRenderingMetrics.rendered3DLayersCount = 0;\n\n if (threeRenderer) {\n // Layered 2D, 3D or 2D+3D rendering.\n threeRenderer.info.autoReset = false;\n threeRenderer.info.reset();\n\n /** Useful to render the background color. */\n let isFirstRender = true;\n\n /**\n * true if the last layer rendered 3D objects using Three.js, false otherwise.\n * Useful to avoid needlessly resetting the WebGL states between layers (which can be expensive).\n */\n let lastRenderWas3D = true;\n\n // Even if no rendering at all has been made already, setting up the Three.js/PixiJS renderers\n // might have changed some WebGL states already. Reset the state for the very first frame.\n // And, out of caution, keep doing it for every frame.\n // TODO (3D): optimization - check if this can be done only on the very first frame.\n threeRenderer.resetState();\n\n // Render each layer one by one.\n for (let i = 0; i < this._runtimeScene._orderedLayers.length; ++i) {\n const runtimeLayer = this._runtimeScene._orderedLayers[i];\n if (!runtimeLayer.isVisible()) continue;\n\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n const runtimeLayerRenderingType = runtimeLayer.getRenderingType();\n const layerHas3DObjectsToRender = runtimeLayerRenderer.has3DObjects();\n if (\n runtimeLayerRenderingType ===\n gdjs.RuntimeLayerRenderingType.TWO_D ||\n !layerHas3DObjectsToRender\n ) {\n // Render a layer with 2D rendering (PixiJS) only if layer is configured as is\n // or if there is no 3D object to render.\n\n if (lastRenderWas3D) {\n // Ensure the state is clean for PixiJS to render.\n threeRenderer.resetState();\n pixiRenderer.reset();\n }\n\n if (isFirstRender) {\n // Render the background color.\n pixiRenderer.background.color =\n this._runtimeScene.getBackgroundColor();\n pixiRenderer.background.alpha = 1;\n if (this._runtimeScene.getClearCanvas()) pixiRenderer.clear();\n\n isFirstRender = false;\n }\n\n if (runtimeLayer.isLightingLayer()) {\n // Render the lights on the render texture used then by the lighting Sprite.\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n }\n\n // TODO (2d lights): refactor to remove the need for `getLightingSprite`.\n const pixiContainer =\n (runtimeLayer.isLightingLayer() &&\n runtimeLayerRenderer.getLightingSprite()) ||\n runtimeLayerRenderer.getRendererObject();\n\n pixiRenderer.render(pixiContainer, { clear: false });\n this._layerRenderingMetrics.rendered2DLayersCount++;\n\n lastRenderWas3D = false;\n } else {\n // Render a layer with 3D rendering, and possibly some 2D rendering too.\n const threeScene = runtimeLayerRenderer.getThreeScene();\n const threeCamera = runtimeLayerRenderer.getThreeCamera();\n const threeEffectComposer =\n runtimeLayerRenderer.getThreeEffectComposer();\n\n // Render the 3D objects of this layer.\n if (threeScene && threeCamera && threeEffectComposer) {\n // TODO (3D) - optimization: do this at the beginning for all layers that are 2d+3d?\n // So the second pass is clearer (just rendering 2d or 3d layers without doing PixiJS renders in between).\n if (\n runtimeLayerRenderingType ===\n gdjs.RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D\n ) {\n const layerHas2DObjectsToRender =\n runtimeLayerRenderer.has2DObjects();\n\n if (layerHas2DObjectsToRender) {\n if (lastRenderWas3D) {\n // Ensure the state is clean for PixiJS to render.\n threeRenderer.resetState();\n pixiRenderer.reset();\n }\n\n // Do the rendering of the PixiJS objects of the layer on the render texture.\n // Then, update the texture of the plane showing the PixiJS rendering,\n // so that the 2D rendering made by PixiJS can be shown in the 3D world.\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n runtimeLayerRenderer.updateThreePlaneTextureFromPixiRenderTexture(\n // The renderers are needed to find the internal WebGL texture.\n threeRenderer,\n pixiRenderer\n );\n this._layerRenderingMetrics.rendered2DLayersCount++;\n\n lastRenderWas3D = false;\n }\n runtimeLayerRenderer.show2DRenderingPlane(\n layerHas2DObjectsToRender\n );\n }\n\n if (!lastRenderWas3D) {\n // It's important to reset the internal WebGL state of PixiJS, then Three.js\n // to ensure the 3D rendering is made properly by Three.js\n pixiRenderer.reset();\n threeRenderer.resetState();\n }\n\n if (isFirstRender) {\n // Render the background color.\n threeRenderer.setClearColor(\n this._runtimeScene.getBackgroundColor()\n );\n threeRenderer.resetState();\n if (this._runtimeScene.getClearCanvas()) threeRenderer.clear();\n if (!this._backgroundColor) {\n this._backgroundColor = new THREE.Color();\n }\n this._backgroundColor.set(\n this._runtimeScene.getBackgroundColor()\n );\n if (!threeScene.background) {\n threeScene.background = this._backgroundColor;\n }\n\n isFirstRender = false;\n } else {\n // It's important to set the background to null, as maybe the first rendered\n // layer has changed and so the Three.js scene background must be reset.\n if (threeScene.background === this._backgroundColor) {\n threeScene.background = null;\n }\n }\n\n // Clear the depth as each layer is independent and display on top of the previous one,\n // even 3D objects.\n threeRenderer.clearDepth();\n if (runtimeLayerRenderer.hasPostProcessingPass()) {\n threeEffectComposer.render();\n } else {\n threeRenderer.render(threeScene, threeCamera);\n }\n\n this._layerRenderingMetrics.rendered3DLayersCount++;\n\n lastRenderWas3D = true;\n }\n }\n }\n\n const debugContainer = this._runtimeScene\n .getDebuggerRenderer()\n .getRendererObject();\n\n if (debugContainer) {\n threeRenderer.resetState();\n pixiRenderer.reset();\n pixiRenderer.render(debugContainer);\n lastRenderWas3D = false;\n }\n\n if (!lastRenderWas3D) {\n // Out of caution, reset the WebGL states from PixiJS to start again\n // with a 3D rendering on the next frame.\n pixiRenderer.reset();\n }\n\n // Uncomment to display some debug metrics from Three.js.\n // console.log(threeRenderer.info);\n } else {\n // 2D only rendering.\n\n // Render lights in render textures first.\n for (const runtimeLayer of this._runtimeScene._orderedLayers) {\n if (runtimeLayer.isLightingLayer()) {\n // Render the lights on the render texture used then by the lighting Sprite.\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n runtimeLayerRenderer.renderOnPixiRenderTexture(pixiRenderer);\n }\n }\n\n // this._renderProfileText(); //Uncomment to display profiling times\n\n // Render all the layers then.\n // TODO: replace by a loop like in 3D?\n pixiRenderer.background.color = this._runtimeScene.getBackgroundColor();\n pixiRenderer.render(this._pixiContainer, {\n clear: this._runtimeScene.getClearCanvas(),\n });\n this._layerRenderingMetrics.rendered2DLayersCount++;\n }\n\n // synchronize showing the cursor with rendering (useful to reduce\n // blinking while switching from in-game cursor)\n if (this._showCursorAtNextRender) {\n const canvas = runtimeGameRenderer.getCanvas();\n if (canvas) canvas.style.cursor = '';\n this._showCursorAtNextRender = false;\n }\n\n // Uncomment to check the number of 2D&3D rendering done\n // console.log(this._layerRenderingMetrics);\n }\n\n /**\n * Unless you know what you are doing, use the VR extension instead of this function directly.\n *\n * In VR, only 3D elements can be rendered, 2D cannot.\n * This rendering method skips over all 2D layers and elements, and simply renders the 3D content.\n * This method is to be called by the XRSession's `requestAnimationFrame` for rendering to\n * the headset whenever the headset requests the screen to be drawn. Note that while an XRSession\n * is in progress, the regular `requestAnimationFrame` will be disabled. Make sure that whenever you\n * enter an XRSession, you:\n * - Call this function first and foremost when the XRSession's requestAnimationFrame fires,\n * as it is necessary to draw asap as the headset will eventually stop waiting and just draw the\n * framebuffer as it is to maintain a constant screen refresh rate, which can be in the middle of\n * or even before rendering if we aren't fast enough, leading to screen flashes and bugs.\n * - Call GDevelop's step function to give the scene a chance to step after having drawn to the screen\n * to allow the game to actually progress, since GDevelop will no longer step by itself with\n * `requestAnimationFrame` disabled.\n *\n * Note to engine developers: `threeRenderer.resetState()` may NOT be called in this function,\n * as WebXR modifies the WebGL state in a way that resetting it will cause an improper render\n * that will lead to a black screen being displayed in VR mode.\n */\n renderForVR() {\n const runtimeGameRenderer = this._runtimeGameRenderer;\n if (!runtimeGameRenderer) return;\n\n const threeRenderer = this._threeRenderer;\n // VR rendering relies on ThreeJS\n if (!threeRenderer)\n throw new Error('Cannot render a scene with no 3D elements in VR!');\n\n // Render each layer one by one.\n let isFirstRender = true;\n for (let i = 0; i < this._runtimeScene._orderedLayers.length; ++i) {\n const runtimeLayer = this._runtimeScene._orderedLayers[i];\n if (!runtimeLayer.isVisible()) continue;\n\n const runtimeLayerRenderer = runtimeLayer.getRenderer();\n const runtimeLayerRenderingType = runtimeLayer.getRenderingType();\n if (\n runtimeLayerRenderingType === gdjs.RuntimeLayerRenderingType.TWO_D ||\n !runtimeLayerRenderer.has3DObjects()\n )\n continue;\n\n // Render a layer with 3D rendering, and no 2D rendering at all for VR.\n const threeScene = runtimeLayerRenderer.getThreeScene();\n const threeCamera = runtimeLayerRenderer.getThreeCamera();\n if (!threeScene || !threeCamera) continue;\n\n if (isFirstRender) {\n // Render the background color.\n threeRenderer.setClearColor(this._runtimeScene.getBackgroundColor());\n if (this._runtimeScene.getClearCanvas()) threeRenderer.clear();\n threeScene.background = new THREE.Color(\n this._runtimeScene.getBackgroundColor()\n );\n\n isFirstRender = false;\n } else {\n // It's important to set the background to null, as maybe the first rendered\n // layer has changed and so the Three.js scene background must be reset.\n threeScene.background = null;\n }\n\n // Clear the depth as each layer is independent and display on top of the previous one,\n // even 3D objects.\n threeRenderer.clearDepth();\n threeRenderer.render(threeScene, threeCamera);\n }\n }\n\n _renderProfileText() {\n const profiler = this._runtimeScene.getProfiler();\n if (!profiler) {\n return;\n }\n if (!this._profilerText) {\n this._profilerText = new PIXI.Text(' ', {\n align: 'left',\n stroke: '#FFF',\n strokeThickness: 1,\n });\n\n // Add on top of all layers:\n this._pixiContainer.addChild(this._profilerText);\n }\n const average = profiler.getFramesAverageMeasures();\n const outputs = [];\n gdjs.Profiler.getProfilerSectionTexts('All', average, outputs);\n this._profilerText.text = outputs.join('\\n');\n }\n\n hideCursor(): void {\n this._showCursorAtNextRender = false;\n\n const canvas = this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getCanvas()\n : null;\n if (canvas) canvas.style.cursor = 'none';\n }\n\n showCursor(): void {\n this._showCursorAtNextRender = true;\n }\n\n getPIXIContainer() {\n return this._pixiContainer;\n }\n\n getRendererObject() {\n return this._pixiContainer;\n }\n\n get3DRendererObject() {\n // There is no notion of a container for all 3D objects. Each 3D object is\n // added to their layer container.\n return null;\n }\n\n /** @deprecated use `runtimeGame.getRenderer().getPIXIRenderer()` instead */\n getPIXIRenderer() {\n return this._runtimeGameRenderer\n ? this._runtimeGameRenderer.getPIXIRenderer()\n : null;\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();\n let layerPixiObject: PIXI.Container | PIXI.Sprite | null =\n layerPixiRenderer.getRendererObject();\n if (layer.isLightingLayer()) {\n // TODO (2d lights): refactor to remove the need for `getLightingSprite`.\n layerPixiObject = layerPixiRenderer.getLightingSprite();\n }\n if (!layerPixiObject) {\n return;\n }\n if (this._pixiContainer.children.indexOf(layerPixiObject) === index) {\n return;\n }\n this._pixiContainer.removeChild(layerPixiObject);\n this._pixiContainer.addChildAt(layerPixiObject, index);\n }\n }\n\n // Register the class to let the engine use it.\n export type RuntimeSceneRenderer = gdjs.RuntimeScenePixiRenderer;\n export const RuntimeSceneRenderer = gdjs.RuntimeScenePixiRenderer;\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAIS,OAEP,CAgBE,YACE,EACA,EACA,CAfM,mBAAkC,KAClC,6BAAmC,GACnC,oBAA6C,KAC7C,4BAGJ,CACF,sBAAuB,EACvB,sBAAuB,GAEjB,sBAAuC,KAM7C,KAAK,qBAAuB,EAC5B,KAAK,cAAgB,EACrB,KAAK,eAAiB,G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kB,CAChB,MAAO,MAAK,qBACR,KAAK,qBAAqB,kBAC1B,KAGN,cAAc,EAA0B,EAAoB,CAC1D,KAAM,GAA4C,EAAM,cACxD,GAAI,GACF,EAAkB,oBAKpB,AAJI,EAAM,mBAER,GAAkB,EAAkB,qBAElC,EAAC,GAGD,KAAK,eAAe,SAAS,QAAQ,KAAqB,GAG9D,MAAK,eAAe,YAAY,GAChC,KAAK,eAAe,WAAW,EAAiB,KAtb7C,EAAM,2BA4bA,uBAAuB,EAAK,2BAhcjC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){class n{constructor(e){this.minX=0;this.minY=0;this.maxX=0;this.maxY=0;this.behavior=e,this.updateAABBFromOwner()}updateAABBFromOwner(){this.minX=this.behavior.owner.getAABB().min[0],this.minY=this.behavior.owner.getAABB().min[1],this.maxX=this.behavior.owner.getAABB().max[0],this.maxY=this.behavior.owner.getAABB().max[1]}}i.BehaviorRBushAABB=n;class o{constructor(e,t,r){this.owner=r;this._activated=!0;this._syncOverNetwork=!0;this.name=t.name||"",this.type=t.type||"",this._nameId=i.RuntimeObject.getNameIdentifier(this.name)}updateFromBehaviorData(e,t){return!1}getNetworkSyncData(){return{act:this._activated,props:{}}}updateFromNetworkSyncData(e){e.act!==this._activated&&this.activate(e.act)}getName(){return this.name}getNameId(){return this._nameId}stepPreEvents(e){if(this._activated){const t=e.getScene().getProfiler();t&&t.begin(this.name),this.doStepPreEvents(e),t&&t.end(this.name)}}stepPostEvents(e){if(this._activated){const t=e.getScene().getProfiler();t&&t.begin(this.name),this.doStepPostEvents(e),t&&t.end(this.name)}}activate(e){e===void 0&&(e=!0),!this._activated&&e?(this._activated=!0,this.onActivate()):this._activated&&!e&&(this._activated=!1,this.onDeActivate())}onCreated(){}activated(){return this._activated}onActivate(){}onDeActivate(){}doStepPreEvents(e){}doStepPostEvents(e){}onDestroy(){}onObjectHotReloaded(){}usesLifecycleFunction(){return!0}enableSynchronization(e){this._syncOverNetwork=e}isSyncedOverNetwork(){return this._syncOverNetwork}}i.RuntimeBehavior=o,i.registerBehavior("",i.RuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(i){class n{constructor(t){this.minX=0;this.minY=0;this.maxX=0;this.maxY=0;this.behavior=t,this.updateAABBFromOwner()}updateAABBFromOwner(){this.minX=this.behavior.owner.getAABB().min[0],this.minY=this.behavior.owner.getAABB().min[1],this.maxX=this.behavior.owner.getAABB().max[0],this.maxY=this.behavior.owner.getAABB().max[1]}}i.BehaviorRBushAABB=n;class o{constructor(t,e,r){this.owner=r;this._activated=!0;this._syncOverNetwork=!0;this.name=e.name||"",this.type=e.type||"",this._nameId=i.RuntimeObject.getNameIdentifier(this.name)}updateFromBehaviorData(t,e){return!1}getNetworkSyncData(t){return{act:this._activated,props:{}}}updateFromNetworkSyncData(t,e){t.act!==this._activated&&this.activate(t.act)}getName(){return this.name}getNameId(){return this._nameId}stepPreEvents(t){if(this._activated){const e=t.getScene().getProfiler();e&&e.begin(this.name),this.doStepPreEvents(t),e&&e.end(this.name)}}stepPostEvents(t){if(this._activated){const e=t.getScene().getProfiler();e&&e.begin(this.name),this.doStepPostEvents(t),e&&e.end(this.name)}}activate(t){t===void 0&&(t=!0),!this._activated&&t?(this._activated=!0,this.onActivate()):this._activated&&!t&&(this._activated=!1,this.onDeActivate())}onCreated(){}activated(){return this._activated}onActivate(){}onDeActivate(){}doStepPreEvents(t){}doStepPostEvents(t){}onDestroy(){}onObjectHotReloaded(){}usesLifecycleFunction(){return!0}enableSynchronization(t){this._syncOverNetwork=t}isSyncedOverNetwork(){return this._syncOverNetwork}}i.RuntimeBehavior=o,i.registerBehavior("",i.RuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimebehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/runtimebehavior.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Allow to store a behavior in a RBush (spatial data structure).\n * Because this duplicates the AABB, this ensures the RBush AABB\n * stays the same even if the underlying object is moved\n * (in which case the behavior is responsible for removing/adding\n * back/updating this BehaviorRBushAABB).\n */\n export class BehaviorRBushAABB<T extends RuntimeBehavior> {\n minX: float = 0;\n minY: float = 0;\n maxX: float = 0;\n maxY: float = 0;\n behavior: T;\n\n constructor(behavior: T) {\n this.behavior = behavior;\n this.updateAABBFromOwner();\n }\n\n updateAABBFromOwner() {\n this.minX = this.behavior.owner.getAABB().min[0];\n this.minY = this.behavior.owner.getAABB().min[1];\n this.maxX = this.behavior.owner.getAABB().max[0];\n this.maxY = this.behavior.owner.getAABB().max[1];\n }\n }\n\n /**\n * RuntimeBehavior represents a behavior being used by a RuntimeObject.\n */\n export class RuntimeBehavior {\n name: string;\n type: string;\n _nameId: integer;\n _activated: boolean = true;\n\n // When synchronised over the network, a behavior is always owned by the player owning the object,\n // and always synced. If set to false, the behavior properties will not be synced to others.\n _syncOverNetwork: boolean = true;\n\n /**\n * @param instanceContainer The container owning the object of the behavior\n * @param behaviorData The properties used to setup the behavior\n * @param owner The object owning the behavior\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData: BehaviorData,\n public owner: gdjs.RuntimeObject\n ) {\n this.name = behaviorData.name || '';\n this.type = behaviorData.type || '';\n this._nameId = gdjs.RuntimeObject.getNameIdentifier(this.name);\n }\n\n /**\n * Called when the behavior must be updated using the specified behaviorData. This is the\n * case during hot-reload, and is only called if the behavior was modified.\n *\n * @see gdjs.RuntimeBehavior#onObjectHotReloaded\n *\n * @param oldBehaviorData The previous data for the behavior.\n * @param newBehaviorData The new data for the behavior.\n * @returns true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).\n */\n updateFromBehaviorData(\n oldBehaviorData: BehaviorData,\n newBehaviorData: BehaviorData\n ): boolean {\n // If not redefined, mark by default the hot-reload as failed.\n return false;\n }\n\n getNetworkSyncData(): BehaviorNetworkSyncData {\n // To be redefined by behaviors that need to synchronize properties\n // while calling super() to get the common properties.\n return {\n act: this._activated,\n props: {},\n };\n }\n\n /**\n * Update the behavior properties using the provided data.\n * @param networkSyncData The new properties of the behavior.\n */\n updateFromNetworkSyncData(networkSyncData: BehaviorNetworkSyncData): void {\n // Must be redefined by behaviors that need to synchronize properties\n // while calling super() to get the common properties.\n if (networkSyncData.act !== this._activated) {\n this.activate(networkSyncData.act);\n }\n }\n\n /**\n * Get the name of the behavior.\n * @return The behavior's name.\n */\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the name identifier of the behavior.\n * @return The behavior's name identifier.\n */\n getNameId(): integer {\n return this._nameId;\n }\n\n /**\n * Called at each frame before events. Call doStepPreEvents.<br>\n * Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.\n * @param instanceContainer The instanceContainer owning the object\n */\n stepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._activated) {\n const profiler = instanceContainer.getScene().getProfiler();\n if (profiler) {\n profiler.begin(this.name);\n }\n this.doStepPreEvents(instanceContainer);\n if (profiler) {\n profiler.end(this.name);\n }\n }\n }\n\n /**\n * Called at each frame after events. Call doStepPostEvents.<br>\n * Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.\n * @param instanceContainer The instanceContainer owning the object\n */\n stepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._activated) {\n const profiler = instanceContainer.getScene().getProfiler();\n if (profiler) {\n profiler.begin(this.name);\n }\n this.doStepPostEvents(instanceContainer);\n if (profiler) {\n profiler.end(this.name);\n }\n }\n }\n\n /**\n * De/Activate the behavior\n * @param enable true to enable the behavior, false to disable it\n */\n activate(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n if (!this._activated && enable) {\n this._activated = true;\n this.onActivate();\n } else {\n if (this._activated && !enable) {\n this._activated = false;\n this.onDeActivate();\n }\n }\n }\n\n /**\n * Reimplement this to do extra work when the behavior is created (i.e: an\n * object using it was created), after the object is fully initialized (so\n * you can use `this.owner` without risk).\n */\n onCreated(): void {}\n\n /**\n * Return true if the behavior is activated\n */\n activated(): boolean {\n return this._activated;\n }\n\n /**\n * Reimplement this method to do extra work when the behavior is activated (after\n * it has been deactivated, see `onDeActivate`).\n */\n onActivate(): void {}\n\n /**\n * Reimplement this method to do extra work when the behavior is deactivated.\n */\n onDeActivate(): void {}\n\n /**\n * This method is called each tick before events are done.\n * @param instanceContainer The instanceContainer owning the object\n */\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {}\n\n /**\n * This method is called each tick after events are done.\n * @param instanceContainer The instanceContainer owning the object\n */\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {}\n\n /**\n * This method is called when the owner of the behavior\n * is being removed from the scene and is about to be destroyed/reused later\n * or when the behavior is removed from an object (can happen in case of\n * hot-reloading only. Otherwise, behaviors are just de-activated,\n * not removed. See `onDeActivate`).\n */\n onDestroy(): void {}\n\n /**\n * This method is called when the owner of the behavior\n * was hot reloaded, so its position, angle, size can have been changed outside\n * of events.\n */\n onObjectHotReloaded(): void {}\n\n /**\n * Should return `false` if the behavior does not need any lifecycle function to\n * be called.\n * Default, hidden, \"capability\" behaviors set it to `false`.\n * This avoids useless calls to empty lifecycle functions, which would waste CPU\n * time (and have a sizeable impact for example when lots of static instances\n * are living in the scene).\n * @returns\n */\n usesLifecycleFunction(): boolean {\n return true;\n }\n\n enableSynchronization(enable: boolean) {\n this._syncOverNetwork = enable;\n }\n\n isSyncedOverNetwork(): boolean {\n return this._syncOverNetwork;\n }\n }\n gdjs.registerBehavior('', gdjs.RuntimeBehavior);\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAQS,OAAmD,CAOxD,YAAY,EAAa,CANzB,UAAc,EACd,UAAc,EACd,UAAc,EACd,UAAc,EAIZ,KAAK,S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AAgB,EAAwD,EAMxE,iBAAiB,EAAwD,EASzE,WAAkB,EAOlB,qBAA4B,EAW5B,uBAAiC,CAC/B,MAAO,GAGT,sBAAsB,EAAiB,CACrC,KAAK,iBAAmB,EAG1B,qBAA+B,CAC7B,MAAO,MAAK,kBA9MT,EAAM,kBAiNb,EAAK,iBAAiB,GAAI,EAAK,mBAhPvB",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Allow to store a behavior in a RBush (spatial data structure).\n * Because this duplicates the AABB, this ensures the RBush AABB\n * stays the same even if the underlying object is moved\n * (in which case the behavior is responsible for removing/adding\n * back/updating this BehaviorRBushAABB).\n */\n export class BehaviorRBushAABB<T extends RuntimeBehavior> {\n minX: float = 0;\n minY: float = 0;\n maxX: float = 0;\n maxY: float = 0;\n behavior: T;\n\n constructor(behavior: T) {\n this.behavior = behavior;\n this.updateAABBFromOwner();\n }\n\n updateAABBFromOwner() {\n this.minX = this.behavior.owner.getAABB().min[0];\n this.minY = this.behavior.owner.getAABB().min[1];\n this.maxX = this.behavior.owner.getAABB().max[0];\n this.maxY = this.behavior.owner.getAABB().max[1];\n }\n }\n\n /**\n * RuntimeBehavior represents a behavior being used by a RuntimeObject.\n */\n export class RuntimeBehavior {\n name: string;\n type: string;\n _nameId: integer;\n _activated: boolean = true;\n\n // When synchronised over the network, a behavior is always owned by the player owning the object,\n // and always synced. If set to false, the behavior properties will not be synced to others.\n _syncOverNetwork: boolean = true;\n\n /**\n * @param instanceContainer The container owning the object of the behavior\n * @param behaviorData The properties used to setup the behavior\n * @param owner The object owning the behavior\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData: BehaviorData,\n public owner: gdjs.RuntimeObject\n ) {\n this.name = behaviorData.name || '';\n this.type = behaviorData.type || '';\n this._nameId = gdjs.RuntimeObject.getNameIdentifier(this.name);\n }\n\n /**\n * Called when the behavior must be updated using the specified behaviorData. This is the\n * case during hot-reload, and is only called if the behavior was modified.\n *\n * @see gdjs.RuntimeBehavior#onObjectHotReloaded\n *\n * @param oldBehaviorData The previous data for the behavior.\n * @param newBehaviorData The new data for the behavior.\n * @returns true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).\n */\n updateFromBehaviorData(\n oldBehaviorData: BehaviorData,\n newBehaviorData: BehaviorData\n ): boolean {\n // If not redefined, mark by default the hot-reload as failed.\n return false;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): BehaviorNetworkSyncData {\n // To be redefined by behaviors that need to synchronize properties\n // while calling super() to get the common properties.\n return {\n act: this._activated,\n props: {},\n };\n }\n\n /**\n * Update the behavior properties using the provided data.\n * @param networkSyncData The new properties of the behavior.\n */\n updateFromNetworkSyncData(\n networkSyncData: BehaviorNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ): void {\n // Must be redefined by behaviors that need to synchronize properties\n // while calling super() to get the common properties.\n if (networkSyncData.act !== this._activated) {\n this.activate(networkSyncData.act);\n }\n }\n\n /**\n * Get the name of the behavior.\n * @return The behavior's name.\n */\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the name identifier of the behavior.\n * @return The behavior's name identifier.\n */\n getNameId(): integer {\n return this._nameId;\n }\n\n /**\n * Called at each frame before events. Call doStepPreEvents.<br>\n * Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.\n * @param instanceContainer The instanceContainer owning the object\n */\n stepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._activated) {\n const profiler = instanceContainer.getScene().getProfiler();\n if (profiler) {\n profiler.begin(this.name);\n }\n this.doStepPreEvents(instanceContainer);\n if (profiler) {\n profiler.end(this.name);\n }\n }\n }\n\n /**\n * Called at each frame after events. Call doStepPostEvents.<br>\n * Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.\n * @param instanceContainer The instanceContainer owning the object\n */\n stepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._activated) {\n const profiler = instanceContainer.getScene().getProfiler();\n if (profiler) {\n profiler.begin(this.name);\n }\n this.doStepPostEvents(instanceContainer);\n if (profiler) {\n profiler.end(this.name);\n }\n }\n }\n\n /**\n * De/Activate the behavior\n * @param enable true to enable the behavior, false to disable it\n */\n activate(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n if (!this._activated && enable) {\n this._activated = true;\n this.onActivate();\n } else {\n if (this._activated && !enable) {\n this._activated = false;\n this.onDeActivate();\n }\n }\n }\n\n /**\n * Reimplement this to do extra work when the behavior is created (i.e: an\n * object using it was created), after the object is fully initialized (so\n * you can use `this.owner` without risk).\n */\n onCreated(): void {}\n\n /**\n * Return true if the behavior is activated\n */\n activated(): boolean {\n return this._activated;\n }\n\n /**\n * Reimplement this method to do extra work when the behavior is activated (after\n * it has been deactivated, see `onDeActivate`).\n */\n onActivate(): void {}\n\n /**\n * Reimplement this method to do extra work when the behavior is deactivated.\n */\n onDeActivate(): void {}\n\n /**\n * This method is called each tick before events are done.\n * @param instanceContainer The instanceContainer owning the object\n */\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {}\n\n /**\n * This method is called each tick after events are done.\n * @param instanceContainer The instanceContainer owning the object\n */\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer): void {}\n\n /**\n * This method is called when the owner of the behavior\n * is being removed from the scene and is about to be destroyed/reused later\n * or when the behavior is removed from an object (can happen in case of\n * hot-reloading only. Otherwise, behaviors are just de-activated,\n * not removed. See `onDeActivate`).\n */\n onDestroy(): void {}\n\n /**\n * This method is called when the owner of the behavior\n * was hot reloaded, so its position, angle, size can have been changed outside\n * of events.\n */\n onObjectHotReloaded(): void {}\n\n /**\n * Should return `false` if the behavior does not need any lifecycle function to\n * be called.\n * Default, hidden, \"capability\" behaviors set it to `false`.\n * This avoids useless calls to empty lifecycle functions, which would waste CPU\n * time (and have a sizeable impact for example when lots of static instances\n * are living in the scene).\n * @returns\n */\n usesLifecycleFunction(): boolean {\n return true;\n }\n\n enableSynchronization(enable: boolean) {\n this._syncOverNetwork = enable;\n }\n\n isSyncedOverNetwork(): boolean {\n return this._syncOverNetwork;\n }\n }\n gdjs.registerBehavior('', gdjs.RuntimeBehavior);\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAQS,OAAmD,CAOxD,YAAY,EAAa,CANzB,UAAc,EACd,UAAc,EACd,UAAc,EACd,UAAc,EAIZ,KAAK,SAAW,EAChB,KAAK,sBAGP,qBAAsB,CACpB,KAAK,KAAO,KAAK,SAAS,MAAM,UAAU,IAAI,GAC9C,KAAK,KAAO,KAAK,SAAS,MAAM,UAAU,IAAI,GAC9C,KAAK,KAAO,KAAK,SAAS,MAAM,UAAU,IAAI,GAC9C,KAAK,KAAO,KAAK,SAAS,MAAM,UAAU,IAAI,IAhB3C,EAAM,oBAuBN,OAAsB,CAe3B,YACE,EACA,EACO,EACP,CADO,aAdT,gBAAsB,GAItB,sBAA4B,GAY1B,KAAK,KAAO,EAAa,MAAQ,GACjC,KAAK,KAAO,EAAa,MAAQ,GACjC,KAAK,QAAU,EAAK,cAAc,kBAAkB,KAAK,MAa3D,uBACE,EACA,EACS,CAET,MAAO,GAGT,mBACE,EACyB,CAGzB,MAAO,CACL,IAAK,KAAK,WACV,MAAO,IAQX,0BACE,EACA,EACM,CAGN,AAAI,EAAgB,MAAQ,KAAK,YAC/B,KAAK,SAAS,EAAgB,KAQlC,SAAkB,CAChB,MAAO,MAAK,KAOd,WAAqB,CACnB,MAAO,MAAK,QAQd,cAAc,EAAwD,CACpE,GAAI,KAAK,WAAY,CACnB,KAAM,GAAW,EAAkB,WAAW,cAC9C,AAAI,GACF,EAAS,MAAM,KAAK,MAEtB,KAAK,gBAAgB,GACjB,GACF,EAAS,IAAI,KAAK,OAUxB,eAAe,EAAwD,CACrE,GAAI,KAAK,WAAY,CACnB,KAAM,GAAW,EAAkB,WAAW,cAC9C,AAAI,GACF,EAAS,MAAM,KAAK,MAEtB,KAAK,iBAAiB,GAClB,GACF,EAAS,IAAI,KAAK,OASxB,SAAS,EAAuB,CAC9B,AAAI,IAAW,QACb,GAAS,IAEX,AAAI,CAAC,KAAK,YAAc,EACtB,MAAK,WAAa,GAClB,KAAK,cAED,KAAK,YAAc,CAAC,GACtB,MAAK,WAAa,GAClB,KAAK,gBAUX,WAAkB,EAKlB,WAAqB,CACnB,MAAO,MAAK,WAOd,YAAmB,EAKnB,cAAqB,EAMrB,gBAAgB,EAAwD,EAMxE,iBAAiB,EAAwD,EASzE,WAAkB,EAOlB,qBAA4B,EAW5B,uBAAiC,CAC/B,MAAO,GAGT,sBAAsB,EAAiB,CACrC,KAAK,iBAAmB,EAG1B,qBAA+B,CAC7B,MAAO,MAAK,kBAnNT,EAAM,kBAsNb,EAAK,iBAAiB,GAAI,EAAK,mBArPvB",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(n){const g=new n.Logger("Game manager"),c=u=>new Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new n.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._sceneResourcesPreloading=this._data.properties.sceneResourcesPreloading||"at-startup",this._sceneResourcesUnloading=this._data.properties.sceneResourcesUnloading||"never",this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const i=JSON.parse(s.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getResourceLoader(){return this._resourcesLoader}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t<s;++t){const i=this._sceneAndExtensionsData[t];if(e===void 0||i.sceneData.name===e)return i}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let t=0,s=this._data.layouts.length;t<s;++t){const i=this._data.layouts[t];if(e===void 0||i.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,i=this._data.externalLayouts.length;s<i;++s){const r=this._data.externalLayouts[s];if(r.name===e){t=r;break}}return t}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,t){if(this._throwIfDisposed(),this._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&n.RuntimeGameRenderer&&n.RuntimeGameRenderer.getWindowInnerWidth&&n.RuntimeGameRenderer.getWindowInnerHeight){const s=n.RuntimeGameRenderer.getWindowInnerWidth(),i=n.RuntimeGameRenderer.getWindowInnerHeight();if(this._resizeMode==="adaptWidth")this._gameResolutionWidth=this._gameResolutionHeight*s/i;else if(this._resizeMode==="adaptHeight")this._gameResolutionHeight=this._gameResolutionWidth*i/s;else if(this._resizeMode==="scaleOuter"){const r=s/this._originalWidth,o=i/this._originalHeight;r<o?(this._gameResolutionWidth=this._originalWidth,this._gameResolutionHeight=Math.floor(i/r)):(this._gameResolutionWidth=Math.floor(s/o),this._gameResolutionHeight=this._originalHeight)}}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}getSceneResourcesPreloading(){return this._sceneResourcesPreloading}getSceneResourcesUnloading(){return this._sceneResourcesUnloading}loadAllAssets(e,t){this._throwIfDisposed(),this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),t).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,t){try{const s=this._data.properties.loadingScreen.backgroundImageResourceName;s&&await this._resourcesLoader.getImageManager().loadResource(s),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async i=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},t),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);i.setPercent(d),s&&s(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents(),n.inAppTutorialMessage&&n.inAppTutorialMessage.displayInAppTutorialMessage(this,this._options.inAppTutorialMessageInPreview,this._options.inAppTutorialMessagePositionInPreview||"");let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(e){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(e),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,i=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-i,i=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=n.makeUuid();return localStorage.setItem(e,s),s}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((i,r)=>{const o=i.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],i=this.getVariablesForExtension(t);i&&i.updateFromNetworkSyncData(s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const g=new n.Logger("Game manager"),c=u=>new Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,s){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=s||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const t of e.eventsFunctionsExtensions)t.globalVariables.length>0&&this._variablesByExtensionName.set(t.name,new n.VariablesContainer(t.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._sceneResourcesPreloading=this._data.properties.sceneResourcesPreloading||"at-startup",this._sceneResourcesUnloading=this._data.properties.sceneResourcesUnloading||"never",this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const t of this._data.resources.resources)if(t.metadata)try{const i=JSON.parse(t.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(t.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(s=>s.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(s=>({sceneData:s,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const s of this._data.eventsFunctionsExtensions)for(const t of s.eventsBasedObjects)this._eventsBasedObjectDatas.set(s.name+"::"+t.name,t)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getResourceLoader(){return this._resourcesLoader}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const s=this._eventsBasedObjectDatas.get(e);return s||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let s=0,t=this._sceneAndExtensionsData.length;s<t;++s){const i=this._sceneAndExtensionsData[s];if(e===void 0||i.sceneData.name===e)return i}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let s=0,t=this._data.layouts.length;s<t;++s){const i=this._data.layouts[s];if(e===void 0||i.name==e)return!0}return!1}getExternalLayoutData(e){let s=null;for(let t=0,i=this._data.externalLayouts.length;t<i;++t){const a=this._data.externalLayouts[t];if(a.name===e){s=a;break}}return s}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,s){if(this._throwIfDisposed(),this._gameResolutionWidth=e,this._gameResolutionHeight=s,this._adaptGameResolutionAtRuntime&&n.RuntimeGameRenderer&&n.RuntimeGameRenderer.getWindowInnerWidth&&n.RuntimeGameRenderer.getWindowInnerHeight){const t=n.RuntimeGameRenderer.getWindowInnerWidth(),i=n.RuntimeGameRenderer.getWindowInnerHeight();if(this._resizeMode==="adaptWidth")this._gameResolutionWidth=this._gameResolutionHeight*t/i;else if(this._resizeMode==="adaptHeight")this._gameResolutionHeight=this._gameResolutionWidth*i/t;else if(this._resizeMode==="scaleOuter"){const a=t/this._originalWidth,o=i/this._originalHeight;a<o?(this._gameResolutionWidth=this._originalWidth,this._gameResolutionHeight=Math.floor(i/a)):(this._gameResolutionWidth=Math.floor(t/o),this._gameResolutionHeight=this._originalHeight)}}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}getSceneResourcesPreloading(){return this._sceneResourcesPreloading}getSceneResourcesUnloading(){return this._sceneResourcesUnloading}loadAllAssets(e,s){this._throwIfDisposed(),this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),s).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,s){try{const t=this._data.properties.loadingScreen.backgroundImageResourceName;t&&await this._resourcesLoader.getImageManager().loadResource(t),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async i=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},s),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(t){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(t),t}}async loadSceneAssets(e,s){await this._loadAssetsWithLoadingScreen(!1,async t=>{await this._resourcesLoader.loadAndProcessSceneResources(e,t)},s)}async _loadAssetsWithLoadingScreen(e,s,t){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await s(async(o,r)=>{const d=Math.floor(100*o/r);i.setPercent(d),t&&t(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents(),n.inAppTutorialMessage&&n.inAppTutorialMessage.displayInAppTutorialMessage(this,this._options.inAppTutorialMessageInPreview,this._options.inAppTutorialMessagePositionInPreview||"");let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(s=>{try{if(this._paused||(e+=s,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const t=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(t)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(t){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(t),t}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(e){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(e),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let s=0,t=0,i=Date.now();const a=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:a.isCordova,devicePlatform:a.devicePlatform,navigatorPlatform:a.navigatorPlatform,hasTouch:a.hasTouch}})}).then(r=>{if(!r.ok)throw console.error("Error while creating the session",r),new Error("Error while creating the session");return r}).then(r=>r.text()).then(r=>{this._sessionId=r}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const r=Date.now();if(t+=r-i,i=r,t<5*1e3)return;const d=Math.floor(t/1e3)*1e3;s+=d,t-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(s/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const r=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(r||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",s=localStorage.getItem(e);if(s)return s;const t=n.makeUuid();return localStorage.setItem(e,t),t}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const s=this._sceneStack.getCurrentScene();return s?(s.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,s){for(let t of this._data.properties.extensionProperties)if(t.extension===e&&t.property===s)return t.value;return null}resolveEmbeddedResource(e,s){const t=this._embeddedResourcesMappings.get(e);return t&&t[s]?t[s]:s}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const s={var:e.syncGameVariables===!1?void 0:this._variables.getNetworkSyncData(e),sm:e.syncSounds?this.getSoundManager().getNetworkSyncData():void 0,ss:this._sceneStack.getNetworkSyncData(e)||void 0};if(e.syncGameVariables!==!1){const t={};this._variablesByExtensionName.forEach((i,a)=>{const o=i.getNetworkSyncData(e);o.length&&(t[a]=o)}),s.extVar=t}return(!s.var||s.var.length===0)&&!s.ss&&(!s.extVar||Object.keys(s.extVar).length===0)?null:s}updateFromNetworkSyncData(e,s){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var,s),e.sm&&this.getSoundManager().updateFromNetworkSyncData(e.sm),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const i=e.extVar[t],a=this.getVariablesForExtension(t);a&&a.updateFromNetworkSyncData(i,s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimegame.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/runtimegame.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Game manager');\n\n const sleep = (ms: float) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n /** Identify a script file, with its content hash (useful for hot-reloading). */\n export type RuntimeGameOptionsScriptFile = {\n /** The path for this script file. */\n path: string;\n /** The hash of the script file content. */\n hash: number;\n };\n\n const getGlobalResourceNames = (projectData: ProjectData): Array<string> =>\n projectData.usedResources.map((resource) => resource.name);\n\n let supportedCompressionMethods: ('cs:gzip' | 'cs:deflate')[] | null = null;\n const getSupportedCompressionMethods = (): ('cs:gzip' | 'cs:deflate')[] => {\n if (!!supportedCompressionMethods) {\n return supportedCompressionMethods;\n }\n supportedCompressionMethods = [];\n\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('gzip');\n supportedCompressionMethods.push('cs:gzip');\n } catch (e) {}\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('deflate');\n supportedCompressionMethods.push('cs:deflate');\n } catch (e) {}\n\n return supportedCompressionMethods;\n };\n\n /** Options given to the game at startup. */\n export type RuntimeGameOptions = {\n /** if true, force fullscreen. */\n forceFullscreen?: boolean;\n /** if true, game is run as a preview launched from an editor. */\n isPreview?: boolean;\n /** The name of the external layout to create in the scene at position 0;0. */\n injectExternalLayout?: string;\n /** Script files, used for hot-reloading. */\n scriptFiles?: Array<RuntimeGameOptionsScriptFile>;\n /** if true, export is a partial preview without events. */\n projectDataOnlyExport?: boolean;\n /** if true, preview is launched from GDevelop native mobile app. */\n nativeMobileApp?: boolean;\n /** The address of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerAddress?: string;\n /** The port of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerPort?: string;\n\n /**\n * The path to require `@electron/remote` module.\n * This is only useful in a preview, where this can't be required from\n * `@electron/remote` directly as previews don't have any node_modules.\n * On the contrary, a game packaged with Electron as a standalone app\n * has its node_modules.\n * This can be removed once there are no more dependencies on\n * `@electron/remote` in the game engine and extensions.\n */\n electronRemoteRequirePath?: string;\n\n /**\n * The token to use by the game engine when requiring any resource stored on\n * GDevelop Cloud buckets. Note that this is only useful during previews.\n */\n gdevelopResourceToken?: string;\n\n /**\n * Check if, in some exceptional cases, we allow authentication\n * to be done through a iframe.\n * This is usually discouraged as the user can't verify that the authentication\n * window is a genuine one. It's only to be used in trusted contexts.\n */\n allowAuthenticationUsingIframeForPreview?: boolean;\n\n /** If set, the game will send crash reports to GDevelop APIs. */\n crashReportUploadLevel?: 'all' | 'exclude-javascript-code-events' | 'none';\n\n /** Arbitrary string explaining in which context the game is being played. */\n previewContext?: string;\n\n /** The GDevelop version used to build the game. */\n gdevelopVersionWithHash?: string;\n\n /** The template slug that was used to create the project. */\n projectTemplateSlug?: string;\n\n /** The source game id that was used to create the project. */\n sourceGameId?: string;\n\n /** Any capture that should be done during the preview. */\n captureOptions?: CaptureOptions;\n\n /** Message to display to the user during an in-app tutorial. */\n inAppTutorialMessageInPreview?: string;\n inAppTutorialMessagePositionInPreview?: string;\n\n /**\n * If set, this data is used to authenticate automatically when launching the game.\n * This is only useful during previews.\n */\n playerUsername?: string;\n playerId?: string;\n playerToken?: string;\n\n /**\n * If set, the game should use the specified environment for making calls\n * to GDevelop APIs (\"dev\" = development APIs).\n */\n environment?: 'dev';\n };\n\n /**\n * Represents a game being played.\n */\n export class RuntimeGame {\n _resourcesLoader: gdjs.ResourceLoader;\n _variables: VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _data: ProjectData;\n _sceneAndExtensionsData: Array<SceneAndExtensionsData> = [];\n _eventsBasedObjectDatas: Map<String, EventsBasedObjectData>;\n _effectsManager: EffectsManager;\n _maxFPS: integer;\n _minFPS: integer;\n _gameResolutionWidth: integer;\n _gameResolutionHeight: integer;\n _originalWidth: float;\n _originalHeight: float;\n _resizeMode: 'adaptWidth' | 'adaptHeight' | string;\n _adaptGameResolutionAtRuntime: boolean;\n _scaleMode: 'linear' | 'nearest';\n _pixelsRounding: boolean;\n _antialiasingMode: 'none' | 'MSAA';\n _isAntialisingEnabledOnMobile: boolean;\n /**\n * Game loop management (see startGameLoop method)\n */\n _renderer: RuntimeGameRenderer;\n _sessionId: string | null;\n _playerId: string | null;\n _watermark: watermark.RuntimeWatermark;\n\n _sceneStack: SceneStack;\n /**\n * When set to true, the scenes are notified that game resolution size changed.\n */\n _notifyScenesForGameResolutionResize: boolean = false;\n\n /**\n * When paused, the game won't step and will be freezed. Useful for debugging.\n */\n _paused: boolean = false;\n\n /**\n * True during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n _hasJustResumed: boolean = false;\n\n //Inputs :\n _inputManager: InputManager;\n\n /**\n * Allow to specify an external layout to insert in the first scene.\n */\n _injectExternalLayout: any;\n _options: RuntimeGameOptions;\n\n /**\n * The mappings for embedded resources\n */\n _embeddedResourcesMappings: Map<string, Record<string, string>>;\n\n _sceneResourcesPreloading: 'at-startup' | 'never';\n _sceneResourcesUnloading: 'at-scene-exit' | 'never';\n\n /**\n * Optional client to connect to a debugger server.\n */\n _debuggerClient: gdjs.AbstractDebuggerClient | null;\n _sessionMetricsInitialized: boolean = false;\n _disableMetrics: boolean = false;\n _isPreview: boolean;\n\n /**\n * The capture manager, used to manage captures (screenshots, videos, etc...).\n */\n _captureManager: CaptureManager | null;\n\n /** True if the RuntimeGame has been disposed and should not be used anymore. */\n _wasDisposed: boolean = false;\n\n /**\n * @param data The object (usually stored in data.json) containing the full project data\n * @param options The game options\n */\n constructor(data: ProjectData, options?: RuntimeGameOptions) {\n this._options = options || {};\n this._variables = new gdjs.VariablesContainer(data.variables);\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n for (const extensionData of data.eventsFunctionsExtensions) {\n if (extensionData.globalVariables.length > 0) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.globalVariables)\n );\n }\n }\n this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();\n this._data = data;\n this._updateSceneAndExtensionsData();\n\n this._sceneResourcesPreloading =\n this._data.properties.sceneResourcesPreloading || 'at-startup';\n this._sceneResourcesUnloading =\n this._data.properties.sceneResourcesUnloading || 'never';\n\n this._resourcesLoader = new gdjs.ResourceLoader(\n this,\n data.resources.resources,\n getGlobalResourceNames(data),\n data.layouts\n );\n\n this._effectsManager = new gdjs.EffectsManager();\n this._maxFPS = this._data.properties.maxFPS;\n this._minFPS = this._data.properties.minFPS;\n this._gameResolutionWidth = this._data.properties.windowWidth;\n this._gameResolutionHeight = this._data.properties.windowHeight;\n this._originalWidth = this._gameResolutionWidth;\n this._originalHeight = this._gameResolutionHeight;\n this._resizeMode = this._data.properties.sizeOnStartupMode;\n this._adaptGameResolutionAtRuntime =\n this._data.properties.adaptGameResolutionAtRuntime;\n this._scaleMode = data.properties.scaleMode || 'linear';\n this._pixelsRounding = this._data.properties.pixelsRounding;\n this._antialiasingMode = this._data.properties.antialiasingMode;\n this._isAntialisingEnabledOnMobile =\n this._data.properties.antialisingEnabledOnMobile;\n\n this._renderer = new gdjs.RuntimeGameRenderer(\n this,\n this._options.forceFullscreen || false\n );\n this._watermark = new gdjs.watermark.RuntimeWatermark(\n this,\n data.properties.authorUsernames,\n this._data.properties.watermark\n );\n this._sceneStack = new gdjs.SceneStack(this);\n this._inputManager = new gdjs.InputManager();\n this._injectExternalLayout = this._options.injectExternalLayout || '';\n this._debuggerClient = gdjs.DebuggerClient\n ? new gdjs.DebuggerClient(this)\n : null;\n this._captureManager = gdjs.CaptureManager\n ? new gdjs.CaptureManager(\n this._renderer,\n this._options.captureOptions || {}\n )\n : null;\n this._isPreview = this._options.isPreview || false;\n this._sessionId = null;\n this._playerId = null;\n\n this._embeddedResourcesMappings = new Map();\n for (const resource of this._data.resources.resources) {\n if (resource.metadata) {\n try {\n const metadata = JSON.parse(resource.metadata);\n if (metadata?.embeddedResourcesMapping) {\n this._embeddedResourcesMappings.set(\n resource.name,\n metadata.embeddedResourcesMapping\n );\n }\n } catch {\n logger.error(\n 'Some metadata of resources can not be successfully parsed.'\n );\n }\n }\n }\n\n if (this.isUsingGDevelopDevelopmentEnvironment()) {\n logger.info(\n 'This game will run on the development version of GDevelop APIs.'\n );\n }\n }\n\n /**\n * Update the project data. Useful for hot-reloading, should not be used otherwise.\n *\n * @param projectData The object (usually stored in data.json) containing the full project data\n */\n setProjectData(projectData: ProjectData): void {\n this._data = projectData;\n this._updateSceneAndExtensionsData();\n this._resourcesLoader.setResources(\n projectData.resources.resources,\n getGlobalResourceNames(projectData),\n projectData.layouts\n );\n }\n\n private _updateSceneAndExtensionsData(): void {\n const usedExtensionsWithVariablesData =\n this._data.eventsFunctionsExtensions.filter(\n (extensionData) => extensionData.sceneVariables.length > 0\n );\n this._sceneAndExtensionsData = this._data.layouts.map((sceneData) => ({\n sceneData,\n usedExtensionsWithVariablesData,\n }));\n\n this._eventsBasedObjectDatas.clear();\n if (this._data.eventsFunctionsExtensions) {\n for (const extension of this._data.eventsFunctionsExtensions) {\n for (const eventsBasedObject of extension.eventsBasedObjects) {\n this._eventsBasedObjectDatas.set(\n extension.name + '::' + eventsBasedObject.name,\n eventsBasedObject\n );\n }\n }\n }\n }\n\n /**\n * Return the additional options passed to the RuntimeGame when created.\n * @returns The additional options, if any.\n */\n getAdditionalOptions(): RuntimeGameOptions {\n return this._options;\n }\n\n getRenderer(): gdjs.RuntimeGameRenderer {\n return this._renderer;\n }\n\n /**\n * Get the variables of the RuntimeGame.\n * @return The global variables\n */\n getVariables(): gdjs.VariablesContainer {\n return this._variables;\n }\n\n /**\n * Get the extension's global variables.\n * @param extensionName The extension name.\n * @returns The extension's global variables.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the gdjs.ResourceLoader of the RuntimeGame.\n * @return The resource loader.\n */\n getResourceLoader(): gdjs.ResourceLoader {\n return this._resourcesLoader;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._resourcesLoader.getSoundManager();\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._resourcesLoader.getImageManager();\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._resourcesLoader.getFontManager();\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._resourcesLoader.getBitmapFontManager();\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._resourcesLoader.getJsonManager();\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._resourcesLoader.getModel3DManager();\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._resourcesLoader.getSpineManager();\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._resourcesLoader.getSpineAtlasManager();\n }\n\n /**\n * Get the input manager of the game, storing mouse, keyboard\n * and touches states.\n * @return The input manager owned by the game\n */\n getInputManager(): gdjs.InputManager {\n return this._inputManager;\n }\n\n /**\n * Get the effects manager of the game, which allows to manage\n * effects on runtime objects or runtime layers.\n * @return The effects manager for the game\n */\n getEffectsManager(): gdjs.EffectsManager {\n return this._effectsManager;\n }\n\n /**\n * Get the object containing the game data\n * @return The object associated to the game.\n */\n getGameData(): ProjectData {\n return this._data;\n }\n\n getEventsBasedObjectData(type: string): EventsBasedObjectData | null {\n const eventsBasedObjectData = this._eventsBasedObjectDatas.get(type);\n if (!eventsBasedObjectData) {\n logger.error(\n 'The game has no events-based object of the type \"' + type + '\"'\n );\n return null;\n }\n return eventsBasedObjectData;\n }\n\n /**\n * Get the data associated to a scene.\n *\n * @param sceneName The name of the scene. If not defined, the first scene will be returned.\n * @return The data associated to the scene.\n */\n getSceneAndExtensionsData(\n sceneName?: string\n ): SceneAndExtensionsData | null {\n for (let i = 0, len = this._sceneAndExtensionsData.length; i < len; ++i) {\n const sceneAndExtensionsData = this._sceneAndExtensionsData[i];\n if (\n sceneName === undefined ||\n sceneAndExtensionsData.sceneData.name === sceneName\n ) {\n return sceneAndExtensionsData;\n }\n }\n logger.error('The game has no scene called \"' + sceneName + '\"');\n return null;\n }\n\n /**\n * Check if a scene exists\n *\n * @param sceneName The name of the scene to search.\n * @return true if the scene exists. If sceneName is undefined, true if the game has a scene.\n */\n hasScene(sceneName?: string): boolean {\n for (let i = 0, len = this._data.layouts.length; i < len; ++i) {\n const sceneData = this._data.layouts[i];\n if (sceneName === undefined || sceneData.name == sceneName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Get the data associated to an external layout.\n *\n * @param name The name of the external layout.\n * @return The data associated to the external layout or null if not found.\n */\n getExternalLayoutData(name: string): ExternalLayoutData | null {\n let externalLayout: ExternalLayoutData | null = null;\n for (let i = 0, len = this._data.externalLayouts.length; i < len; ++i) {\n const layoutData = this._data.externalLayouts[i];\n if (layoutData.name === name) {\n externalLayout = layoutData;\n break;\n }\n }\n return externalLayout;\n }\n\n /**\n * Get the data representing all the global objects of the game.\n * @return The data associated to the global objects.\n */\n getInitialObjectsData(): ObjectData[] {\n return this._data.objects || [];\n }\n\n /**\n * Get the original width of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalWidth(): float {\n return this._originalWidth;\n }\n\n /**\n * Get the original height of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalHeight(): float {\n return this._originalHeight;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) width.\n * @returns The game resolution width, in pixels.\n */\n getGameResolutionWidth(): float {\n return this._gameResolutionWidth;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) height.\n * @returns The game resolution height, in pixels.\n */\n getGameResolutionHeight(): float {\n return this._gameResolutionHeight;\n }\n\n /**\n * Change the game resolution.\n *\n * @param width The new width\n * @param height The new height\n */\n setGameResolutionSize(width: float, height: float): void {\n this._throwIfDisposed();\n\n this._gameResolutionWidth = width;\n this._gameResolutionHeight = height;\n if (this._adaptGameResolutionAtRuntime) {\n if (\n gdjs.RuntimeGameRenderer &&\n gdjs.RuntimeGameRenderer.getWindowInnerWidth &&\n gdjs.RuntimeGameRenderer.getWindowInnerHeight\n ) {\n const windowInnerWidth =\n gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight =\n gdjs.RuntimeGameRenderer.getWindowInnerHeight();\n\n // Enlarge either the width or the eight to fill the inner window space.\n if (this._resizeMode === 'adaptWidth') {\n this._gameResolutionWidth =\n (this._gameResolutionHeight * windowInnerWidth) /\n windowInnerHeight;\n } else if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n } else if (this._resizeMode === 'scaleOuter') {\n const widthFactor = windowInnerWidth / this._originalWidth;\n const heightFactor = windowInnerHeight / this._originalHeight;\n\n if (widthFactor < heightFactor) {\n this._gameResolutionWidth = this._originalWidth;\n this._gameResolutionHeight = Math.floor(\n windowInnerHeight / widthFactor\n );\n } else {\n this._gameResolutionWidth = Math.floor(\n windowInnerWidth / heightFactor\n );\n this._gameResolutionHeight = this._originalHeight;\n }\n }\n }\n }\n\n // Don't alter the game resolution. The renderer\n // will maybe adapt the size of the canvas or whatever is used to render the\n // game in the window, but this does not change the \"game resolution\".\n\n // Notify the renderer that game resolution changed (so that the renderer size\n // can be updated, and maybe other things like the canvas size), and let the\n // scenes know too.\n this._renderer.updateRendererSize();\n this._notifyScenesForGameResolutionResize = true;\n }\n\n /**\n * Set if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically.\n *\n * @param resizeMode Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n setGameResolutionResizeMode(resizeMode: string): void {\n this._resizeMode = resizeMode;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically (empty string).\n *\n * @returns Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n getGameResolutionResizeMode(): string {\n return this._resizeMode;\n }\n\n /**\n * Set if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @param enable true to change the game resolution according to the window/screen size.\n */\n setAdaptGameResolutionAtRuntime(enable: boolean): void {\n this._adaptGameResolutionAtRuntime = enable;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @returns true if the game resolution is automatically changed according to the window/screen size.\n */\n getAdaptGameResolutionAtRuntime(): boolean {\n return this._adaptGameResolutionAtRuntime;\n }\n\n /**\n * Return the minimal fps that must be guaranteed by the game\n * (otherwise, game is slowed down).\n */\n getMinimalFramerate(): integer {\n return this._minFPS;\n }\n\n /**\n * Return the scale mode of the game (\"linear\" or \"nearest\").\n */\n getScaleMode(): 'linear' | 'nearest' {\n return this._scaleMode;\n }\n\n /**\n * Return if the game is rounding pixels when rendering.\n */\n getPixelsRounding(): boolean {\n return this._pixelsRounding;\n }\n\n /**\n * Return the antialiasing mode used by the game (\"none\" or \"MSAA\").\n */\n getAntialiasingMode(): 'none' | 'MSAA' {\n return this._antialiasingMode;\n }\n\n /**\n * Return true if antialising is enabled on mobiles.\n */\n isAntialisingEnabledOnMobile(): boolean {\n return this._isAntialisingEnabledOnMobile;\n }\n\n /**\n * Set or unset the game as paused.\n * When paused, the game won't step and will be freezed. Useful for debugging.\n * @param enable true to pause the game, false to unpause\n */\n pause(enable: boolean) {\n if (this._paused === enable) return;\n\n this._paused = enable;\n if (this._debuggerClient) {\n if (this._paused) this._debuggerClient.sendGamePaused();\n else this._debuggerClient.sendGameResumed();\n }\n }\n\n /**\n * @returns true during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n hasJustResumed() {\n return this._hasJustResumed;\n }\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n prioritizeLoadingOfScene(sceneName: string) {\n // Don't await the scene assets to be loaded.\n this._resourcesLoader.loadSceneResources(sceneName);\n }\n\n /**\n * @return The progress of assets loading in background for a scene\n * (between 0 and 1).\n */\n getSceneLoadingProgress(sceneName: string): number {\n return this._resourcesLoader.getSceneLoadingProgress(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsLoaded(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsReady(sceneName);\n }\n\n /**\n * Returns the scene resources preloading mode.\n * It can be overriden by each scene.\n */\n getSceneResourcesPreloading(): 'at-startup' | 'never' {\n return this._sceneResourcesPreloading;\n }\n\n /**\n * Returns the scene resources unloading mode.\n * It can be overriden by each scene.\n */\n getSceneResourcesUnloading(): 'at-scene-exit' | 'never' {\n return this._sceneResourcesUnloading;\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n */\n loadAllAssets(\n callback: () => void,\n progressCallback?: (progress: float) => void\n ) {\n this._throwIfDisposed();\n this.loadFirstAssetsAndStartBackgroundLoading(\n this._getFirstSceneName(),\n progressCallback\n ).then(callback);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n *\n * When a game is hot-reload, this method can be called with the current\n * scene.\n */\n async loadFirstAssetsAndStartBackgroundLoading(\n firstSceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n try {\n // Download the loading screen background image first to be able to\n // display the loading screen as soon as possible.\n const backgroundImageResourceName =\n this._data.properties.loadingScreen.backgroundImageResourceName;\n if (backgroundImageResourceName) {\n await this._resourcesLoader\n .getImageManager()\n .loadResource(backgroundImageResourceName);\n }\n await Promise.all([\n this._loadAssetsWithLoadingScreen(\n /* isFirstScene = */ true,\n async (onProgress) => {\n // TODO Is a setting needed?\n if (false) {\n await this._resourcesLoader.loadAllResources(onProgress);\n } else {\n await this._resourcesLoader.loadGlobalAndFirstSceneResources(\n firstSceneName,\n onProgress\n );\n // Don't await as it must not block the first scene from starting.\n this._resourcesLoader.loadAllSceneInBackground();\n }\n },\n progressCallback\n ),\n // TODO This is probably not necessary in case of hot reload.\n gdjs.getAllAsynchronouslyLoadingLibraryPromise(),\n ]);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Load all assets for a given scene, displaying progress in renderer.\n */\n async loadSceneAssets(\n sceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n await this._loadAssetsWithLoadingScreen(\n /* isFirstLayout = */ false,\n async (onProgress) => {\n await this._resourcesLoader.loadAndProcessSceneResources(\n sceneName,\n onProgress\n );\n },\n progressCallback\n );\n }\n\n /**\n * Load assets, displaying progress in renderer.\n */\n private async _loadAssetsWithLoadingScreen(\n isFirstScene: boolean,\n loadAssets: (\n onProgress: (count: integer, total: integer) => Promise<void>\n ) => Promise<void>,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n this.pause(true);\n const loadingScreen = new gdjs.LoadingScreenRenderer(\n this.getRenderer(),\n this._resourcesLoader.getImageManager(),\n this._data.properties.loadingScreen,\n this._data.properties.watermark.showWatermark,\n isFirstScene\n );\n\n const onProgress = async (count: integer, total: integer) => {\n const percent = Math.floor((100 * count) / total);\n loadingScreen.setPercent(percent);\n if (progressCallback) {\n progressCallback(percent);\n }\n const hasRendered = loadingScreen.renderIfNeeded();\n if (hasRendered) {\n // Give a chance to draw calls from the renderer to be handled.\n await sleep(1);\n }\n };\n await loadAssets(onProgress);\n\n await loadingScreen.unload();\n this.pause(false);\n }\n\n private _getFirstSceneName(): string {\n const firstSceneName = this._data.firstLayout;\n return this.hasScene(firstSceneName)\n ? firstSceneName\n : // There is always at least a scene\n this.getSceneAndExtensionsData()!.sceneData.name;\n }\n\n /**\n * Start the game loop, to be called once assets are loaded.\n */\n startGameLoop() {\n this._throwIfDisposed();\n try {\n if (!this.hasScene()) {\n logger.error('The game has no scene.');\n return;\n }\n this._forceGameResolutionUpdate();\n\n // Load the first scene\n this._sceneStack.push(\n this._getFirstSceneName(),\n this._injectExternalLayout\n );\n this._watermark.displayAtStartup();\n\n //Uncomment to profile the first x frames of the game.\n // var x = 500;\n // var startTime = Date.now();\n // console.profile(\"Stepping for \" + x + \" frames\")\n // for(var i = 0; i < x; ++i) {\n // this._sceneStack.step(16);\n // }\n // console.profileEnd();\n // var time = Date.now() - startTime;\n // logger.log(\"Took\", time, \"ms\");\n // return;\n\n this._setupGameVisibilityEvents();\n\n if (gdjs.inAppTutorialMessage) {\n gdjs.inAppTutorialMessage.displayInAppTutorialMessage(\n this,\n this._options.inAppTutorialMessageInPreview,\n this._options.inAppTutorialMessagePositionInPreview || ''\n );\n }\n\n // The standard game loop\n let accumulatedElapsedTime = 0;\n this._hasJustResumed = false;\n this._renderer.startGameLoop((lastCallElapsedTime) => {\n try {\n if (this._paused) {\n return true;\n }\n\n // Skip the frame if we rendering frames too fast\n accumulatedElapsedTime += lastCallElapsedTime;\n if (\n this._maxFPS > 0 &&\n 1000.0 / accumulatedElapsedTime > this._maxFPS + 7\n ) {\n // Only skip frame if the framerate is 7 frames above the maximum framerate.\n // Most browser/engines will try to run at slightly more than 60 frames per second.\n // If game is set to have a maximum FPS to 60, then one out of two frames will be dropped.\n // Hence, we use a 7 frames margin to ensure that we're not skipping frames too much.\n return true;\n }\n const elapsedTime = accumulatedElapsedTime;\n accumulatedElapsedTime = 0;\n\n // Manage resize events.\n if (this._notifyScenesForGameResolutionResize) {\n this._sceneStack.onGameResolutionResized();\n this._notifyScenesForGameResolutionResize = false;\n }\n\n // Render and step the scene.\n if (this._sceneStack.step(elapsedTime)) {\n this.getInputManager().onFrameEnded();\n this._hasJustResumed = false;\n return true;\n }\n return false;\n } catch (e) {\n if (this._debuggerClient)\n this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n });\n setTimeout(() => {\n this._setupSessionMetrics();\n }, 4000);\n if (this._captureManager) {\n this._captureManager.setupCaptureOptions(this._isPreview);\n }\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Stop game loop, unload all scenes, dispose renderer and resources.\n * After calling this method, the RuntimeGame should not be used anymore.\n * @param removeCanvas If true, the canvas will be removed from the DOM.\n */\n dispose(removeCanvas?: boolean): void {\n this._renderer.stopGameLoop();\n this._sceneStack.dispose();\n this._renderer.dispose(removeCanvas);\n this._resourcesLoader.dispose();\n\n this._wasDisposed = true;\n }\n\n /**\n * Set if the session should be registered.\n */\n enableMetrics(enable: boolean): void {\n this._disableMetrics = !enable;\n if (enable) {\n this._setupSessionMetrics();\n }\n }\n\n /**\n * Helper function to get information about the platform running the game.\n */\n getPlatformInfo = () => {\n return {\n // @ts-ignore\n isCordova: !!window.cordova,\n devicePlatform:\n // @ts-ignore\n typeof device !== 'undefined' ? device.platform || '' : '',\n navigatorPlatform:\n typeof navigator !== 'undefined' ? navigator.platform : '',\n hasTouch:\n typeof navigator !== 'undefined'\n ? !!navigator.maxTouchPoints && navigator.maxTouchPoints > 2\n : false,\n supportedCompressionMethods: getSupportedCompressionMethods(),\n };\n };\n\n _setupGameVisibilityEvents() {\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this._hasJustResumed = true;\n }\n });\n window.addEventListener(\n 'resume',\n () => {\n this._hasJustResumed = true;\n },\n false\n );\n }\n }\n\n /**\n * Register a new session for the game, and set up listeners to follow the session\n * time.\n */\n _setupSessionMetrics() {\n if (this._sessionMetricsInitialized) {\n return;\n }\n if (this._disableMetrics) {\n return;\n }\n if (this.isPreview()) {\n return;\n }\n if (typeof fetch === 'undefined') {\n return;\n }\n if (!this._data.properties.projectUuid) {\n return;\n }\n const baseUrl = 'https://api.gdevelop-app.com/analytics';\n this._playerId = this._makePlayerUuid();\n /**\n * The duration that is already sent to the service\n * (in milliseconds).\n **/\n let sentDuration = 0;\n /**\n * The duration that is not yet sent to the service to avoid flooding\n * (in milliseconds).\n **/\n let notYetSentDuration = 0;\n /**\n * The last time when duration has been counted\n * either in sendedDuration or notYetSentDuration.\n **/\n let lastSessionResumeTime = Date.now();\n const platform = this.getPlatformInfo();\n fetch(baseUrl + '/session', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n // It's important to ensure that the data sent here does not contain\n // any personal information from the player or that would allow to\n // precisely identify someone.\n body: JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n game: {\n name: this._data.properties.name || '',\n packageName: this._data.properties.packageName || '',\n version: this._data.properties.version || '',\n location: window.location.href,\n },\n platform: {\n isCordova: platform.isCordova,\n devicePlatform: platform.devicePlatform,\n navigatorPlatform: platform.navigatorPlatform,\n hasTouch: platform.hasTouch,\n },\n }),\n })\n .then((response) => {\n // Ensure the session is correctly created to avoid sending hits that will fail.\n if (!response.ok) {\n console.error('Error while creating the session', response);\n throw new Error('Error while creating the session');\n }\n return response;\n })\n .then((response) => response.text())\n .then((returnedSessionId) => {\n this._sessionId = returnedSessionId;\n })\n .catch(() => {});\n\n /* Ignore any error */\n const sendSessionHit = () => {\n if (!this._sessionId) {\n return;\n }\n\n const now = Date.now();\n notYetSentDuration += now - lastSessionResumeTime;\n lastSessionResumeTime = now;\n\n // Group repeated calls to sendSessionHit - which could\n // happen because of multiple event listeners being fired.\n if (notYetSentDuration < 5 * 1000) {\n return;\n }\n // The backend use seconds for duration.\n // The milliseconds will stay in notYetSentDuration.\n const toBeSentDuration = Math.floor(notYetSentDuration / 1000) * 1000;\n sentDuration += toBeSentDuration;\n notYetSentDuration -= toBeSentDuration;\n\n navigator.sendBeacon(\n baseUrl + '/session-hit',\n JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n sessionId: this._sessionId,\n duration: Math.floor(sentDuration / 1000),\n })\n );\n };\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n } else {\n sendSessionHit();\n }\n });\n window.addEventListener('pagehide', sendSessionHit, false);\n // Cordova events\n window.addEventListener('pause', sendSessionHit, false);\n window.addEventListener(\n 'resume',\n () => {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n },\n false\n );\n\n // Detect Safari to work around Safari-specific bugs:\n // - https://bugs.webkit.org/show_bug.cgi?id=151610\n // - https://bugs.webkit.org/show_bug.cgi?id=151234\n // @ts-ignore\n const isSafari = typeof safari === 'object' && safari.pushNotification;\n const isElectron = /electron/i.test(navigator.userAgent);\n if (isSafari || isElectron) {\n window.addEventListener('beforeunload', () => {\n sendSessionHit();\n });\n }\n }\n this._sessionMetricsInitialized = true;\n this._sessionId = this._sessionId;\n }\n\n /**\n * Generate an anonymous unique identifier to differentiate\n * the player from others in the game metrics.\n */\n _makePlayerUuid(): string {\n try {\n const key = 'GDJS-internal-player-uuid';\n const existingPlayerUuid = localStorage.getItem(key);\n if (existingPlayerUuid) {\n return existingPlayerUuid;\n }\n const newPlayerUuid = gdjs.makeUuid();\n localStorage.setItem(key, newPlayerUuid);\n return newPlayerUuid;\n } catch (err) {\n return gdjs.makeUuid();\n }\n }\n\n getSessionId(): string | null {\n return this._sessionId;\n }\n\n getPlayerId(): string | null {\n return this._playerId;\n }\n\n /**\n * Called by the game renderer when the window containing the game\n * has changed size (this can result from a resize of the window,\n * but also other factors like a device orientation change on mobile).\n */\n onWindowInnerSizeChanged() {\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Enlarge/reduce the width (or the height) of the game to fill the inner window.\n */\n private _forceGameResolutionUpdate() {\n this.setGameResolutionSize(\n this._gameResolutionWidth,\n this._gameResolutionHeight\n );\n }\n\n /**\n * Start a profiler for the currently running scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startCurrentSceneProfiler(\n onProfilerStopped: (oldProfiler: Profiler) => void\n ) {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return false;\n }\n currentScene.startProfiler(onProfilerStopped);\n return true;\n }\n\n /**\n * Stop the profiler for the currently running scene.\n */\n stopCurrentSceneProfiler() {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return;\n }\n currentScene.stopProfiler();\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._sceneStack.wasFirstSceneLoaded();\n }\n\n /**\n * Return the stack of {@link gdjs.RuntimeScene} being played.\n */\n getSceneStack(): gdjs.SceneStack {\n return this._sceneStack;\n }\n\n /**\n * Check if the game is running as a preview, launched from an editor.\n * @returns true if the current game is a preview.\n */\n isPreview(): boolean {\n return this._isPreview;\n }\n\n /**\n * Check if the game should call GDevelop development APIs or not.\n *\n * Unless you are contributing to GDevelop, avoid using this.\n */\n isUsingGDevelopDevelopmentEnvironment(): boolean {\n return this._options.environment === 'dev';\n }\n\n /**\n * Gets an extension property from the project data.\n * @param extensionName The extension name.\n * @param propertyName The property name.\n * @return The property value.\n */\n getExtensionProperty(\n extensionName: string,\n propertyName: string\n ): string | null {\n for (let property of this._data.properties.extensionProperties) {\n if (\n property.extension === extensionName &&\n property.property === propertyName\n ) {\n return property.value;\n }\n }\n return null;\n }\n\n /**\n * Resolves the name of an embedded resource.\n * @param mainResourceName The name of the resource containing the embedded resource.\n * @param embeddedResourceName The name of the embedded resource.\n * @return The resource name.\n */\n resolveEmbeddedResource(\n mainResourceName: string,\n embeddedResourceName: string\n ): string {\n const mapping = this._embeddedResourcesMappings.get(mainResourceName);\n return mapping && mapping[embeddedResourceName]\n ? mapping[embeddedResourceName]\n : embeddedResourceName;\n }\n\n /**\n * Returns the array of resources that are embedded to passed one.\n * @param resourceName The name of resource to find embedded resources of.\n * @returns The array of related resources names.\n */\n getEmbeddedResourcesNames(resourceName: string): string[] {\n return this._embeddedResourcesMappings.has(resourceName)\n ? Object.keys(this._embeddedResourcesMappings.get(resourceName)!)\n : [];\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): GameNetworkSyncData | null {\n const syncData: GameNetworkSyncData = {\n var: this._variables.getNetworkSyncData(syncOptions),\n ss: this._sceneStack.getNetworkSyncData(syncOptions) || undefined,\n };\n\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData =\n variables.getNetworkSyncData(syncOptions);\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[extensionName] =\n extensionVariablesSyncData;\n }\n });\n syncData.extVar = extensionsVariablesSyncData;\n\n if (\n (!syncData.var || syncData.var.length === 0) &&\n !syncData.ss &&\n (!syncData.extVar || Object.keys(syncData.extVar).length === 0)\n ) {\n // Nothing to sync.\n return null;\n }\n\n return syncData;\n }\n\n updateFromNetworkSyncData(syncData: GameNetworkSyncData) {\n this._throwIfDisposed();\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var);\n }\n if (syncData.ss) {\n this._sceneStack.updateFromNetworkSyncData(syncData.ss);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables =\n this.getVariablesForExtension(extensionName);\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\n }\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The RuntimeGame has been disposed and should not be used anymore.';\n }\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,gBAEzB,EAAQ,AAAC,GACb,GAAI,SAAQ,AAAC,GAAY,WAAW,EAAS,IAUzC,EAAyB,AAAC,GAC9B,EAAY,cAAc,IAAI,AAAC,GAAa,EAAS,MAEvD,GAAI,GAAmE,KACvE,KAAM,GAAiC,IAAoC,CACzE,GAAM,EACJ,MAAO,GAET,EAA8B,GAE9B,GAAI,CAEF,GAAI,mBAAkB,QACtB,EAA4B,KAAK,gBACjC,EACF,GAAI,CAEF,GAAI,mBAAkB,WACtB,EAA4B,KAAK,mBACjC,EAEF,MAAO,IAuFF,OAAkB,CAkFvB,YAAY,EAAmB,EAA8B,CA7E7D,6BAAyD,GA2BzD,0CAAgD,GAKhD,aAAmB,GAMnB,qBAA2B,GAuB3B,gCAAsC,GACtC,qBAA2B,GAS3B,kBAAwB,GAi1BxB,qBAAkB,IACT,EAEL,UAAW,CAAC,CAAC,OAAO,QACpB,eAEE,MAAO,SAAW,aAAc,OAAO,UAAY,GACrD,kBACE,MAAO,YAAc,YAAc,UAA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2BAA2B,IAAI,GACpD,MAAO,IAAW,EAAQ,GACtB,EAAQ,GACR,EAQN,0BAA0B,EAAgC,CACxD,MAAO,MAAK,2BAA2B,IAAI,GACvC,OAAO,KAAK,KAAK,2BAA2B,IAAI,IAChD,GAGN,mBACE,EAC4B,CAC5B,KAAM,GAAgC,CACpC,IAAK,KAAK,WAAW,mBAAmB,GACxC,GAAI,KAAK,YAAY,mBAAmB,IAAgB,QAGpD,EAA8B,GAYpC,MAXA,MAAK,0BAA0B,QAAQ,CAAC,EAAW,IAAkB,CACnE,KAAM,GACJ,EAAU,mBAAmB,GAE/B,AAAI,EAA2B,QAC7B,GAA4B,GAC1B,KAGN,EAAS,OAAS,EAGf,EAAC,EAAS,KAAO,EAAS,IAAI,SAAW,IAC1C,CAAC,EAAS,IACT,EAAC,EAAS,QAAU,OAAO,KAAK,EAAS,QAAQ,SAAW,GAGtD,KAGF,EAGT,0BAA0B,EAA+B,CAQvD,GAPA,KAAK,mBACD,EAAS,KACX,KAAK,WAAW,0BAA0B,EAAS,KAEjD,EAAS,IACX,KAAK,YAAY,0BAA0B,EAAS,IAElD,EAAS,OACX,SAAW,KAAiB,GAAS,OAAQ,CAC3C,GAAI,CAAC,EAAS,OAAO,eAAe,GAClC,SAEF,KAAM,GAAyB,EAAS,OAAO,GACzC,EACJ,KAAK,yBAAyB,GAChC,AAAI,GACF,EAAmB,0BACjB,IAOF,kBAAyB,CAC/B,GAAI,KAAK,aACP,KAAM,qEAlyCL,EAAM,gBA1HL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Game manager');\n\n const sleep = (ms: float) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n /** Identify a script file, with its content hash (useful for hot-reloading). */\n export type RuntimeGameOptionsScriptFile = {\n /** The path for this script file. */\n path: string;\n /** The hash of the script file content. */\n hash: number;\n };\n\n const getGlobalResourceNames = (projectData: ProjectData): Array<string> =>\n projectData.usedResources.map((resource) => resource.name);\n\n let supportedCompressionMethods: ('cs:gzip' | 'cs:deflate')[] | null = null;\n const getSupportedCompressionMethods = (): ('cs:gzip' | 'cs:deflate')[] => {\n if (!!supportedCompressionMethods) {\n return supportedCompressionMethods;\n }\n supportedCompressionMethods = [];\n\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('gzip');\n supportedCompressionMethods.push('cs:gzip');\n } catch (e) {}\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('deflate');\n supportedCompressionMethods.push('cs:deflate');\n } catch (e) {}\n\n return supportedCompressionMethods;\n };\n\n /** Options given to the game at startup. */\n export type RuntimeGameOptions = {\n /** if true, force fullscreen. */\n forceFullscreen?: boolean;\n /** if true, game is run as a preview launched from an editor. */\n isPreview?: boolean;\n /** The name of the external layout to create in the scene at position 0;0. */\n injectExternalLayout?: string;\n /** Script files, used for hot-reloading. */\n scriptFiles?: Array<RuntimeGameOptionsScriptFile>;\n /** if true, export is a partial preview without events. */\n projectDataOnlyExport?: boolean;\n /** if true, preview is launched from GDevelop native mobile app. */\n nativeMobileApp?: boolean;\n /** The address of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerAddress?: string;\n /** The port of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerPort?: string;\n\n /**\n * The path to require `@electron/remote` module.\n * This is only useful in a preview, where this can't be required from\n * `@electron/remote` directly as previews don't have any node_modules.\n * On the contrary, a game packaged with Electron as a standalone app\n * has its node_modules.\n * This can be removed once there are no more dependencies on\n * `@electron/remote` in the game engine and extensions.\n */\n electronRemoteRequirePath?: string;\n\n /**\n * The token to use by the game engine when requiring any resource stored on\n * GDevelop Cloud buckets. Note that this is only useful during previews.\n */\n gdevelopResourceToken?: string;\n\n /**\n * Check if, in some exceptional cases, we allow authentication\n * to be done through a iframe.\n * This is usually discouraged as the user can't verify that the authentication\n * window is a genuine one. It's only to be used in trusted contexts.\n */\n allowAuthenticationUsingIframeForPreview?: boolean;\n\n /** If set, the game will send crash reports to GDevelop APIs. */\n crashReportUploadLevel?: 'all' | 'exclude-javascript-code-events' | 'none';\n\n /** Arbitrary string explaining in which context the game is being played. */\n previewContext?: string;\n\n /** The GDevelop version used to build the game. */\n gdevelopVersionWithHash?: string;\n\n /** The template slug that was used to create the project. */\n projectTemplateSlug?: string;\n\n /** The source game id that was used to create the project. */\n sourceGameId?: string;\n\n /** Any capture that should be done during the preview. */\n captureOptions?: CaptureOptions;\n\n /** Message to display to the user during an in-app tutorial. */\n inAppTutorialMessageInPreview?: string;\n inAppTutorialMessagePositionInPreview?: string;\n\n /**\n * If set, this data is used to authenticate automatically when launching the game.\n * This is only useful during previews.\n */\n playerUsername?: string;\n playerId?: string;\n playerToken?: string;\n\n /**\n * If set, the game should use the specified environment for making calls\n * to GDevelop APIs (\"dev\" = development APIs).\n */\n environment?: 'dev';\n };\n\n /**\n * Represents a game being played.\n */\n export class RuntimeGame {\n _resourcesLoader: gdjs.ResourceLoader;\n _variables: VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _data: ProjectData;\n _sceneAndExtensionsData: Array<SceneAndExtensionsData> = [];\n _eventsBasedObjectDatas: Map<String, EventsBasedObjectData>;\n _effectsManager: EffectsManager;\n _maxFPS: integer;\n _minFPS: integer;\n _gameResolutionWidth: integer;\n _gameResolutionHeight: integer;\n _originalWidth: float;\n _originalHeight: float;\n _resizeMode: 'adaptWidth' | 'adaptHeight' | string;\n _adaptGameResolutionAtRuntime: boolean;\n _scaleMode: 'linear' | 'nearest';\n _pixelsRounding: boolean;\n _antialiasingMode: 'none' | 'MSAA';\n _isAntialisingEnabledOnMobile: boolean;\n /**\n * Game loop management (see startGameLoop method)\n */\n _renderer: RuntimeGameRenderer;\n _sessionId: string | null;\n _playerId: string | null;\n _watermark: watermark.RuntimeWatermark;\n\n _sceneStack: SceneStack;\n /**\n * When set to true, the scenes are notified that game resolution size changed.\n */\n _notifyScenesForGameResolutionResize: boolean = false;\n\n /**\n * When paused, the game won't step and will be freezed. Useful for debugging.\n */\n _paused: boolean = false;\n\n /**\n * True during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n _hasJustResumed: boolean = false;\n\n //Inputs :\n _inputManager: InputManager;\n\n /**\n * Allow to specify an external layout to insert in the first scene.\n */\n _injectExternalLayout: any;\n _options: RuntimeGameOptions;\n\n /**\n * The mappings for embedded resources\n */\n _embeddedResourcesMappings: Map<string, Record<string, string>>;\n\n _sceneResourcesPreloading: 'at-startup' | 'never';\n _sceneResourcesUnloading: 'at-scene-exit' | 'never';\n\n /**\n * Optional client to connect to a debugger server.\n */\n _debuggerClient: gdjs.AbstractDebuggerClient | null;\n _sessionMetricsInitialized: boolean = false;\n _disableMetrics: boolean = false;\n _isPreview: boolean;\n\n /**\n * The capture manager, used to manage captures (screenshots, videos, etc...).\n */\n _captureManager: CaptureManager | null;\n\n /** True if the RuntimeGame has been disposed and should not be used anymore. */\n _wasDisposed: boolean = false;\n\n /**\n * @param data The object (usually stored in data.json) containing the full project data\n * @param options The game options\n */\n constructor(data: ProjectData, options?: RuntimeGameOptions) {\n this._options = options || {};\n this._variables = new gdjs.VariablesContainer(data.variables);\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n for (const extensionData of data.eventsFunctionsExtensions) {\n if (extensionData.globalVariables.length > 0) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.globalVariables)\n );\n }\n }\n this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();\n this._data = data;\n this._updateSceneAndExtensionsData();\n\n this._sceneResourcesPreloading =\n this._data.properties.sceneResourcesPreloading || 'at-startup';\n this._sceneResourcesUnloading =\n this._data.properties.sceneResourcesUnloading || 'never';\n\n this._resourcesLoader = new gdjs.ResourceLoader(\n this,\n data.resources.resources,\n getGlobalResourceNames(data),\n data.layouts\n );\n\n this._effectsManager = new gdjs.EffectsManager();\n this._maxFPS = this._data.properties.maxFPS;\n this._minFPS = this._data.properties.minFPS;\n this._gameResolutionWidth = this._data.properties.windowWidth;\n this._gameResolutionHeight = this._data.properties.windowHeight;\n this._originalWidth = this._gameResolutionWidth;\n this._originalHeight = this._gameResolutionHeight;\n this._resizeMode = this._data.properties.sizeOnStartupMode;\n this._adaptGameResolutionAtRuntime =\n this._data.properties.adaptGameResolutionAtRuntime;\n this._scaleMode = data.properties.scaleMode || 'linear';\n this._pixelsRounding = this._data.properties.pixelsRounding;\n this._antialiasingMode = this._data.properties.antialiasingMode;\n this._isAntialisingEnabledOnMobile =\n this._data.properties.antialisingEnabledOnMobile;\n\n this._renderer = new gdjs.RuntimeGameRenderer(\n this,\n this._options.forceFullscreen || false\n );\n this._watermark = new gdjs.watermark.RuntimeWatermark(\n this,\n data.properties.authorUsernames,\n this._data.properties.watermark\n );\n this._sceneStack = new gdjs.SceneStack(this);\n this._inputManager = new gdjs.InputManager();\n this._injectExternalLayout = this._options.injectExternalLayout || '';\n this._debuggerClient = gdjs.DebuggerClient\n ? new gdjs.DebuggerClient(this)\n : null;\n this._captureManager = gdjs.CaptureManager\n ? new gdjs.CaptureManager(\n this._renderer,\n this._options.captureOptions || {}\n )\n : null;\n this._isPreview = this._options.isPreview || false;\n this._sessionId = null;\n this._playerId = null;\n\n this._embeddedResourcesMappings = new Map();\n for (const resource of this._data.resources.resources) {\n if (resource.metadata) {\n try {\n const metadata = JSON.parse(resource.metadata);\n if (metadata?.embeddedResourcesMapping) {\n this._embeddedResourcesMappings.set(\n resource.name,\n metadata.embeddedResourcesMapping\n );\n }\n } catch {\n logger.error(\n 'Some metadata of resources can not be successfully parsed.'\n );\n }\n }\n }\n\n if (this.isUsingGDevelopDevelopmentEnvironment()) {\n logger.info(\n 'This game will run on the development version of GDevelop APIs.'\n );\n }\n }\n\n /**\n * Update the project data. Useful for hot-reloading, should not be used otherwise.\n *\n * @param projectData The object (usually stored in data.json) containing the full project data\n */\n setProjectData(projectData: ProjectData): void {\n this._data = projectData;\n this._updateSceneAndExtensionsData();\n this._resourcesLoader.setResources(\n projectData.resources.resources,\n getGlobalResourceNames(projectData),\n projectData.layouts\n );\n }\n\n private _updateSceneAndExtensionsData(): void {\n const usedExtensionsWithVariablesData =\n this._data.eventsFunctionsExtensions.filter(\n (extensionData) => extensionData.sceneVariables.length > 0\n );\n this._sceneAndExtensionsData = this._data.layouts.map((sceneData) => ({\n sceneData,\n usedExtensionsWithVariablesData,\n }));\n\n this._eventsBasedObjectDatas.clear();\n if (this._data.eventsFunctionsExtensions) {\n for (const extension of this._data.eventsFunctionsExtensions) {\n for (const eventsBasedObject of extension.eventsBasedObjects) {\n this._eventsBasedObjectDatas.set(\n extension.name + '::' + eventsBasedObject.name,\n eventsBasedObject\n );\n }\n }\n }\n }\n\n /**\n * Return the additional options passed to the RuntimeGame when created.\n * @returns The additional options, if any.\n */\n getAdditionalOptions(): RuntimeGameOptions {\n return this._options;\n }\n\n getRenderer(): gdjs.RuntimeGameRenderer {\n return this._renderer;\n }\n\n /**\n * Get the variables of the RuntimeGame.\n * @return The global variables\n */\n getVariables(): gdjs.VariablesContainer {\n return this._variables;\n }\n\n /**\n * Get the extension's global variables.\n * @param extensionName The extension name.\n * @returns The extension's global variables.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the gdjs.ResourceLoader of the RuntimeGame.\n * @return The resource loader.\n */\n getResourceLoader(): gdjs.ResourceLoader {\n return this._resourcesLoader;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._resourcesLoader.getSoundManager();\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._resourcesLoader.getImageManager();\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._resourcesLoader.getFontManager();\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._resourcesLoader.getBitmapFontManager();\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._resourcesLoader.getJsonManager();\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._resourcesLoader.getModel3DManager();\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._resourcesLoader.getSpineManager();\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._resourcesLoader.getSpineAtlasManager();\n }\n\n /**\n * Get the input manager of the game, storing mouse, keyboard\n * and touches states.\n * @return The input manager owned by the game\n */\n getInputManager(): gdjs.InputManager {\n return this._inputManager;\n }\n\n /**\n * Get the effects manager of the game, which allows to manage\n * effects on runtime objects or runtime layers.\n * @return The effects manager for the game\n */\n getEffectsManager(): gdjs.EffectsManager {\n return this._effectsManager;\n }\n\n /**\n * Get the object containing the game data\n * @return The object associated to the game.\n */\n getGameData(): ProjectData {\n return this._data;\n }\n\n getEventsBasedObjectData(type: string): EventsBasedObjectData | null {\n const eventsBasedObjectData = this._eventsBasedObjectDatas.get(type);\n if (!eventsBasedObjectData) {\n logger.error(\n 'The game has no events-based object of the type \"' + type + '\"'\n );\n return null;\n }\n return eventsBasedObjectData;\n }\n\n /**\n * Get the data associated to a scene.\n *\n * @param sceneName The name of the scene. If not defined, the first scene will be returned.\n * @return The data associated to the scene.\n */\n getSceneAndExtensionsData(\n sceneName?: string\n ): SceneAndExtensionsData | null {\n for (let i = 0, len = this._sceneAndExtensionsData.length; i < len; ++i) {\n const sceneAndExtensionsData = this._sceneAndExtensionsData[i];\n if (\n sceneName === undefined ||\n sceneAndExtensionsData.sceneData.name === sceneName\n ) {\n return sceneAndExtensionsData;\n }\n }\n logger.error('The game has no scene called \"' + sceneName + '\"');\n return null;\n }\n\n /**\n * Check if a scene exists\n *\n * @param sceneName The name of the scene to search.\n * @return true if the scene exists. If sceneName is undefined, true if the game has a scene.\n */\n hasScene(sceneName?: string): boolean {\n for (let i = 0, len = this._data.layouts.length; i < len; ++i) {\n const sceneData = this._data.layouts[i];\n if (sceneName === undefined || sceneData.name == sceneName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Get the data associated to an external layout.\n *\n * @param name The name of the external layout.\n * @return The data associated to the external layout or null if not found.\n */\n getExternalLayoutData(name: string): ExternalLayoutData | null {\n let externalLayout: ExternalLayoutData | null = null;\n for (let i = 0, len = this._data.externalLayouts.length; i < len; ++i) {\n const layoutData = this._data.externalLayouts[i];\n if (layoutData.name === name) {\n externalLayout = layoutData;\n break;\n }\n }\n return externalLayout;\n }\n\n /**\n * Get the data representing all the global objects of the game.\n * @return The data associated to the global objects.\n */\n getInitialObjectsData(): ObjectData[] {\n return this._data.objects || [];\n }\n\n /**\n * Get the original width of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalWidth(): float {\n return this._originalWidth;\n }\n\n /**\n * Get the original height of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalHeight(): float {\n return this._originalHeight;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) width.\n * @returns The game resolution width, in pixels.\n */\n getGameResolutionWidth(): float {\n return this._gameResolutionWidth;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) height.\n * @returns The game resolution height, in pixels.\n */\n getGameResolutionHeight(): float {\n return this._gameResolutionHeight;\n }\n\n /**\n * Change the game resolution.\n *\n * @param width The new width\n * @param height The new height\n */\n setGameResolutionSize(width: float, height: float): void {\n this._throwIfDisposed();\n\n this._gameResolutionWidth = width;\n this._gameResolutionHeight = height;\n if (this._adaptGameResolutionAtRuntime) {\n if (\n gdjs.RuntimeGameRenderer &&\n gdjs.RuntimeGameRenderer.getWindowInnerWidth &&\n gdjs.RuntimeGameRenderer.getWindowInnerHeight\n ) {\n const windowInnerWidth =\n gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight =\n gdjs.RuntimeGameRenderer.getWindowInnerHeight();\n\n // Enlarge either the width or the eight to fill the inner window space.\n if (this._resizeMode === 'adaptWidth') {\n this._gameResolutionWidth =\n (this._gameResolutionHeight * windowInnerWidth) /\n windowInnerHeight;\n } else if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n } else if (this._resizeMode === 'scaleOuter') {\n const widthFactor = windowInnerWidth / this._originalWidth;\n const heightFactor = windowInnerHeight / this._originalHeight;\n\n if (widthFactor < heightFactor) {\n this._gameResolutionWidth = this._originalWidth;\n this._gameResolutionHeight = Math.floor(\n windowInnerHeight / widthFactor\n );\n } else {\n this._gameResolutionWidth = Math.floor(\n windowInnerWidth / heightFactor\n );\n this._gameResolutionHeight = this._originalHeight;\n }\n }\n }\n }\n\n // Don't alter the game resolution. The renderer\n // will maybe adapt the size of the canvas or whatever is used to render the\n // game in the window, but this does not change the \"game resolution\".\n\n // Notify the renderer that game resolution changed (so that the renderer size\n // can be updated, and maybe other things like the canvas size), and let the\n // scenes know too.\n this._renderer.updateRendererSize();\n this._notifyScenesForGameResolutionResize = true;\n }\n\n /**\n * Set if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically.\n *\n * @param resizeMode Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n setGameResolutionResizeMode(resizeMode: string): void {\n this._resizeMode = resizeMode;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically (empty string).\n *\n * @returns Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n getGameResolutionResizeMode(): string {\n return this._resizeMode;\n }\n\n /**\n * Set if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @param enable true to change the game resolution according to the window/screen size.\n */\n setAdaptGameResolutionAtRuntime(enable: boolean): void {\n this._adaptGameResolutionAtRuntime = enable;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @returns true if the game resolution is automatically changed according to the window/screen size.\n */\n getAdaptGameResolutionAtRuntime(): boolean {\n return this._adaptGameResolutionAtRuntime;\n }\n\n /**\n * Return the minimal fps that must be guaranteed by the game\n * (otherwise, game is slowed down).\n */\n getMinimalFramerate(): integer {\n return this._minFPS;\n }\n\n /**\n * Return the scale mode of the game (\"linear\" or \"nearest\").\n */\n getScaleMode(): 'linear' | 'nearest' {\n return this._scaleMode;\n }\n\n /**\n * Return if the game is rounding pixels when rendering.\n */\n getPixelsRounding(): boolean {\n return this._pixelsRounding;\n }\n\n /**\n * Return the antialiasing mode used by the game (\"none\" or \"MSAA\").\n */\n getAntialiasingMode(): 'none' | 'MSAA' {\n return this._antialiasingMode;\n }\n\n /**\n * Return true if antialising is enabled on mobiles.\n */\n isAntialisingEnabledOnMobile(): boolean {\n return this._isAntialisingEnabledOnMobile;\n }\n\n /**\n * Set or unset the game as paused.\n * When paused, the game won't step and will be freezed. Useful for debugging.\n * @param enable true to pause the game, false to unpause\n */\n pause(enable: boolean) {\n if (this._paused === enable) return;\n\n this._paused = enable;\n if (this._debuggerClient) {\n if (this._paused) this._debuggerClient.sendGamePaused();\n else this._debuggerClient.sendGameResumed();\n }\n }\n\n /**\n * @returns true during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n hasJustResumed() {\n return this._hasJustResumed;\n }\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n prioritizeLoadingOfScene(sceneName: string) {\n // Don't await the scene assets to be loaded.\n this._resourcesLoader.loadSceneResources(sceneName);\n }\n\n /**\n * @return The progress of assets loading in background for a scene\n * (between 0 and 1).\n */\n getSceneLoadingProgress(sceneName: string): number {\n return this._resourcesLoader.getSceneLoadingProgress(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsLoaded(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsReady(sceneName);\n }\n\n /**\n * Returns the scene resources preloading mode.\n * It can be overriden by each scene.\n */\n getSceneResourcesPreloading(): 'at-startup' | 'never' {\n return this._sceneResourcesPreloading;\n }\n\n /**\n * Returns the scene resources unloading mode.\n * It can be overriden by each scene.\n */\n getSceneResourcesUnloading(): 'at-scene-exit' | 'never' {\n return this._sceneResourcesUnloading;\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n */\n loadAllAssets(\n callback: () => void,\n progressCallback?: (progress: float) => void\n ) {\n this._throwIfDisposed();\n this.loadFirstAssetsAndStartBackgroundLoading(\n this._getFirstSceneName(),\n progressCallback\n ).then(callback);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n *\n * When a game is hot-reload, this method can be called with the current\n * scene.\n */\n async loadFirstAssetsAndStartBackgroundLoading(\n firstSceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n try {\n // Download the loading screen background image first to be able to\n // display the loading screen as soon as possible.\n const backgroundImageResourceName =\n this._data.properties.loadingScreen.backgroundImageResourceName;\n if (backgroundImageResourceName) {\n await this._resourcesLoader\n .getImageManager()\n .loadResource(backgroundImageResourceName);\n }\n await Promise.all([\n this._loadAssetsWithLoadingScreen(\n /* isFirstScene = */ true,\n async (onProgress) => {\n // TODO Is a setting needed?\n if (false) {\n await this._resourcesLoader.loadAllResources(onProgress);\n } else {\n await this._resourcesLoader.loadGlobalAndFirstSceneResources(\n firstSceneName,\n onProgress\n );\n // Don't await as it must not block the first scene from starting.\n this._resourcesLoader.loadAllSceneInBackground();\n }\n },\n progressCallback\n ),\n // TODO This is probably not necessary in case of hot reload.\n gdjs.getAllAsynchronouslyLoadingLibraryPromise(),\n ]);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Load all assets for a given scene, displaying progress in renderer.\n */\n async loadSceneAssets(\n sceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n await this._loadAssetsWithLoadingScreen(\n /* isFirstLayout = */ false,\n async (onProgress) => {\n await this._resourcesLoader.loadAndProcessSceneResources(\n sceneName,\n onProgress\n );\n },\n progressCallback\n );\n }\n\n /**\n * Load assets, displaying progress in renderer.\n */\n private async _loadAssetsWithLoadingScreen(\n isFirstScene: boolean,\n loadAssets: (\n onProgress: (count: integer, total: integer) => Promise<void>\n ) => Promise<void>,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n this.pause(true);\n const loadingScreen = new gdjs.LoadingScreenRenderer(\n this.getRenderer(),\n this._resourcesLoader.getImageManager(),\n this._data.properties.loadingScreen,\n this._data.properties.watermark.showWatermark,\n isFirstScene\n );\n\n const onProgress = async (count: integer, total: integer) => {\n const percent = Math.floor((100 * count) / total);\n loadingScreen.setPercent(percent);\n if (progressCallback) {\n progressCallback(percent);\n }\n const hasRendered = loadingScreen.renderIfNeeded();\n if (hasRendered) {\n // Give a chance to draw calls from the renderer to be handled.\n await sleep(1);\n }\n };\n await loadAssets(onProgress);\n\n await loadingScreen.unload();\n this.pause(false);\n }\n\n private _getFirstSceneName(): string {\n const firstSceneName = this._data.firstLayout;\n return this.hasScene(firstSceneName)\n ? firstSceneName\n : // There is always at least a scene\n this.getSceneAndExtensionsData()!.sceneData.name;\n }\n\n /**\n * Start the game loop, to be called once assets are loaded.\n */\n startGameLoop() {\n this._throwIfDisposed();\n try {\n if (!this.hasScene()) {\n logger.error('The game has no scene.');\n return;\n }\n this._forceGameResolutionUpdate();\n\n // Load the first scene\n this._sceneStack.push(\n this._getFirstSceneName(),\n this._injectExternalLayout\n );\n this._watermark.displayAtStartup();\n\n //Uncomment to profile the first x frames of the game.\n // var x = 500;\n // var startTime = Date.now();\n // console.profile(\"Stepping for \" + x + \" frames\")\n // for(var i = 0; i < x; ++i) {\n // this._sceneStack.step(16);\n // }\n // console.profileEnd();\n // var time = Date.now() - startTime;\n // logger.log(\"Took\", time, \"ms\");\n // return;\n\n this._setupGameVisibilityEvents();\n\n if (gdjs.inAppTutorialMessage) {\n gdjs.inAppTutorialMessage.displayInAppTutorialMessage(\n this,\n this._options.inAppTutorialMessageInPreview,\n this._options.inAppTutorialMessagePositionInPreview || ''\n );\n }\n\n // The standard game loop\n let accumulatedElapsedTime = 0;\n this._hasJustResumed = false;\n this._renderer.startGameLoop((lastCallElapsedTime) => {\n try {\n if (this._paused) {\n return true;\n }\n\n // Skip the frame if we rendering frames too fast\n accumulatedElapsedTime += lastCallElapsedTime;\n if (\n this._maxFPS > 0 &&\n 1000.0 / accumulatedElapsedTime > this._maxFPS + 7\n ) {\n // Only skip frame if the framerate is 7 frames above the maximum framerate.\n // Most browser/engines will try to run at slightly more than 60 frames per second.\n // If game is set to have a maximum FPS to 60, then one out of two frames will be dropped.\n // Hence, we use a 7 frames margin to ensure that we're not skipping frames too much.\n return true;\n }\n const elapsedTime = accumulatedElapsedTime;\n accumulatedElapsedTime = 0;\n\n // Manage resize events.\n if (this._notifyScenesForGameResolutionResize) {\n this._sceneStack.onGameResolutionResized();\n this._notifyScenesForGameResolutionResize = false;\n }\n\n // Render and step the scene.\n if (this._sceneStack.step(elapsedTime)) {\n this.getInputManager().onFrameEnded();\n this._hasJustResumed = false;\n return true;\n }\n return false;\n } catch (e) {\n if (this._debuggerClient)\n this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n });\n setTimeout(() => {\n this._setupSessionMetrics();\n }, 4000);\n if (this._captureManager) {\n this._captureManager.setupCaptureOptions(this._isPreview);\n }\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Stop game loop, unload all scenes, dispose renderer and resources.\n * After calling this method, the RuntimeGame should not be used anymore.\n * @param removeCanvas If true, the canvas will be removed from the DOM.\n */\n dispose(removeCanvas?: boolean): void {\n this._renderer.stopGameLoop();\n this._sceneStack.dispose();\n this._renderer.dispose(removeCanvas);\n this._resourcesLoader.dispose();\n\n this._wasDisposed = true;\n }\n\n /**\n * Set if the session should be registered.\n */\n enableMetrics(enable: boolean): void {\n this._disableMetrics = !enable;\n if (enable) {\n this._setupSessionMetrics();\n }\n }\n\n /**\n * Helper function to get information about the platform running the game.\n */\n getPlatformInfo = () => {\n return {\n // @ts-ignore\n isCordova: !!window.cordova,\n devicePlatform:\n // @ts-ignore\n typeof device !== 'undefined' ? device.platform || '' : '',\n navigatorPlatform:\n typeof navigator !== 'undefined' ? navigator.platform : '',\n hasTouch:\n typeof navigator !== 'undefined'\n ? !!navigator.maxTouchPoints && navigator.maxTouchPoints > 2\n : false,\n supportedCompressionMethods: getSupportedCompressionMethods(),\n };\n };\n\n _setupGameVisibilityEvents() {\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this._hasJustResumed = true;\n }\n });\n window.addEventListener(\n 'resume',\n () => {\n this._hasJustResumed = true;\n },\n false\n );\n }\n }\n\n /**\n * Register a new session for the game, and set up listeners to follow the session\n * time.\n */\n _setupSessionMetrics() {\n if (this._sessionMetricsInitialized) {\n return;\n }\n if (this._disableMetrics) {\n return;\n }\n if (this.isPreview()) {\n return;\n }\n if (typeof fetch === 'undefined') {\n return;\n }\n if (!this._data.properties.projectUuid) {\n return;\n }\n const baseUrl = 'https://api.gdevelop-app.com/analytics';\n this._playerId = this._makePlayerUuid();\n /**\n * The duration that is already sent to the service\n * (in milliseconds).\n **/\n let sentDuration = 0;\n /**\n * The duration that is not yet sent to the service to avoid flooding\n * (in milliseconds).\n **/\n let notYetSentDuration = 0;\n /**\n * The last time when duration has been counted\n * either in sendedDuration or notYetSentDuration.\n **/\n let lastSessionResumeTime = Date.now();\n const platform = this.getPlatformInfo();\n fetch(baseUrl + '/session', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n // It's important to ensure that the data sent here does not contain\n // any personal information from the player or that would allow to\n // precisely identify someone.\n body: JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n game: {\n name: this._data.properties.name || '',\n packageName: this._data.properties.packageName || '',\n version: this._data.properties.version || '',\n location: window.location.href,\n },\n platform: {\n isCordova: platform.isCordova,\n devicePlatform: platform.devicePlatform,\n navigatorPlatform: platform.navigatorPlatform,\n hasTouch: platform.hasTouch,\n },\n }),\n })\n .then((response) => {\n // Ensure the session is correctly created to avoid sending hits that will fail.\n if (!response.ok) {\n console.error('Error while creating the session', response);\n throw new Error('Error while creating the session');\n }\n return response;\n })\n .then((response) => response.text())\n .then((returnedSessionId) => {\n this._sessionId = returnedSessionId;\n })\n .catch(() => {});\n\n /* Ignore any error */\n const sendSessionHit = () => {\n if (!this._sessionId) {\n return;\n }\n\n const now = Date.now();\n notYetSentDuration += now - lastSessionResumeTime;\n lastSessionResumeTime = now;\n\n // Group repeated calls to sendSessionHit - which could\n // happen because of multiple event listeners being fired.\n if (notYetSentDuration < 5 * 1000) {\n return;\n }\n // The backend use seconds for duration.\n // The milliseconds will stay in notYetSentDuration.\n const toBeSentDuration = Math.floor(notYetSentDuration / 1000) * 1000;\n sentDuration += toBeSentDuration;\n notYetSentDuration -= toBeSentDuration;\n\n navigator.sendBeacon(\n baseUrl + '/session-hit',\n JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n sessionId: this._sessionId,\n duration: Math.floor(sentDuration / 1000),\n })\n );\n };\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n } else {\n sendSessionHit();\n }\n });\n window.addEventListener('pagehide', sendSessionHit, false);\n // Cordova events\n window.addEventListener('pause', sendSessionHit, false);\n window.addEventListener(\n 'resume',\n () => {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n },\n false\n );\n\n // Detect Safari to work around Safari-specific bugs:\n // - https://bugs.webkit.org/show_bug.cgi?id=151610\n // - https://bugs.webkit.org/show_bug.cgi?id=151234\n // @ts-ignore\n const isSafari = typeof safari === 'object' && safari.pushNotification;\n const isElectron = /electron/i.test(navigator.userAgent);\n if (isSafari || isElectron) {\n window.addEventListener('beforeunload', () => {\n sendSessionHit();\n });\n }\n }\n this._sessionMetricsInitialized = true;\n this._sessionId = this._sessionId;\n }\n\n /**\n * Generate an anonymous unique identifier to differentiate\n * the player from others in the game metrics.\n */\n _makePlayerUuid(): string {\n try {\n const key = 'GDJS-internal-player-uuid';\n const existingPlayerUuid = localStorage.getItem(key);\n if (existingPlayerUuid) {\n return existingPlayerUuid;\n }\n const newPlayerUuid = gdjs.makeUuid();\n localStorage.setItem(key, newPlayerUuid);\n return newPlayerUuid;\n } catch (err) {\n return gdjs.makeUuid();\n }\n }\n\n getSessionId(): string | null {\n return this._sessionId;\n }\n\n getPlayerId(): string | null {\n return this._playerId;\n }\n\n /**\n * Called by the game renderer when the window containing the game\n * has changed size (this can result from a resize of the window,\n * but also other factors like a device orientation change on mobile).\n */\n onWindowInnerSizeChanged() {\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Enlarge/reduce the width (or the height) of the game to fill the inner window.\n */\n private _forceGameResolutionUpdate() {\n this.setGameResolutionSize(\n this._gameResolutionWidth,\n this._gameResolutionHeight\n );\n }\n\n /**\n * Start a profiler for the currently running scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startCurrentSceneProfiler(\n onProfilerStopped: (oldProfiler: Profiler) => void\n ) {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return false;\n }\n currentScene.startProfiler(onProfilerStopped);\n return true;\n }\n\n /**\n * Stop the profiler for the currently running scene.\n */\n stopCurrentSceneProfiler() {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return;\n }\n currentScene.stopProfiler();\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._sceneStack.wasFirstSceneLoaded();\n }\n\n /**\n * Return the stack of {@link gdjs.RuntimeScene} being played.\n */\n getSceneStack(): gdjs.SceneStack {\n return this._sceneStack;\n }\n\n /**\n * Check if the game is running as a preview, launched from an editor.\n * @returns true if the current game is a preview.\n */\n isPreview(): boolean {\n return this._isPreview;\n }\n\n /**\n * Check if the game should call GDevelop development APIs or not.\n *\n * Unless you are contributing to GDevelop, avoid using this.\n */\n isUsingGDevelopDevelopmentEnvironment(): boolean {\n return this._options.environment === 'dev';\n }\n\n /**\n * Gets an extension property from the project data.\n * @param extensionName The extension name.\n * @param propertyName The property name.\n * @return The property value.\n */\n getExtensionProperty(\n extensionName: string,\n propertyName: string\n ): string | null {\n for (let property of this._data.properties.extensionProperties) {\n if (\n property.extension === extensionName &&\n property.property === propertyName\n ) {\n return property.value;\n }\n }\n return null;\n }\n\n /**\n * Resolves the name of an embedded resource.\n * @param mainResourceName The name of the resource containing the embedded resource.\n * @param embeddedResourceName The name of the embedded resource.\n * @return The resource name.\n */\n resolveEmbeddedResource(\n mainResourceName: string,\n embeddedResourceName: string\n ): string {\n const mapping = this._embeddedResourcesMappings.get(mainResourceName);\n return mapping && mapping[embeddedResourceName]\n ? mapping[embeddedResourceName]\n : embeddedResourceName;\n }\n\n /**\n * Returns the array of resources that are embedded to passed one.\n * @param resourceName The name of resource to find embedded resources of.\n * @returns The array of related resources names.\n */\n getEmbeddedResourcesNames(resourceName: string): string[] {\n return this._embeddedResourcesMappings.has(resourceName)\n ? Object.keys(this._embeddedResourcesMappings.get(resourceName)!)\n : [];\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): GameNetworkSyncData | null {\n const syncData: GameNetworkSyncData = {\n var:\n syncOptions.syncGameVariables === false\n ? undefined\n : this._variables.getNetworkSyncData(syncOptions),\n sm: syncOptions.syncSounds\n ? this.getSoundManager().getNetworkSyncData()\n : undefined,\n ss: this._sceneStack.getNetworkSyncData(syncOptions) || undefined,\n };\n\n if (syncOptions.syncGameVariables !== false) {\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData =\n variables.getNetworkSyncData(syncOptions);\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[extensionName] =\n extensionVariablesSyncData;\n }\n });\n syncData.extVar = extensionsVariablesSyncData;\n }\n\n if (\n (!syncData.var || syncData.var.length === 0) &&\n !syncData.ss &&\n (!syncData.extVar || Object.keys(syncData.extVar).length === 0)\n ) {\n // Nothing to sync.\n return null;\n }\n\n return syncData;\n }\n\n updateFromNetworkSyncData(\n syncData: GameNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ) {\n this._throwIfDisposed();\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var, options);\n }\n if (syncData.sm) {\n this.getSoundManager().updateFromNetworkSyncData(syncData.sm);\n }\n if (syncData.ss) {\n this._sceneStack.updateFromNetworkSyncData(syncData.ss);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables =\n this.getVariablesForExtension(extensionName);\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData,\n options\n );\n }\n }\n }\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The RuntimeGame has been disposed and should not be used anymore.';\n }\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,gBAEzB,EAAQ,AAAC,GACb,GAAI,SAAQ,AAAC,GAAY,WAAW,EAAS,IAUzC,EAAyB,AAAC,GAC9B,EAAY,cAAc,IAAI,AAAC,GAAa,EAAS,MAEvD,GAAI,GAAmE,KACvE,KAAM,GAAiC,IAAoC,CACzE,GAAM,EACJ,MAAO,GAET,EAA8B,GAE9B,GAAI,CAEF,GAAI,mBAAkB,QACtB,EAA4B,KAAK,gBACjC,EACF,GAAI,CAEF,GAAI,mBAAkB,WACtB,EAA4B,KAAK,mBACjC,EAEF,MAAO,IAuFF,OAAkB,CAkFvB,YAAY,EAAmB,EAA8B,CA7E7D,6BAAyD,GA2BzD,0CAAgD,GAKhD,aAAmB,GAMnB,qBAA2B,GAuB3B,gCAAsC,GACtC,qBAA2B,GAS3B,kBAAwB,GAi1BxB,qBAAkB,IACT,EAEL,UAAW,CAAC,CAAC,OAAO,QACpB,eAEE,MAAO,SAAW,aAAc,OAAO,UAAY,GACrD,kBACE,MAAO,YAAc,YAAc,UAAU,SAAW,GAC1D,SACE,MAAO,YAAc,YACjB,CAAC,CAAC,UAAU,gBAAkB,UAAU,eAAiB,EACzD,GACN,4BAA6B,MAv1B/B,KAAK,SAAW,GAAW,GAC3B,KAAK,WAAa,GAAI,GAAK,mBAAmB,EAAK,WACnD,KAAK,0BAA4B,GAAI,KAIrC,SAAW,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