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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/Runtime/AsyncTasksManager.js +2 -2
  2. package/dist/Runtime/AsyncTasksManager.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  6. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +47 -0
  12. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  16. package/dist/Runtime/Extensions/3D/Skybox.js +2 -0
  17. package/dist/Runtime/Extensions/3D/Skybox.js.map +7 -0
  18. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  19. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  20. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  21. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  22. package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
  23. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  24. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  25. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
  26. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  27. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  28. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  29. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  30. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  31. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  32. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  34. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  35. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  38. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  39. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  40. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  41. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  42. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  43. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  44. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  45. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  46. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  47. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
  48. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  49. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  50. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  51. package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
  52. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
  53. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
  54. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
  55. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
  56. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  57. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  58. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  59. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  60. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  61. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  62. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
  63. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  64. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  65. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  66. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  67. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  68. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  69. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  70. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  71. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  74. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  75. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
  76. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  78. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  79. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js +1 -1
  80. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
  81. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  82. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  83. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  84. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  85. package/dist/Runtime/RuntimeLayer.js +1 -1
  86. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  87. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  88. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  89. package/dist/Runtime/events-tools/objecttools.js +1 -1
  90. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  91. package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
  92. package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
  93. package/dist/Runtime/gd.js +1 -1
  94. package/dist/Runtime/gd.js.map +2 -2
  95. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  96. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  97. package/dist/Runtime/indexeddb.js +2 -0
  98. package/dist/Runtime/indexeddb.js.map +7 -0
  99. package/dist/Runtime/oncetriggers.js +1 -1
  100. package/dist/Runtime/oncetriggers.js.map +2 -2
  101. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  102. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  103. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js +2 -2
  104. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  105. package/dist/Runtime/runtimebehavior.js +1 -1
  106. package/dist/Runtime/runtimebehavior.js.map +2 -2
  107. package/dist/Runtime/runtimegame.js +1 -1
  108. package/dist/Runtime/runtimegame.js.map +2 -2
  109. package/dist/Runtime/runtimeobject.js +1 -1
  110. package/dist/Runtime/runtimeobject.js.map +2 -2
  111. package/dist/Runtime/runtimescene.js +1 -1
  112. package/dist/Runtime/runtimescene.js.map +2 -2
  113. package/dist/Runtime/scenestack.js +1 -1
  114. package/dist/Runtime/scenestack.js.map +2 -2
  115. package/dist/Runtime/spriteruntimeobject.js +1 -1
  116. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  117. package/dist/Runtime/timemanager.js +1 -1
  118. package/dist/Runtime/timemanager.js.map +2 -2
  119. package/dist/Runtime/timer.js +1 -1
  120. package/dist/Runtime/timer.js.map +2 -2
  121. package/dist/Runtime/types/global-types.d.ts +29 -0
  122. package/dist/Runtime/types/project-data.d.ts +144 -3
  123. package/dist/Runtime/types/save-state.d.ts +9 -0
  124. package/dist/Runtime/variable.js +1 -1
  125. package/dist/Runtime/variable.js.map +2 -2
  126. package/dist/Runtime/variablescontainer.js +1 -1
  127. package/dist/Runtime/variablescontainer.js.map +2 -2
  128. package/dist/lib/libGD.cjs +1 -1
  129. package/dist/lib/libGD.wasm +0 -0
  130. package/dist/loaders.cjs +1 -1
  131. package/gd.d.ts +1 -0
  132. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/events-tools/objecttools.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 object {\n /**\n * Keep only the specified object in the lists of picked objects.\n *\n * @param objectsLists The lists of objects to trim\n * @param runtimeObject The object to keep in the lists\n */\n export const pickOnly = function (\n objectsLists: ObjectsLists,\n runtimeObject: gdjs.RuntimeObject\n ) {\n for (const listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n const list = objectsLists.items[listName];\n\n //Be sure not to lose the reference to the original array\n if (list.indexOf(runtimeObject) === -1) {\n list.length = 0;\n } else {\n list.length = 0;\n\n //Be sure not to lose the reference to the original array\n list.push(runtimeObject);\n }\n }\n }\n };\n\n /**\n * Do a test on two tables of objects so as to pick only the pair of objects for which the test is true.\n *\n * Note that the predicate method is not called strictly for each pair: When considering a pair of objects, if\n * these objects have already been marked as picked, the predicate method won't be called again.\n *\n * Cost (Worst case, predicate being always false):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*NbObjList1*NbObjList2\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n * + Cost(Removing NbObjList1+NbObjList2 objects from all the lists)\n *\n * Cost (Best case, predicate being always true):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*(NbObjList1+NbObjList2)\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n *\n *\n * @param predicate The predicate function is called with the two objects to compare, and an optional argument `extraArg`\n * @param objectsLists1 The first lists of objects\n * @param objectsLists2 The second lists of objects\n * @param inverted If `inverted` == true, only the objects of the first table are filtered.\n * @param extraArg (optional) This argument should be used to avoid declaring the predicate as a closure that would be created and destroyed at each call to twoListsTest (potentially multiple time per frame).\n */\n export const twoListsTest = function (\n predicate: (\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n extraArg: any\n ) => boolean,\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n extraArg: any\n ) {\n let isTrue = false;\n const objects1Lists = gdjs.staticArray(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists1.values(objects1Lists);\n const objects2Lists = gdjs.staticArray2(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists2.values(objects2Lists);\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n\n //Launch the function for each object of the first list with each object\n //of the second list.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n const arr1 = objects1Lists[i];\n for (let k = 0, lenk = arr1.length; k < lenk; ++k) {\n let atLeastOneObject = false;\n for (let j = 0, lenj = objects2Lists.length; j < lenj; ++j) {\n const arr2 = objects2Lists[j];\n for (let l = 0, lenl = arr2.length; l < lenl; ++l) {\n if (arr1[k].pick && arr2[l].pick) {\n continue;\n }\n\n //Avoid unnecessary costly call to predicate.\n if (\n arr1[k].id !== arr2[l].id &&\n predicate(arr1[k], arr2[l], extraArg)\n ) {\n if (!inverted) {\n isTrue = true;\n\n //Pick the objects\n arr1[k].pick = true;\n arr2[l].pick = true;\n }\n atLeastOneObject = true;\n }\n }\n }\n if (!atLeastOneObject && inverted) {\n //For example, the object is not overlapping any other object.\n isTrue = true;\n arr1[k].pick = true;\n }\n }\n }\n\n //Trim not picked objects from lists.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n if (!inverted) {\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n }\n return isTrue;\n };\n\n /**\n * Filter objects to keep only the one that fullfil the predicate\n *\n * Objects that do not fullfil the predicate are removed from objects lists.\n *\n * @param predicate The function applied to each object: must return true if the object fulfill the predicate.\n * @param objectsLists The lists of objects to trim\n * @param negatePredicate If set to true, the result of the predicate is negated.\n * @param extraArg Argument passed to the predicate (along with the object). Useful for avoiding relying on temporary closures.\n * @return true if at least one object fulfill the predicate.\n */\n export const pickObjectsIf = function (\n predicate: Function,\n objectsLists: ObjectsLists,\n negatePredicate: boolean,\n extraArg: any\n ): boolean {\n let isTrue = false;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickObjectsIf);\n objectsLists.values(lists);\n\n // Pick only objects that are fulfilling the predicate.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n const arr = lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const object = arr[k];\n // @ts-ignore\n if (negatePredicate ^ predicate(object, extraArg)) {\n isTrue = true;\n object.pick = true;\n } else {\n object.pick = false;\n }\n }\n }\n\n // Trim not picked objects from lists.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n gdjs.evtTools.object.filterPickedObjectsList(lists[i]);\n }\n return isTrue;\n };\n\n /**\n * Filter in-place the specified array to remove objects for which\n * `pick` property is set to false.\n */\n export const filterPickedObjectsList = function (\n arr: gdjs.RuntimeObject[]\n ) {\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const obj = arr[k];\n if (obj.pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n };\n\n export const hitBoxesCollisionTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n instanceContainer: gdjs.RuntimeInstanceContainer,\n ignoreTouchingEdges: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.RuntimeObject.collisionTest,\n objectsLists1,\n objectsLists2,\n inverted,\n ignoreTouchingEdges\n );\n };\n\n export const _distanceBetweenObjects = function (obj1, obj2, distance) {\n return obj1.getSqDistanceToObject(obj2) <= distance;\n };\n\n export const distanceTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n distance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._distanceBetweenObjects,\n objectsLists1,\n objectsLists2,\n inverted,\n distance * distance\n );\n };\n\n export const _movesToward = function (obj1, obj2, tolerance) {\n if (obj1.hasNoForces()) {\n return false;\n }\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAverageForce().getAngle(),\n objAngle\n )\n ) <=\n tolerance / 2\n );\n };\n\n export const movesTowardTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._movesToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n // Deprecated\n export const _turnedToward = function (obj1, obj2, tolerance) {\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(obj1.getAngle(), objAngle)\n ) <=\n tolerance / 2\n );\n };\n\n // Deprecated\n export const turnedTowardTest = function (\n objectsLists1,\n objectsLists2,\n tolerance,\n inverted\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._turnedToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const _isTurnedTowardObject = function (\n obj1: gdjs.RuntimeObject,\n obj2: gdjs.RuntimeObject,\n tolerance: float\n ) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAngle(),\n obj1.getAngleToObject(obj2)\n )\n ) <= tolerance\n );\n };\n\n export const isTurnedTowardObject = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._isTurnedTowardObject,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const pickAllObjects = function (objectsContext, objectsLists) {\n for (const name in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(name)) {\n const allObjects = objectsContext.getObjects(name);\n const objectsList = objectsLists.items[name];\n gdjs.copyArray(allObjects, objectsList);\n }\n }\n return true;\n };\n\n export const pickRandomObject = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectsLists: ObjectsLists\n ) {\n // Compute one many objects we have\n let objectsCount = 0;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n objectsCount += list.length;\n }\n }\n if (objectsCount === 0) {\n return false;\n }\n\n // Pick one random object\n let index = Math.floor(Math.random() * objectsCount);\n if (index >= objectsCount) {\n index = objectsCount - 1;\n }\n\n //Should never happen.\n\n // Find the object\n let startIndex = 0;\n let theChosenOne: gdjs.RuntimeObject | null = null;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n if (index - startIndex < list.length) {\n theChosenOne = list[index - startIndex];\n break;\n }\n startIndex += list.length;\n }\n }\n // @ts-ignore\n gdjs.evtTools.object.pickOnly(objectsLists, theChosenOne);\n return true;\n };\n\n export const pickNearestObject = function (objectsLists, x, y, inverted) {\n let bestObject = null;\n let best = 0;\n let first = true;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickNearestObject);\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n const list = lists[i];\n for (let j = 0; j < list.length; ++j) {\n const object = list[j];\n const distance = object.getSqDistanceToPosition(x, y);\n // @ts-ignore\n if (first || (distance < best) ^ inverted) {\n best = distance;\n bestObject = object;\n }\n first = false;\n }\n }\n if (!bestObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, bestObject);\n return true;\n };\n\n export const raycastObject = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n angle: float,\n dist: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.raycastObjectToPosition(\n objectsLists,\n x,\n y,\n x + dist * Math.cos((angle * Math.PI) / 180.0),\n y + dist * Math.sin((angle * Math.PI) / 180.0),\n varX,\n varY,\n inverted\n );\n };\n\n export const raycastObjectToPosition = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n endX: float,\n endY: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n let matchObject: gdjs.RuntimeObject | null = null;\n let testSqDist = inverted\n ? 0\n : (endX - x) * (endX - x) + (endY - y) * (endY - y);\n let resultX = 0;\n let resultY = 0;\n const lists: RuntimeObject[][] = gdjs.staticArray(\n gdjs.evtTools.object.raycastObjectToPosition\n );\n objectsLists.values(lists);\n for (let i = 0; i < lists.length; i++) {\n const list = lists[i];\n for (let j = 0; j < list.length; j++) {\n const object = list[j];\n const result = object.raycastTest(x, y, endX, endY, !inverted);\n if (result.collision) {\n if (!inverted && result.closeSqDist <= testSqDist) {\n testSqDist = result.closeSqDist;\n matchObject = object;\n resultX = result.closeX;\n resultY = result.closeY;\n } else {\n if (inverted && result.farSqDist >= testSqDist) {\n testSqDist = result.farSqDist;\n matchObject = object;\n resultX = result.farX;\n resultY = result.farY;\n }\n }\n }\n }\n }\n if (!matchObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, matchObject);\n varX.setNumber(resultX);\n varY.setNumber(resultY);\n return true;\n };\n\n /**\n * Do the work of creating a new object\n */\n export const doCreateObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectName: string,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n // objectsContext will either be the gdjs.RuntimeScene or, in an events function, the\n // eventsFunctionContext. We can't directly use runtimeScene because the object name could\n // be different than the real object name (this is the case in a function. The eventsFunctionContext\n // will take care of this in createObject).\n const obj = objectsContext.createObject(objectName);\n const layer = objectsContext.getLayer(layerName);\n if (obj !== null) {\n //Do some extra setup\n obj.setPosition(x, y);\n obj.setLayer(layerName);\n obj.setZOrder(layer.getDefaultZOrder());\n\n //Let the new object be picked by next actions/conditions.\n if (objectsLists.containsKey(objectName)) {\n objectsLists.get(objectName).push(obj);\n }\n }\n return obj;\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n return gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectsLists.firstKey() as string,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectFromGroupOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n objectName: string,\n x: float,\n y: float,\n layerName: string\n ) {\n gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectName,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Return the number of instances in the specified lists of objects.\n */\n export const getPickedInstancesCount = (objectsLists: ObjectsLists) => {\n let count = 0;\n const lists = gdjs.staticArray(\n gdjs.evtTools.object.getPickedInstancesCount\n );\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n count += lists[i].length;\n }\n return count;\n };\n\n /**\n * Return the number of instances of the specified objects living on the scene.\n */\n export const getSceneInstancesCount = (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists\n ) => {\n let count = 0;\n\n const objectNames = gdjs.staticArray(\n gdjs.evtTools.object.getSceneInstancesCount\n );\n objectsLists.keys(objectNames);\n\n const uniqueObjectNames = new Set(objectNames);\n for (const objectName of uniqueObjectNames) {\n count += objectsContext.getInstancesCountOnScene(objectName);\n }\n return count;\n };\n\n /** @deprecated */\n export const pickedObjectsCount = getPickedInstancesCount;\n }\n }\n\n /**\n * A container for objects lists that should last more than the current frame.\n * It automatically removes objects that were destroyed from the objects lists.\n */\n export class LongLivedObjectsList {\n private objectsLists = new Map<string, Array<RuntimeObject>>();\n private localVariablesContainers: Array<gdjs.VariablesContainer> = [];\n private callbacks = new Map<RuntimeObject, () => void>();\n private parent: LongLivedObjectsList | null = null;\n\n /**\n * Create a new container for objects lists, inheriting from another one. This is\n * useful should we get the objects that have not been saved in this context (using\n * `addObject`) but saved in a parent context.\n * This avoids to save all object lists every time we create a new `LongLivedObjectsList`,\n * despite not all objects lists being used.\n *\n * @param parent\n * @returns\n */\n static from(parent: LongLivedObjectsList): LongLivedObjectsList {\n const newList = new LongLivedObjectsList();\n newList.parent = parent;\n return newList;\n }\n\n private getOrCreateList(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName))\n this.objectsLists.set(objectName, []);\n return this.objectsLists.get(objectName)!;\n }\n\n getObjects(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName) && this.parent)\n return this.parent.getObjects(objectName);\n return this.objectsLists.get(objectName) || [];\n }\n\n addObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n if (list.includes(runtimeObject)) return;\n list.push(runtimeObject);\n\n // Register callbacks for when the object is destroyed\n const onDestroy = () => this.removeObject(objectName, runtimeObject);\n this.callbacks.set(runtimeObject, onDestroy);\n runtimeObject.registerDestroyCallback(onDestroy);\n }\n\n removeObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n const index = list.indexOf(runtimeObject);\n if (index === -1) return;\n list.splice(index, 1);\n\n // Properly remove callbacks to not leak the object\n runtimeObject.unregisterDestroyCallback(\n this.callbacks.get(runtimeObject)!\n );\n this.callbacks.delete(runtimeObject);\n }\n\n restoreLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(this.localVariablesContainers, variablesContainers);\n }\n\n backupLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(variablesContainers, this.localVariablesContainers);\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CAOE,AAAM,WAAW,SACtB,EACA,EACA,CACA,SAAW,KAAY,GAAa,MAClC,GAAI,EAAa,MAAM,eAAe,GAAW,CAC/C,KAAM,GAAO,EAAa,MAAM,GAGhC,AAAI,EAAK,QAAQ,KAAmB,GAClC,EAAK,OAAS,EAEd,GAAK,OAAS,EAGd,EAAK,KAAK,MA8BL,eAAe,SAC1B,EAKA,EACA,EACA,EACA,EACA,CACA,GAAI,GAAS,GACb,KAAM,GAAgB,EAAK,YACzB,EAAK,SAAS,OAAO,cAEvB,EAAc,OAAO,GACrB,KAAM,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I,IAErB,KAAK,UAAU,OAAO,IAGxB,gCACE,EACM,CACN,EAAK,UAAU,KAAK,yBAA0B,GAGhD,+BACE,EACM,CACN,EAAK,UAAU,EAAqB,KAAK,2BAnEtC,EAAM,yBA/mBL",
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 object {\n /**\n * Keep only the specified object in the lists of picked objects.\n *\n * @param objectsLists The lists of objects to trim\n * @param runtimeObject The object to keep in the lists\n */\n export const pickOnly = function (\n objectsLists: ObjectsLists,\n runtimeObject: gdjs.RuntimeObject\n ) {\n for (const listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n const list = objectsLists.items[listName];\n\n //Be sure not to lose the reference to the original array\n if (list.indexOf(runtimeObject) === -1) {\n list.length = 0;\n } else {\n list.length = 0;\n\n //Be sure not to lose the reference to the original array\n list.push(runtimeObject);\n }\n }\n }\n };\n\n /**\n * Do a test on two tables of objects so as to pick only the pair of objects for which the test is true.\n *\n * Note that the predicate method is not called strictly for each pair: When considering a pair of objects, if\n * these objects have already been marked as picked, the predicate method won't be called again.\n *\n * Cost (Worst case, predicate being always false):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*NbObjList1*NbObjList2\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n * + Cost(Removing NbObjList1+NbObjList2 objects from all the lists)\n *\n * Cost (Best case, predicate being always true):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*(NbObjList1+NbObjList2)\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n *\n *\n * @param predicate The predicate function is called with the two objects to compare, and an optional argument `extraArg`\n * @param objectsLists1 The first lists of objects\n * @param objectsLists2 The second lists of objects\n * @param inverted If `inverted` == true, only the objects of the first table are filtered.\n * @param extraArg (optional) This argument should be used to avoid declaring the predicate as a closure that would be created and destroyed at each call to twoListsTest (potentially multiple time per frame).\n */\n export const twoListsTest = function (\n predicate: (\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n extraArg: any\n ) => boolean,\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n extraArg: any\n ) {\n let isTrue = false;\n const objects1Lists = gdjs.staticArray(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists1.values(objects1Lists);\n const objects2Lists = gdjs.staticArray2(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists2.values(objects2Lists);\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n\n //Launch the function for each object of the first list with each object\n //of the second list.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n const arr1 = objects1Lists[i];\n for (let k = 0, lenk = arr1.length; k < lenk; ++k) {\n let atLeastOneObject = false;\n for (let j = 0, lenj = objects2Lists.length; j < lenj; ++j) {\n const arr2 = objects2Lists[j];\n for (let l = 0, lenl = arr2.length; l < lenl; ++l) {\n if (arr1[k].pick && arr2[l].pick) {\n continue;\n }\n\n //Avoid unnecessary costly call to predicate.\n if (\n arr1[k].id !== arr2[l].id &&\n predicate(arr1[k], arr2[l], extraArg)\n ) {\n if (!inverted) {\n isTrue = true;\n\n //Pick the objects\n arr1[k].pick = true;\n arr2[l].pick = true;\n }\n atLeastOneObject = true;\n }\n }\n }\n if (!atLeastOneObject && inverted) {\n //For example, the object is not overlapping any other object.\n isTrue = true;\n arr1[k].pick = true;\n }\n }\n }\n\n //Trim not picked objects from lists.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n if (!inverted) {\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n }\n return isTrue;\n };\n\n /**\n * Filter objects to keep only the one that fullfil the predicate\n *\n * Objects that do not fullfil the predicate are removed from objects lists.\n *\n * @param predicate The function applied to each object: must return true if the object fulfill the predicate.\n * @param objectsLists The lists of objects to trim\n * @param negatePredicate If set to true, the result of the predicate is negated.\n * @param extraArg Argument passed to the predicate (along with the object). Useful for avoiding relying on temporary closures.\n * @return true if at least one object fulfill the predicate.\n */\n export const pickObjectsIf = function (\n predicate: Function,\n objectsLists: ObjectsLists,\n negatePredicate: boolean,\n extraArg: any\n ): boolean {\n let isTrue = false;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickObjectsIf);\n objectsLists.values(lists);\n\n // Pick only objects that are fulfilling the predicate.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n const arr = lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const object = arr[k];\n // @ts-ignore\n if (negatePredicate ^ predicate(object, extraArg)) {\n isTrue = true;\n object.pick = true;\n } else {\n object.pick = false;\n }\n }\n }\n\n // Trim not picked objects from lists.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n gdjs.evtTools.object.filterPickedObjectsList(lists[i]);\n }\n return isTrue;\n };\n\n /**\n * Filter in-place the specified array to remove objects for which\n * `pick` property is set to false.\n */\n export const filterPickedObjectsList = function (\n arr: gdjs.RuntimeObject[]\n ) {\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const obj = arr[k];\n if (obj.pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n };\n\n export const hitBoxesCollisionTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n instanceContainer: gdjs.RuntimeInstanceContainer,\n ignoreTouchingEdges: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.RuntimeObject.collisionTest,\n objectsLists1,\n objectsLists2,\n inverted,\n ignoreTouchingEdges\n );\n };\n\n export const _distanceBetweenObjects = function (obj1, obj2, distance) {\n return obj1.getSqDistanceToObject(obj2) <= distance;\n };\n\n export const distanceTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n distance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._distanceBetweenObjects,\n objectsLists1,\n objectsLists2,\n inverted,\n distance * distance\n );\n };\n\n export const _movesToward = function (obj1, obj2, tolerance) {\n if (obj1.hasNoForces()) {\n return false;\n }\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAverageForce().getAngle(),\n objAngle\n )\n ) <=\n tolerance / 2\n );\n };\n\n export const movesTowardTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._movesToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n // Deprecated\n export const _turnedToward = function (obj1, obj2, tolerance) {\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(obj1.getAngle(), objAngle)\n ) <=\n tolerance / 2\n );\n };\n\n // Deprecated\n export const turnedTowardTest = function (\n objectsLists1,\n objectsLists2,\n tolerance,\n inverted\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._turnedToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const _isTurnedTowardObject = function (\n obj1: gdjs.RuntimeObject,\n obj2: gdjs.RuntimeObject,\n tolerance: float\n ) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAngle(),\n obj1.getAngleToObject(obj2)\n )\n ) <= tolerance\n );\n };\n\n export const isTurnedTowardObject = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._isTurnedTowardObject,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const pickAllObjects = function (objectsContext, objectsLists) {\n for (const name in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(name)) {\n const allObjects = objectsContext.getObjects(name);\n const objectsList = objectsLists.items[name];\n gdjs.copyArray(allObjects, objectsList);\n }\n }\n return true;\n };\n\n export const pickRandomObject = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectsLists: ObjectsLists\n ) {\n // Compute one many objects we have\n let objectsCount = 0;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n objectsCount += list.length;\n }\n }\n if (objectsCount === 0) {\n return false;\n }\n\n // Pick one random object\n let index = Math.floor(Math.random() * objectsCount);\n if (index >= objectsCount) {\n index = objectsCount - 1;\n }\n\n //Should never happen.\n\n // Find the object\n let startIndex = 0;\n let theChosenOne: gdjs.RuntimeObject | null = null;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n if (index - startIndex < list.length) {\n theChosenOne = list[index - startIndex];\n break;\n }\n startIndex += list.length;\n }\n }\n // @ts-ignore\n gdjs.evtTools.object.pickOnly(objectsLists, theChosenOne);\n return true;\n };\n\n export const pickNearestObject = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n inverted?: boolean | undefined\n ) {\n let bestObject = null;\n let best = 0;\n let first = true;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickNearestObject);\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n const list = lists[i];\n for (let j = 0; j < list.length; ++j) {\n const object = list[j];\n const distance = object.getSqDistanceToPosition(x, y);\n if (first || distance < best !== inverted) {\n best = distance;\n bestObject = object;\n }\n first = false;\n }\n }\n if (!bestObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, bestObject);\n return true;\n };\n\n export const raycastObject = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n angle: float,\n dist: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.raycastObjectToPosition(\n objectsLists,\n x,\n y,\n x + dist * Math.cos((angle * Math.PI) / 180.0),\n y + dist * Math.sin((angle * Math.PI) / 180.0),\n varX,\n varY,\n inverted\n );\n };\n\n export const raycastObjectToPosition = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n endX: float,\n endY: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n let matchObject: gdjs.RuntimeObject | null = null;\n let testSqDist = inverted\n ? 0\n : (endX - x) * (endX - x) + (endY - y) * (endY - y);\n let resultX = 0;\n let resultY = 0;\n const lists: RuntimeObject[][] = gdjs.staticArray(\n gdjs.evtTools.object.raycastObjectToPosition\n );\n objectsLists.values(lists);\n for (let i = 0; i < lists.length; i++) {\n const list = lists[i];\n for (let j = 0; j < list.length; j++) {\n const object = list[j];\n const result = object.raycastTest(x, y, endX, endY, !inverted);\n if (result.collision) {\n if (!inverted && result.closeSqDist <= testSqDist) {\n testSqDist = result.closeSqDist;\n matchObject = object;\n resultX = result.closeX;\n resultY = result.closeY;\n } else {\n if (inverted && result.farSqDist >= testSqDist) {\n testSqDist = result.farSqDist;\n matchObject = object;\n resultX = result.farX;\n resultY = result.farY;\n }\n }\n }\n }\n }\n if (!matchObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, matchObject);\n varX.setNumber(resultX);\n varY.setNumber(resultY);\n return true;\n };\n\n /**\n * Do the work of creating a new object\n */\n export const doCreateObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectName: string,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n // objectsContext will either be the gdjs.RuntimeScene or, in an events function, the\n // eventsFunctionContext. We can't directly use runtimeScene because the object name could\n // be different than the real object name (this is the case in a function. The eventsFunctionContext\n // will take care of this in createObject).\n const obj = objectsContext.createObject(objectName);\n const layer = objectsContext.getLayer(layerName);\n if (obj !== null) {\n //Do some extra setup\n obj.setPosition(x, y);\n obj.setLayer(layerName);\n obj.setZOrder(layer.getDefaultZOrder());\n\n //Let the new object be picked by next actions/conditions.\n if (objectsLists.containsKey(objectName)) {\n objectsLists.get(objectName).push(obj);\n }\n }\n return obj;\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n return gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectsLists.firstKey() as string,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectFromGroupOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n objectName: string,\n x: float,\n y: float,\n layerName: string\n ) {\n gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectName,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Return the number of instances in the specified lists of objects.\n */\n export const getPickedInstancesCount = (objectsLists: ObjectsLists) => {\n let count = 0;\n const lists = gdjs.staticArray(\n gdjs.evtTools.object.getPickedInstancesCount\n );\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n count += lists[i].length;\n }\n return count;\n };\n\n /**\n * Return the number of instances of the specified objects living on the scene.\n */\n export const getSceneInstancesCount = (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists\n ) => {\n let count = 0;\n\n const objectNames = gdjs.staticArray(\n gdjs.evtTools.object.getSceneInstancesCount\n );\n objectsLists.keys(objectNames);\n\n const uniqueObjectNames = new Set(objectNames);\n for (const objectName of uniqueObjectNames) {\n count += objectsContext.getInstancesCountOnScene(objectName);\n }\n return count;\n };\n\n /** @deprecated */\n export const pickedObjectsCount = getPickedInstancesCount;\n }\n }\n\n const logger = new gdjs.Logger('LongLivedObjectsLists');\n export type LongLivedObjectsListNetworkSyncData = {\n objectsLists: {\n [objectName: string]: Array<string>;\n };\n localVariablesContainers: Array<Array<VariableNetworkSyncData>>;\n };\n\n /**\n * A container for objects lists that should last more than the current frame.\n * It automatically removes objects that were destroyed from the objects lists.\n */\n export class LongLivedObjectsList {\n private objectsLists = new Map<string, Array<RuntimeObject>>();\n private localVariablesContainers: Array<gdjs.VariablesContainer> = [];\n private callbacks = new Map<RuntimeObject, () => void>();\n private parent: LongLivedObjectsList | null = null;\n\n /**\n * Create a new container for objects lists, inheriting from another one. This is\n * useful should we get the objects that have not been saved in this context (using\n * `addObject`) but saved in a parent context.\n * This avoids to save all object lists every time we create a new `LongLivedObjectsList`,\n * despite not all objects lists being used.\n *\n * @param parent\n * @returns\n */\n static from(parent: LongLivedObjectsList): LongLivedObjectsList {\n const newList = new LongLivedObjectsList();\n newList.parent = parent;\n return newList;\n }\n\n private getOrCreateList(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName))\n this.objectsLists.set(objectName, []);\n return this.objectsLists.get(objectName)!;\n }\n\n getObjects(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName) && this.parent)\n return this.parent.getObjects(objectName);\n return this.objectsLists.get(objectName) || [];\n }\n\n addObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n if (list.includes(runtimeObject)) return;\n list.push(runtimeObject);\n\n // Register callbacks for when the object is destroyed\n const onDestroy = () => this.removeObject(objectName, runtimeObject);\n this.callbacks.set(runtimeObject, onDestroy);\n runtimeObject.registerDestroyCallback(onDestroy);\n }\n\n removeObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n const index = list.indexOf(runtimeObject);\n if (index === -1) return;\n list.splice(index, 1);\n\n // Properly remove callbacks to not leak the object\n runtimeObject.unregisterDestroyCallback(\n this.callbacks.get(runtimeObject)!\n );\n this.callbacks.delete(runtimeObject);\n }\n\n restoreLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(this.localVariablesContainers, variablesContainers);\n }\n\n backupLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(variablesContainers, this.localVariablesContainers);\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): LongLivedObjectsListNetworkSyncData {\n const objectsLists: {\n [objectName: string]: Array<string>;\n } = {};\n for (const [objectName, runtimeObjects] of this.objectsLists.entries()) {\n const objectNetworkIds: Array<string> = [];\n for (const runtimeObject of runtimeObjects) {\n const objectNetworkId = runtimeObject.getNetworkId();\n if (!objectNetworkId) {\n logger.warn(\n 'Tried to get sync data of a LongLivedObjectsList and found an object without a network ID'\n );\n continue;\n }\n objectNetworkIds.push(objectNetworkId);\n }\n objectsLists[objectName] = objectNetworkIds;\n }\n return {\n objectsLists,\n localVariablesContainers: this.localVariablesContainers.map(\n (container) => container.getNetworkSyncData(syncOptions)\n ),\n };\n }\n\n updateFromNetworkSyncData(\n syncData: LongLivedObjectsListNetworkSyncData,\n runtimeScene: gdjs.RuntimeScene,\n syncOptions: UpdateFromNetworkSyncDataOptions\n ) {\n const { objectsLists, localVariablesContainers } = syncData;\n\n // Clear the current state.\n this.objectsLists.clear();\n this.localVariablesContainers.length = 0;\n\n // Restore the list of objects.\n for (const [objectName, objectNetworkIds] of Object.entries(\n objectsLists\n )) {\n const runtimeObjects = runtimeScene.getObjects(objectName);\n if (!runtimeObjects) {\n logger.warn(\n 'Tried to update sync data of a LongLivedObjectsList but cannot find objects with name: ' +\n objectName\n );\n continue;\n }\n\n const runtimeObjectsFromSyncData = runtimeObjects.filter(\n (runtimeObject) => {\n const runtimeObjectNetworkId = runtimeObject.getNetworkId();\n return (\n !!runtimeObjectNetworkId &&\n objectNetworkIds.includes(runtimeObjectNetworkId)\n );\n }\n );\n\n for (const runtimeObject of runtimeObjectsFromSyncData) {\n this.addObject(objectName, runtimeObject);\n }\n }\n\n // Restore the local variables containers.\n this.localVariablesContainers = localVariablesContainers.map(\n (localVariablesContainer) => {\n const newContainer = new gdjs.VariablesContainer();\n newContainer.updateFromNetworkSyncData(\n localVariablesContainer,\n syncOptions\n );\n return newContainer;\n }\n );\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CAOE,AAAM,WAAW,SACtB,EACA,EACA,CACA,SAAW,KAAY,GAAa,MAClC,GAAI,EAAa,MAAM,eAAe,GAAW,CAC/C,KAAM,GAAO,EAAa,MAAM,GAGhC,AAAI,EAAK,QAAQ,KAAmB,GAClC,EAAK,OAAS,EAEd,GAAK,OAAS,EAGd,EAAK,KAAK,MA8BL,eAAe,SAC1B,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e.getScene().getTimeManager().isFirstFrame()},s.sceneJustResumed=function(e){return e.getScene().sceneJustResumed()},s.getSceneName=function(e){return e.getScene().getName()},s.setBackgroundColor=function(e,t){const n=r.rgbOrHexToRGBColor(t);e.getScene().setBackgroundColor(n[0],n[1],n[2])},s.getElapsedTimeInSeconds=function(e){return e.getScene().getTimeManager().getElapsedTime()/1e3},s.setTimeScale=function(e,t){return e.getScene().getTimeManager().setTimeScale(t)},s.getTimeScale=function(e){return e.getScene().getTimeManager().getTimeScale()},s.timerElapsedTime=function(e,t,n){const a=e.getScene().getTimeManager();return a.hasTimer(n)?a.getTimer(n).getTime()/1e3>=t:(a.addTimer(n),!1)},s.timerPaused=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).isPaused():!1},s.resetTimer=function(e,t){const n=e.getScene().getTimeManager();n.hasTimer(t)?n.getTimer(t).reset():n.addTimer(t)},s.pauseTimer=function(e,t){const n=e.getScene().getTimeManager();n.hasTimer(t)||n.addTimer(t),n.getTimer(t).setPaused(!0)},s.unpauseTimer=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)||n.addTimer(t),n.getTimer(t).setPaused(!1)},s.removeTimer=function(e,t){e.getScene().getTimeManager().removeTimer(t)};class m extends r.AsyncTask{constructor(t){super();this.timeElapsedOnScene=0;this.duration=t}update(t){return this.timeElapsedOnScene+=t.getScene().getTimeManager().getElapsedTime(),this.timeElapsedOnScene>=this.duration}}s.WaitTask=m,s.wait=e=>new m(e*1e3),s.getTimerElapsedTimeInSeconds=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).getTime()/1e3:0},s.getTimerElapsedTimeInSecondsOrNaN=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).getTime()/1e3:Number.NaN},s.getTimeFromStartInSeconds=function(e){return e.getScene().getTimeManager().getTimeFromStart()/1e3},s.getTime=function(e,t){if(t==="timestamp")return Date.now();const n=new Date;if(t==="hour")return n.getHours();if(t==="min")return n.getMinutes();if(t==="sec")return n.getSeconds();if(t==="mday")return n.getDate();if(t==="mon")return n.getMonth();if(t==="year")return n.getFullYear()-1900;if(t==="wday")return n.getDay();if(t==="yday"){const a=new Date(n.getFullYear(),0,0),g=n.getTime()-a.getTime(),o=1e3*60*60*24;return Math.floor(g/o)}return 0},s.replaceScene=function(e,t,n){!e.getGame().getSceneAndExtensionsData(t)||e.getScene().requestChange(n?r.SceneChangeRequest.CLEAR_SCENES:r.SceneChangeRequest.REPLACE_SCENE,t)},s.pushScene=function(e,t){!e.getGame().getSceneAndExtensionsData(t)||e.getScene().requestChange(r.SceneChangeRequest.PUSH_SCENE,t)},s.popScene=function(e){e.getScene().requestChange(r.SceneChangeRequest.POP_SCENE)},s.stopGame=function(e){e.getScene().requestChange(r.SceneChangeRequest.STOP_GAME)},s.createObjectsFromExternalLayout=function(e,t,n,a,g){const o=e.getGame().getExternalLayoutData(t);o!==null&&e.getScene().createObjectsFrom(o.instances,n,a,g||0,!1)},s.hasGameJustResumed=e=>e.getGame().hasJustResumed(),s.doesSceneExist=(e,t)=>e.getGame().hasScene(t),s.prioritizeLoadingOfScene=(e,t)=>{e.getGame().prioritizeLoadingOfScene(t)},s.getSceneLoadingProgress=(e,t)=>e.getGame().getSceneLoadingProgress(t),s.areSceneAssetsLoaded=(e,t)=>e.getGame().areSceneAssetsLoaded(t)})(u=i.runtimeScene||(i.runtimeScene={}))})(c=r.evtTools||(r.evtTools={}))})(gdjs||(gdjs={}));
1
+ var gdjs;(function(r){let c;(function(g){let u;(function(s){s.sceneJustBegins=function(t){return t.getScene().getTimeManager().isFirstFrame()},s.sceneJustResumed=function(t){return t.getScene().sceneJustResumed()},s.getSceneName=function(t){return t.getScene().getName()},s.setBackgroundColor=function(t,e){const n=r.rgbOrHexToRGBColor(e);t.getScene().setBackgroundColor(n[0],n[1],n[2])},s.getElapsedTimeInSeconds=function(t){return t.getScene().getTimeManager().getElapsedTime()/1e3},s.setTimeScale=function(t,e){return t.getScene().getTimeManager().setTimeScale(e)},s.getTimeScale=function(t){return t.getScene().getTimeManager().getTimeScale()},s.timerElapsedTime=function(t,e,n){const a=t.getScene().getTimeManager();return a.hasTimer(n)?a.getTimer(n).getTime()/1e3>=e:(a.addTimer(n),!1)},s.timerPaused=function(t,e){const n=t.getScene().getTimeManager();return n.hasTimer(e)?n.getTimer(e).isPaused():!1},s.resetTimer=function(t,e){const n=t.getScene().getTimeManager();n.hasTimer(e)?n.getTimer(e).reset():n.addTimer(e)},s.pauseTimer=function(t,e){const n=t.getScene().getTimeManager();n.hasTimer(e)||n.addTimer(e),n.getTimer(e).setPaused(!0)},s.unpauseTimer=function(t,e){const n=t.getScene().getTimeManager();return n.hasTimer(e)||n.addTimer(e),n.getTimer(e).setPaused(!1)},s.removeTimer=function(t,e){t.getScene().getTimeManager().removeTimer(e)};class d extends r.AsyncTask{constructor(e){super();this.timeElapsedOnScene=0;this.duration=e}update(e){return this.timeElapsedOnScene+=e.getScene().getTimeManager().getElapsedTime(),this.timeElapsedOnScene>=this.duration}getNetworkSyncData(){return{type:"wait",duration:this.duration,timeElapsedOnScene:this.timeElapsedOnScene}}updateFromNetworkSyncData(e){this.duration=e.duration,this.timeElapsedOnScene=e.timeElapsedOnScene}}s.WaitTask=d,s.wait=t=>new d(t*1e3),s.getTimerElapsedTimeInSeconds=function(t,e){const n=t.getScene().getTimeManager();return n.hasTimer(e)?n.getTimer(e).getTime()/1e3:0},s.getTimerElapsedTimeInSecondsOrNaN=function(t,e){const n=t.getScene().getTimeManager();return n.hasTimer(e)?n.getTimer(e).getTime()/1e3:Number.NaN},s.getTimeFromStartInSeconds=function(t){return t.getScene().getTimeManager().getTimeFromStart()/1e3},s.getTime=function(t,e){if(e==="timestamp")return Date.now();const n=new Date;if(e==="hour")return n.getHours();if(e==="min")return n.getMinutes();if(e==="sec")return n.getSeconds();if(e==="mday")return n.getDate();if(e==="mon")return n.getMonth();if(e==="year")return n.getFullYear()-1900;if(e==="wday")return n.getDay();if(e==="yday"){const a=new Date(n.getFullYear(),0,0),i=n.getTime()-a.getTime(),o=1e3*60*60*24;return Math.floor(i/o)}return 0},s.replaceScene=function(t,e,n){!t.getGame().getSceneAndExtensionsData(e)||t.getScene().requestChange(n?r.SceneChangeRequest.CLEAR_SCENES:r.SceneChangeRequest.REPLACE_SCENE,e)},s.pushScene=function(t,e){!t.getGame().getSceneAndExtensionsData(e)||t.getScene().requestChange(r.SceneChangeRequest.PUSH_SCENE,e)},s.popScene=function(t){t.getScene().requestChange(r.SceneChangeRequest.POP_SCENE)},s.stopGame=function(t){t.getScene().requestChange(r.SceneChangeRequest.STOP_GAME)},s.createObjectsFromExternalLayout=function(t,e,n,a,i){const o=t.getGame().getExternalLayoutData(e);o!==null&&t.getScene().createObjectsFrom(o.instances,n,a,i||0,!1)},s.hasGameJustResumed=t=>t.getGame().hasJustResumed(),s.doesSceneExist=(t,e)=>t.getGame().hasScene(e),s.prioritizeLoadingOfScene=(t,e)=>{t.getGame().prioritizeLoadingOfScene(e)},s.getSceneLoadingProgress=(t,e)=>t.getGame().getSceneLoadingProgress(e),s.areSceneAssetsLoaded=(t,e)=>t.getGame().areSceneAssetsLoaded(e)})(u=g.runtimeScene||(g.runtimeScene={}))})(c=r.evtTools||(r.evtTools={}))})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimescenetools.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/events-tools/runtimescenetools.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 runtimeScene {\n export const sceneJustBegins = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().getTimeManager().isFirstFrame();\n };\n\n export const sceneJustResumed = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().sceneJustResumed();\n };\n\n export const getSceneName = function (runtimeScene: gdjs.RuntimeScene) {\n return runtimeScene.getScene().getName();\n };\n\n export const setBackgroundColor = function (\n runtimeScene: gdjs.RuntimeScene,\n rgbOrHexColor: string\n ) {\n const color = gdjs.rgbOrHexToRGBColor(rgbOrHexColor);\n runtimeScene\n .getScene()\n .setBackgroundColor(color[0], color[1], color[2]);\n };\n\n export const getElapsedTimeInSeconds = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().getTimeManager().getElapsedTime() / 1000;\n };\n\n export const setTimeScale = function (\n runtimeScene: gdjs.RuntimeScene,\n timeScale: float\n ) {\n return runtimeScene.getScene().getTimeManager().setTimeScale(timeScale);\n };\n\n export const getTimeScale = function (runtimeScene: gdjs.RuntimeScene) {\n return runtimeScene.getScene().getTimeManager().getTimeScale();\n };\n\n /**\n * Test a timer elapsed time, if the timer doesn't exist it is created.\n *\n * @deprecated prefer using getTimerElapsedTimeInSecondsOrNaN\n *\n * @param runtimeScene The scene owning the timer\n * @param timeInSeconds The time value to check in seconds\n * @param timerName The timer name\n * @return True if the timer exists and its value is greater than or equal than the given time, false otherwise\n */\n export const timerElapsedTime = function (\n runtimeScene: gdjs.RuntimeScene,\n timeInSeconds: float,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n return false;\n }\n return (\n timeManager.getTimer(timerName).getTime() / 1000 >= timeInSeconds\n );\n };\n\n export const timerPaused = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return false;\n }\n return timeManager.getTimer(timerName).isPaused();\n };\n\n export const resetTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n } else {\n timeManager.getTimer(timerName).reset();\n }\n };\n\n export const pauseTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n }\n timeManager.getTimer(timerName).setPaused(true);\n };\n\n export const unpauseTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n }\n return timeManager.getTimer(timerName).setPaused(false);\n };\n\n export const removeTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n timeManager.removeTimer(timerName);\n };\n\n export class WaitTask extends gdjs.AsyncTask {\n private duration: float;\n private timeElapsedOnScene = 0;\n\n constructor(durationInMilliseconds: float) {\n super();\n this.duration = durationInMilliseconds;\n }\n\n update(runtimeScene: RuntimeScene): boolean {\n this.timeElapsedOnScene += runtimeScene\n .getScene()\n .getTimeManager()\n .getElapsedTime();\n return this.timeElapsedOnScene >= this.duration;\n }\n }\n\n export const wait = (durationInSeconds: float): AsyncTask =>\n new WaitTask(\n durationInSeconds * 1000 /* Convert from seconds to milliseconds */\n );\n\n /**\n * This is used by expressions to return 0 when a timer doesn't exist,\n * because numeric expressions must always return a number.\n *\n * @param runtimeScene The scene owning the timer.\n * @param timerName The timer name.\n * @returns The timer elapsed time in seconds or 0 if the timer doesn't exist.\n */\n export const getTimerElapsedTimeInSeconds = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return 0;\n }\n return timeManager.getTimer(timerName).getTime() / 1000;\n };\n\n /**\n * This is used by conditions to return false when a timer doesn't exist,\n * no matter the relational operator.\n *\n * @param runtimeScene The scene owning the timer.\n * @param timerName The timer name.\n * @returns The timer elapsed time in seconds or NaN if the timer doesn't exist.\n */\n export const getTimerElapsedTimeInSecondsOrNaN = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return Number.NaN;\n }\n return timeManager.getTimer(timerName).getTime() / 1000;\n };\n\n export const getTimeFromStartInSeconds = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return (\n runtimeScene.getScene().getTimeManager().getTimeFromStart() / 1000\n );\n };\n\n export const getTime = function (\n runtimeScene: gdjs.RuntimeScene,\n what: string\n ) {\n if (what === 'timestamp') {\n return Date.now();\n }\n const now = new Date();\n if (what === 'hour') {\n return now.getHours();\n } else if (what === 'min') {\n return now.getMinutes();\n } else if (what === 'sec') {\n return now.getSeconds();\n } else if (what === 'mday') {\n return now.getDate();\n } else if (what === 'mon') {\n return now.getMonth();\n } else if (what === 'year') {\n //Conform to the C way of returning years.\n return now.getFullYear() - 1900;\n } else if (what === 'wday') {\n return now.getDay();\n } else if (what === 'yday') {\n const start = new Date(now.getFullYear(), 0, 0);\n const diff = now.getTime() - start.getTime();\n const oneDay = 1000 * 60 * 60 * 24;\n return Math.floor(diff / oneDay);\n }\n return 0;\n };\n\n export const replaceScene = function (\n runtimeScene: gdjs.RuntimeScene,\n newSceneName: string,\n clearOthers: boolean\n ) {\n if (!runtimeScene.getGame().getSceneAndExtensionsData(newSceneName)) {\n return;\n }\n runtimeScene\n .getScene()\n .requestChange(\n clearOthers\n ? gdjs.SceneChangeRequest.CLEAR_SCENES\n : gdjs.SceneChangeRequest.REPLACE_SCENE,\n newSceneName\n );\n };\n\n export const pushScene = function (\n runtimeScene: gdjs.RuntimeScene,\n newSceneName: string\n ) {\n if (!runtimeScene.getGame().getSceneAndExtensionsData(newSceneName)) {\n return;\n }\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.PUSH_SCENE, newSceneName);\n };\n\n export const popScene = function (runtimeScene: gdjs.RuntimeScene) {\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.POP_SCENE);\n };\n\n export const stopGame = function (runtimeScene: gdjs.RuntimeScene) {\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.STOP_GAME);\n };\n\n export const createObjectsFromExternalLayout = function (\n scene: gdjs.RuntimeInstanceContainer,\n externalLayout: string,\n xPos: float,\n yPos: float,\n zPos: float\n ) {\n const externalLayoutData = scene\n .getGame()\n .getExternalLayoutData(externalLayout);\n if (externalLayoutData === null) {\n return;\n }\n\n // trackByPersistentUuid is set to false as we don't want external layouts\n // instantiated at runtime to be hot-reloaded.\n scene.getScene().createObjectsFrom(\n externalLayoutData.instances,\n xPos,\n yPos,\n /**\n * When 3D was introduced, zPos argument was added to the signature.\n * Existing calls (in JS events) to createObjectsFromExternalLayout will\n * have zPos undefined. So it is set to 0 in that case.\n */\n zPos || 0,\n /*trackByPersistentUuid=*/\n false\n );\n };\n\n /**\n * Check if the game has just resumed from being hidden\n */\n export const hasGameJustResumed = (\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): boolean => {\n return instanceContainer.getGame().hasJustResumed();\n };\n\n /**\n * Check if a scene exists.\n */\n export const doesSceneExist = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): boolean => {\n return runtimeScene.getGame().hasScene(sceneName);\n };\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n export const prioritizeLoadingOfScene = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): void => {\n runtimeScene.getGame().prioritizeLoadingOfScene(sceneName);\n };\n\n /**\n * @return The progress of assets loading in background for a scene (between 0 and 1).\n */\n export const getSceneLoadingProgress = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): float => {\n return runtimeScene.getGame().getSceneLoadingProgress(sceneName);\n };\n\n /**\n * Check if scene assets have finished to load in background.\n */\n export const areSceneAssetsLoaded = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): boolean => {\n return runtimeScene.getGame().areSceneAssetsLoaded(sceneName);\n };\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CACE,AAAM,kBAAkB,SAC7B,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,gBAGrC,mBAAmB,SAC9B,EACA,CACA,MAAO,GAAa,WAAW,oBAGpB,eAAe,SAAU,EAAiC,CACrE,MAAO,GAAa,WAAW,WAGpB,qBAAqB,SAChC,EACA,EACA,CACA,KAAM,GAAQ,EAAK,mBAAmB,GACtC,EACG,WACA,mBAAmB,EAAM,GAAI,EAAM,GAAI,EAAM,KAGrC,0BAA0B,SACrC,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,iBAAmB,KAGxD,eAAe,SAC1B,EACA,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,aAAa,IAGlD,eAAe,SAAU,EAAiC,CACrE,MAAO,GAAa,WAAW,iBAAiB,gBAarC,mBAAmB,SAC9B,EACA,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,MAAK,GAAY,SAAS,GAKxB,EAAY,SAAS,GAAW,UAAY,KAAQ,EAJpD,GAAY,SAAS,GACd,KAOE,cAAc,SACzB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,MAAK,GAAY,SAAS,GAGnB,EAAY,SAAS,GAAW,WAF9B,IAKE,aAAa,SACxB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,AAAK,EAAY,SAAS,GAGxB,EAAY,SAAS,GAAW,QAFhC,EAAY,SAAS,IAMZ,aAAa,SACxB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,AAAK,EAAY,SAAS,IACxB,EAAY,SAAS,GAEvB,EAAY,SAAS,GAAW,UAAU,KAG/B,eAAe,SAC1B,EACA,EACA,CACA,KAAM,GAAc,EAA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C1B,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAa,UAAU,0BAA0B,IAGtD,EACG,WACA,cACC,EACI,EAAK,mBAAmB,aACxB,EAAK,mBAAmB,cAC5B,IAIO,YAAY,SACvB,EACA,EACA,CACA,AAAI,CAAC,EAAa,UAAU,0BAA0B,IAGtD,EACG,WACA,cAAc,EAAK,mBAAmB,WAAY,IAG1C,WAAW,SAAU,EAAiC,CACjE,EACG,WACA,cAAc,EAAK,mBAAmB,YAG9B,WAAW,SAAU,EAAiC,CACjE,EACG,WACA,cAAc,EAAK,mBAAmB,YAG9B,kCAAkC,SAC7C,EACA,EACA,EACA,EACA,EACA,CACA,KAAM,GAAqB,EACxB,UACA,sBAAsB,GACzB,AAAI,IAAuB,MAM3B,EAAM,WAAW,kBACf,EAAmB,UACnB,EACA,EAMA,GAAQ,EAER,KAOS,qBAAqB,AAChC,GAEO,EAAkB,UAAU,iBAMxB,iBAAiB,CAC5B,EACA,IAEO,EAAa,UAAU,SAAS,GAM5B,2BAA2B,CACtC,EACA,IACS,CACT,EAAa,UAAU,yBAAyB,IAMrC,0BAA0B,CACrC,EACA,IAEO,EAAa,UAAU,wBAAwB,GAM3C,uBAAuB,CAClC,EACA,IAEO,EAAa,UAAU,qBAAqB,KAtVtC,yCADF,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 runtimeScene {\n export const sceneJustBegins = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().getTimeManager().isFirstFrame();\n };\n\n export const sceneJustResumed = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().sceneJustResumed();\n };\n\n export const getSceneName = function (runtimeScene: gdjs.RuntimeScene) {\n return runtimeScene.getScene().getName();\n };\n\n export const setBackgroundColor = function (\n runtimeScene: gdjs.RuntimeScene,\n rgbOrHexColor: string\n ) {\n const color = gdjs.rgbOrHexToRGBColor(rgbOrHexColor);\n runtimeScene\n .getScene()\n .setBackgroundColor(color[0], color[1], color[2]);\n };\n\n export const getElapsedTimeInSeconds = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return runtimeScene.getScene().getTimeManager().getElapsedTime() / 1000;\n };\n\n export const setTimeScale = function (\n runtimeScene: gdjs.RuntimeScene,\n timeScale: float\n ) {\n return runtimeScene.getScene().getTimeManager().setTimeScale(timeScale);\n };\n\n export const getTimeScale = function (runtimeScene: gdjs.RuntimeScene) {\n return runtimeScene.getScene().getTimeManager().getTimeScale();\n };\n\n /**\n * Test a timer elapsed time, if the timer doesn't exist it is created.\n *\n * @deprecated prefer using getTimerElapsedTimeInSecondsOrNaN\n *\n * @param runtimeScene The scene owning the timer\n * @param timeInSeconds The time value to check in seconds\n * @param timerName The timer name\n * @return True if the timer exists and its value is greater than or equal than the given time, false otherwise\n */\n export const timerElapsedTime = function (\n runtimeScene: gdjs.RuntimeScene,\n timeInSeconds: float,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n return false;\n }\n return (\n timeManager.getTimer(timerName).getTime() / 1000 >= timeInSeconds\n );\n };\n\n export const timerPaused = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return false;\n }\n return timeManager.getTimer(timerName).isPaused();\n };\n\n export const resetTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n } else {\n timeManager.getTimer(timerName).reset();\n }\n };\n\n export const pauseTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n }\n timeManager.getTimer(timerName).setPaused(true);\n };\n\n export const unpauseTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n timeManager.addTimer(timerName);\n }\n return timeManager.getTimer(timerName).setPaused(false);\n };\n\n export const removeTimer = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n timeManager.removeTimer(timerName);\n };\n\n export class WaitTask extends gdjs.AsyncTask {\n private duration: float;\n private timeElapsedOnScene = 0;\n\n constructor(durationInMilliseconds: float) {\n super();\n this.duration = durationInMilliseconds;\n }\n\n update(runtimeScene: RuntimeScene): boolean {\n this.timeElapsedOnScene += runtimeScene\n .getScene()\n .getTimeManager()\n .getElapsedTime();\n return this.timeElapsedOnScene >= this.duration;\n }\n\n getNetworkSyncData(): WaitTaskNetworkSyncData {\n return {\n type: 'wait',\n duration: this.duration,\n timeElapsedOnScene: this.timeElapsedOnScene,\n };\n }\n\n updateFromNetworkSyncData(syncData: WaitTaskNetworkSyncData): void {\n this.duration = syncData.duration;\n this.timeElapsedOnScene = syncData.timeElapsedOnScene;\n }\n }\n\n export const wait = (durationInSeconds: float): AsyncTask =>\n new WaitTask(\n durationInSeconds * 1000 /* Convert from seconds to milliseconds */\n );\n\n /**\n * This is used by expressions to return 0 when a timer doesn't exist,\n * because numeric expressions must always return a number.\n *\n * @param runtimeScene The scene owning the timer.\n * @param timerName The timer name.\n * @returns The timer elapsed time in seconds or 0 if the timer doesn't exist.\n */\n export const getTimerElapsedTimeInSeconds = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return 0;\n }\n return timeManager.getTimer(timerName).getTime() / 1000;\n };\n\n /**\n * This is used by conditions to return false when a timer doesn't exist,\n * no matter the relational operator.\n *\n * @param runtimeScene The scene owning the timer.\n * @param timerName The timer name.\n * @returns The timer elapsed time in seconds or NaN if the timer doesn't exist.\n */\n export const getTimerElapsedTimeInSecondsOrNaN = function (\n runtimeScene: gdjs.RuntimeScene,\n timerName: string\n ) {\n const timeManager = runtimeScene.getScene().getTimeManager();\n if (!timeManager.hasTimer(timerName)) {\n return Number.NaN;\n }\n return timeManager.getTimer(timerName).getTime() / 1000;\n };\n\n export const getTimeFromStartInSeconds = function (\n runtimeScene: gdjs.RuntimeScene\n ) {\n return (\n runtimeScene.getScene().getTimeManager().getTimeFromStart() / 1000\n );\n };\n\n export const getTime = function (\n runtimeScene: gdjs.RuntimeScene,\n what: string\n ) {\n if (what === 'timestamp') {\n return Date.now();\n }\n const now = new Date();\n if (what === 'hour') {\n return now.getHours();\n } else if (what === 'min') {\n return now.getMinutes();\n } else if (what === 'sec') {\n return now.getSeconds();\n } else if (what === 'mday') {\n return now.getDate();\n } else if (what === 'mon') {\n return now.getMonth();\n } else if (what === 'year') {\n //Conform to the C way of returning years.\n return now.getFullYear() - 1900;\n } else if (what === 'wday') {\n return now.getDay();\n } else if (what === 'yday') {\n const start = new Date(now.getFullYear(), 0, 0);\n const diff = now.getTime() - start.getTime();\n const oneDay = 1000 * 60 * 60 * 24;\n return Math.floor(diff / oneDay);\n }\n return 0;\n };\n\n export const replaceScene = function (\n runtimeScene: gdjs.RuntimeScene,\n newSceneName: string,\n clearOthers: boolean\n ) {\n if (!runtimeScene.getGame().getSceneAndExtensionsData(newSceneName)) {\n return;\n }\n runtimeScene\n .getScene()\n .requestChange(\n clearOthers\n ? gdjs.SceneChangeRequest.CLEAR_SCENES\n : gdjs.SceneChangeRequest.REPLACE_SCENE,\n newSceneName\n );\n };\n\n export const pushScene = function (\n runtimeScene: gdjs.RuntimeScene,\n newSceneName: string\n ) {\n if (!runtimeScene.getGame().getSceneAndExtensionsData(newSceneName)) {\n return;\n }\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.PUSH_SCENE, newSceneName);\n };\n\n export const popScene = function (runtimeScene: gdjs.RuntimeScene) {\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.POP_SCENE);\n };\n\n export const stopGame = function (runtimeScene: gdjs.RuntimeScene) {\n runtimeScene\n .getScene()\n .requestChange(gdjs.SceneChangeRequest.STOP_GAME);\n };\n\n export const createObjectsFromExternalLayout = function (\n scene: gdjs.RuntimeInstanceContainer,\n externalLayout: string,\n xPos: float,\n yPos: float,\n zPos: float\n ) {\n const externalLayoutData = scene\n .getGame()\n .getExternalLayoutData(externalLayout);\n if (externalLayoutData === null) {\n return;\n }\n\n // trackByPersistentUuid is set to false as we don't want external layouts\n // instantiated at runtime to be hot-reloaded.\n scene.getScene().createObjectsFrom(\n externalLayoutData.instances,\n xPos,\n yPos,\n /**\n * When 3D was introduced, zPos argument was added to the signature.\n * Existing calls (in JS events) to createObjectsFromExternalLayout will\n * have zPos undefined. So it is set to 0 in that case.\n */\n zPos || 0,\n /*trackByPersistentUuid=*/\n false\n );\n };\n\n /**\n * Check if the game has just resumed from being hidden\n */\n export const hasGameJustResumed = (\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): boolean => {\n return instanceContainer.getGame().hasJustResumed();\n };\n\n /**\n * Check if a scene exists.\n */\n export const doesSceneExist = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): boolean => {\n return runtimeScene.getGame().hasScene(sceneName);\n };\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n export const prioritizeLoadingOfScene = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): void => {\n runtimeScene.getGame().prioritizeLoadingOfScene(sceneName);\n };\n\n /**\n * @return The progress of assets loading in background for a scene (between 0 and 1).\n */\n export const getSceneLoadingProgress = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): float => {\n return runtimeScene.getGame().getSceneLoadingProgress(sceneName);\n };\n\n /**\n * Check if scene assets have finished to load in background.\n */\n export const areSceneAssetsLoaded = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string\n ): boolean => {\n return runtimeScene.getGame().areSceneAssetsLoaded(sceneName);\n };\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CACE,AAAM,kBAAkB,SAC7B,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,gBAGrC,mBAAmB,SAC9B,EACA,CACA,MAAO,GAAa,WAAW,oBAGpB,eAAe,SAAU,EAAiC,CACrE,MAAO,GAAa,WAAW,WAGpB,qBAAqB,SAChC,EACA,EACA,CACA,KAAM,GAAQ,EAAK,mBAAmB,GACtC,EACG,WACA,mBAAmB,EAAM,GAAI,EAAM,GAAI,EAAM,KAGrC,0BAA0B,SACrC,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,iBAAmB,KAGxD,eAAe,SAC1B,EACA,EACA,CACA,MAAO,GAAa,WAAW,iBAAiB,aAAa,IAGlD,eAAe,SAAU,EAAiC,CACrE,MAAO,GAAa,WAAW,iBAAiB,gBAarC,mBAAmB,SAC9B,EACA,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,MAAK,GAAY,SAAS,GAKxB,EAAY,SAAS,GAAW,UAAY,KAAQ,EAJpD,GAAY,SAAS,GACd,KAOE,cAAc,SACzB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,MAAK,GAAY,SAAS,GAGnB,EAAY,SAAS,GAAW,WAF9B,IAKE,aAAa,SACxB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,AAAK,EAAY,SAAS,GAGxB,EAAY,SAAS,GAAW,QAFhC,EAAY,SAAS,IAMZ,aAAa,SACxB,EACA,EACA,CACA,KAAM,GAAc,EAAa,WAAW,iBAC5C,AAAK,EAAY,SAAS,IACxB,EAAY,SAAS,GAEvB,EAAY,SAAS,GAA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OAClB,MAAO,GAAI,SACN,GAAI,IAAS,OAAQ,CAC1B,KAAM,GAAQ,GAAI,MAAK,EAAI,cAAe,EAAG,GACvC,EAAO,EAAI,UAAY,EAAM,UAC7B,EAAS,IAAO,GAAK,GAAK,GAChC,MAAO,MAAK,MAAM,EAAO,GAE3B,MAAO,IAGI,eAAe,SAC1B,EACA,EACA,EACA,CACA,AAAI,CAAC,EAAa,UAAU,0BAA0B,IAGtD,EACG,WACA,cACC,EACI,EAAK,mBAAmB,aACxB,EAAK,mBAAmB,cAC5B,IAIO,YAAY,SACvB,EACA,EACA,CACA,AAAI,CAAC,EAAa,UAAU,0BAA0B,IAGtD,EACG,WACA,cAAc,EAAK,mBAAmB,WAAY,IAG1C,WAAW,SAAU,EAAiC,CACjE,EACG,WACA,cAAc,EAAK,mBAAmB,YAG9B,WAAW,SAAU,EAAiC,CACjE,EACG,WACA,cAAc,EAAK,mBAAmB,YAG9B,kCAAkC,SAC7C,EACA,EACA,EACA,EACA,EACA,CACA,KAAM,GAAqB,EACxB,UACA,sBAAsB,GACzB,AAAI,IAAuB,MAM3B,EAAM,WAAW,kBACf,EAAmB,UACnB,EACA,EAMA,GAAQ,EAER,KAOS,qBAAqB,AAChC,GAEO,EAAkB,UAAU,iBAMxB,iBAAiB,CAC5B,EACA,IAEO,EAAa,UAAU,SAAS,GAM5B,2BAA2B,CACtC,EACA,IACS,CACT,EAAa,UAAU,yBAAyB,IAMrC,0BAA0B,CACrC,EACA,IAEO,EAAa,UAAU,wBAAwB,GAM3C,uBAAuB,CAClC,EACA,IAEO,EAAa,UAAU,qBAAqB,KAnWtC,yCADF,iCADT",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(t){const i=new t.Logger("Engine runtime"),l=/^(#{0,1}[A-Fa-f0-9]{6})$/,s=/^(#{0,1}[A-Fa-f0-9]{3})$/;let b;(function(n){const e=!0})(b=t.evtTools||(t.evtTools={})),t.objectsTypes=new Hashtable,t.behaviorsTypes=new Hashtable,t.callbacksFirstRuntimeSceneLoaded=[],t.callbacksRuntimeSceneLoaded=[],t.callbacksRuntimeScenePreEvents=[],t.callbacksRuntimeScenePostEvents=[],t.callbacksRuntimeScenePaused=[],t.callbacksRuntimeSceneResumed=[],t.callbacksRuntimeSceneUnloading=[],t.callbacksRuntimeSceneUnloaded=[],t.callbacksObjectDeletedFromScene=[],t.gdevelopLogo="",t.rgbToHex=function(e,n,r){return""+((1<<24)+(e<<16)+(n<<8)+r).toString(16).slice(1)},t.hexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[n>>16&255,n>>8&255,n&255]:[0,0,0]},t.shorthandHexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[17*(n>>8&15),17*(n>>4&15),17*(n&15)]:[0,0,0]},t.rgbOrHexToRGBColor=function(e){if(!e.startsWith("#")){const o=e.split(";");if(o.length===3)return[Math.min(255,parseInt(o[0],10)),Math.min(255,parseInt(o[1],10)),Math.min(255,parseInt(o[2],10))]}const n=t.extractHexString(e);if(n)return t.hexToRGBColor(n);const r=t.extractShorthandHexString(e);return r?t.shorthandHexToRGBColor(r):[0,0,0]},t.rgbOrHexStringToNumber=e=>{const n=t.rgbOrHexToRGBColor(e);return t.rgbToHexNumber(n[0],n[1],n[2])},t.rgbToHexNumber=function(e,n,r){return(Math.round(e)<<16)+(Math.round(n)<<8)+Math.round(r)},t.hexNumberToRGB=e=>({r:e>>16&255,g:e>>8&255,b:e&255,a:255}),t.hexNumberToRGBArray=e=>[e>>16&255,e>>8&255,e&255],t.extractHexString=e=>{const n=e.match(l);return n?n[0]:null},t.extractShorthandHexString=e=>{const n=e.match(s);return n?n[0]:null},t.random=function(e){return e<=0?0:Math.floor(Math.random()*(e+1))},t.randomInRange=function(e,n){return e+t.random(n-e)},t.randomFloat=function(e){return e<=0?0:Math.random()*e},t.randomFloatInRange=function(e,n){return e+t.randomFloat(n-e)},t.randomWithStep=function(e,n,r){return r<=0?e+t.random(n-e):e+t.random(Math.floor((n-e)/r))*r},t.toRad=function(e){return e/180*Math.PI},t.toDegrees=function(e){return e*180/Math.PI},t.registerObject=function(e,n){t.objectsTypes.put(e,n)},t.registerBehavior=function(e,n){t.behaviorsTypes.put(e,n)},t.registerFirstRuntimeSceneLoadedCallback=function(e){t.callbacksFirstRuntimeSceneLoaded.push(e)},t.registerRuntimeSceneLoadedCallback=function(e){t.callbacksRuntimeSceneLoaded.push(e)},t.registerRuntimeScenePreEventsCallback=function(e){t.callbacksRuntimeScenePreEvents.push(e)},t.registerRuntimeScenePostEventsCallback=function(e){t.callbacksRuntimeScenePostEvents.push(e)},t.registerRuntimeScenePausedCallback=function(e){t.callbacksRuntimeScenePaused.push(e)},t.registerRuntimeSceneResumedCallback=function(e){t.callbacksRuntimeSceneResumed.push(e)},t.registerRuntimeSceneUnloadingCallback=function(e){t.callbacksRuntimeSceneUnloading.push(e)},t.registerRuntimeSceneUnloadedCallback=function(e){t.callbacksRuntimeSceneUnloaded.push(e)},t.registerObjectDeletedFromSceneCallback=function(e){t.callbacksObjectDeletedFromScene.push(e)},t._unregisterCallback=function(e){const n=r=>{for(let o=0;o<r.length;)r[o]===e?r.splice(o,1):o++};n(t.callbacksFirstRuntimeSceneLoaded),n(t.callbacksRuntimeSceneLoaded),n(t.callbacksRuntimeScenePreEvents),n(t.callbacksRuntimeScenePostEvents),n(t.callbacksRuntimeScenePaused),n(t.callbacksRuntimeSceneResumed),n(t.callbacksRuntimeSceneUnloading),n(t.callbacksRuntimeSceneUnloaded),n(t.callbacksObjectDeletedFromScene)},t.registerGlobalCallbacks=function(){i.warn("You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.")},t.getObjectConstructor=function(e){return e!==void 0&&t.objectsTypes.containsKey(e)?t.objectsTypes.get(e):(i.warn('Object type "'+e+'" was not found.'),t.objectsTypes.get(""))},t.getBehaviorConstructor=function(e){return e!==void 0&&t.behaviorsTypes.containsKey(e)?t.behaviorsTypes.get(e):(i.warn('Behavior type "'+e+'" was not found.'),t.behaviorsTypes.get(""))},t.staticArray=function(e){return e._staticArray=e._staticArray||[],e._staticArray},t.staticArray2=function(e){return e._staticArray2=e._staticArray2||[],e._staticArray2},t.staticObject=function(e){return e._staticObject=e._staticObject||{},e._staticObject},t.objectsListsToArray=function(e){var n=t.staticArray(t.objectsListsToArray);e.values(n);for(var r=[],o=0;o<n.length;++o)for(var a=n[o],c=0;c<a.length;++c)r.push(a[c]);return r},t.copyArray=function(e,n){for(var r=e.length,o=0;o<r;++o)n[o]=e[o];n.length=r},t.makeUuid=function(){if(typeof crypto=="undefined"||!crypto.getRandomValues){const o=a=>a?(a^Math.random()*16>>a/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o);return o()}if(!t.makeUuid.hex){t.makeUuid.hex=[];for(var e=0;e<256;e++)t.makeUuid.hex[e]=(e<16?"0":"")+e.toString(16)}const n=t.makeUuid.hex;var r=crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},t.nearlyEqual=(e,n,r)=>{const o=Math.abs(e),a=Math.abs(n),c=Math.abs(e-n);return e===n?!0:e==0||n==0||o+a<Number.EPSILON?c<r*Number.EPSILON:c/Math.min(o+a,Number.MAX_VALUE)<r};const u=[];t.registerAsynchronouslyLoadingLibraryPromise=e=>{u.push(e)},t.getAllAsynchronouslyLoadingLibraryPromise=()=>Promise.all(u)})(gdjs||(gdjs={})),console.warn=console.warn||console.log,console.error=console.error||console.log;
1
+ var gdjs;(function(t){const i=new t.Logger("Engine runtime"),l=/^(#{0,1}[A-Fa-f0-9]{6})$/,s=/^(#{0,1}[A-Fa-f0-9]{3})$/;let m;(function(n){const e=!0})(m=t.evtTools||(t.evtTools={})),t.objectsTypes=new Hashtable,t.behaviorsTypes=new Hashtable,t.callbacksFirstRuntimeSceneLoaded=[],t.callbacksRuntimeSceneLoaded=[],t.callbacksRuntimeScenePreEvents=[],t.callbacksRuntimeScenePostEvents=[],t.callbacksRuntimeScenePaused=[],t.callbacksRuntimeSceneResumed=[],t.callbacksRuntimeSceneUnloading=[],t.callbacksRuntimeSceneUnloaded=[],t.callbacksObjectDeletedFromScene=[],t.callbacksRuntimeSceneGetSyncData=[],t.callbacksRuntimeSceneUpdateFromSyncData=[],t.gdevelopLogo="",t.rgbToHex=function(e,n,r){return""+((1<<24)+(e<<16)+(n<<8)+r).toString(16).slice(1)},t.hexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[n>>16&255,n>>8&255,n&255]:[0,0,0]},t.shorthandHexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[17*(n>>8&15),17*(n>>4&15),17*(n&15)]:[0,0,0]},t.rgbOrHexToRGBColor=function(e){if(!e.startsWith("#")){const o=e.split(";");if(o.length===3)return[Math.min(255,parseInt(o[0],10)),Math.min(255,parseInt(o[1],10)),Math.min(255,parseInt(o[2],10))]}const n=t.extractHexString(e);if(n)return t.hexToRGBColor(n);const r=t.extractShorthandHexString(e);return r?t.shorthandHexToRGBColor(r):[0,0,0]},t.rgbOrHexStringToNumber=e=>{const n=t.rgbOrHexToRGBColor(e);return t.rgbToHexNumber(n[0],n[1],n[2])},t.rgbToHexNumber=function(e,n,r){return(Math.round(e)<<16)+(Math.round(n)<<8)+Math.round(r)},t.hexNumberToRGB=e=>({r:e>>16&255,g:e>>8&255,b:e&255,a:255}),t.hexNumberToRGBArray=e=>[e>>16&255,e>>8&255,e&255],t.extractHexString=e=>{const n=e.match(l);return n?n[0]:null},t.extractShorthandHexString=e=>{const n=e.match(s);return n?n[0]:null},t.random=function(e){return e<=0?0:Math.floor(Math.random()*(e+1))},t.randomInRange=function(e,n){return e+t.random(n-e)},t.randomFloat=function(e){return e<=0?0:Math.random()*e},t.randomFloatInRange=function(e,n){return e+t.randomFloat(n-e)},t.randomWithStep=function(e,n,r){return r<=0?e+t.random(n-e):e+t.random(Math.floor((n-e)/r))*r},t.toRad=function(e){return e/180*Math.PI},t.toDegrees=function(e){return e*180/Math.PI},t.registerObject=function(e,n){t.objectsTypes.put(e,n)},t.registerBehavior=function(e,n){t.behaviorsTypes.put(e,n)},t.registerFirstRuntimeSceneLoadedCallback=function(e){t.callbacksFirstRuntimeSceneLoaded.push(e)},t.registerRuntimeSceneLoadedCallback=function(e){t.callbacksRuntimeSceneLoaded.push(e)},t.registerRuntimeScenePreEventsCallback=function(e){t.callbacksRuntimeScenePreEvents.push(e)},t.registerRuntimeScenePostEventsCallback=function(e){t.callbacksRuntimeScenePostEvents.push(e)},t.registerRuntimeScenePausedCallback=function(e){t.callbacksRuntimeScenePaused.push(e)},t.registerRuntimeSceneResumedCallback=function(e){t.callbacksRuntimeSceneResumed.push(e)},t.registerRuntimeSceneUnloadingCallback=function(e){t.callbacksRuntimeSceneUnloading.push(e)},t.registerRuntimeSceneUnloadedCallback=function(e){t.callbacksRuntimeSceneUnloaded.push(e)},t.registerObjectDeletedFromSceneCallback=function(e){t.callbacksObjectDeletedFromScene.push(e)},t.registerRuntimeSceneGetSyncDataCallback=function(e){t.callbacksRuntimeSceneGetSyncData.push(e)},t.registerRuntimeSceneUpdateFromSyncDataCallback=function(e){t.callbacksRuntimeSceneUpdateFromSyncData.push(e)},t._unregisterCallback=function(e){const n=r=>{for(let o=0;o<r.length;)r[o]===e?r.splice(o,1):o++};n(t.callbacksFirstRuntimeSceneLoaded),n(t.callbacksRuntimeSceneLoaded),n(t.callbacksRuntimeScenePreEvents),n(t.callbacksRuntimeScenePostEvents),n(t.callbacksRuntimeScenePaused),n(t.callbacksRuntimeSceneResumed),n(t.callbacksRuntimeSceneUnloading),n(t.callbacksRuntimeSceneUnloaded),n(t.callbacksObjectDeletedFromScene)},t.registerGlobalCallbacks=function(){i.warn("You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.")},t.getObjectConstructor=function(e){return e!==void 0&&t.objectsTypes.containsKey(e)?t.objectsTypes.get(e):(i.warn('Object type "'+e+'" was not found.'),t.objectsTypes.get(""))},t.getBehaviorConstructor=function(e){return e!==void 0&&t.behaviorsTypes.containsKey(e)?t.behaviorsTypes.get(e):(i.warn('Behavior type "'+e+'" was not found.'),t.behaviorsTypes.get(""))},t.staticArray=function(e){return e._staticArray=e._staticArray||[],e._staticArray},t.staticArray2=function(e){return e._staticArray2=e._staticArray2||[],e._staticArray2},t.staticObject=function(e){return e._staticObject=e._staticObject||{},e._staticObject},t.objectsListsToArray=function(e){var n=t.staticArray(t.objectsListsToArray);e.values(n);for(var r=[],o=0;o<n.length;++o)for(var a=n[o],c=0;c<a.length;++c)r.push(a[c]);return r},t.copyArray=function(e,n){for(var r=e.length,o=0;o<r;++o)n[o]=e[o];n.length=r},t.makeUuid=function(){if(typeof crypto=="undefined"||!crypto.getRandomValues){const o=a=>a?(a^Math.random()*16>>a/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o);return o()}if(!t.makeUuid.hex){t.makeUuid.hex=[];for(var e=0;e<256;e++)t.makeUuid.hex[e]=(e<16?"0":"")+e.toString(16)}const n=t.makeUuid.hex;var r=crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},t.nearlyEqual=(e,n,r)=>{const o=Math.abs(e),a=Math.abs(n),c=Math.abs(e-n);return e===n?!0:e==0||n==0||o+a<Number.EPSILON?c<r*Number.EPSILON:c/Math.min(o+a,Number.MAX_VALUE)<r};const u=[];t.registerAsynchronouslyLoadingLibraryPromise=e=>{u.push(e)},t.getAllAsynchronouslyLoadingLibraryPromise=()=>Promise.all(u)})(gdjs||(gdjs={})),console.warn=console.warn||console.log,console.error=console.error||console.log;
2
2
  //# sourceMappingURL=gd.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/gd.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 */\n\n/**\n * The `gdjs` namespace contains all classes and objects of the game engine.\n * @namespace gdjs\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Engine runtime');\n const hexStringRegex = /^(#{0,1}[A-Fa-f0-9]{6})$/;\n const shorthandHexStringRegex = /^(#{0,1}[A-Fa-f0-9]{3})$/;\n\n /**\n * Contains functions used by events (this is a convention only, functions can actually\n * be anywhere).\n * @namespace\n * @memberOf gdjs\n */\n export namespace evtTools {\n // @ts-ignore - This variable is unused on purpose.\n const thisIsUnusedButEnsureTheNamespaceIsDeclared = true;\n }\n\n export const objectsTypes = new Hashtable<typeof gdjs.RuntimeObject>();\n export const behaviorsTypes = new Hashtable<typeof gdjs.RuntimeBehavior>();\n\n type RuntimeSceneCallback = (runtimeScene: gdjs.RuntimeScene) => void;\n type RuntimeSceneRuntimeObjectCallback = (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n runtimeObject: gdjs.RuntimeObject\n ) => void;\n\n export const callbacksFirstRuntimeSceneLoaded: Array<RuntimeSceneCallback> =\n [];\n export const callbacksRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePreEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePostEvents: Array<RuntimeSceneCallback> =\n [];\n export const callbacksRuntimeScenePaused: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneResumed: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloading: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloaded: Array<RuntimeSceneCallback> = [];\n export const callbacksObjectDeletedFromScene: Array<RuntimeSceneRuntimeObjectCallback> =\n [];\n\n /** Base64 encoded logo of GDevelop for the splash screen. */\n export let gdevelopLogo: string = '';\n\n /**\n * Convert a RGB object to a Hex string.\n *\n * No \"#\" or \"0x\" are added.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHex = function (\n r: integer,\n g: integer,\n b: integer\n ): string {\n return '' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n };\n\n /**\n * Convert a Hex string (#124FE4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const hexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [(hexNumber >> 16) & 0xff, (hexNumber >> 8) & 0xff, hexNumber & 0xff]\n : [0, 0, 0];\n };\n\n /**\n * Convert a shorthand Hex string (#1F4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const shorthandHexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [\n 17 * ((hexNumber >> 8) & 0xf),\n 17 * ((hexNumber >> 4) & 0xf),\n 17 * (hexNumber & 0xf),\n ]\n : [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color array ([r,g,b] with each component going from 0 to 255).\n * @param value The color as a RGB string or Hex string\n */\n export const rgbOrHexToRGBColor = function (\n value: string\n ): [number, number, number] {\n // TODO Add a `result` parameter to allow to reuse the returned array.\n if (!value.startsWith('#')) {\n const splitValue = value.split(';');\n // If a RGB string is provided, return the RGB object.\n if (splitValue.length === 3) {\n return [\n Math.min(255, parseInt(splitValue[0], 10)),\n Math.min(255, parseInt(splitValue[1], 10)),\n Math.min(255, parseInt(splitValue[2], 10)),\n ];\n }\n }\n\n const hexColor = extractHexString(value);\n if (hexColor) {\n return hexToRGBColor(hexColor);\n }\n const shorthandHexColor = extractShorthandHexString(value);\n if (shorthandHexColor) {\n return shorthandHexToRGBColor(shorthandHexColor);\n }\n return [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color number.\n * @param rgbOrHexString The color as a RGB string or Hex string\n */\n export const rgbOrHexStringToNumber = (rgbOrHexString: string): integer => {\n const components = gdjs.rgbOrHexToRGBColor(rgbOrHexString);\n return gdjs.rgbToHexNumber(components[0], components[1], components[2]);\n };\n\n /**\n * Convert a RGB object to a Hex number.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHexNumber = function (\n r: float,\n g: float,\n b: float\n ): integer {\n return (Math.round(r) << 16) + (Math.round(g) << 8) + Math.round(b);\n };\n\n /**\n * Convert a Hex number to a RGB color object ({r,g,b,a} with each component going from 0 to 255 and alpha set to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGB = (\n hexNumber: number\n ): { r: integer; g: integer; b: integer; a: integer } => {\n return {\n r: (hexNumber >> 16) & 0xff,\n g: (hexNumber >> 8) & 0xff,\n b: hexNumber & 0xff,\n a: 255,\n };\n };\n\n /**\n * Convert a Hex number to a RGB color array([r,g,b] with each component going from 0 to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGBArray = (\n hexNumber: number\n ): [integer, integer, integer] => {\n return [\n (hexNumber >> 16) & 0xff,\n (hexNumber >> 8) & 0xff,\n hexNumber & 0xff,\n ];\n };\n\n export const extractHexString = (str: string): string | null => {\n const matches = str.match(hexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n export const extractShorthandHexString = (str: string): string | null => {\n const matches = str.match(shorthandHexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n\n /**\n * Get a random integer between 0 and max.\n * @param max The maximum value (inclusive).\n */\n export const random = function (max: float): float {\n if (max <= 0) return 0;\n return Math.floor(Math.random() * (max + 1));\n };\n\n /**\n * Get a random integer between min and max.\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n\n */\n export const randomInRange = function (min: float, max: float): float {\n return min + gdjs.random(max - min); // return min if min >= max\n };\n\n /**\n * Get a random float in the range 0 to less than max (inclusive of 0, but not max).\n * @param max The maximum value (exclusive).\n */\n export const randomFloat = function (max: float): float {\n if (max <= 0) return 0;\n return Math.random() * max;\n };\n\n /**\n * Get a random float between min and max\n * @param min The minimum value (inclusive).\n * @param max The maximum value (exclusive).\n * @returns {number}\n */\n export const randomFloatInRange = function (min: float, max: float): float {\n return min + gdjs.randomFloat(max - min); // return min if min >= max\n };\n\n /**\n * Get a random number between min and max in steps\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @param step The interval between each value.\n * @returns {number}\n */\n export const randomWithStep = function (\n min: float,\n max: float,\n step: float\n ): float {\n if (step <= 0) return min + gdjs.random(max - min);\n return min + gdjs.random(Math.floor((max - min) / step)) * step; // return min if min >= max\n };\n\n /**\n * Convert an angle in degrees to radians.\n * @param angleInDegrees The angle in degrees.\n */\n export const toRad = function (angleInDegrees: float): float {\n return (angleInDegrees / 180) * Math.PI;\n };\n\n /**\n * Convert an angle in radians to degrees.\n * @param angleInRadians The angle in radians.\n */\n export const toDegrees = function (angleInRadians: float): float {\n return (angleInRadians * 180) / Math.PI;\n };\n\n /**\n * Register a runtime object (class extending {@link gdjs.RuntimeObject}) that can be used in a scene.\n *\n * The name of the type of the object must be complete, with the namespace if any. For\n * example, if you are providing a Text object in the TextObject extension, the full name\n * of the type of the object is \"TextObject::Text\".\n *\n * @param objectTypeName The name of the type of the Object.\n * @param Ctor The constructor of the Object.\n */\n export const registerObject = function (\n objectTypeName: string,\n Ctor: typeof gdjs.RuntimeObject\n ): void {\n gdjs.objectsTypes.put(objectTypeName, Ctor);\n };\n\n /**\n * Register a runtime behavior (class extending {@link gdjs.RuntimeBehavior}) that can be used by a\n * {@link gdjs.RuntimeObject}.\n *\n * The type of the behavior must be complete, with the namespace of the extension. For\n * example, if you are providing a Draggable behavior in the DraggableBehavior extension,\n * the full name of the type of the behavior is \"DraggableBehavior::Draggable\".\n *\n * @param behaviorTypeName The name of the type of the behavior.\n * @param Ctor The constructor of the Object.\n */\n export const registerBehavior = function (\n behaviorTypeName: string,\n Ctor: typeof gdjs.RuntimeBehavior\n ): void {\n gdjs.behaviorsTypes.put(behaviorTypeName, Ctor);\n };\n\n /**\n * Register a function to be called when the first {@link gdjs.RuntimeScene} is loaded, after\n * resources loading is done. This can be considered as the \"start of the game\".\n *\n * @param callback The function to be called.\n */\n export const registerFirstRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksFirstRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is loaded.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * before events are run.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePreEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePreEvents.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * after events are run and before rendering.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePostEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePostEvents.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is paused.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePausedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePaused.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is resumed.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneResumedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneResumed.push(callback);\n };\n\n /**\n * Register a function to be called when a scene unload started. This is\n * before the object deletion and renderer destruction. It is safe to\n * manipulate these. It is **not** safe to release resources as other\n * callbacks might do operations on objects or the scene.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadingCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloading.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is unloaded. The objects\n * and renderer are now destroyed - it is **not** safe to do anything apart\n * from releasing resources.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloaded.push(callback);\n };\n\n /**\n * Register a function to be called when an object is deleted from a scene.\n * @param callback The function to be called.\n */\n export const registerObjectDeletedFromSceneCallback = function (\n callback: RuntimeSceneRuntimeObjectCallback\n ): void {\n gdjs.callbacksObjectDeletedFromScene.push(callback);\n };\n\n /**\n * Unregister a callback.\n * This should not be used apart from the code generated from extensions\n * events functions, to handle hot-reloading.\n * In any other case, a callback should be registered once, and only once.\n *\n * @internal\n */\n export const _unregisterCallback = function (callback: unknown): void {\n const filterArrayInPlace = (array: unknown[]) => {\n for (let i = 0; i < array.length; ) {\n if (array[i] === callback) {\n array.splice(i, 1);\n } else {\n i++;\n }\n }\n };\n\n filterArrayInPlace(callbacksFirstRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeScenePreEvents);\n filterArrayInPlace(callbacksRuntimeScenePostEvents);\n filterArrayInPlace(callbacksRuntimeScenePaused);\n filterArrayInPlace(callbacksRuntimeSceneResumed);\n filterArrayInPlace(callbacksRuntimeSceneUnloading);\n filterArrayInPlace(callbacksRuntimeSceneUnloaded);\n filterArrayInPlace(callbacksObjectDeletedFromScene);\n };\n\n /**\n * Keep this function until we're sure now client is using it anymore.\n * @deprecated\n * @private\n */\n export const registerGlobalCallbacks = function (): void {\n logger.warn(\n \"You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.\"\n );\n };\n\n /**\n * Get the constructor of an object.\n *\n * @param name The name of the type of the object.\n */\n export const getObjectConstructor = function (\n name: string\n ): typeof gdjs.RuntimeObject {\n if (name !== undefined && gdjs.objectsTypes.containsKey(name))\n return gdjs.objectsTypes.get(name);\n\n logger.warn('Object type \"' + name + '\" was not found.');\n return gdjs.objectsTypes.get(''); //Create a base empty runtime object.\n };\n\n /**\n * Get the constructor of a behavior.\n *\n * @param name The name of the type of the behavior.\n */\n export const getBehaviorConstructor = function (\n name: string\n ): typeof gdjs.RuntimeBehavior {\n if (name !== undefined && gdjs.behaviorsTypes.containsKey(name))\n return gdjs.behaviorsTypes.get(name);\n\n logger.warn('Behavior type \"' + name + '\" was not found.');\n return gdjs.behaviorsTypes.get(''); //Create a base empty runtime behavior.\n };\n\n /**\n * Create a static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray = function (owner: any): Array<any> {\n owner._staticArray = owner._staticArray || [];\n return owner._staticArray;\n };\n\n /**\n * Create a second static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray2 = function (owner: any): Array<any> {\n owner._staticArray2 = owner._staticArray2 || [];\n return owner._staticArray2;\n };\n\n /**\n * Create a static object that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticObject = function (owner: any): Object {\n owner._staticObject = owner._staticObject || {};\n return owner._staticObject;\n };\n\n /**\n * Return a new array of objects that is the concatenation of all the objects passed\n * as parameters.\n * @param objectsLists\n * @returns {Array}\n */\n export const objectsListsToArray = function (\n objectsLists: Hashtable<RuntimeObject>\n ): Array<RuntimeObject> {\n var lists = gdjs.staticArray(gdjs.objectsListsToArray);\n objectsLists.values(lists);\n\n var result: Array<RuntimeObject> = [];\n for (var i = 0; i < lists.length; ++i) {\n var arr = lists[i];\n for (var k = 0; k < arr.length; ++k) {\n result.push(arr[k]);\n }\n }\n return result;\n };\n\n /**\n * Copy the element for the first array into the second array, so that\n * both array contains the same elements.\n * @param src The source array\n * @param dst The destination array\n */\n export const copyArray = function <T>(src: Array<T>, dst: Array<T>): void {\n var len = src.length;\n for (var i = 0; i < len; ++i) {\n dst[i] = src[i];\n }\n dst.length = len;\n };\n\n interface MakeUUID {\n (): string;\n hex?: string[];\n }\n\n /**\n * Generate a UUID v4.\n * @returns The generated UUID.\n */\n export const makeUuid = <MakeUUID>function (): string {\n // Fallback to non cryptographically secure UUIDs if not supported\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n const makeMathRandomUuid = (a?: any): string => {\n return a\n ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)\n : ('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(\n /[018]/g,\n makeMathRandomUuid\n );\n };\n\n return makeMathRandomUuid();\n }\n\n if (!gdjs.makeUuid.hex) {\n gdjs.makeUuid.hex = [];\n\n for (var i = 0; i < 256; i++) {\n gdjs.makeUuid.hex[i] = (i < 16 ? '0' : '') + i.toString(16);\n }\n }\n const hex = gdjs.makeUuid.hex;\n\n var r = crypto.getRandomValues(new Uint8Array(16));\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return (\n hex[r[0]] +\n hex[r[1]] +\n hex[r[2]] +\n hex[r[3]] +\n '-' +\n hex[r[4]] +\n hex[r[5]] +\n '-' +\n hex[r[6]] +\n hex[r[7]] +\n '-' +\n hex[r[8]] +\n hex[r[9]] +\n '-' +\n hex[r[10]] +\n hex[r[11]] +\n hex[r[12]] +\n hex[r[13]] +\n hex[r[14]] +\n hex[r[15]]\n );\n };\n\n /**\n * See https://floating-point-gui.de/errors/comparison/\n * @param a\n * @param b\n * @param epsilon the relative margin error\n * @returns true when a and b are within a relative margin error.\n */\n export const nearlyEqual = (a: float, b: float, epsilon: float): boolean => {\n const absA = Math.abs(a);\n const absB = Math.abs(b);\n const diff = Math.abs(a - b);\n\n if (a === b) {\n // shortcut, handles infinities\n return true;\n } else if (a == 0 || b == 0 || absA + absB < Number.EPSILON) {\n // a or b is zero or both are extremely close to it\n // relative error is less meaningful here\n return diff < epsilon * Number.EPSILON;\n } else {\n // use relative error\n return diff / Math.min(absA + absB, Number.MAX_VALUE) < epsilon;\n }\n };\n\n const asynchronouslyLoadingLibraryPromises: Array<Promise<any>> = [];\n\n /**\n * Register a promise which will be resolved when a third party library has\n * finished loading (and is required to load before launching the game).\n *\n * This method must be called by any library that loads asynchronously.\n */\n export const registerAsynchronouslyLoadingLibraryPromise = (\n promise: Promise<any>\n ): void => {\n asynchronouslyLoadingLibraryPromises.push(promise);\n };\n\n /**\n * @returns a promise resolved when all all third party libraries, which need\n * to be loaded before the game startup, are loaded. If a library fails\n * loading, this will be rejected.\n */\n export const getAllAsynchronouslyLoadingLibraryPromise = (): Promise<\n any[]\n > => {\n return Promise.all(asynchronouslyLoadingLibraryPromises);\n };\n}\n\n// Make sure console.warn and console.error are available.\nconsole.warn = console.warn || console.log;\nconsole.error = console.error || console.log;\n"],
5
- "mappings": "AAUA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBACzB,EAAiB,2BACjB,EAA0B,2BAQzB,GAAU,GAAV,UAAU,EAAV,CAEL,KAAM,GAA8C,KAFrC,+BAKJ,eAAe,GAAI,WACnB,iBAAiB,GAAI,WAQrB,mCACX,GACW,8BAA2D,GAC3D,iCAA8D,GAC9D,kCACX,GACW,8BAA2D,GAC3D,+BAA4D,GAC5D,iCAA8D,GAC9D,gCAA6D,GAC7D,kCACX,GAGS,eAAuB,GAUrB,WAAW,SACtB,EACA,EACA,EACQ,CACR,MAAO,GAAO,KAAK,IAAO,IAAK,IAAO,IAAK,GAAK,GAAG,SAAS,IAAI,MAAM,IAQ3D,gBAA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A4nBV,QAAQ,KAAO,QAAQ,MAAQ,QAAQ,IACvC,QAAQ,MAAQ,QAAQ,OAAS,QAAQ",
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 */\n\n/**\n * The `gdjs` namespace contains all classes and objects of the game engine.\n * @namespace gdjs\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Engine runtime');\n const hexStringRegex = /^(#{0,1}[A-Fa-f0-9]{6})$/;\n const shorthandHexStringRegex = /^(#{0,1}[A-Fa-f0-9]{3})$/;\n\n /**\n * Contains functions used by events (this is a convention only, functions can actually\n * be anywhere).\n * @namespace\n * @memberOf gdjs\n */\n export namespace evtTools {\n // @ts-ignore - This variable is unused on purpose.\n const thisIsUnusedButEnsureTheNamespaceIsDeclared = true;\n }\n\n export const objectsTypes = new Hashtable<typeof gdjs.RuntimeObject>();\n export const behaviorsTypes = new Hashtable<typeof gdjs.RuntimeBehavior>();\n\n type RuntimeSceneCallback = (runtimeScene: gdjs.RuntimeScene) => void;\n type RuntimeSceneRuntimeObjectCallback = (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n runtimeObject: gdjs.RuntimeObject\n ) => void;\n type RuntimeSceneGetSyncDataCallback = (\n runtimeScene: gdjs.RuntimeScene,\n currentSyncData: LayoutNetworkSyncData,\n syncOptions: GetNetworkSyncDataOptions\n ) => void;\n type RuntimeSceneUpdateFromSyncData = (\n runtimeScene: gdjs.RuntimeScene,\n receivedSyncData: LayoutNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ) => void;\n\n export const callbacksFirstRuntimeSceneLoaded: Array<RuntimeSceneCallback> =\n [];\n export const callbacksRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePreEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePostEvents: Array<RuntimeSceneCallback> =\n [];\n export const callbacksRuntimeScenePaused: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneResumed: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloading: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloaded: Array<RuntimeSceneCallback> = [];\n export const callbacksObjectDeletedFromScene: Array<RuntimeSceneRuntimeObjectCallback> =\n [];\n export const callbacksRuntimeSceneGetSyncData: Array<RuntimeSceneGetSyncDataCallback> =\n [];\n export const callbacksRuntimeSceneUpdateFromSyncData: Array<RuntimeSceneUpdateFromSyncData> =\n [];\n\n /** Base64 encoded logo of GDevelop for the splash screen. */\n export let gdevelopLogo: string = '';\n\n /**\n * Convert a RGB object to a Hex string.\n *\n * No \"#\" or \"0x\" are added.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHex = function (\n r: integer,\n g: integer,\n b: integer\n ): string {\n return '' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n };\n\n /**\n * Convert a Hex string (#124FE4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const hexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [(hexNumber >> 16) & 0xff, (hexNumber >> 8) & 0xff, hexNumber & 0xff]\n : [0, 0, 0];\n };\n\n /**\n * Convert a shorthand Hex string (#1F4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const shorthandHexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [\n 17 * ((hexNumber >> 8) & 0xf),\n 17 * ((hexNumber >> 4) & 0xf),\n 17 * (hexNumber & 0xf),\n ]\n : [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color array ([r,g,b] with each component going from 0 to 255).\n * @param value The color as a RGB string or Hex string\n */\n export const rgbOrHexToRGBColor = function (\n value: string\n ): [number, number, number] {\n // TODO Add a `result` parameter to allow to reuse the returned array.\n if (!value.startsWith('#')) {\n const splitValue = value.split(';');\n // If a RGB string is provided, return the RGB object.\n if (splitValue.length === 3) {\n return [\n Math.min(255, parseInt(splitValue[0], 10)),\n Math.min(255, parseInt(splitValue[1], 10)),\n Math.min(255, parseInt(splitValue[2], 10)),\n ];\n }\n }\n\n const hexColor = extractHexString(value);\n if (hexColor) {\n return hexToRGBColor(hexColor);\n }\n const shorthandHexColor = extractShorthandHexString(value);\n if (shorthandHexColor) {\n return shorthandHexToRGBColor(shorthandHexColor);\n }\n return [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color number.\n * @param rgbOrHexString The color as a RGB string or Hex string\n */\n export const rgbOrHexStringToNumber = (rgbOrHexString: string): integer => {\n const components = gdjs.rgbOrHexToRGBColor(rgbOrHexString);\n return gdjs.rgbToHexNumber(components[0], components[1], components[2]);\n };\n\n /**\n * Convert a RGB object to a Hex number.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHexNumber = function (\n r: float,\n g: float,\n b: float\n ): integer {\n return (Math.round(r) << 16) + (Math.round(g) << 8) + Math.round(b);\n };\n\n /**\n * Convert a Hex number to a RGB color object ({r,g,b,a} with each component going from 0 to 255 and alpha set to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGB = (\n hexNumber: number\n ): { r: integer; g: integer; b: integer; a: integer } => {\n return {\n r: (hexNumber >> 16) & 0xff,\n g: (hexNumber >> 8) & 0xff,\n b: hexNumber & 0xff,\n a: 255,\n };\n };\n\n /**\n * Convert a Hex number to a RGB color array([r,g,b] with each component going from 0 to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGBArray = (\n hexNumber: number\n ): [integer, integer, integer] => {\n return [\n (hexNumber >> 16) & 0xff,\n (hexNumber >> 8) & 0xff,\n hexNumber & 0xff,\n ];\n };\n\n export const extractHexString = (str: string): string | null => {\n const matches = str.match(hexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n export const extractShorthandHexString = (str: string): string | null => {\n const matches = str.match(shorthandHexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n\n /**\n * Get a random integer between 0 and max.\n * @param max The maximum value (inclusive).\n */\n export const random = function (max: float): float {\n if (max <= 0) return 0;\n return Math.floor(Math.random() * (max + 1));\n };\n\n /**\n * Get a random integer between min and max.\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n\n */\n export const randomInRange = function (min: float, max: float): float {\n return min + gdjs.random(max - min); // return min if min >= max\n };\n\n /**\n * Get a random float in the range 0 to less than max (inclusive of 0, but not max).\n * @param max The maximum value (exclusive).\n */\n export const randomFloat = function (max: float): float {\n if (max <= 0) return 0;\n return Math.random() * max;\n };\n\n /**\n * Get a random float between min and max\n * @param min The minimum value (inclusive).\n * @param max The maximum value (exclusive).\n * @returns {number}\n */\n export const randomFloatInRange = function (min: float, max: float): float {\n return min + gdjs.randomFloat(max - min); // return min if min >= max\n };\n\n /**\n * Get a random number between min and max in steps\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @param step The interval between each value.\n * @returns {number}\n */\n export const randomWithStep = function (\n min: float,\n max: float,\n step: float\n ): float {\n if (step <= 0) return min + gdjs.random(max - min);\n return min + gdjs.random(Math.floor((max - min) / step)) * step; // return min if min >= max\n };\n\n /**\n * Convert an angle in degrees to radians.\n * @param angleInDegrees The angle in degrees.\n */\n export const toRad = function (angleInDegrees: float): float {\n return (angleInDegrees / 180) * Math.PI;\n };\n\n /**\n * Convert an angle in radians to degrees.\n * @param angleInRadians The angle in radians.\n */\n export const toDegrees = function (angleInRadians: float): float {\n return (angleInRadians * 180) / Math.PI;\n };\n\n /**\n * Register a runtime object (class extending {@link gdjs.RuntimeObject}) that can be used in a scene.\n *\n * The name of the type of the object must be complete, with the namespace if any. For\n * example, if you are providing a Text object in the TextObject extension, the full name\n * of the type of the object is \"TextObject::Text\".\n *\n * @param objectTypeName The name of the type of the Object.\n * @param Ctor The constructor of the Object.\n */\n export const registerObject = function (\n objectTypeName: string,\n Ctor: typeof gdjs.RuntimeObject\n ): void {\n gdjs.objectsTypes.put(objectTypeName, Ctor);\n };\n\n /**\n * Register a runtime behavior (class extending {@link gdjs.RuntimeBehavior}) that can be used by a\n * {@link gdjs.RuntimeObject}.\n *\n * The type of the behavior must be complete, with the namespace of the extension. For\n * example, if you are providing a Draggable behavior in the DraggableBehavior extension,\n * the full name of the type of the behavior is \"DraggableBehavior::Draggable\".\n *\n * @param behaviorTypeName The name of the type of the behavior.\n * @param Ctor The constructor of the Object.\n */\n export const registerBehavior = function (\n behaviorTypeName: string,\n Ctor: typeof gdjs.RuntimeBehavior\n ): void {\n gdjs.behaviorsTypes.put(behaviorTypeName, Ctor);\n };\n\n /**\n * Register a function to be called when the first {@link gdjs.RuntimeScene} is loaded, after\n * resources loading is done. This can be considered as the \"start of the game\".\n *\n * @param callback The function to be called.\n */\n export const registerFirstRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksFirstRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is loaded.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * before events are run.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePreEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePreEvents.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * after events are run and before rendering.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePostEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePostEvents.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is paused.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePausedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePaused.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is resumed.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneResumedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneResumed.push(callback);\n };\n\n /**\n * Register a function to be called when a scene unload started. This is\n * before the object deletion and renderer destruction. It is safe to\n * manipulate these. It is **not** safe to release resources as other\n * callbacks might do operations on objects or the scene.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadingCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloading.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is unloaded. The objects\n * and renderer are now destroyed - it is **not** safe to do anything apart\n * from releasing resources.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloaded.push(callback);\n };\n\n /**\n * Register a function to be called when an object is deleted from a scene.\n * @param callback The function to be called.\n */\n export const registerObjectDeletedFromSceneCallback = function (\n callback: RuntimeSceneRuntimeObjectCallback\n ): void {\n gdjs.callbacksObjectDeletedFromScene.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is getting its sync\n * data retrieved (via getNetworkSyncData).\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneGetSyncDataCallback = function (\n callback: RuntimeSceneGetSyncDataCallback\n ): void {\n gdjs.callbacksRuntimeSceneGetSyncData.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is getting its sync\n * data updated (via updateFromNetworkSyncData).\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUpdateFromSyncDataCallback = function (\n callback: RuntimeSceneUpdateFromSyncData\n ): void {\n gdjs.callbacksRuntimeSceneUpdateFromSyncData.push(callback);\n };\n\n /**\n * Unregister a callback.\n * This should not be used apart from the code generated from extensions\n * events functions, to handle hot-reloading.\n * In any other case, a callback should be registered once, and only once.\n *\n * @internal\n */\n export const _unregisterCallback = function (callback: unknown): void {\n const filterArrayInPlace = (array: unknown[]) => {\n for (let i = 0; i < array.length; ) {\n if (array[i] === callback) {\n array.splice(i, 1);\n } else {\n i++;\n }\n }\n };\n\n filterArrayInPlace(callbacksFirstRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeScenePreEvents);\n filterArrayInPlace(callbacksRuntimeScenePostEvents);\n filterArrayInPlace(callbacksRuntimeScenePaused);\n filterArrayInPlace(callbacksRuntimeSceneResumed);\n filterArrayInPlace(callbacksRuntimeSceneUnloading);\n filterArrayInPlace(callbacksRuntimeSceneUnloaded);\n filterArrayInPlace(callbacksObjectDeletedFromScene);\n };\n\n /**\n * Keep this function until we're sure now client is using it anymore.\n * @deprecated\n * @private\n */\n export const registerGlobalCallbacks = function (): void {\n logger.warn(\n \"You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.\"\n );\n };\n\n /**\n * Get the constructor of an object.\n *\n * @param name The name of the type of the object.\n */\n export const getObjectConstructor = function (\n name: string\n ): typeof gdjs.RuntimeObject {\n if (name !== undefined && gdjs.objectsTypes.containsKey(name))\n return gdjs.objectsTypes.get(name);\n\n logger.warn('Object type \"' + name + '\" was not found.');\n return gdjs.objectsTypes.get(''); //Create a base empty runtime object.\n };\n\n /**\n * Get the constructor of a behavior.\n *\n * @param name The name of the type of the behavior.\n */\n export const getBehaviorConstructor = function (\n name: string\n ): typeof gdjs.RuntimeBehavior {\n if (name !== undefined && gdjs.behaviorsTypes.containsKey(name))\n return gdjs.behaviorsTypes.get(name);\n\n logger.warn('Behavior type \"' + name + '\" was not found.');\n return gdjs.behaviorsTypes.get(''); //Create a base empty runtime behavior.\n };\n\n /**\n * Create a static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray = function (owner: any): Array<any> {\n owner._staticArray = owner._staticArray || [];\n return owner._staticArray;\n };\n\n /**\n * Create a second static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray2 = function (owner: any): Array<any> {\n owner._staticArray2 = owner._staticArray2 || [];\n return owner._staticArray2;\n };\n\n /**\n * Create a static object that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticObject = function (owner: any): Object {\n owner._staticObject = owner._staticObject || {};\n return owner._staticObject;\n };\n\n /**\n * Return a new array of objects that is the concatenation of all the objects passed\n * as parameters.\n * @param objectsLists\n * @returns {Array}\n */\n export const objectsListsToArray = function (\n objectsLists: Hashtable<RuntimeObject>\n ): Array<RuntimeObject> {\n var lists = gdjs.staticArray(gdjs.objectsListsToArray);\n objectsLists.values(lists);\n\n var result: Array<RuntimeObject> = [];\n for (var i = 0; i < lists.length; ++i) {\n var arr = lists[i];\n for (var k = 0; k < arr.length; ++k) {\n result.push(arr[k]);\n }\n }\n return result;\n };\n\n /**\n * Copy the element for the first array into the second array, so that\n * both array contains the same elements.\n * @param src The source array\n * @param dst The destination array\n */\n export const copyArray = function <T>(src: Array<T>, dst: Array<T>): void {\n var len = src.length;\n for (var i = 0; i < len; ++i) {\n dst[i] = src[i];\n }\n dst.length = len;\n };\n\n interface MakeUUID {\n (): string;\n hex?: string[];\n }\n\n /**\n * Generate a UUID v4.\n * @returns The generated UUID.\n */\n export const makeUuid = <MakeUUID>function (): string {\n // Fallback to non cryptographically secure UUIDs if not supported\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n const makeMathRandomUuid = (a?: any): string => {\n return a\n ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)\n : ('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(\n /[018]/g,\n makeMathRandomUuid\n );\n };\n\n return makeMathRandomUuid();\n }\n\n if (!gdjs.makeUuid.hex) {\n gdjs.makeUuid.hex = [];\n\n for (var i = 0; i < 256; i++) {\n gdjs.makeUuid.hex[i] = (i < 16 ? '0' : '') + i.toString(16);\n }\n }\n const hex = gdjs.makeUuid.hex;\n\n var r = crypto.getRandomValues(new Uint8Array(16));\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return (\n hex[r[0]] +\n hex[r[1]] +\n hex[r[2]] +\n hex[r[3]] +\n '-' +\n hex[r[4]] +\n hex[r[5]] +\n '-' +\n hex[r[6]] +\n hex[r[7]] +\n '-' +\n hex[r[8]] +\n hex[r[9]] +\n '-' +\n hex[r[10]] +\n hex[r[11]] +\n hex[r[12]] +\n hex[r[13]] +\n hex[r[14]] +\n hex[r[15]]\n );\n };\n\n /**\n * See https://floating-point-gui.de/errors/comparison/\n * @param a\n * @param b\n * @param epsilon the relative margin error\n * @returns true when a and b are within a relative margin error.\n */\n export const nearlyEqual = (a: float, b: float, epsilon: float): boolean => {\n const absA = Math.abs(a);\n const absB = Math.abs(b);\n const diff = Math.abs(a - b);\n\n if (a === b) {\n // shortcut, handles infinities\n return true;\n } else if (a == 0 || b == 0 || absA + absB < Number.EPSILON) {\n // a or b is zero or both are extremely close to it\n // relative error is less meaningful here\n return diff < epsilon * Number.EPSILON;\n } else {\n // use relative error\n return diff / Math.min(absA + absB, Number.MAX_VALUE) < epsilon;\n }\n };\n\n const asynchronouslyLoadingLibraryPromises: Array<Promise<any>> = [];\n\n /**\n * Register a promise which will be resolved when a third party library has\n * finished loading (and is required to load before launching the game).\n *\n * This method must be called by any library that loads asynchronously.\n */\n export const registerAsynchronouslyLoadingLibraryPromise = (\n promise: Promise<any>\n ): void => {\n asynchronouslyLoadingLibraryPromises.push(promise);\n };\n\n /**\n * @returns a promise resolved when all all third party libraries, which need\n * to be loaded before the game startup, are loaded. If a library fails\n * loading, this will be rejected.\n */\n export const getAllAsynchronouslyLoadingLibraryPromise = (): Promise<\n any[]\n > => {\n return Promise.all(asynchronouslyLoadingLibraryPromises);\n };\n}\n\n// Make sure console.warn and console.error are available.\nconsole.warn = console.warn || console.log;\nconsole.error = console.error || console.log;\n"],
5
+ "mappings": "AAUA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBACzB,EAAiB,2BACjB,EAA0B,2BAQzB,GAAU,GAAV,UAAU,EAAV,CAEL,KAAM,GAA8C,KAFrC,+BAKJ,eAAe,GAAI,WACnB,iBAAiB,GAAI,WAkBrB,mCACX,GACW,8BAA2D,GAC3D,iCAA8D,GAC9D,kCACX,GACW,8BAA2D,GAC3D,+BAA4D,GAC5D,iCAA8D,GAC9D,gCAA6D,GAC7D,kCACX,GACW,mCACX,GACW,0CACX,GAGS,eAAuB,GAUrB,WAAW,SACtB,EACA,EACA,EACQ,CACR,MAAO,GAAO,KAAK,IAAO,IAAK,IAAO,IAAK,GAAK,GAAG,SAAS,IAAI,MAAM,IAQ3D,gBAAgB,SAC3B,EAC0B,CAC1B,KAAM,GAAY,SAAS,EAAU,QAAQ,IAAK,IAAK,IACvD,MAAO,QAAO,SAAS,GACnB,CAAE,GAAa,GAAM,IAAO,GAAa,EAAK,IAAM,EAAY,KAChE,CAAC,EAAG,EAAG,IAQA,yBAAyB,SACpC,EAC0B,CAC1B,KAAM,GAAY,SAAS,EAAU,QAAQ,IAAK,IAAK,IACvD,MAAO,QAAO,SAAS,GACnB,CACE,GAAO,IAAa,EAAK,IACzB,GAAO,IAAa,EAAK,IACzB,GAAM,GAAY,KAEpB,CAAC,EAAG,EAAG,IAOA,qBAAqB,SAChC,EAC0B,CAE1B,GAAI,CAAC,EAAM,WAAW,KAAM,CAC1B,KAAM,GAAa,EAAM,MAAM,KAE/B,GAAI,EAAW,SAAW,EACxB,MAAO,CACL,KAAK,IAAI,IAAK,SAAS,EAAW,GAAI,KACtC,KAAK,IAAI,IAAK,SAAS,EAAW,GAAI,KACtC,KAAK,IAAI,IAAK,SAAS,EAAW,GAAI,MAK5C,KAAM,GAAW,mBAAiB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Q,IAGrB,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,MAWG,cAAc,CAAC,EAAU,EAAU,IAA4B,CAC1E,KAAM,GAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,EAAI,GAE1B,MAAI,KAAM,EAED,GACE,GAAK,GAAK,GAAK,GAAK,EAAO,EAAO,OAAO,QAG3C,EAAO,EAAU,OAAO,QAGxB,EAAO,KAAK,IAAI,EAAO,EAAM,OAAO,WAAa,GAI5D,KAAM,GAA4D,GAQ3D,AAAM,8CAA8C,AACzD,GACS,CACT,EAAqC,KAAK,IAQ/B,4CAA4C,IAGhD,QAAQ,IAAI,KA3pBb,iBAgqBV,QAAQ,KAAO,QAAQ,MAAQ,QAAQ,IACvC,QAAQ,MAAQ,QAAQ,OAAS,QAAQ",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
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 p{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=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(){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()}unloadResource(e){this._loadedMusics.get(e)&&this.unloadAudio(e.name,!0),this._loadedSounds.get(e)&&this.unloadAudio(e.name,!1)}}a.HowlerSoundManager=f,a.SoundManager=f})(gdjs||(gdjs={}));
1
+ var gdjs;(function(h){const d=new h.Logger("Audio manager"),f=["audio"],_={preload:!0,onplayerror:(l,e)=>d.error("Can't play an audio file: "+e),onloaderror:(l,e)=>d.error("Error while loading an audio file: "+e)},c=l=>l>1?1:l<0?0:l,u=(l,e)=>{if(l instanceof Error&&l.message&&typeof l.message=="string"&&l.message.startsWith("Maximum call stack size exceeded"))console.warn(`An error occurred when call method "${e}":`,l);else throw l};class S{constructor(e,t,s,i,a){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=c(t),this._loop=s,this._rate=i,this._audioResourceName=a}isLoaded(){return this._howl.state()==="loaded"}play(){try{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(h.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(t=>{this.on("play",t),t(e)}),this._oncePlay.forEach(t=>t(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play())}catch(e){u(e,"play")}return this}pause(){try{this._id!==null&&this._howl.pause(this._id)}catch(e){u(e,"pause")}return this}stop(){try{this._id!==null&&this._howl.stop(this._id)}catch(e){u(e,"stop")}return 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){try{this._rate=e,this._id!==null&&(e=h.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id))}catch(t){u(t,"rate")}return this}getLoop(){return this._loop}setLoop(e){try{this._loop=e,this._id!==null&&this._howl.loop(e,this._id)}catch(t){u(t,"loop")}return this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){try{this._initialVolume=c(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id)}catch(t){u(t,"volume")}return this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){try{this._id!==null&&this._howl.mute(e,this._id)}catch(t){u(t,"mute")}return this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){try{this._id!==null&&this._howl.seek(e,this._id)}catch(t){u(t,"seek")}return this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,t,s){return this._id!==null&&this._howl.pos(e,t,s,this._id),this}fade(e,t,s){try{this._id!==null&&this._howl.fade(c(e),c(t),s,this._id)}catch(i){u(i,"fade")}return this}on(e,t){return e==="play"?this._id===null?this._onPlay.push(t):this._howl.on(e,t,this._id):this._id===null?this.once("play",()=>this.on(e,t)):this._howl.on(e,t,this._id),this}once(e,t){return e==="play"?this._id===null?this._oncePlay.push(t):this.playing()?t(this._id):this._howl.once(e,t,this._id):this._id===null?this.once("play",()=>this.once(e,t)):this._howl.once(e,t,this._id),this}off(e,t){return this._id!==null&&this._howl.off(e,t,this._id),this}getNetworkSyncData(){if(this.paused()||!this.isLoaded()||this.stopped())return;const e=this.getSeek(),t=typeof e!="number"?0:e,s=this.isLoaded()?this.getVolume():this._initialVolume;return{resourceName:this._audioResourceName,loop:this._loop,volume:s,rate:this._rate,seek:t}}}h.HowlerSound=S;class p{constructor(e){this._loadedMusics=new h.ResourceCache;this._loadedSounds=new h.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 t=this._resourceLoader.getResource(e);return t&&this.getResourceKinds().includes(t.kind)?t:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e,h.registerRuntimeScenePostEventsCallback(this._clearCachedSpatialPosition.bind(this));const t=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){t.pauseAllActiveSounds()},!1),document.addEventListener("resume",function(){t.resumeAllActiveSounds()},!1)})}pauseAllActiveSounds(){const e=this._freeSounds.concat(this._freeMusics);for(let t in this._sounds)this._sounds.hasOwnProperty(t)&&e.push(this._sounds[t]);for(let t in this._musics)this._musics.hasOwnProperty(t)&&e.push(this._musics[t]);for(let t=0;t<e.length;t++){const s=e[t];!s.paused()&&!s.stopped()&&(s.pause(),this._pausedSounds.push(s))}this._paused=!0}resumeAllActiveSounds(){try{for(let e=0;e<this._pausedSounds.length;e++){const t=this._pausedSounds[e];t.stopped()||t.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 f}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,t){const s=e.file;return new Promise((i,a)=>{const o=t?this._loadedMusics:this._loadedSounds;o[s]=new Howl(Object.assign({},_,{src:this._getSoundUrlsFromResource(e),onload:i,onloaderror:(n,r)=>a(r),html5:t,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(s)},volume:0}))})}_storeSoundInArray(e,t){for(let s=0,i=e.length;s<i;++s)if(!e[s]||e[s].stopped())return e[s]=t,t;return e.push(t),t}createHowlerSound(e,t,s,i,a){const o=t?this._loadedMusics:this._loadedSounds,n=this._getAudioResource(e);let r=o.get(n);return r||(r=new Howl(Object.assign({src:this._getSoundUrlsFromResource(n),html5:t,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(n.file)},volume:0},_)),o.set(n,r)),new h.HowlerSound(r,s,i,a,e)}loadAudio(e,t){const s=t?this._loadedMusics:this._loadedSounds,i=this._getAudioResource(e);s.get(i)||s.set(i,new Howl(Object.assign({src:this._getSoundUrlsFromResource(i),html5:t,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(i.file)},volume:0},_)))}unloadAudio(e,t){const s=t?this._loadedMusics:this._loadedSounds,i=this._getAudioResource(e),a=s.get(i);if(!a)return;function o(n){for(let r in n)n[r]&&n[r]._howl===a&&(n[r].stop(),delete n[r])}o(this._freeMusics),o(this._freeSounds),o(Object.values(this._musics)),o(Object.values(this._sounds)),o(this._pausedSounds),a.unload(),s.delete(i)}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,t,s,i,a){const o=this.createHowlerSound(e,!1,s/100,t,i);this._storeSoundInArray(this._freeSounds,o),o.once("play",()=>{this._paused&&(o.pause(),this._pausedSounds.push(o))}),o.play(),a&&o.setSeek(a)}playSoundOnChannel(e,t,s,i,a,o){this._sounds[t]&&this._sounds[t].stop();const n=this.createHowlerSound(e,!1,i/100,s,a),r=this._cachedSpatialPosition[t];r&&n.once("play",()=>{n.setSpatialPosition(...r)}),this._sounds[t]=n,n.once("play",()=>{this._paused&&(n.pause(),this._pausedSounds.push(n))}),n.play(),o&&n.setSeek(o)}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,t,s,i,a){const o=this.createHowlerSound(e,!0,s/100,t,i);this._storeSoundInArray(this._freeMusics,o),o.once("play",()=>{this._paused&&(o.pause(),this._pausedSounds.push(o))}),o.play(),a&&o.setSeek(a)}playMusicOnChannel(e,t,s,i,a,o){this._musics[t]&&this._musics[t].stop();const n=this.createHowlerSound(e,!0,i/100,s,a);this._musics[t]=n,n.once("play",()=>{this._paused&&(n.pause(),this._pausedSounds.push(n))}),n.play(),o&&n.setSeek(o)}getMusicOnChannel(e){return this._musics[e]||null}setSoundSpatialPositionOnChannel(e,t,s,i){const a=this.getSoundOnChannel(e);a&&!a.paused()?a.setSpatialPosition(t,s,i):this._cachedSpatialPosition[e]=[t,s,i]}_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 t=this._resourceLoader.getResource(e);if(!t){d.warn('Unable to find audio for resource "'+e+'".');return}if(t.file){if(this._availableResources[t.name])return;this._availableResources[t.name]=t}if(t.preloadAsMusic)try{await this._preloadAudioFile(t,!0)}catch(s){d.warn("There was an error while preloading an audio file: "+s)}if(t.preloadAsSound)try{await this._preloadAudioFile(t,!1)}catch(s){d.warn("There was an error while preloading an audio file: "+s)}else if(t.preloadInCache||!t.preloadAsMusic)try{const s=t.file;await new Promise((i,a)=>{const o=new XMLHttpRequest;o.withCredentials=this._resourceLoader.checkIfCredentialsRequired(s),o.addEventListener("load",i),o.addEventListener("error",n=>a("XHR error: "+s)),o.addEventListener("abort",n=>a("XHR abort: "+s)),o.open("GET",this._getDefaultSoundUrl(t)),o.send()})}catch(s){d.warn("There was an error while preloading an audio file: "+s)}}getNetworkSyncData(){const e=[];this._freeMusics.forEach(a=>{const o=a.getNetworkSyncData();o&&e.push(o)});const t=[];this._freeSounds.forEach(a=>{const o=a.getNetworkSyncData();o&&t.push(o)});const s={};Object.entries(this._musics).forEach(([a,o])=>{const n=o.getNetworkSyncData();if(n){const r=parseInt(a,10);s[r]=n}});const i={};return Object.entries(this._sounds).forEach(([a,o])=>{const n=o.getNetworkSyncData();if(n){const r=parseInt(a,10);i[r]=n}}),{globalVolume:this._globalVolume,cachedSpatialPosition:this._cachedSpatialPosition,freeMusics:e,freeSounds:t,musics:s,sounds:i}}updateFromNetworkSyncData(e){this.clearAll(),this._globalVolume=e.globalVolume,this._cachedSpatialPosition=e.cachedSpatialPosition;for(let t=0;t<e.freeSounds.length;t++){const s=e.freeSounds[t];this.playSound(s.resourceName,s.loop,s.volume*100,s.rate,s.seek)}for(let t=0;t<e.freeMusics.length;t++){const s=e.freeMusics[t];this.playMusic(s.resourceName,s.loop,s.volume*100,s.rate,s.seek)}for(const[t,s]of Object.entries(e.sounds)){const i=parseInt(t,10);this.playSoundOnChannel(s.resourceName,i,s.loop,s.volume*100,s.rate,s.seek)}for(const[t,s]of Object.entries(e.musics)){const i=parseInt(t,10);this.playMusicOnChannel(s.resourceName,i,s.loop,s.volume*100,s.rate,s.seek)}}dispose(){this.unloadAll()}unloadResource(e){this._loadedMusics.get(e)&&this.unloadAudio(e.name,!0),this._loadedSounds.get(e)&&this.unloadAudio(e.name,!1)}}h.HowlerSoundManager=p,h.SoundManager=p})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=howler-sound-manager.js.map