gdcore-tools 2.0.0-gd-v5.5.242-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 (126) 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 +5 -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/BBText/bbtextruntimeobject.js +1 -1
  17. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  18. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  19. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  20. package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
  21. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  22. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  23. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
  24. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  25. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  26. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  27. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  28. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  29. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  30. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  31. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  32. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
  34. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  35. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  38. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  39. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  40. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  41. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  42. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  43. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  44. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  45. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
  46. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  47. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  48. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  49. package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
  50. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
  51. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
  52. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
  53. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
  54. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  55. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  56. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  57. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  58. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  59. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  60. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
  61. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  62. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  63. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  64. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  65. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  66. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  67. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  68. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  69. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  70. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  71. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  72. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  73. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
  74. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +2 -2
  75. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  76. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  77. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js +1 -1
  78. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
  79. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  80. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  81. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  82. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  83. package/dist/Runtime/RuntimeLayer.js +1 -1
  84. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  85. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  86. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  87. package/dist/Runtime/events-tools/objecttools.js +1 -1
  88. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  89. package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
  90. package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
  91. package/dist/Runtime/gd.js +1 -1
  92. package/dist/Runtime/gd.js.map +2 -2
  93. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  94. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  95. package/dist/Runtime/indexeddb.js +2 -0
  96. package/dist/Runtime/indexeddb.js.map +7 -0
  97. package/dist/Runtime/oncetriggers.js +1 -1
  98. package/dist/Runtime/oncetriggers.js.map +2 -2
  99. package/dist/Runtime/runtimebehavior.js +1 -1
  100. package/dist/Runtime/runtimebehavior.js.map +2 -2
  101. package/dist/Runtime/runtimegame.js +1 -1
  102. package/dist/Runtime/runtimegame.js.map +2 -2
  103. package/dist/Runtime/runtimeobject.js +1 -1
  104. package/dist/Runtime/runtimeobject.js.map +2 -2
  105. package/dist/Runtime/runtimescene.js +1 -1
  106. package/dist/Runtime/runtimescene.js.map +2 -2
  107. package/dist/Runtime/scenestack.js +1 -1
  108. package/dist/Runtime/scenestack.js.map +2 -2
  109. package/dist/Runtime/spriteruntimeobject.js +1 -1
  110. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  111. package/dist/Runtime/timemanager.js +1 -1
  112. package/dist/Runtime/timemanager.js.map +2 -2
  113. package/dist/Runtime/timer.js +1 -1
  114. package/dist/Runtime/timer.js.map +2 -2
  115. package/dist/Runtime/types/global-types.d.ts +29 -0
  116. package/dist/Runtime/types/project-data.d.ts +144 -3
  117. package/dist/Runtime/types/save-state.d.ts +9 -0
  118. package/dist/Runtime/variable.js +1 -1
  119. package/dist/Runtime/variable.js.map +2 -2
  120. package/dist/Runtime/variablescontainer.js +1 -1
  121. package/dist/Runtime/variablescontainer.js.map +2 -2
  122. package/dist/lib/libGD.cjs +1 -1
  123. package/dist/lib/libGD.wasm +0 -0
  124. package/dist/loaders.cjs +1 -1
  125. package/gd.d.ts +1 -0
  126. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/spriteruntimeobject.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 /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The scale applied to object to evaluate the default dimensions */\n preScale?: float;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler\n {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n _preScale: float = 1;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._preScale = newObjectData.preScale || 1;\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this._updateAnimationFrame();\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(newNetworkSyncData: SpriteNetworkSyncData) {\n super.updateFromNetworkSyncData(newNetworkSyncData);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged =\n this._animator.setAnimationIndex(newAnimation);\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged =\n this._animator.setAnimationName(newAnimationName);\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param newValue The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.setAnimationElapsedTime(time);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame =\n this._animator.getCurrentFrame() as SpriteAnimationFrame<any>;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.x * Math.abs(this._scaleX * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX * this._preScale)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.y * Math.abs(this._scaleY * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY * this._preScale)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbOrHexColor The color as a string, in RGB format (\"128;200;255\") or Hex format.\n */\n setColor(rgbOrHexColor: string): void {\n this._renderer.setColor(rgbOrHexColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / (unscaledWidth * this._preScale));\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / (unscaledHeight * this._preScale));\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null) {\n if (obj === null) {\n return;\n }\n this.rotateTowardPosition(\n obj.getDrawableX() + obj.getCenterX(),\n obj.getDrawableY() + obj.getCenterY(),\n 0\n );\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CA6BS,eACG,GAAK,aAOf,CAkBE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApB3B,aAAiB,EACjB,aAAiB,EACjB,gBAAsB,EACtB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IAEjB,eAAmB,EAGnB,0BAAuB,GAWrB,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,UAAY,GAAI,GAAK,eACxB,EAAiB,WACjB,EAAK,4BAA4B,gCAC/B,EAAkB,UAAU,oBAGhC,KAAK,wBAGL,KAAK,YAGP,aAAa,EAAoC,CAC/C,MAAM,aAAa,GACnB,KAAM,GAAoB,KAAK,uBAC/B,KAAK,UAAU,aAAa,EAAiB,YAC7C,KAAK,QAAU,EACf,KAAK,QAAU,EACf,KAAK,WAAa,EAClB,KAAK,UAAY,GACjB,KAAK,UAAY,GACjB,KAAK,QAAU,IACf,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAU,aAAa,KAAM,GAClC,KAAK,wBAGL,KAAK,YAGP,qBACE,E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aACzB,EAAI,eAAiB,EAAI,aACzB,IA15BC,EAAM,sBA85Bb,EAAK,eACH,SAEA,EAAK,qBAIP,EAAoB,yBAA2B,KAl8BvC",
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 /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The scale applied to object to evaluate the default dimensions */\n preScale?: float;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler\n {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n _preScale: float = 1;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._preScale = newObjectData.preScale || 1;\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this._updateAnimationFrame();\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(syncOptions),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(\n newNetworkSyncData: SpriteNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ) {\n super.updateFromNetworkSyncData(newNetworkSyncData, options);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged =\n this._animator.setAnimationIndex(newAnimation);\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged =\n this._animator.setAnimationName(newAnimationName);\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param newValue The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.setAnimationElapsedTime(time);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame =\n this._animator.getCurrentFrame() as SpriteAnimationFrame<any>;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.x * Math.abs(this._scaleX * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX * this._preScale)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.y * Math.abs(this._scaleY * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY * this._preScale)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbOrHexColor The color as a string, in RGB format (\"128;200;255\") or Hex format.\n */\n setColor(rgbOrHexColor: string): void {\n this._renderer.setColor(rgbOrHexColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / (unscaledWidth * this._preScale));\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / (unscaledHeight * this._preScale));\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null) {\n return this.rotateTowardObject(obj, 0);\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CA6BS,eACG,GAAK,aAOf,CAkBE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApB3B,aAAiB,EACjB,aAAiB,EACjB,gBAAsB,EACtB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IAEjB,eAAmB,EAGnB,0BAAuB,GAWrB,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,UAAY,GAAI,GAAK,eACxB,EAAiB,WACjB,EAAK,4BAA4B,gCAC/B,EAAkB,UAAU,oBAGhC,KAAK,wBAGL,KAAK,YAGP,aAAa,EAAoC,CAC/C,MAAM,aAAa,GACnB,KAAM,GAAoB,KAAK,uBAC/B,KAAK,UAAU,aAAa,EAAiB,YAC7C,KAAK,QAAU,EACf,KAAK,QAAU,EACf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KAAK,SAC7B,MAAO,KAAW,EAAS,EAAS,KAAK,KAAK,EAAS,GAQzD,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAQvB,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAQvB,iBAAiB,EAAgC,CAC/C,MAAO,MAAK,mBAAmB,EAAK,IAz5BjC,EAAM,sBA45Bb,EAAK,eACH,SAEA,EAAK,qBAIP,EAAoB,yBAA2B,KAh8BvC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){class r{constructor(){this._elapsedTime=0;this._timeScale=1;this._timeFromStart=0;this._firstFrame=!0;this._timers=new Hashtable;this._firstUpdateDone=!1;this.reset()}reset(){this._elapsedTime=0,this._timeScale=1,this._timeFromStart=0,this._firstFrame=!0,this._timers=new Hashtable}update(e,s){this._firstUpdateDone&&(this._firstFrame=!1),this._firstUpdateDone=!0,this._elapsedTime=Math.min(e,1e3/s),this._elapsedTime*=this._timeScale;for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(this._elapsedTime);this._timeFromStart+=this._elapsedTime}setTimeScale(e){e>=0&&(this._timeScale=e)}getTimeScale(){return this._timeScale}getTimeFromStart(){return this._timeFromStart}isFirstFrame(){return this._firstFrame}getElapsedTime(){return this._elapsedTime}addTimer(e){this._timers.put(e,new i.Timer(e))}hasTimer(e){return this._timers.containsKey(e)}getTimer(e){return this._timers.get(e)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}}i.TimeManager=r})(gdjs||(gdjs={}));
1
+ var gdjs;(function(r){class a{constructor(){this._elapsedTime=0;this._timeScale=1;this._timeFromStart=0;this._firstFrame=!0;this._timers=new Hashtable;this._firstUpdateDone=!1;this.reset()}reset(){this._elapsedTime=0,this._timeScale=1,this._timeFromStart=0,this._firstFrame=!0,this._timers=new Hashtable}update(e,i){this._firstUpdateDone&&(this._firstFrame=!1),this._firstUpdateDone=!0,this._elapsedTime=Math.min(e,1e3/i),this._elapsedTime*=this._timeScale;for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(this._elapsedTime);this._timeFromStart+=this._elapsedTime}setTimeScale(e){e>=0&&(this._timeScale=e)}getNetworkSyncData(){const e=new Hashtable;return Object.entries(this._timers.items).forEach(([i,t])=>{e.put(i,t.getNetworkSyncData())}),{elapsedTime:this._elapsedTime,timeScale:this._timeScale,timeFromStart:this._timeFromStart,firstFrame:this._firstFrame,timers:e,firstUpdateDone:this._firstUpdateDone}}updateFromNetworkSyncData(e){e.elapsedTime!==void 0&&(this._elapsedTime=e.elapsedTime),e.timeScale!==void 0&&(this._timeScale=e.timeScale),e.timeFromStart!==void 0&&(this._timeFromStart=e.timeFromStart),e.firstFrame!==void 0&&(this._firstFrame=e.firstFrame),e.timers!==void 0&&(this._timers.clear(),Object.entries(e.timers.items).forEach(([i,t])=>{const s=new r.Timer(t.name);s.updateFromNetworkSyncData(t),this._timers.put(i,s)})),e.firstUpdateDone!==void 0&&(this._firstUpdateDone=e.firstUpdateDone)}getTimeScale(){return this._timeScale}getTimeFromStart(){return this._timeFromStart}isFirstFrame(){return this._firstFrame}getElapsedTime(){return this._elapsedTime}addTimer(e){this._timers.put(e,new r.Timer(e))}hasTimer(e){return this._timers.containsKey(e)}getTimer(e){return this._timers.get(e)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}}r.TimeManager=a})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=timemanager.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/timemanager.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Manage the timers and times elapsed during last\n * frame, since the beginning of the scene and other time related values.\n * All durations are expressed in milliseconds.\n */\n export class TimeManager {\n _elapsedTime: float = 0;\n _timeScale: float = 1;\n _timeFromStart: float = 0;\n _firstFrame: boolean = true;\n _timers: Hashtable<gdjs.Timer> = new Hashtable();\n _firstUpdateDone: boolean = false;\n\n constructor() {\n this.reset();\n }\n\n reset(): void {\n this._elapsedTime = 0;\n this._timeScale = 1;\n this._timeFromStart = 0;\n this._firstFrame = true;\n this._timers = new Hashtable();\n }\n\n update(elapsedTime: float, minimumFPS: integer): void {\n if (this._firstUpdateDone) {\n this._firstFrame = false;\n }\n this._firstUpdateDone = true;\n\n //Compute the elapsed time since last frame\n this._elapsedTime = Math.min(elapsedTime, 1000 / minimumFPS);\n this._elapsedTime *= this._timeScale;\n\n //Update timers and others members\n for (const name in this._timers.items) {\n if (this._timers.items.hasOwnProperty(name)) {\n this._timers.items[name].updateTime(this._elapsedTime);\n }\n }\n this._timeFromStart += this._elapsedTime;\n }\n\n /**\n * Set the time scale: time will be slower if time scale is < 1,\n * faster if > 1.\n * @param timeScale The new time scale (must be positive).\n */\n setTimeScale(timeScale: float): void {\n if (timeScale >= 0) {\n this._timeScale = timeScale;\n }\n }\n\n /**\n * Get the time scale.\n * @return The time scale (positive, 1 is normal speed).\n */\n getTimeScale(): float {\n return this._timeScale;\n }\n\n /**\n * Get the time since the instantiation of the manager (i.e: since\n * the beginning of the scene most of the time), in milliseconds.\n */\n getTimeFromStart(): float {\n return this._timeFromStart;\n }\n\n /**\n * Return true if update was called only once (i.e: if the scene\n * is rendering its first frame).\n */\n isFirstFrame(): boolean {\n return this._firstFrame;\n }\n\n /**\n * Return the time elapsed since the last call to update\n * (i.e: the last frame), in milliseconds.\n */\n getElapsedTime(): float {\n return this._elapsedTime;\n }\n\n addTimer(name: string): void {\n this._timers.put(name, new gdjs.Timer(name));\n }\n\n hasTimer(name: string): boolean {\n return this._timers.containsKey(name);\n }\n\n getTimer(name: string): gdjs.Timer {\n return this._timers.get(name);\n }\n\n removeTimer(name: string): void {\n if (this._timers.containsKey(name)) {\n this._timers.remove(name);\n }\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAMS,OAAkB,CAQvB,aAAc,CAPd,kBAAsB,EACtB,gBAAoB,EACpB,oBAAwB,EACxB,iBAAuB,GACvB,aAAiC,GAAI,WACrC,sBAA4B,GAG1B,KAAK,QAGP,OAAc,CACZ,KAAK,aAAe,EACpB,KAAK,WAAa,EAClB,KAAK,eAAiB,EACtB,KAAK,YAAc,GACnB,KAAK,QAAU,GAAI,WAGrB,OAAO,EAAoB,EAA2B,CACpD,AAAI,KAAK,kBACP,MAAK,YAAc,IAErB,KAAK,iBAAmB,GAGxB,KAAK,aAAe,KAAK,IAAI,EAAa,IAAO,GACjD,KAAK,cAAgB,KAAK,WAG1B,SAAW,KAAQ,MAAK,QAAQ,MAC9B,AAAI,KAAK,QAAQ,MAAM,eAAe,IACpC,KAAK,QAAQ,MAAM,GAAM,WAAW,KAAK,cAG7C,KAAK,gBAAkB,KAAK,aAQ9B,aAAa,EAAwB,CACnC,AAAI,GAAa,GACf,MAAK,WAAa,GAQtB,cAAsB,CACpB,MAAO,MAAK,WAOd,kBAA0B,CACxB,MAAO,MAAK,eAOd,cAAwB,CACtB,MAAO,MAAK,YAOd,gBAAwB,CACtB,MAAO,MAAK,aAGd,SAAS,EAAoB,CAC3B,KAAK,QAAQ,IAAI,EAAM,GAAI,GAAK,MAAM,IAGxC,SAAS,EAAuB,CAC9B,MAAO,MAAK,QAAQ,YAAY,GAGlC,SAAS,EAA0B,CACjC,MAAO,MAAK,QAAQ,IAAI,GAG1B,YAAY,EAAoB,CAC9B,AAAI,KAAK,QAAQ,YAAY,IAC3B,KAAK,QAAQ,OAAO,IAhGnB,EAAM,gBANL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Manage the timers and times elapsed during last\n * frame, since the beginning of the scene and other time related values.\n * All durations are expressed in milliseconds.\n */\n\n declare interface TimeManagerSyncData {\n elapsedTime: float;\n timeScale: float;\n timeFromStart: float;\n firstFrame: boolean;\n timers: Hashtable<TimerNetworkSyncData>;\n firstUpdateDone: boolean;\n }\n export class TimeManager {\n _elapsedTime: float = 0;\n _timeScale: float = 1;\n _timeFromStart: float = 0;\n _firstFrame: boolean = true;\n _timers: Hashtable<gdjs.Timer> = new Hashtable();\n _firstUpdateDone: boolean = false;\n\n constructor() {\n this.reset();\n }\n\n reset(): void {\n this._elapsedTime = 0;\n this._timeScale = 1;\n this._timeFromStart = 0;\n this._firstFrame = true;\n this._timers = new Hashtable();\n }\n\n update(elapsedTime: float, minimumFPS: integer): void {\n if (this._firstUpdateDone) {\n this._firstFrame = false;\n }\n this._firstUpdateDone = true;\n\n //Compute the elapsed time since last frame\n this._elapsedTime = Math.min(elapsedTime, 1000 / minimumFPS);\n this._elapsedTime *= this._timeScale;\n\n //Update timers and others members\n for (const name in this._timers.items) {\n if (this._timers.items.hasOwnProperty(name)) {\n this._timers.items[name].updateTime(this._elapsedTime);\n }\n }\n this._timeFromStart += this._elapsedTime;\n }\n\n /**\n * Set the time scale: time will be slower if time scale is < 1,\n * faster if > 1.\n * @param timeScale The new time scale (must be positive).\n */\n setTimeScale(timeScale: float): void {\n if (timeScale >= 0) {\n this._timeScale = timeScale;\n }\n }\n\n getNetworkSyncData(): TimeManagerSyncData {\n const timerNetworkSyncDatas = new Hashtable<TimerNetworkSyncData>();\n Object.entries(this._timers.items).forEach(([key, timer]) => {\n timerNetworkSyncDatas.put(key, timer.getNetworkSyncData());\n });\n\n return {\n elapsedTime: this._elapsedTime,\n timeScale: this._timeScale,\n timeFromStart: this._timeFromStart,\n firstFrame: this._firstFrame,\n timers: timerNetworkSyncDatas,\n firstUpdateDone: this._firstUpdateDone,\n };\n }\n\n updateFromNetworkSyncData(syncData: TimeManagerSyncData): void {\n if (syncData.elapsedTime !== undefined) {\n this._elapsedTime = syncData.elapsedTime;\n }\n if (syncData.timeScale !== undefined) {\n this._timeScale = syncData.timeScale;\n }\n if (syncData.timeFromStart !== undefined) {\n this._timeFromStart = syncData.timeFromStart;\n }\n if (syncData.firstFrame !== undefined) {\n this._firstFrame = syncData.firstFrame;\n }\n if (syncData.timers !== undefined) {\n this._timers.clear();\n Object.entries(syncData.timers.items).forEach(([key, timerData]) => {\n const newTimer = new gdjs.Timer(timerData.name);\n newTimer.updateFromNetworkSyncData(timerData);\n this._timers.put(key, newTimer);\n });\n }\n\n if (syncData.firstUpdateDone !== undefined) {\n this._firstUpdateDone = syncData.firstUpdateDone;\n }\n }\n /**\n * Get the time scale.\n * @return The time scale (positive, 1 is normal speed).\n */\n getTimeScale(): float {\n return this._timeScale;\n }\n\n /**\n * Get the time since the instantiation of the manager (i.e: since\n * the beginning of the scene most of the time), in milliseconds.\n */\n getTimeFromStart(): float {\n return this._timeFromStart;\n }\n\n /**\n * Return true if update was called only once (i.e: if the scene\n * is rendering its first frame).\n */\n isFirstFrame(): boolean {\n return this._firstFrame;\n }\n\n /**\n * Return the time elapsed since the last call to update\n * (i.e: the last frame), in milliseconds.\n */\n getElapsedTime(): float {\n return this._elapsedTime;\n }\n\n addTimer(name: string): void {\n this._timers.put(name, new gdjs.Timer(name));\n }\n\n hasTimer(name: string): boolean {\n return this._timers.containsKey(name);\n }\n\n getTimer(name: string): gdjs.Timer {\n return this._timers.get(name);\n }\n\n removeTimer(name: string): void {\n if (this._timers.containsKey(name)) {\n this._timers.remove(name);\n }\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAeS,OAAkB,CAQvB,aAAc,CAPd,kBAAsB,EACtB,gBAAoB,EACpB,oBAAwB,EACxB,iBAAuB,GACvB,aAAiC,GAAI,WACrC,sBAA4B,GAG1B,KAAK,QAGP,OAAc,CACZ,KAAK,aAAe,EACpB,KAAK,WAAa,EAClB,KAAK,eAAiB,EACtB,KAAK,YAAc,GACnB,KAAK,QAAU,GAAI,WAGrB,OAAO,EAAoB,EAA2B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K,MAAM,IAGxC,SAAS,EAAuB,CAC9B,MAAO,MAAK,QAAQ,YAAY,GAGlC,SAAS,EAA0B,CACjC,MAAO,MAAK,QAAQ,IAAI,GAG1B,YAAY,EAAoB,CAC9B,AAAI,KAAK,QAAQ,YAAY,IAC3B,KAAK,QAAQ,OAAO,IA1InB,EAAM,gBAfL",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){class t{constructor(e){this._time=0;this._paused=!1;this._name=e}getName(){return this._name}getTime(){return this._time}updateTime(e){this._paused||(this._time+=e)}setTime(e){this._time=e}reset(){this.setTime(0)}setPaused(e){this._paused=e}isPaused(){return this._paused}getNetworkSyncData(){return{time:this._time,paused:this._paused}}updateFromNetworkSyncData(e){this._time=e.time,this._paused=e.paused}}i.Timer=t})(gdjs||(gdjs={}));
1
+ var gdjs;(function(i){class t{constructor(e){this._time=0;this._paused=!1;this._name=e}getName(){return this._name}getTime(){return this._time}updateTime(e){this._paused||(this._time+=e)}setTime(e){this._time=e}reset(){this.setTime(0)}setPaused(e){this._paused=e}isPaused(){return this._paused}getNetworkSyncData(){return{name:this._name,time:this._time,paused:this._paused}}updateFromNetworkSyncData(e){this._time=e.time,this._paused=e.paused}}i.Timer=t})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=timer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/timer.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Represents a timer, which must be updated manually with {@link gdjs.Timer.updateTime}.\n */\n export class Timer {\n _name: string;\n _time: float = 0;\n _paused: boolean = false;\n\n /**\n * @param name The name of the timer.\n */\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Get the name of the timer\n * @return The name of the timer\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Get the time of the timer, in milliseconds.\n * @return The time of the timer, in milliseconds.\n */\n getTime(): float {\n return this._time;\n }\n\n /**\n * Notify the timer that some time has passed.\n * @param time The elapsed time, in milliseconds.\n */\n updateTime(time: float): void {\n if (!this._paused) {\n this._time += time;\n }\n }\n\n /**\n * Change the time.\n * @param time The new time, in milliseconds.\n */\n setTime(time: float): void {\n this._time = time;\n }\n\n /**\n * Reset the time to zero.\n */\n reset(): void {\n this.setTime(0);\n }\n\n /**\n * Set if the timer is paused.\n * @param enable true to pause the timer, false otherwise.\n */\n setPaused(enable: boolean): void {\n this._paused = enable;\n }\n\n /**\n * Check if the timer is paused.\n */\n isPaused(): boolean {\n return this._paused;\n }\n\n getNetworkSyncData(): TimerNetworkSyncData {\n return {\n time: this._time,\n paused: this._paused,\n };\n }\n\n updateFromNetworkSyncData(syncData: TimerNetworkSyncData) {\n this._time = syncData.time;\n this._paused = syncData.paused;\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAIS,OAAY,CAQjB,YAAY,EAAc,CAN1B,WAAe,EACf,aAAmB,GAMjB,KAAK,MAAQ,EAOf,SAAkB,CAChB,MAAO,MAAK,MAOd,SAAiB,CACf,MAAO,MAAK,MAOd,WAAW,EAAmB,CAC5B,AAAK,KAAK,SACR,MAAK,OAAS,GAQlB,QAAQ,EAAmB,CACzB,KAAK,MAAQ,EAMf,OAAc,CACZ,KAAK,QAAQ,GAOf,UAAU,EAAuB,CAC/B,KAAK,QAAU,EAMjB,UAAoB,CAClB,MAAO,MAAK,QAGd,oBAA2C,CACzC,MAAO,CACL,KAAM,KAAK,MACX,OAAQ,KAAK,SAIjB,0BAA0B,EAAgC,CACxD,KAAK,MAAQ,EAAS,KACtB,KAAK,QAAU,EAAS,QA7ErB,EAAM,UAJL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * Represents a timer, which must be updated manually with {@link gdjs.Timer.updateTime}.\n */\n export class Timer {\n _name: string;\n _time: float = 0;\n _paused: boolean = false;\n\n /**\n * @param name The name of the timer.\n */\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Get the name of the timer\n * @return The name of the timer\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Get the time of the timer, in milliseconds.\n * @return The time of the timer, in milliseconds.\n */\n getTime(): float {\n return this._time;\n }\n\n /**\n * Notify the timer that some time has passed.\n * @param time The elapsed time, in milliseconds.\n */\n updateTime(time: float): void {\n if (!this._paused) {\n this._time += time;\n }\n }\n\n /**\n * Change the time.\n * @param time The new time, in milliseconds.\n */\n setTime(time: float): void {\n this._time = time;\n }\n\n /**\n * Reset the time to zero.\n */\n reset(): void {\n this.setTime(0);\n }\n\n /**\n * Set if the timer is paused.\n * @param enable true to pause the timer, false otherwise.\n */\n setPaused(enable: boolean): void {\n this._paused = enable;\n }\n\n /**\n * Check if the timer is paused.\n */\n isPaused(): boolean {\n return this._paused;\n }\n\n getNetworkSyncData(): TimerNetworkSyncData {\n return {\n name: this._name,\n time: this._time,\n paused: this._paused,\n };\n }\n\n updateFromNetworkSyncData(syncData: TimerNetworkSyncData) {\n this._time = syncData.time;\n this._paused = syncData.paused;\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAIS,OAAY,CAQjB,YAAY,EAAc,CAN1B,WAAe,EACf,aAAmB,GAMjB,KAAK,MAAQ,EAOf,SAAkB,CAChB,MAAO,MAAK,MAOd,SAAiB,CACf,MAAO,MAAK,MAOd,WAAW,EAAmB,CAC5B,AAAK,KAAK,SACR,MAAK,OAAS,GAQlB,QAAQ,EAAmB,CACzB,KAAK,MAAQ,EAMf,OAAc,CACZ,KAAK,QAAQ,GAOf,UAAU,EAAuB,CAC/B,KAAK,QAAU,EAMjB,UAAoB,CAClB,MAAO,MAAK,QAGd,oBAA2C,CACzC,MAAO,CACL,KAAM,KAAK,MACX,KAAM,KAAK,MACX,OAAQ,KAAK,SAIjB,0BAA0B,EAAgC,CACxD,KAAK,MAAQ,EAAS,KACtB,KAAK,QAAU,EAAS,QA9ErB,EAAM,UAJL",
6
6
  "names": []
7
7
  }
@@ -76,3 +76,32 @@ declare namespace gdjs {
76
76
 
77
77
  /** The global cc object from Cocos2D-Js. */
78
78
  declare var cc: any;
79
+
80
+ /**
81
+ * Fixes https://github.com/microsoft/TypeScript/issues/16655 for `Array.prototype.filter()`
82
+ * For example, using the fix the type of `bar` is `string[]` in the below snippet as it should be.
83
+ *
84
+ * const foo: (string | null | undefined)[] = [];
85
+ * const bar = foo.filter(Boolean);
86
+ *
87
+ * For related definitions, see https://github.com/microsoft/TypeScript/blob/master/src/lib/es5.d.ts
88
+ *
89
+ * Original licenses apply, see
90
+ * - https://github.com/microsoft/TypeScript/blob/master/LICENSE.txt
91
+ * - https://stackoverflow.com/help/licensing
92
+ */
93
+
94
+ /** See https://stackoverflow.com/a/51390763/1470607 */
95
+ type Falsy = false | 0 | '' | null | undefined;
96
+
97
+ interface Array<T> {
98
+ /**
99
+ * Returns the elements of an array that meet the condition specified in a callback function.
100
+ * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
101
+ * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
102
+ */
103
+ filter<S extends T>(
104
+ predicate: BooleanConstructor,
105
+ thisArg?: any
106
+ ): Exclude<S, Falsy>[];
107
+ }
@@ -42,6 +42,28 @@ declare type ObjectData = {
42
42
  declare type GetNetworkSyncDataOptions = {
43
43
  playerNumber?: number;
44
44
  isHost?: boolean;
45
+ syncObjectIdentifiers?: boolean;
46
+ shouldExcludeVariableFromData?: (variable: Variable) => boolean;
47
+ syncAllBehaviors?: boolean;
48
+ syncGameVariables?: boolean;
49
+ syncSceneTimers?: boolean;
50
+ syncOnceTriggers?: boolean;
51
+ syncSounds?: boolean;
52
+ syncTweens?: boolean;
53
+ syncLayers?: boolean;
54
+ syncAsyncTasks?: boolean;
55
+ syncSceneVisualProps?: boolean;
56
+ syncFullTileMaps?: boolean;
57
+ };
58
+
59
+ declare type UpdateFromNetworkSyncDataOptions = {
60
+ clearSceneStack?: boolean;
61
+ getExcludedObjectNames?: (runtimeScene: RuntimeScene) => Set<string>;
62
+ preventSoundsStoppingOnStartup?: boolean;
63
+ clearInputs?: boolean;
64
+ keepControl?: boolean;
65
+ ignoreVariableOwnership?: boolean;
66
+ shouldExcludeVariableFromUpdate?: (variable: Variable) => boolean;
45
67
  };
46
68
 
47
69
  /** Object containing basic properties for all objects synchronizing over the network. */
@@ -70,6 +92,10 @@ declare type BasicObjectNetworkSyncData = {
70
92
  pfx: number;
71
93
  /** Permanent force on Y */
72
94
  pfy: number;
95
+ /** Name of the object */
96
+ n?: string;
97
+ /** The network ID of the instance. */
98
+ networkId?: string;
73
99
  };
74
100
 
75
101
  /**
@@ -91,6 +117,8 @@ declare interface ObjectNetworkSyncData extends BasicObjectNetworkSyncData {
91
117
  tim?: {
92
118
  [timerName: string]: TimerNetworkSyncData;
93
119
  };
120
+ /** Tweens */
121
+ tween?: TweenManagerNetworkSyncData;
94
122
  }
95
123
 
96
124
  declare type ForceNetworkSyncData = {
@@ -102,6 +130,7 @@ declare type ForceNetworkSyncData = {
102
130
  };
103
131
 
104
132
  declare type TimerNetworkSyncData = {
133
+ name: string;
105
134
  time: float;
106
135
  paused: boolean;
107
136
  };
@@ -128,12 +157,30 @@ declare type VariableData = Readonly<{
128
157
  /** A variable child of a container. Those always have a name. */
129
158
  declare type RootVariableData = Omit<VariableData, 'name'> & { name: string };
130
159
 
131
- declare type VariableNetworkSyncData = {
132
- name: string;
160
+ declare type UnnamedVariableNetworkSyncData = {
133
161
  value: string | float | boolean;
134
162
  children?: VariableNetworkSyncData[];
135
163
  type: VariableType;
136
- owner: number;
164
+ owner: number | null;
165
+ };
166
+ declare type VariableNetworkSyncData = UnnamedVariableNetworkSyncData & {
167
+ name: string;
168
+ };
169
+
170
+ declare type LayerNetworkSyncData = {
171
+ timeScale: float;
172
+ defaultZOrder: integer;
173
+ hidden: boolean;
174
+ effects: {
175
+ [effectName: string]: EffectNetworkSyncData;
176
+ };
177
+ followBaseLayerCamera: boolean;
178
+ clearColor: Array<integer>;
179
+ cameraX: float;
180
+ cameraY: float;
181
+ cameraZ: float;
182
+ cameraRotation: float;
183
+ cameraZoom: float;
137
184
  };
138
185
 
139
186
  /** Properties to set up a behavior. */
@@ -149,6 +196,74 @@ declare type BehaviorNetworkSyncData = {
149
196
  props: any;
150
197
  };
151
198
 
199
+ declare type SceneTweenType =
200
+ | 'layoutValue'
201
+ | 'layerValue'
202
+ | 'variable'
203
+ | 'cameraZoom'
204
+ | 'cameraRotation'
205
+ | 'cameraPosition'
206
+ | 'colorEffectProperty'
207
+ | 'numberEffectProperty';
208
+ declare type ObjectTweenType =
209
+ | 'variable'
210
+ | 'position'
211
+ | 'positionX'
212
+ | 'positionY'
213
+ | 'positionZ'
214
+ | 'width'
215
+ | 'height'
216
+ | 'depth'
217
+ | 'angle'
218
+ | 'rotationX'
219
+ | 'rotationY'
220
+ | 'scale'
221
+ | 'scaleXY'
222
+ | 'scaleX'
223
+ | 'scaleY'
224
+ | 'opacity'
225
+ | 'characterSize'
226
+ | 'numberEffectProperty'
227
+ | 'colorEffectProperty'
228
+ | 'objectColor'
229
+ | 'objectColorHSL'
230
+ | 'objectValue';
231
+
232
+ declare type TweenInformation = {
233
+ type: SceneTweenType | ObjectTweenType;
234
+ layerName?: string;
235
+ variable?: Variable;
236
+ effectName?: string;
237
+ propertyName?: string;
238
+ scaleFromCenterOfObject?: boolean;
239
+ useHSLColorTransition?: boolean;
240
+ destroyObjectWhenFinished?: boolean;
241
+ };
242
+
243
+ declare type TweenInformationNetworkSyncData = Omit<
244
+ TweenInformation,
245
+ 'variable' // When synced, a variable is replaced by its path
246
+ > & { variablePath?: string[] };
247
+
248
+ declare type TweenInstanceNetworkSyncData<T> = {
249
+ initialValue: T;
250
+ targetedValue: T;
251
+ elapsedTime: float;
252
+ totalDuration: float;
253
+ easingIdentifier: string;
254
+ interpolationString: 'linear' | 'exponential';
255
+ isPaused: boolean;
256
+ tweenInformation: TweenInformationNetworkSyncData;
257
+ };
258
+
259
+ declare type TweenManagerNetworkSyncData = {
260
+ tweens: Record<
261
+ string,
262
+ | TweenInstanceNetworkSyncData<float>
263
+ | TweenInstanceNetworkSyncData<Array<float>>
264
+ >;
265
+ };
266
+
152
267
  declare interface GdVersionData {
153
268
  build: number;
154
269
  major: number;
@@ -183,6 +298,14 @@ declare interface LayoutNetworkSyncData {
183
298
  extVar?: {
184
299
  [extensionName: string]: VariableNetworkSyncData[];
185
300
  };
301
+ time?: TimeManagerSyncData;
302
+ tween?: TweenManagerNetworkSyncData;
303
+ once?: OnceTriggersSyncData;
304
+ layers?: {
305
+ [layerName: string]: LayerNetworkSyncData;
306
+ };
307
+ async?: AsyncTasksManagerNetworkSyncData;
308
+ color?: integer;
186
309
  }
187
310
 
188
311
  declare interface SceneStackSceneNetworkSyncData {
@@ -192,12 +315,30 @@ declare interface SceneStackSceneNetworkSyncData {
192
315
 
193
316
  declare type SceneStackNetworkSyncData = SceneStackSceneNetworkSyncData[];
194
317
 
318
+ declare type SoundSyncData = {
319
+ loop: boolean;
320
+ volume: float;
321
+ rate: float;
322
+ resourceName: string;
323
+ seek: float;
324
+ };
325
+ declare type ChannelsSoundSyncData = Record<integer, SoundSyncData>;
326
+ declare type SoundManagerSyncData = {
327
+ globalVolume: float;
328
+ cachedSpatialPosition: Record<number, [number, number, number]>;
329
+ freeSounds: SoundSyncData[];
330
+ freeMusics: SoundSyncData[];
331
+ musics: ChannelsSoundSyncData;
332
+ sounds: ChannelsSoundSyncData;
333
+ };
334
+
195
335
  declare interface GameNetworkSyncData {
196
336
  var?: VariableNetworkSyncData[];
197
337
  ss?: SceneStackNetworkSyncData;
198
338
  extVar?: {
199
339
  [extensionName: string]: VariableNetworkSyncData[];
200
340
  };
341
+ sm?: SoundManagerSyncData;
201
342
  }
202
343
 
203
344
  declare interface EventsFunctionsExtensionData {
@@ -0,0 +1,9 @@
1
+ declare type SceneSaveState = {
2
+ sceneData: LayoutNetworkSyncData;
3
+ objectDatas: { [objectId: integer]: ObjectNetworkSyncData };
4
+ };
5
+
6
+ declare type GameSaveState = {
7
+ gameNetworkSyncData: GameNetworkSyncData | null;
8
+ layoutNetworkSyncDatas: SceneSaveState[];
9
+ };
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){const n=new i.Logger("Variables");class l{constructor(e){this._type="number";this._value=0;this._str="0";this._bool=!1;this._children={};this._childrenArray=[];this._undefinedInContainer=!1;this._playerNumber=0;this.reinitialize(e)}reinitialize(e){if(this._type="number",this._value=0,this._str="0",this._bool=!1,this._children={},this._childrenArray=[],this._undefinedInContainer=!1,e!==void 0){if(this._type=e.type||"number",this._type==="number")this._value=parseFloat(e.value||"0"),this._value!==this._value&&(this._value=0);else if(this._type==="string")this._str=""+e.value||"0";else if(this._type==="boolean")this._bool=!!e.value;else if(this._type==="structure"){if(e.children!==void 0)for(var t=0,r=e.children.length;t<r;++t){var s=e.children[t];s.name!==void 0&&(this._children[s.name]=new i.Variable(s))}}else if(this._type==="array"&&e.children)for(const a of e.children)this._childrenArray.push(new i.Variable(a))}}static isPrimitive(e){return e==="string"||e==="number"||e==="boolean"}static copy(e,t,r){if(r||t.clearChildren(),t.castTo(e.getType()),e.isPrimitive())t.setValue(e.getValue());else if(e.getType()==="structure"){const s=e.getAllChildren();for(const a in s)s.hasOwnProperty(a)&&t.addChild(a,s[a].clone())}else if(e.getType()==="array")for(const s of e.getAllChildrenArray())t.pushVariableCopy(s);return t}fromJSObject(e){if(e===null)this.setString("null");else if(typeof e=="number")Number.isNaN(e)?(n.warn("Variables cannot be set to NaN, setting it to 0."),this.setNumber(0)):this.setNumber(e);else if(typeof e=="string")this.setString(e);else if(typeof e!="undefined")if(typeof e=="boolean")this.setBoolean(e);else if(Array.isArray(e)){this.castTo("array"),this.clearChildren();for(const r in e)this.getChild(r).fromJSObject(e[r])}else if(typeof e=="object"){this.castTo("structure"),this.clearChildren();for(var t in e)e.hasOwnProperty(t)&&this.getChild(t).fromJSObject(e[t])}else typeof e=="symbol"?this.setString(e.toString()):typeof e=="bigint"?(e>Number.MAX_SAFE_INTEGER&&n.warn("Error while converting JS variable to GDevelop variable: Integers bigger than "+Number.MAX_SAFE_INTEGER+" aren't supported by GDevelop variables, it will be reduced to that size."),variable.setNumber(parseInt(e,10))):typeof e=="function"?n.error("Error while converting JS variable to GDevelop variable: Impossible to set variable value to a function."):n.error("Error while converting JS variable to GDevelop variable: Cannot identify type of object "+e);return this}fromJSON(e){try{var t=JSON.parse(e)}catch(r){return n.error("Unable to parse JSON: "+e+r),this}return this.fromJSObject(t),this}toJSObject(){switch(this._type){case"string":return this.getAsString();case"number":return this.getAsNumber();case"boolean":return this.getAsBoolean();case"structure":const e={};for(const r in this._children)e[r]=this._children[r].toJSObject();return e;case"array":const t=[];for(const r of this._childrenArray)t.push(r===void 0?void 0:r.toJSObject());return t}}isPrimitive(){return i.Variable.isPrimitive(this._type)}clone(){return i.Variable.copy(this,new i.Variable)}setUndefinedInContainer(){this._undefinedInContainer=!0}isUndefinedInContainer(){return this._undefinedInContainer}castTo(e){if(e==="string")this.setString(this.getAsString());else if(e==="number")this.setNumber(this.getAsNumber());else if(e==="boolean")this.setBoolean(this.getAsBoolean());else if(e==="structure"){if(this._type==="structure")return;this._children=this.getAllChildren(),this._type="structure"}else if(e==="array"){if(this._type==="array")return;this._childrenArray=this.getAllChildrenArray(),this._type="array"}}getChild(e){return this._type==="array"?this.getChildAt(Number.isInteger(e)?e:parseInt(e,10)||0):(this._type!=="structure"&&this.castTo("structure"),this.getChildNamed(""+e))}getChildNamed(e){const t=this._children[e];return t??(this._children[e]=new i.Variable)}addChild(e,t){return this._type!=="structure"&&this.castTo("structure"),this._children[e]=t,this}hasChild(e){return this._type==="structure"&&this._children.hasOwnProperty(e)}removeChild(e){this._type==="structure"&&delete this._children[e]}clearChildren(){this._children={},this._childrenArray=[]}replaceChildren(e){this._type="structure",this._children=e}replaceChildrenArray(e){this._type="array",this._childrenArray=e}getAsNumber(){if(this._type!=="number"){let e=0;return this._type==="string"?e=parseFloat(this._str):this._type==="boolean"&&(e=this._bool?1:0),e===e?e:0}return this._value}setNumber(e){this._type="number",e=parseFloat(e),this._value=e===e?e:0}getAsString(){return this._type!=="string"?this._type==="number"?this._value.toString():this._type==="boolean"?this._bool?"true":"false":this._type==="structure"?"[Structure]":this._type==="array"?"[Array]":"":this._str}setString(e){this._type="string",this._str=""+e}getAsNumberOrString(){return this._type==="number"?this._value:this.getAsString()}getAsBoolean(){return this._type!=="boolean"?this._type==="number"?this._value!==0:this._type==="string"?this._str!=="0"&&this._str!==""&&this._str!=="false":!0:this._bool}setBoolean(e){this._type="boolean",this._bool=!!e}toggle(){this.setBoolean(!this.getAsBoolean())}setValue(e){this._type==="string"?this.setString(e):this._type==="number"?this.setNumber(e):this._type==="boolean"&&this.setBoolean(e)}getValue(){return this._type==="number"?this.getAsNumber():this._type==="boolean"?this.getAsBoolean():this.getAsString()}isStructure(){return this._type==="structure"}isNumber(){return this._type==="number"}getType(){return this._type}getAllChildren(){return this._type==="structure"?this._children:this._type==="array"?Object.assign({},this._childrenArray):{}}getAllChildrenArray(){return this._type==="structure"?Object.values(this._children):this._type==="array"?this._childrenArray:[]}getChildrenCount(){return this._type==="structure"?Object.keys(this._children).length:this._type==="array"?this._childrenArray.length:0}add(e){this.setNumber(this.getAsNumber()+e)}sub(e){this.setNumber(this.getAsNumber()-e)}mul(e){this.setNumber(this.getAsNumber()*e)}div(e){this.setNumber(this.getAsNumber()/e)}concatenateString(e){this.setString(this.getAsString()+e)}concatenate(e){this.setString(this.getAsString()+e)}getChildAt(e){return this._type!=="array"&&this.castTo("array"),(this._childrenArray[e]===void 0||this._childrenArray[e]===null)&&(this._childrenArray[e]=new i.Variable),this._childrenArray[e]}removeAtIndex(e){this._type==="array"&&this._childrenArray.splice(e,1)}pushVariableCopy(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e.clone())}_pushVariable(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e)}pushValue(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(new i.Variable({type:typeof e,value:e}))}getPlayerOwnership(){return this._playerNumber}setPlayerOwnership(e){this._playerNumber=e}disableSynchronization(){this._playerNumber=null}}i.Variable=l})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const l=new n.Logger("Variables");class u{constructor(e){this._type="number";this._value=0;this._str="0";this._bool=!1;this._children={};this._childrenArray=[];this._undefinedInContainer=!1;this._playerNumber=0;this.reinitialize(e)}reinitialize(e){if(this._type="number",this._value=0,this._str="0",this._bool=!1,this._children={},this._childrenArray=[],this._undefinedInContainer=!1,e!==void 0){if(this._type=e.type||"number",this._type==="number")this._value=parseFloat(e.value||"0"),this._value!==this._value&&(this._value=0);else if(this._type==="string")this._str=""+e.value||"0";else if(this._type==="boolean")this._bool=!!e.value;else if(this._type==="structure"){if(e.children!==void 0)for(var t=0,r=e.children.length;t<r;++t){var i=e.children[t];i.name!==void 0&&(this._children[i.name]=new n.Variable(i))}}else if(this._type==="array"&&e.children)for(const s of e.children)this._childrenArray.push(new n.Variable(s))}}static isPrimitive(e){return e==="string"||e==="number"||e==="boolean"}static copy(e,t,r){if(r||t.clearChildren(),t.castTo(e.getType()),e.isPrimitive())t.setValue(e.getValue());else if(e.getType()==="structure"){const i=e.getAllChildren();for(const s in i)i.hasOwnProperty(s)&&t.addChild(s,i[s].clone())}else if(e.getType()==="array")for(const i of e.getAllChildrenArray())t.pushVariableCopy(i);return t}getNetworkSyncData(e){if(this.isUndefinedInContainer())return;const t=this.getPlayerOwnership();if(e.shouldExcludeVariableFromData){if(e.shouldExcludeVariableFromData(this))return}else{const s=e.playerNumber,a=e.isHost;if(t===null||s!==void 0&&t===0&&!a||t!==0&&s!==t)return}const r=this.getType();return{value:r==="structure"||r==="array"?"":this.getValue(),type:r,children:this.getStructureNetworkSyncData(this),owner:t}}getStructureNetworkSyncData(e){if(e.getType()==="array"){const t=[];return e.getAllChildrenArray().forEach(r=>{const i=r.getType(),s=i==="structure"||i==="array"?"":r.getValue(),a=r.getPlayerOwnership();r.isUndefinedInContainer()||a===null||t.push({name:"",value:s,type:i,children:this.getStructureNetworkSyncData(r),owner:a})}),t}if(e.getType()==="structure"){const t=e.getAllChildren();if(!t)return;const r=[];return Object.entries(t).forEach(([i,s])=>{const a=s.getType(),o=a==="structure"||a==="array"?"":s.getValue(),h=s.getPlayerOwnership();s.isUndefinedInContainer()||h===null||r.push({name:i,value:o,type:a,children:this.getStructureNetworkSyncData(s),owner:h})}),r}}updateFromNetworkSyncData(e,t){const r=e.owner,i=n.Variable.getVariableDataFromNetworkSyncData(e);if(!(t.shouldExcludeVariableFromUpdate&&t.shouldExcludeVariableFromUpdate(this))){if(!t.ignoreVariableOwnership){const s=n.multiplayer.getCurrentPlayerNumber(),a=this.getPlayerOwnership();if(s===a)return;r&&r!==a&&this.setPlayerOwnership(r)}this.reinitialize(i)}}fromJSObject(e){if(e===null)this.setString("null");else if(typeof e=="number")Number.isNaN(e)?(l.warn("Variables cannot be set to NaN, setting it to 0."),this.setNumber(0)):this.setNumber(e);else if(typeof e=="string")this.setString(e);else if(typeof e!="undefined")if(typeof e=="boolean")this.setBoolean(e);else if(Array.isArray(e)){this.castTo("array"),this.clearChildren();for(const r in e)this.getChild(r).fromJSObject(e[r])}else if(typeof e=="object"){this.castTo("structure"),this.clearChildren();for(var t in e)e.hasOwnProperty(t)&&this.getChild(t).fromJSObject(e[t])}else typeof e=="symbol"?this.setString(e.toString()):typeof e=="bigint"?(e>Number.MAX_SAFE_INTEGER&&l.warn("Error while converting JS variable to GDevelop variable: Integers bigger than "+Number.MAX_SAFE_INTEGER+" aren't supported by GDevelop variables, it will be reduced to that size."),this.setNumber(parseInt(e,10))):typeof e=="function"?l.error("Error while converting JS variable to GDevelop variable: Impossible to set variable value to a function."):l.error("Error while converting JS variable to GDevelop variable: Cannot identify type of object "+e);return this}fromJSON(e){try{var t=JSON.parse(e)}catch(r){return l.error("Unable to parse JSON: "+e+r),this}return this.fromJSObject(t),this}toJSObject(){switch(this._type){case"string":return this.getAsString();case"number":return this.getAsNumber();case"boolean":return this.getAsBoolean();case"structure":const e={};for(const r in this._children)e[r]=this._children[r].toJSObject();return e;case"array":const t=[];for(const r of this._childrenArray)t.push(r===void 0?void 0:r.toJSObject());return t}}isPrimitive(){return n.Variable.isPrimitive(this._type)}clone(){return n.Variable.copy(this,new n.Variable)}setUndefinedInContainer(){this._undefinedInContainer=!0}isUndefinedInContainer(){return this._undefinedInContainer}castTo(e){if(e==="string")this.setString(this.getAsString());else if(e==="number")this.setNumber(this.getAsNumber());else if(e==="boolean")this.setBoolean(this.getAsBoolean());else if(e==="structure"){if(this._type==="structure")return;this._children=this.getAllChildren(),this._type="structure"}else if(e==="array"){if(this._type==="array")return;this._childrenArray=this.getAllChildrenArray(),this._type="array"}}getChild(e){return this._type==="array"?this.getChildAt(Number.isInteger(e)?e:parseInt(e,10)||0):(this._type!=="structure"&&this.castTo("structure"),this.getChildNamed(""+e))}getChildNamed(e){const t=this._children[e];return t??(this._children[e]=new n.Variable)}addChild(e,t){return this._type!=="structure"&&this.castTo("structure"),this._children[e]=t,this}hasChild(e){return this._type==="structure"&&this._children.hasOwnProperty(e)}removeChild(e){this._type==="structure"&&delete this._children[e]}clearChildren(){this._children={},this._childrenArray=[]}replaceChildren(e){this._type="structure",this._children=e}replaceChildrenArray(e){this._type="array",this._childrenArray=e}getAsNumber(){if(this._type!=="number"){let e=0;return this._type==="string"?e=parseFloat(this._str):this._type==="boolean"&&(e=this._bool?1:0),e===e?e:0}return this._value}setNumber(e){this._type="number",e=parseFloat(e),this._value=e===e?e:0}getAsString(){return this._type!=="string"?this._type==="number"?this._value.toString():this._type==="boolean"?this._bool?"true":"false":this._type==="structure"?"[Structure]":this._type==="array"?"[Array]":"":this._str}setString(e){this._type="string",this._str=""+e}getAsNumberOrString(){return this._type==="number"?this._value:this.getAsString()}getAsBoolean(){return this._type!=="boolean"?this._type==="number"?this._value!==0:this._type==="string"?this._str!=="0"&&this._str!==""&&this._str!=="false":!0:this._bool}setBoolean(e){this._type="boolean",this._bool=!!e}toggle(){this.setBoolean(!this.getAsBoolean())}setValue(e){this._type==="string"?this.setString(e):this._type==="number"?this.setNumber(e):this._type==="boolean"&&this.setBoolean(e)}getValue(){return this._type==="number"?this.getAsNumber():this._type==="boolean"?this.getAsBoolean():this.getAsString()}isStructure(){return this._type==="structure"}isNumber(){return this._type==="number"}getType(){return this._type}getAllChildren(){return this._type==="structure"?this._children:this._type==="array"?Object.assign({},this._childrenArray):{}}getAllChildrenArray(){return this._type==="structure"?Object.values(this._children):this._type==="array"?this._childrenArray:[]}getChildrenCount(){return this._type==="structure"?Object.keys(this._children).length:this._type==="array"?this._childrenArray.length:0}add(e){this.setNumber(this.getAsNumber()+e)}sub(e){this.setNumber(this.getAsNumber()-e)}mul(e){this.setNumber(this.getAsNumber()*e)}div(e){this.setNumber(this.getAsNumber()/e)}concatenateString(e){this.setString(this.getAsString()+e)}concatenate(e){this.setString(this.getAsString()+e)}getChildAt(e){return this._type!=="array"&&this.castTo("array"),(this._childrenArray[e]===void 0||this._childrenArray[e]===null)&&(this._childrenArray[e]=new n.Variable),this._childrenArray[e]}removeAtIndex(e){this._type==="array"&&this._childrenArray.splice(e,1)}pushVariableCopy(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e.clone())}_pushVariable(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e)}pushValue(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(new n.Variable({type:typeof e,value:e}))}getPlayerOwnership(){return this._playerNumber}setPlayerOwnership(e){this._playerNumber=e}disableSynchronization(){this._playerNumber=null}}u.getVariableDataFromNetworkSyncData=e=>({name:e.name,value:e.value,type:e.type,children:e.children?e.children.map(t=>n.Variable.getVariableDataFromNetworkSyncData(t)):void 0}),n.Variable=u})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=variable.js.map