gdcore-tools 2.0.0-beta2 → 2.0.0-beta4
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.
- package/dist/Runtime/AsyncTasksManager.js +2 -2
- package/dist/Runtime/AsyncTasksManager.js.map +2 -2
- package/dist/Runtime/Cordova/config.xml +23 -1
- package/dist/Runtime/Cordova/www/LICENSE.GDevelop.txt +2 -0
- package/dist/Runtime/Cordova/www/index.html +1 -1
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObject2D.js +2 -0
- package/dist/Runtime/CustomRuntimeObject2D.js.map +7 -0
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- package/dist/Runtime/Electron/LICENSE.GDevelop.txt +2 -0
- package/dist/Runtime/Electron/package.json +3 -0
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
- package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Base3DBehavior.js +1 -1
- package/dist/Runtime/Extensions/3D/Base3DBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/3D/BloomEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/BloomEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/BrightnessAndContrastEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/BrightnessAndContrastEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +2 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +7 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js +2 -0
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +7 -0
- package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
- package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
- package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/ExposureEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/ExposureEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HueAndSaturationEffect.js +1 -1
- package/dist/Runtime/Extensions/3D/HueAndSaturationEffect.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +56 -24
- package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
- package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/AdMob/JsExtension.js +11 -10
- package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
- package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/BBText/JsExtension.js +20 -11
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/BitmapText/JsExtension.js +2 -8
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/CMakeLists.txt +35 -0
- package/dist/Runtime/Extensions/CMakeUtils.txt +81 -0
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/DialogueTree/bondage.js/version.txt +5 -0
- package/dist/Runtime/Extensions/DraggableBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/hsl-adjustment-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/hsl-adjustment-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/light-night-pixi-filter.js +2 -2
- package/dist/Runtime/Extensions/Effects/light-night-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/motion-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/motion-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/night-pixi-filter.js +2 -2
- package/dist/Runtime/Extensions/Effects/night-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js +1 -1
- package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js.map +2 -2
- package/dist/Runtime/Extensions/FileSystem/JsExtension.js +22 -0
- package/dist/Runtime/Extensions/FileSystem/filesystemtools.js +1 -1
- package/dist/Runtime/Extensions/FileSystem/filesystemtools.js.map +2 -2
- package/dist/Runtime/Extensions/Firebase/A_firebasejs/NOTICE.txt +6 -0
- package/dist/Runtime/Extensions/Inventory/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +13 -4
- package/dist/Runtime/Extensions/Leaderboards/JsExtension.js +42 -1
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
- package/dist/Runtime/Extensions/Lighting/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/LinkedObjects/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js +1 -1
- package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +1130 -0
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/peer.js +10 -0
- package/dist/Runtime/Extensions/Multiplayer/peer.js.map +1 -0
- package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js +2 -0
- package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js.map +7 -0
- package/dist/Runtime/Extensions/Multiplayer/peerjs.d.ts +509 -0
- package/dist/Runtime/Extensions/P2P/A_peer.js +8 -2
- package/dist/Runtime/Extensions/P2P/A_peer.js.map +1 -1
- package/dist/Runtime/Extensions/P2P/B_p2ptools.js +1 -1
- package/dist/Runtime/Extensions/P2P/B_p2ptools.js.map +2 -2
- package/dist/Runtime/Extensions/P2P/JsExtension.js +27 -0
- package/dist/Runtime/Extensions/PanelSpriteObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
- package/dist/Runtime/Extensions/PathfindingBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +47 -4
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PhysicsBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PlatformBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PlayerAuthentication/JsExtension.js +6 -3
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js +4 -4
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js.map +2 -2
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
- package/dist/Runtime/Extensions/PrimitiveDrawing/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Shopify/CMakeLists.txt +26 -0
- package/dist/Runtime/Extensions/Spine/CMakeLists.txt +20 -0
- package/dist/Runtime/Extensions/Spine/JsExtension.js +11 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/pixi-spine/Spine-Runtimes-License-Agreement.txt +11 -0
- package/dist/Runtime/Extensions/Spine/pixi-spine/pixi-spine.js +5 -3
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/SystemInfo/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextEntryObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +3 -10
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/JsExtension.js +834 -23
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.d.ts +2 -0
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/CommonTypes.d.ts +12 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/CommonTypes.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +119 -5
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts +25 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +16 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +2 -0
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +7 -0
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TiledSpriteObject/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TopDownMovementBehavior/CMakeLists.txt +23 -0
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Video/JsExtension.js +2 -11
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/SpriteAnimator.js +2 -0
- package/dist/Runtime/SpriteAnimator.js.map +7 -0
- package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/events-tools/objecttools.js +1 -1
- package/dist/Runtime/events-tools/objecttools.js.map +2 -2
- package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
- package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
- package/dist/Runtime/force.js +1 -1
- package/dist/Runtime/force.js.map +2 -2
- package/dist/Runtime/object-capabilities/TextContainerBehavior.js.map +1 -1
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +2 -0
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +7 -0
- package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js +1 -1
- package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js +2 -2
- package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/polygon.js +1 -1
- package/dist/Runtime/polygon.js.map +2 -2
- package/dist/Runtime/runtimebehavior.js +1 -1
- package/dist/Runtime/runtimebehavior.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimeobject.js +1 -1
- package/dist/Runtime/runtimeobject.js.map +2 -2
- package/dist/Runtime/runtimescene.js +1 -1
- package/dist/Runtime/runtimescene.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/Runtime/timer.js +1 -1
- package/dist/Runtime/timer.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +115 -0
- package/dist/Runtime/variable.js +1 -1
- package/dist/Runtime/variable.js.map +2 -2
- package/dist/Runtime/variablescontainer.js +1 -1
- package/dist/Runtime/variablescontainer.js.map +2 -2
- package/dist/lib/libGD.cjs +2 -1
- package/dist/lib/libGD.wasm +0 -0
- package/dist/loaders.cjs +2 -1
- package/gd.d.ts +217 -223
- package/package.json +15 -7
- package/src/index.js +2 -0
- package/src/open_project.js +1 -1
- package/types/index.d.ts +2 -2
- package/types/open_project.d.ts +5 -5
- package/dist/Runtime/Extensions/Spine/pixi-spine/pixi-spine.js.map +0 -7
- package/dist/Runtime/pixi-renderers/CustomObjectPixiRenderer.js +0 -2
- package/dist/Runtime/pixi-renderers/CustomObjectPixiRenderer.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/RuntimeInstanceContainer.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('RuntimeInstanceContainer');\n\n /**\n * A container of object instances rendered on screen.\n */\n export abstract class RuntimeInstanceContainer {\n _initialBehaviorSharedData: Hashtable<BehaviorSharedData | null>;\n\n /** Contains the instances living on the container */\n _instances: Hashtable<RuntimeObject[]>;\n\n /**\n * An array used to create a list of all instance when necessary.\n * @see gdjs.RuntimeInstanceContainer#_constructListOfAllInstances}\n */\n private _allInstancesList: gdjs.RuntimeObject[] = [];\n _allInstancesListIsUpToDate = true;\n\n /** Used to recycle destroyed instance instead of creating new ones. */\n _instancesCache: Hashtable<RuntimeObject[]>;\n\n /** The instances removed from the container and waiting to be sent to the cache. */\n _instancesRemoved: gdjs.RuntimeObject[] = [];\n\n /** Contains the objects data stored in the project */\n _objects: Hashtable<ObjectData>;\n _objectsCtor: Hashtable<typeof RuntimeObject>;\n\n _layers: Hashtable<RuntimeLayer>;\n _orderedLayers: RuntimeLayer[]; // TODO: should this be a single structure with _layers, to enforce its usage?\n _layersCameraCoordinates: Record<string, [float, float, float, float]> = {};\n\n // Options for the debug draw:\n _debugDrawEnabled: boolean = false;\n _debugDrawShowHiddenInstances: boolean = false;\n _debugDrawShowPointsNames: boolean = false;\n _debugDrawShowCustomPoints: boolean = false;\n\n constructor() {\n this._initialBehaviorSharedData = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objects = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._layers = new Hashtable();\n this._orderedLayers = [];\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n abstract getElapsedTime(): float;\n\n /**\n * Get the renderer associated to the container.\n */\n abstract getRenderer(): gdjs.RuntimeInstanceContainerRenderer;\n\n /**\n * Get the renderer for visual debugging associated to the container.\n */\n abstract getDebuggerRenderer(): gdjs.DebuggerRenderer;\n\n /**\n * Get the {@link gdjs.RuntimeGame} associated to this.\n */\n abstract getGame(): gdjs.RuntimeGame;\n\n /**\n * Get the {@link gdjs.RuntimeScene} associated to this.\n */\n abstract getScene(): gdjs.RuntimeScene;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(x: float, y: float, result?: FloatPoint): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param sceneX The x position, in container coordinates.\n * @param sceneY The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * @return the width of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportWidth(): float;\n\n /**\n * @return the height of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportHeight(): float;\n\n /**\n * @return the center X of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginX(): float;\n\n /**\n * @return the center Y of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginY(): float;\n\n /**\n * Triggered when the AABB of a child of the container could have changed.\n */\n abstract onChildrenLocationChanged(): void;\n\n /**\n * Activate or deactivate the debug visualization for collisions and points.\n */\n enableDebugDraw(\n enableDebugDraw: boolean,\n showHiddenInstances: boolean,\n showPointsNames: boolean,\n showCustomPoints: boolean\n ): void {\n if (this._debugDrawEnabled && !enableDebugDraw) {\n this.getDebuggerRenderer().clearDebugDraw();\n }\n\n this._debugDrawEnabled = enableDebugDraw;\n this._debugDrawShowHiddenInstances = showHiddenInstances;\n this._debugDrawShowPointsNames = showPointsNames;\n this._debugDrawShowCustomPoints = showCustomPoints;\n }\n\n /**\n * Check if an object is registered, meaning that instances of it can be\n * created and lives in the container.\n * @see gdjs.RuntimeInstanceContainer#registerObject\n */\n isObjectRegistered(objectName: string): boolean {\n return (\n this._objects.containsKey(objectName) &&\n this._instances.containsKey(objectName) &&\n this._objectsCtor.containsKey(objectName)\n );\n }\n\n /**\n * Register a {@link gdjs.RuntimeObject} so that instances of it can be\n * used in the container.\n * @param objectData The data for the object to register.\n */\n registerObject(objectData: ObjectData) {\n this._objects.put(objectData.name, objectData);\n this._instances.put(objectData.name, []);\n\n // Cache the constructor\n const Ctor = gdjs.getObjectConstructor(objectData.type);\n this._objectsCtor.put(objectData.name, Ctor);\n\n // Also prepare a cache for recycled instances, if the object supports it.\n if (Ctor.supportsReinitialization) {\n this._instancesCache.put(objectData.name, []);\n }\n }\n\n /**\n * Update the data of a {@link gdjs.RuntimeObject} so that instances use\n * this when constructed.\n * @param objectData The data for the object to register.\n */\n updateObject(objectData: ObjectData): void {\n if (!this.isObjectRegistered(objectData.name)) {\n logger.warn(\n 'Tried to call updateObject for an object that was not registered (' +\n objectData.name +\n '). Call registerObject first.'\n );\n }\n this._objects.put(objectData.name, objectData);\n }\n\n // Don't erase instances, nor instances cache, or objectsCtor cache.\n /**\n * Unregister a {@link gdjs.RuntimeObject}. Instances will be destroyed.\n * @param objectName The name of the object to unregister.\n */\n unregisterObject(objectName: string) {\n const instances = this._instances.get(objectName);\n if (instances) {\n // This is sub-optimal: markObjectForDeletion will search the instance to\n // remove in instances, so cost is O(n^2), n being the number of instances.\n // As we're unregistering an object which only happen during a hot-reloading,\n // this is fine.\n const instancesToRemove = instances.slice();\n for (let i = 0; i < instancesToRemove.length; i++) {\n this.markObjectForDeletion(instancesToRemove[i]);\n }\n this._cacheOrClearRemovedInstances();\n }\n this._objects.remove(objectName);\n this._instances.remove(objectName);\n this._instancesCache.remove(objectName);\n this._objectsCtor.remove(objectName);\n }\n\n /**\n * Create objects from initial instances data (for example, the initial instances\n * of the scene or the instances of an external layout).\n *\n * @param data The instances data\n * @param xPos The offset on X axis\n * @param yPos The offset on Y axis\n * @param zPos The offset on Z axis\n * @param trackByPersistentUuid If true, objects are tracked by setting their `persistentUuid`\n * to the same as the associated instance. Useful for hot-reloading when instances are changed.\n */\n createObjectsFrom(\n data: InstanceData[],\n xPos: float,\n yPos: float,\n zPos: float,\n trackByPersistentUuid: boolean\n ): void {\n let zOffset: number;\n let shouldTrackByPersistentUuid: boolean;\n\n if (arguments.length === 5) {\n zOffset = zPos;\n shouldTrackByPersistentUuid = trackByPersistentUuid;\n } else {\n /**\n * Support for the previous signature (before 3D was introduced):\n * createObjectsFrom(data, xPos, yPos, trackByPersistentUuid)\n */\n zOffset = 0;\n shouldTrackByPersistentUuid = arguments[3];\n }\n\n for (let i = 0, len = data.length; i < len; ++i) {\n const instanceData = data[i];\n const objectName = instanceData.name;\n const newObject = this.createObject(objectName);\n if (newObject !== null) {\n if (shouldTrackByPersistentUuid) {\n // Give the object the same persistentUuid as the instance, so that\n // it can be hot-reloaded.\n newObject.persistentUuid = instanceData.persistentUuid || null;\n }\n newObject.setPosition(instanceData.x + xPos, instanceData.y + yPos);\n newObject.setAngle(instanceData.angle);\n if (\n gdjs.RuntimeObject3D &&\n newObject instanceof gdjs.RuntimeObject3D\n ) {\n if (instanceData.z !== undefined)\n newObject.setZ(instanceData.z + zOffset);\n if (instanceData.rotationX !== undefined)\n newObject.setRotationX(instanceData.rotationX);\n if (instanceData.rotationY !== undefined)\n newObject.setRotationY(instanceData.rotationY);\n }\n\n newObject.setZOrder(instanceData.zOrder);\n newObject.setLayer(instanceData.layer);\n newObject\n .getVariables()\n .initFrom(instanceData.initialVariables, true);\n newObject.extraInitializationFromInitialInstance(instanceData);\n }\n }\n }\n\n /**\n * Get the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @returns The shared data for the behavior, if any.\n */\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n return this._initialBehaviorSharedData.get(name);\n }\n\n /**\n * Set the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @param sharedData The shared data for the behavior, or null to remove it.\n */\n setInitialSharedDataForBehavior(\n name: string,\n sharedData: BehaviorSharedData | null\n ): void {\n this._initialBehaviorSharedData.put(name, sharedData);\n }\n\n /**\n * Set the default Z order for each layer, which is the highest Z order found on each layer.\n * Useful as it ensures that instances created from events are, by default, shown in front\n * of other instances.\n */\n _setLayerDefaultZOrders() {\n if (\n this.getGame().getGameData().properties.useDeprecatedZeroAsDefaultZOrder\n ) {\n // Deprecated option to still support games that were made considered 0 as the\n // default Z order for all layers.\n return;\n }\n const layerHighestZOrders: Record<string, number> = {};\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n const object = allInstances[i];\n let layerName = object.getLayer();\n const zOrder = object.getZOrder();\n if (\n layerHighestZOrders[layerName] === undefined ||\n layerHighestZOrders[layerName] < zOrder\n ) {\n layerHighestZOrders[layerName] = zOrder;\n }\n }\n for (let layerName in layerHighestZOrders) {\n this.getLayer(layerName).setDefaultZOrder(\n layerHighestZOrders[layerName] + 1\n );\n }\n }\n\n _updateLayersCameraCoordinates(scale: float) {\n this._layersCameraCoordinates = this._layersCameraCoordinates || {};\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer = this._layers.items[name];\n this._layersCameraCoordinates[name] = this._layersCameraCoordinates[\n name\n ] || [0, 0, 0, 0];\n this._layersCameraCoordinates[name][0] =\n theLayer.getCameraX() - (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][1] =\n theLayer.getCameraY() - (theLayer.getCameraHeight() / 2) * scale;\n this._layersCameraCoordinates[name][2] =\n theLayer.getCameraX() + (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][3] =\n theLayer.getCameraY() + (theLayer.getCameraHeight() / 2) * scale;\n }\n }\n }\n\n /**\n * Called to update effects of layers before rendering.\n */\n _updateLayersPreRender() {\n for (const layer of this._orderedLayers) {\n layer.updatePreRender(this);\n }\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Empty the list of the removed objects:\n *\n * When an object is removed from the container, it is still kept in\n * {@link gdjs.RuntimeInstanceContainer#_instancesRemoved}.\n *\n * This method should be called regularly (after events or behaviors steps) so as to clear this list\n * and allows the removed objects to be cached (or destroyed if the cache is full).\n *\n * The removed objects could not be sent directly to the cache, as events may still be using them after\n * removing them from the scene for example.\n */\n _cacheOrClearRemovedInstances() {\n for (let k = 0, lenk = this._instancesRemoved.length; k < lenk; ++k) {\n const instance = this._instancesRemoved[k];\n // Cache the instance to recycle it into a new instance later.\n // If the object does not support recycling, the cache won't be defined.\n const cache = this._instancesCache.get(instance.getName());\n if (cache) {\n if (cache.length < 128) {\n cache.push(instance);\n }\n }\n instance.onDestroyed();\n }\n this._instancesRemoved.length = 0;\n }\n\n /**\n * Tool function filling _allInstancesList member with all the living object instances.\n */\n private _constructListOfAllInstances() {\n let currentListSize = 0;\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n const oldSize = currentListSize;\n currentListSize += list.length;\n for (let j = 0, lenj = list.length; j < lenj; ++j) {\n if (oldSize + j < this._allInstancesList.length) {\n this._allInstancesList[oldSize + j] = list[j];\n } else {\n this._allInstancesList.push(list[j]);\n }\n }\n }\n }\n this._allInstancesList.length = currentListSize;\n this._allInstancesListIsUpToDate = true;\n }\n\n /**\n * @param objectName The name of the object\n * @returns the instances of a given object in the container.\n */\n getInstancesOf(objectName: string): gdjs.RuntimeObject[] {\n return this._instances.items[objectName];\n }\n\n /**\n * Get a list of all {@link gdjs.RuntimeObject} living in the container.\n * You should not, normally, need this method at all. It's only to be used\n * in exceptional use cases where you need to loop through all objects,\n * and it won't be performant.\n *\n * @returns The list of all runtime objects in the container\n */\n getAdhocListOfAllInstances(): gdjs.RuntimeObject[] {\n if (!this._allInstancesListIsUpToDate) {\n this._constructListOfAllInstances();\n }\n return this._allInstancesList;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n allInstancesList[i].stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Update the objects (update positions, time management...)\n */\n _updateObjectsPostEvents() {\n this._cacheOrClearRemovedInstances();\n\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n allInstancesList[i].stepBehaviorsPostEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Add an object to the instances living in the container.\n * @param obj The object to be added.\n */\n addObject(obj: gdjs.RuntimeObject) {\n if (!this._instances.containsKey(obj.name)) {\n this._instances.put(obj.name, []);\n }\n this._instances.get(obj.name).push(obj);\n this._allInstancesListIsUpToDate = false;\n }\n\n /**\n * Get all the instances of the object called name.\n * @param name Name of the object for which the instances must be returned.\n * @return The list of objects with the given name\n */\n getObjects(name: string): gdjs.RuntimeObject[] | undefined {\n if (!this._instances.containsKey(name)) {\n logger.info(\n 'RuntimeScene.getObjects: No instances called \"' +\n name +\n '\"! Adding it.'\n );\n this._instances.put(name, []);\n }\n return this._instances.get(name);\n }\n\n /**\n * Create a new object from its name. The object is also added to the instances\n * living in the container (No need to call {@link gdjs.RuntimeScene.addObject})\n * @param objectName The name of the object to be created\n * @return The created object\n */\n createObject(objectName: string): gdjs.RuntimeObject | null {\n if (\n !this._objectsCtor.containsKey(objectName) ||\n !this._objects.containsKey(objectName)\n ) {\n // There is no such object in this container.\n return null;\n }\n\n // Create a new object using the object constructor (cached during loading)\n // and the stored object's data:\n const cache = this._instancesCache.get(objectName);\n const ctor = this._objectsCtor.get(objectName);\n let obj;\n if (!cache || cache.length === 0) {\n obj = new ctor(this, this._objects.get(objectName));\n } else {\n // Reuse an objet destroyed before. If there is an object in the cache,\n // then it means it does support reinitialization.\n obj = cache.pop();\n obj.reinitialize(this._objects.get(objectName));\n }\n this.addObject(obj);\n return obj;\n }\n\n /**\n * Must be called whenever an object must be removed from the container.\n * @param obj The object to be removed.\n */\n markObjectForDeletion(obj: gdjs.RuntimeObject) {\n // Add to the objects removed list.\n // The objects will be sent to the instances cache or really deleted from memory later.\n if (this._instancesRemoved.indexOf(obj) === -1) {\n this._instancesRemoved.push(obj);\n }\n\n // Delete from the living instances.\n if (this._instances.containsKey(obj.getName())) {\n const objId = obj.id;\n const allInstances = this._instances.get(obj.getName());\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n if (allInstances[i].id == objId) {\n allInstances.splice(i, 1);\n this._allInstancesListIsUpToDate = false;\n break;\n }\n }\n }\n\n // Notify the object it was removed from the container\n obj.onDeletedFromScene(this);\n\n // Notify the global callbacks\n for (let j = 0; j < gdjs.callbacksObjectDeletedFromScene.length; ++j) {\n gdjs.callbacksObjectDeletedFromScene[j](this, obj);\n }\n return;\n }\n\n /**\n * Get the layer with the given name\n * @param name The name of the layer\n * @returns The layer, or the base layer if not found\n */\n getLayer(name: string): gdjs.RuntimeLayer {\n if (this._layers.containsKey(name)) {\n return this._layers.get(name);\n }\n return this._layers.get('');\n }\n\n /**\n * Check if a layer exists\n * @param name The name of the layer\n */\n hasLayer(name: string): boolean {\n return this._layers.containsKey(name);\n }\n\n /**\n * Add a layer.\n * @param layerData The data to construct the layer\n */\n abstract addLayer(layerData: LayerData);\n\n /**\n * Remove a layer. All {@link gdjs.RuntimeObject} on this layer will\n * be moved back to the base layer.\n * @param layerName The name of the layer to remove\n */\n removeLayer(layerName: string) {\n const existingLayer = this._layers.get(layerName);\n if (!existingLayer) return;\n\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0; i < allInstances.length; ++i) {\n const runtimeObject = allInstances[i];\n if (runtimeObject.getLayer() === layerName) {\n runtimeObject.setLayer('');\n }\n }\n this._layers.remove(layerName);\n const layerIndex = this._orderedLayers.indexOf(existingLayer);\n this._orderedLayers.splice(layerIndex, 1);\n }\n\n /**\n * Change the position of a layer.\n *\n * @param layerName The name of the layer to reorder\n * @param index The new position in the list of layers\n */\n setLayerIndex(layerName: string, newIndex: integer): void {\n const layer: gdjs.RuntimeLayer = this._layers.get(layerName);\n if (!layer) {\n return;\n }\n const layerIndex = this._orderedLayers.indexOf(layer);\n if (layerIndex === newIndex) return;\n\n this._orderedLayers.splice(layerIndex, 1);\n this._orderedLayers.splice(newIndex, 0, layer);\n\n this.getRenderer().setLayerIndex(layer, newIndex);\n }\n\n /**\n * Fill the array passed as argument with the names of all layers\n * @param result The array where to put the layer names\n */\n getAllLayerNames(result: string[]) {\n this._layers.keys(result);\n }\n\n /**\n * Return the number of instances of the specified object living in the container.\n * @param objectName The object name for which instances must be counted.\n */\n getInstancesCountOnScene(objectName: string): integer {\n const instances = this._instances.get(objectName);\n if (instances) {\n return instances.length;\n }\n\n return 0;\n }\n\n /**\n * Update the objects positions according to their forces\n */\n updateObjectsForces(): void {\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n for (let j = 0, listLen = list.length; j < listLen; ++j) {\n const obj = list[j];\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = obj.getElapsedTime() / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.updateForces(elapsedTimeInSeconds);\n }\n }\n }\n }\n }\n\n /**\n * Clear any data structures to make sure memory is freed as soon as\n * possible.\n */\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n this._layers = new Hashtable();\n this._orderedLayers = [];\n this._objects = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._allInstancesList = [];\n this._instancesRemoved = [];\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,4BAKxB,OAAwC,CAiC7C,aAAc,CAvBN,uBAA0C,GAClD,iCAA8B,GAM9B,uBAA0C,GAQ1C,8BAA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EACV,EAA8B,GAM9B,GAAU,EACV,EAA8B,UAAU,IAG1C,OAAS,GAAI,EAAG,EAAM,EAAK,OAAQ,EAAI,EAAK,EAAE,EAAG,CAC/C,KAAM,GAAe,EAAK,GACpB,EAAa,EAAa,KAC1B,EAAY,KAAK,aAAa,GACpC,AAAI,IAAc,MACZ,IAGF,GAAU,eAAiB,EAAa,gBAAkB,MAE5D,EAAU,YAAY,EAAa,EAAI,EAAM,EAAa,EAAI,GAC9D,EAAU,SAAS,EAAa,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('RuntimeInstanceContainer');\n\n /**\n * A container of object instances rendered on screen.\n */\n export abstract class RuntimeInstanceContainer {\n _initialBehaviorSharedData: Hashtable<BehaviorSharedData | null>;\n\n /** Contains the instances living on the container */\n _instances: Hashtable<RuntimeObject[]>;\n\n /**\n * An array used to create a list of all instance when necessary.\n * @see gdjs.RuntimeInstanceContainer#_constructListOfAllInstances}\n */\n private _allInstancesList: gdjs.RuntimeObject[] = [];\n _allInstancesListIsUpToDate = true;\n\n /** Used to recycle destroyed instance instead of creating new ones. */\n _instancesCache: Hashtable<RuntimeObject[]>;\n\n /** The instances removed from the container and waiting to be sent to the cache. */\n _instancesRemoved: gdjs.RuntimeObject[] = [];\n\n /** Contains the objects data stored in the project */\n _objects: Hashtable<ObjectData>;\n _objectsCtor: Hashtable<typeof RuntimeObject>;\n\n _layers: Hashtable<RuntimeLayer>;\n _orderedLayers: RuntimeLayer[]; // TODO: should this be a single structure with _layers, to enforce its usage?\n _layersCameraCoordinates: Record<string, [float, float, float, float]> = {};\n\n // Options for the debug draw:\n _debugDrawEnabled: boolean = false;\n _debugDrawShowHiddenInstances: boolean = false;\n _debugDrawShowPointsNames: boolean = false;\n _debugDrawShowCustomPoints: boolean = false;\n\n constructor() {\n this._initialBehaviorSharedData = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objects = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._layers = new Hashtable();\n this._orderedLayers = [];\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n abstract getElapsedTime(): float;\n\n /**\n * Get the renderer associated to the container.\n */\n abstract getRenderer(): gdjs.RuntimeInstanceContainerRenderer;\n\n /**\n * Get the renderer for visual debugging associated to the container.\n */\n abstract getDebuggerRenderer(): gdjs.DebuggerRenderer;\n\n /**\n * Get the {@link gdjs.RuntimeGame} associated to this.\n */\n abstract getGame(): gdjs.RuntimeGame;\n\n /**\n * Get the {@link gdjs.RuntimeScene} associated to this.\n */\n abstract getScene(): gdjs.RuntimeScene;\n\n /**\n * Convert a point from the canvas coordinates (for example,\n * the mouse position) to the container coordinates.\n *\n * @param x The x position, in container coordinates.\n * @param y The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertCoords(x: float, y: float, result?: FloatPoint): FloatPoint;\n\n /**\n * Convert a point from the container coordinates (for example,\n * an object position) to the canvas coordinates.\n *\n * @param sceneX The x position, in container coordinates.\n * @param sceneY The y position, in container coordinates.\n * @param result The point instance that is used to return the result.\n */\n abstract convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint;\n\n /**\n * @return the width of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportWidth(): float;\n\n /**\n * @return the height of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportHeight(): float;\n\n /**\n * @return the center X of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginX(): float;\n\n /**\n * @return the center Y of:\n * - the game resolution for a {@link gdjs.RuntimeScene}\n * - the default dimensions (the AABB of all its children) for a\n * {@link gdjs.CustomRuntimeObject}.\n */\n abstract getViewportOriginY(): float;\n\n /**\n * Triggered when the AABB of a child of the container could have changed.\n */\n abstract onChildrenLocationChanged(): void;\n\n /**\n * Activate or deactivate the debug visualization for collisions and points.\n */\n enableDebugDraw(\n enableDebugDraw: boolean,\n showHiddenInstances: boolean,\n showPointsNames: boolean,\n showCustomPoints: boolean\n ): void {\n if (this._debugDrawEnabled && !enableDebugDraw) {\n this.getDebuggerRenderer().clearDebugDraw();\n }\n\n this._debugDrawEnabled = enableDebugDraw;\n this._debugDrawShowHiddenInstances = showHiddenInstances;\n this._debugDrawShowPointsNames = showPointsNames;\n this._debugDrawShowCustomPoints = showCustomPoints;\n }\n\n /**\n * Check if an object is registered, meaning that instances of it can be\n * created and lives in the container.\n * @see gdjs.RuntimeInstanceContainer#registerObject\n */\n isObjectRegistered(objectName: string): boolean {\n return (\n this._objects.containsKey(objectName) &&\n this._instances.containsKey(objectName) &&\n this._objectsCtor.containsKey(objectName)\n );\n }\n\n /**\n * Register a {@link gdjs.RuntimeObject} so that instances of it can be\n * used in the container.\n * @param objectData The data for the object to register.\n */\n registerObject(objectData: ObjectData) {\n this._objects.put(objectData.name, objectData);\n this._instances.put(objectData.name, []);\n\n // Cache the constructor\n const Ctor = gdjs.getObjectConstructor(objectData.type);\n this._objectsCtor.put(objectData.name, Ctor);\n\n // Also prepare a cache for recycled instances, if the object supports it.\n if (Ctor.supportsReinitialization) {\n this._instancesCache.put(objectData.name, []);\n }\n }\n\n /**\n * Update the data of a {@link gdjs.RuntimeObject} so that instances use\n * this when constructed.\n * @param objectData The data for the object to register.\n */\n updateObject(objectData: ObjectData): void {\n if (!this.isObjectRegistered(objectData.name)) {\n logger.warn(\n 'Tried to call updateObject for an object that was not registered (' +\n objectData.name +\n '). Call registerObject first.'\n );\n }\n this._objects.put(objectData.name, objectData);\n }\n\n // Don't erase instances, nor instances cache, or objectsCtor cache.\n /**\n * Unregister a {@link gdjs.RuntimeObject}. Instances will be destroyed.\n * @param objectName The name of the object to unregister.\n */\n unregisterObject(objectName: string) {\n const instances = this._instances.get(objectName);\n if (instances) {\n // This is sub-optimal: markObjectForDeletion will search the instance to\n // remove in instances, so cost is O(n^2), n being the number of instances.\n // As we're unregistering an object which only happen during a hot-reloading,\n // this is fine.\n const instancesToRemove = instances.slice();\n for (let i = 0; i < instancesToRemove.length; i++) {\n this.markObjectForDeletion(instancesToRemove[i]);\n }\n this._cacheOrClearRemovedInstances();\n }\n this._objects.remove(objectName);\n this._instances.remove(objectName);\n this._instancesCache.remove(objectName);\n this._objectsCtor.remove(objectName);\n }\n\n /**\n * Create objects from initial instances data (for example, the initial instances\n * of the scene or the instances of an external layout).\n *\n * @param data The instances data\n * @param xPos The offset on X axis\n * @param yPos The offset on Y axis\n * @param zPos The offset on Z axis\n * @param trackByPersistentUuid If true, objects are tracked by setting their `persistentUuid`\n * to the same as the associated instance. Useful for hot-reloading when instances are changed.\n */\n createObjectsFrom(\n data: InstanceData[],\n xPos: float,\n yPos: float,\n zPos: float,\n trackByPersistentUuid: boolean\n ): void {\n let zOffset: number;\n let shouldTrackByPersistentUuid: boolean;\n\n if (arguments.length === 5) {\n zOffset = zPos;\n shouldTrackByPersistentUuid = trackByPersistentUuid;\n } else {\n /**\n * Support for the previous signature (before 3D was introduced):\n * createObjectsFrom(data, xPos, yPos, trackByPersistentUuid)\n */\n zOffset = 0;\n shouldTrackByPersistentUuid = arguments[3];\n }\n\n for (let i = 0, len = data.length; i < len; ++i) {\n const instanceData = data[i];\n const objectName = instanceData.name;\n const newObject = this.createObject(objectName);\n if (newObject !== null) {\n if (shouldTrackByPersistentUuid) {\n // Give the object the same persistentUuid as the instance, so that\n // it can be hot-reloaded.\n newObject.persistentUuid = instanceData.persistentUuid || null;\n }\n newObject.setPosition(instanceData.x + xPos, instanceData.y + yPos);\n newObject.setAngle(instanceData.angle);\n if (gdjs.Base3DHandler && gdjs.Base3DHandler.is3D(newObject)) {\n if (instanceData.z !== undefined)\n newObject.setZ(instanceData.z + zOffset);\n if (instanceData.rotationX !== undefined)\n newObject.setRotationX(instanceData.rotationX);\n if (instanceData.rotationY !== undefined)\n newObject.setRotationY(instanceData.rotationY);\n }\n\n newObject.setZOrder(instanceData.zOrder);\n newObject.setLayer(instanceData.layer);\n newObject\n .getVariables()\n .initFrom(instanceData.initialVariables, true);\n newObject.extraInitializationFromInitialInstance(instanceData);\n }\n }\n }\n\n /**\n * Get the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @returns The shared data for the behavior, if any.\n */\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n return this._initialBehaviorSharedData.get(name);\n }\n\n /**\n * Set the data representing the initial shared data of the scene for the specified behavior.\n * @param name The name of the behavior\n * @param sharedData The shared data for the behavior, or null to remove it.\n */\n setInitialSharedDataForBehavior(\n name: string,\n sharedData: BehaviorSharedData | null\n ): void {\n this._initialBehaviorSharedData.put(name, sharedData);\n }\n\n /**\n * Set the default Z order for each layer, which is the highest Z order found on each layer.\n * Useful as it ensures that instances created from events are, by default, shown in front\n * of other instances.\n */\n _setLayerDefaultZOrders() {\n if (\n this.getGame().getGameData().properties.useDeprecatedZeroAsDefaultZOrder\n ) {\n // Deprecated option to still support games that were made considered 0 as the\n // default Z order for all layers.\n return;\n }\n const layerHighestZOrders: Record<string, number> = {};\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n const object = allInstances[i];\n let layerName = object.getLayer();\n const zOrder = object.getZOrder();\n if (\n layerHighestZOrders[layerName] === undefined ||\n layerHighestZOrders[layerName] < zOrder\n ) {\n layerHighestZOrders[layerName] = zOrder;\n }\n }\n for (let layerName in layerHighestZOrders) {\n this.getLayer(layerName).setDefaultZOrder(\n layerHighestZOrders[layerName] + 1\n );\n }\n }\n\n _updateLayersCameraCoordinates(scale: float) {\n this._layersCameraCoordinates = this._layersCameraCoordinates || {};\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer = this._layers.items[name];\n this._layersCameraCoordinates[name] = this._layersCameraCoordinates[\n name\n ] || [0, 0, 0, 0];\n this._layersCameraCoordinates[name][0] =\n theLayer.getCameraX() - (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][1] =\n theLayer.getCameraY() - (theLayer.getCameraHeight() / 2) * scale;\n this._layersCameraCoordinates[name][2] =\n theLayer.getCameraX() + (theLayer.getCameraWidth() / 2) * scale;\n this._layersCameraCoordinates[name][3] =\n theLayer.getCameraY() + (theLayer.getCameraHeight() / 2) * scale;\n }\n }\n }\n\n /**\n * Called to update effects of layers before rendering.\n */\n _updateLayersPreRender() {\n for (const layer of this._orderedLayers) {\n layer.updatePreRender(this);\n }\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Empty the list of the removed objects:\n *\n * When an object is removed from the container, it is still kept in\n * {@link gdjs.RuntimeInstanceContainer#_instancesRemoved}.\n *\n * This method should be called regularly (after events or behaviors steps) so as to clear this list\n * and allows the removed objects to be cached (or destroyed if the cache is full).\n *\n * The removed objects could not be sent directly to the cache, as events may still be using them after\n * removing them from the scene for example.\n */\n _cacheOrClearRemovedInstances() {\n for (let k = 0, lenk = this._instancesRemoved.length; k < lenk; ++k) {\n const instance = this._instancesRemoved[k];\n // Cache the instance to recycle it into a new instance later.\n // If the object does not support recycling, the cache won't be defined.\n const cache = this._instancesCache.get(instance.getName());\n if (cache) {\n if (cache.length < 128) {\n cache.push(instance);\n }\n }\n instance.onDestroyed();\n }\n this._instancesRemoved.length = 0;\n }\n\n /**\n * Tool function filling _allInstancesList member with all the living object instances.\n */\n private _constructListOfAllInstances() {\n let currentListSize = 0;\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n const oldSize = currentListSize;\n currentListSize += list.length;\n for (let j = 0, lenj = list.length; j < lenj; ++j) {\n if (oldSize + j < this._allInstancesList.length) {\n this._allInstancesList[oldSize + j] = list[j];\n } else {\n this._allInstancesList.push(list[j]);\n }\n }\n }\n }\n this._allInstancesList.length = currentListSize;\n this._allInstancesListIsUpToDate = true;\n }\n\n /**\n * @param objectName The name of the object\n * @returns the instances of a given object in the container.\n */\n getInstancesOf(objectName: string): gdjs.RuntimeObject[] {\n return this._instances.items[objectName];\n }\n\n /**\n * Get a list of all {@link gdjs.RuntimeObject} living in the container.\n * You should not, normally, need this method at all. It's only to be used\n * in exceptional use cases where you need to loop through all objects,\n * and it won't be performant.\n *\n * @returns The list of all runtime objects in the container\n */\n getAdhocListOfAllInstances(): gdjs.RuntimeObject[] {\n if (!this._allInstancesListIsUpToDate) {\n this._constructListOfAllInstances();\n }\n return this._allInstancesList;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n allInstancesList[i].stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Update the objects (update positions, time management...)\n */\n _updateObjectsPostEvents() {\n this._cacheOrClearRemovedInstances();\n\n // It is *mandatory* to create and iterate on a external list of all objects, as the behaviors\n // may delete the objects.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n allInstancesList[i].stepBehaviorsPostEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Add an object to the instances living in the container.\n * @param obj The object to be added.\n */\n addObject(obj: gdjs.RuntimeObject) {\n if (!this._instances.containsKey(obj.name)) {\n this._instances.put(obj.name, []);\n }\n this._instances.get(obj.name).push(obj);\n this._allInstancesListIsUpToDate = false;\n }\n\n /**\n * Get all the instances of the object called name.\n * @param name Name of the object for which the instances must be returned.\n * @return The list of objects with the given name\n */\n getObjects(name: string): gdjs.RuntimeObject[] | undefined {\n if (!this._instances.containsKey(name)) {\n logger.info(\n 'RuntimeScene.getObjects: No instances called \"' +\n name +\n '\"! Adding it.'\n );\n this._instances.put(name, []);\n }\n return this._instances.get(name);\n }\n\n /**\n * Create a new object from its name. The object is also added to the instances\n * living in the container (No need to call {@link gdjs.RuntimeScene.addObject})\n * @param objectName The name of the object to be created\n * @return The created object\n */\n createObject(objectName: string): gdjs.RuntimeObject | null {\n if (\n !this._objectsCtor.containsKey(objectName) ||\n !this._objects.containsKey(objectName)\n ) {\n // There is no such object in this container.\n return null;\n }\n\n // Create a new object using the object constructor (cached during loading)\n // and the stored object's data:\n const cache = this._instancesCache.get(objectName);\n const ctor = this._objectsCtor.get(objectName);\n let obj;\n if (!cache || cache.length === 0) {\n obj = new ctor(this, this._objects.get(objectName));\n } else {\n // Reuse an objet destroyed before. If there is an object in the cache,\n // then it means it does support reinitialization.\n obj = cache.pop();\n obj.reinitialize(this._objects.get(objectName));\n }\n this.addObject(obj);\n return obj;\n }\n\n /**\n * Must be called whenever an object must be removed from the container.\n * @param obj The object to be removed.\n */\n markObjectForDeletion(obj: gdjs.RuntimeObject) {\n // Add to the objects removed list.\n // The objects will be sent to the instances cache or really deleted from memory later.\n if (this._instancesRemoved.indexOf(obj) === -1) {\n this._instancesRemoved.push(obj);\n }\n\n // Delete from the living instances.\n if (this._instances.containsKey(obj.getName())) {\n const objId = obj.id;\n const allInstances = this._instances.get(obj.getName());\n for (let i = 0, len = allInstances.length; i < len; ++i) {\n if (allInstances[i].id == objId) {\n allInstances.splice(i, 1);\n this._allInstancesListIsUpToDate = false;\n break;\n }\n }\n }\n\n // Notify the object it was removed from the container\n obj.onDeletedFromScene(this);\n\n // Notify the global callbacks\n for (let j = 0; j < gdjs.callbacksObjectDeletedFromScene.length; ++j) {\n gdjs.callbacksObjectDeletedFromScene[j](this, obj);\n }\n return;\n }\n\n /**\n * Get the layer with the given name\n * @param name The name of the layer\n * @returns The layer, or the base layer if not found\n */\n getLayer(name: string): gdjs.RuntimeLayer {\n if (this._layers.containsKey(name)) {\n return this._layers.get(name);\n }\n return this._layers.get('');\n }\n\n /**\n * Check if a layer exists\n * @param name The name of the layer\n */\n hasLayer(name: string): boolean {\n return this._layers.containsKey(name);\n }\n\n /**\n * Add a layer.\n * @param layerData The data to construct the layer\n */\n abstract addLayer(layerData: LayerData);\n\n /**\n * Remove a layer. All {@link gdjs.RuntimeObject} on this layer will\n * be moved back to the base layer.\n * @param layerName The name of the layer to remove\n */\n removeLayer(layerName: string) {\n const existingLayer = this._layers.get(layerName);\n if (!existingLayer) return;\n\n const allInstances = this.getAdhocListOfAllInstances();\n for (let i = 0; i < allInstances.length; ++i) {\n const runtimeObject = allInstances[i];\n if (runtimeObject.getLayer() === layerName) {\n runtimeObject.setLayer('');\n }\n }\n this._layers.remove(layerName);\n const layerIndex = this._orderedLayers.indexOf(existingLayer);\n this._orderedLayers.splice(layerIndex, 1);\n }\n\n /**\n * Change the position of a layer.\n *\n * @param layerName The name of the layer to reorder\n * @param index The new position in the list of layers\n */\n setLayerIndex(layerName: string, newIndex: integer): void {\n const layer: gdjs.RuntimeLayer = this._layers.get(layerName);\n if (!layer) {\n return;\n }\n const layerIndex = this._orderedLayers.indexOf(layer);\n if (layerIndex === newIndex) return;\n\n this._orderedLayers.splice(layerIndex, 1);\n this._orderedLayers.splice(newIndex, 0, layer);\n\n this.getRenderer().setLayerIndex(layer, newIndex);\n }\n\n /**\n * Fill the array passed as argument with the names of all layers\n * @param result The array where to put the layer names\n */\n getAllLayerNames(result: string[]) {\n this._layers.keys(result);\n }\n\n /**\n * Return the number of instances of the specified object living in the container.\n * @param objectName The object name for which instances must be counted.\n */\n getInstancesCountOnScene(objectName: string): integer {\n const instances = this._instances.get(objectName);\n if (instances) {\n return instances.length;\n }\n\n return 0;\n }\n\n /**\n * Update the objects positions according to their forces\n */\n updateObjectsForces(): void {\n for (const name in this._instances.items) {\n if (this._instances.items.hasOwnProperty(name)) {\n const list = this._instances.items[name];\n for (let j = 0, listLen = list.length; j < listLen; ++j) {\n const obj = list[j];\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = obj.getElapsedTime() / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.updateForces(elapsedTimeInSeconds);\n }\n }\n }\n }\n }\n\n /**\n * Clear any data structures to make sure memory is freed as soon as\n * possible.\n */\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n this._layers = new Hashtable();\n this._orderedLayers = [];\n this._objects = new Hashtable();\n this._instances = new Hashtable();\n this._instancesCache = new Hashtable();\n this._objectsCtor = new Hashtable();\n this._allInstancesList = [];\n this._instancesRemoved = [];\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,4BAKxB,OAAwC,CAiC7C,aAAc,CAvBN,uBAA0C,GAClD,iCAA8B,GAM9B,uBAA0C,GAQ1C,8BAAyE,GAGzE,uBAA6B,GAC7B,mCAAyC,GACzC,+BAAqC,GACrC,gCAAsC,GAGpC,KAAK,2BAA6B,GAAI,WACtC,KAAK,WAAa,GAAI,WACtB,KAAK,gBAAkB,GAAI,WAC3B,KAAK,SAAW,GAAI,WACpB,KAAK,aAAe,GAAI,WACxB,KAAK,QAAU,GAAI,WACnB,KAAK,eAAiB,GA6FxB,gBACE,EACA,EACA,EACA,EACM,CACN,AAAI,KAAK,mBAAqB,CAAC,GAC7B,KAAK,sBAAsB,iBAG7B,KAAK,kBAAoB,EACzB,KAAK,8BAAgC,EACrC,KAAK,0BAA4B,EACjC,KAAK,2BAA6B,EAQpC,mBAAmB,EAA6B,CAC9C,MACE,MAAK,SAAS,YAAY,IAC1B,KAAK,WAAW,YAAY,IAC5B,KAAK,aAAa,YAAY,GASlC,eAAe,EAAwB,CACrC,KAAK,SAAS,IAAI,EAAW,KAAM,GACnC,KAAK,WAAW,IAAI,EAAW,KAAM,IAGrC,KAAM,GAAO,EAAK,qBAAqB,EAAW,MAClD,KAAK,aAAa,IAAI,EAAW,KAAM,GAGnC,EAAK,0BACP,KAAK,gBAAgB,IAAI,EAAW,KAAM,IAS9C,aAAa,EAA8B,CACzC,AAAK,KAAK,mBAAmB,EAAW,OACtC,EAAO,KACL,qEACE,EAAW,KACX,iCAGN,KAAK,SAAS,IAAI,EAAW,KAAM,GAQrC,iBAAiB,EAAoB,CACnC,KAAM,GAAY,KAAK,WAAW,IAAI,GACtC,GAAI,EAAW,CAKb,KAAM,GAAoB,EAAU,QACpC,OA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
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var gdjs;(function(a){class u{constructor(t,i){this.center={x:0,y:0};this.origin={x:0,y:0};this.hasCustomHitBoxes=!1;this.customHitBoxes=[];this.image=t?t.image:"",this.texture=i.getAnimationFrameTexture(this.image),this.points=new Hashtable,this.reinitialize(t,i)}reinitialize(t,i){this.points.clear();for(let n=0,o=t.points.length;n<o;++n){const m=t.points[n],s={x:m.x,y:m.y};this.points.put(m.name,s)}const e=t.originPoint;this.origin.x=e.x,this.origin.y=e.y;const r=t.centerPoint;if(r.automatic!==!0?(this.center.x=r.x,this.center.y=r.y):(this.center.x=i.getAnimationFrameWidth(this.texture)/2,this.center.y=i.getAnimationFrameHeight(this.texture)/2),t.hasCustomCollisionMask){this.hasCustomHitBoxes=!0;let n=0;for(let o=t.customCollisionMask.length;n<o;++n){const m=t.customCollisionMask[n];n>=this.customHitBoxes.length&&this.customHitBoxes.push(new a.Polygon);let s=0;for(const c=m.length;s<c;++s){const l=m[s];s>=this.customHitBoxes[n].vertices.length&&this.customHitBoxes[n].vertices.push([0,0]),this.customHitBoxes[n].vertices[s][0]=l.x,this.customHitBoxes[n].vertices[s][1]=l.y}this.customHitBoxes[n].vertices.length=s}this.customHitBoxes.length=n}else this.customHitBoxes.length=0}getPoint(t){return t==="Centre"||t==="Center"?this.center:t==="Origin"?this.origin:this.points.containsKey(t)?this.points.get(t):this.origin}}a.SpriteAnimationFrame=u;class _{constructor(t,i){this.frames=[];this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping,this.reinitialize(t,i)}reinitialize(t,i){this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping;let e=0;for(const r=t.sprites.length;e<r;++e){const n=t.sprites[e];e<this.frames.length?this.frames[e].reinitialize(n,i):this.frames.push(new a.SpriteAnimationFrame(n,i))}this.frames.length=e}}a.SpriteAnimationDirection=_;class p{constructor(t,i){this.directions=[];this.hasMultipleDirections=!!t.useMultipleDirections,this.name=t.name||"",this.reinitialize(t,i)}reinitialize(t,i){this.hasMultipleDirections=!!t.useMultipleDirections,this.name=t.name||"";let e=0;for(const r=t.directions.length;e<r;++e){const n=t.directions[e];e<this.directions.length?this.directions[e].reinitialize(n,i):this.directions.push(new a.SpriteAnimationDirection(n,i))}this.directions.length=e}}a.SpriteAnimation=p;class g{constructor(t,i){this._animations=[];this._animationFrame=null;this._animationFrameDirty=!0;this._currentAnimation=0;this._currentDirection=0;this._currentFrameIndex=0;this._animationElapsedTime=0;this._animationSpeedScale=1;this._animationPaused=!1;this._onFrameChange=null;this._textureManager=i;for(let e=0,r=t.length;e<r;++e)this._animations.push(new a.SpriteAnimation(t[e],i))}invalidateFrame(){this._animationFrameDirty=!0,this._onFrameChange&&this._onFrameChange()}reinitialize(t){this._currentAnimation=0,this._currentDirection=0,this._currentFrameIndex=0,this._animationElapsedTime=0,this._animationSpeedScale=1,this._animationPaused=!1;let i=0;for(const e=t.length;i<e;++i){const r=t[i];i<this._animations.length?this._animations[i].reinitialize(r,this._textureManager):this._animations.push(new a.SpriteAnimation(r,this._textureManager))}this._animations.length=i,this._animationFrame=null,this.invalidateFrame()}updateFromObjectData(t,i){let e=0;for(const n=i.length;e<n;++e){const o=i[e];e<this._animations.length?this._animations[e].reinitialize(o,this._textureManager):this._animations.push(new a.SpriteAnimation(o,this._textureManager))}return this._animations.length=e,this.invalidateFrame(),this.getCurrentFrame()||this.setAnimationIndex(0),!0}getNetworkSyncData(){return{an:this._currentAnimation,di:this._currentDirection,fr:this._currentFrameIndex,et:this._animationElapsedTime,ss:this._animationSpeedScale,pa:this._animationPaused}}updateFromNetworkSyncData(t){this._currentAnimation=t.an,this._currentDirection=t.di,this._currentFrameIndex=t.fr,this._animationElapsedTime=t.et,this._animationSpeedScale=t.ss,this._animationPaused=t.pa,this.invalidateFrame()}getCurrentFrame(){if(!this._animationFrameDirty)return this._animationFrame;if(this._animationFrameDirty=!1,this._currentAnimation<this._animations.length&&this._currentDirection<this._animations[this._currentAnimation].directions.length){const t=this._animations[this._currentAnimation].directions[this._currentDirection];if(this._currentFrameIndex<t.frames.length)return this._animationFrame=t.frames[this._currentFrameIndex],this._animationFrame}return this._animationFrame=null,this._animationFrame}step(t){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection],e=this.getAnimationDuration();if(!this._animationPaused&&(i.loop||this._animationElapsedTime!==e)&&i.timeBetweenFrames){const r=this._animationElapsedTime+t*this._animationSpeedScale;return this.setAnimationElapsedTime(i.loop?a.evtTools.common.mod(r,e):a.evtTools.common.clamp(r,0,e))}return!1}setOnFrameChangeCallback(t){this._onFrameChange=t}getAnimationIndex(){return this._currentAnimation}setAnimationIndex(t){return t=t|0,t<this._animations.length&&this._currentAnimation!==t&&t>=0?(this._currentAnimation=t,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),!0):!1}getAnimationName(){return this._currentAnimation>=this._animations.length?"":this._animations[this._currentAnimation].name}setAnimationName(t){if(!t)return!1;for(let i=0;i<this._animations.length;++i)if(this._animations[i].name===t)return this.setAnimationIndex(i),!0;return!1}hasAnimationEnded(){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1&&this._animationElapsedTime===t.frames.length*t.timeBetweenFrames}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0}resumeAnimation(){this._animationPaused=!1}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(t){this._animationSpeedScale=t}setAnimationFrameIndex(t){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection];return t>=0&&t<i.frames.length&&t!==this._currentFrameIndex?(this._currentFrameIndex=t,this._animationElapsedTime=t*i.timeBetweenFrames,this.invalidateFrame(),!0):!1}getAnimationFrameIndex(){return this._currentFrameIndex}getAnimationElapsedTime(){return this._animationElapsedTime}setAnimationElapsedTime(t){const i=this._animations[this._currentAnimation].directions[this._currentDirection];this._animationElapsedTime=a.evtTools.common.clamp(t,0,this.getAnimationDuration());const e=this._currentFrameIndex;return this._currentFrameIndex=Math.min(Math.floor(this._animationElapsedTime/i.timeBetweenFrames),i.frames.length-1),e!==this._currentFrameIndex?(this.invalidateFrame(),!0):!1}getAnimationDuration(){const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.frames.length*t.timeBetweenFrames}getAnimationFrameCount(){if(this._currentAnimation>=this._animations.length)return 0;const t=this._animations[this._currentAnimation];return this._currentDirection>=t.directions.length?0:t.directions[this._currentDirection].frames.length}setDirectionOrAngle(t,i){if(this._currentAnimation>=this._animations.length)return null;const e=this._animations[this._currentAnimation];return e.hasMultipleDirections?(i=i|0,i===this._currentDirection||i>=e.directions.length||e.directions[i].frames.length===0?null:(this._currentDirection=i,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),0)):t===i?null:i}getDirectionOrAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection:t}getAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection*45:t}setAngle(t,i){return this._currentAnimation>=this._animations.length?null:this._animations[this._currentAnimation].hasMultipleDirections?(i=i%360,i<0&&(i+=360),this.setDirectionOrAngle(t,Math.round(i/45)%8)):t===i?null:i}hasAnimationEndedLegacy(){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1}}a.SpriteAnimator=g})(gdjs||(gdjs={}));
|
|
2
|
+
//# sourceMappingURL=SpriteAnimator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../GDevelop/GDJS/Runtime/SpriteAnimator.ts"],
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n /** Represents a point in a coordinate system. */\n export type SpritePoint = {\n /** X position of the point. */\n x: float;\n /** Y position of the point. */\n y: float;\n };\n\n /** Represents a custom point in a frame. */\n export type SpriteCustomPointData = {\n /** Name of the point. */\n name: string;\n /** X position of the point. */\n x: float;\n /** Y position of the point. */\n y: float;\n };\n\n /** Represents the center point in a frame. */\n export type SpriteCenterPointData = {\n /** Name of the point. */\n name: string;\n /** Is the center automatically computed? */\n automatic: boolean;\n /** X position of the point. */\n x: float;\n /** Y position of the point. */\n y: float;\n };\n\n /** Represents a {@link gdjs.SpriteAnimationFrame}. */\n export type SpriteFrameData = {\n /** The resource name of the image used in this frame. */\n image: string;\n /** The points of the frame. */\n points: Array<SpriteCustomPointData>;\n /** The origin point. */\n originPoint: SpriteCustomPointData;\n /** The center of the frame. */\n centerPoint: SpriteCenterPointData;\n /** Is The collision mask custom? */\n hasCustomCollisionMask: boolean;\n /** The collision mask if it is custom. */\n customCollisionMask: Array<Array<SpritePoint>>;\n };\n\n /** Represents the data of a {@link gdjs.SpriteAnimationDirection}. */\n export type SpriteDirectionData = {\n /** Time between each frame, in seconds. */\n timeBetweenFrames: float;\n /** Is the animation looping? */\n looping: boolean;\n /** The list of frames. */\n sprites: Array<SpriteFrameData>;\n };\n\n /** Represents the data of a {@link gdjs.SpriteAnimation}. */\n export type SpriteAnimationData = {\n /** The name of the animation. */\n name: string;\n /** Does the animation use multiple {@link gdjs.SpriteAnimationDirection}? */\n useMultipleDirections: boolean;\n /** The list of {@link SpriteDirectionData} representing {@link gdjs.SpriteAnimationDirection} instances. */\n directions: Array<SpriteDirectionData>;\n };\n\n /** Represents all the information needed to synchronize the animations of an object. */\n export type SpriteAnimatorNetworkSyncData = {\n an: integer;\n di: integer;\n fr: integer;\n et: float;\n ss: float;\n pa: boolean;\n };\n\n /**\n * Abstraction from graphic libraries texture classes.\n */\n export interface AnimationFrameTextureManager<T> {\n getAnimationFrameTexture(imageName: string): T;\n getAnimationFrameWidth(pixiTexture: T);\n getAnimationFrameHeight(pixiTexture: T);\n }\n\n /**\n * A frame used by a SpriteAnimation in a {@link gdjs.SpriteRuntimeObject}.\n *\n * It contains the texture displayed as well as information like the points position\n * or the collision mask.\n */\n export class SpriteAnimationFrame<T> {\n image: string;\n\n //TODO: Rename in imageName, and do not store it in the object?\n texture: T;\n center: SpritePoint = { x: 0, y: 0 };\n origin: SpritePoint = { x: 0, y: 0 };\n hasCustomHitBoxes: boolean = false;\n customHitBoxes: gdjs.Polygon[] = [];\n points: Hashtable<SpritePoint>;\n\n /**\n * @param imageManager The game image manager\n * @param frameData The frame data used to initialize the frame\n */\n constructor(\n frameData: SpriteFrameData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.image = frameData ? frameData.image : '';\n this.texture = textureManager.getAnimationFrameTexture(this.image);\n this.points = new Hashtable();\n this.reinitialize(frameData, textureManager);\n }\n\n /**\n * @param frameData The frame data used to initialize the frame\n * @param textureManager The game image manager\n */\n reinitialize(\n frameData: SpriteFrameData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.points.clear();\n for (let i = 0, len = frameData.points.length; i < len; ++i) {\n const ptData = frameData.points[i];\n const point = { x: ptData.x, y: ptData.y };\n this.points.put(ptData.name, point);\n }\n const origin = frameData.originPoint;\n this.origin.x = origin.x;\n this.origin.y = origin.y;\n const center = frameData.centerPoint;\n if (center.automatic !== true) {\n this.center.x = center.x;\n this.center.y = center.y;\n } else {\n this.center.x = textureManager.getAnimationFrameWidth(this.texture) / 2;\n this.center.y =\n textureManager.getAnimationFrameHeight(this.texture) / 2;\n }\n\n //Load the custom collision mask, if any:\n if (frameData.hasCustomCollisionMask) {\n this.hasCustomHitBoxes = true;\n let i = 0;\n for (let len = frameData.customCollisionMask.length; i < len; ++i) {\n const polygonData: SpritePoint[] = frameData.customCollisionMask[i];\n\n //Add a polygon, if necessary (Avoid recreating a polygon if it already exists).\n if (i >= this.customHitBoxes.length) {\n this.customHitBoxes.push(new gdjs.Polygon());\n }\n let j = 0;\n for (const len2 = polygonData.length; j < len2; ++j) {\n const pointData: SpritePoint = polygonData[j];\n\n //Add a point, if necessary (Avoid recreating a point if it already exists).\n if (j >= this.customHitBoxes[i].vertices.length) {\n this.customHitBoxes[i].vertices.push([0, 0]);\n }\n this.customHitBoxes[i].vertices[j][0] = pointData.x;\n this.customHitBoxes[i].vertices[j][1] = pointData.y;\n }\n this.customHitBoxes[i].vertices.length = j;\n }\n this.customHitBoxes.length = i;\n } else {\n this.customHitBoxes.length = 0;\n }\n }\n\n /**\n * Get a point of the frame.<br>\n * If the point does not exist, the origin is returned.\n * @param name The point's name\n * @return The requested point. If it doesn't exists returns the origin point.\n */\n getPoint(name: string): SpritePoint {\n if (name === 'Centre' || name === 'Center') {\n return this.center;\n } else {\n if (name === 'Origin') {\n return this.origin;\n }\n }\n return this.points.containsKey(name)\n ? this.points.get(name)\n : this.origin;\n }\n }\n\n /**\n * Represents a direction of an animation of a {@link gdjs.SpriteRuntimeObject}.\n */\n export class SpriteAnimationDirection<T> {\n timeBetweenFrames: float;\n loop: boolean;\n frames: SpriteAnimationFrame<T>[] = [];\n\n /**\n * @param imageManager The game image manager\n * @param directionData The direction data used to initialize the direction\n */\n constructor(\n directionData: SpriteDirectionData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.timeBetweenFrames = directionData\n ? directionData.timeBetweenFrames\n : 1.0;\n this.loop = !!directionData.looping;\n this.reinitialize(directionData, textureManager);\n }\n\n /**\n * @param directionData The direction data used to initialize the direction\n * @param textureManager The game image manager\n */\n reinitialize(\n directionData: SpriteDirectionData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.timeBetweenFrames = directionData\n ? directionData.timeBetweenFrames\n : 1.0;\n this.loop = !!directionData.looping;\n let i = 0;\n for (const len = directionData.sprites.length; i < len; ++i) {\n const frameData = directionData.sprites[i];\n if (i < this.frames.length) {\n this.frames[i].reinitialize(frameData, textureManager);\n } else {\n this.frames.push(\n new gdjs.SpriteAnimationFrame<T>(frameData, textureManager)\n );\n }\n }\n this.frames.length = i;\n }\n }\n\n /**\n * Represents an animation of a {@link SpriteRuntimeObject}.\n */\n export class SpriteAnimation<T> {\n hasMultipleDirections: boolean;\n name: string;\n directions: gdjs.SpriteAnimationDirection<T>[] = [];\n\n /**\n * @param animData The animation data used to initialize the animation\n * @param textureManager The game image manager\n */\n constructor(\n animData: SpriteAnimationData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.hasMultipleDirections = !!animData.useMultipleDirections;\n this.name = animData.name || '';\n this.reinitialize(animData, textureManager);\n }\n\n /**\n * @param animData The animation data used to initialize the animation\n * @param textureManager The game image manager\n */\n reinitialize(\n animData: SpriteAnimationData,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this.hasMultipleDirections = !!animData.useMultipleDirections;\n this.name = animData.name || '';\n let i = 0;\n for (const len = animData.directions.length; i < len; ++i) {\n const directionData = animData.directions[i];\n if (i < this.directions.length) {\n this.directions[i].reinitialize(directionData, textureManager);\n } else {\n this.directions.push(\n new gdjs.SpriteAnimationDirection(directionData, textureManager)\n );\n }\n }\n // Make sure to delete already existing directions which are not used anymore.\n this.directions.length = i;\n }\n }\n\n /**\n * Image-base animation model.\n */\n export class SpriteAnimator<T> implements gdjs.Animatable {\n _animations: gdjs.SpriteAnimation<T>[] = [];\n _textureManager: gdjs.AnimationFrameTextureManager<T>;\n /**\n * Reference to the current SpriteAnimationFrame that is displayed.\n * Can be null, so ensure that this case is handled properly.\n */\n private _animationFrame: gdjs.SpriteAnimationFrame<T> | null = null;\n private _animationFrameDirty: boolean = true;\n\n private _currentAnimation: integer = 0;\n private _currentDirection: integer = 0;\n private _currentFrameIndex: integer = 0;\n /** In seconds */\n private _animationElapsedTime: float = 0;\n private _animationSpeedScale: float = 1;\n private _animationPaused: boolean = false;\n private _onFrameChange: (() => void) | null = null;\n\n /**\n * @param frameData The frame data used to initialize the frame\n * @param textureManager The game image manager\n */\n constructor(\n animations: Array<SpriteAnimationData>,\n textureManager: gdjs.AnimationFrameTextureManager<T>\n ) {\n this._textureManager = textureManager;\n for (let i = 0, len = animations.length; i < len; ++i) {\n this._animations.push(\n new gdjs.SpriteAnimation(animations[i], textureManager)\n );\n }\n }\n\n invalidateFrame() {\n this._animationFrameDirty = true;\n if (this._onFrameChange) {\n this._onFrameChange();\n }\n }\n\n reinitialize(animations: Array<SpriteAnimationData>) {\n this._currentAnimation = 0;\n this._currentDirection = 0;\n this._currentFrameIndex = 0;\n this._animationElapsedTime = 0;\n this._animationSpeedScale = 1;\n this._animationPaused = false;\n\n let i = 0;\n for (const len = animations.length; i < len; ++i) {\n const animData = animations[i];\n if (i < this._animations.length) {\n this._animations[i].reinitialize(animData, this._textureManager);\n } else {\n this._animations.push(\n new gdjs.SpriteAnimation(animData, this._textureManager)\n );\n }\n }\n this._animations.length = i;\n\n // Make sure to delete already existing animations which are not used anymore.\n this._animationFrame = null;\n this.invalidateFrame();\n }\n\n updateFromObjectData(\n oldAnimations: Array<SpriteAnimationData>,\n newAnimations: Array<SpriteAnimationData>\n ): boolean {\n let i = 0;\n for (const len = newAnimations.length; i < len; ++i) {\n const animData = newAnimations[i];\n if (i < this._animations.length) {\n this._animations[i].reinitialize(animData, this._textureManager);\n } else {\n this._animations.push(\n new gdjs.SpriteAnimation(animData, this._textureManager)\n );\n }\n }\n this._animations.length = i;\n\n // Make sure to delete already existing animations which are not used anymore.\n this.invalidateFrame();\n const animationFrame = this.getCurrentFrame();\n if (!animationFrame) {\n this.setAnimationIndex(0);\n }\n return true;\n }\n\n getNetworkSyncData(): SpriteAnimatorNetworkSyncData {\n return {\n an: this._currentAnimation,\n di: this._currentDirection,\n fr: this._currentFrameIndex,\n et: this._animationElapsedTime,\n ss: this._animationSpeedScale,\n pa: this._animationPaused,\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: SpriteAnimatorNetworkSyncData) {\n this._currentAnimation = networkSyncData.an;\n this._currentDirection = networkSyncData.di;\n this._currentFrameIndex = networkSyncData.fr;\n this._animationElapsedTime = networkSyncData.et;\n this._animationSpeedScale = networkSyncData.ss;\n this._animationPaused = networkSyncData.pa;\n this.invalidateFrame();\n }\n\n /**\n * @returns Returns the current frame or null if the current animation doesn't have any frame.\n */\n getCurrentFrame(): gdjs.SpriteAnimationFrame<T> | null {\n if (!this._animationFrameDirty) {\n return this._animationFrame;\n }\n this._animationFrameDirty = false;\n if (\n this._currentAnimation < this._animations.length &&\n this._currentDirection <\n this._animations[this._currentAnimation].directions.length\n ) {\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n if (this._currentFrameIndex < direction.frames.length) {\n this._animationFrame = direction.frames[this._currentFrameIndex];\n return this._animationFrame;\n }\n }\n\n //Invalid animation/direction/frame:\n this._animationFrame = null;\n return this._animationFrame;\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n * @param timeDelta in seconds\n */\n step(timeDelta: float): boolean {\n if (\n this._currentAnimation >= this._animations.length ||\n this._currentDirection >=\n this._animations[this._currentAnimation].directions.length\n ) {\n return false;\n }\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n const animationDuration = this.getAnimationDuration();\n if (\n !this._animationPaused &&\n (direction.loop || this._animationElapsedTime !== animationDuration) &&\n direction.timeBetweenFrames\n ) {\n const animationElapsedTime =\n this._animationElapsedTime + timeDelta * this._animationSpeedScale;\n return this.setAnimationElapsedTime(\n direction.loop\n ? gdjs.evtTools.common.mod(animationElapsedTime, animationDuration)\n : gdjs.evtTools.common.clamp(\n animationElapsedTime,\n 0,\n animationDuration\n )\n );\n }\n return false;\n }\n\n /**\n * Register a listener to frame changes.\n *\n * It's useful for custom objects as they don't drive this class themselves.\n *\n * @param callback Called each time {@link getCurrentFrame} changes.\n */\n setOnFrameChangeCallback(callback: () => void): void {\n this._onFrameChange = callback;\n }\n\n getAnimationIndex(): integer {\n return this._currentAnimation;\n }\n\n setAnimationIndex(newAnimation: integer): boolean {\n // Truncate the index.\n newAnimation = newAnimation | 0;\n if (\n newAnimation < this._animations.length &&\n this._currentAnimation !== newAnimation &&\n newAnimation >= 0\n ) {\n this._currentAnimation = newAnimation;\n this._currentFrameIndex = 0;\n this._animationElapsedTime = 0;\n this.invalidateFrame();\n return true;\n }\n return false;\n }\n\n getAnimationName(): string {\n if (this._currentAnimation >= this._animations.length) {\n return '';\n }\n return this._animations[this._currentAnimation].name;\n }\n\n setAnimationName(newAnimationName: string): boolean {\n if (!newAnimationName) {\n return false;\n }\n for (let i = 0; i < this._animations.length; ++i) {\n if (this._animations[i].name === newAnimationName) {\n this.setAnimationIndex(i);\n return true;\n }\n }\n return false;\n }\n\n hasAnimationEnded(): boolean {\n if (\n this._currentAnimation >= this._animations.length ||\n this._currentDirection >=\n this._animations[this._currentAnimation].directions.length\n ) {\n return true;\n }\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n if (direction.loop) {\n return false;\n }\n return (\n this._currentFrameIndex === direction.frames.length - 1 &&\n this._animationElapsedTime ===\n direction.frames.length * direction.timeBetweenFrames\n );\n }\n\n isAnimationPaused() {\n return this._animationPaused;\n }\n\n pauseAnimation() {\n this._animationPaused = true;\n }\n\n resumeAnimation() {\n this._animationPaused = false;\n }\n\n getAnimationSpeedScale() {\n return this._animationSpeedScale;\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animationSpeedScale = ratio;\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrameIndex The index of the frame to be displayed\n */\n setAnimationFrameIndex(newFrameIndex: integer): boolean {\n if (\n this._currentAnimation >= this._animations.length ||\n this._currentDirection >=\n this._animations[this._currentAnimation].directions.length\n ) {\n return false;\n }\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n if (\n newFrameIndex >= 0 &&\n newFrameIndex < direction.frames.length &&\n newFrameIndex !== this._currentFrameIndex\n ) {\n this._currentFrameIndex = newFrameIndex;\n this._animationElapsedTime =\n newFrameIndex * direction.timeBetweenFrames;\n this.invalidateFrame();\n return true;\n }\n return false;\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 getAnimationFrameIndex(): integer {\n return this._currentFrameIndex;\n }\n\n getAnimationElapsedTime(): float {\n return this._animationElapsedTime;\n }\n\n setAnimationElapsedTime(time: float): boolean {\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n this._animationElapsedTime = gdjs.evtTools.common.clamp(\n time,\n 0,\n this.getAnimationDuration()\n );\n\n const oldFrame = this._currentFrameIndex;\n this._currentFrameIndex = Math.min(\n Math.floor(this._animationElapsedTime / direction.timeBetweenFrames),\n direction.frames.length - 1\n );\n if (oldFrame !== this._currentFrameIndex) {\n this.invalidateFrame();\n return true;\n }\n return false;\n }\n\n getAnimationDuration(): float {\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n return direction.frames.length * direction.timeBetweenFrames;\n }\n\n getAnimationFrameCount(): integer {\n if (this._currentAnimation >= this._animations.length) {\n return 0;\n }\n const currentAnimation = this._animations[this._currentAnimation];\n if (this._currentDirection >= currentAnimation.directions.length) {\n return 0;\n }\n return currentAnimation.directions[this._currentDirection].frames.length;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param The new angle (or direction index) to be applied\n * @deprecated\n */\n setDirectionOrAngle(oldValue: float, newValue: float): float | null {\n if (this._currentAnimation >= this._animations.length) {\n return null;\n }\n const anim = this._animations[this._currentAnimation];\n if (!anim.hasMultipleDirections) {\n return oldValue === newValue ? null : newValue;\n } else {\n newValue = newValue | 0;\n if (\n newValue === this._currentDirection ||\n newValue >= anim.directions.length ||\n anim.directions[newValue].frames.length === 0\n ) {\n return null;\n }\n this._currentDirection = newValue;\n this._currentFrameIndex = 0;\n this._animationElapsedTime = 0;\n this.invalidateFrame();\n return 0;\n }\n }\n\n /**\n * @deprecated\n */\n getDirectionOrAngle(angle: float): float {\n if (this._currentAnimation >= this._animations.length) {\n return 0;\n }\n if (!this._animations[this._currentAnimation].hasMultipleDirections) {\n return angle;\n } else {\n return this._currentDirection;\n }\n }\n\n /**\n * @deprecated\n */\n getAngle(angle: float): float {\n if (this._currentAnimation >= this._animations.length) {\n return 0;\n }\n if (!this._animations[this._currentAnimation].hasMultipleDirections) {\n return angle;\n } else {\n return this._currentDirection * 45;\n }\n }\n\n /**\n * @deprecated\n */\n setAngle(oldAngle: float, angle: float): float | null {\n if (this._currentAnimation >= this._animations.length) {\n return null;\n }\n if (!this._animations[this._currentAnimation].hasMultipleDirections) {\n if (oldAngle === angle) {\n return null;\n }\n return angle;\n } else {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return this.setDirectionOrAngle(oldAngle, Math.round(angle / 45) % 8);\n }\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using {@link hasAnimationEnded}. 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 if (\n this._currentAnimation >= this._animations.length ||\n this._currentDirection >=\n this._animations[this._currentAnimation].directions.length\n ) {\n return true;\n }\n const direction = this._animations[this._currentAnimation].directions[\n this._currentDirection\n ];\n if (direction.loop) {\n return false;\n }\n return this._currentFrameIndex === direction.frames.length - 1;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CA4FS,OAA8B,CAenC,YACE,EACA,EACA,CAbF,YAAsB,CAAE,EAAG,EAAG,EAAG,GACjC,YAAsB,CAAE,EAAG,EAAG,EAAG,GACjC,uBAA6B,GAC7B,oBAAiC,GAW/B,KAAK,MAAQ,EAAY,EAAU,MAAQ,GAC3C,KAAK,QAAU,EAAe,yBAAyB,KAAK,OAC5D,KAAK,OAAS,GAAI,WAClB,KAAK,aAAa,EAAW,GAO/B,aACE,EACA,EACA,CACA,KAAK,OAAO,QACZ,OAA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,EACR,KAEF,EAgBX,yBAAmC,CACjC,GACE,KAAK,mBAAqB,KAAK,YAAY,QAC3C,KAAK,mBACH,KAAK,YAAY,KAAK,mBAAmB,WAAW,OAEtD,MAAO,GAET,KAAM,GAAY,KAAK,YAAY,KAAK,mBAAmB,WACzD,KAAK,mBAEP,MAAI,GAAU,KACL,GAEF,KAAK,qBAAuB,EAAU,OAAO,OAAS,GAlc1D,EAAM,mBAtSL",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(d){const u=new d.Logger("Hot reloader");class m{constructor(i){this._reloadedScriptElement={};this._logs=[];this._alreadyLoadedScriptFiles={};this._runtimeGame=i}static groupByPersistentUuid(i){return i.reduce(function(e,r){return r.persistentUuid&&(e[r.persistentUuid]=r),e},{})}_canReloadScriptFile(i){function e(r,t){const o=r.indexOf(t);return o!==-1&&o===r.length-t.length}return!(e(i,".h")||this._alreadyLoadedScriptFiles[i]&&(e(i,"box2d.js")||e(i,"sha256.js")||e(i,"shifty.js")||e(i,"shopify-buy.umd.polyfilled.min.js")||e(i,"pixi-multistyle-text.umd.js")||e(i,"pixi-tilemap.umd.js")||e(i,"bondage.min.js")||e(i,"pixi-particles-pixi-renderer.min.js")||e(i,"pixi-tilemap.umd.js")||e(i,"pixi-tilemap-helper.js")||e(i,"pako/dist/pako.min")))}_reloadScript(i){function e(t,o){const a=t.indexOf(o);return a!==-1&&a===t.length-o.length}if(!this._canReloadScriptFile(i))return this._logs.push({kind:"info",message:"Not reloading "+i+" as it is blocked for hot-reloading."}),Promise.resolve();const r=document.getElementsByTagName("head")[0];return r?new Promise((t,o)=>{const a=this._reloadedScriptElement[i];if(a)r.removeChild(a);else{const n=r.getElementsByTagName("script");for(let h=0;h<n.length;++h){const l=n[h];e(l.src,i)&&r.removeChild(l)}}const s=document.createElement("script");s.src=i+"?timestamp="+Date.now(),s.onload=()=>{t()},s.onerror=n=>{o(n)},r.appendChild(s),this._reloadedScriptElement[i]=s}):Promise.reject(new Error("No head element found, are you in a navigator?"))}hotReload(){u.info("Hot reload started"),this._runtimeGame.pause(!0),this._logs=[];const i=d.projectData,e=d.runtimeGameOptions.scriptFiles;e.forEach(t=>{this._alreadyLoadedScriptFiles[t.path]=!0});const r={};for(let t in d.behaviorsTypes.items)r[t]=d.behaviorsTypes.items[t];return this._reloadScript("data.js").then(()=>{const t=d.projectData,o=d.runtimeGameOptions,a=o.scriptFiles,s=!!o.projectDataOnlyExport;return this.reloadScriptFiles(t,e,a,s).then(()=>{const n=this._computeChangedRuntimeBehaviors(r,d.behaviorsTypes.items);return this._hotReloadRuntimeGame(i,t,n,this._runtimeGame)}).catch(n=>{const h=n.target;h instanceof HTMLScriptElement?this._logs.push({kind:"fatal",message:"Unable to reload script:"+h.src}):this._logs.push({kind:"fatal",message:"Unexpected error happened while hot-reloading:"+n.message})}).then(()=>(u.info("Hot reload finished with logs:",this._logs),this._runtimeGame.pause(!1),this._logs))})}_computeChangedRuntimeBehaviors(i,e){const r=[];for(let t in i){const o=i[t],a=e[t];a?o!==a&&(this._logs.push({kind:"info",message:"Behavior with type "+t+" was changed, and will be re-instantiated in gdjs.RuntimeObjects using it."}),r.push({oldBehaviorConstructor:o,newBehaviorConstructor:a,behaviorTypeName:t})):this._logs.push({kind:"warning",message:"Behavior with type "+t+" was removed from the registered behaviors in gdjs."})}return r}reloadScriptFiles(i,e,r,t){const o=[];t||i.layouts.forEach((a,s)=>{o.push(this._reloadScript("code"+s+".js"))});for(let a=0;a<r.length;++a){const s=r[a],n=e.filter(h=>h.path===s.path)[0];n?s.hash!==n.hash&&(this._logs.push({kind:"info",message:"Reloading "+s.path+" because it was changed."}),o.push(this._reloadScript(s.path))):(this._logs.push({kind:"info",message:"Loading "+s.path+" as it was added to the list of scripts."}),o.push(this._reloadScript(s.path)))}for(let a=0;a<e.length;++a){const s=e[a];!r.filter(h=>h.path===s.path)[0]&&!t&&this._logs.push({kind:"warning",message:"Script file "+s.path+" was removed."})}return Promise.all(o)}async _hotReloadRuntimeGame(i,e,r,t){const o=t.getSceneStack(),a=o.getCurrentScene();if(!a){this._logs.push({kind:"error",message:"Can't hot-reload as no scene are opened."});return}t.setProjectData(e),await t.loadFirstAssetsAndStartBackgroundLoading(a.getName(),()=>{}),this._hotReloadVariablesContainer(i.variables,e.variables,t.getVariables()),o._stack.forEach(s=>{const n=i.layouts.filter(l=>l.name===s.getName())[0],h=e.layouts.filter(l=>l.name===s.getName())[0];n&&h?this._hotReloadRuntimeScene(n,h,r,s):this._logs.push({kind:"error",message:"Scene "+n.name+" was removed. A fresh preview should be launched."})}),e.externalLayouts.forEach(s=>{const n=i.externalLayouts.filter(h=>h.name===s.name)[0];n&&!m.deepEqual(n,s)&&o._stack.forEach(h=>{this._hotReloadRuntimeSceneInstances(n.instances,s.instances,h)})})}_hotReloadVariablesContainer(i,e,r){e.forEach(t=>{const o=t.name,a=i.find(n=>n.name===o),s=r.get(t.name);a?d.Variable.isPrimitive(t.type||"number")&&(a.value!==t.value||!d.Variable.isPrimitive(a.type||"number"))?(r.remove(o),r.add(o,new d.Variable(t))):d.Variable.isPrimitive(t.type||"number")||(t.type==="structure"?this._hotReloadStructureVariable(a.children,t.children,s):(r.remove(o),r.add(o,new d.Variable(t)))):r.add(o,new d.Variable(t))}),i.forEach(t=>{e.find(a=>a.name===t.name)||r.remove(t.name)})}_hotReloadStructureVariable(i,e,r){i?(i.forEach(t=>{const o=e.find(a=>a.name===t.name);o?d.Variable.isPrimitive(o.type||"number")&&(t.value!==o.value||!d.Variable.isPrimitive(t.type||"number"))?r.addChild(o.name,new d.Variable(o)):d.Variable.isPrimitive(o.type||"number")||(o.type==="structure"?this._hotReloadStructureVariable(t.children,o.children,r.getChild(o.name)):r.addChild(o.name,new d.Variable(o))):r.removeChild(t.name)}),e.forEach(t=>{i.find(a=>a.name===t.name)||r.addChild(t.name,new d.Variable(t))})):e.forEach(t=>{r.addChild(t.name,new d.Variable(t))})}_hotReloadRuntimeScene(i,e,r,t){t.setBackgroundColor(e.r,e.v,e.b),i.title!==e.title&&t.getGame().getRenderer().setWindowTitle(e.title),this._hotReloadVariablesContainer(i.variables,e.variables,t.getVariables()),this._hotReloadRuntimeSceneBehaviorsSharedData(i.behaviorsSharedData,e.behaviorsSharedData,t),this._reinstantiateRuntimeSceneRuntimeBehaviors(r,e.objects,t),this._hotReloadRuntimeSceneObjects(i.objects,e.objects,t),this._hotReloadRuntimeSceneInstances(i.instances,e.instances,t),this._hotReloadRuntimeSceneLayers(i.layers,e.layers,t),t.setEventsGeneratedCodeFunction(e)}_hotReloadRuntimeSceneBehaviorsSharedData(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];a?m.deepEqual(t,a)||r.setInitialSharedDataForBehavior(a.name,a):r.setInitialSharedDataForBehavior(t.name,null)}),e.forEach(t=>{const o=t.name;i.filter(s=>s.name===o)[0]||r.setInitialSharedDataForBehavior(t.name,t)})}_reinstantiateRuntimeSceneRuntimeBehaviors(i,e,r){e.forEach(t=>{const o=t.name,a=t.behaviors,s=r.getObjects(o);i.forEach(n=>{const h=n.behaviorTypeName;a.filter(l=>l.type===h).forEach(l=>{const f=l.name;this._logs.push({kind:"info",message:'Re-instantiating behavior named "'+f+'" for instances of object "'+o+'".'}),s.forEach(c=>{this._reinstantiateRuntimeObjectRuntimeBehavior(l,c)})})})})}_reinstantiateRuntimeObjectRuntimeBehavior(i,e){const r=i.name,t=e.getBehavior(r);if(!t)return;e.removeBehavior(r),e.addNewBehavior(i);const o=e.getBehavior(r);if(!o){this._logs.push({kind:"error",message:"Could not create behavior "+r+" (type: "+i.type+") for object "+e.getName()});return}for(let a in t)if(!!t.hasOwnProperty(a))if(a==="_behaviorData"){o[a]=o[a]||{};for(let s in t[a])o[a][s]=t[a][s]}else o[a]=t[a]}_hotReloadRuntimeSceneObjects(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];!a||t.type!==a.type?r.unregisterObject(o):r.isObjectRegistered(o)&&this._hotReloadRuntimeSceneObject(t,a,r)}),e.forEach(t=>{const o=t.name,a=i.filter(s=>s.name===o)[0];(!a||a.type!==t.type)&&!r.isObjectRegistered(o)&&r.registerObject(t)})}_hotReloadRuntimeSceneObject(i,e,r){let t=!0;if(!m.deepEqual(i,e)){this._logs.push({kind:"info",message:'Object "'+e.name+'" was modified and is hot-reloaded.'}),r.updateObject(e);const o=r.getObjects(e.name);o.forEach(a=>{t=a.updateFromObjectData(i,e)&&t}),o.forEach(a=>{this._hotReloadVariablesContainer(i.variables,e.variables,a.getVariables())}),this._hotReloadRuntimeObjectsBehaviors(i.behaviors,e.behaviors,o),this._hotReloadRuntimeObjectsEffects(i.effects,e.effects,o)}t||this._logs.push({kind:"error",message:'Object "'+e.name+'" could not be hot-reloaded. A fresh preview should be run.'})}_hotReloadRuntimeObjectsBehaviors(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];if(!a)r.forEach(s=>{s.hasBehavior(o)&&(s.removeBehavior(o)||this._logs.push({kind:"error",message:"Behavior "+o+" could not be removed from object"+s.getName()}))});else if(!m.deepEqual(t,a)){let s=!0;r.forEach(n=>{const h=n.getBehavior(a.name);h&&(s=this._hotReloadRuntimeBehavior(t,a,h)&&s)}),s||this._logs.push({kind:"error",message:a.name+" behavior could not be hot-reloaded."})}}),e.forEach(t=>{const o=t.name;if(!i.filter(s=>s.name===o)[0]){let s=!0;r.forEach(n=>{s=n.addNewBehavior(t)&&s}),s||this._logs.push({kind:"error",message:t.name+" behavior could not be added during hot-reload."})}})}_hotReloadRuntimeObjectsEffects(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];if(!a)r.forEach(s=>{s.hasEffect(o)&&(s.removeEffect(o)||this._logs.push({kind:"error",message:"Effect "+o+" could not be removed from object"+s.getName()}))});else if(!m.deepEqual(t,a)){let s=!0;r.forEach(n=>{t.effectType===a.effectType?s=n.updateAllEffectParameters(a)&&s:(n.removeEffect(t.name),n.addEffect(a))}),s||this._logs.push({kind:"error",message:a.name+" effect could not be hot-reloaded."})}}),e.forEach(t=>{const o=t.name;if(!i.filter(s=>s.name===o)[0]){let s=!0;r.forEach(n=>{s=n.addEffect(t)&&s}),s||this._logs.push({kind:"error",message:t.name+" effect could not be added during hot-reload."})}})}_hotReloadRuntimeBehavior(i,e,r){return r.updateFromBehaviorData(i,e)}_hotReloadRuntimeSceneLayers(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];if(!a)r.removeLayer(o);else if(r.hasLayer(o)){const s=r.getLayer(o);this._hotReloadRuntimeLayer(t,a,s)}}),e.forEach(t=>{const o=t.name;!i.filter(s=>s.name===o)[0]&&!r.hasLayer(o)&&r.addLayer(t)}),e.forEach((t,o)=>{r.setLayerIndex(t.name,o)})}_hotReloadRuntimeLayer(i,e,r){i.visibility!==e.visibility&&r.show(e.visibility),e.isLightingLayer&&((i.ambientLightColorR!==e.ambientLightColorR||i.ambientLightColorG!==e.ambientLightColorG||i.ambientLightColorB!==e.ambientLightColorB)&&r.setClearColor(e.ambientLightColorR,e.ambientLightColorG,e.ambientLightColorB),i.followBaseLayerCamera!==e.followBaseLayerCamera&&r.setFollowBaseLayerCamera(e.followBaseLayerCamera)),i.renderingType!==e.renderingType&&this._logs.push({kind:"error",message:`Could not change the rendering type (2D, 3D...) layer at runtime (for layer "${e.name}").`}),e.isLightingLayer!==i.isLightingLayer&&this._logs.push({kind:"error",message:`Could not add/remove a lighting layer at runtime (for layer "${e.name}").`}),this._hotReloadRuntimeLayerEffects(i.effects,e.effects,r)}_hotReloadRuntimeLayerEffects(i,e,r){i.forEach(t=>{const o=t.name,a=e.filter(s=>s.name===o)[0];a?r.hasEffect(o)&&(t.effectType!==a.effectType?(r.removeEffect(o),r.addEffect(a)):this._hotReloadRuntimeLayerEffect(t,a,r,o)):r.removeEffect(o)}),e.forEach(t=>{const o=t.name;!i.filter(s=>s.name===o)[0]&&!r.hasEffect(o)&&r.addEffect(t)})}_hotReloadRuntimeLayerEffect(i,e,r,t){for(let o in e.booleanParameters){const a=e.booleanParameters[o];a!==i.booleanParameters[o]&&r.setEffectBooleanParameter(t,o,a)}for(let o in e.doubleParameters){const a=e.doubleParameters[o];a!==i.doubleParameters[o]&&r.setEffectDoubleParameter(t,o,a)}for(let o in e.stringParameters){const a=e.stringParameters[o];a!==i.stringParameters[o]&&r.setEffectStringParameter(t,o,a)}}_hotReloadRuntimeSceneInstances(i,e,r){const t=r.getAdhocListOfAllInstances(),o=m.groupByPersistentUuid(i),a=m.groupByPersistentUuid(e),s=m.groupByPersistentUuid(t);for(let n in o){const h=o[n],l=a[n],f=s[n];h&&(!l||h.name!==l.name)?f&&f.deleteFromScene(r):h&&l&&f&&this._hotReloadRuntimeInstance(h,l,f)}for(let n in a){const h=o[n],l=a[n],f=s[n];l&&(!h||h.name!==l.name)&&!f&&r.createObjectsFrom([l],0,0,0,!0)}}_hotReloadRuntimeInstance(i,e,r){let t=!1;i.x!==e.x&&(r.setX(e.x),t=!0),i.y!==e.y&&(r.setY(e.y),t=!0),i.angle!==e.angle&&(r.setAngle(e.angle),t=!0),i.zOrder!==e.zOrder&&(r.setZOrder(e.zOrder),t=!0),i.layer!==e.layer&&(r.setLayer(e.layer),t=!0),d.RuntimeObject3D&&r instanceof d.RuntimeObject3D&&(i.z!==e.z&&e.z!==void 0&&(r.setZ(e.z),t=!0),i.rotationX!==e.rotationX&&e.rotationX!==void 0&&(r.setRotationX(e.rotationX),t=!0),i.rotationY!==e.rotationY&&e.rotationY!==void 0&&(r.setRotationY(e.rotationY),t=!0));let o=!1;e.customSize?i.customSize?(i.width!==e.width&&(r.setWidth(e.width),t=!0,o=!0),i.height!==e.height&&(r.setHeight(e.height),t=!0,o=!0)):(r.setWidth(e.width),r.setHeight(e.height),t=!0,o=!0):!e.customSize&&i.customSize&&(o=!0),d.RuntimeObject3D&&r instanceof d.RuntimeObject3D&&(i.depth!==e.depth&&e.depth!==void 0?(r.setDepth(e.depth),t=!0,o=!0):e.depth===void 0&&i.depth!==void 0&&(o=!0)),this._hotReloadVariablesContainer(i.initialVariables,e.initialVariables,r.getVariables());const a=e.numberProperties.some(n=>{const h=n.name,l=n.value,f=i.numberProperties.filter(c=>c.name===h)[0];return!f||f.value!==l}),s=e.stringProperties.some(n=>{const h=n.name,l=n.value,f=i.stringProperties.filter(c=>c.name===h)[0];return!f||f.value!==l});(a||s||o)&&(r.extraInitializationFromInitialInstance(e),t=!0),t&&r.notifyBehaviorsObjectHotReloaded()}static deepEqual(i,e){if(i===e)return!0;if(i&&e&&typeof i=="object"&&typeof e=="object"){if(i.constructor!==e.constructor)return!1;let r,t,o;if(Array.isArray(i)){if(r=i.length,r!=e.length)return!1;for(t=r;t--!=0;)if(!m.deepEqual(i[t],e[t]))return!1;return!0}if(i.valueOf!==Object.prototype.valueOf)return i.valueOf()===e.valueOf();if(i.toString!==Object.prototype.toString)return i.toString()===e.toString();if(o=Object.keys(i),r=o.length,r!==Object.keys(e).length)return!1;for(t=r;t--!=0;)if(!Object.prototype.hasOwnProperty.call(e,o[t]))return!1;for(t=r;t--!=0;){const a=o[t];if(!m.deepEqual(i[a],e[a]))return!1}return!0}return i!==i&&e!==e}}d.HotReloader=m})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(d){const u=new d.Logger("Hot reloader");class m{constructor(o){this._reloadedScriptElement={};this._logs=[];this._alreadyLoadedScriptFiles={};this._runtimeGame=o}static groupByPersistentUuid(o){return o.reduce(function(e,r){return r.persistentUuid&&(e[r.persistentUuid]=r),e},{})}_canReloadScriptFile(o){function e(r,t){const i=r.indexOf(t);return i!==-1&&i===r.length-t.length}return!(e(o,".h")||this._alreadyLoadedScriptFiles[o]&&(e(o,"box2d.js")||e(o,"sha256.js")||e(o,"shopify-buy.umd.polyfilled.min.js")||e(o,"pixi-multistyle-text.umd.js")||e(o,"pixi-tilemap.umd.js")||e(o,"bondage.min.js")||e(o,"pixi-particles-pixi-renderer.min.js")||e(o,"pixi-tilemap.umd.js")||e(o,"pixi-tilemap-helper.js")||e(o,"pako/dist/pako.min")))}_reloadScript(o){function e(t,i){const a=t.indexOf(i);return a!==-1&&a===t.length-i.length}if(!this._canReloadScriptFile(o))return this._logs.push({kind:"info",message:"Not reloading "+o+" as it is blocked for hot-reloading."}),Promise.resolve();const r=document.getElementsByTagName("head")[0];return r?new Promise((t,i)=>{const a=this._reloadedScriptElement[o];if(a)r.removeChild(a);else{const n=r.getElementsByTagName("script");for(let h=0;h<n.length;++h){const l=n[h];e(l.src,o)&&r.removeChild(l)}}const s=document.createElement("script");s.src=o+"?timestamp="+Date.now(),s.onload=()=>{t()},s.onerror=n=>{i(n)},r.appendChild(s),this._reloadedScriptElement[o]=s}):Promise.reject(new Error("No head element found, are you in a navigator?"))}hotReload(){u.info("Hot reload started"),this._runtimeGame.pause(!0),this._logs=[];const o=d.projectData,e=d.runtimeGameOptions.scriptFiles;e.forEach(t=>{this._alreadyLoadedScriptFiles[t.path]=!0});const r={};for(let t in d.behaviorsTypes.items)r[t]=d.behaviorsTypes.items[t];return this._reloadScript("data.js").then(()=>{const t=d.projectData,i=d.runtimeGameOptions,a=i.scriptFiles,s=!!i.projectDataOnlyExport;return this.reloadScriptFiles(t,e,a,s).then(()=>{const n=this._computeChangedRuntimeBehaviors(r,d.behaviorsTypes.items);return this._hotReloadRuntimeGame(o,t,n,this._runtimeGame)}).catch(n=>{const h=n.target;h instanceof HTMLScriptElement?this._logs.push({kind:"fatal",message:"Unable to reload script:"+h.src}):this._logs.push({kind:"fatal",message:"Unexpected error happened while hot-reloading:"+n.message})}).then(()=>(u.info("Hot reload finished with logs:",this._logs),this._runtimeGame.pause(!1),this._logs))})}_computeChangedRuntimeBehaviors(o,e){const r=[];for(let t in o){const i=o[t],a=e[t];a?i!==a&&(this._logs.push({kind:"info",message:"Behavior with type "+t+" was changed, and will be re-instantiated in gdjs.RuntimeObjects using it."}),r.push({oldBehaviorConstructor:i,newBehaviorConstructor:a,behaviorTypeName:t})):this._logs.push({kind:"warning",message:"Behavior with type "+t+" was removed from the registered behaviors in gdjs."})}return r}reloadScriptFiles(o,e,r,t){const i=[];t||o.layouts.forEach((a,s)=>{i.push(this._reloadScript("code"+s+".js"))});for(let a=0;a<r.length;++a){const s=r[a],n=e.filter(h=>h.path===s.path)[0];n?s.hash!==n.hash&&(this._logs.push({kind:"info",message:"Reloading "+s.path+" because it was changed."}),i.push(this._reloadScript(s.path))):(this._logs.push({kind:"info",message:"Loading "+s.path+" as it was added to the list of scripts."}),i.push(this._reloadScript(s.path)))}for(let a=0;a<e.length;++a){const s=e[a];!r.filter(h=>h.path===s.path)[0]&&!t&&this._logs.push({kind:"warning",message:"Script file "+s.path+" was removed."})}return Promise.all(i)}async _hotReloadRuntimeGame(o,e,r,t){const i=t.getSceneStack(),a=i.getCurrentScene();if(!a){this._logs.push({kind:"error",message:"Can't hot-reload as no scene are opened."});return}t.setProjectData(e),await t.loadFirstAssetsAndStartBackgroundLoading(a.getName(),()=>{}),this._hotReloadVariablesContainer(o.variables,e.variables,t.getVariables()),i._stack.forEach(s=>{const n=o.layouts.filter(l=>l.name===s.getName())[0],h=e.layouts.filter(l=>l.name===s.getName())[0];n&&h?this._hotReloadRuntimeScene(n,h,r,s):this._logs.push({kind:"error",message:"Scene "+n.name+" was removed. A fresh preview should be launched."})}),e.externalLayouts.forEach(s=>{const n=o.externalLayouts.filter(h=>h.name===s.name)[0];n&&!m.deepEqual(n,s)&&i._stack.forEach(h=>{this._hotReloadRuntimeSceneInstances(n.instances,s.instances,h)})})}_hotReloadVariablesContainer(o,e,r){e.forEach(t=>{const i=t.name,a=o.find(n=>n.name===i),s=r.get(t.name);a?d.Variable.isPrimitive(t.type||"number")&&(a.value!==t.value||!d.Variable.isPrimitive(a.type||"number"))?(r.remove(i),r.add(i,new d.Variable(t))):d.Variable.isPrimitive(t.type||"number")||(t.type==="structure"?this._hotReloadStructureVariable(a.children,t.children,s):(r.remove(i),r.add(i,new d.Variable(t)))):r.add(i,new d.Variable(t))}),o.forEach(t=>{e.find(a=>a.name===t.name)||r.remove(t.name)})}_hotReloadStructureVariable(o,e,r){o?(o.forEach(t=>{const i=e.find(a=>a.name===t.name);i?d.Variable.isPrimitive(i.type||"number")&&(t.value!==i.value||!d.Variable.isPrimitive(t.type||"number"))?r.addChild(i.name,new d.Variable(i)):d.Variable.isPrimitive(i.type||"number")||(i.type==="structure"?this._hotReloadStructureVariable(t.children,i.children,r.getChild(i.name)):r.addChild(i.name,new d.Variable(i))):r.removeChild(t.name)}),e.forEach(t=>{o.find(a=>a.name===t.name)||r.addChild(t.name,new d.Variable(t))})):e.forEach(t=>{r.addChild(t.name,new d.Variable(t))})}_hotReloadRuntimeScene(o,e,r,t){t.setBackgroundColor(e.r,e.v,e.b),o.title!==e.title&&t.getGame().getRenderer().setWindowTitle(e.title),this._hotReloadVariablesContainer(o.variables,e.variables,t.getVariables()),this._hotReloadRuntimeSceneBehaviorsSharedData(o.behaviorsSharedData,e.behaviorsSharedData,t),this._reinstantiateRuntimeSceneRuntimeBehaviors(r,e.objects,t),this._hotReloadRuntimeSceneObjects(o.objects,e.objects,t),this._hotReloadRuntimeSceneInstances(o.instances,e.instances,t),this._hotReloadRuntimeSceneLayers(o.layers,e.layers,t),t.setEventsGeneratedCodeFunction(e)}_hotReloadRuntimeSceneBehaviorsSharedData(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];a?m.deepEqual(t,a)||r.setInitialSharedDataForBehavior(a.name,a):r.setInitialSharedDataForBehavior(t.name,null)}),e.forEach(t=>{const i=t.name;o.filter(s=>s.name===i)[0]||r.setInitialSharedDataForBehavior(t.name,t)})}_reinstantiateRuntimeSceneRuntimeBehaviors(o,e,r){e.forEach(t=>{const i=t.name,a=t.behaviors,s=r.getObjects(i);o.forEach(n=>{const h=n.behaviorTypeName;a.filter(l=>l.type===h).forEach(l=>{const f=l.name;this._logs.push({kind:"info",message:'Re-instantiating behavior named "'+f+'" for instances of object "'+i+'".'}),s.forEach(c=>{this._reinstantiateRuntimeObjectRuntimeBehavior(l,c)})})})})}_reinstantiateRuntimeObjectRuntimeBehavior(o,e){const r=o.name,t=e.getBehavior(r);if(!t)return;e.removeBehavior(r),e.addNewBehavior(o);const i=e.getBehavior(r);if(!i){this._logs.push({kind:"error",message:"Could not create behavior "+r+" (type: "+o.type+") for object "+e.getName()});return}for(let a in t)if(!!t.hasOwnProperty(a))if(a==="_behaviorData"){i[a]=i[a]||{};for(let s in t[a])i[a][s]=t[a][s]}else i[a]=t[a]}_hotReloadRuntimeSceneObjects(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];!a||t.type!==a.type?r.unregisterObject(i):r.isObjectRegistered(i)&&this._hotReloadRuntimeSceneObject(t,a,r)}),e.forEach(t=>{const i=t.name,a=o.filter(s=>s.name===i)[0];(!a||a.type!==t.type)&&!r.isObjectRegistered(i)&&r.registerObject(t)})}_hotReloadRuntimeSceneObject(o,e,r){let t=!0;if(!m.deepEqual(o,e)){this._logs.push({kind:"info",message:'Object "'+e.name+'" was modified and is hot-reloaded.'}),r.updateObject(e);const i=r.getObjects(e.name);i.forEach(a=>{t=a.updateFromObjectData(o,e)&&t}),i.forEach(a=>{this._hotReloadVariablesContainer(o.variables,e.variables,a.getVariables())}),this._hotReloadRuntimeObjectsBehaviors(o.behaviors,e.behaviors,i),this._hotReloadRuntimeObjectsEffects(o.effects,e.effects,i)}t||this._logs.push({kind:"error",message:'Object "'+e.name+'" could not be hot-reloaded. A fresh preview should be run.'})}_hotReloadRuntimeObjectsBehaviors(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];if(!a)r.forEach(s=>{s.hasBehavior(i)&&(s.removeBehavior(i)||this._logs.push({kind:"error",message:"Behavior "+i+" could not be removed from object"+s.getName()}))});else if(!m.deepEqual(t,a)){let s=!0;r.forEach(n=>{const h=n.getBehavior(a.name);h&&(s=this._hotReloadRuntimeBehavior(t,a,h)&&s)}),s||this._logs.push({kind:"error",message:a.name+" behavior could not be hot-reloaded."})}}),e.forEach(t=>{const i=t.name;if(!o.filter(s=>s.name===i)[0]){let s=!0;r.forEach(n=>{s=n.addNewBehavior(t)&&s}),s||this._logs.push({kind:"error",message:t.name+" behavior could not be added during hot-reload."})}})}_hotReloadRuntimeObjectsEffects(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];if(!a)r.forEach(s=>{s.hasEffect(i)&&(s.removeEffect(i)||this._logs.push({kind:"error",message:"Effect "+i+" could not be removed from object"+s.getName()}))});else if(!m.deepEqual(t,a)){let s=!0;r.forEach(n=>{t.effectType===a.effectType?s=n.updateAllEffectParameters(a)&&s:(n.removeEffect(t.name),n.addEffect(a))}),s||this._logs.push({kind:"error",message:a.name+" effect could not be hot-reloaded."})}}),e.forEach(t=>{const i=t.name;if(!o.filter(s=>s.name===i)[0]){let s=!0;r.forEach(n=>{s=n.addEffect(t)&&s}),s||this._logs.push({kind:"error",message:t.name+" effect could not be added during hot-reload."})}})}_hotReloadRuntimeBehavior(o,e,r){return r.updateFromBehaviorData(o,e)}_hotReloadRuntimeSceneLayers(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];if(!a)r.removeLayer(i);else if(r.hasLayer(i)){const s=r.getLayer(i);this._hotReloadRuntimeLayer(t,a,s)}}),e.forEach(t=>{const i=t.name;!o.filter(s=>s.name===i)[0]&&!r.hasLayer(i)&&r.addLayer(t)}),e.forEach((t,i)=>{r.setLayerIndex(t.name,i)})}_hotReloadRuntimeLayer(o,e,r){o.visibility!==e.visibility&&r.show(e.visibility),e.isLightingLayer&&((o.ambientLightColorR!==e.ambientLightColorR||o.ambientLightColorG!==e.ambientLightColorG||o.ambientLightColorB!==e.ambientLightColorB)&&r.setClearColor(e.ambientLightColorR,e.ambientLightColorG,e.ambientLightColorB),o.followBaseLayerCamera!==e.followBaseLayerCamera&&r.setFollowBaseLayerCamera(e.followBaseLayerCamera)),o.renderingType!==e.renderingType&&this._logs.push({kind:"error",message:`Could not change the rendering type (2D, 3D...) layer at runtime (for layer "${e.name}").`}),e.isLightingLayer!==o.isLightingLayer&&this._logs.push({kind:"error",message:`Could not add/remove a lighting layer at runtime (for layer "${e.name}").`}),this._hotReloadRuntimeLayerEffects(o.effects,e.effects,r)}_hotReloadRuntimeLayerEffects(o,e,r){o.forEach(t=>{const i=t.name,a=e.filter(s=>s.name===i)[0];a?r.hasEffect(i)&&(t.effectType!==a.effectType?(r.removeEffect(i),r.addEffect(a)):this._hotReloadRuntimeLayerEffect(t,a,r,i)):r.removeEffect(i)}),e.forEach(t=>{const i=t.name;!o.filter(s=>s.name===i)[0]&&!r.hasEffect(i)&&r.addEffect(t)})}_hotReloadRuntimeLayerEffect(o,e,r,t){for(let i in e.booleanParameters){const a=e.booleanParameters[i];a!==o.booleanParameters[i]&&r.setEffectBooleanParameter(t,i,a)}for(let i in e.doubleParameters){const a=e.doubleParameters[i];a!==o.doubleParameters[i]&&r.setEffectDoubleParameter(t,i,a)}for(let i in e.stringParameters){const a=e.stringParameters[i];a!==o.stringParameters[i]&&r.setEffectStringParameter(t,i,a)}}_hotReloadRuntimeSceneInstances(o,e,r){const t=r.getAdhocListOfAllInstances(),i=m.groupByPersistentUuid(o),a=m.groupByPersistentUuid(e),s=m.groupByPersistentUuid(t);for(let n in i){const h=i[n],l=a[n],f=s[n];h&&(!l||h.name!==l.name)?f&&f.deleteFromScene(r):h&&l&&f&&this._hotReloadRuntimeInstance(h,l,f)}for(let n in a){const h=i[n],l=a[n],f=s[n];l&&(!h||h.name!==l.name)&&!f&&r.createObjectsFrom([l],0,0,0,!0)}}_hotReloadRuntimeInstance(o,e,r){let t=!1;o.x!==e.x&&(r.setX(e.x),t=!0),o.y!==e.y&&(r.setY(e.y),t=!0),o.angle!==e.angle&&(r.setAngle(e.angle),t=!0),o.zOrder!==e.zOrder&&(r.setZOrder(e.zOrder),t=!0),o.layer!==e.layer&&(r.setLayer(e.layer),t=!0),d.Base3DHandler&&d.Base3DHandler.is3D(r)&&(o.z!==e.z&&e.z!==void 0&&(r.setZ(e.z),t=!0),o.rotationX!==e.rotationX&&e.rotationX!==void 0&&(r.setRotationX(e.rotationX),t=!0),o.rotationY!==e.rotationY&&e.rotationY!==void 0&&(r.setRotationY(e.rotationY),t=!0));let i=!1;e.customSize?o.customSize?(o.width!==e.width&&(r.setWidth(e.width),t=!0,i=!0),o.height!==e.height&&(r.setHeight(e.height),t=!0,i=!0)):(r.setWidth(e.width),r.setHeight(e.height),t=!0,i=!0):!e.customSize&&o.customSize&&(i=!0),d.Base3DHandler&&d.Base3DHandler.is3D(r)&&(o.depth!==e.depth&&e.depth!==void 0?(r.setDepth(e.depth),t=!0,i=!0):e.depth===void 0&&o.depth!==void 0&&(i=!0)),this._hotReloadVariablesContainer(o.initialVariables,e.initialVariables,r.getVariables());const a=e.numberProperties.some(n=>{const h=n.name,l=n.value,f=o.numberProperties.filter(c=>c.name===h)[0];return!f||f.value!==l}),s=e.stringProperties.some(n=>{const h=n.name,l=n.value,f=o.stringProperties.filter(c=>c.name===h)[0];return!f||f.value!==l});(a||s||i)&&(r.extraInitializationFromInitialInstance(e),t=!0),t&&r.notifyBehaviorsObjectHotReloaded()}static deepEqual(o,e){if(o===e)return!0;if(o&&e&&typeof o=="object"&&typeof e=="object"){if(o.constructor!==e.constructor)return!1;let r,t,i;if(Array.isArray(o)){if(r=o.length,r!=e.length)return!1;for(t=r;t--!=0;)if(!m.deepEqual(o[t],e[t]))return!1;return!0}if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===e.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===e.toString();if(i=Object.keys(o),r=i.length,r!==Object.keys(e).length)return!1;for(t=r;t--!=0;)if(!Object.prototype.hasOwnProperty.call(e,i[t]))return!1;for(t=r;t--!=0;){const a=i[t];if(!m.deepEqual(o[a],e[a]))return!1}return!0}return o!==o&&e!==e}}d.HotReloader=m})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=hot-reloader.js.map
|