gdcore-tools 2.0.0-beta5 → 2.0.0-beta7

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 (170) hide show
  1. package/dist/Runtime/Cordova/config.xml +4 -0
  2. package/dist/Runtime/Cordova/package.json +12 -20
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
  10. package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  12. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  13. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  14. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
  16. package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
  17. package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
  18. package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
  19. package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
  20. package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
  21. package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
  22. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  23. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  24. package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
  25. package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
  26. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
  27. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  28. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  29. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  30. package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
  31. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  32. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
  34. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  35. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/JsExtension.js +2 -2
  37. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
  38. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  39. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
  40. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  41. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
  42. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  43. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
  44. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  45. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
  46. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  47. package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
  48. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
  49. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
  50. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
  51. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
  52. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  53. package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
  54. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
  55. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  56. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +112 -7
  57. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  58. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  59. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
  60. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
  61. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  62. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  63. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
  64. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  65. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
  66. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  67. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  68. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  69. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
  70. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  71. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  72. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +127 -40
  74. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  75. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  76. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  77. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  78. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  79. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  80. package/dist/Runtime/Extensions/Spine/JsExtension.js +77 -36
  81. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js +1 -1
  82. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
  83. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  84. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  85. package/dist/Runtime/Extensions/TextInput/JsExtension.js +55 -56
  86. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  87. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  88. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  89. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  90. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
  91. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  92. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  93. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  94. package/dist/Runtime/Extensions/TileMap/JsExtension.js +511 -287
  95. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
  96. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  97. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
  98. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  99. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  100. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  101. package/dist/Runtime/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map +1 -1
  102. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +12 -1
  103. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
  104. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
  105. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
  106. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
  107. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  108. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  109. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  110. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  111. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  112. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  113. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  114. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  115. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  116. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  117. package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -0
  118. package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
  119. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  120. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  121. package/dist/Runtime/ResourceLoader.js +1 -1
  122. package/dist/Runtime/ResourceLoader.js.map +2 -2
  123. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  124. package/dist/Runtime/SpriteAnimator.js +1 -1
  125. package/dist/Runtime/SpriteAnimator.js.map +2 -2
  126. package/dist/Runtime/debugger-client/InGameDebugger.js +1 -1
  127. package/dist/Runtime/debugger-client/InGameDebugger.js.map +2 -2
  128. package/dist/Runtime/debugger-client/abstract-debugger-client.js +1 -1
  129. package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
  130. package/dist/Runtime/debugger-client/hot-reloader.js +2 -1
  131. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  132. package/dist/Runtime/debugger-client/minimal-debugger-client.js +2 -0
  133. package/dist/Runtime/debugger-client/minimal-debugger-client.js.map +7 -0
  134. package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
  135. package/dist/Runtime/debugger-client/window-message-debugger-client.js.map +2 -2
  136. package/dist/Runtime/events-tools/inputtools.js +1 -1
  137. package/dist/Runtime/events-tools/inputtools.js.map +2 -2
  138. package/dist/Runtime/events-tools/objecttools.js +1 -1
  139. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  140. package/dist/Runtime/gd.js +1 -1
  141. package/dist/Runtime/gd.js.map +2 -2
  142. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  143. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  144. package/dist/Runtime/inputmanager.js +1 -1
  145. package/dist/Runtime/inputmanager.js.map +2 -2
  146. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  147. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  148. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
  149. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  150. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  151. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  152. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
  153. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  154. package/dist/Runtime/runtimegame.js +1 -1
  155. package/dist/Runtime/runtimegame.js.map +2 -2
  156. package/dist/Runtime/runtimeobject.js +1 -1
  157. package/dist/Runtime/runtimeobject.js.map +2 -2
  158. package/dist/Runtime/runtimescene.js +1 -1
  159. package/dist/Runtime/runtimescene.js.map +2 -2
  160. package/dist/Runtime/scenestack.js +1 -1
  161. package/dist/Runtime/scenestack.js.map +2 -2
  162. package/dist/Runtime/spriteruntimeobject.js +1 -1
  163. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  164. package/dist/Runtime/types/project-data.d.ts +36 -8
  165. package/dist/Runtime/variablescontainer.js +1 -1
  166. package/dist/Runtime/variablescontainer.js.map +2 -2
  167. package/dist/lib/libGD.cjs +1 -1
  168. package/dist/lib/libGD.wasm +0 -0
  169. package/gd.d.ts +149 -75
  170. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.ts"],
