gdcore-tools 2.0.0-gd-v5.5.230-autobuild → 2.0.0-gd-v5.5.232-autobuild

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject2D.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject2D.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/CustomRuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +6 -2
  12. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  13. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  14. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  15. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  16. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  17. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  18. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
  19. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  20. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  21. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  22. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +1047 -3
  23. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  24. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  25. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +2 -0
  26. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +7 -0
  27. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  28. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  29. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +94 -9
  30. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +1 -1
  31. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +2 -2
  32. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
  33. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  34. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  35. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -1
  38. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  39. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  40. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  41. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  42. package/dist/Runtime/debugger-client/hot-reloader.js +3 -2
  43. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  44. package/dist/Runtime/events-tools/cameratools.js +1 -1
  45. package/dist/Runtime/events-tools/cameratools.js.map +2 -2
  46. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  47. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  48. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  49. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  50. package/dist/Runtime/runtimeobject.js +1 -1
  51. package/dist/Runtime/runtimeobject.js.map +2 -2
  52. package/dist/Runtime/runtimescene.js +1 -1
  53. package/dist/Runtime/runtimescene.js.map +2 -2
  54. package/dist/Runtime/spriteruntimeobject.js +1 -1
  55. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  56. package/dist/Runtime/types/project-data.d.ts +1 -1
  57. package/dist/lib/libGD.cjs +1 -1
  58. package/dist/lib/libGD.wasm +0 -0
  59. package/dist/loaders.cjs +3 -3
  60. package/gd.d.ts +7 -0
  61. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/events-tools/cameratools.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 export namespace evtTools {\n export namespace camera {\n export const setCameraX = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n x: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).setCameraX(x, cameraId);\n };\n\n export const setCameraY = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n y: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).setCameraY(y, cameraId);\n };\n\n export const getCameraX = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraX();\n };\n\n export const getCameraY = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraY();\n };\n\n export const getCameraWidth = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraWidth();\n };\n\n export const getCameraHeight = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraHeight();\n };\n\n export const getCameraBorderLeft = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraX(instanceContainer, layer, cameraId) -\n getCameraWidth(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderRight = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraX(instanceContainer, layer, cameraId) +\n getCameraWidth(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderTop = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraY(instanceContainer, layer, cameraId) -\n getCameraHeight(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderBottom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraY(instanceContainer, layer, cameraId) +\n getCameraHeight(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const showLayer = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).show(true);\n };\n\n export const hideLayer = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).show(false);\n };\n\n export const layerIsVisible = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): boolean {\n return (\n instanceContainer.hasLayer(layer) &&\n instanceContainer.getLayer(layer).isVisible()\n );\n };\n\n export const setCameraRotation = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n rotation: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setCameraRotation(rotation, cameraId);\n };\n\n export const getCameraRotation = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraRotation(cameraId);\n };\n\n export const getCameraZoom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraZoom(cameraId);\n };\n\n export const setCameraZoom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n newZoom: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setCameraZoom(newZoom, cameraId);\n };\n\n export const centerCamera = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n object: gdjs.RuntimeObject | null,\n anticipateMove: boolean,\n layerName: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layerName) || object == null) {\n return;\n }\n let xOffset = 0;\n let yOffset = 0;\n if (anticipateMove && !object.hasNoForces()) {\n const objectAverageForce = object.getAverageForce();\n const elapsedTimeInSeconds =\n object.getElapsedTime(instanceContainer) / 1000;\n xOffset = objectAverageForce.getX() * elapsedTimeInSeconds;\n yOffset = objectAverageForce.getY() * elapsedTimeInSeconds;\n }\n const layer = instanceContainer.getLayer(layerName);\n layer.setCameraX(object.getCenterXInScene() + xOffset, cameraId);\n layer.setCameraY(object.getCenterYInScene() + yOffset, cameraId);\n };\n\n /**\n * @deprecated prefer using centerCamera and clampCamera.\n */\n export const centerCameraWithinLimits = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n object: gdjs.RuntimeObject | null,\n left: number,\n top: number,\n right: number,\n bottom: number,\n anticipateMove: boolean,\n layerName: string,\n cameraId: integer\n ) {\n centerCamera(\n instanceContainer,\n object,\n anticipateMove,\n layerName,\n cameraId\n );\n clampCamera(\n instanceContainer,\n left,\n top,\n right,\n bottom,\n layerName,\n cameraId\n );\n };\n\n export const clampCamera = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n left: float,\n top: float,\n right: float,\n bottom: float,\n layerName: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layerName)) {\n return;\n }\n const layer = instanceContainer.getLayer(layerName);\n const cameraHalfWidth = layer.getCameraWidth(cameraId) / 2;\n const cameraHalfHeight = layer.getCameraHeight(cameraId) / 2;\n\n const centerLeftBound = left + cameraHalfWidth;\n const centerRightBound = right - cameraHalfWidth;\n const centerTopBound = top + cameraHalfHeight;\n const centerBottomBound = bottom - cameraHalfHeight;\n\n const cameraX =\n centerLeftBound < centerRightBound\n ? gdjs.evtTools.common.clamp(\n layer.getCameraX(cameraId),\n centerLeftBound,\n centerRightBound\n )\n : // Center on the bounds when they are too small to fit the viewport.\n (centerLeftBound + centerRightBound) / 2;\n const cameraY =\n centerTopBound < centerBottomBound\n ? gdjs.evtTools.common.clamp(\n layer.getCameraY(cameraId),\n centerTopBound,\n centerBottomBound\n )\n : // Center on the bounds when they are too small to fit the viewport.\n (centerTopBound + centerBottomBound) / 2;\n\n layer.setCameraX(cameraX, cameraId);\n layer.setCameraY(cameraY, cameraId);\n };\n\n /**\n * Update a layer effect property (with a number).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectDoubleParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: float\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectDoubleParameter(effect, parameter, value);\n };\n\n /**\n * Update a layer effect property (with a string).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectStringParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectStringParameter(effect, parameter, value);\n };\n\n /**\n * Enable or disable a layer effect property (boolean).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectBooleanParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: boolean\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectBooleanParameter(effect, parameter, value);\n };\n\n /**\n * Enable, or disable, an effect of a layer.\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param enabled true to enable, false to disable.\n */\n export const enableLayerEffect = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n enabled: boolean\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).enableEffect(effect, enabled);\n };\n\n /**\n * Check if an effect is enabled.\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @return true if the effect is enabled, false otherwise.\n */\n export const layerEffectEnabled = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string\n ): boolean {\n if (!instanceContainer.hasLayer(layer)) {\n return true;\n }\n return instanceContainer.getLayer(layer).isEffectEnabled(effect);\n };\n\n export const setLayerTimeScale = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n timeScale: float\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).setTimeScale(timeScale);\n };\n\n export const getLayerTimeScale = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 1;\n }\n return instanceContainer.getLayer(layer).getTimeScale();\n };\n\n export const setLayerDefaultZOrder = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n defaultZOrder: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setDefaultZOrder(defaultZOrder);\n };\n\n export const getLayerDefaultZOrder = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getDefaultZOrder();\n };\n\n /**\n * @param instanceContainer the container owning the layer\n * @param layerName The lighting layer with the ambient color.\n * @param rgbColor The color, in RGB format (\"128;200;255\").\n */\n export const setLayerAmbientLightColor = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layerName: string,\n rgbColor: string\n ) {\n if (\n !instanceContainer.hasLayer(layerName) ||\n !instanceContainer.getLayer(layerName).isLightingLayer()\n ) {\n return;\n }\n const colors = rgbColor.split(';');\n if (colors.length < 3) {\n return;\n }\n return instanceContainer\n .getLayer(layerName)\n .setClearColor(\n parseInt(colors[0], 10),\n parseInt(colors[1], 10),\n parseInt(colors[2], 10)\n );\n };\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CACE,AAAM,aAAa,SACxB,EACA,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAkB,SAAS,IAGhC,EAAkB,SAAS,GAAO,WAAW,EAAG,IAGrC,aAAa,SACxB,EACA,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAkB,SAAS,IAGhC,EAAkB,SAAS,GAAO,WAAW,EAAG,IAGrC,aAAa,SACxB,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,aAFhC,GAKE,aAAa,SACxB,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,aAFhC,GAKE,iBAAiB,SAC5B,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,iBAFhC,GAKE,kBAAkB,SAC7B,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,kBAFhC,GAKE,sBAAsB,SACjC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,EAAO,GACrC,iBAAe,EAAmB,EAAO,GAAY,EAJ9C,GAQE,uBAAuB,SAClC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,EAAO,GACrC,iBAAe,EAAmB,EAAO,GAAY,EAJ9C,GAQE,qBAAqB,SAChC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,E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AAkB,SAAS,GAAO,gBAAgB,GAFhD,IAKE,oBAAoB,SAC/B,EACA,EACA,EACA,CACA,GAAI,EAAC,EAAkB,SAAS,GAGhC,MAAO,GAAkB,SAAS,GAAO,aAAa,IAG3C,oBAAoB,SAC/B,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,eAFhC,GAKE,wBAAwB,SACnC,EACA,EACA,EACA,CACA,GAAI,EAAC,EAAkB,SAAS,GAGhC,MAAO,GACJ,SAAS,GACT,iBAAiB,IAGT,wBAAwB,SACnC,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,mBAFhC,GAUE,4BAA4B,SACvC,EACA,EACA,EACA,CACA,GACE,CAAC,EAAkB,SAAS,IAC5B,CAAC,EAAkB,SAAS,GAAW,kBAEvC,OAEF,KAAM,GAAS,EAAS,MAAM,KAC9B,GAAI,IAAO,OAAS,GAGpB,MAAO,GACJ,SAAS,GACT,cACC,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,QAheX,6BADF,iCADT",
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 export namespace evtTools {\n export namespace camera {\n export const setCameraX = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n x: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).setCameraX(x, cameraId);\n };\n\n export const setCameraY = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n y: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).setCameraY(y, cameraId);\n };\n\n export const getCameraX = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraX();\n };\n\n export const getCameraY = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraY();\n };\n\n export const getCameraWidth = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraWidth();\n };\n\n export const getCameraHeight = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraHeight();\n };\n\n export const getCameraBorderLeft = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraX(instanceContainer, layer, cameraId) -\n getCameraWidth(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderRight = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraX(instanceContainer, layer, cameraId) +\n getCameraWidth(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderTop = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraY(instanceContainer, layer, cameraId) -\n getCameraHeight(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const getCameraBorderBottom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return (\n getCameraY(instanceContainer, layer, cameraId) +\n getCameraHeight(instanceContainer, layer, cameraId) / 2\n );\n };\n\n export const showLayer = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).show(true);\n };\n\n export const hideLayer = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).show(false);\n };\n\n export const layerIsVisible = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): boolean {\n return (\n instanceContainer.hasLayer(layer) &&\n instanceContainer.getLayer(layer).isVisible()\n );\n };\n\n export const setCameraRotation = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n rotation: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setCameraRotation(rotation, cameraId);\n };\n\n export const getCameraRotation = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraRotation(cameraId);\n };\n\n export const getCameraZoom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n cameraId: integer\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getCameraZoom(cameraId);\n };\n\n export const setCameraZoom = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n newZoom: float,\n layer: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setCameraZoom(newZoom, cameraId);\n };\n\n export const centerCamera = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n object: gdjs.RuntimeObject | null,\n anticipateMove: boolean,\n layerName: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layerName) || object == null) {\n return;\n }\n let xOffset = 0;\n let yOffset = 0;\n if (anticipateMove && !object.hasNoForces()) {\n const objectAverageForce = object.getAverageForce();\n const elapsedTimeInSeconds = object.getElapsedTime() / 1000;\n xOffset = objectAverageForce.getX() * elapsedTimeInSeconds;\n yOffset = objectAverageForce.getY() * elapsedTimeInSeconds;\n }\n const layer = instanceContainer.getLayer(layerName);\n layer.setCameraX(object.getCenterXInScene() + xOffset, cameraId);\n layer.setCameraY(object.getCenterYInScene() + yOffset, cameraId);\n };\n\n /**\n * @deprecated prefer using centerCamera and clampCamera.\n */\n export const centerCameraWithinLimits = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n object: gdjs.RuntimeObject | null,\n left: number,\n top: number,\n right: number,\n bottom: number,\n anticipateMove: boolean,\n layerName: string,\n cameraId: integer\n ) {\n centerCamera(\n instanceContainer,\n object,\n anticipateMove,\n layerName,\n cameraId\n );\n clampCamera(\n instanceContainer,\n left,\n top,\n right,\n bottom,\n layerName,\n cameraId\n );\n };\n\n export const clampCamera = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n left: float,\n top: float,\n right: float,\n bottom: float,\n layerName: string,\n cameraId: integer\n ) {\n if (!instanceContainer.hasLayer(layerName)) {\n return;\n }\n const layer = instanceContainer.getLayer(layerName);\n const cameraHalfWidth = layer.getCameraWidth(cameraId) / 2;\n const cameraHalfHeight = layer.getCameraHeight(cameraId) / 2;\n\n const centerLeftBound = left + cameraHalfWidth;\n const centerRightBound = right - cameraHalfWidth;\n const centerTopBound = top + cameraHalfHeight;\n const centerBottomBound = bottom - cameraHalfHeight;\n\n const cameraX =\n centerLeftBound < centerRightBound\n ? gdjs.evtTools.common.clamp(\n layer.getCameraX(cameraId),\n centerLeftBound,\n centerRightBound\n )\n : // Center on the bounds when they are too small to fit the viewport.\n (centerLeftBound + centerRightBound) / 2;\n const cameraY =\n centerTopBound < centerBottomBound\n ? gdjs.evtTools.common.clamp(\n layer.getCameraY(cameraId),\n centerTopBound,\n centerBottomBound\n )\n : // Center on the bounds when they are too small to fit the viewport.\n (centerTopBound + centerBottomBound) / 2;\n\n layer.setCameraX(cameraX, cameraId);\n layer.setCameraY(cameraY, cameraId);\n };\n\n /**\n * Update a layer effect property (with a number).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectDoubleParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: float\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectDoubleParameter(effect, parameter, value);\n };\n\n /**\n * Update a layer effect property (with a string).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectStringParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: string\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectStringParameter(effect, parameter, value);\n };\n\n /**\n * Enable or disable a layer effect property (boolean).\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param parameter The property to update\n * @param value The new value\n */\n export const setLayerEffectBooleanParameter = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n parameter: string,\n value: boolean\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setEffectBooleanParameter(effect, parameter, value);\n };\n\n /**\n * Enable, or disable, an effect of a layer.\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @param enabled true to enable, false to disable.\n */\n export const enableLayerEffect = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string,\n enabled: boolean\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n instanceContainer.getLayer(layer).enableEffect(effect, enabled);\n };\n\n /**\n * Check if an effect is enabled.\n * @param instanceContainer the container owning the layer\n * @param layer The name of the layer\n * @param effect The name of the effect\n * @return true if the effect is enabled, false otherwise.\n */\n export const layerEffectEnabled = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n effect: string\n ): boolean {\n if (!instanceContainer.hasLayer(layer)) {\n return true;\n }\n return instanceContainer.getLayer(layer).isEffectEnabled(effect);\n };\n\n export const setLayerTimeScale = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n timeScale: float\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer.getLayer(layer).setTimeScale(timeScale);\n };\n\n export const getLayerTimeScale = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 1;\n }\n return instanceContainer.getLayer(layer).getTimeScale();\n };\n\n export const setLayerDefaultZOrder = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string,\n defaultZOrder: integer\n ) {\n if (!instanceContainer.hasLayer(layer)) {\n return;\n }\n return instanceContainer\n .getLayer(layer)\n .setDefaultZOrder(defaultZOrder);\n };\n\n export const getLayerDefaultZOrder = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: string\n ): number {\n if (!instanceContainer.hasLayer(layer)) {\n return 0;\n }\n return instanceContainer.getLayer(layer).getDefaultZOrder();\n };\n\n /**\n * @param instanceContainer the container owning the layer\n * @param layerName The lighting layer with the ambient color.\n * @param rgbColor The color, in RGB format (\"128;200;255\").\n */\n export const setLayerAmbientLightColor = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layerName: string,\n rgbColor: string\n ) {\n if (\n !instanceContainer.hasLayer(layerName) ||\n !instanceContainer.getLayer(layerName).isLightingLayer()\n ) {\n return;\n }\n const colors = rgbColor.split(';');\n if (colors.length < 3) {\n return;\n }\n return instanceContainer\n .getLayer(layerName)\n .setClearColor(\n parseInt(colors[0], 10),\n parseInt(colors[1], 10),\n parseInt(colors[2], 10)\n );\n };\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CACE,AAAM,aAAa,SACxB,EACA,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAkB,SAAS,IAGhC,EAAkB,SAAS,GAAO,WAAW,EAAG,IAGrC,aAAa,SACxB,EACA,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAkB,SAAS,IAGhC,EAAkB,SAAS,GAAO,WAAW,EAAG,IAGrC,aAAa,SACxB,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,aAFhC,GAKE,aAAa,SACxB,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,aAFhC,GAKE,iBAAiB,SAC5B,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,iBAFhC,GAKE,kBAAkB,SAC7B,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,kBAFhC,GAKE,sBAAsB,SACjC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,EAAO,GACrC,iBAAe,EAAmB,EAAO,GAAY,EAJ9C,GAQE,uBAAuB,SAClC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,EAAO,GACrC,iBAAe,EAAmB,EAAO,GAAY,EAJ9C,GAQE,qBAAqB,SAChC,EACA,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAI9B,aAAW,EAAmB,EAAO,GACrC,kBAAgB,EAAmB,EAAO,GAAY,EAJ/C,GAQE,wBAA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A,EACA,CACA,GAAI,EAAC,EAAkB,SAAS,GAGhC,MAAO,GAAkB,SAAS,GAAO,aAAa,IAG3C,oBAAoB,SAC/B,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,eAFhC,GAKE,wBAAwB,SACnC,EACA,EACA,EACA,CACA,GAAI,EAAC,EAAkB,SAAS,GAGhC,MAAO,GACJ,SAAS,GACT,iBAAiB,IAGT,wBAAwB,SACnC,EACA,EACQ,CACR,MAAK,GAAkB,SAAS,GAGzB,EAAkB,SAAS,GAAO,mBAFhC,GAUE,4BAA4B,SACvC,EACA,EACA,EACA,CACA,GACE,CAAC,EAAkB,SAAS,IAC5B,CAAC,EAAkB,SAAS,GAAW,kBAEvC,OAEF,KAAM,GAAS,EAAS,MAAM,KAC9B,GAAI,IAAO,OAAS,GAGpB,MAAO,GACJ,SAAS,GACT,cACC,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,IACpB,SAAS,EAAO,GAAI,QA/dX,6BADF,iCADT",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(a){const h=new a.Logger("Audio manager"),c=["audio"],_={preload:!0,onplayerror:(u,e)=>h.error("Can't play an audio file: "+e),onloaderror:(u,e)=>h.error("Error while loading an audio file: "+e)},d=u=>u>1?1:u<0?0:u;class p{constructor(e,s,t,o){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=d(s),this._loop=t,this._rate=o}isLoaded(){return this._howl.state()==="loaded"}play(){if(this.isLoaded()){const e=this._howl.play(this._id===null?"__default":this._id);this._id=e,this._howl.volume(this._initialVolume,e),this._howl.loop(this._loop,e),this._howl.rate(a.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(s=>{this.on("play",s),s(e)}),this._oncePlay.forEach(s=>s(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play());return this}pause(){return this._id!==null&&this._howl.pause(this._id),this}stop(){return this._id!==null&&this._howl.stop(this._id),this}playing(){return(this._id!==null?this._howl.playing(this._id):!0)||!this.isLoaded()}paused(){return!this.playing()}stopped(){return this.paused()&&this.getSeek()===0}getRate(){return this._rate}setRate(e){return this._rate=e,this._id!==null&&(e=a.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id)),this}getLoop(){return this._loop}setLoop(e){return this._loop=e,this._id!==null&&this._howl.loop(e,this._id),this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){return this._initialVolume=d(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id),this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){return this._id!==null&&this._howl.mute(e,this._id),this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){return this._id!==null&&this._howl.seek(e,this._id),this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,s,t){return this._id!==null&&this._howl.pos(e,s,t,this._id),this}fade(e,s,t){return this._id!==null&&this._howl.fade(d(e),d(s),t,this._id),this}on(e,s){return e==="play"?this._id===null?this._onPlay.push(s):this._howl.on(e,s,this._id):this._id===null?this.once("play",()=>this.on(e,s)):this._howl.on(e,s,this._id),this}once(e,s){return e==="play"?this._id===null?this._oncePlay.push(s):this.playing()?s(this._id):this._howl.once(e,s,this._id):this._id===null?this.once("play",()=>this.once(e,s)):this._howl.once(e,s,this._id),this}off(e,s){return this._id!==null&&this._howl.off(e,s,this._id),this}}a.HowlerSound=p;class f{constructor(e){this._loadedMusics=new a.ResourceCache;this._loadedSounds=new a.ResourceCache;this._availableResources={};this._globalVolume=100;this._sounds={};this._cachedSpatialPosition={};this._musics={};this._freeSounds=[];this._freeMusics=[];this._pausedSounds=[];this._paused=!1;this._getAudioResource=e=>{const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e,a.registerRuntimeScenePostEventsCallback(this._clearCachedSpatialPosition.bind(this));const s=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){const t=s._freeSounds.concat(s._freeMusics);for(let o in s._sounds)s._sounds.hasOwnProperty(o)&&t.push(s._sounds[o]);for(let o in s._musics)s._musics.hasOwnProperty(o)&&t.push(s._musics[o]);for(let o=0;o<t.length;o++){const i=t[o];!i.paused()&&!i.stopped()&&(i.pause(),s._pausedSounds.push(i))}s._paused=!0},!1),document.addEventListener("resume",function(){try{for(let t=0;t<s._pausedSounds.length;t++){const o=s._pausedSounds[t];o.stopped()||o.play()}}catch(t){if(t.message&&typeof t.message=="string"&&t.message.startsWith("Maximum call stack size exceeded"))console.warn("An error occurred when resuming paused sounds while the game was in background:",t);else throw t}s._pausedSounds.length=0,s._paused=!1},!1)})}getResourceKinds(){return c}static clampRate(e){return e>4?4:e<.5?.5:e}_getSoundUrlsFromResource(e){return[this._resourceLoader.getFullUrl(e.file)]}_getDefaultSoundUrl(e){return this._resourceLoader.getFullUrl(e.file)}_preloadAudioFile(e,s){const t=e.file;return new Promise((o,i)=>{const l=s?this._loadedMusics:this._loadedSounds;l[t]=new Howl(Object.assign({},_,{src:this._getSoundUrlsFromResource(e),onload:o,onloaderror:(r,n)=>i(n),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(t)},volume:0}))})}_storeSoundInArray(e,s){for(let t=0,o=e.length;t<o;++t)if(!e[t]||e[t].stopped())return e[t]=s,s;return e.push(s),s}createHowlerSound(e,s,t,o,i){const l=s?this._loadedMusics:this._loadedSounds,r=this._getAudioResource(e);let n=l.get(r);return n||(n=new Howl(Object.assign({src:this._getSoundUrlsFromResource(r),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(r.file)},volume:0},_)),l.set(r,n)),new a.HowlerSound(n,t,o,i)}loadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,o=this._getAudioResource(e);t.get(o)||t.set(o,new Howl(Object.assign({src:this._getSoundUrlsFromResource(o),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(o.file)},volume:0},_)))}unloadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,o=this._getAudioResource(e),i=t.get(o);if(!i)return;function l(r){for(let n in r)r[n]&&r[n]._howl===i&&(r[n].stop(),delete r[n])}l(this._freeMusics),l(this._freeSounds),l(Object.values(this._musics)),l(Object.values(this._sounds)),l(this._pausedSounds),i.unload(),t.delete(o)}unloadAll(){Howler.unload(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0,this._loadedMusics.clear(),this._loadedSounds.clear()}playSound(e,s,t,o){const i=this.createHowlerSound(e,!1,t/100,s,o);this._storeSoundInArray(this._freeSounds,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playSoundOnChannel(e,s,t,o,i){this._sounds[s]&&this._sounds[s].stop();const l=this.createHowlerSound(e,!1,o/100,t,i),r=this._cachedSpatialPosition[s];r&&l.once("play",()=>{l.setSpatialPosition(...r)}),this._sounds[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,s,t,o){const i=this.createHowlerSound(e,!0,t/100,s,o);this._storeSoundInArray(this._freeMusics,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playMusicOnChannel(e,s,t,o,i){this._musics[s]&&this._musics[s].stop();const l=this.createHowlerSound(e,!0,o/100,t,i);this._musics[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getMusicOnChannel(e){return this._musics[e]||null}setSoundSpatialPositionOnChannel(e,s,t,o){const i=this.getSoundOnChannel(e);i&&!i.paused()?i.setSpatialPosition(s,t,o):this._cachedSpatialPosition[e]=[s,t,o]}_clearCachedSpatialPosition(){this._cachedSpatialPosition={}}setGlobalVolume(e){this._globalVolume=e,this._globalVolume>100&&(this._globalVolume=100),this._globalVolume<0&&(this._globalVolume=0),Howler.volume(this._globalVolume/100)}getGlobalVolume(){return this._globalVolume}clearAll(){Howler.stop(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0}async processResource(e){}async loadResource(e){const s=this._resourceLoader.getResource(e);if(!s){h.warn('Unable to find audio for resource "'+e+'".');return}if(s.file){if(this._availableResources[s.name])return;this._availableResources[s.name]=s}if(s.preloadAsMusic)try{await this._preloadAudioFile(s,!0)}catch(t){h.warn("There was an error while preloading an audio file: "+t)}if(s.preloadAsSound)try{await this._preloadAudioFile(s,!1)}catch(t){h.warn("There was an error while preloading an audio file: "+t)}else if(s.preloadInCache||!s.preloadAsMusic)try{const t=s.file;await new Promise((o,i)=>{const l=new XMLHttpRequest;l.withCredentials=this._resourceLoader.checkIfCredentialsRequired(t),l.addEventListener("load",o),l.addEventListener("error",r=>i("XHR error: "+t)),l.addEventListener("abort",r=>i("XHR abort: "+t)),l.open("GET",this._getDefaultSoundUrl(s)),l.send()})}catch(t){h.warn("There was an error while preloading an audio file: "+t)}}dispose(){this.unloadAll()}}a.HowlerSoundManager=f,a.SoundManager=f})(gdjs||(gdjs={}));
1
+ var gdjs;(function(a){const h=new a.Logger("Audio manager"),_=["audio"],c={preload:!0,onplayerror:(u,e)=>h.error("Can't play an audio file: "+e),onloaderror:(u,e)=>h.error("Error while loading an audio file: "+e)},d=u=>u>1?1:u<0?0:u;class f{constructor(e,s,t,l){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=d(s),this._loop=t,this._rate=l}isLoaded(){return this._howl.state()==="loaded"}play(){if(this.isLoaded()){const e=this._howl.play(this._id===null?"__default":this._id);this._id=e,this._howl.volume(this._initialVolume,e),this._howl.loop(this._loop,e),this._howl.rate(a.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(s=>{this.on("play",s),s(e)}),this._oncePlay.forEach(s=>s(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play());return this}pause(){return this._id!==null&&this._howl.pause(this._id),this}stop(){return this._id!==null&&this._howl.stop(this._id),this}playing(){return(this._id!==null?this._howl.playing(this._id):!0)||!this.isLoaded()}paused(){return!this.playing()}stopped(){return this.paused()&&this.getSeek()===0}getRate(){return this._rate}setRate(e){return this._rate=e,this._id!==null&&(e=a.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id)),this}getLoop(){return this._loop}setLoop(e){return this._loop=e,this._id!==null&&this._howl.loop(e,this._id),this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){return this._initialVolume=d(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id),this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){return this._id!==null&&this._howl.mute(e,this._id),this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){return this._id!==null&&this._howl.seek(e,this._id),this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,s,t){return this._id!==null&&this._howl.pos(e,s,t,this._id),this}fade(e,s,t){return this._id!==null&&this._howl.fade(d(e),d(s),t,this._id),this}on(e,s){return e==="play"?this._id===null?this._onPlay.push(s):this._howl.on(e,s,this._id):this._id===null?this.once("play",()=>this.on(e,s)):this._howl.on(e,s,this._id),this}once(e,s){return e==="play"?this._id===null?this._oncePlay.push(s):this.playing()?s(this._id):this._howl.once(e,s,this._id):this._id===null?this.once("play",()=>this.once(e,s)):this._howl.once(e,s,this._id),this}off(e,s){return this._id!==null&&this._howl.off(e,s,this._id),this}}a.HowlerSound=f;class p{constructor(e){this._loadedMusics=new a.ResourceCache;this._loadedSounds=new a.ResourceCache;this._availableResources={};this._globalVolume=100;this._sounds={};this._cachedSpatialPosition={};this._musics={};this._freeSounds=[];this._freeMusics=[];this._pausedSounds=[];this._paused=!1;this._getAudioResource=e=>{const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e,a.registerRuntimeScenePostEventsCallback(this._clearCachedSpatialPosition.bind(this));const s=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){s.pauseAllActiveSounds()},!1),document.addEventListener("resume",function(){s.resumeAllActiveSounds()},!1)})}pauseAllActiveSounds(){const e=this._freeSounds.concat(this._freeMusics);for(let s in this._sounds)this._sounds.hasOwnProperty(s)&&e.push(this._sounds[s]);for(let s in this._musics)this._musics.hasOwnProperty(s)&&e.push(this._musics[s]);for(let s=0;s<e.length;s++){const t=e[s];!t.paused()&&!t.stopped()&&(t.pause(),this._pausedSounds.push(t))}this._paused=!0}resumeAllActiveSounds(){try{for(let e=0;e<this._pausedSounds.length;e++){const s=this._pausedSounds[e];s.stopped()||s.play()}}catch(e){if(e.message&&typeof e.message=="string"&&e.message.startsWith("Maximum call stack size exceeded"))console.warn("An error occurred when resuming paused sounds while the game was in background:",e);else throw e}this._pausedSounds.length=0,this._paused=!1}getResourceKinds(){return _}static clampRate(e){return e>4?4:e<.5?.5:e}_getSoundUrlsFromResource(e){return[this._resourceLoader.getFullUrl(e.file)]}_getDefaultSoundUrl(e){return this._resourceLoader.getFullUrl(e.file)}_preloadAudioFile(e,s){const t=e.file;return new Promise((l,i)=>{const o=s?this._loadedMusics:this._loadedSounds;o[t]=new Howl(Object.assign({},c,{src:this._getSoundUrlsFromResource(e),onload:l,onloaderror:(r,n)=>i(n),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(t)},volume:0}))})}_storeSoundInArray(e,s){for(let t=0,l=e.length;t<l;++t)if(!e[t]||e[t].stopped())return e[t]=s,s;return e.push(s),s}createHowlerSound(e,s,t,l,i){const o=s?this._loadedMusics:this._loadedSounds,r=this._getAudioResource(e);let n=o.get(r);return n||(n=new Howl(Object.assign({src:this._getSoundUrlsFromResource(r),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(r.file)},volume:0},c)),o.set(r,n)),new a.HowlerSound(n,t,l,i)}loadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,l=this._getAudioResource(e);t.get(l)||t.set(l,new Howl(Object.assign({src:this._getSoundUrlsFromResource(l),html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(l.file)},volume:0},c)))}unloadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,l=this._getAudioResource(e),i=t.get(l);if(!i)return;function o(r){for(let n in r)r[n]&&r[n]._howl===i&&(r[n].stop(),delete r[n])}o(this._freeMusics),o(this._freeSounds),o(Object.values(this._musics)),o(Object.values(this._sounds)),o(this._pausedSounds),i.unload(),t.delete(l)}unloadAll(){Howler.unload(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0,this._loadedMusics.clear(),this._loadedSounds.clear()}playSound(e,s,t,l){const i=this.createHowlerSound(e,!1,t/100,s,l);this._storeSoundInArray(this._freeSounds,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playSoundOnChannel(e,s,t,l,i){this._sounds[s]&&this._sounds[s].stop();const o=this.createHowlerSound(e,!1,l/100,t,i),r=this._cachedSpatialPosition[s];r&&o.once("play",()=>{o.setSpatialPosition(...r)}),this._sounds[s]=o,o.once("play",()=>{this._paused&&(o.pause(),this._pausedSounds.push(o))}),o.play()}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,s,t,l){const i=this.createHowlerSound(e,!0,t/100,s,l);this._storeSoundInArray(this._freeMusics,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playMusicOnChannel(e,s,t,l,i){this._musics[s]&&this._musics[s].stop();const o=this.createHowlerSound(e,!0,l/100,t,i);this._musics[s]=o,o.once("play",()=>{this._paused&&(o.pause(),this._pausedSounds.push(o))}),o.play()}getMusicOnChannel(e){return this._musics[e]||null}setSoundSpatialPositionOnChannel(e,s,t,l){const i=this.getSoundOnChannel(e);i&&!i.paused()?i.setSpatialPosition(s,t,l):this._cachedSpatialPosition[e]=[s,t,l]}_clearCachedSpatialPosition(){this._cachedSpatialPosition={}}setGlobalVolume(e){this._globalVolume=e,this._globalVolume>100&&(this._globalVolume=100),this._globalVolume<0&&(this._globalVolume=0),Howler.volume(this._globalVolume/100)}getGlobalVolume(){return this._globalVolume}clearAll(){Howler.stop(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0}async processResource(e){}async loadResource(e){const s=this._resourceLoader.getResource(e);if(!s){h.warn('Unable to find audio for resource "'+e+'".');return}if(s.file){if(this._availableResources[s.name])return;this._availableResources[s.name]=s}if(s.preloadAsMusic)try{await this._preloadAudioFile(s,!0)}catch(t){h.warn("There was an error while preloading an audio file: "+t)}if(s.preloadAsSound)try{await this._preloadAudioFile(s,!1)}catch(t){h.warn("There was an error while preloading an audio file: "+t)}else if(s.preloadInCache||!s.preloadAsMusic)try{const t=s.file;await new Promise((l,i)=>{const o=new XMLHttpRequest;o.withCredentials=this._resourceLoader.checkIfCredentialsRequired(t),o.addEventListener("load",l),o.addEventListener("error",r=>i("XHR error: "+t)),o.addEventListener("abort",r=>i("XHR abort: "+t)),o.open("GET",this._getDefaultSoundUrl(s)),o.send()})}catch(t){h.warn("There was an error while preloading an audio file: "+t)}}dispose(){this.unloadAll()}}a.HowlerSoundManager=p,a.SoundManager=p})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=howler-sound-manager.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/howler-sound-manager/howler-sound-manager.ts"],
4
- "sourcesContent": ["///<reference path='../types/howler'>\n/*\n * GDevelop JS Platform\n * Copyright 2013-present 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('Audio manager');\n\n const resourceKinds: Array<ResourceKind> = ['audio'];\n\n const HowlParameters: HowlOptions = {\n preload: true,\n onplayerror: (_, error) =>\n logger.error(\"Can't play an audio file: \" + error),\n onloaderror: (_, error) =>\n logger.error('Error while loading an audio file: ' + error),\n };\n\n /**\n * Ensure the volume is between 0 and 1.\n */\n const clampVolume = (volume: float): float => {\n if (volume > 1.0) {\n return 1.0;\n }\n if (volume < 0) {\n return 0;\n }\n return volume;\n };\n\n /**\n * A thin wrapper around a Howl object with:\n * * Handling of callbacks when the sound is not yet loaded.\n * * Automatic clamping when calling `setRate` to ensure a valid value is passed to Howler.js.\n * * Automatic clamping when calling `setVolume` so that the volume is always between 0 and 1.\n *\n * @memberof gdjs\n * @class HowlerSound\n */\n export class HowlerSound {\n /**\n * The ID of the played sound.\n */\n private _id: integer | null = null;\n\n /**\n * The Howl passed to the constructor.\n * It defines the sound file that is being played.\n */\n private _howl: Howl;\n\n /**\n * The **initial** volume at which the sound is being played.\n * Once the sound is started, this volume can be not in sync\n * (in the case the sound is faded by Howler), so volume must\n * be gotten from `this._howl` directly.\n *\n * This value is clamped between 0 and 1.\n */\n private _initialVolume: float;\n\n /**\n * Whether the sound is being played in a loop or not.\n */\n private _loop: boolean;\n\n /**\n * The rate (speed) the sound is being played at.\n * This value is not clamped, though technically Howler.js will only\n * accepts values between a specific range (so we clamp this when\n * passing it to Howler.js, but keep the original value here).\n */\n private _rate: float;\n\n /**\n * An array of callbacks to call once the sound starts to play.\n */\n private _oncePlay: Array<HowlCallback> = [];\n\n /**\n * An array of callbacks to call everytime the sound starts to play.\n */\n private _onPlay: Array<HowlCallback> = [];\n\n constructor(howl: Howl, volume: float, loop: boolean, rate: float) {\n this._howl = howl;\n this._initialVolume = clampVolume(volume);\n this._loop = loop;\n this._rate = rate;\n }\n\n /**\n * Returns true if the associated howl is fully loaded.\n */\n isLoaded(): boolean {\n return this._howl.state() === 'loaded';\n }\n\n /**\n * Begins playback of the sound, or if the Howl is still loading, schedule playing for once it loads.\n * @returns The current instance for chaining.\n */\n play(): this {\n if (this.isLoaded()) {\n const newID = this._howl.play(\n this._id === null ? '__default' : this._id\n );\n this._id = newID;\n\n // Set the howl properties as soon as the sound is played and we have its ID.\n this._howl.volume(this._initialVolume, newID); // this._initialVolume is already clamped between 0 and 1.\n this._howl.loop(this._loop, newID);\n // this._rate is not clamped, but we need to clamp it when passing it to Howler.js as it\n // only supports a specific range.\n this._howl.rate(gdjs.HowlerSoundManager.clampRate(this._rate), newID);\n\n // Manually handle the play event before we have an ID.\n // Before loading, howler won't register events as without an ID we cannot set a listener.\n // Once we have an ID, we can transfer control of the events to howler.\n // We also need to call them once as Howler doesn't for the first play event.\n this._onPlay.forEach((func) => {\n // Transfer the event to howler now that we have an ID\n this.on('play', func);\n func(newID);\n });\n this._oncePlay.forEach((func) => func(newID));\n this._onPlay = [];\n this._oncePlay = [];\n } else this._howl.once('load', () => this.play()); // Play only once the howl is fully loaded\n\n return this;\n }\n\n /**\n * Pauses playback of the sound, saving the seek of playback.\n * @returns The current instance for chaining.\n */\n pause(): this {\n if (this._id !== null) this._howl.pause(this._id);\n return this;\n }\n\n /**\n * Stops playback of the sound, resetting seek to 0.\n * @returns The current instance for chaining.\n */\n stop(): this {\n if (this._id !== null) this._howl.stop(this._id);\n return this;\n }\n\n /**\n * Check if the sound is currently playing.\n * Note that a loading sound is considered as playing (as it will be\n * played as soon as it's loaded). To avoid loading at runtime, prefer\n * to preload the sounds.\n */\n playing(): boolean {\n return (\n (this._id !== null ? this._howl.playing(this._id) : true) ||\n !this.isLoaded() // Loading is considered playing\n );\n }\n\n /**\n * Check if the sound is currently paused.\n */\n paused(): boolean {\n return !this.playing();\n }\n\n /**\n * Check if the sound is currently stopped.\n */\n stopped(): boolean {\n return this.paused() && this.getSeek() === 0;\n }\n\n /**\n * Get the sound playback rate. This 1 for the default speed.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n */\n getRate(): float {\n return this._rate;\n }\n\n /**\n * Set the playback rate.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n * @returns The current instance for chaining.\n */\n setRate(rate: float): this {\n this._rate = rate;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) {\n rate = gdjs.HowlerSoundManager.clampRate(rate);\n this._howl.rate(rate, this._id);\n }\n return this;\n }\n\n /**\n * Get if the sound is looping.\n */\n getLoop(): boolean {\n return this._loop;\n }\n\n /**\n * Set if the sound is looping.\n * @returns The current instance for chaining.\n */\n setLoop(loop: boolean): this {\n this._loop = loop;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.loop(loop, this._id);\n return this;\n }\n\n //TODO: Replace float type in those 2 methods with RangeOf<0..1> once it is standardized (https://github.com/Microsoft/TypeScript/issues/15480)\n /**\n * Get the sound volume.\n * @returns A float from 0 to 1.\n */\n getVolume(): float {\n if (this._id === null) return this._initialVolume;\n return this._howl.volume(this._id);\n }\n\n /**\n * Set the sound volume.\n * @param volume A float from 0 to 1. The value is clamped if too high or too low.\n * @returns The current instance for chaining.\n */\n setVolume(volume: float): this {\n this._initialVolume = clampVolume(volume);\n\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.volume(this._initialVolume, this._id);\n return this;\n }\n\n /**\n * Get if the sound is muted.\n */\n getMute(): boolean {\n if (this._id === null) return false;\n return this._howl.mute(this._id);\n }\n\n /**\n * Set if the sound is muted.\n * @returns The current instance for chaining.\n */\n setMute(mute: boolean): this {\n if (this._id !== null) this._howl.mute(mute, this._id);\n return this;\n }\n\n /**\n * Get the sound seek.\n */\n getSeek(): float {\n if (this._id === null) return 0;\n return this._howl.seek(this._id);\n }\n\n /**\n * Set the sound seek.\n * @returns The current instance for chaining.\n */\n setSeek(seek: float): this {\n if (this._id !== null) this._howl.seek(seek, this._id);\n return this;\n }\n\n /**\n * Get the sound spatial position.\n */\n getSpatialPosition(axis: 'x' | 'y' | 'z'): float {\n if (this._id === null) return 0;\n return this._howl.pos(this._id)[axis === 'x' ? 0 : axis === 'y' ? 1 : 2];\n }\n\n /**\n * Set the sound spatial position.\n * @returns The current instance for chaining.\n */\n setSpatialPosition(x: float, y: float, z: float): this {\n if (this._id !== null) this._howl.pos(x, y, z, this._id);\n return this;\n }\n\n /**\n * Fade the volume sound.\n * @returns The current instance for chaining.\n */\n fade(from: float, to: float, duration: float): this {\n if (this._id !== null)\n this._howl.fade(clampVolume(from), clampVolume(to), duration, this._id);\n return this;\n }\n\n /**\n * Adds an event listener to the howl.\n */\n on(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._onPlay.push(handler);\n } else {\n this._howl.on(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.on(event, handler));\n else this._howl.on(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Adds an event listener to the howl that removes itself after being called.\n * If the event is `play` and the sound is being played, the handler is\n * called synchronously.\n */\n once(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._oncePlay.push(handler);\n } else if (this.playing()) {\n // Immediately call the handler if the sound is already playing.\n // This is useful for sounds that were just started and have a `.once('play', ...)`\n // handler added on them to set up the volume/rate/loop. If we don't do it\n // synchronously, the sound can play for a tiny bit at the default volume and rate.\n // See https://github.com/4ian/GDevelop/issues/2490.\n handler(this._id);\n } else {\n this._howl.once(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.once(event, handler));\n else this._howl.once(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Removes an event listener to the howl.\n */\n off(event: HowlEvent, handler: HowlCallback): this {\n if (this._id !== null) this._howl.off(event, handler, this._id);\n return this;\n }\n }\n\n /**\n * HowlerSoundManager is used to manage the sounds and musics of a RuntimeScene.\n *\n * It is basically a container to associate channels to sounds and keep a list\n * of all sounds being played.\n */\n export class HowlerSoundManager {\n _loadedMusics = new gdjs.ResourceCache<Howl>();\n _loadedSounds = new gdjs.ResourceCache<Howl>();\n _availableResources: Record<string, ResourceData> = {};\n _globalVolume: float = 100;\n _sounds: Record<integer, HowlerSound> = {};\n _cachedSpatialPosition: Record<integer, [number, number, number]> = {};\n _musics: Record<integer, HowlerSound> = {};\n _freeSounds: HowlerSound[] = []; // Sounds without an assigned channel.\n _freeMusics: HowlerSound[] = []; // Musics without an assigned channel.\n\n /** Paused sounds or musics that should be played once the game is resumed. */\n _pausedSounds: HowlerSound[] = [];\n _paused: boolean = false;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n gdjs.registerRuntimeScenePostEventsCallback(\n this._clearCachedSpatialPosition.bind(this)\n );\n const that = this;\n document.addEventListener('deviceready', function () {\n // pause/resume sounds in Cordova when the app is being paused/resumed\n document.addEventListener(\n 'pause',\n function () {\n const soundList = that._freeSounds.concat(that._freeMusics);\n for (let key in that._sounds) {\n if (that._sounds.hasOwnProperty(key)) {\n soundList.push(that._sounds[key]);\n }\n }\n for (let key in that._musics) {\n if (that._musics.hasOwnProperty(key)) {\n soundList.push(that._musics[key]);\n }\n }\n for (let i = 0; i < soundList.length; i++) {\n const sound = soundList[i];\n if (!sound.paused() && !sound.stopped()) {\n sound.pause();\n that._pausedSounds.push(sound);\n }\n }\n that._paused = true;\n },\n false\n );\n document.addEventListener(\n 'resume',\n function () {\n try {\n for (let i = 0; i < that._pausedSounds.length; i++) {\n const sound = that._pausedSounds[i];\n if (!sound.stopped()) {\n sound.play();\n }\n }\n } catch (error) {\n if (\n error.message &&\n typeof error.message === 'string' &&\n error.message.startsWith('Maximum call stack size exceeded')\n ) {\n console.warn(\n 'An error occurred when resuming paused sounds while the game was in background:',\n error\n );\n } else {\n throw error;\n }\n }\n that._pausedSounds.length = 0;\n that._paused = false;\n },\n false\n );\n });\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Ensure rate is in a range valid for Howler.js\n * @return The clamped rate\n */\n static clampRate(rate: float): float {\n if (rate > 4.0) {\n return 4.0;\n }\n if (rate < 0.5) {\n return 0.5;\n }\n return rate;\n }\n\n /**\n * Return the file associated to the given sound name.\n *\n * Names and files are loaded from resources when preloadAudio is called. If no\n * file is associated to the given name, then the name will be considered as a\n * filename and will be returned.\n *\n * @return The associated resource\n */\n private _getAudioResource = (resourceName: string): ResourceData => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : ({\n file: resourceName,\n kind: 'audio',\n metadata: '',\n name: resourceName,\n } as ResourceData);\n };\n\n /**\n * @param resource\n * @returns Resource files\n */\n private _getSoundUrlsFromResource(resource: ResourceData): string[] {\n return [this._resourceLoader.getFullUrl(resource.file)];\n }\n\n /**\n * @param resource\n * @returns Resource file\n */\n private _getDefaultSoundUrl(resource: ResourceData): string {\n return this._resourceLoader.getFullUrl(resource.file);\n }\n\n /**\n * Preload audio file\n * @param resource\n * @param isMusic\n */\n private _preloadAudioFile(\n resource: ResourceData,\n isMusic: boolean\n ): Promise<number> {\n const file = resource.file;\n return new Promise((resolve, reject) => {\n const container = isMusic ? this._loadedMusics : this._loadedSounds;\n container[file] = new Howl(\n Object.assign({}, HowlParameters, {\n src: this._getSoundUrlsFromResource(resource),\n onload: resolve,\n onloaderror: (soundId: number, error?: string) => reject(error),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(file),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n })\n );\n });\n }\n\n /**\n * Store the sound in the specified array, put it at the first index that\n * is free, or add it at the end if no element is free\n * (\"free\" means that the gdjs.HowlerSound can be destroyed).\n *\n * @param arr The array containing the sounds.\n * @param arr The gdjs.HowlerSound to add.\n * @return The gdjs.HowlerSound that have been added (i.e: the second parameter).\n */\n private _storeSoundInArray(\n arr: Array<HowlerSound>,\n sound: HowlerSound\n ): HowlerSound {\n // Try to recycle an old sound.\n for (let i = 0, len = arr.length; i < len; ++i) {\n if (!arr[i] || arr[i].stopped()) {\n arr[i] = sound;\n return sound;\n }\n }\n\n arr.push(sound);\n return sound;\n }\n\n /**\n * Creates a new gdjs.HowlerSound using preloaded/cached Howl instances.\n * @param soundName The name of the file or resource to play.\n * @param isMusic True if a music, false if a sound.\n * @param volume Between 0 and 1.\n * @param loop True if it should be played looping.\n * @param rate speed at which it is played.\n */\n createHowlerSound(\n soundName: string,\n isMusic: boolean,\n volume: float,\n loop: boolean,\n rate: float\n ): HowlerSound {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n let howl = cacheContainer.get(resource);\n if (!howl) {\n howl = new Howl(\n Object.assign(\n {\n src: this._getSoundUrlsFromResource(resource),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n );\n cacheContainer.set(resource, howl);\n }\n\n return new gdjs.HowlerSound(howl, volume, loop, rate);\n }\n\n /**\n * Preloads a sound or a music in memory.\n * @param soundName The name of the file or resource to preload.\n * @param isMusic True if a music, false if a sound.\n */\n loadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n // Do not reload if it is already loaded.\n if (cacheContainer.get(resource)) {\n return;\n }\n\n cacheContainer.set(\n resource,\n new Howl(\n Object.assign(\n {\n src: this._getSoundUrlsFromResource(resource),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n )\n );\n }\n\n /**\n * Unloads a sound or a music from memory. This will stop any sound/music using it.\n * @param soundName The name of the file or resource to unload.\n * @param isMusic True if a music, false if a sound.\n */\n unloadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n const howl = cacheContainer.get(resource);\n if (!howl) {\n return;\n }\n\n // Make sure any sound using the howl is deleted so\n // that the howl can be garbage collected\n // and no weird \"zombies\" using the unloaded howl can exist.\n function clearContainer(howlerSoundContainer: HowlerSound[]) {\n for (let i in howlerSoundContainer) {\n if (\n howlerSoundContainer[i] &&\n //@ts-ignore We really need to access the raw howl here.\n howlerSoundContainer[i]._howl === howl\n ) {\n howlerSoundContainer[i].stop();\n delete howlerSoundContainer[i];\n }\n }\n }\n\n clearContainer(this._freeMusics);\n clearContainer(this._freeSounds);\n clearContainer(Object.values(this._musics));\n clearContainer(Object.values(this._sounds));\n clearContainer(this._pausedSounds);\n\n howl.unload();\n cacheContainer.delete(resource);\n }\n\n /**\n * Unloads all audio from memory.\n * This will clear the Howl cache.\n * This will also stop any running music or sounds.\n */\n unloadAll() {\n Howler.unload();\n\n // Clean up old sounds that still have the dead Howl instances.\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n this._loadedMusics.clear();\n this._loadedSounds.clear();\n }\n\n playSound(soundName: string, loop: boolean, volume: float, pitch: float) {\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeSounds, sound);\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n playSoundOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._sounds[channel]) this._sounds[channel].stop();\n\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n const spatialPosition = this._cachedSpatialPosition[channel];\n if (spatialPosition) {\n sound.once('play', () => {\n sound.setSpatialPosition(...spatialPosition);\n });\n }\n this._sounds[channel] = sound;\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n getSoundOnChannel(channel: integer): HowlerSound | null {\n return this._sounds[channel] || null;\n }\n\n playMusic(soundName: string, loop: boolean, volume: float, pitch: float) {\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeMusics, music);\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n playMusicOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._musics[channel]) this._musics[channel].stop();\n\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n // Musics are played with the html5 backend, that is not compatible with spatialization.\n this._musics[channel] = music;\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n getMusicOnChannel(channel: integer): HowlerSound | null {\n return this._musics[channel] || null;\n }\n\n setSoundSpatialPositionOnChannel(\n channel: number,\n x: number,\n y: number,\n z: number\n ) {\n const sound = this.getSoundOnChannel(channel);\n if (sound && !sound.paused()) sound.setSpatialPosition(x, y, z);\n else {\n // If no sound is playing at the time the method is called, the\n // position is cached and will be used by the `playSoundOnChannel` method\n // to set the spatial position right after the sound starts playing.\n // This cached value is then cleared at the end of the frame.\n // Without this caching strategy, if actions are in the wrong order,\n // the spatial position will not apply to the sound because\n // it is not playing yet.\n this._cachedSpatialPosition[channel] = [x, y, z];\n }\n }\n\n _clearCachedSpatialPosition() {\n this._cachedSpatialPosition = {};\n }\n\n setGlobalVolume(volume: float): void {\n this._globalVolume = volume;\n if (this._globalVolume > 100) {\n this._globalVolume = 100;\n }\n if (this._globalVolume < 0) {\n this._globalVolume = 0;\n }\n Howler.volume(this._globalVolume / 100);\n }\n\n getGlobalVolume(): float {\n return this._globalVolume;\n }\n\n clearAll() {\n Howler.stop();\n\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because sounds are light enough to be parsed in background.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find audio for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (resource.file) {\n if (this._availableResources[resource.name]) {\n return;\n }\n\n this._availableResources[resource.name] = resource;\n }\n\n if (resource.preloadAsMusic) {\n try {\n await this._preloadAudioFile(resource, /* isMusic= */ true);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n\n if (resource.preloadAsSound) {\n try {\n await this._preloadAudioFile(resource, /* isMusic= */ false);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n } else if (\n resource.preloadInCache ||\n // Force downloading of sounds.\n // TODO Decide if sounds should be allowed to be downloaded after the scene starts.\n // - they should be requested automatically at the end of the scene loading\n // - they will be downloaded while the scene is playing\n // - other scenes will be pre-loaded only when all the sounds for the current scene are in cache\n !resource.preloadAsMusic\n ) {\n // preloading as sound already does a XHR request, hence \"else if\"\n try {\n const file = resource.file;\n await new Promise((resolve, reject) => {\n const sound = new XMLHttpRequest();\n sound.withCredentials =\n this._resourceLoader.checkIfCredentialsRequired(file);\n sound.addEventListener('load', resolve);\n sound.addEventListener('error', (_) =>\n reject('XHR error: ' + file)\n );\n sound.addEventListener('abort', (_) =>\n reject('XHR abort: ' + file)\n );\n sound.open('GET', this._getDefaultSoundUrl(resource));\n sound.send();\n });\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n }\n\n /**\n * To be called when the game is disposed.\n * Unloads all audio from memory, clear Howl cache and stop all audio.\n */\n dispose(): void {\n this.unloadAll();\n }\n }\n\n // Register the class to let the engine use it.\n export const SoundManager = HowlerSoundManager;\n export type SoundManager = HowlerSoundManager;\n}\n"],
5
- "mappings": "AAMA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAqC,CAAC,SAEtC,EAA8B,CAClC,QAAS,GACT,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,6BAA+B,GAC9C,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,sCAAwC,IAMnD,EAAc,AAAC,GACf,EAAS,EACJ,EAEL,EAAS,EACJ,EAEF,EAYF,OAAkB,CA6CvB,YAAY,EAAY,EAAe,EAAe,EAAa,CAzC3D,SAAsB,KAkCtB,eAAiC,GAKjC,aAA+B,GAGrC,KAAK,MAAQ,EACb,KAAK,eAAiB,EAAY,GAClC,KAAK,MAAQ,EACb,KAAK,MAAQ,EAMf,UAAoB,CAClB,MAAO,MAAK,MAAM,UAAY,SAOhC,MAAa,CACX,GAAI,KAAK,WAAY,CACnB,KAAM,GAAQ,KAAK,MAAM,KACvB,KAAK,MAAQ,KAAO,YAAc,KAAK,KAEzC,KAAK,IAAM,EAGX,KAAK,MAAM,OAAO,KAAK,eAAgB,GACvC,KAAK,MAAM,KAAK,KAAK,MAAO,GAG5B,KAAK,MAAM,KAAK,EAAK,mBAAmB,UAAU,KAAK,OAAQ,GAM/D,KAAK,QAAQ,QAAQ,AAAC,GAAS,CAE7B,KAAK,GAAG,OAAQ,GAChB,EAAK,KAEP,KAAK,UAAU,QAAQ,AAAC,GAAS,EAAK,IACtC,KAAK,QAAU,GACf,KAAK,UAAY,OACZ,MAAK,MAAM,KAAK,OAAQ,IAAM,KAAK,QAE1C,MAAO,MAOT,OAAc,CACZ,MAAI,MAAK,MAAQ,MAAM,KAAK,MAAM,MAAM,KAAK,KACtC,KAOT,MAAa,CACX,MAAI,MAAK,MAAQ,MAAM,KAAK,MAAM,KAAK,KAAK,KACrC,KAST,SAAmB,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BAMT,CAAC,EAAS,eAGV,GAAI,CACF,KAAM,GAAO,EAAS,KACtB,KAAM,IAAI,SAAQ,CAAC,EAAS,IAAW,CACrC,KAAM,GAAQ,GAAI,gBAClB,EAAM,gBACJ,KAAK,gBAAgB,2BAA2B,GAClD,EAAM,iBAAiB,OAAQ,GAC/B,EAAM,iBAAiB,QAAS,AAAC,GAC/B,EAAO,cAAgB,IAEzB,EAAM,iBAAiB,QAAS,AAAC,GAC/B,EAAO,cAAgB,IAEzB,EAAM,KAAK,MAAO,KAAK,oBAAoB,IAC3C,EAAM,eAED,EAAP,CACA,EAAO,KACL,sDAAwD,IAUhE,SAAgB,CACd,KAAK,aApjBF,EAAM,qBAyjBA,eAAe,IAl6BpB",
4
+ "sourcesContent": ["///<reference path='../types/howler'>\n/*\n * GDevelop JS Platform\n * Copyright 2013-present 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('Audio manager');\n\n const resourceKinds: Array<ResourceKind> = ['audio'];\n\n const HowlParameters: HowlOptions = {\n preload: true,\n onplayerror: (_, error) =>\n logger.error(\"Can't play an audio file: \" + error),\n onloaderror: (_, error) =>\n logger.error('Error while loading an audio file: ' + error),\n };\n\n /**\n * Ensure the volume is between 0 and 1.\n */\n const clampVolume = (volume: float): float => {\n if (volume > 1.0) {\n return 1.0;\n }\n if (volume < 0) {\n return 0;\n }\n return volume;\n };\n\n /**\n * A thin wrapper around a Howl object with:\n * * Handling of callbacks when the sound is not yet loaded.\n * * Automatic clamping when calling `setRate` to ensure a valid value is passed to Howler.js.\n * * Automatic clamping when calling `setVolume` so that the volume is always between 0 and 1.\n *\n * @memberof gdjs\n * @class HowlerSound\n */\n export class HowlerSound {\n /**\n * The ID of the played sound.\n */\n private _id: integer | null = null;\n\n /**\n * The Howl passed to the constructor.\n * It defines the sound file that is being played.\n */\n private _howl: Howl;\n\n /**\n * The **initial** volume at which the sound is being played.\n * Once the sound is started, this volume can be not in sync\n * (in the case the sound is faded by Howler), so volume must\n * be gotten from `this._howl` directly.\n *\n * This value is clamped between 0 and 1.\n */\n private _initialVolume: float;\n\n /**\n * Whether the sound is being played in a loop or not.\n */\n private _loop: boolean;\n\n /**\n * The rate (speed) the sound is being played at.\n * This value is not clamped, though technically Howler.js will only\n * accepts values between a specific range (so we clamp this when\n * passing it to Howler.js, but keep the original value here).\n */\n private _rate: float;\n\n /**\n * An array of callbacks to call once the sound starts to play.\n */\n private _oncePlay: Array<HowlCallback> = [];\n\n /**\n * An array of callbacks to call everytime the sound starts to play.\n */\n private _onPlay: Array<HowlCallback> = [];\n\n constructor(howl: Howl, volume: float, loop: boolean, rate: float) {\n this._howl = howl;\n this._initialVolume = clampVolume(volume);\n this._loop = loop;\n this._rate = rate;\n }\n\n /**\n * Returns true if the associated howl is fully loaded.\n */\n isLoaded(): boolean {\n return this._howl.state() === 'loaded';\n }\n\n /**\n * Begins playback of the sound, or if the Howl is still loading, schedule playing for once it loads.\n * @returns The current instance for chaining.\n */\n play(): this {\n if (this.isLoaded()) {\n const newID = this._howl.play(\n this._id === null ? '__default' : this._id\n );\n this._id = newID;\n\n // Set the howl properties as soon as the sound is played and we have its ID.\n this._howl.volume(this._initialVolume, newID); // this._initialVolume is already clamped between 0 and 1.\n this._howl.loop(this._loop, newID);\n // this._rate is not clamped, but we need to clamp it when passing it to Howler.js as it\n // only supports a specific range.\n this._howl.rate(gdjs.HowlerSoundManager.clampRate(this._rate), newID);\n\n // Manually handle the play event before we have an ID.\n // Before loading, howler won't register events as without an ID we cannot set a listener.\n // Once we have an ID, we can transfer control of the events to howler.\n // We also need to call them once as Howler doesn't for the first play event.\n this._onPlay.forEach((func) => {\n // Transfer the event to howler now that we have an ID\n this.on('play', func);\n func(newID);\n });\n this._oncePlay.forEach((func) => func(newID));\n this._onPlay = [];\n this._oncePlay = [];\n } else this._howl.once('load', () => this.play()); // Play only once the howl is fully loaded\n\n return this;\n }\n\n /**\n * Pauses playback of the sound, saving the seek of playback.\n * @returns The current instance for chaining.\n */\n pause(): this {\n if (this._id !== null) this._howl.pause(this._id);\n return this;\n }\n\n /**\n * Stops playback of the sound, resetting seek to 0.\n * @returns The current instance for chaining.\n */\n stop(): this {\n if (this._id !== null) this._howl.stop(this._id);\n return this;\n }\n\n /**\n * Check if the sound is currently playing.\n * Note that a loading sound is considered as playing (as it will be\n * played as soon as it's loaded). To avoid loading at runtime, prefer\n * to preload the sounds.\n */\n playing(): boolean {\n return (\n (this._id !== null ? this._howl.playing(this._id) : true) ||\n !this.isLoaded() // Loading is considered playing\n );\n }\n\n /**\n * Check if the sound is currently paused.\n */\n paused(): boolean {\n return !this.playing();\n }\n\n /**\n * Check if the sound is currently stopped.\n */\n stopped(): boolean {\n return this.paused() && this.getSeek() === 0;\n }\n\n /**\n * Get the sound playback rate. This 1 for the default speed.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n */\n getRate(): float {\n return this._rate;\n }\n\n /**\n * Set the playback rate.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n * @returns The current instance for chaining.\n */\n setRate(rate: float): this {\n this._rate = rate;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) {\n rate = gdjs.HowlerSoundManager.clampRate(rate);\n this._howl.rate(rate, this._id);\n }\n return this;\n }\n\n /**\n * Get if the sound is looping.\n */\n getLoop(): boolean {\n return this._loop;\n }\n\n /**\n * Set if the sound is looping.\n * @returns The current instance for chaining.\n */\n setLoop(loop: boolean): this {\n this._loop = loop;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.loop(loop, this._id);\n return this;\n }\n\n //TODO: Replace float type in those 2 methods with RangeOf<0..1> once it is standardized (https://github.com/Microsoft/TypeScript/issues/15480)\n /**\n * Get the sound volume.\n * @returns A float from 0 to 1.\n */\n getVolume(): float {\n if (this._id === null) return this._initialVolume;\n return this._howl.volume(this._id);\n }\n\n /**\n * Set the sound volume.\n * @param volume A float from 0 to 1. The value is clamped if too high or too low.\n * @returns The current instance for chaining.\n */\n setVolume(volume: float): this {\n this._initialVolume = clampVolume(volume);\n\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.volume(this._initialVolume, this._id);\n return this;\n }\n\n /**\n * Get if the sound is muted.\n */\n getMute(): boolean {\n if (this._id === null) return false;\n return this._howl.mute(this._id);\n }\n\n /**\n * Set if the sound is muted.\n * @returns The current instance for chaining.\n */\n setMute(mute: boolean): this {\n if (this._id !== null) this._howl.mute(mute, this._id);\n return this;\n }\n\n /**\n * Get the sound seek.\n */\n getSeek(): float {\n if (this._id === null) return 0;\n return this._howl.seek(this._id);\n }\n\n /**\n * Set the sound seek.\n * @returns The current instance for chaining.\n */\n setSeek(seek: float): this {\n if (this._id !== null) this._howl.seek(seek, this._id);\n return this;\n }\n\n /**\n * Get the sound spatial position.\n */\n getSpatialPosition(axis: 'x' | 'y' | 'z'): float {\n if (this._id === null) return 0;\n return this._howl.pos(this._id)[axis === 'x' ? 0 : axis === 'y' ? 1 : 2];\n }\n\n /**\n * Set the sound spatial position.\n * @returns The current instance for chaining.\n */\n setSpatialPosition(x: float, y: float, z: float): this {\n if (this._id !== null) this._howl.pos(x, y, z, this._id);\n return this;\n }\n\n /**\n * Fade the volume sound.\n * @returns The current instance for chaining.\n */\n fade(from: float, to: float, duration: float): this {\n if (this._id !== null)\n this._howl.fade(clampVolume(from), clampVolume(to), duration, this._id);\n return this;\n }\n\n /**\n * Adds an event listener to the howl.\n */\n on(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._onPlay.push(handler);\n } else {\n this._howl.on(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.on(event, handler));\n else this._howl.on(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Adds an event listener to the howl that removes itself after being called.\n * If the event is `play` and the sound is being played, the handler is\n * called synchronously.\n */\n once(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._oncePlay.push(handler);\n } else if (this.playing()) {\n // Immediately call the handler if the sound is already playing.\n // This is useful for sounds that were just started and have a `.once('play', ...)`\n // handler added on them to set up the volume/rate/loop. If we don't do it\n // synchronously, the sound can play for a tiny bit at the default volume and rate.\n // See https://github.com/4ian/GDevelop/issues/2490.\n handler(this._id);\n } else {\n this._howl.once(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.once(event, handler));\n else this._howl.once(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Removes an event listener to the howl.\n */\n off(event: HowlEvent, handler: HowlCallback): this {\n if (this._id !== null) this._howl.off(event, handler, this._id);\n return this;\n }\n }\n\n /**\n * HowlerSoundManager is used to manage the sounds and musics of a RuntimeScene.\n *\n * It is basically a container to associate channels to sounds and keep a list\n * of all sounds being played.\n */\n export class HowlerSoundManager {\n _loadedMusics = new gdjs.ResourceCache<Howl>();\n _loadedSounds = new gdjs.ResourceCache<Howl>();\n _availableResources: Record<string, ResourceData> = {};\n _globalVolume: float = 100;\n _sounds: Record<integer, HowlerSound> = {};\n _cachedSpatialPosition: Record<integer, [number, number, number]> = {};\n _musics: Record<integer, HowlerSound> = {};\n _freeSounds: HowlerSound[] = []; // Sounds without an assigned channel.\n _freeMusics: HowlerSound[] = []; // Musics without an assigned channel.\n\n /** Paused sounds or musics that should be played once the game is resumed. */\n _pausedSounds: HowlerSound[] = [];\n _paused: boolean = false;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n gdjs.registerRuntimeScenePostEventsCallback(\n this._clearCachedSpatialPosition.bind(this)\n );\n const that = this;\n document.addEventListener('deviceready', function () {\n // pause/resume sounds in Cordova when the app is being paused/resumed\n document.addEventListener(\n 'pause',\n function () {\n that.pauseAllActiveSounds();\n },\n false\n );\n document.addEventListener(\n 'resume',\n function () {\n that.resumeAllActiveSounds();\n },\n false\n );\n });\n }\n\n pauseAllActiveSounds(): void {\n const soundList = this._freeSounds.concat(this._freeMusics);\n for (let key in this._sounds) {\n if (this._sounds.hasOwnProperty(key)) {\n soundList.push(this._sounds[key]);\n }\n }\n for (let key in this._musics) {\n if (this._musics.hasOwnProperty(key)) {\n soundList.push(this._musics[key]);\n }\n }\n for (let i = 0; i < soundList.length; i++) {\n const sound = soundList[i];\n if (!sound.paused() && !sound.stopped()) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n }\n this._paused = true;\n }\n\n resumeAllActiveSounds(): void {\n try {\n for (let i = 0; i < this._pausedSounds.length; i++) {\n const sound = this._pausedSounds[i];\n if (!sound.stopped()) {\n sound.play();\n }\n }\n } catch (error) {\n if (\n error.message &&\n typeof error.message === 'string' &&\n error.message.startsWith('Maximum call stack size exceeded')\n ) {\n console.warn(\n 'An error occurred when resuming paused sounds while the game was in background:',\n error\n );\n } else {\n throw error;\n }\n }\n this._pausedSounds.length = 0;\n this._paused = false;\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Ensure rate is in a range valid for Howler.js\n * @return The clamped rate\n */\n static clampRate(rate: float): float {\n if (rate > 4.0) {\n return 4.0;\n }\n if (rate < 0.5) {\n return 0.5;\n }\n return rate;\n }\n\n /**\n * Return the file associated to the given sound name.\n *\n * Names and files are loaded from resources when preloadAudio is called. If no\n * file is associated to the given name, then the name will be considered as a\n * filename and will be returned.\n *\n * @return The associated resource\n */\n private _getAudioResource = (resourceName: string): ResourceData => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : ({\n file: resourceName,\n kind: 'audio',\n metadata: '',\n name: resourceName,\n } as ResourceData);\n };\n\n /**\n * @param resource\n * @returns Resource files\n */\n private _getSoundUrlsFromResource(resource: ResourceData): string[] {\n return [this._resourceLoader.getFullUrl(resource.file)];\n }\n\n /**\n * @param resource\n * @returns Resource file\n */\n private _getDefaultSoundUrl(resource: ResourceData): string {\n return this._resourceLoader.getFullUrl(resource.file);\n }\n\n /**\n * Preload audio file\n * @param resource\n * @param isMusic\n */\n private _preloadAudioFile(\n resource: ResourceData,\n isMusic: boolean\n ): Promise<number> {\n const file = resource.file;\n return new Promise((resolve, reject) => {\n const container = isMusic ? this._loadedMusics : this._loadedSounds;\n container[file] = new Howl(\n Object.assign({}, HowlParameters, {\n src: this._getSoundUrlsFromResource(resource),\n onload: resolve,\n onloaderror: (soundId: number, error?: string) => reject(error),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(file),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n })\n );\n });\n }\n\n /**\n * Store the sound in the specified array, put it at the first index that\n * is free, or add it at the end if no element is free\n * (\"free\" means that the gdjs.HowlerSound can be destroyed).\n *\n * @param arr The array containing the sounds.\n * @param arr The gdjs.HowlerSound to add.\n * @return The gdjs.HowlerSound that have been added (i.e: the second parameter).\n */\n private _storeSoundInArray(\n arr: Array<HowlerSound>,\n sound: HowlerSound\n ): HowlerSound {\n // Try to recycle an old sound.\n for (let i = 0, len = arr.length; i < len; ++i) {\n if (!arr[i] || arr[i].stopped()) {\n arr[i] = sound;\n return sound;\n }\n }\n\n arr.push(sound);\n return sound;\n }\n\n /**\n * Creates a new gdjs.HowlerSound using preloaded/cached Howl instances.\n * @param soundName The name of the file or resource to play.\n * @param isMusic True if a music, false if a sound.\n * @param volume Between 0 and 1.\n * @param loop True if it should be played looping.\n * @param rate speed at which it is played.\n */\n createHowlerSound(\n soundName: string,\n isMusic: boolean,\n volume: float,\n loop: boolean,\n rate: float\n ): HowlerSound {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n let howl = cacheContainer.get(resource);\n if (!howl) {\n howl = new Howl(\n Object.assign(\n {\n src: this._getSoundUrlsFromResource(resource),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n );\n cacheContainer.set(resource, howl);\n }\n\n return new gdjs.HowlerSound(howl, volume, loop, rate);\n }\n\n /**\n * Preloads a sound or a music in memory.\n * @param soundName The name of the file or resource to preload.\n * @param isMusic True if a music, false if a sound.\n */\n loadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n // Do not reload if it is already loaded.\n if (cacheContainer.get(resource)) {\n return;\n }\n\n cacheContainer.set(\n resource,\n new Howl(\n Object.assign(\n {\n src: this._getSoundUrlsFromResource(resource),\n html5: isMusic,\n xhr: {\n withCredentials:\n this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n )\n );\n }\n\n /**\n * Unloads a sound or a music from memory. This will stop any sound/music using it.\n * @param soundName The name of the file or resource to unload.\n * @param isMusic True if a music, false if a sound.\n */\n unloadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n const howl = cacheContainer.get(resource);\n if (!howl) {\n return;\n }\n\n // Make sure any sound using the howl is deleted so\n // that the howl can be garbage collected\n // and no weird \"zombies\" using the unloaded howl can exist.\n function clearContainer(howlerSoundContainer: HowlerSound[]) {\n for (let i in howlerSoundContainer) {\n if (\n howlerSoundContainer[i] &&\n //@ts-ignore We really need to access the raw howl here.\n howlerSoundContainer[i]._howl === howl\n ) {\n howlerSoundContainer[i].stop();\n delete howlerSoundContainer[i];\n }\n }\n }\n\n clearContainer(this._freeMusics);\n clearContainer(this._freeSounds);\n clearContainer(Object.values(this._musics));\n clearContainer(Object.values(this._sounds));\n clearContainer(this._pausedSounds);\n\n howl.unload();\n cacheContainer.delete(resource);\n }\n\n /**\n * Unloads all audio from memory.\n * This will clear the Howl cache.\n * This will also stop any running music or sounds.\n */\n unloadAll() {\n Howler.unload();\n\n // Clean up old sounds that still have the dead Howl instances.\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n this._loadedMusics.clear();\n this._loadedSounds.clear();\n }\n\n playSound(soundName: string, loop: boolean, volume: float, pitch: float) {\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeSounds, sound);\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n playSoundOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._sounds[channel]) this._sounds[channel].stop();\n\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n const spatialPosition = this._cachedSpatialPosition[channel];\n if (spatialPosition) {\n sound.once('play', () => {\n sound.setSpatialPosition(...spatialPosition);\n });\n }\n this._sounds[channel] = sound;\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n getSoundOnChannel(channel: integer): HowlerSound | null {\n return this._sounds[channel] || null;\n }\n\n playMusic(soundName: string, loop: boolean, volume: float, pitch: float) {\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeMusics, music);\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n playMusicOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._musics[channel]) this._musics[channel].stop();\n\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n // Musics are played with the html5 backend, that is not compatible with spatialization.\n this._musics[channel] = music;\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n getMusicOnChannel(channel: integer): HowlerSound | null {\n return this._musics[channel] || null;\n }\n\n setSoundSpatialPositionOnChannel(\n channel: number,\n x: number,\n y: number,\n z: number\n ) {\n const sound = this.getSoundOnChannel(channel);\n if (sound && !sound.paused()) sound.setSpatialPosition(x, y, z);\n else {\n // If no sound is playing at the time the method is called, the\n // position is cached and will be used by the `playSoundOnChannel` method\n // to set the spatial position right after the sound starts playing.\n // This cached value is then cleared at the end of the frame.\n // Without this caching strategy, if actions are in the wrong order,\n // the spatial position will not apply to the sound because\n // it is not playing yet.\n this._cachedSpatialPosition[channel] = [x, y, z];\n }\n }\n\n _clearCachedSpatialPosition() {\n this._cachedSpatialPosition = {};\n }\n\n setGlobalVolume(volume: float): void {\n this._globalVolume = volume;\n if (this._globalVolume > 100) {\n this._globalVolume = 100;\n }\n if (this._globalVolume < 0) {\n this._globalVolume = 0;\n }\n Howler.volume(this._globalVolume / 100);\n }\n\n getGlobalVolume(): float {\n return this._globalVolume;\n }\n\n clearAll() {\n Howler.stop();\n\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because sounds are light enough to be parsed in background.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find audio for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (resource.file) {\n if (this._availableResources[resource.name]) {\n return;\n }\n\n this._availableResources[resource.name] = resource;\n }\n\n if (resource.preloadAsMusic) {\n try {\n await this._preloadAudioFile(resource, /* isMusic= */ true);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n\n if (resource.preloadAsSound) {\n try {\n await this._preloadAudioFile(resource, /* isMusic= */ false);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n } else if (\n resource.preloadInCache ||\n // Force downloading of sounds.\n // TODO Decide if sounds should be allowed to be downloaded after the scene starts.\n // - they should be requested automatically at the end of the scene loading\n // - they will be downloaded while the scene is playing\n // - other scenes will be pre-loaded only when all the sounds for the current scene are in cache\n !resource.preloadAsMusic\n ) {\n // preloading as sound already does a XHR request, hence \"else if\"\n try {\n const file = resource.file;\n await new Promise((resolve, reject) => {\n const sound = new XMLHttpRequest();\n sound.withCredentials =\n this._resourceLoader.checkIfCredentialsRequired(file);\n sound.addEventListener('load', resolve);\n sound.addEventListener('error', (_) =>\n reject('XHR error: ' + file)\n );\n sound.addEventListener('abort', (_) =>\n reject('XHR abort: ' + file)\n );\n sound.open('GET', this._getDefaultSoundUrl(resource));\n sound.send();\n });\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n }\n\n /**\n * To be called when the game is disposed.\n * Unloads all audio from memory, clear Howl cache and stop all audio.\n */\n dispose(): void {\n this.unloadAll();\n }\n }\n\n // Register the class to let the engine use it.\n export const SoundManager = HowlerSoundManager;\n export type SoundManager = HowlerSoundManager;\n}\n"],
5
+ "mappings": "AAMA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAqC,CAAC,SAEtC,EAA8B,CAClC,QAAS,GACT,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,6BAA+B,GAC9C,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,sCAAwC,IAMnD,EAAc,AAAC,GACf,EAAS,EACJ,EAEL,EAAS,EACJ,EAEF,EAYF,OAAkB,CA6CvB,YAAY,EAAY,EAAe,EAAe,EAAa,CAzC3D,SAAsB,KAk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,SAAgB,CACd,KAAK,aA5jBF,EAAM,qBAikBA,eAAe,IA16BpB",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(r){class a{constructor(e,t,i){this._isContainerDirty=!0;this._debugDraw=null;this._debugDrawContainer=null;this._object=e,this._instanceContainer=t,this._pixiContainer=new PIXI.Container,this._debugDrawRenderedObjectsPoints={},this._pixiContainer.sortableChildren=!0,this._debugDraw=null;const n=i.getLayer("");n&&n.getRenderer().addRendererObject(this._pixiContainer,e.getZOrder())}reinitialize(e,t){this._object=e,this._isContainerDirty=!0;const i=t.getLayer("");i&&i.getRenderer().addRendererObject(this._pixiContainer,e.getZOrder())}getRendererObject(){return this._pixiContainer}get3DRendererObject(){return null}_updatePIXIContainer(){const e=this._object.getScaleX(),t=this._object.getScaleY(),i=this._object.getOpacity();this._pixiContainer.pivot.x=this._object.getUnscaledCenterX(),this._pixiContainer.pivot.y=this._object.getUnscaledCenterY(),this._pixiContainer.position.x=this._object.getX()+this._pixiContainer.pivot.x*Math.abs(e),this._pixiContainer.position.y=this._object.getY()+this._pixiContainer.pivot.y*Math.abs(t),this._pixiContainer.rotation=r.toRad(this._object.angle),this._pixiContainer.scale.x=e*(this._object.isFlippedX()?-1:1),this._pixiContainer.scale.y=t*(this._object.isFlippedY()?-1:1),this._pixiContainer.visible=!this._object.hidden,this._pixiContainer.alpha=i/255,this._isContainerDirty=!1}ensureUpToDate(){this._isContainerDirty&&this._updatePIXIContainer()}update(){this._isContainerDirty=!0}updateX(){const e=this._object.getScaleX();this._pixiContainer.position.x=this._object.x+this._pixiContainer.pivot.x*Math.abs(e)}updateY(){const e=this._object.getScaleY();this._pixiContainer.position.y=this._object.y+this._pixiContainer.pivot.y*Math.abs(e)}updateAngle(){this._pixiContainer.rotation=r.toRad(this._object.angle)}updateOpacity(){const e=this._object.getOpacity();this._pixiContainer.alpha=e/255}updateVisibility(){this._pixiContainer.visible=!this._object.hidden}getPIXIContainer(){return this._pixiContainer}getPIXIRenderer(){return null}setLayerIndex(e,t){const i=e.getRenderer();let n=i.getRendererObject();e.isLightingLayer()&&(n=i.getLightingSprite()),!!n&&this._pixiContainer.children.indexOf(n)!==t&&(this._pixiContainer.removeChild(n),this._pixiContainer.addChildAt(n,t))}static getAnimationFrameTextureManager(e){return r.SpriteRuntimeObjectPixiRenderer.getAnimationFrameTextureManager(e)}}r.CustomRuntimeObject2DPixiRenderer=a,r.CustomRuntimeObject2DRenderer=r.CustomRuntimeObject2DPixiRenderer})(gdjs||(gdjs={}));
1
+ var gdjs;(function(r){class a{constructor(e,t,n){this._isContainerDirty=!0;this._debugDraw=null;this._debugDrawContainer=null;this._object=e,this._instanceContainer=t,this._pixiContainer=new PIXI.Container,this._debugDrawRenderedObjectsPoints={},this._pixiContainer.sortableChildren=!0,this._debugDraw=null;const i=n.getLayer("");i&&i.getRenderer().addRendererObject(this._pixiContainer,e.getZOrder())}reinitialize(e,t){this._object=e,this._isContainerDirty=!0,this._pixiContainer.removeChildren()}getRendererObject(){return this._pixiContainer}get3DRendererObject(){return null}_updatePIXIContainer(){const e=this._object.getScaleX(),t=this._object.getScaleY(),n=this._object.getOpacity();this._pixiContainer.pivot.x=this._object.getUnscaledCenterX(),this._pixiContainer.pivot.y=this._object.getUnscaledCenterY(),this._pixiContainer.position.x=this._object.getX()+this._pixiContainer.pivot.x*Math.abs(e),this._pixiContainer.position.y=this._object.getY()+this._pixiContainer.pivot.y*Math.abs(t),this._pixiContainer.rotation=r.toRad(this._object.angle),this._pixiContainer.scale.x=e*(this._object.isFlippedX()?-1:1),this._pixiContainer.scale.y=t*(this._object.isFlippedY()?-1:1),this._pixiContainer.visible=!this._object.hidden,this._pixiContainer.alpha=n/255,this._isContainerDirty=!1}ensureUpToDate(){this._isContainerDirty&&this._updatePIXIContainer()}update(){this._isContainerDirty=!0}updateX(){const e=this._object.getScaleX();this._pixiContainer.position.x=this._object.x+this._pixiContainer.pivot.x*Math.abs(e)}updateY(){const e=this._object.getScaleY();this._pixiContainer.position.y=this._object.y+this._pixiContainer.pivot.y*Math.abs(e)}updateAngle(){this._pixiContainer.rotation=r.toRad(this._object.angle)}updateOpacity(){const e=this._object.getOpacity();this._pixiContainer.alpha=e/255}updateVisibility(){this._pixiContainer.visible=!this._object.hidden}getPIXIContainer(){return this._pixiContainer}getPIXIRenderer(){return null}setLayerIndex(e,t){const n=e.getRenderer();let i=n.getRendererObject();e.isLightingLayer()&&(i=n.getLightingSprite()),!!i&&this._pixiContainer.children.indexOf(i)!==t&&(this._pixiContainer.removeChild(i),this._pixiContainer.addChildAt(i,t))}static getAnimationFrameTextureManager(e){return r.SpriteRuntimeObjectPixiRenderer.getAnimationFrameTextureManager(e)}}r.CustomRuntimeObject2DPixiRenderer=a,r.CustomRuntimeObject2DRenderer=r.CustomRuntimeObject2DPixiRenderer})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=CustomRuntimeObject2DPixiRenderer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.ts"],
4
- "sourcesContent": ["namespace gdjs {\n /**\n * The renderer for a {@link gdjs.CustomRuntimeObject2D} using Pixi.js.\n */\n export class CustomRuntimeObject2DPixiRenderer\n implements gdjs.RuntimeInstanceContainerPixiRenderer\n {\n _object: gdjs.CustomRuntimeObject;\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _pixiContainer: PIXI.Container;\n _isContainerDirty: boolean = true;\n _debugDraw: PIXI.Graphics | null = null;\n _debugDrawContainer: PIXI.Container | null = null;\n _debugDrawRenderedObjectsPoints: Record<\n number,\n {\n wasRendered: boolean;\n points: Record<string, PIXI.Text>;\n }\n >;\n\n constructor(\n object: gdjs.CustomRuntimeObject,\n instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._instanceContainer = instanceContainer;\n\n // TODO (3D) - optimization: don't create a PixiJS container if only 3D objects.\n // And same, in reverse, for 2D only objects.\n this._pixiContainer = new PIXI.Container();\n this._debugDrawRenderedObjectsPoints = {};\n\n // Contains the layers of the scene (and, optionally, debug PIXI objects).\n this._pixiContainer.sortableChildren = true;\n this._debugDraw = null;\n\n const layer = parent.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._pixiContainer, object.getZOrder());\n }\n }\n\n reinitialize(\n object: gdjs.CustomRuntimeObject,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._isContainerDirty = true;\n const layer = parent.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._pixiContainer, object.getZOrder());\n }\n }\n\n getRendererObject() {\n return this._pixiContainer;\n }\n\n get3DRendererObject(): THREE.Object3D | null {\n return null;\n }\n\n /**\n * Update the internal PIXI.Container position, angle...\n */\n _updatePIXIContainer() {\n const scaleX = this._object.getScaleX();\n const scaleY = this._object.getScaleY();\n const opacity = this._object.getOpacity();\n this._pixiContainer.pivot.x = this._object.getUnscaledCenterX();\n this._pixiContainer.pivot.y = this._object.getUnscaledCenterY();\n this._pixiContainer.position.x =\n this._object.getX() + this._pixiContainer.pivot.x * Math.abs(scaleX);\n this._pixiContainer.position.y =\n this._object.getY() + this._pixiContainer.pivot.y * Math.abs(scaleY);\n\n this._pixiContainer.rotation = gdjs.toRad(this._object.angle);\n this._pixiContainer.scale.x =\n scaleX * (this._object.isFlippedX() ? -1 : 1);\n this._pixiContainer.scale.y =\n scaleY * (this._object.isFlippedY() ? -1 : 1);\n this._pixiContainer.visible = !this._object.hidden;\n this._pixiContainer.alpha = opacity / 255;\n\n this._isContainerDirty = false;\n }\n\n /**\n * Call this to make sure the object is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._isContainerDirty) {\n this._updatePIXIContainer();\n }\n }\n\n update(): void {\n this._isContainerDirty = true;\n }\n\n updateX(): void {\n const scaleX = this._object.getScaleX();\n this._pixiContainer.position.x =\n this._object.x + this._pixiContainer.pivot.x * Math.abs(scaleX);\n }\n\n updateY(): void {\n const scaleY = this._object.getScaleY();\n this._pixiContainer.position.y =\n this._object.y + this._pixiContainer.pivot.y * Math.abs(scaleY);\n }\n\n updateAngle(): void {\n this._pixiContainer.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n const opacity = this._object.getOpacity();\n this._pixiContainer.alpha = opacity / 255;\n }\n\n updateVisibility(): void {\n this._pixiContainer.visible = !this._object.hidden;\n }\n\n getPIXIContainer() {\n return this._pixiContainer;\n }\n\n getPIXIRenderer() {\n return null;\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();\n let layerPixiObject: PIXI.Container | PIXI.Sprite | null =\n layerPixiRenderer.getRendererObject();\n if (layer.isLightingLayer()) {\n layerPixiObject = layerPixiRenderer.getLightingSprite();\n }\n if (!layerPixiObject) {\n return;\n }\n if (this._pixiContainer.children.indexOf(layerPixiObject) === index) {\n return;\n }\n this._pixiContainer.removeChild(layerPixiObject);\n this._pixiContainer.addChildAt(layerPixiObject, index);\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ) {\n return gdjs.SpriteRuntimeObjectPixiRenderer.getAnimationFrameTextureManager(\n imageManager\n );\n }\n }\n\n // Register the class to let the engine use it.\n export type CustomRuntimeObject2DRenderer =\n gdjs.CustomRuntimeObject2DPixiRenderer;\n export const CustomRuntimeObject2DRenderer =\n gdjs.CustomRuntimeObject2DPixiRenderer;\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAIS,OAEP,CAeE,YACE,EACA,EACA,EACA,CAfF,uBAA6B,GAC7B,gBAAmC,KACnC,yBAA6C,KAc3C,KAAK,QAAU,EACf,KAAK,mBAAqB,EAI1B,KAAK,eAAiB,GAAI,MAAK,UAC/B,KAAK,gCAAkC,GAGvC,KAAK,eAAe,iBAAmB,GAC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AAK,QAAQ,EAAI,KAAK,eAAe,MAAM,EAAI,KAAK,IAAI,GAG5D,aAAoB,CAClB,KAAK,eAAe,SAAW,EAAK,MAAM,KAAK,QAAQ,OAGzD,eAAsB,CACpB,KAAM,GAAU,KAAK,QAAQ,aAC7B,KAAK,eAAe,MAAQ,EAAU,IAGxC,kBAAyB,CACvB,KAAK,eAAe,QAAU,CAAC,KAAK,QAAQ,OAG9C,kBAAmB,CACjB,MAAO,MAAK,eAGd,iBAAkB,CAChB,MAAO,MAGT,cAAc,EAA0B,EAAoB,CAC1D,KAAM,GAA4C,EAAM,cACxD,GAAI,GACF,EAAkB,oBAIpB,AAHI,EAAM,mBACR,GAAkB,EAAkB,qBAElC,EAAC,GAGD,KAAK,eAAe,SAAS,QAAQ,KAAqB,GAG9D,MAAK,eAAe,YAAY,GAChC,KAAK,eAAe,WAAW,EAAiB,UAG3C,iCACL,EACA,CACA,MAAO,GAAK,gCAAgC,gCAC1C,IA5JC,EAAM,oCAoKA,gCACX,EAAK,oCAzKC",
4
+ "sourcesContent": ["namespace gdjs {\n /**\n * The renderer for a {@link gdjs.CustomRuntimeObject2D} using Pixi.js.\n */\n export class CustomRuntimeObject2DPixiRenderer\n implements gdjs.RuntimeInstanceContainerPixiRenderer\n {\n _object: gdjs.CustomRuntimeObject;\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _pixiContainer: PIXI.Container;\n _isContainerDirty: boolean = true;\n _debugDraw: PIXI.Graphics | null = null;\n _debugDrawContainer: PIXI.Container | null = null;\n _debugDrawRenderedObjectsPoints: Record<\n number,\n {\n wasRendered: boolean;\n points: Record<string, PIXI.Text>;\n }\n >;\n\n constructor(\n object: gdjs.CustomRuntimeObject,\n instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._instanceContainer = instanceContainer;\n\n // TODO (3D) - optimization: don't create a PixiJS container if only 3D objects.\n // And same, in reverse, for 2D only objects.\n this._pixiContainer = new PIXI.Container();\n this._debugDrawRenderedObjectsPoints = {};\n\n // Contains the layers of the scene (and, optionally, debug PIXI objects).\n this._pixiContainer.sortableChildren = true;\n this._debugDraw = null;\n\n const layer = parent.getLayer('');\n if (layer) {\n layer\n .getRenderer()\n .addRendererObject(this._pixiContainer, object.getZOrder());\n }\n }\n\n reinitialize(\n object: gdjs.CustomRuntimeObject,\n parent: gdjs.RuntimeInstanceContainer\n ) {\n this._object = object;\n this._isContainerDirty = true;\n this._pixiContainer.removeChildren();\n }\n\n getRendererObject() {\n return this._pixiContainer;\n }\n\n get3DRendererObject(): THREE.Object3D | null {\n return null;\n }\n\n /**\n * Update the internal PIXI.Container position, angle...\n */\n _updatePIXIContainer() {\n const scaleX = this._object.getScaleX();\n const scaleY = this._object.getScaleY();\n const opacity = this._object.getOpacity();\n this._pixiContainer.pivot.x = this._object.getUnscaledCenterX();\n this._pixiContainer.pivot.y = this._object.getUnscaledCenterY();\n this._pixiContainer.position.x =\n this._object.getX() + this._pixiContainer.pivot.x * Math.abs(scaleX);\n this._pixiContainer.position.y =\n this._object.getY() + this._pixiContainer.pivot.y * Math.abs(scaleY);\n\n this._pixiContainer.rotation = gdjs.toRad(this._object.angle);\n this._pixiContainer.scale.x =\n scaleX * (this._object.isFlippedX() ? -1 : 1);\n this._pixiContainer.scale.y =\n scaleY * (this._object.isFlippedY() ? -1 : 1);\n this._pixiContainer.visible = !this._object.hidden;\n this._pixiContainer.alpha = opacity / 255;\n\n this._isContainerDirty = false;\n }\n\n /**\n * Call this to make sure the object is ready to be rendered.\n */\n ensureUpToDate() {\n if (this._isContainerDirty) {\n this._updatePIXIContainer();\n }\n }\n\n update(): void {\n this._isContainerDirty = true;\n }\n\n updateX(): void {\n const scaleX = this._object.getScaleX();\n this._pixiContainer.position.x =\n this._object.x + this._pixiContainer.pivot.x * Math.abs(scaleX);\n }\n\n updateY(): void {\n const scaleY = this._object.getScaleY();\n this._pixiContainer.position.y =\n this._object.y + this._pixiContainer.pivot.y * Math.abs(scaleY);\n }\n\n updateAngle(): void {\n this._pixiContainer.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n const opacity = this._object.getOpacity();\n this._pixiContainer.alpha = opacity / 255;\n }\n\n updateVisibility(): void {\n this._pixiContainer.visible = !this._object.hidden;\n }\n\n getPIXIContainer() {\n return this._pixiContainer;\n }\n\n getPIXIRenderer() {\n return null;\n }\n\n setLayerIndex(layer: gdjs.RuntimeLayer, index: float): void {\n const layerPixiRenderer: gdjs.LayerPixiRenderer = layer.getRenderer();\n let layerPixiObject: PIXI.Container | PIXI.Sprite | null =\n layerPixiRenderer.getRendererObject();\n if (layer.isLightingLayer()) {\n layerPixiObject = layerPixiRenderer.getLightingSprite();\n }\n if (!layerPixiObject) {\n return;\n }\n if (this._pixiContainer.children.indexOf(layerPixiObject) === index) {\n return;\n }\n this._pixiContainer.removeChild(layerPixiObject);\n this._pixiContainer.addChildAt(layerPixiObject, index);\n }\n\n static getAnimationFrameTextureManager(\n imageManager: gdjs.PixiImageManager\n ) {\n return gdjs.SpriteRuntimeObjectPixiRenderer.getAnimationFrameTextureManager(\n imageManager\n );\n }\n }\n\n // Register the class to let the engine use it.\n export type CustomRuntimeObject2DRenderer =\n gdjs.CustomRuntimeObject2DPixiRenderer;\n export const CustomRuntimeObject2DRenderer =\n gdjs.CustomRuntimeObject2DPixiRenderer;\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAIS,OAEP,CAeE,YACE,EACA,EACA,EACA,CAfF,uBAA6B,GAC7B,gBAAmC,KACnC,yBAA6C,KAc3C,KAAK,QAAU,EACf,KAAK,mBAAqB,EAI1B,KAAK,eAAiB,GAAI,MAAK,UAC/B,KAAK,gCAAkC,GAGvC,KAAK,eAAe,iBAAmB,GACvC,KAAK,WAAa,KAElB,KAAM,GAAQ,EAAO,SAAS,IAC9B,AAAI,GACF,EACG,cACA,kBAAkB,KAAK,eAAgB,EAAO,aAIrD,aACE,E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MAAQ,EAAU,IAGxC,kBAAyB,CACvB,KAAK,eAAe,QAAU,CAAC,KAAK,QAAQ,OAG9C,kBAAmB,CACjB,MAAO,MAAK,eAGd,iBAAkB,CAChB,MAAO,MAGT,cAAc,EAA0B,EAAoB,CAC1D,KAAM,GAA4C,EAAM,cACxD,GAAI,GACF,EAAkB,oBAIpB,AAHI,EAAM,mBACR,GAAkB,EAAkB,qBAElC,EAAC,GAGD,KAAK,eAAe,SAAS,QAAQ,KAAqB,GAG9D,MAAK,eAAe,YAAY,GAChC,KAAK,eAAe,WAAW,EAAiB,UAG3C,iCACL,EACA,CACA,MAAO,GAAK,gCAAgC,gCAC1C,IAvJC,EAAM,oCA+JA,gCACX,EAAK,oCApKC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
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),i.onCreated(),!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={}));
1
+ var gdjs;(function(n){const C=(_,e,t,i)=>{const s=Math.max(t,_-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=(_,e,t)=>{if(e.length===0)return e.length=0,t.length=0,!1;if(e.length===1)return _.setPosition(_.getX()+e[0],_.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)),_.setPosition(_.getX()+u,_.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(){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(){this._livingOnScene&&(this._runtimeScene.markObjectForDeletion(this),this._livingOnScene=!1)}registerDestroyCallback(e){this.destroyCallbacks.add(e)}unregisterDestroyCallback(e){this.destroyCallbacks.delete(e)}onDeletedFromScene(){const e=this._runtimeScene.getLayer(this.layer),t=this.getRendererObject();t&&e.getRenderer().removeRendererObject(t);const i=this.get3DRendererObject();i&&e.getRenderer().remove3DRendererObject(i);for(let s=0,r=this._behaviors.length;s<r;++s)this._behaviors[s].onDestroy();this.destroyCallbacks.forEach(s=>s()),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){this.rotateTowardAngle(n.toDegrees(Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX()))),i)}rotateTowardAngle(e,t){if(t===0){this.setAngle(e);return}const s=n.evtTools.common.angleDifference(this.getAngle(),e)>=0;let r=this.getAngle()+(s?-1:1)*t*this.getElapsedTime()/1e3;n.evtTools.common.angleDifference(r,e)>0^s&&(r=e),this.setAngle(r),this.getAngle()!==r&&this.setAngle(e)}rotate(e){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),i.onCreated(),!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(C(e.getWidth(),e.getHeight(),r,a)),h=t.getCenterX(),m=t.getCenterY(),g=Math.sqrt(C(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=C(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