4
- "sourcesContent": ["namespace gdjs {\n export interface PixiImageManager {\n _pixiAnimationFrameTextureManager: PixiAnimationFrameTextureManager;\n }\n /**\n * The renderer for a gdjs.SpriteRuntimeObject using Pixi.js.\n */\n export class SpriteRuntimeObjectPixiRenderer {\n _object: gdjs.SpriteRuntimeObject;\n _spriteDirty: boolean = true;\n _textureDirty: boolean = true;\n _sprite: PIXI.Sprite;\n _cachedWidth: float = 0;\n _cachedHeight: float = 0;\n\n /**\n * @param runtimeObject The object\n * @param instanceContainer The scene\n */\n constructor(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n const imageManager = instanceContainer.getGame().getImageManager();\n this._sprite = new PIXI.Sprite(imageManager.getInvalidPIXITexture());\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n reinitialize(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._spriteDirty = true;\n this._textureDirty = true;\n this._sprite.tint = 0xffffff;\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n getRendererObject() {\n return this._sprite;\n }\n\n /**\n * Update the internal PIXI.Sprite position, angle...\n */\n _updatePIXISprite() {\n const animationFrame = this._object._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this._sprite.anchor.x =\n animationFrame.center.x / this._sprite.texture.frame.width;\n this._sprite.anchor.y =\n animationFrame.center.y / this._sprite.texture.frame.height;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(this._object._scaleX);\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(this._object._scaleY);\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n this._sprite.visible = !this._object.hidden;\n this._sprite.blendMode = this._object._blendMode;\n this._sprite.alpha = this._object.opacity / 255;\n this._sprite.scale.x = this._object._scaleX;\n this._sprite.scale.y = this._object._scaleY;\n this._cachedWidth = Math.abs(this._sprite.width);\n this._cachedHeight = Math.abs(this._sprite.height);\n } else {\n this._sprite.visible = false;\n this._sprite.alpha = 0;\n this._cachedWidth = 0;\n this._cachedHeight = 0;\n }\n this._spriteDirty = false;\n }\n\n /**\n * Call this to make sure the sprite is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n }\n\n /**\n * Update the internal texture of the PIXI sprite.\n */\n updateFrame(animationFrame: gdjs.SpriteAnimationFrame<PIXI.Texture>): void {\n this._spriteDirty = true;\n this._sprite.texture = animationFrame.texture;\n }\n\n update(): void {\n this._spriteDirty = true;\n }\n\n updateX(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(this._object._scaleX);\n }\n\n updateY(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(this._object._scaleY);\n }\n\n updateAngle(): void {\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n this._sprite.alpha = this._object.opacity / 255;\n }\n\n updateVisibility(): void {\n this._sprite.visible = !this._object.hidden;\n }\n\n setColor(rgbColor): void {\n const colors = rgbColor.split(';');\n if (colors.length < 3) {\n return;\n }\n this._sprite.tint = gdjs.rgbToHexNumber(\n parseInt(colors[0], 10),\n parseInt(colors[1], 10),\n parseInt(colors[2], 10)\n );\n }\n\n getColor() {\n const rgb = new PIXI.Color(this._sprite.tint).toRgbArray();\n return (\n Math.floor(rgb[0] * 255) +\n ';' +\n Math.floor(rgb[1] * 255) +\n ';' +\n Math.floor(rgb[2] * 255)\n );\n }\n\n getWidth(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedWidth;\n }\n\n getHeight(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedHeight;\n }\n\n getUnscaledWidth(): float {\n return this._sprite.texture.frame.width;\n }\n\n getUnscaledHeight(): float {\n return this._sprite.texture.frame.height;\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ): PixiAnimationFrameTextureManager {\n if (!imageManager._pixiAnimationFrameTextureManager) {\n imageManager._pixiAnimationFrameTextureManager = new PixiAnimationFrameTextureManager(\n imageManager\n );\n }\n return imageManager._pixiAnimationFrameTextureManager;\n }\n }\n\n class PixiAnimationFrameTextureManager\n implements gdjs.AnimationFrameTextureManager<PIXI.Texture> {\n private _imageManager: gdjs.PixiImageManager;\n\n constructor(imageManager: gdjs.PixiImageManager) {\n this._imageManager = imageManager;\n }\n\n getAnimationFrameTexture(imageName: string) {\n return this._imageManager.getPIXITexture(imageName);\n }\n\n getAnimationFrameWidth(pixiTexture: PIXI.Texture) {\n return pixiTexture.width;\n }\n\n getAnimationFrameHeight(pixiTexture: PIXI.Texture) {\n return pixiTexture.height;\n }\n }\n\n // Register the class to let the engine use it.\n export const SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n export type SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAOS,OAAsC,CAY3C,YACE,EACA,EACA,CAbF,kBAAwB,GACxB,mBAAyB,GAEzB,kBAAsB,EACtB,mBAAuB,EAUrB,KAAK,QAAU,EACf,KAAM,GAAe,EAAkB,UAAU,kBACjD,KAAK,QAAU,GAAI,MAAK,OAAO,EAAa,yBAC5C,KAAM,GAAQ,EAAkB,SAAS,IACzC,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,QAAS,EAAc,aAIrD,aACE,EACA,EACA,CACA,KAAK,QAAU,EACf,KAAK,aAAe,GACpB,KAAK,cAAgB,GACrB,KAAK,QAAQ,KAAO,SACpB,KAAM,GAAQ,EAAkB,SAAS,IACzC,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,QAAS,EAAc,aAIrD,mBAAoB,CAClB,MAAO,MAAK,QAMd,mBAAoB,CAClB,KAAM,GAAiB,KAAK,QAAQ,UAAU,kBAC9C,AAAI,IAAm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rameTextureManager: PixiAnimationFrameTextureManager;\n }\n /**\n * The renderer for a gdjs.SpriteRuntimeObject using Pixi.js.\n */\n export class SpriteRuntimeObjectPixiRenderer {\n _object: gdjs.SpriteRuntimeObject;\n _spriteDirty: boolean = true;\n _textureDirty: boolean = true;\n _sprite: PIXI.Sprite;\n _cachedWidth: float = 0;\n _cachedHeight: float = 0;\n\n /**\n * @param runtimeObject The object\n * @param instanceContainer The scene\n */\n constructor(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n const imageManager = instanceContainer.getGame().getImageManager();\n this._sprite = new PIXI.Sprite(imageManager.getInvalidPIXITexture());\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n reinitialize(\n runtimeObject: gdjs.SpriteRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._spriteDirty = true;\n this._textureDirty = true;\n this._sprite.tint = 0xffffff;\n const layer = instanceContainer.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._sprite, runtimeObject.getZOrder());\n }\n }\n\n getRendererObject() {\n return this._sprite;\n }\n\n /**\n * Update the internal PIXI.Sprite position, angle...\n */\n _updatePIXISprite() {\n const animationFrame = this._object._animator.getCurrentFrame();\n if (animationFrame !== null) {\n const scaleX = this._object._scaleX * this._object._preScale;\n const scaleY = this._object._scaleY * this._object._preScale;\n this._sprite.anchor.x =\n animationFrame.center.x / this._sprite.texture.frame.width;\n this._sprite.anchor.y =\n animationFrame.center.y / this._sprite.texture.frame.height;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(scaleX);\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(scaleY);\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n this._sprite.visible = !this._object.hidden;\n this._sprite.blendMode = this._object._blendMode;\n this._sprite.alpha = this._object.opacity / 255;\n this._sprite.scale.x = scaleX;\n this._sprite.scale.y = scaleY;\n this._cachedWidth = Math.abs(this._sprite.width);\n this._cachedHeight = Math.abs(this._sprite.height);\n } else {\n this._sprite.visible = false;\n this._sprite.alpha = 0;\n this._cachedWidth = 0;\n this._cachedHeight = 0;\n }\n this._spriteDirty = false;\n }\n\n /**\n * Call this to make sure the sprite is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n }\n\n /**\n * Update the internal texture of the PIXI sprite.\n */\n updateFrame(animationFrame: gdjs.SpriteAnimationFrame<PIXI.Texture>): void {\n this._spriteDirty = true;\n this._sprite.texture = animationFrame.texture;\n }\n\n update(): void {\n this._spriteDirty = true;\n }\n\n updateX(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.x =\n this._object.x +\n (animationFrame.center.x - animationFrame.origin.x) *\n Math.abs(this._object._scaleX * this._object._preScale);\n }\n\n updateY(): void {\n const animationFrame = this._object._animator.getCurrentFrame() as SpriteAnimationFrame<\n PIXI.Texture\n >;\n this._sprite.position.y =\n this._object.y +\n (animationFrame.center.y - animationFrame.origin.y) *\n Math.abs(this._object._scaleY * this._object._preScale);\n }\n\n updateAngle(): void {\n this._sprite.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n this._sprite.alpha = this._object.opacity / 255;\n }\n\n updateVisibility(): void {\n this._sprite.visible = !this._object.hidden;\n }\n\n setColor(rgbOrHexColor): void {\n this._sprite.tint = gdjs.rgbOrHexStringToNumber(rgbOrHexColor);\n }\n\n getColor() {\n const rgb = new PIXI.Color(this._sprite.tint).toRgbArray();\n return (\n Math.floor(rgb[0] * 255) +\n ';' +\n Math.floor(rgb[1] * 255) +\n ';' +\n Math.floor(rgb[2] * 255)\n );\n }\n\n getWidth(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedWidth;\n }\n\n getHeight(): float {\n if (this._spriteDirty) {\n this._updatePIXISprite();\n }\n return this._cachedHeight;\n }\n\n getUnscaledWidth(): float {\n return this._sprite.texture.frame.width;\n }\n\n getUnscaledHeight(): float {\n return this._sprite.texture.frame.height;\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ): PixiAnimationFrameTextureManager {\n if (!imageManager._pixiAnimationFrameTextureManager) {\n imageManager._pixiAnimationFrameTextureManager = new PixiAnimationFrameTextureManager(\n imageManager\n );\n }\n return imageManager._pixiAnimationFrameTextureManager;\n }\n }\n\n class PixiAnimationFrameTextureManager\n implements gdjs.AnimationFrameTextureManager<PIXI.Texture> {\n private _imageManager: gdjs.PixiImageManager;\n\n constructor(imageManager: gdjs.PixiImageManager) {\n this._imageManager = imageManager;\n }\n\n getAnimationFrameTexture(imageName: string) {\n return this._imageManager.getPIXITexture(imageName);\n }\n\n getAnimationFrameWidth(pixiTexture: PIXI.Texture) {\n return pixiTexture.width;\n }\n\n getAnimationFrameHeight(pixiTexture: PIXI.Texture) {\n return pixiTexture.height;\n }\n }\n\n // Register the class to let the engine use it.\n export const SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n export type SpriteRuntimeObjectRenderer = SpriteRuntimeObjectPixiRenderer;\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAOS,OAAsC,CAY3C,YACE,EACA,EACA,CAbF,kBAAwB,GACxB,mBAAyB,GAEzB,kBAAsB,EACtB,mBAAuB,EAUrB,KAAK,QAAU,EACf,KAAM,GAAe,EAAkB,UAAU,kBACjD,KAAK,QAAU,GAAI,MAAK,OAAO,EAAa,yBAC5C,KAAM,GAAQ,EAAkB,SAAS,IACzC,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,QAAS,EAAc,aAIrD,aACE,EACA,EACA,CACA,KAAK,QAAU,EACf,KAAK,aAAe,GAC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CAC1C,MAAO,MAAK,cAAc,eAAe,GAG3C,uBAAuB,EAA2B,CAChD,MAAO,GAAY,MAGrB,wBAAwB,EAA2B,CACjD,MAAO,GAAY,QAKhB,AAAM,8BAA8B,IAvNnC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){const g=new i.Logger("Game manager"),h=u=>new Promise(e=>setTimeout(e,u)),c=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 m{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!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 i.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new i.VariablesContainer(s.globalVariables));this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new i.ResourceLoader(this,e.resources.resources,c(e),e.layouts),this._effectsManager=new i.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 i.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new i.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new i.SceneStack(this),this._inputManager=new i.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=i.DebuggerClient?new i.DebuggerClient(this):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 n=JSON.parse(s.metadata);n?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,n.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}if(this._eventsBasedObjectDatas=new Map,this._data.eventsFunctionsExtensions)for(const s of this._data.eventsFunctionsExtensions)for(const n of s.eventsBasedObjects)this._eventsBasedObjectDatas.set(s.name+"::"+n.name,n);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,c(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e}))}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}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 n=this._sceneAndExtensionsData[t];if(e===void 0||n.sceneData.name===e)return n}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 n=this._data.layouts[t];if(e===void 0||n.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,n=this._data.externalLayouts.length;s<n;++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._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&i.RuntimeGameRenderer&&i.RuntimeGameRenderer.getWindowInnerWidth&&i.RuntimeGameRenderer.getWindowInnerHeight){const s=i.RuntimeGameRenderer.getWindowInnerWidth(),n=i.RuntimeGameRenderer.getWindowInnerHeight();this._resizeMode==="adaptWidth"?this._gameResolutionWidth=this._gameResolutionHeight*s/n:this._resizeMode==="adaptHeight"&&(this._gameResolutionHeight=this._gameResolutionWidth*n/s)}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)}loadAllAssets(e,t){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 n=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,n),this._resourcesLoader.loadAllSceneInBackground()},t),i.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 n=new i.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);n.setPercent(d),s&&s(d),n.renderIfNeeded()&&await h(1)}),await n.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){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();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()},1e4)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}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,n=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-n,n=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"?n=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{n=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=i.makeUuid();return localStorage.setItem(e,s),s}catch{return i.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){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((n,r)=>{const o=n.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(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],n=this.getVariablesForExtension(t);n&&n.updateFromNetworkSyncData(s)}}}i.RuntimeGame=m})(gdjs||(gdjs={}));
1
+ var gdjs;(function(i){const g=new i.Logger("Game manager"),h=u=>new Promise(e=>setTimeout(e,u)),c=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 m{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!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 i.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new i.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new i.ResourceLoader(this,e.resources.resources,c(e),e.layouts),this._effectsManager=new i.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 i.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new i.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new i.SceneStack(this),this._inputManager=new i.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=i.DebuggerClient?new i.DebuggerClient(this):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 n=JSON.parse(s.metadata);n?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,n.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,c(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}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 n=this._sceneAndExtensionsData[t];if(e===void 0||n.sceneData.name===e)return n}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 n=this._data.layouts[t];if(e===void 0||n.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,n=this._data.externalLayouts.length;s<n;++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._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&i.RuntimeGameRenderer&&i.RuntimeGameRenderer.getWindowInnerWidth&&i.RuntimeGameRenderer.getWindowInnerHeight){const s=i.RuntimeGameRenderer.getWindowInnerWidth(),n=i.RuntimeGameRenderer.getWindowInnerHeight();this._resizeMode==="adaptWidth"?this._gameResolutionWidth=this._gameResolutionHeight*s/n:this._resizeMode==="adaptHeight"&&(this._gameResolutionHeight=this._gameResolutionWidth*n/s)}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)}loadAllAssets(e,t){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 n=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,n),this._resourcesLoader.loadAllSceneInBackground()},t),i.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 n=new i.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);n.setPercent(d),s&&s(d),n.renderIfNeeded()&&await h(1)}),await n.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){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();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)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}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,n=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-n,n=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"?n=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{n=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=i.makeUuid();return localStorage.setItem(e,s),s}catch{return i.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){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((n,r)=>{const o=n.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(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],n=this.getVariablesForExtension(t);n&&n.updateFromNetworkSyncData(s)}}}i.RuntimeGame=m})(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 /**\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 /**\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 * @param data The object (usually stored in data.json) containing the full project data\n * @param\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._data = data;\n this._updateSceneAndExtensionsData();\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 = 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 = this._data.properties.antialisingEnabledOnMobile;\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._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 this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();\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 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 = 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\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.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._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 = gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight = 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 {\n if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n }\n }\n }\n } else {\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 * 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.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 = this._data.properties.loadingScreen\n .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 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 // 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 }, 10000);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\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 _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 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 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 = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[\n 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 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 = this.getVariablesForExtension(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\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,IAiEF,OAAkB,CAuEvB,YAAY,EAAmB,EAA8B,CAlE7D,6BAAyD,GA2BzD,0CAAgD,GAKhD,aAAmB,GAMnB,qBAA2B,GAoB3B,gCAAsC,GACtC,qBAA2B,GA+vB3B,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,MApwB/B,KAAK,SAAW,GAAW,GAC3B,KAAK,WAAa,GAAI,GAAK,mBAAmB,EAAK,WACnD,KAAK,0BAA4B,GAAI,KAIrC,SAAW,KAAiB,GAAK,0BAC/B,AAAI,EAAc,gBAAgB,OAAS,GACzC,KAAK,0BAA0B,IAC7B,EAAc,KACd,GAAI,GAAK,mBAAmB,EAAc,kBAIhD,KAAK,MAAQ,EACb,KAAK,gCAEL,KAAK,iBAAmB,GAAI,GAAK,eAC/B,KACA,EAAK,UAAU,UACf,EAAuB,GACvB,EAA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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,GAcpC,MAbA,MAAK,0BAA0B,QAAQ,CAAC,EAAW,IAAkB,CACnE,KAAM,GAA6B,EAAU,mBAC3C,GAGF,AAAI,EAA2B,QAC7B,GACE,GACE,KAGR,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,CAOvD,GANI,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,EAAqB,KAAK,yBAC9B,GAEF,AAAI,GACF,EAAmB,0BACjB,KA3rCL,EAAM,gBApGL",
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 /**\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 /**\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 * @param data The object (usually stored in data.json) containing the full project data\n * @param\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._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 = 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 = this._data.properties.antialisingEnabledOnMobile;\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._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 = 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.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._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 = gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight = 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 {\n if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n }\n }\n }\n } else {\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 * 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.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 = this._data.properties.loadingScreen\n .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 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 // 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 } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\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 _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 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 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 = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[\n 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 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 = this.getVariablesForExtension(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\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,IAgFF,OAAkB,CAuEvB,YAAY,EAAm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I,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,EAAqB,KAAK,yBAC9B,GAEF,AAAI,GACF,EAAmB,0BACjB,KA5rCL,EAAM,gBAnHL",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(n){const x=(C,e,t,i)=>{const s=Math.max(t,C-t),r=Math.max(i,e-i);return Math.pow(s,2)+Math.pow(r,2)},_={moveXArray:[],moveYArray:[]},D={result:n.Polygon.makeNewRaycastTestResult()},F=(C,e,t)=>{if(e.length===0)return e.length=0,t.length=0,!1;if(e.length===1)return C.setPosition(C.getX()+e[0],C.getY()+t[0]),e.length=0,t.length=0,!0;let i=0,s=0;for(let f=0;f<e.length;f++){const y=e[f],d=t[f],A=y*y+d*d;A>i&&(i=A,s=f)}const r=Math.sqrt(i),a=e[s]/r,h=-(t[s]/r),m=a;let g=0,c=0;for(let f=0;f<e.length;f++){const y=e[f],d=t[f],A=y*h+d*m;g=Math.min(g,A),c=Math.max(c,A)}let u=e[s],B=t[s];const v=-g<c/1048576,p=c<-g/1048576;return v!==p&&(p?(u+=g*h,B+=g*m):(u+=c*h,B+=c*m)),C.setPosition(C.getX()+u,C.getY()+B),e.length=0,t.length=0,!0},o=class{constructor(e,t){this.x=0;this.y=0;this.angle=0;this.zOrder=0;this.hidden=!1;this.layer="";this._livingOnScene=!0;this.destroyCallbacks=new Set;this.persistentUuid=null;this.networkId=null;this.pick=!1;this._defaultHitBoxes=[];this.hitBoxesDirty=!0;this.aabb={min:[0,0],max:[0,0]};this._isIncludedInParentCollisionMask=!0;this._rendererEffects={};this._instantForces=[];this._permanentForceX=0;this._permanentForceY=0;this._behaviors=[];this.getVariableNumber=o.getVariableNumber;this.returnVariable=o.returnVariable;this.getVariableString=o.getVariableString;this.setVariableNumber=o.setVariableNumber;this.setVariableString=o.setVariableString;this.getVariableBoolean=o.getVariableBoolean;this.setVariableBoolean=o.setVariableBoolean;this.getVariableChildCount=o.getVariableChildCount;this.getFirstVariableNumber=o.getFirstVariableNumber;this.getFirstVariableString=o.getFirstVariableString;this.getLastVariableNumber=o.getLastVariableNumber;this.getLastVariableString=o.getLastVariableString;this.toggleVariableBoolean=o.toggleVariableBoolean;this.variableChildExists=o.variableChildExists;this.variableRemoveChild=o.variableRemoveChild;this.variableClearChildren=o.variableClearChildren;this.variablePushCopy=o.variablePushCopy;this.valuePush=o.valuePush;this.variableRemoveAt=o.variableRemoveAt;this.getSqDistanceTo=o.prototype.getSqDistanceToPosition;this.name=t.name||"",this.type=t.type||"",this._nameId=o.getNameIdentifier(this.name),this.id=e.getScene().createNewUniqueId(),this._runtimeScene=e,this._defaultHitBoxes.push(n.Polygon.createRectangle(0,0)),this.hitBoxes=this._defaultHitBoxes,this._variables=new n.VariablesContainer(t?t.variables:void 0),this._totalForce=new n.Force(0,0,0),this._behaviorsTable=new Hashtable;for(let i=0;i<t.effects.length;++i)this._runtimeScene.getGame().getEffectsManager().initializeEffect(t.effects[i],this._rendererEffects,this),this.updateAllEffectParameters(t.effects[i]);for(let i=0,s=t.behaviors.length;i<s;++i){const r=t.behaviors[i],a=n.getBehaviorConstructor(r.type),l=new a(e,r,this);l.usesLifecycleFunction()&&this._behaviors.push(l),this._behaviorsTable.put(r.name,l)}this._timers=new Hashtable}onCreated(){if(this.getRendererObject())for(const t in this._rendererEffects)this._rendererEffects[t].applyEffect(this);for(let t=0;t<this._behaviors.length;++t)this._behaviors[t].onCreated()}reinitialize(e){const t=this._runtimeScene;this.x=0,this.y=0,this.angle=0,this.zOrder=0,this.hidden=!1,this.layer="",this._livingOnScene=!0,this.id=t.getScene().createNewUniqueId(),this.persistentUuid=null,this.networkId=null,this.pick=!1,this.hitBoxesDirty=!0,this._defaultHitBoxes.length=0,this._defaultHitBoxes.push(n.Polygon.createRectangle(0,0)),this.aabb.min[0]=0,this.aabb.min[1]=0,this.aabb.max[0]=0,this.aabb.max[1]=0,this._variables=new n.VariablesContainer(e.variables),this.clearForces(),this._behaviorsTable.clear();const i=e.behaviors.length;let s=0;for(let r=0;r<i;++r){const a=e.behaviors[r],l=n.getBehaviorConstructor(a.type),h=new l(t,a,this);h.usesLifecycleFunction()&&(s<this._behaviors.length?this._behaviors[s]=h:this._behaviors.push(h),s++),this._behaviorsTable.put(a.name,h)}this._behaviors.length=s;for(let r=0;r<e.effects.length;++r)this._runtimeScene.getGame().getEffectsManager().initializeEffect(e.effects[r],this._rendererEffects,this),this.updateAllEffectParameters(e.effects[r]);this._timers.clear(),this.destroyCallbacks.clear(),this.invalidateHitboxes()}getElapsedTime(e){return this._runtimeScene.getLayer(this.layer).getElapsedTime()}getParent(){return this._runtimeScene}getRuntimeScene(){return this._runtimeScene.getScene()}getInstanceContainer(){return this._runtimeScene}update(e){}updatePreRender(e){}extraInitializationFromInitialInstance(e){}updateFromObjectData(e,t){return!1}getNetworkSyncData(){const e={};this._behaviors.forEach(r=>{if(!r.isSyncedOverNetwork())return;const a=r.getNetworkSyncData();a&&(e[r.getName()]=a)});const t=this._variables.getNetworkSyncData({}),i={};for(const r in this._rendererEffects)i[r]=this._rendererEffects[r].getNetworkSyncData();const s={};for(const r in this._timers.items)s[r]=this._timers.items[r].getNetworkSyncData();return{x:this.x,y:this.y,zo:this.zOrder,a:this.angle,hid:this.hidden,lay:this.layer,if:this._instantForces.map(r=>r.getNetworkSyncData()),pfx:this._permanentForceX,pfy:this._permanentForceY,beh:e,var:t,eff:i,tim:s}}updateFromNetworkSyncData(e){if(e.x!==void 0&&this.setX(e.x),e.y!==void 0&&this.setY(e.y),e.zo!==void 0&&this.setZOrder(e.zo),e.a!==void 0&&this.setAngle(e.a),e.hid!==void 0&&this.hidden!==e.hid&&this.hide(e.hid),e.lay!==void 0&&this.layer!==e.lay&&this.setLayer(e.lay),e.if){this.clearForces();for(let t=0,i=e.if.length;t<i;++t){const s=e.if[t],r=this._getRecycledForce(s.x,s.y,s.m);r.updateFromNetworkSyncData(s),this._instantForces.push(r)}}e.pfx!==void 0&&(this._permanentForceX=e.pfx),e.pfy!==void 0&&(this._permanentForceY=e.pfy);for(const t in e.beh){const i=e.beh[t],s=this.getBehavior(t);s&&s.updateFromNetworkSyncData(i)}if(e.var&&this._variables.updateFromNetworkSyncData(e.var),e.eff)for(const t in e.eff){const i=e.eff[t],s=this._rendererEffects[t];s&&s.updateFromNetworkSyncData(i)}if(e.tim)for(const t in e.tim){const i=e.tim[t],s=this._timers.get(t);s&&s.updateFromNetworkSyncData(i)}}deleteFromScene(e){this._livingOnScene&&(e.markObjectForDeletion(this),this._livingOnScene=!1)}registerDestroyCallback(e){this.destroyCallbacks.add(e)}unregisterDestroyCallback(e){this.destroyCallbacks.delete(e)}onDeletedFromScene(e){const t=e.getLayer(this.layer),i=this.getRendererObject();i&&t.getRenderer().removeRendererObject(i);const s=this.get3DRendererObject();s&&t.getRenderer().remove3DRendererObject(s);for(let r=0,a=this._behaviors.length;r<a;++r)this._behaviors[r].onDestroy();this.destroyCallbacks.forEach(r=>r()),this.clearEffects()}onDestroyed(){}onScenePaused(e){}onSceneResumed(e){}getRendererObject(){}get3DRendererObject(){}getName(){return this.name}getNameId(){return this._nameId}getUniqueId(){return this.id}setPosition(e,t){this.setX(e),this.setY(t)}setX(e){e!==this.x&&(this.x=e,this.invalidateHitboxes())}invalidateHitboxes(){this.hitBoxesDirty=!0,this._runtimeScene.onChildrenLocationChanged()}getX(){return this.x}setY(e){e!==this.y&&(this.y=e,this.invalidateHitboxes())}getY(){return this.y}getDrawableX(){return this.getX()}getDrawableY(){return this.getY()}rotateTowardPosition(e,t,i,s){this.rotateTowardAngle(n.toDegrees(Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX()))),i,s)}rotateTowardAngle(e,t,i){if(t===0){this.setAngle(e);return}const r=n.evtTools.common.angleDifference(this.getAngle(),e)>=0;let a=this.getAngle()+(r?-1:1)*t*this.getElapsedTime()/1e3;n.evtTools.common.angleDifference(a,e)>0^r&&(a=e),this.setAngle(a),this.getAngle()!==a&&this.setAngle(e)}rotate(e,t){this.setAngle(this.getAngle()+e*this.getElapsedTime()/1e3)}setAngle(e){this.angle!==e&&(this.angle=e,this.invalidateHitboxes())}getAngle(){return this.angle}setLayer(e){if(e===this.layer)return;const t=this._runtimeScene.getLayer(this.layer);this.layer=e;const i=this._runtimeScene.getLayer(this.layer),s=this.getRendererObject();s&&(t.getRenderer().removeRendererObject(s),i.getRenderer().addRendererObject(s,this.zOrder));const r=this.get3DRendererObject();r&&(t.getRenderer().remove3DRendererObject(r),i.getRenderer().add3DRendererObject(r))}getLayer(){return this.layer}isOnLayer(e){return this.layer===e}setZOrder(e){if(e===this.zOrder)return;this.zOrder=e;const t=this.getRendererObject();t&&this._runtimeScene.getLayer(this.layer).getRenderer().changeRendererObjectZOrder(t,e)}getZOrder(){return this.zOrder}getVariables(){return this._variables}static getVariableNumber(e){return e.getAsNumber()}static returnVariable(e){return e}static getVariableString(e){return e.getAsString()}static getVariableChildCount(e){return e.getChildrenCount()}static setVariableNumber(e,t){e.setNumber(t)}static setVariableString(e,t){e.setString(t)}static variableChildExists(e,t){return e.hasChild(t)}static variableRemoveChild(e,t){e.removeChild(t)}static variableClearChildren(e){e.clearChildren()}hasVariable(e){return this._variables.has(e)}getRendererEffects(){return this._rendererEffects}addEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().addEffect(e,this._rendererEffects,this):!1}removeEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().removeEffect(this._rendererEffects,this,e):!1}clearEffects(){const e=this.getRendererObject();return e?(this._rendererEffects={},this._runtimeScene.getGame().getEffectsManager().clearEffects(e)):!1}setEffectDoubleParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectDoubleParameter(this._rendererEffects,e,t,i)}setEffectStringParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectStringParameter(this._rendererEffects,e,t,i)}setEffectBooleanParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectBooleanParameter(this._rendererEffects,e,t,i)}updateAllEffectParameters(e){return this._runtimeScene.getGame().getEffectsManager().updateAllEffectParameters(this._rendererEffects,e)}enableEffect(e,t){this._runtimeScene.getGame().getEffectsManager().enableEffect(this._rendererEffects,this,e,t)}isEffectEnabled(e){return this._runtimeScene.getGame().getEffectsManager().isEffectEnabled(this._rendererEffects,this,e)}hasEffect(e){return this._runtimeScene.getGame().getEffectsManager().hasEffect(this._rendererEffects,e)}hide(e){e===void 0&&(e=!0),this.hidden=e}isVisible(){return!this.hidden}isHidden(){return this.hidden}setWidth(e){}setHeight(e){}getWidth(){return 0}getHeight(){return 0}getCenterX(){return this.getWidth()/2}getCenterY(){return this.getHeight()/2}getCenterXInScene(){return this.getDrawableX()+this.getCenterX()}getCenterYInScene(){return this.getDrawableY()+this.getCenterY()}setCenterPositionInScene(e,t){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX())),this.setY(t+this.y-(this.getDrawableY()+this.getCenterY()))}setCenterXInScene(e){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX()))}setCenterYInScene(e){this.setY(e+this.y-(this.getDrawableY()+this.getCenterY()))}_getRecycledForce(e,t,i){if(o.forcesGarbage.length===0)return new n.Force(e,t,i);{const s=o.forcesGarbage.pop();return s.setX(e),s.setY(t),s.setMultiplier(i),s}}addForce(e,t,i){i===1?(this._permanentForceX+=e,this._permanentForceY+=t):i===0&&this._instantForces.length>0&&this._instantForces[0].getMultiplier()===0?this._instantForces[0].add(e,t):this._instantForces.push(this._getRecycledForce(e,t,i))}addPolarForce(e,t,i){const s=n.toRad(e),r=Math.cos(s)*t,a=Math.sin(s)*t;this.addForce(r,a,i)}addForceTowardPosition(e,t,i,s){const r=Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX())),a=Math.cos(r)*i,l=Math.sin(r)*i;this.addForce(a,l,s)}addForceTowardObject(e,t,i){e!=null&&this.addForceTowardPosition(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}clearForces(){o.forcesGarbage.push.apply(o.forcesGarbage,this._instantForces),this._instantForces.length=0,this._permanentForceX=0,this._permanentForceY=0}hasNoForces(){return this._instantForces.length===0&&this._permanentForceX===0&&this._permanentForceY===0}updateForces(e){for(let t=0;t<this._instantForces.length;){const i=this._instantForces[t],s=i.getMultiplier();s===1?++t:s===0||i.getLength()<=.001?(o.forcesGarbage.push(i),this._instantForces.splice(t,1)):(i.setLength(i.getLength()-i.getLength()*(1-s)*e),++t)}}getAverageForce(){this._totalForce.clear(),this._totalForce.add(this._permanentForceX,this._permanentForceY);for(let e=0,t=this._instantForces.length;e<t;++e)this._totalForce.addForce(this._instantForces[e]);return this._totalForce}averageForceAngleIs(e,t){let i=this.getAverageForce().getAngle();return i<0&&(i+=360),Math.abs(e-i)<t/2}isTotalForceAngleAround(e,t){return Math.abs(n.evtTools.common.angleDifference(this.getAverageForce().getAngle(),e))<=t}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}getHitBoxesAround(e,t,i,s){return this.getHitBoxes()}updateHitBoxes(){this.hitBoxes=this._defaultHitBoxes;const e=this.getWidth(),t=this.getHeight(),i=this.getCenterX(),s=this.getCenterY();i===e/2&&s===t/2?(this.hitBoxes[0].vertices[0][0]=-i,this.hitBoxes[0].vertices[0][1]=-s,this.hitBoxes[0].vertices[1][0]=+i,this.hitBoxes[0].vertices[1][1]=-s,this.hitBoxes[0].vertices[2][0]=+i,this.hitBoxes[0].vertices[2][1]=+s,this.hitBoxes[0].vertices[3][0]=-i,this.hitBoxes[0].vertices[3][1]=+s):(this.hitBoxes[0].vertices[0][0]=0-i,this.hitBoxes[0].vertices[0][1]=0-s,this.hitBoxes[0].vertices[1][0]=e-i,this.hitBoxes[0].vertices[1][1]=0-s,this.hitBoxes[0].vertices[2][0]=e-i,this.hitBoxes[0].vertices[2][1]=t-s,this.hitBoxes[0].vertices[3][0]=0-i,this.hitBoxes[0].vertices[3][1]=t-s),this.hitBoxes[0].rotate(n.toRad(this.getAngle())),this.hitBoxes[0].move(this.getDrawableX()+i,this.getDrawableY()+s)}isIncludedInParentCollisionMask(){return this._isIncludedInParentCollisionMask}setIncludedInParentCollisionMask(e){const t=this._isIncludedInParentCollisionMask;this._isIncludedInParentCollisionMask=e,t!==e&&this._runtimeScene.onChildrenLocationChanged()}getAABB(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb}getVisibilityAABB(){return this.getAABB()}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.getDrawableX(),this.aabb.min[1]=this.getDrawableY(),this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{let e=!0;for(let t=0;t<this.hitBoxes.length;t++)for(let i=0;i<this.hitBoxes[t].vertices.length;i++){const s=this.hitBoxes[t].vertices[i];e?(this.aabb.min[0]=s[0],this.aabb.max[0]=s[0],this.aabb.min[1]=s[1],this.aabb.max[1]=s[1],e=!1):(this.aabb.min[0]=Math.min(this.aabb.min[0],s[0]),this.aabb.max[0]=Math.max(this.aabb.max[0],s[0]),this.aabb.min[1]=Math.min(this.aabb.min[1],s[1]),this.aabb.max[1]=Math.max(this.aabb.max[1],s[1]))}}}getAABBLeft(){return this.getAABB().min[0]}getAABBTop(){return this.getAABB().min[1]}getAABBRight(){return this.getAABB().max[0]}getAABBBottom(){return this.getAABB().max[1]}getAABBCenterX(){return this.getAABB().min[0]/2+this.getAABB().max[0]/2}getAABBCenterY(){return this.getAABB().min[1]/2+this.getAABB().max[1]/2}stepBehaviorsPreEvents(e){for(let t=0,i=this._behaviors.length;t<i;++t)this._behaviors[t].stepPreEvents(e)}stepBehaviorsPostEvents(e){for(let t=0,i=this._behaviors.length;t<i;++t)this._behaviors[t].stepPostEvents(e)}notifyBehaviorsObjectHotReloaded(){for(let e=0,t=this._behaviors.length;e<t;++e)this._behaviors[e].onObjectHotReloaded()}getBehavior(e){return this._behaviorsTable.get(e)}hasBehavior(e){return this._behaviorsTable.containsKey(e)}activateBehavior(e,t){this._behaviorsTable.containsKey(e)&&this._behaviorsTable.get(e).activate(t)}behaviorActivated(e){return this._behaviorsTable.containsKey(e)?this._behaviorsTable.get(e).activated():!1}removeBehavior(e){const t=this._behaviorsTable.get(e);if(!t)return!1;t.onDestroy();const i=this._behaviors.indexOf(t);return i!==-1&&this._behaviors.splice(i,1),this._behaviorsTable.remove(e),!0}addNewBehavior(e){const t=n.getBehaviorConstructor(e.type);if(!t)return!1;const i=new t(this._runtimeScene,e,this);return i.usesLifecycleFunction()&&this._behaviors.push(i),this._behaviorsTable.put(e.name,i),!0}updateTimers(e){for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(e)}timerElapsedTime(e,t){return this._timers.containsKey(e)?this.getTimerElapsedTimeInSeconds(e)>=t:(this._timers.put(e,new n.Timer(e)),!1)}timerPaused(e){return this._timers.containsKey(e)?this._timers.get(e).isPaused():!1}resetTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).reset()}pauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!0)}unpauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!1)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}getTimerElapsedTimeInSeconds(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:0}getTimerElapsedTimeInSecondsOrNaN(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:Number.NaN}separateFromObjects(e,t){let i=_.moveXArray,s=_.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l of e){if(l.id===this.id)continue;let h=l.getHitBoxes(),m=h;h.length>4&&(a||(a=this.getAABB()),m=l.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const g of r)for(const c of m){const u=n.Polygon.collisionTest(g,c,t);u.collision&&(i.push(u.move_axis[0]),s.push(u.move_axis[1]))}}return F(this,i,s)}separateFromObjectsList(e,t){let i=_.moveXArray,s=_.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l in e.items)if(e.items.hasOwnProperty(l)){const h=e.items[l];for(const m of h){if(m.id===this.id)continue;let g=m.getHitBoxes(),c=g;g.length>4&&(a||(a=this.getAABB()),c=m.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const u of r)for(const B of c){const v=n.Polygon.collisionTest(u,B,t);v.collision&&(i.push(v.move_axis[0]),s.push(v.move_axis[1]))}}}return F(this,i,s)}getDistanceToObject(e){return Math.sqrt(this.getSqDistanceToObject(e))}getSqDistanceToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return t*t+i*i}getDistanceToPosition(e,t){return Math.sqrt(this.getSqDistanceToPosition(e,t))}getSqDistanceToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return i*i+s*s}getAngleToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return n.toDegrees(Math.atan2(-i,-t))}getXFromAngleAndDistance(e,t){return this.getDrawableX()+this.getCenterX()+t*Math.cos(n.toRad(e))}getYFromAngleAndDistance(e,t){return this.getDrawableY()+this.getCenterY()+t*Math.sin(n.toRad(e))}getAngleToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return n.toDegrees(Math.atan2(-s,-i))}putAround(e,t,i,s){const r=n.toRad(s);this.setCenterXInScene(e+Math.cos(r)*i),this.setCenterYInScene(t+Math.sin(r)*i)}putAroundObject(e,t,i){!e||this.putAround(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}separateObjectsWithoutForces(e){const t=n.staticArray(o.prototype.separateObjectsWithoutForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithoutForces);e.values(i);for(let s=0,r=i.length;s<r;++s)t.push.apply(t,i[s]);for(let s=0,r=t.length;s<r;++s)t[s].id!=this.id&&(this.getDrawableX()<t[s].getDrawableX()?this.setX(t[s].getDrawableX()-this.getWidth()):this.getDrawableX()+this.getWidth()>t[s].getDrawableX()+t[s].getWidth()&&this.setX(t[s].getDrawableX()+t[s].getWidth()),this.getDrawableY()<t[s].getDrawableY()?this.setY(t[s].getDrawableY()-this.getHeight()):this.getDrawableY()+this.getHeight()>t[s].getDrawableY()+t[s].getHeight()&&this.setY(t[s].getDrawableY()+t[s].getHeight()))}separateObjectsWithForces(e){const t=n.staticArray(o.prototype.separateObjectsWithForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithForces);e.values(i);for(let s=0,r=i.length;s<r;++s)t.push.apply(t,i[s]);for(let s=0,r=t.length;s<r;++s)if(t[s].id!=this.id){if(this.getDrawableX()+this.getCenterX()<t[s].getDrawableX()+t[s].getCenterX()){let a=this.hasNoForces()?0:this.getAverageForce().getX();this.addForce(-a-10,0,0)}else{let a=this.hasNoForces()?0:this.getAverageForce().getX();this.addForce(-a+10,0,0)}if(this.getDrawableY()+this.getCenterY()<t[s].getDrawableY()+t[s].getCenterY()){let a=this.hasNoForces()?0:this.getAverageForce().getY();this.addForce(0,-a-10,0)}else{let a=this.hasNoForces()?0:this.getAverageForce().getY();this.addForce(0,-a+10,0)}}}static collisionTest(e,t,i,s=null){const r=e.getCenterX(),a=e.getCenterY(),l=Math.sqrt(x(e.getWidth(),e.getHeight(),r,a)),h=t.getCenterX(),m=t.getCenterY(),g=Math.sqrt(x(t.getWidth(),t.getHeight(),h,m)),c=e.getDrawableX()+r,u=e.getDrawableY()+a,B=t.getDrawableX()+h,v=t.getDrawableY()+m,p=c-B,f=u-v;if(Math.sqrt(p*p+f*f)>l+g)return!1;const y=e.getHitBoxesAround(B-g,v-g,B+g,v+g),d=t.getHitBoxesAround(c-l,u-l,c+l,u+l);for(const A of y)if(A!==s){for(const j of d)if(n.Polygon.collisionTest(A,j,i).collision)return!0}return!1}raycastTest(e,t,i,s,r){const a=this.getCenterX(),l=this.getCenterY(),h=x(this.getWidth(),this.getHeight(),a,l),m=(e+i)/2,g=(t+s)/2,c=(i-e)*(i-e)+(s-t)*(s-t),u=this.getDrawableX()+a-m,B=this.getDrawableY()+l-g;let v=D.result;if(v.collision=!1,u*u+B*B>h+c+2*Math.sqrt(c*h))return v;if(r){let p=Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const y of f){const d=n.Polygon.raycastTest(y,e,t,i,s);d.collision&&d.closeSqDist<p&&(p=d.closeSqDist,n.Polygon.copyRaycastTestResult(d,v))}}else{let p=-Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const y of f){const d=n.Polygon.raycastTest(y,e,t,i,s);d.collision&&d.farSqDist>p&&d.farSqDist<=c&&(p=d.farSqDist,n.Polygon.copyRaycastTestResult(d,v))}}return v}insideObject(e,t){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb.min[0]<=e&&this.aabb.max[0]>=e&&this.aabb.min[1]<=t&&this.aabb.max[1]>=t}static distanceTest(e,t,i){return e.getSqDistanceToObject(t)<=i}cursorOnObject(e){const t=n.staticArray(o.prototype.cursorOnObject);t.length=2;const i=e.getGame().getInputManager(),s=e.getLayer(this.layer),r=s.convertCoords(i.getCursorX(),i.getCursorY(),0,t);if(this.insideObject(r[0],r[1]))return!0;const a=i.getAllTouchIdentifiers();for(let l=0;l<a.length;++l){const h=s.convertCoords(i.getTouchX(a[l]),i.getTouchY(a[l]),0,t);if(this.insideObject(h[0],h[1]))return!0}return!1}isCollidingWithPoint(e,t){const i=this.getHitBoxesAround(e,t,e,t);for(const s of i)if(n.Polygon.isPointInside(s,e,t))return!0;return!1}static getNameIdentifier(e){if(o._identifiers.containsKey(e))return o._identifiers.get(e);o._newId=(o._newId||0)+1;const t=o._newId;return o._identifiers.put(e,t),t}};let b=o;b.supportsReinitialization=!1,b.setVariableBoolean=function(e,t){e.setBoolean(t)},b.getVariableBoolean=function(e,t){return n.evtTools.common.getVariableBoolean(e,t)},b.toggleVariableBoolean=function(e){n.evtTools.common.toggleVariableBoolean(e)},b.variablePushCopy=function(e,t){e.pushVariableCopy(t)},b.valuePush=function(e,t){e.pushValue(t)},b.variableRemoveAt=function(e,t){e.removeAtIndex(t)},b.getFirstVariableString=function(e){return e.getChildrenCount()===0?"":e.getAllChildrenArray()[0].getAsString()},b.getFirstVariableNumber=function(e){return e.getChildrenCount()===0?0:e.getAllChildrenArray()[0].getAsNumber()},b.getLastVariableString=function(e){const t=e.getAllChildrenArray();return t.length===0?"":t[t.length-1].getAsString()},b.getLastVariableNumber=function(e){const t=e.getAllChildrenArray();return t.length===0?0:t[t.length-1].getAsNumber()},b._identifiers=new Hashtable,b._newId=0,b.forcesGarbage=[],n.RuntimeObject=b,n.registerObject("",n.RuntimeObject)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const _=(C,e,t,i)=>{const s=Math.max(t,C-t),r=Math.max(i,e-i);return Math.pow(s,2)+Math.pow(r,2)},x={moveXArray:[],moveYArray:[]},D={result:n.Polygon.makeNewRaycastTestResult()},F=(C,e,t)=>{if(e.length===0)return e.length=0,t.length=0,!1;if(e.length===1)return C.setPosition(C.getX()+e[0],C.getY()+t[0]),e.length=0,t.length=0,!0;let i=0,s=0;for(let f=0;f<e.length;f++){const y=e[f],d=t[f],A=y*y+d*d;A>i&&(i=A,s=f)}const r=Math.sqrt(i),a=e[s]/r,h=-(t[s]/r),m=a;let g=0,c=0;for(let f=0;f<e.length;f++){const y=e[f],d=t[f],A=y*h+d*m;g=Math.min(g,A),c=Math.max(c,A)}let u=e[s],B=t[s];const v=-g<c/1048576,p=c<-g/1048576;return v!==p&&(p?(u+=g*h,B+=g*m):(u+=c*h,B+=c*m)),C.setPosition(C.getX()+u,C.getY()+B),e.length=0,t.length=0,!0},o=class{constructor(e,t){this.x=0;this.y=0;this.angle=0;this.zOrder=0;this.hidden=!1;this.layer="";this._livingOnScene=!0;this.destroyCallbacks=new Set;this.persistentUuid=null;this.networkId=null;this.pick=!1;this._defaultHitBoxes=[];this.hitBoxesDirty=!0;this.aabb={min:[0,0],max:[0,0]};this._isIncludedInParentCollisionMask=!0;this._rendererEffects={};this._instantForces=[];this._permanentForceX=0;this._permanentForceY=0;this._behaviors=[];this.getVariableNumber=o.getVariableNumber;this.returnVariable=o.returnVariable;this.getVariableString=o.getVariableString;this.setVariableNumber=o.setVariableNumber;this.setVariableString=o.setVariableString;this.getVariableBoolean=o.getVariableBoolean;this.setVariableBoolean=o.setVariableBoolean;this.getVariableChildCount=o.getVariableChildCount;this.getFirstVariableNumber=o.getFirstVariableNumber;this.getFirstVariableString=o.getFirstVariableString;this.getLastVariableNumber=o.getLastVariableNumber;this.getLastVariableString=o.getLastVariableString;this.toggleVariableBoolean=o.toggleVariableBoolean;this.variableChildExists=o.variableChildExists;this.variableRemoveChild=o.variableRemoveChild;this.variableClearChildren=o.variableClearChildren;this.variablePushCopy=o.variablePushCopy;this.valuePush=o.valuePush;this.variableRemoveAt=o.variableRemoveAt;this.getSqDistanceTo=o.prototype.getSqDistanceToPosition;this.name=t.name||"",this.type=t.type||"",this._nameId=o.getNameIdentifier(this.name),this.id=e.getScene().createNewUniqueId(),this._runtimeScene=e,this._defaultHitBoxes.push(n.Polygon.createRectangle(0,0)),this.hitBoxes=this._defaultHitBoxes,this._variables=new n.VariablesContainer(t?t.variables:void 0),this._totalForce=new n.Force(0,0,0),this._behaviorsTable=new Hashtable;for(let i=0;i<t.effects.length;++i)this._runtimeScene.getGame().getEffectsManager().initializeEffect(t.effects[i],this._rendererEffects,this),this.updateAllEffectParameters(t.effects[i]);for(let i=0,s=t.behaviors.length;i<s;++i){const r=t.behaviors[i],a=n.getBehaviorConstructor(r.type),l=new a(e,r,this);l.usesLifecycleFunction()&&this._behaviors.push(l),this._behaviorsTable.put(r.name,l)}this._timers=new Hashtable}onCreated(){if(this.getRendererObject())for(const t in this._rendererEffects)this._rendererEffects[t].applyEffect(this);for(let t=0;t<this._behaviors.length;++t)this._behaviors[t].onCreated()}reinitialize(e){const t=this._runtimeScene;this.x=0,this.y=0,this.angle=0,this.zOrder=0,this.hidden=!1,this.layer="",this._livingOnScene=!0,this.id=t.getScene().createNewUniqueId(),this.persistentUuid=null,this.networkId=null,this.pick=!1,this.hitBoxesDirty=!0,this._defaultHitBoxes.length=0,this._defaultHitBoxes.push(n.Polygon.createRectangle(0,0)),this.aabb.min[0]=0,this.aabb.min[1]=0,this.aabb.max[0]=0,this.aabb.max[1]=0,this._variables=new n.VariablesContainer(e.variables),this.clearForces(),this._behaviorsTable.clear();const i=e.behaviors.length;let s=0;for(let r=0;r<i;++r){const a=e.behaviors[r],l=n.getBehaviorConstructor(a.type),h=new l(t,a,this);h.usesLifecycleFunction()&&(s<this._behaviors.length?this._behaviors[s]=h:this._behaviors.push(h),s++),this._behaviorsTable.put(a.name,h)}this._behaviors.length=s;for(let r=0;r<e.effects.length;++r)this._runtimeScene.getGame().getEffectsManager().initializeEffect(e.effects[r],this._rendererEffects,this),this.updateAllEffectParameters(e.effects[r]);this._timers.clear(),this.destroyCallbacks.clear(),this.invalidateHitboxes()}getElapsedTime(e){return this._runtimeScene.getLayer(this.layer).getElapsedTime()}getParent(){return this._runtimeScene}getRuntimeScene(){return this._runtimeScene.getScene()}getInstanceContainer(){return this._runtimeScene}update(e){}updatePreRender(e){}extraInitializationFromInitialInstance(e){}updateFromObjectData(e,t){return!1}getNetworkSyncData(){const e={};this._behaviors.forEach(r=>{if(!r.isSyncedOverNetwork())return;const a=r.getNetworkSyncData();a&&(e[r.getName()]=a)});const t=this._variables.getNetworkSyncData({}),i={};for(const r in this._rendererEffects)i[r]=this._rendererEffects[r].getNetworkSyncData();const s={};for(const r in this._timers.items)s[r]=this._timers.items[r].getNetworkSyncData();return{x:this.x,y:this.y,zo:this.zOrder,a:this.angle,hid:this.hidden,lay:this.layer,if:this._instantForces.map(r=>r.getNetworkSyncData()),pfx:this._permanentForceX,pfy:this._permanentForceY,beh:e,var:t,eff:i,tim:s}}updateFromNetworkSyncData(e){if(e.x!==void 0&&this.setX(e.x),e.y!==void 0&&this.setY(e.y),e.zo!==void 0&&this.setZOrder(e.zo),e.a!==void 0&&this.setAngle(e.a),e.hid!==void 0&&this.hidden!==e.hid&&this.hide(e.hid),e.lay!==void 0&&this.layer!==e.lay&&this.setLayer(e.lay),e.if){this.clearForces();for(let t=0,i=e.if.length;t<i;++t){const s=e.if[t],r=this._getRecycledForce(s.x,s.y,s.m);r.updateFromNetworkSyncData(s),this._instantForces.push(r)}}e.pfx!==void 0&&(this._permanentForceX=e.pfx),e.pfy!==void 0&&(this._permanentForceY=e.pfy);for(const t in e.beh){const i=e.beh[t],s=this.getBehavior(t);s&&s.updateFromNetworkSyncData(i)}if(e.var&&this._variables.updateFromNetworkSyncData(e.var),e.eff)for(const t in e.eff){const i=e.eff[t],s=this._rendererEffects[t];s&&s.updateFromNetworkSyncData(i)}if(e.tim)for(const t in e.tim){const i=e.tim[t],s=this._timers.get(t);s&&s.updateFromNetworkSyncData(i)}}deleteFromScene(e){this._livingOnScene&&(e.markObjectForDeletion(this),this._livingOnScene=!1)}registerDestroyCallback(e){this.destroyCallbacks.add(e)}unregisterDestroyCallback(e){this.destroyCallbacks.delete(e)}onDeletedFromScene(e){const t=e.getLayer(this.layer),i=this.getRendererObject();i&&t.getRenderer().removeRendererObject(i);const s=this.get3DRendererObject();s&&t.getRenderer().remove3DRendererObject(s);for(let r=0,a=this._behaviors.length;r<a;++r)this._behaviors[r].onDestroy();this.destroyCallbacks.forEach(r=>r()),this.clearEffects()}onDestroyed(){}onScenePaused(e){}onSceneResumed(e){}getRendererObject(){}get3DRendererObject(){}getName(){return this.name}getNameId(){return this._nameId}getUniqueId(){return this.id}setPosition(e,t){this.setX(e),this.setY(t)}setX(e){e!==this.x&&(this.x=e,this.invalidateHitboxes())}invalidateHitboxes(){this.hitBoxesDirty=!0,this._runtimeScene.onChildrenLocationChanged()}getX(){return this.x}setY(e){e!==this.y&&(this.y=e,this.invalidateHitboxes())}getY(){return this.y}getDrawableX(){return this.getX()}getDrawableY(){return this.getY()}rotateTowardPosition(e,t,i,s){this.rotateTowardAngle(n.toDegrees(Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX()))),i,s)}rotateTowardAngle(e,t,i){if(t===0){this.setAngle(e);return}const r=n.evtTools.common.angleDifference(this.getAngle(),e)>=0;let a=this.getAngle()+(r?-1:1)*t*this.getElapsedTime()/1e3;n.evtTools.common.angleDifference(a,e)>0^r&&(a=e),this.setAngle(a),this.getAngle()!==a&&this.setAngle(e)}rotate(e,t){this.setAngle(this.getAngle()+e*this.getElapsedTime()/1e3)}setAngle(e){this.angle!==e&&(this.angle=e,this.invalidateHitboxes())}getAngle(){return this.angle}setLayer(e){if(e===this.layer)return;const t=this._runtimeScene.getLayer(this.layer);this.layer=e;const i=this._runtimeScene.getLayer(this.layer),s=this.getRendererObject();s&&(t.getRenderer().removeRendererObject(s),i.getRenderer().addRendererObject(s,this.zOrder));const r=this.get3DRendererObject();r&&(t.getRenderer().remove3DRendererObject(r),i.getRenderer().add3DRendererObject(r))}getLayer(){return this.layer}isOnLayer(e){return this.layer===e}setZOrder(e){if(e===this.zOrder)return;this.zOrder=e;const t=this.getRendererObject();t&&this._runtimeScene.getLayer(this.layer).getRenderer().changeRendererObjectZOrder(t,e)}getZOrder(){return this.zOrder}getVariables(){return this._variables}static getVariableNumber(e){return e.getAsNumber()}static returnVariable(e){return e}static getVariableString(e){return e.getAsString()}static getVariableChildCount(e){return e.getChildrenCount()}static setVariableNumber(e,t){e.setNumber(t)}static setVariableString(e,t){e.setString(t)}static variableChildExists(e,t){return e.hasChild(t)}static variableRemoveChild(e,t){e.removeChild(t)}static variableClearChildren(e){e.clearChildren()}hasVariable(e){return this._variables.has(e)}getRendererEffects(){return this._rendererEffects}addEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().addEffect(e,this._rendererEffects,this):!1}removeEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().removeEffect(this._rendererEffects,this,e):!1}clearEffects(){const e=this.getRendererObject();return e?(this._rendererEffects={},this._runtimeScene.getGame().getEffectsManager().clearEffects(e)):!1}setEffectDoubleParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectDoubleParameter(this._rendererEffects,e,t,i)}setEffectStringParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectStringParameter(this._rendererEffects,e,t,i)}setEffectBooleanParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectBooleanParameter(this._rendererEffects,e,t,i)}updateAllEffectParameters(e){return this._runtimeScene.getGame().getEffectsManager().updateAllEffectParameters(this._rendererEffects,e)}enableEffect(e,t){this._runtimeScene.getGame().getEffectsManager().enableEffect(this._rendererEffects,this,e,t)}isEffectEnabled(e){return this._runtimeScene.getGame().getEffectsManager().isEffectEnabled(this._rendererEffects,this,e)}hasEffect(e){return this._runtimeScene.getGame().getEffectsManager().hasEffect(this._rendererEffects,e)}hide(e){e===void 0&&(e=!0),this.hidden=e}isVisible(){return!this.hidden}isHidden(){return this.hidden}setWidth(e){}setHeight(e){}getWidth(){return 0}getHeight(){return 0}getCenterX(){return this.getWidth()/2}getCenterY(){return this.getHeight()/2}getCenterXInScene(){return this.getDrawableX()+this.getCenterX()}getCenterYInScene(){return this.getDrawableY()+this.getCenterY()}setCenterPositionInScene(e,t){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX())),this.setY(t+this.y-(this.getDrawableY()+this.getCenterY()))}setCenterXInScene(e){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX()))}setCenterYInScene(e){this.setY(e+this.y-(this.getDrawableY()+this.getCenterY()))}_getRecycledForce(e,t,i){if(o.forcesGarbage.length===0)return new n.Force(e,t,i);{const s=o.forcesGarbage.pop();return s.setX(e),s.setY(t),s.setMultiplier(i),s}}addForce(e,t,i){i===1?(this._permanentForceX+=e,this._permanentForceY+=t):i===0&&this._instantForces.length>0&&this._instantForces[0].getMultiplier()===0?this._instantForces[0].add(e,t):this._instantForces.push(this._getRecycledForce(e,t,i))}addPolarForce(e,t,i){const s=n.toRad(e),r=Math.cos(s)*t,a=Math.sin(s)*t;this.addForce(r,a,i)}addForceTowardPosition(e,t,i,s){const r=Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX())),a=Math.cos(r)*i,l=Math.sin(r)*i;this.addForce(a,l,s)}addForceTowardObject(e,t,i){e!=null&&this.addForceTowardPosition(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}clearForces(){o.forcesGarbage.push.apply(o.forcesGarbage,this._instantForces),this._instantForces.length=0,this._permanentForceX=0,this._permanentForceY=0}hasNoForces(){return this._instantForces.length===0&&this._permanentForceX===0&&this._permanentForceY===0}updateForces(e){for(let t=0;t<this._instantForces.length;){const i=this._instantForces[t],s=i.getMultiplier();s===1?++t:s===0||i.getLength()<=.001?(o.forcesGarbage.push(i),this._instantForces.splice(t,1)):(i.setLength(i.getLength()-i.getLength()*(1-s)*e),++t)}}getAverageForce(){this._totalForce.clear(),this._totalForce.add(this._permanentForceX,this._permanentForceY);for(let e=0,t=this._instantForces.length;e<t;++e)this._totalForce.addForce(this._instantForces[e]);return this._totalForce}averageForceAngleIs(e,t){let i=this.getAverageForce().getAngle();return i<0&&(i+=360),Math.abs(e-i)<t/2}isTotalForceAngleAround(e,t){return Math.abs(n.evtTools.common.angleDifference(this.getAverageForce().getAngle(),e))<=t}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}getHitBoxesAround(e,t,i,s){return this.getHitBoxes()}updateHitBoxes(){if(this.hitBoxes=this._defaultHitBoxes,this.hitBoxes.length===0)return;const e=this.getWidth(),t=this.getHeight(),i=this.getCenterX(),s=this.getCenterY();i===e/2&&s===t/2?(this.hitBoxes[0].vertices[0][0]=-i,this.hitBoxes[0].vertices[0][1]=-s,this.hitBoxes[0].vertices[1][0]=+i,this.hitBoxes[0].vertices[1][1]=-s,this.hitBoxes[0].vertices[2][0]=+i,this.hitBoxes[0].vertices[2][1]=+s,this.hitBoxes[0].vertices[3][0]=-i,this.hitBoxes[0].vertices[3][1]=+s):(this.hitBoxes[0].vertices[0][0]=0-i,this.hitBoxes[0].vertices[0][1]=0-s,this.hitBoxes[0].vertices[1][0]=e-i,this.hitBoxes[0].vertices[1][1]=0-s,this.hitBoxes[0].vertices[2][0]=e-i,this.hitBoxes[0].vertices[2][1]=t-s,this.hitBoxes[0].vertices[3][0]=0-i,this.hitBoxes[0].vertices[3][1]=t-s),this.hitBoxes[0].rotate(n.toRad(this.getAngle())),this.hitBoxes[0].move(this.getDrawableX()+i,this.getDrawableY()+s)}isIncludedInParentCollisionMask(){return this._isIncludedInParentCollisionMask}setIncludedInParentCollisionMask(e){const t=this._isIncludedInParentCollisionMask;this._isIncludedInParentCollisionMask=e,t!==e&&this._runtimeScene.onChildrenLocationChanged()}getAABB(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb}getVisibilityAABB(){return this.getAABB()}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.getDrawableX(),this.aabb.min[1]=this.getDrawableY(),this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{let e=!0;for(let t=0;t<this.hitBoxes.length;t++)for(let i=0;i<this.hitBoxes[t].vertices.length;i++){const s=this.hitBoxes[t].vertices[i];e?(this.aabb.min[0]=s[0],this.aabb.max[0]=s[0],this.aabb.min[1]=s[1],this.aabb.max[1]=s[1],e=!1):(this.aabb.min[0]=Math.min(this.aabb.min[0],s[0]),this.aabb.max[0]=Math.max(this.aabb.max[0],s[0]),this.aabb.min[1]=Math.min(this.aabb.min[1],s[1]),this.aabb.max[1]=Math.max(this.aabb.max[1],s[1]))}}}getAABBLeft(){return this.getAABB().min[0]}getAABBTop(){return this.getAABB().min[1]}getAABBRight(){return this.getAABB().max[0]}getAABBBottom(){return this.getAABB().max[1]}getAABBCenterX(){return this.getAABB().min[0]/2+this.getAABB().max[0]/2}getAABBCenterY(){return this.getAABB().min[1]/2+this.getAABB().max[1]/2}stepBehaviorsPreEvents(e){for(let t=0,i=this._behaviors.length;t<i;++t)this._behaviors[t].stepPreEvents(e)}stepBehaviorsPostEvents(e){for(let t=0,i=this._behaviors.length;t<i;++t)this._behaviors[t].stepPostEvents(e)}notifyBehaviorsObjectHotReloaded(){for(let e=0,t=this._behaviors.length;e<t;++e)this._behaviors[e].onObjectHotReloaded()}getBehavior(e){return this._behaviorsTable.get(e)}hasBehavior(e){return this._behaviorsTable.containsKey(e)}activateBehavior(e,t){this._behaviorsTable.containsKey(e)&&this._behaviorsTable.get(e).activate(t)}behaviorActivated(e){return this._behaviorsTable.containsKey(e)?this._behaviorsTable.get(e).activated():!1}removeBehavior(e){const t=this._behaviorsTable.get(e);if(!t)return!1;t.onDestroy();const i=this._behaviors.indexOf(t);return i!==-1&&this._behaviors.splice(i,1),this._behaviorsTable.remove(e),!0}addNewBehavior(e){const t=n.getBehaviorConstructor(e.type);if(!t)return!1;const i=new t(this._runtimeScene,e,this);return i.usesLifecycleFunction()&&this._behaviors.push(i),this._behaviorsTable.put(e.name,i),!0}updateTimers(e){for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(e)}timerElapsedTime(e,t){return this._timers.containsKey(e)?this.getTimerElapsedTimeInSeconds(e)>=t:(this._timers.put(e,new n.Timer(e)),!1)}timerPaused(e){return this._timers.containsKey(e)?this._timers.get(e).isPaused():!1}resetTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).reset()}pauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!0)}unpauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!1)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}getTimerElapsedTimeInSeconds(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:0}getTimerElapsedTimeInSecondsOrNaN(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:Number.NaN}separateFromObjects(e,t){let i=x.moveXArray,s=x.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l of e){if(l.id===this.id)continue;let h=l.getHitBoxes(),m=h;h.length>4&&(a||(a=this.getAABB()),m=l.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const g of r)for(const c of m){const u=n.Polygon.collisionTest(g,c,t);u.collision&&(i.push(u.move_axis[0]),s.push(u.move_axis[1]))}}return F(this,i,s)}separateFromObjectsList(e,t){let i=x.moveXArray,s=x.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l in e.items)if(e.items.hasOwnProperty(l)){const h=e.items[l];for(const m of h){if(m.id===this.id)continue;let g=m.getHitBoxes(),c=g;g.length>4&&(a||(a=this.getAABB()),c=m.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const u of r)for(const B of c){const v=n.Polygon.collisionTest(u,B,t);v.collision&&(i.push(v.move_axis[0]),s.push(v.move_axis[1]))}}}return F(this,i,s)}getDistanceToObject(e){return Math.sqrt(this.getSqDistanceToObject(e))}getSqDistanceToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return t*t+i*i}getDistanceToPosition(e,t){return Math.sqrt(this.getSqDistanceToPosition(e,t))}getSqDistanceToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return i*i+s*s}getAngleToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return n.toDegrees(Math.atan2(-i,-t))}getXFromAngleAndDistance(e,t){return this.getDrawableX()+this.getCenterX()+t*Math.cos(n.toRad(e))}getYFromAngleAndDistance(e,t){return this.getDrawableY()+this.getCenterY()+t*Math.sin(n.toRad(e))}getAngleToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return n.toDegrees(Math.atan2(-s,-i))}putAround(e,t,i,s){const r=n.toRad(s);this.setCenterXInScene(e+Math.cos(r)*i),this.setCenterYInScene(t+Math.sin(r)*i)}putAroundObject(e,t,i){!e||this.putAround(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}separateObjectsWithoutForces(e){const t=n.staticArray(o.prototype.separateObjectsWithoutForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithoutForces);e.values(i);for(let s=0,r=i.length;s<r;++s)t.push.apply(t,i[s]);for(let s=0,r=t.length;s<r;++s)t[s].id!=this.id&&(this.getDrawableX()<t[s].getDrawableX()?this.setX(t[s].getDrawableX()-this.getWidth()):this.getDrawableX()+this.getWidth()>t[s].getDrawableX()+t[s].getWidth()&&this.setX(t[s].getDrawableX()+t[s].getWidth()),this.getDrawableY()<t[s].getDrawableY()?this.setY(t[s].getDrawableY()-this.getHeight()):this.getDrawableY()+this.getHeight()>t[s].getDrawableY()+t[s].getHeight()&&this.setY(t[s].getDrawableY()+t[s].getHeight()))}separateObjectsWithForces(e){const t=n.staticArray(o.prototype.separateObjectsWithForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithForces);e.values(i);for(let s=0,r=i.length;s<r;++s)t.push.apply(t,i[s]);for(let s=0,r=t.length;s<r;++s)if(t[s].id!=this.id){if(this.getDrawableX()+this.getCenterX()<t[s].getDrawableX()+t[s].getCenterX()){let a=this.hasNoForces()?0:this.getAverageForce().getX();this.addForce(-a-10,0,0)}else{let a=this.hasNoForces()?0:this.getAverageForce().getX();this.addForce(-a+10,0,0)}if(this.getDrawableY()+this.getCenterY()<t[s].getDrawableY()+t[s].getCenterY()){let a=this.hasNoForces()?0:this.getAverageForce().getY();this.addForce(0,-a-10,0)}else{let a=this.hasNoForces()?0:this.getAverageForce().getY();this.addForce(0,-a+10,0)}}}static collisionTest(e,t,i,s=null){const r=e.getCenterX(),a=e.getCenterY(),l=Math.sqrt(_(e.getWidth(),e.getHeight(),r,a)),h=t.getCenterX(),m=t.getCenterY(),g=Math.sqrt(_(t.getWidth(),t.getHeight(),h,m)),c=e.getDrawableX()+r,u=e.getDrawableY()+a,B=t.getDrawableX()+h,v=t.getDrawableY()+m,p=c-B,f=u-v;if(Math.sqrt(p*p+f*f)>l+g)return!1;const y=e.getHitBoxesAround(B-g,v-g,B+g,v+g),d=t.getHitBoxesAround(c-l,u-l,c+l,u+l);for(const A of y)if(A!==s){for(const j of d)if(n.Polygon.collisionTest(A,j,i).collision)return!0}return!1}raycastTest(e,t,i,s,r){const a=this.getCenterX(),l=this.getCenterY(),h=_(this.getWidth(),this.getHeight(),a,l),m=(e+i)/2,g=(t+s)/2,c=(i-e)*(i-e)+(s-t)*(s-t),u=this.getDrawableX()+a-m,B=this.getDrawableY()+l-g;let v=D.result;if(v.collision=!1,u*u+B*B>h+c+2*Math.sqrt(c*h))return v;if(r){let p=Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const y of f){const d=n.Polygon.raycastTest(y,e,t,i,s);d.collision&&d.closeSqDist<p&&(p=d.closeSqDist,n.Polygon.copyRaycastTestResult(d,v))}}else{let p=-Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const y of f){const d=n.Polygon.raycastTest(y,e,t,i,s);d.collision&&d.farSqDist>p&&d.farSqDist<=c&&(p=d.farSqDist,n.Polygon.copyRaycastTestResult(d,v))}}return v}insideObject(e,t){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb.min[0]<=e&&this.aabb.max[0]>=e&&this.aabb.min[1]<=t&&this.aabb.max[1]>=t}static distanceTest(e,t,i){return e.getSqDistanceToObject(t)<=i}cursorOnObject(e){const t=n.staticArray(o.prototype.cursorOnObject);t.length=2;const i=e.getGame().getInputManager(),s=e.getLayer(this.layer),r=s.convertCoords(i.getCursorX(),i.getCursorY(),0,t);if(this.insideObject(r[0],r[1]))return!0;const a=i.getAllTouchIdentifiers();for(let l=0;l<a.length;++l){const h=s.convertCoords(i.getTouchX(a[l]),i.getTouchY(a[l]),0,t);if(this.insideObject(h[0],h[1]))return!0}return!1}isCollidingWithPoint(e,t){const i=this.getHitBoxesAround(e,t,e,t);for(const s of i)if(n.Polygon.isPointInside(s,e,t))return!0;return!1}static getNameIdentifier(e){if(o._identifiers.containsKey(e))return o._identifiers.get(e);o._newId=(o._newId||0)+1;const t=o._newId;return o._identifiers.put(e,t),t}};let b=o;b.supportsReinitialization=!1,b.setVariableBoolean=function(e,t){e.setBoolean(t)},b.getVariableBoolean=function(e,t){return n.evtTools.common.getVariableBoolean(e,t)},b.toggleVariableBoolean=function(e){n.evtTools.common.toggleVariableBoolean(e)},b.variablePushCopy=function(e,t){e.pushVariableCopy(t)},b.valuePush=function(e,t){e.pushValue(t)},b.variableRemoveAt=function(e,t){e.removeAtIndex(t)},b.getFirstVariableString=function(e){return e.getChildrenCount()===0?"":e.getAllChildrenArray()[0].getAsString()},b.getFirstVariableNumber=function(e){return e.getChildrenCount()===0?0:e.getAllChildrenArray()[0].getAsNumber()},b.getLastVariableString=function(e){const t=e.getAllChildrenArray();return t.length===0?"":t[t.length-1].getAsString()},b.getLastVariableNumber=function(e){const t=e.getAllChildrenArray();return t.length===0?0:t[t.length-1].getAsNumber()},b._identifiers=new Hashtable,b._newId=0,b.forcesGarbage=[],n.RuntimeObject=b,n.registerObject("",n.RuntimeObject)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimeobject.js.map