gdcore-tools 2.0.0-beta5 → 2.0.0-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Cordova/config.xml +4 -0
- package/dist/Runtime/Cordova/package.json +12 -20
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- 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/AmbientLight.js +1 -1
- package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- 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/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
- 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/AdMob/admobtools.js +1 -1
- package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
- package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
- package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
- 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 +40 -49
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/JsExtension.js +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/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/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/glow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glow-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/ExampleJsExtension/JsExtension.js +18 -21
- package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
- package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
- package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
- 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 +50 -38
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +112 -7
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- 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/Physics2Behavior/JsExtension.js +127 -40
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.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/shapepainterruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/JsExtension.js +77 -36
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +55 -56
- 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/textruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
- 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 +511 -287
- 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.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +12 -1
- 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.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- 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/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -0
- package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/ResourceLoader.js +1 -1
- package/dist/Runtime/ResourceLoader.js.map +2 -2
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/SpriteAnimator.js +1 -1
- package/dist/Runtime/SpriteAnimator.js.map +2 -2
- package/dist/Runtime/debugger-client/InGameDebugger.js +1 -1
- package/dist/Runtime/debugger-client/InGameDebugger.js.map +2 -2
- package/dist/Runtime/debugger-client/abstract-debugger-client.js +1 -1
- package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/hot-reloader.js +2 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/debugger-client/minimal-debugger-client.js +2 -0
- package/dist/Runtime/debugger-client/minimal-debugger-client.js.map +7 -0
- package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/window-message-debugger-client.js.map +2 -2
- package/dist/Runtime/events-tools/inputtools.js +1 -1
- package/dist/Runtime/events-tools/inputtools.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/gd.js +1 -1
- package/dist/Runtime/gd.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/inputmanager.js +1 -1
- package/dist/Runtime/inputmanager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.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/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/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/types/project-data.d.ts +36 -8
- package/dist/Runtime/variablescontainer.js +1 -1
- package/dist/Runtime/variablescontainer.js.map +2 -2
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +149 -75
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){const h=new i.Logger("RuntimeScene"),d=new i.Logger("RuntimeScene (setup warnings)");class c extends i.RuntimeInstanceContainer{constructor(t){super();this._eventsFunction=null;this._lastId=0;this._name="";this._gameStopRequested=!1;this._requestedScene="";this._asyncTasksManager=new i.AsyncTasksManager;this._isLoaded=!1;this._isJustResumed=!1;this._backgroundColor=0;this._clearCanvas=!0;this._profiler=null;this._onProfilerStopped=null;this.networkId=null;this._runtimeGame=t,this._variables=new i.VariablesContainer,this._variablesByExtensionName=new Map,this._timeManager=new i.TimeManager,this._onceTriggers=new i.OnceTriggers,this._requestedChange=l.CONTINUE,this._cachedGameResolutionWidth=t?t.getGameResolutionWidth():0,this._cachedGameResolutionHeight=t?t.getGameResolutionHeight():0,this._renderer=new i.RuntimeSceneRenderer(this,t?t.getRenderer():null),this._debuggerRenderer=new i.DebuggerRenderer(this),this.onGameResolutionResized()}addLayer(t){const e=new i.Layer(t,this);this._layers.put(t.name,e),this._orderedLayers.push(e)}onGameResolutionResized(){const t=this.getViewportOriginX(),e=this.getViewportOriginY();this._cachedGameResolutionWidth=this._runtimeGame?this._runtimeGame.getGameResolutionWidth():0,this._cachedGameResolutionHeight=this._runtimeGame?this._runtimeGame.getGameResolutionHeight():0;for(const a in this._layers.items)this._layers.items.hasOwnProperty(a)&&this._layers.items[a].onGameResolutionResized(t,e);this._renderer.onGameResolutionResized()}loadFromScene(t){if(!t){h.error("loadFromScene was called without a scene");return}const{sceneData:e,usedExtensionsWithVariablesData:a}=t;this._isLoaded&&this.unloadScene(),this._runtimeGame&&this._runtimeGame.getRenderer().setWindowTitle(e.title),this._name=e.name,this.setBackgroundColor(e.r,e.v,e.b);for(let r=0,s=e.layers.length;r<s;++r)this.addLayer(e.layers[r]);this._variables=new i.VariablesContainer(e.variables);for(const r of a)this._variablesByExtensionName.set(r.name,new i.VariablesContainer(r.sceneVariables));for(let r=0,s=e.behaviorsSharedData.length;r<s;++r){const o=e.behaviorsSharedData[r];this.setInitialSharedDataForBehavior(o.name,o)}const n=this.getGame().getInitialObjectsData();for(let r=0,s=n.length;r<s;++r)this.registerObject(n[r]);for(let r=0,s=e.objects.length;r<s;++r)this.registerObject(e.objects[r]);if(this.createObjectsFrom(e.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this.setEventsGeneratedCodeFunction(e),this._onceTriggers=new i.OnceTriggers,this._runtimeGame&&!this._runtimeGame.wasFirstSceneLoaded())for(let r=0;r<i.callbacksFirstRuntimeSceneLoaded.length;++r)i.callbacksFirstRuntimeSceneLoaded[r](this);for(let r=0;r<i.callbacksRuntimeSceneLoaded.length;++r)i.callbacksRuntimeSceneLoaded[r](this);e.stopSoundsOnStartup&&this._runtimeGame&&this._runtimeGame.getSoundManager().clearAll(),this._isLoaded=!0,this._timeManager.reset()}getInitialSharedDataForBehavior(t){const e=super.getInitialSharedDataForBehavior(t);return e||h.error("Can't find shared data for behavior with name: "+t),e}onPause(){const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e)t[e].onScenePaused(this);for(let e=0;e<i.callbacksRuntimeScenePaused.length;++e)i.callbacksRuntimeScenePaused[e](this)}onResume(){this._isJustResumed=!0;const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e)t[e].onSceneResumed(this);for(let e=0;e<i.callbacksRuntimeSceneResumed.length;++e)i.callbacksRuntimeSceneResumed[e](this)}unloadScene(){if(!this._isLoaded)return;this._profiler&&this.stopProfiler();for(let e=0;e<i.callbacksRuntimeSceneUnloading.length;++e)i.callbacksRuntimeSceneUnloading[e](this);const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e){const n=t[e];n.onDeletedFromScene(this),n.onDestroyed()}this._renderer&&this._renderer.onSceneUnloaded();for(let e=0;e<i.callbacksRuntimeSceneUnloaded.length;++e)i.callbacksRuntimeSceneUnloaded[e](this);this._destroy(),this._isLoaded=!1,this.onGameResolutionResized()}_destroy(){super._destroy(),this._variables=new i.VariablesContainer,this._variablesByExtensionName=new Map,this._initialBehaviorSharedData=new Hashtable,this._eventsFunction=null,this._lastId=0,this.networkId=null,this._onceTriggers=null}setEventsGeneratedCodeFunction(t){const e=i[t.mangledName+"Code"];e&&e.func?this._eventsFunction=e.func:(d.warn("No function found for running logic of scene "+this._name),this._eventsFunction=function(){})}setEventsFunction(t){this._eventsFunction=t}renderAndStep(t){this._profiler&&this._profiler.beginFrame(),this._requestedChange=l.CONTINUE,this._timeManager.update(t,this._runtimeGame.getMinimalFramerate()),this._profiler&&this._profiler.begin("asynchronous actions (wait action, etc...)"),this._asyncTasksManager.processTasks(this),this._profiler&&this._profiler.end("asynchronous actions (wait action, etc...)"),this._profiler&&this._profiler.begin("objects (pre-events)"),this._updateObjectsPreEvents(),this._profiler&&this._profiler.end("objects (pre-events)"),this._profiler&&this._profiler.begin("callbacks and extensions (pre-events)");for(let e=0;e<i.callbacksRuntimeScenePreEvents.length;++e)i.callbacksRuntimeScenePreEvents[e](this);this._profiler&&this._profiler.end("callbacks and extensions (pre-events)"),this._profiler&&this._profiler.begin("events"),this._eventsFunction!==null&&this._eventsFunction(this),this._profiler&&this._profiler.end("events"),this._profiler&&this._profiler.begin("objects (post-events)"),this._updateObjectsPostEvents(),this._profiler&&this._profiler.end("objects (post-events)"),this._profiler&&this._profiler.begin("callbacks and extensions (post-events)");for(let e=0;e<i.callbacksRuntimeScenePostEvents.length;++e)i.callbacksRuntimeScenePostEvents[e](this);return this._profiler&&this._profiler.end("callbacks and extensions (post-events)"),this._profiler&&this._profiler.begin("objects (pre-render, effects update)"),this._updateObjectsPreRender(),this._profiler&&this._profiler.end("objects (pre-render, effects update)"),this._profiler&&this._profiler.begin("layers (effects update)"),this._updateLayersPreRender(),this._profiler&&this._profiler.end("layers (effects update)"),this._profiler&&this._profiler.begin("render"),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(this.getAdhocListOfAllInstances(),this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),this._isJustResumed=!1,this.render(),this._profiler&&this._profiler.end("render"),this._profiler&&this._profiler.endFrame(),!!this.getRequestedChange()}render(){this._renderer.render()}_updateObjectsPreRender(){if(this._timeManager.isFirstFrame()){super._updateObjectsPreRender();return}else{this._updateLayersCameraCoordinates(2);const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e){const n=t[e],r=n.getRendererObject();if(r){if(n.isHidden())r.visible=!1;else{const s=this._layersCameraCoordinates[n.getLayer()];if(!s)continue;const o=n.getVisibilityAABB();r.visible=!o||!(o.min[0]>s[2]||o.min[1]>s[3]||o.max[0]<s[0]||o.max[1]<s[1])}r.visible&&(this._runtimeGame.getEffectsManager().updatePreRender(n.getRendererEffects(),n),n.updatePreRender(this))}else n.updatePreRender(this)}}}setBackgroundColor(t,e,a){this._backgroundColor=parseInt(i.rgbToHex(t,e,a),16)}getBackgroundColor(){return this._backgroundColor}setClearCanvas(t){this._clearCanvas=t}getClearCanvas(){return this._clearCanvas}getName(){return this._name}createNewUniqueId(){return this._lastId++,this._lastId}getRenderer(){return this._renderer}getDebuggerRenderer(){return this._debuggerRenderer}getGame(){return this._runtimeGame}getScene(){return this}getViewportWidth(){return this._cachedGameResolutionWidth}getViewportHeight(){return this._cachedGameResolutionHeight}getViewportOriginX(){return this._cachedGameResolutionWidth/2}getViewportOriginY(){return this._cachedGameResolutionHeight/2}convertCoords(t,e,a){const n=a||[0,0];return n[0]=t,n[1]=e,n}convertInverseCoords(t,e,a){const n=a||[0,0];return n[0]=t,n[1]=e,n}onChildrenLocationChanged(){}getVariables(){return this._variables}getVariablesForExtension(t){return this._variablesByExtensionName.get(t)||null}getTimeManager(){return this._timeManager}getElapsedTime(){return this._timeManager.getElapsedTime()}getSoundManager(){return this._runtimeGame.getSoundManager()}getAsyncTasksManager(){return this._asyncTasksManager}getRequestedChange(){return this._requestedChange}getRequestedScene(){return this._requestedScene}requestChange(t,e){this._requestedChange=t,e&&(this._requestedScene=e)}getProfiler(){return this._profiler}startProfiler(t){this._profiler||(this._profiler=new i.Profiler,this._onProfilerStopped=t)}stopProfiler(){if(!this._profiler)return;const t=this._profiler,e=this._onProfilerStopped;this._profiler=null,this._onProfilerStopped=null,e&&e(t)}getOnceTriggers(){return this._onceTriggers}sceneJustResumed(){return this._isJustResumed}getNetworkSyncData(t){const e=t.playerNumber,a=this._variables.getNetworkSyncData(t),n={};return this._variablesByExtensionName.forEach((r,s)=>{const o=r.getNetworkSyncData(t);o&&(n[s]=o)}),e!==void 0&&e!==1&&(!this.networkId||a.length===0&&!Object.keys(n).length)?null:{var:a,extVar:n,id:this.getOrCreateNetworkId()}}updateFromNetworkSyncData(t){if(t.var&&this._variables.updateFromNetworkSyncData(t.var),t.extVar)for(const e in t.extVar){if(!t.extVar.hasOwnProperty(e))continue;const a=t.extVar[e],n=this._variablesByExtensionName.get(e);n&&n.updateFromNetworkSyncData(a)}}getOrCreateNetworkId(){if(!this.networkId){const t=i.makeUuid().substring(0,8);this.networkId=t}return this.networkId}}i.RuntimeScene=c;let l;(function(s){s[s.CONTINUE=0]="CONTINUE",s[s.PUSH_SCENE=1]="PUSH_SCENE",s[s.POP_SCENE=2]="POP_SCENE",s[s.REPLACE_SCENE=3]="REPLACE_SCENE",s[s.CLEAR_SCENES=4]="CLEAR_SCENES",s[s.STOP_GAME=5]="STOP_GAME"})(l=i.SceneChangeRequest||(i.SceneChangeRequest={}))})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){const h=new i.Logger("RuntimeScene"),d=new i.Logger("RuntimeScene (setup warnings)");class c extends i.RuntimeInstanceContainer{constructor(t){super();this._eventsFunction=null;this._lastId=0;this._name="";this._gameStopRequested=!1;this._requestedScene="";this._asyncTasksManager=new i.AsyncTasksManager;this._isLoaded=!1;this._isJustResumed=!1;this._backgroundColor=0;this._clearCanvas=!0;this._profiler=null;this._onProfilerStopped=null;this.networkId=null;this._runtimeGame=t,this._variables=new i.VariablesContainer,this._variablesByExtensionName=new Map,this._timeManager=new i.TimeManager,this._onceTriggers=new i.OnceTriggers,this._requestedChange=l.CONTINUE,this._cachedGameResolutionWidth=t?t.getGameResolutionWidth():0,this._cachedGameResolutionHeight=t?t.getGameResolutionHeight():0,this._renderer=new i.RuntimeSceneRenderer(this,t?t.getRenderer():null),this._debuggerRenderer=new i.DebuggerRenderer(this),this.onGameResolutionResized()}addLayer(t){const e=new i.Layer(t,this);this._layers.put(t.name,e),this._orderedLayers.push(e)}onGameResolutionResized(){const t=this.getViewportOriginX(),e=this.getViewportOriginY();this._cachedGameResolutionWidth=this._runtimeGame?this._runtimeGame.getGameResolutionWidth():0,this._cachedGameResolutionHeight=this._runtimeGame?this._runtimeGame.getGameResolutionHeight():0;for(const a in this._layers.items)this._layers.items.hasOwnProperty(a)&&this._layers.items[a].onGameResolutionResized(t,e);this._renderer.onGameResolutionResized()}loadFromScene(t){if(!t){h.error("loadFromScene was called without a scene");return}const{sceneData:e,usedExtensionsWithVariablesData:a}=t;this._isLoaded&&this.unloadScene(),this._runtimeGame&&this._runtimeGame.getRenderer().setWindowTitle(e.title),this._name=e.name,this.setBackgroundColor(e.r,e.v,e.b);for(let r=0,s=e.layers.length;r<s;++r)this.addLayer(e.layers[r]);this._variables=new i.VariablesContainer(e.variables);for(const r of a)this._variablesByExtensionName.set(r.name,new i.VariablesContainer(r.sceneVariables));for(let r=0,s=e.behaviorsSharedData.length;r<s;++r){const o=e.behaviorsSharedData[r];this.setInitialSharedDataForBehavior(o.name,o)}const n=this.getGame().getInitialObjectsData();for(let r=0,s=n.length;r<s;++r)this.registerObject(n[r]);for(let r=0,s=e.objects.length;r<s;++r)this.registerObject(e.objects[r]);if(this.createObjectsFrom(e.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this.setEventsGeneratedCodeFunction(e),this._onceTriggers=new i.OnceTriggers,this._runtimeGame&&!this._runtimeGame.wasFirstSceneLoaded())for(let r=0;r<i.callbacksFirstRuntimeSceneLoaded.length;++r)i.callbacksFirstRuntimeSceneLoaded[r](this);for(let r=0;r<i.callbacksRuntimeSceneLoaded.length;++r)i.callbacksRuntimeSceneLoaded[r](this);e.stopSoundsOnStartup&&this._runtimeGame&&this._runtimeGame.getSoundManager().clearAll(),this._isLoaded=!0,this._timeManager.reset()}getInitialSharedDataForBehavior(t){const e=super.getInitialSharedDataForBehavior(t);return e||h.error("Can't find shared data for behavior with name: "+t),e}onPause(){const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e)t[e].onScenePaused(this);for(let e=0;e<i.callbacksRuntimeScenePaused.length;++e)i.callbacksRuntimeScenePaused[e](this)}onResume(){this._isJustResumed=!0;const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e)t[e].onSceneResumed(this);for(let e=0;e<i.callbacksRuntimeSceneResumed.length;++e)i.callbacksRuntimeSceneResumed[e](this)}unloadScene(){if(!this._isLoaded)return;this._profiler&&this.stopProfiler();for(let e=0;e<i.callbacksRuntimeSceneUnloading.length;++e)i.callbacksRuntimeSceneUnloading[e](this);const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e){const n=t[e];n.onDeletedFromScene(this),n.onDestroyed()}this._renderer&&this._renderer.onSceneUnloaded();for(let e=0;e<i.callbacksRuntimeSceneUnloaded.length;++e)i.callbacksRuntimeSceneUnloaded[e](this);this._destroy(),this._isLoaded=!1,this.onGameResolutionResized()}_destroy(){super._destroy(),this._variables=new i.VariablesContainer,this._variablesByExtensionName=new Map,this._initialBehaviorSharedData=new Hashtable,this._eventsFunction=null,this._lastId=0,this.networkId=null,this._onceTriggers=null}setEventsGeneratedCodeFunction(t){const e=i[t.mangledName+"Code"];e&&e.func?this._eventsFunction=e.func:(d.warn("No function found for running logic of scene "+this._name),this._eventsFunction=function(){})}setEventsFunction(t){this._eventsFunction=t}renderAndStep(t){this._profiler&&this._profiler.beginFrame(),this._requestedChange=l.CONTINUE,this._timeManager.update(t,this._runtimeGame.getMinimalFramerate()),this._profiler&&this._profiler.begin("asynchronous actions (wait action, etc...)"),this._asyncTasksManager.processTasks(this),this._profiler&&this._profiler.end("asynchronous actions (wait action, etc...)"),this._profiler&&this._profiler.begin("objects (pre-events)"),this._updateObjectsPreEvents(),this._profiler&&this._profiler.end("objects (pre-events)"),this._profiler&&this._profiler.begin("callbacks and extensions (pre-events)");for(let e=0;e<i.callbacksRuntimeScenePreEvents.length;++e)i.callbacksRuntimeScenePreEvents[e](this);this._profiler&&this._profiler.end("callbacks and extensions (pre-events)"),this._profiler&&this._profiler.begin("events"),this._eventsFunction!==null&&this._eventsFunction(this),this._profiler&&this._profiler.end("events"),this._profiler&&this._profiler.begin("objects (post-events)"),this._updateObjectsPostEvents(),this._profiler&&this._profiler.end("objects (post-events)"),this._profiler&&this._profiler.begin("callbacks and extensions (post-events)");for(let e=0;e<i.callbacksRuntimeScenePostEvents.length;++e)i.callbacksRuntimeScenePostEvents[e](this);return this._profiler&&this._profiler.end("callbacks and extensions (post-events)"),this._profiler&&this._profiler.begin("objects (pre-render, effects update)"),this._updateObjectsPreRender(),this._profiler&&this._profiler.end("objects (pre-render, effects update)"),this._profiler&&this._profiler.begin("layers (effects update)"),this._updateLayersPreRender(),this._profiler&&this._profiler.end("layers (effects update)"),this._profiler&&this._profiler.begin("render"),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(this.getAdhocListOfAllInstances(),this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),this._isJustResumed=!1,this.render(),this._profiler&&this._profiler.end("render"),this._profiler&&this._profiler.endFrame(),!!this.getRequestedChange()}render(){this._renderer.render()}_updateObjectsPreRender(){if(this._timeManager.isFirstFrame()){super._updateObjectsPreRender();return}else{this._updateLayersCameraCoordinates(2);const t=this.getAdhocListOfAllInstances();for(let e=0,a=t.length;e<a;++e){const n=t[e],r=n.getRendererObject();if(r){if(n.isHidden())r.visible=!1;else{const s=this._layersCameraCoordinates[n.getLayer()];if(!s)continue;const o=n.getVisibilityAABB();r.visible=!o||!(o.min[0]>s[2]||o.min[1]>s[3]||o.max[0]<s[0]||o.max[1]<s[1])}r.visible&&(this._runtimeGame.getEffectsManager().updatePreRender(n.getRendererEffects(),n),n.updatePreRender(this))}else n.updatePreRender(this)}}}setBackgroundColor(t,e,a){this._backgroundColor=parseInt(i.rgbToHex(t,e,a),16)}getBackgroundColor(){return this._backgroundColor}setClearCanvas(t){this._clearCanvas=t}getClearCanvas(){return this._clearCanvas}getName(){return this._name}createNewUniqueId(){return this._lastId++,this._lastId}getRenderer(){return this._renderer}getDebuggerRenderer(){return this._debuggerRenderer}getGame(){return this._runtimeGame}getScene(){return this}getUnrotatedViewportMinX(){return 0}getUnrotatedViewportMinY(){return 0}getUnrotatedViewportMaxX(){return this._cachedGameResolutionWidth}getUnrotatedViewportMaxY(){return this._cachedGameResolutionHeight}getInitialUnrotatedViewportMinX(){return 0}getInitialUnrotatedViewportMinY(){return 0}getInitialUnrotatedViewportMaxX(){return this.getGame().getOriginalWidth()}getInitialUnrotatedViewportMaxY(){return this.getGame().getOriginalHeight()}getViewportWidth(){return this._cachedGameResolutionWidth}getViewportHeight(){return this._cachedGameResolutionHeight}getViewportOriginX(){return this._cachedGameResolutionWidth/2}getViewportOriginY(){return this._cachedGameResolutionHeight/2}convertCoords(t,e,a){const n=a||[0,0];return n[0]=t,n[1]=e,n}convertInverseCoords(t,e,a){const n=a||[0,0];return n[0]=t,n[1]=e,n}onChildrenLocationChanged(){}getVariables(){return this._variables}getVariablesForExtension(t){return this._variablesByExtensionName.get(t)||null}getTimeManager(){return this._timeManager}getElapsedTime(){return this._timeManager.getElapsedTime()}getSoundManager(){return this._runtimeGame.getSoundManager()}getAsyncTasksManager(){return this._asyncTasksManager}getRequestedChange(){return this._requestedChange}getRequestedScene(){return this._requestedScene}requestChange(t,e){this._requestedChange=t,e&&(this._requestedScene=e)}getProfiler(){return this._profiler}startProfiler(t){this._profiler||(this._profiler=new i.Profiler,this._onProfilerStopped=t)}stopProfiler(){if(!this._profiler)return;const t=this._profiler,e=this._onProfilerStopped;this._profiler=null,this._onProfilerStopped=null,e&&e(t)}getOnceTriggers(){return this._onceTriggers}sceneJustResumed(){return this._isJustResumed}getNetworkSyncData(t){const e=t.playerNumber,a=this._variables.getNetworkSyncData(t),n={};return this._variablesByExtensionName.forEach((r,s)=>{const o=r.getNetworkSyncData(t);o&&(n[s]=o)}),e!==void 0&&e!==1&&(!this.networkId||a.length===0&&!Object.keys(n).length)?null:{var:a,extVar:n,id:this.getOrCreateNetworkId()}}updateFromNetworkSyncData(t){if(t.var&&this._variables.updateFromNetworkSyncData(t.var),t.extVar)for(const e in t.extVar){if(!t.extVar.hasOwnProperty(e))continue;const a=t.extVar[e],n=this._variablesByExtensionName.get(e);n&&n.updateFromNetworkSyncData(a)}}getOrCreateNetworkId(){if(!this.networkId){const t=i.makeUuid().substring(0,8);this.networkId=t}return this.networkId}}i.RuntimeScene=c;let l;(function(s){s[s.CONTINUE=0]="CONTINUE",s[s.PUSH_SCENE=1]="PUSH_SCENE",s[s.POP_SCENE=2]="POP_SCENE",s[s.REPLACE_SCENE=3]="REPLACE_SCENE",s[s.CLEAR_SCENES=4]="CLEAR_SCENES",s[s.STOP_GAME=5]="STOP_GAME"})(l=i.SceneChangeRequest||(i.SceneChangeRequest={}))})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=runtimescene.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/runtimescene.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('RuntimeScene');\n const setupWarningLogger = new gdjs.Logger('RuntimeScene (setup warnings)');\n\n /**\n * A scene being played, containing instances of objects rendered on screen.\n */\n export class RuntimeScene extends gdjs.RuntimeInstanceContainer {\n _eventsFunction: null | ((runtimeScene: RuntimeScene) => void) = null;\n\n _renderer: RuntimeSceneRenderer;\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _variables: gdjs.VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _runtimeGame: gdjs.RuntimeGame;\n _lastId: integer = 0;\n _name: string = '';\n _timeManager: TimeManager;\n _gameStopRequested: boolean = false;\n _requestedScene: string = '';\n private _asyncTasksManager = new gdjs.AsyncTasksManager();\n\n /** True if loadFromScene was called and the scene is being played. */\n _isLoaded: boolean = false;\n /** True in the first frame after resuming the paused scene */\n _isJustResumed: boolean = false;\n\n _requestedChange: SceneChangeRequest;\n /** Black background by default. */\n _backgroundColor: integer = 0;\n\n /** Should the canvas be cleared before this scene rendering. */\n _clearCanvas: boolean = true;\n\n _onceTriggers: OnceTriggers;\n _profiler: gdjs.Profiler | null = null;\n\n // Set to `new gdjs.Profiler()` to have profiling done on the scene.\n _onProfilerStopped: null | ((oldProfiler: gdjs.Profiler) => void) = null;\n\n _cachedGameResolutionWidth: integer;\n _cachedGameResolutionHeight: integer;\n\n /**\n * A network ID associated to the scene to be used\n * for multiplayer, to identify the scene across peers.\n * A scene can have its networkId re-generated during the game, meaning\n * that the scene is re-created on every peer.\n */\n networkId: string | null = null;\n\n /**\n * @param runtimeGame The game associated to this scene.\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n super();\n this._runtimeGame = runtimeGame;\n this._variables = new gdjs.VariablesContainer();\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n this._timeManager = new gdjs.TimeManager();\n this._onceTriggers = new gdjs.OnceTriggers();\n this._requestedChange = SceneChangeRequest.CONTINUE;\n this._cachedGameResolutionWidth = runtimeGame\n ? runtimeGame.getGameResolutionWidth()\n : 0;\n this._cachedGameResolutionHeight = runtimeGame\n ? runtimeGame.getGameResolutionHeight()\n : 0;\n\n this._renderer = new gdjs.RuntimeSceneRenderer(\n this,\n // @ts-ignore This is needed because of test. They should mock RuntimeGame instead.\n runtimeGame ? runtimeGame.getRenderer() : null\n );\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n\n // What to do after the frame is rendered.\n\n // The callback function to call when the profiler is stopped.\n this.onGameResolutionResized();\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.Layer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n /**\n * Should be called when the canvas where the scene is rendered has been resized.\n * See gdjs.RuntimeGame.startGameLoop in particular.\n */\n onGameResolutionResized() {\n const oldGameResolutionOriginX = this.getViewportOriginX();\n const oldGameResolutionOriginY = this.getViewportOriginY();\n this._cachedGameResolutionWidth = this._runtimeGame\n ? this._runtimeGame.getGameResolutionWidth()\n : 0;\n this._cachedGameResolutionHeight = this._runtimeGame\n ? this._runtimeGame.getGameResolutionHeight()\n : 0;\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer: gdjs.RuntimeLayer = this._layers.items[name];\n theLayer.onGameResolutionResized(\n oldGameResolutionOriginX,\n oldGameResolutionOriginY\n );\n }\n }\n this._renderer.onGameResolutionResized();\n }\n\n /**\n * Load the runtime scene from the given scene.\n * @param sceneData An object containing the scene data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFromScene(sceneAndExtensionsData: SceneAndExtensionsData | null) {\n if (!sceneAndExtensionsData) {\n logger.error('loadFromScene was called without a scene');\n return;\n }\n const {\n sceneData,\n usedExtensionsWithVariablesData,\n } = sceneAndExtensionsData;\n\n if (this._isLoaded) {\n this.unloadScene();\n }\n\n //Setup main properties\n if (this._runtimeGame) {\n this._runtimeGame.getRenderer().setWindowTitle(sceneData.title);\n }\n this._name = sceneData.name;\n this.setBackgroundColor(sceneData.r, sceneData.v, sceneData.b);\n\n //Load layers\n for (let i = 0, len = sceneData.layers.length; i < len; ++i) {\n this.addLayer(sceneData.layers[i]);\n }\n\n // Load variables\n this._variables = new gdjs.VariablesContainer(sceneData.variables);\n for (const extensionData of usedExtensionsWithVariablesData) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.sceneVariables)\n );\n }\n\n //Cache the initial shared data of the behaviors\n for (\n let i = 0, len = sceneData.behaviorsSharedData.length;\n i < len;\n ++i\n ) {\n const behaviorSharedData = sceneData.behaviorsSharedData[i];\n this.setInitialSharedDataForBehavior(\n behaviorSharedData.name,\n behaviorSharedData\n );\n }\n\n //Registering objects: Global objects first...\n const initialGlobalObjectsData = this.getGame().getInitialObjectsData();\n for (let i = 0, len = initialGlobalObjectsData.length; i < len; ++i) {\n this.registerObject(initialGlobalObjectsData[i]);\n }\n\n //...then the scene objects\n for (let i = 0, len = sceneData.objects.length; i < len; ++i) {\n this.registerObject(sceneData.objects[i]);\n }\n\n //Create initial instances of objects\n this.createObjectsFrom(\n sceneData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n //Set up the function to be executed at each tick\n this.setEventsGeneratedCodeFunction(sceneData);\n this._onceTriggers = new gdjs.OnceTriggers();\n\n // Notify the global callbacks\n if (this._runtimeGame && !this._runtimeGame.wasFirstSceneLoaded()) {\n for (let i = 0; i < gdjs.callbacksFirstRuntimeSceneLoaded.length; ++i) {\n gdjs.callbacksFirstRuntimeSceneLoaded[i](this);\n }\n }\n for (let i = 0; i < gdjs.callbacksRuntimeSceneLoaded.length; ++i) {\n gdjs.callbacksRuntimeSceneLoaded[i](this);\n }\n if (sceneData.stopSoundsOnStartup && this._runtimeGame) {\n this._runtimeGame.getSoundManager().clearAll();\n }\n this._isLoaded = true;\n this._timeManager.reset();\n }\n\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n // TODO Move this error in RuntimeInstanceContainer after deciding\n // what to do with shared data in custom object.\n const behaviorSharedData = super.getInitialSharedDataForBehavior(name);\n if (!behaviorSharedData) {\n logger.error(\"Can't find shared data for behavior with name: \" + name);\n }\n return behaviorSharedData;\n }\n\n /**\n * Called when a scene is \"paused\", i.e it will be not be rendered again\n * for some time, until it's resumed or unloaded.\n */\n onPause() {\n // Notify the objects that the scene is being paused. Objects should not\n // do anything special, but some object renderers might want to know about this.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onScenePaused(this);\n }\n\n for (let i = 0; i < gdjs.callbacksRuntimeScenePaused.length; ++i) {\n gdjs.callbacksRuntimeScenePaused[i](this);\n }\n }\n\n /**\n * Called when a scene is \"resumed\", i.e it will be rendered again\n * on screen after having being paused.\n */\n onResume() {\n this._isJustResumed = true;\n\n // Notify the objects that the scene is being resumed. Objects should not\n // do anything special, but some object renderers might want to know about this.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onSceneResumed(this);\n }\n\n for (let i = 0; i < gdjs.callbacksRuntimeSceneResumed.length; ++i) {\n gdjs.callbacksRuntimeSceneResumed[i](this);\n }\n }\n\n /**\n * Called before a scene is removed from the stack of scenes\n * rendered on the screen.\n */\n unloadScene() {\n if (!this._isLoaded) {\n return;\n }\n if (this._profiler) {\n this.stopProfiler();\n }\n\n // Notify the global callbacks (which should not release resources yet,\n // as other callbacks might still refer to the objects/scene).\n for (let i = 0; i < gdjs.callbacksRuntimeSceneUnloading.length; ++i) {\n gdjs.callbacksRuntimeSceneUnloading[i](this);\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene(this);\n object.onDestroyed();\n }\n\n // Notify the renderer\n if (this._renderer) {\n this._renderer.onSceneUnloaded();\n }\n\n // Notify the global callbacks (after notifying objects and renderer, because\n // callbacks from extensions might want to free resources - which can't be done\n // safely before destroying objects and the renderer).\n for (let i = 0; i < gdjs.callbacksRuntimeSceneUnloaded.length; ++i) {\n gdjs.callbacksRuntimeSceneUnloaded[i](this);\n }\n\n this._destroy();\n\n this._isLoaded = false;\n this.onGameResolutionResized();\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the RuntimeScene is released immediately.\n super._destroy();\n this._variables = new gdjs.VariablesContainer();\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n this._initialBehaviorSharedData = new Hashtable();\n this._eventsFunction = null;\n this._lastId = 0;\n this.networkId = null;\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Set the function called each time the scene is stepped to be the events generated code,\n * which is by convention assumed to be a function in `gdjs` with a name based on the scene\n * mangled name.\n *\n * @param sceneData The scene data, used to find where the code was generated.\n */\n setEventsGeneratedCodeFunction(sceneData: LayoutData): void {\n const module = gdjs[sceneData.mangledName + 'Code'];\n if (module && module.func) {\n this._eventsFunction = module.func;\n } else {\n setupWarningLogger.warn(\n 'No function found for running logic of scene ' + this._name\n );\n this._eventsFunction = function () {};\n }\n }\n\n /**\n * Set the function called each time the scene is stepped.\n * The function will be passed the `runtimeScene` as argument.\n *\n * Note that this is already set up by the gdjs.RuntimeScene constructor and that you should\n * not need to use this method.\n *\n * @param func The function to be called.\n */\n setEventsFunction(func: () => void): void {\n this._eventsFunction = func;\n }\n\n /**\n * Step and render the scene.\n * @param elapsedTime In milliseconds\n * @return true if the game loop should continue, false if a scene change/push/pop\n * or a game stop was requested.\n */\n renderAndStep(elapsedTime: float): boolean {\n if (this._profiler) {\n this._profiler.beginFrame();\n }\n this._requestedChange = SceneChangeRequest.CONTINUE;\n this._timeManager.update(\n elapsedTime,\n this._runtimeGame.getMinimalFramerate()\n );\n if (this._profiler) {\n this._profiler.begin('asynchronous actions (wait action, etc...)');\n }\n this._asyncTasksManager.processTasks(this);\n if (this._profiler) {\n this._profiler.end('asynchronous actions (wait action, etc...)');\n }\n if (this._profiler) {\n this._profiler.begin('objects (pre-events)');\n }\n this._updateObjectsPreEvents();\n if (this._profiler) {\n this._profiler.end('objects (pre-events)');\n }\n if (this._profiler) {\n this._profiler.begin('callbacks and extensions (pre-events)');\n }\n for (let i = 0; i < gdjs.callbacksRuntimeScenePreEvents.length; ++i) {\n gdjs.callbacksRuntimeScenePreEvents[i](this);\n }\n if (this._profiler) {\n this._profiler.end('callbacks and extensions (pre-events)');\n }\n if (this._profiler) {\n this._profiler.begin('events');\n }\n if (this._eventsFunction !== null) this._eventsFunction(this);\n if (this._profiler) {\n this._profiler.end('events');\n }\n if (this._profiler) {\n this._profiler.begin('objects (post-events)');\n }\n this._updateObjectsPostEvents();\n if (this._profiler) {\n this._profiler.end('objects (post-events)');\n }\n if (this._profiler) {\n this._profiler.begin('callbacks and extensions (post-events)');\n }\n for (let i = 0; i < gdjs.callbacksRuntimeScenePostEvents.length; ++i) {\n gdjs.callbacksRuntimeScenePostEvents[i](this);\n }\n if (this._profiler) {\n this._profiler.end('callbacks and extensions (post-events)');\n }\n if (this._profiler) {\n this._profiler.begin('objects (pre-render, effects update)');\n }\n this._updateObjectsPreRender();\n if (this._profiler) {\n this._profiler.end('objects (pre-render, effects update)');\n }\n if (this._profiler) {\n this._profiler.begin('layers (effects update)');\n }\n this._updateLayersPreRender();\n if (this._profiler) {\n this._profiler.end('layers (effects update)');\n }\n if (this._profiler) {\n this._profiler.begin('render');\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n this.getAdhocListOfAllInstances(),\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n this._isJustResumed = false;\n this.render();\n if (this._profiler) {\n this._profiler.end('render');\n }\n if (this._profiler) {\n this._profiler.endFrame();\n }\n return !!this.getRequestedChange();\n }\n\n /**\n * Render the PIXI container associated to the runtimeScene.\n */\n render() {\n this._renderer.render();\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 if (this._timeManager.isFirstFrame()) {\n super._updateObjectsPreRender();\n return;\n } else {\n // After first frame, optimise rendering by setting only objects\n // near camera as visible.\n // TODO: For compatibility, pass a scale of `2`,\n // meaning that size of cameras will be multiplied by 2 and so objects\n // will be hidden if they are outside of this *larger* camera area.\n // This is useful for:\n // - objects not properly reporting their visibility AABB,\n // (so we have a \"safety margin\") but these objects should be fixed\n // instead.\n // - objects having effects rendering outside of their visibility AABB.\n\n // TODO (3D) culling - add support for 3D object culling?\n this._updateLayersCameraCoordinates(2);\n const allInstancesList = this.getAdhocListOfAllInstances();\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 if (object.isHidden()) {\n rendererObject.visible = false;\n } else {\n const cameraCoords = this._layersCameraCoordinates[\n object.getLayer()\n ];\n if (!cameraCoords) {\n continue;\n }\n const aabb = object.getVisibilityAABB();\n rendererObject.visible =\n // If no AABB is returned, the object should always be visible\n !aabb ||\n // If an AABB is there, it must be at least partially inside\n // the camera bounds.\n !(\n aabb.min[0] > cameraCoords[2] ||\n aabb.min[1] > cameraCoords[3] ||\n aabb.max[0] < cameraCoords[0] ||\n aabb.max[1] < cameraCoords[1]\n );\n }\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this._runtimeGame\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n\n // Perform pre-render update only if the object is visible\n // (including if there is no visibility AABB returned previously).\n object.updatePreRender(this);\n }\n } else {\n // Perform pre-render update, always for objects not having an\n // associated renderer object (so it must handle visibility on its own).\n object.updatePreRender(this);\n }\n }\n }\n }\n\n /**\n * Change the background color, by setting the RGB components.\n * Internally, the color is stored as an hexadecimal number.\n *\n * @param r The color red component (0-255).\n * @param g The color green component (0-255).\n * @param b The color blue component (0-255).\n */\n setBackgroundColor(r: integer, g: integer, b: integer): void {\n this._backgroundColor = parseInt(gdjs.rgbToHex(r, g, b), 16);\n }\n\n /**\n * Get the background color, as an hexadecimal number.\n * @returns The current background color.\n */\n getBackgroundColor(): number {\n return this._backgroundColor;\n }\n\n /**\n * Set whether the canvas should be cleared before this scene rendering.\n * This is experimental: if possible, try to avoid relying on this and use\n * custom objects to build complex scenes.\n */\n setClearCanvas(shouldClearCanvas: boolean): void {\n this._clearCanvas = shouldClearCanvas;\n }\n\n /**\n * Get whether the canvas should be cleared before this scene rendering.\n */\n getClearCanvas(): boolean {\n return this._clearCanvas;\n }\n\n /**\n * Get the name of the scene.\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Create an identifier for a new object of the scene.\n */\n createNewUniqueId(): integer {\n this._lastId++;\n return this._lastId;\n }\n\n getRenderer(): gdjs.RuntimeScenePixiRenderer {\n return this._renderer;\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeGame;\n }\n\n getScene() {\n return this;\n }\n\n getViewportWidth(): float {\n return this._cachedGameResolutionWidth;\n }\n\n getViewportHeight(): float {\n return this._cachedGameResolutionHeight;\n }\n\n getViewportOriginX(): float {\n return this._cachedGameResolutionWidth / 2;\n }\n\n getViewportOriginY(): float {\n return this._cachedGameResolutionHeight / 2;\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n const point = result || [0, 0];\n point[0] = x;\n point[1] = y;\n return point;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const point = result || [0, 0];\n point[0] = sceneX;\n point[1] = sceneY;\n return point;\n }\n\n onChildrenLocationChanged(): void {\n // Scenes don't maintain bounds.\n }\n\n /**\n * Get the variables of the runtimeScene.\n * @return The container holding the variables of the scene.\n */\n getVariables() {\n return this._variables;\n }\n\n /**\n * Get the extension's variables for this scene.\n * @param extensionName The extension name.\n * @returns The extension's variables for this scene.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the TimeManager of the scene.\n * @return The gdjs.TimeManager of the scene.\n */\n getTimeManager(): gdjs.TimeManager {\n return this._timeManager;\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._timeManager.getElapsedTime();\n }\n\n /**\n * Shortcut to get the SoundManager of the game.\n * @return The gdjs.SoundManager of the game.\n */\n getSoundManager(): gdjs.SoundManager {\n return this._runtimeGame.getSoundManager();\n }\n\n /**\n * @returns The scene's async tasks manager.\n */\n getAsyncTasksManager() {\n return this._asyncTasksManager;\n }\n\n /**\n * Return the value of the scene change that is requested.\n */\n getRequestedChange(): SceneChangeRequest {\n return this._requestedChange;\n }\n\n /**\n * Return the name of the new scene to be launched.\n *\n * See requestChange.\n */\n getRequestedScene(): string {\n return this._requestedScene;\n }\n\n /**\n * Request a scene change to be made. The change is handled externally (see gdjs.SceneStack)\n * thanks to getRequestedChange and getRequestedScene methods.\n * @param change One of RuntimeScene.CONTINUE|PUSH_SCENE|POP_SCENE|REPLACE_SCENE|CLEAR_SCENES|STOP_GAME.\n * @param sceneName The name of the new scene to launch, if applicable.\n */\n requestChange(change: SceneChangeRequest, sceneName?: string) {\n this._requestedChange = change;\n if (sceneName) this._requestedScene = sceneName;\n }\n\n /**\n * Get the profiler associated with the scene, or null if none.\n */\n getProfiler(): gdjs.Profiler | null {\n return this._profiler;\n }\n\n /**\n * Start a new profiler to measures the time passed in sections of the engine\n * in the scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startProfiler(onProfilerStopped: (oldProfiler: gdjs.Profiler) => void) {\n if (this._profiler) {\n return;\n }\n this._profiler = new gdjs.Profiler();\n this._onProfilerStopped = onProfilerStopped;\n }\n\n /**\n * Stop the profiler being run on the scene.\n */\n stopProfiler() {\n if (!this._profiler) {\n return;\n }\n const oldProfiler = this._profiler;\n const onProfilerStopped = this._onProfilerStopped;\n this._profiler = null;\n this._onProfilerStopped = null;\n if (onProfilerStopped) {\n onProfilerStopped(oldProfiler);\n }\n }\n\n /**\n * Get the structure containing the triggers for \"Trigger once\" conditions.\n */\n getOnceTriggers() {\n return this._onceTriggers;\n }\n\n /**\n * Check if the scene was just resumed.\n * This is true during the first frame after the scene has been unpaused.\n *\n * @returns true if the scene was just resumed\n */\n sceneJustResumed(): boolean {\n return this._isJustResumed;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): LayoutNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n const variablesNetworkSyncData = this._variables.getNetworkSyncData(\n syncOptions\n );\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData) {\n extensionsVariablesSyncData[\n extensionName\n ] = extensionVariablesSyncData;\n }\n });\n\n if (\n syncedPlayerNumber !== undefined &&\n syncedPlayerNumber !== 1 &&\n (!this.networkId ||\n (variablesNetworkSyncData.length === 0 &&\n !Object.keys(extensionsVariablesSyncData).length))\n ) {\n // If we are getting sync data for a specific player,\n // and they are not the host, there is no sync data to send if:\n // - The scene has no networkId (it's either not a multiplayer scene or the scene is not yet networked).\n // - There are no variables to sync in the scene or extensions.\n return null;\n }\n\n return {\n var: variablesNetworkSyncData,\n extVar: extensionsVariablesSyncData,\n id: this.getOrCreateNetworkId(),\n };\n }\n\n updateFromNetworkSyncData(syncData: LayoutNetworkSyncData) {\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables = this._variablesByExtensionName.get(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\n }\n }\n\n getOrCreateNetworkId(): string {\n if (!this.networkId) {\n const newNetworkId = gdjs.makeUuid().substring(0, 8);\n this.networkId = newNetworkId;\n }\n return this.networkId;\n }\n }\n\n //The flags to describe the change request by a scene:\n export enum SceneChangeRequest {\n CONTINUE,\n PUSH_SCENE,\n POP_SCENE,\n REPLACE_SCENE,\n CLEAR_SCENES,\n STOP_GAME,\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,gBACzB,EAAqB,GAAI,GAAK,OAAO,iCAKpC,eAA2B,GAAK,wBAAyB,CA+C9D,YAAY,EAA+B,CACzC,QA/CF,qBAAiE,KAOjE,aAAmB,EACnB,WAAgB,GAEhB,wBAA8B,GAC9B,qBAA0B,GAClB,wBAAqB,GAAI,GAAK,kBAGtC,eAAqB,GAErB,oBAA0B,GAI1B,sBAA4B,EAG5B,kBAAwB,GAGxB,eAAkC,KAGlC,wBAAoE,KAWpE,eAA2B,KAOzB,KAAK,aAAe,EACpB,KAAK,WAAa,GAAI,GAAK,mBAC3B,KAAK,0BAA4B,GAAI,KA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B,EAAS,OAAO,GACzC,EAAqB,KAAK,0BAA0B,IACxD,GAEF,AAAI,GACF,EAAmB,0BACjB,IAOV,sBAA+B,CAC7B,GAAI,CAAC,KAAK,UAAW,CACnB,KAAM,GAAe,EAAK,WAAW,UAAU,EAAG,GAClD,KAAK,UAAY,EAEnB,MAAO,MAAK,
|
|
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('RuntimeScene');\n const setupWarningLogger = new gdjs.Logger('RuntimeScene (setup warnings)');\n\n /**\n * A scene being played, containing instances of objects rendered on screen.\n */\n export class RuntimeScene extends gdjs.RuntimeInstanceContainer {\n _eventsFunction: null | ((runtimeScene: RuntimeScene) => void) = null;\n\n _renderer: RuntimeSceneRenderer;\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _variables: gdjs.VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _runtimeGame: gdjs.RuntimeGame;\n _lastId: integer = 0;\n _name: string = '';\n _timeManager: TimeManager;\n _gameStopRequested: boolean = false;\n _requestedScene: string = '';\n private _asyncTasksManager = new gdjs.AsyncTasksManager();\n\n /** True if loadFromScene was called and the scene is being played. */\n _isLoaded: boolean = false;\n /** True in the first frame after resuming the paused scene */\n _isJustResumed: boolean = false;\n\n _requestedChange: SceneChangeRequest;\n /** Black background by default. */\n _backgroundColor: integer = 0;\n\n /** Should the canvas be cleared before this scene rendering. */\n _clearCanvas: boolean = true;\n\n _onceTriggers: OnceTriggers;\n _profiler: gdjs.Profiler | null = null;\n\n // Set to `new gdjs.Profiler()` to have profiling done on the scene.\n _onProfilerStopped: null | ((oldProfiler: gdjs.Profiler) => void) = null;\n\n _cachedGameResolutionWidth: integer;\n _cachedGameResolutionHeight: integer;\n\n /**\n * A network ID associated to the scene to be used\n * for multiplayer, to identify the scene across peers.\n * A scene can have its networkId re-generated during the game, meaning\n * that the scene is re-created on every peer.\n */\n networkId: string | null = null;\n\n /**\n * @param runtimeGame The game associated to this scene.\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n super();\n this._runtimeGame = runtimeGame;\n this._variables = new gdjs.VariablesContainer();\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n this._timeManager = new gdjs.TimeManager();\n this._onceTriggers = new gdjs.OnceTriggers();\n this._requestedChange = SceneChangeRequest.CONTINUE;\n this._cachedGameResolutionWidth = runtimeGame\n ? runtimeGame.getGameResolutionWidth()\n : 0;\n this._cachedGameResolutionHeight = runtimeGame\n ? runtimeGame.getGameResolutionHeight()\n : 0;\n\n this._renderer = new gdjs.RuntimeSceneRenderer(\n this,\n // @ts-ignore This is needed because of test. They should mock RuntimeGame instead.\n runtimeGame ? runtimeGame.getRenderer() : null\n );\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n\n // What to do after the frame is rendered.\n\n // The callback function to call when the profiler is stopped.\n this.onGameResolutionResized();\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.Layer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n /**\n * Should be called when the canvas where the scene is rendered has been resized.\n * See gdjs.RuntimeGame.startGameLoop in particular.\n */\n onGameResolutionResized() {\n const oldGameResolutionOriginX = this.getViewportOriginX();\n const oldGameResolutionOriginY = this.getViewportOriginY();\n this._cachedGameResolutionWidth = this._runtimeGame\n ? this._runtimeGame.getGameResolutionWidth()\n : 0;\n this._cachedGameResolutionHeight = this._runtimeGame\n ? this._runtimeGame.getGameResolutionHeight()\n : 0;\n for (const name in this._layers.items) {\n if (this._layers.items.hasOwnProperty(name)) {\n const theLayer: gdjs.RuntimeLayer = this._layers.items[name];\n theLayer.onGameResolutionResized(\n oldGameResolutionOriginX,\n oldGameResolutionOriginY\n );\n }\n }\n this._renderer.onGameResolutionResized();\n }\n\n /**\n * Load the runtime scene from the given scene.\n * @param sceneData An object containing the scene data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFromScene(sceneAndExtensionsData: SceneAndExtensionsData | null) {\n if (!sceneAndExtensionsData) {\n logger.error('loadFromScene was called without a scene');\n return;\n }\n const {\n sceneData,\n usedExtensionsWithVariablesData,\n } = sceneAndExtensionsData;\n\n if (this._isLoaded) {\n this.unloadScene();\n }\n\n //Setup main properties\n if (this._runtimeGame) {\n this._runtimeGame.getRenderer().setWindowTitle(sceneData.title);\n }\n this._name = sceneData.name;\n this.setBackgroundColor(sceneData.r, sceneData.v, sceneData.b);\n\n //Load layers\n for (let i = 0, len = sceneData.layers.length; i < len; ++i) {\n this.addLayer(sceneData.layers[i]);\n }\n\n // Load variables\n this._variables = new gdjs.VariablesContainer(sceneData.variables);\n for (const extensionData of usedExtensionsWithVariablesData) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.sceneVariables)\n );\n }\n\n //Cache the initial shared data of the behaviors\n for (\n let i = 0, len = sceneData.behaviorsSharedData.length;\n i < len;\n ++i\n ) {\n const behaviorSharedData = sceneData.behaviorsSharedData[i];\n this.setInitialSharedDataForBehavior(\n behaviorSharedData.name,\n behaviorSharedData\n );\n }\n\n //Registering objects: Global objects first...\n const initialGlobalObjectsData = this.getGame().getInitialObjectsData();\n for (let i = 0, len = initialGlobalObjectsData.length; i < len; ++i) {\n this.registerObject(initialGlobalObjectsData[i]);\n }\n\n //...then the scene objects\n for (let i = 0, len = sceneData.objects.length; i < len; ++i) {\n this.registerObject(sceneData.objects[i]);\n }\n\n //Create initial instances of objects\n this.createObjectsFrom(\n sceneData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n //Set up the function to be executed at each tick\n this.setEventsGeneratedCodeFunction(sceneData);\n this._onceTriggers = new gdjs.OnceTriggers();\n\n // Notify the global callbacks\n if (this._runtimeGame && !this._runtimeGame.wasFirstSceneLoaded()) {\n for (let i = 0; i < gdjs.callbacksFirstRuntimeSceneLoaded.length; ++i) {\n gdjs.callbacksFirstRuntimeSceneLoaded[i](this);\n }\n }\n for (let i = 0; i < gdjs.callbacksRuntimeSceneLoaded.length; ++i) {\n gdjs.callbacksRuntimeSceneLoaded[i](this);\n }\n if (sceneData.stopSoundsOnStartup && this._runtimeGame) {\n this._runtimeGame.getSoundManager().clearAll();\n }\n this._isLoaded = true;\n this._timeManager.reset();\n }\n\n getInitialSharedDataForBehavior(name: string): BehaviorSharedData | null {\n // TODO Move this error in RuntimeInstanceContainer after deciding\n // what to do with shared data in custom object.\n const behaviorSharedData = super.getInitialSharedDataForBehavior(name);\n if (!behaviorSharedData) {\n logger.error(\"Can't find shared data for behavior with name: \" + name);\n }\n return behaviorSharedData;\n }\n\n /**\n * Called when a scene is \"paused\", i.e it will be not be rendered again\n * for some time, until it's resumed or unloaded.\n */\n onPause() {\n // Notify the objects that the scene is being paused. Objects should not\n // do anything special, but some object renderers might want to know about this.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onScenePaused(this);\n }\n\n for (let i = 0; i < gdjs.callbacksRuntimeScenePaused.length; ++i) {\n gdjs.callbacksRuntimeScenePaused[i](this);\n }\n }\n\n /**\n * Called when a scene is \"resumed\", i.e it will be rendered again\n * on screen after having being paused.\n */\n onResume() {\n this._isJustResumed = true;\n\n // Notify the objects that the scene is being resumed. Objects should not\n // do anything special, but some object renderers might want to know about this.\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onSceneResumed(this);\n }\n\n for (let i = 0; i < gdjs.callbacksRuntimeSceneResumed.length; ++i) {\n gdjs.callbacksRuntimeSceneResumed[i](this);\n }\n }\n\n /**\n * Called before a scene is removed from the stack of scenes\n * rendered on the screen.\n */\n unloadScene() {\n if (!this._isLoaded) {\n return;\n }\n if (this._profiler) {\n this.stopProfiler();\n }\n\n // Notify the global callbacks (which should not release resources yet,\n // as other callbacks might still refer to the objects/scene).\n for (let i = 0; i < gdjs.callbacksRuntimeSceneUnloading.length; ++i) {\n gdjs.callbacksRuntimeSceneUnloading[i](this);\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene(this);\n object.onDestroyed();\n }\n\n // Notify the renderer\n if (this._renderer) {\n this._renderer.onSceneUnloaded();\n }\n\n // Notify the global callbacks (after notifying objects and renderer, because\n // callbacks from extensions might want to free resources - which can't be done\n // safely before destroying objects and the renderer).\n for (let i = 0; i < gdjs.callbacksRuntimeSceneUnloaded.length; ++i) {\n gdjs.callbacksRuntimeSceneUnloaded[i](this);\n }\n\n this._destroy();\n\n this._isLoaded = false;\n this.onGameResolutionResized();\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the RuntimeScene is released immediately.\n super._destroy();\n this._variables = new gdjs.VariablesContainer();\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n this._initialBehaviorSharedData = new Hashtable();\n this._eventsFunction = null;\n this._lastId = 0;\n this.networkId = null;\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Set the function called each time the scene is stepped to be the events generated code,\n * which is by convention assumed to be a function in `gdjs` with a name based on the scene\n * mangled name.\n *\n * @param sceneData The scene data, used to find where the code was generated.\n */\n setEventsGeneratedCodeFunction(sceneData: LayoutData): void {\n const module = gdjs[sceneData.mangledName + 'Code'];\n if (module && module.func) {\n this._eventsFunction = module.func;\n } else {\n setupWarningLogger.warn(\n 'No function found for running logic of scene ' + this._name\n );\n this._eventsFunction = function () {};\n }\n }\n\n /**\n * Set the function called each time the scene is stepped.\n * The function will be passed the `runtimeScene` as argument.\n *\n * Note that this is already set up by the gdjs.RuntimeScene constructor and that you should\n * not need to use this method.\n *\n * @param func The function to be called.\n */\n setEventsFunction(func: () => void): void {\n this._eventsFunction = func;\n }\n\n /**\n * Step and render the scene.\n * @param elapsedTime In milliseconds\n * @return true if the game loop should continue, false if a scene change/push/pop\n * or a game stop was requested.\n */\n renderAndStep(elapsedTime: float): boolean {\n if (this._profiler) {\n this._profiler.beginFrame();\n }\n this._requestedChange = SceneChangeRequest.CONTINUE;\n this._timeManager.update(\n elapsedTime,\n this._runtimeGame.getMinimalFramerate()\n );\n if (this._profiler) {\n this._profiler.begin('asynchronous actions (wait action, etc...)');\n }\n this._asyncTasksManager.processTasks(this);\n if (this._profiler) {\n this._profiler.end('asynchronous actions (wait action, etc...)');\n }\n if (this._profiler) {\n this._profiler.begin('objects (pre-events)');\n }\n this._updateObjectsPreEvents();\n if (this._profiler) {\n this._profiler.end('objects (pre-events)');\n }\n if (this._profiler) {\n this._profiler.begin('callbacks and extensions (pre-events)');\n }\n for (let i = 0; i < gdjs.callbacksRuntimeScenePreEvents.length; ++i) {\n gdjs.callbacksRuntimeScenePreEvents[i](this);\n }\n if (this._profiler) {\n this._profiler.end('callbacks and extensions (pre-events)');\n }\n if (this._profiler) {\n this._profiler.begin('events');\n }\n if (this._eventsFunction !== null) this._eventsFunction(this);\n if (this._profiler) {\n this._profiler.end('events');\n }\n if (this._profiler) {\n this._profiler.begin('objects (post-events)');\n }\n this._updateObjectsPostEvents();\n if (this._profiler) {\n this._profiler.end('objects (post-events)');\n }\n if (this._profiler) {\n this._profiler.begin('callbacks and extensions (post-events)');\n }\n for (let i = 0; i < gdjs.callbacksRuntimeScenePostEvents.length; ++i) {\n gdjs.callbacksRuntimeScenePostEvents[i](this);\n }\n if (this._profiler) {\n this._profiler.end('callbacks and extensions (post-events)');\n }\n if (this._profiler) {\n this._profiler.begin('objects (pre-render, effects update)');\n }\n this._updateObjectsPreRender();\n if (this._profiler) {\n this._profiler.end('objects (pre-render, effects update)');\n }\n if (this._profiler) {\n this._profiler.begin('layers (effects update)');\n }\n this._updateLayersPreRender();\n if (this._profiler) {\n this._profiler.end('layers (effects update)');\n }\n if (this._profiler) {\n this._profiler.begin('render');\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n this.getAdhocListOfAllInstances(),\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n this._isJustResumed = false;\n this.render();\n if (this._profiler) {\n this._profiler.end('render');\n }\n if (this._profiler) {\n this._profiler.endFrame();\n }\n return !!this.getRequestedChange();\n }\n\n /**\n * Render the PIXI container associated to the runtimeScene.\n */\n render() {\n this._renderer.render();\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 if (this._timeManager.isFirstFrame()) {\n super._updateObjectsPreRender();\n return;\n } else {\n // After first frame, optimise rendering by setting only objects\n // near camera as visible.\n // TODO: For compatibility, pass a scale of `2`,\n // meaning that size of cameras will be multiplied by 2 and so objects\n // will be hidden if they are outside of this *larger* camera area.\n // This is useful for:\n // - objects not properly reporting their visibility AABB,\n // (so we have a \"safety margin\") but these objects should be fixed\n // instead.\n // - objects having effects rendering outside of their visibility AABB.\n\n // TODO (3D) culling - add support for 3D object culling?\n this._updateLayersCameraCoordinates(2);\n const allInstancesList = this.getAdhocListOfAllInstances();\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 if (object.isHidden()) {\n rendererObject.visible = false;\n } else {\n const cameraCoords = this._layersCameraCoordinates[\n object.getLayer()\n ];\n if (!cameraCoords) {\n continue;\n }\n const aabb = object.getVisibilityAABB();\n rendererObject.visible =\n // If no AABB is returned, the object should always be visible\n !aabb ||\n // If an AABB is there, it must be at least partially inside\n // the camera bounds.\n !(\n aabb.min[0] > cameraCoords[2] ||\n aabb.min[1] > cameraCoords[3] ||\n aabb.max[0] < cameraCoords[0] ||\n aabb.max[1] < cameraCoords[1]\n );\n }\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this._runtimeGame\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n\n // Perform pre-render update only if the object is visible\n // (including if there is no visibility AABB returned previously).\n object.updatePreRender(this);\n }\n } else {\n // Perform pre-render update, always for objects not having an\n // associated renderer object (so it must handle visibility on its own).\n object.updatePreRender(this);\n }\n }\n }\n }\n\n /**\n * Change the background color, by setting the RGB components.\n * Internally, the color is stored as an hexadecimal number.\n *\n * @param r The color red component (0-255).\n * @param g The color green component (0-255).\n * @param b The color blue component (0-255).\n */\n setBackgroundColor(r: integer, g: integer, b: integer): void {\n this._backgroundColor = parseInt(gdjs.rgbToHex(r, g, b), 16);\n }\n\n /**\n * Get the background color, as an hexadecimal number.\n * @returns The current background color.\n */\n getBackgroundColor(): number {\n return this._backgroundColor;\n }\n\n /**\n * Set whether the canvas should be cleared before this scene rendering.\n * This is experimental: if possible, try to avoid relying on this and use\n * custom objects to build complex scenes.\n */\n setClearCanvas(shouldClearCanvas: boolean): void {\n this._clearCanvas = shouldClearCanvas;\n }\n\n /**\n * Get whether the canvas should be cleared before this scene rendering.\n */\n getClearCanvas(): boolean {\n return this._clearCanvas;\n }\n\n /**\n * Get the name of the scene.\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Create an identifier for a new object of the scene.\n */\n createNewUniqueId(): integer {\n this._lastId++;\n return this._lastId;\n }\n\n getRenderer(): gdjs.RuntimeScenePixiRenderer {\n return this._renderer;\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeGame;\n }\n\n getScene() {\n return this;\n }\n\n getUnrotatedViewportMinX(): float {\n return 0;\n }\n\n getUnrotatedViewportMinY(): float {\n return 0;\n }\n\n getUnrotatedViewportMaxX(): float {\n return this._cachedGameResolutionWidth;\n }\n\n getUnrotatedViewportMaxY(): float {\n return this._cachedGameResolutionHeight;\n }\n\n getInitialUnrotatedViewportMinX(): float {\n return 0;\n }\n\n getInitialUnrotatedViewportMinY(): float {\n return 0;\n }\n\n getInitialUnrotatedViewportMaxX(): float {\n return this.getGame().getOriginalWidth();\n }\n\n getInitialUnrotatedViewportMaxY(): float {\n return this.getGame().getOriginalHeight();\n }\n\n getViewportWidth(): float {\n return this._cachedGameResolutionWidth;\n }\n\n getViewportHeight(): float {\n return this._cachedGameResolutionHeight;\n }\n\n getViewportOriginX(): float {\n return this._cachedGameResolutionWidth / 2;\n }\n\n getViewportOriginY(): float {\n return this._cachedGameResolutionHeight / 2;\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n const point = result || [0, 0];\n point[0] = x;\n point[1] = y;\n return point;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const point = result || [0, 0];\n point[0] = sceneX;\n point[1] = sceneY;\n return point;\n }\n\n onChildrenLocationChanged(): void {\n // Scenes don't maintain bounds.\n }\n\n /**\n * Get the variables of the runtimeScene.\n * @return The container holding the variables of the scene.\n */\n getVariables() {\n return this._variables;\n }\n\n /**\n * Get the extension's variables for this scene.\n * @param extensionName The extension name.\n * @returns The extension's variables for this scene.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the TimeManager of the scene.\n * @return The gdjs.TimeManager of the scene.\n */\n getTimeManager(): gdjs.TimeManager {\n return this._timeManager;\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._timeManager.getElapsedTime();\n }\n\n /**\n * Shortcut to get the SoundManager of the game.\n * @return The gdjs.SoundManager of the game.\n */\n getSoundManager(): gdjs.SoundManager {\n return this._runtimeGame.getSoundManager();\n }\n\n /**\n * @returns The scene's async tasks manager.\n */\n getAsyncTasksManager() {\n return this._asyncTasksManager;\n }\n\n /**\n * Return the value of the scene change that is requested.\n */\n getRequestedChange(): SceneChangeRequest {\n return this._requestedChange;\n }\n\n /**\n * Return the name of the new scene to be launched.\n *\n * See requestChange.\n */\n getRequestedScene(): string {\n return this._requestedScene;\n }\n\n /**\n * Request a scene change to be made. The change is handled externally (see gdjs.SceneStack)\n * thanks to getRequestedChange and getRequestedScene methods.\n * @param change One of RuntimeScene.CONTINUE|PUSH_SCENE|POP_SCENE|REPLACE_SCENE|CLEAR_SCENES|STOP_GAME.\n * @param sceneName The name of the new scene to launch, if applicable.\n */\n requestChange(change: SceneChangeRequest, sceneName?: string) {\n this._requestedChange = change;\n if (sceneName) this._requestedScene = sceneName;\n }\n\n /**\n * Get the profiler associated with the scene, or null if none.\n */\n getProfiler(): gdjs.Profiler | null {\n return this._profiler;\n }\n\n /**\n * Start a new profiler to measures the time passed in sections of the engine\n * in the scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startProfiler(onProfilerStopped: (oldProfiler: gdjs.Profiler) => void) {\n if (this._profiler) {\n return;\n }\n this._profiler = new gdjs.Profiler();\n this._onProfilerStopped = onProfilerStopped;\n }\n\n /**\n * Stop the profiler being run on the scene.\n */\n stopProfiler() {\n if (!this._profiler) {\n return;\n }\n const oldProfiler = this._profiler;\n const onProfilerStopped = this._onProfilerStopped;\n this._profiler = null;\n this._onProfilerStopped = null;\n if (onProfilerStopped) {\n onProfilerStopped(oldProfiler);\n }\n }\n\n /**\n * Get the structure containing the triggers for \"Trigger once\" conditions.\n */\n getOnceTriggers() {\n return this._onceTriggers;\n }\n\n /**\n * Check if the scene was just resumed.\n * This is true during the first frame after the scene has been unpaused.\n *\n * @returns true if the scene was just resumed\n */\n sceneJustResumed(): boolean {\n return this._isJustResumed;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): LayoutNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n const variablesNetworkSyncData = this._variables.getNetworkSyncData(\n syncOptions\n );\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData) {\n extensionsVariablesSyncData[\n extensionName\n ] = extensionVariablesSyncData;\n }\n });\n\n if (\n syncedPlayerNumber !== undefined &&\n syncedPlayerNumber !== 1 &&\n (!this.networkId ||\n (variablesNetworkSyncData.length === 0 &&\n !Object.keys(extensionsVariablesSyncData).length))\n ) {\n // If we are getting sync data for a specific player,\n // and they are not the host, there is no sync data to send if:\n // - The scene has no networkId (it's either not a multiplayer scene or the scene is not yet networked).\n // - There are no variables to sync in the scene or extensions.\n return null;\n }\n\n return {\n var: variablesNetworkSyncData,\n extVar: extensionsVariablesSyncData,\n id: this.getOrCreateNetworkId(),\n };\n }\n\n updateFromNetworkSyncData(syncData: LayoutNetworkSyncData) {\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables = this._variablesByExtensionName.get(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\n }\n }\n\n getOrCreateNetworkId(): string {\n if (!this.networkId) {\n const newNetworkId = gdjs.makeUuid().substring(0, 8);\n this.networkId = newNetworkId;\n }\n return this.networkId;\n }\n }\n\n //The flags to describe the change request by a scene:\n export enum SceneChangeRequest {\n CONTINUE,\n PUSH_SCENE,\n POP_SCENE,\n REPLACE_SCENE,\n CLEAR_SCENES,\n STOP_GAME,\n }\n}\n"],
|
|
5
|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AK,UACR,OAEF,KAAM,GAAc,KAAK,UACnB,EAAoB,KAAK,mBAC/B,KAAK,UAAY,KACjB,KAAK,mBAAqB,KACtB,GACF,EAAkB,GAOtB,iBAAkB,CAChB,MAAO,MAAK,cASd,kBAA4B,CAC1B,MAAO,MAAK,eAGd,mBACE,EAC8B,CAC9B,KAAM,GAAqB,EAAY,aACjC,EAA2B,KAAK,WAAW,mBAC/C,GAEI,EAA8B,GAapC,MAZA,MAAK,0BAA0B,QAAQ,CAAC,EAAW,IAAkB,CACnE,KAAM,GAA6B,EAAU,mBAC3C,GAGF,AAAI,GACF,GACE,GACE,KAKN,IAAuB,QACvB,IAAuB,GACtB,EAAC,KAAK,WACJ,EAAyB,SAAW,GACnC,CAAC,OAAO,KAAK,GAA6B,QAMvC,KAGF,CACL,IAAK,EACL,OAAQ,EACR,GAAI,KAAK,wBAIb,0BAA0B,EAAiC,CAIzD,GAHI,EAAS,KACX,KAAK,WAAW,0BAA0B,EAAS,KAEjD,EAAS,OACX,SAAW,KAAiB,GAAS,OAAQ,CAC3C,GAAI,CAAC,EAAS,OAAO,eAAe,GAClC,SAEF,KAAM,GAAyB,EAAS,OAAO,GACzC,EAAqB,KAAK,0BAA0B,IACxD,GAEF,AAAI,GACF,EAAmB,0BACjB,IAOV,sBAA+B,CAC7B,GAAI,CAAC,KAAK,UAAW,CACnB,KAAM,GAAe,EAAK,WAAW,UAAU,EAAG,GAClD,KAAK,UAAY,EAEnB,MAAO,MAAK,WA91BT,EAAM,eAm2BN,GAAK,GAAL,UAAK,EAAL,CACL,2BACA,+BACA,6BACA,qCACA,mCACA,+BANU,qDA12BJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(c){const o=new c.Logger("Scene stack"),r=new c.Logger("Multiplayer - Debug");class h{constructor(t){this._stack=[];this._wasFirstSceneLoaded=!1;this._isNextLayoutLoading=!1;this._sceneStackSyncDataToApply=null;if(!t)throw"SceneStack must be constructed with a gdjs.RuntimeGame.";this._runtimeGame=t}onGameResolutionResized(){for(let t=0;t<this._stack.length;++t)this._stack[t].onGameResolutionResized()}step(t){if(this._isNextLayoutLoading||this._stack.length===0)return!1;if(this.applyUpdateFromNetworkSyncDataIfAny())return r.info("Scene stack has been updated from network sync data, skipping step."),!0;const e=this._stack[this._stack.length-1];if(e.renderAndStep(t)){const n=e.getRequestedChange();if(n===c.SceneChangeRequest.STOP_GAME)return this._runtimeGame.getRenderer().stopGame(),!0;n===c.SceneChangeRequest.POP_SCENE?this.pop():n===c.SceneChangeRequest.PUSH_SCENE?this.push(e.getRequestedScene()):n===c.SceneChangeRequest.REPLACE_SCENE?this.replace(e.getRequestedScene()):n===c.SceneChangeRequest.CLEAR_SCENES?this.replace(e.getRequestedScene(),!0):o.error("Unrecognized change in scene stack: "+n)}return!0}renderWithoutStep(){return this._stack.length===0?!1:(this._stack[this._stack.length-1].render(),!0)}pop(t=1){let s=!1;for(let e=0;e<t&&!(this._stack.length<=1);++e){s=!0;const n=this._stack.pop();if(!n)return;n.unloadScene()}if(s){const e=this._stack[this._stack.length-1];e&&e.onResume()}}push(t,s){const e=this._stack[this._stack.length-1];return e&&e.onPause(),this._runtimeGame.areSceneAssetsReady(t)?this._loadNewScene(t,s):(this._isNextLayoutLoading=!0,this._runtimeGame.loadSceneAssets(t).then(()=>{this._loadNewScene(t),this._isNextLayoutLoading=!1}),null)}_loadNewScene(t,s){const e=new c.RuntimeScene(this._runtimeGame);if(e.loadFromScene(this._runtimeGame.getSceneAndExtensionsData(t)),this._wasFirstSceneLoaded=!0,s){const n=this._runtimeGame.getExternalLayoutData(s);n&&e.createObjectsFrom(n.instances,0,0,0,!0)}return this._stack.push(e),e}replace(t,s){if(s)for(;this._stack.length!==0;){let e=this._stack.pop();e&&e.unloadScene()}else if(this._stack.length!==0){let e=this._stack.pop();e&&e.unloadScene()}return this.push(t)}getCurrentScene(){return this._stack.length===0?null:this._stack[this._stack.length-1]}wasFirstSceneLoaded(){return this._wasFirstSceneLoaded}getAllSceneNames(){return this._stack.map(t=>t.getName())}getNetworkSyncData(t){const s=t.playerNumber,e=t.isHost;if(s!==void 0&&!e)return null;const n=[];for(let a=0;a<this._stack.length;++a){const i=this._stack[a];n.push({name:i.getName(),networkId:i.getOrCreateNetworkId()})}return n}updateFromNetworkSyncData(t){this._sceneStackSyncDataToApply=t}applyUpdateFromNetworkSyncDataIfAny(){const t=this._sceneStackSyncDataToApply;let s=!1;if(!t)return s;this._sceneStackSyncDataToApply=null;for(let e=0;e<t.length;++e){const n=t[e],a=this._stack[e];if(!a){r.info(`Scene at position ${e} with name ${n.name} is missing from the stack, adding it.`);const i=this.push(n.name);i&&(i.networkId=n.networkId),s=!0;continue}if(a.getName()!==n.name){r.info(`Scene at position ${e} and name ${a.getName()} is not the same as the expected ${n.name}, replacing.`);const i=this.replace(n.name,!0);i&&(i.networkId=n.networkId),s=!0;continue}if(!a.networkId&&n.networkId&&n.name===a.getName()){r.info(`Scene at position ${e} and name ${a.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${n.networkId}.`),a.networkId=n.networkId;continue}if(a.networkId!==n.networkId){r.info(`Scene at position ${e} and name ${a.getName()} has a different networkId ${a.networkId} than the expected ${n.networkId}, replacing.`);const i=this.replace(n.name,!1);i&&(i.networkId=n.networkId),s=!0;continue}}if(this._stack.length>t.length){const e=this._stack.length-t.length;this.pop(e),s=!0}return s}}c.SceneStack=h})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=scenestack.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/scenestack.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Scene stack');\n const debugLogger = new gdjs.Logger('Multiplayer - Debug');\n\n /**\n * Hold the stack of scenes ({@link gdjs.RuntimeScene}) being played.\n */\n export class SceneStack {\n _runtimeGame: gdjs.RuntimeGame;\n _stack: gdjs.RuntimeScene[] = [];\n _wasFirstSceneLoaded: boolean = false;\n _isNextLayoutLoading: boolean = false;\n _sceneStackSyncDataToApply: SceneStackNetworkSyncData | null = null;\n\n /**\n * @param runtimeGame The runtime game that is using the scene stack\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n if (!runtimeGame) {\n throw 'SceneStack must be constructed with a gdjs.RuntimeGame.';\n }\n this._runtimeGame = runtimeGame;\n }\n\n /**\n * Called by the RuntimeGame when the game resolution is changed.\n * Useful to notify scene and layers that resolution is changed, as they\n * might be caching it.\n */\n onGameResolutionResized(): void {\n for (let i = 0; i < this._stack.length; ++i) {\n this._stack[i].onGameResolutionResized();\n }\n }\n\n step(elapsedTime: float): boolean {\n if (this._isNextLayoutLoading || this._stack.length === 0) {\n return false;\n }\n\n const hasMadeChangeToStack = this.applyUpdateFromNetworkSyncDataIfAny();\n if (hasMadeChangeToStack) {\n debugLogger.info(\n 'Scene stack has been updated from network sync data, skipping step.'\n );\n // If we have made changes to the stack as part of the network sync,\n // we trust the network to be the source of truth for the scene stack,\n // and skip the scene rendering (and so any other request to change the scene stack from it)\n return true;\n }\n\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene.renderAndStep(elapsedTime)) {\n const request = currentScene.getRequestedChange();\n\n // A scene change was requested by the current scene.\n if (request === gdjs.SceneChangeRequest.STOP_GAME) {\n this._runtimeGame.getRenderer().stopGame();\n return true;\n } else if (request === gdjs.SceneChangeRequest.POP_SCENE) {\n this.pop();\n } else if (request === gdjs.SceneChangeRequest.PUSH_SCENE) {\n this.push(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.REPLACE_SCENE) {\n this.replace(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.CLEAR_SCENES) {\n this.replace(currentScene.getRequestedScene(), true);\n } else {\n logger.error('Unrecognized change in scene stack: ' + request);\n }\n }\n\n return true;\n }\n\n renderWithoutStep(): boolean {\n if (this._stack.length === 0) {\n return false;\n }\n const currentScene = this._stack[this._stack.length - 1];\n currentScene.render();\n return true;\n }\n\n pop(popCount = 1): void {\n let hasDoneAnyChanges = false;\n for (let i = 0; i < popCount; ++i) {\n if (this._stack.length <= 1) {\n break;\n }\n\n // Unload the current scene\n hasDoneAnyChanges = true;\n const scene = this._stack.pop();\n if (!scene) {\n return;\n }\n scene.unloadScene();\n }\n\n // Tell the new current scene it's being resumed\n if (hasDoneAnyChanges) {\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onResume();\n }\n }\n }\n\n /**\n * Pause the scene currently being played and start the new scene that is specified.\n * If `externalLayoutName` is set, also instantiate the objects from this external layout.\n */\n push(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene | null {\n // Tell the scene it's being paused\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onPause();\n }\n\n // Avoid a risk of displaying an intermediate loading screen\n // during 1 frame.\n if (this._runtimeGame.areSceneAssetsReady(newSceneName)) {\n return this._loadNewScene(newSceneName, externalLayoutName);\n }\n\n this._isNextLayoutLoading = true;\n this._runtimeGame.loadSceneAssets(newSceneName).then(() => {\n this._loadNewScene(newSceneName);\n this._isNextLayoutLoading = false;\n });\n return null;\n }\n\n private _loadNewScene(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene {\n // Load the new one\n const newScene = new gdjs.RuntimeScene(this._runtimeGame);\n newScene.loadFromScene(\n this._runtimeGame.getSceneAndExtensionsData(newSceneName)\n );\n this._wasFirstSceneLoaded = true;\n\n // Optionally create the objects from an external layout.\n if (externalLayoutName) {\n const externalLayoutData = this._runtimeGame.getExternalLayoutData(\n externalLayoutName\n );\n if (externalLayoutData) {\n newScene.createObjectsFrom(\n externalLayoutData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n }\n }\n this._stack.push(newScene);\n return newScene;\n }\n\n /**\n * Start the specified scene, replacing the one currently being played.\n * If `clear` is set to true, all running scenes are also removed from the stack of scenes.\n */\n replace(newSceneName: string, clear?: boolean): gdjs.RuntimeScene | null {\n if (!!clear) {\n // Unload all the scenes\n while (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n } else {\n // Unload the current scene\n if (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n }\n return this.push(newSceneName);\n }\n\n /**\n * Return the current gdjs.RuntimeScene being played, or null if none is run.\n */\n getCurrentScene(): gdjs.RuntimeScene | null {\n if (this._stack.length === 0) {\n return null;\n }\n return this._stack[this._stack.length - 1];\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._wasFirstSceneLoaded;\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): SceneStackNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n if (syncedPlayerNumber !== undefined && syncedPlayerNumber !== 1) {\n // If we are getting sync data of a specific player,\n // and they are not the host, we don't sync the scene stack.\n return null;\n }\n\n // If we are the host, we can take charge of\n // generating a networkId for each scene if they don't have one.\n // They will be reconciled on the other players' games.\n const sceneStackSyncData: SceneStackSceneNetworkSyncData[] = [];\n for (let i = 0; i < this._stack.length; ++i) {\n const scene = this._stack[i];\n sceneStackSyncData.push({\n name: scene.getName(),\n networkId: scene.getOrCreateNetworkId(),\n });\n }\n return sceneStackSyncData;\n }\n\n updateFromNetworkSyncData(\n sceneStackSyncData: SceneStackNetworkSyncData\n ): void {\n // Don't directly apply changes to the scene stack. Store them and they will be applied\n // in `step` (i.e: at the end of a frame). Otherwise, we would risk doing operations on the scene\n // stack, like creating a new scene or unloading a scene, while being inside the `renderAndStep` method\n // of the current scene.\n this._sceneStackSyncDataToApply = sceneStackSyncData;\n }\n\n applyUpdateFromNetworkSyncDataIfAny(): boolean {\n const sceneStackSyncData = this._sceneStackSyncDataToApply;\n let hasMadeChangeToStack = false;\n if (!sceneStackSyncData) return hasMadeChangeToStack;\n\n this._sceneStackSyncDataToApply = null;\n\n // If this method is called, we are a client.\n // We trust the host to be the source of truth for the scene stack.\n // So we loop through the scenes in the stack given by the host and either:\n // - Set the networkId of the scene if it's already in the stack at the right place\n // - Add the scene to the stack if it's not there, and set its networkId\n // - Remove any scenes that are in the stack but not in the data given by the host\n for (let i = 0; i < sceneStackSyncData.length; ++i) {\n const sceneSyncData = sceneStackSyncData[i];\n const sceneAtThisPositionInOurStack = this._stack[i];\n if (!sceneAtThisPositionInOurStack) {\n debugLogger.info(\n `Scene at position ${i} with name ${sceneSyncData.name} is missing from the stack, adding it.`\n );\n // We have fewer scenes in the stack than the host, let's add the scene.\n const newScene = this.push(sceneSyncData.name);\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (sceneAtThisPositionInOurStack.getName() !== sceneSyncData.name) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} is not the same as the expected ${\n sceneSyncData.name\n }, replacing.`\n );\n // The scene does not correspond to the scene at this position in our stack\n // Let's unload everything after this position to recreate the stack.\n const newScene = this.replace(\n sceneSyncData.name,\n true // Clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n !sceneAtThisPositionInOurStack.networkId &&\n sceneSyncData.networkId &&\n sceneSyncData.name === sceneAtThisPositionInOurStack.getName()\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${\n sceneSyncData.networkId\n }.`\n );\n // The scene is in the stack but has no networkId,\n // this can happen at the start of the game on a player that is not the host,\n // or if a player switch to another scene before the host has sent the scene stack.\n // Let's set the networkId of the scene.\n sceneAtThisPositionInOurStack.networkId = sceneSyncData.networkId;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n sceneAtThisPositionInOurStack.networkId !== sceneSyncData.networkId\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has a different networkId ${\n sceneAtThisPositionInOurStack.networkId\n } than the expected ${sceneSyncData.networkId}, replacing.`\n );\n // The scene is in the stack but has a different networkId\n // This can happen if the host has restarted the scene\n // We can't just update the networkId of the scene in the stack\n // We need to replace it with a new scene\n const newScene = this.replace(\n sceneSyncData.name,\n false // Don't clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n // The scene is in the stack and has the right networkId.\n // Nothing to do, just continue to the next scene in the stack received from the host.\n }\n\n // Pop any scene not on the host.\n // In the future, we could avoid to pop scenes if they are not set to be synchronized.\n if (this._stack.length > sceneStackSyncData.length) {\n const popCount = this._stack.length - sceneStackSyncData.length;\n this.pop(popCount);\n hasMadeChangeToStack = true;\n }\n\n return hasMadeChangeToStack;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eACzB,EAAc,GAAI,GAAK,OAAO,uBAK7B,OAAiB,CAUtB,YAAY,EAA+B,CAR3C,YAA8B,GAC9B,0BAAgC,GAChC,0BAAgC,GAChC,gCAA+D,KAM7D,GAAI,CAAC,EACH,KAAM,0DAER,KAAK,aAAe,EAQtB,yBAAgC,CAC9B,OAAS,GAAI,EAAG,EAAI,KAAK,OAAO,OAAQ,EAAE,EACxC,KAAK,OAAO,GAAG,0BAInB,KAAK,EAA6B,CAChC,GAAI,KAAK,sBAAwB,KAAK,OAAO,SAAW,EACtD,MAAO,GAIT,GAD6B,KAAK,sCAEhC,SAAY,KACV,uEAKK,GAGT,KAAM,G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AAqB,KAAK,aAAa,sBAC3C,GAEF,AAAI,GACF,EAAS,kBACP,EAAmB,UACnB,EACA,EACA,EAEA,IAIN,YAAK,OAAO,KAAK,GACV,EAOT,QAAQ,EAAsB,EAA2C,CACvE,GAAM,EAEJ,KAAO,KAAK,OAAO,SAAW,GAAG,CAC/B,GAAI,GAAQ,KAAK,OAAO,MACxB,AAAI,GACF,EAAM,sBAKN,KAAK,OAAO,SAAW,EAAG,CAC5B,GAAI,GAAQ,KAAK,OAAO,MACxB,AAAI,GACF,EAAM,cAIZ,MAAO,MAAK,KAAK,GAMnB,iBAA4C,CAC1C,MAAI,MAAK,OAAO,SAAW,EAClB,KAEF,KAAK,OAAO,KAAK,OAAO,OAAS,GAM1C,qBAA+B,CAC7B,MAAO,MAAK,qBAGd,mBACE,EACkC,CAClC,KAAM,GAAqB,EAAY,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Scene stack');\n const debugLogger = new gdjs.Logger('Multiplayer - Debug');\n\n /**\n * Hold the stack of scenes ({@link gdjs.RuntimeScene}) being played.\n */\n export class SceneStack {\n _runtimeGame: gdjs.RuntimeGame;\n _stack: gdjs.RuntimeScene[] = [];\n _wasFirstSceneLoaded: boolean = false;\n _isNextLayoutLoading: boolean = false;\n _sceneStackSyncDataToApply: SceneStackNetworkSyncData | null = null;\n\n /**\n * @param runtimeGame The runtime game that is using the scene stack\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n if (!runtimeGame) {\n throw 'SceneStack must be constructed with a gdjs.RuntimeGame.';\n }\n this._runtimeGame = runtimeGame;\n }\n\n /**\n * Called by the RuntimeGame when the game resolution is changed.\n * Useful to notify scene and layers that resolution is changed, as they\n * might be caching it.\n */\n onGameResolutionResized(): void {\n for (let i = 0; i < this._stack.length; ++i) {\n this._stack[i].onGameResolutionResized();\n }\n }\n\n step(elapsedTime: float): boolean {\n if (this._isNextLayoutLoading || this._stack.length === 0) {\n return false;\n }\n\n const hasMadeChangeToStack = this.applyUpdateFromNetworkSyncDataIfAny();\n if (hasMadeChangeToStack) {\n debugLogger.info(\n 'Scene stack has been updated from network sync data, skipping step.'\n );\n // If we have made changes to the stack as part of the network sync,\n // we trust the network to be the source of truth for the scene stack,\n // and skip the scene rendering (and so any other request to change the scene stack from it)\n return true;\n }\n\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene.renderAndStep(elapsedTime)) {\n const request = currentScene.getRequestedChange();\n\n // A scene change was requested by the current scene.\n if (request === gdjs.SceneChangeRequest.STOP_GAME) {\n this._runtimeGame.getRenderer().stopGame();\n return true;\n } else if (request === gdjs.SceneChangeRequest.POP_SCENE) {\n this.pop();\n } else if (request === gdjs.SceneChangeRequest.PUSH_SCENE) {\n this.push(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.REPLACE_SCENE) {\n this.replace(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.CLEAR_SCENES) {\n this.replace(currentScene.getRequestedScene(), true);\n } else {\n logger.error('Unrecognized change in scene stack: ' + request);\n }\n }\n\n return true;\n }\n\n renderWithoutStep(): boolean {\n if (this._stack.length === 0) {\n return false;\n }\n const currentScene = this._stack[this._stack.length - 1];\n currentScene.render();\n return true;\n }\n\n pop(popCount = 1): void {\n let hasDoneAnyChanges = false;\n for (let i = 0; i < popCount; ++i) {\n if (this._stack.length <= 1) {\n break;\n }\n\n // Unload the current scene\n hasDoneAnyChanges = true;\n const scene = this._stack.pop();\n if (!scene) {\n return;\n }\n scene.unloadScene();\n }\n\n // Tell the new current scene it's being resumed\n if (hasDoneAnyChanges) {\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onResume();\n }\n }\n }\n\n /**\n * Pause the scene currently being played and start the new scene that is specified.\n * If `externalLayoutName` is set, also instantiate the objects from this external layout.\n */\n push(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene | null {\n // Tell the scene it's being paused\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onPause();\n }\n\n // Avoid a risk of displaying an intermediate loading screen\n // during 1 frame.\n if (this._runtimeGame.areSceneAssetsReady(newSceneName)) {\n return this._loadNewScene(newSceneName, externalLayoutName);\n }\n\n this._isNextLayoutLoading = true;\n this._runtimeGame.loadSceneAssets(newSceneName).then(() => {\n this._loadNewScene(newSceneName);\n this._isNextLayoutLoading = false;\n });\n return null;\n }\n\n private _loadNewScene(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene {\n // Load the new one\n const newScene = new gdjs.RuntimeScene(this._runtimeGame);\n newScene.loadFromScene(\n this._runtimeGame.getSceneAndExtensionsData(newSceneName)\n );\n this._wasFirstSceneLoaded = true;\n\n // Optionally create the objects from an external layout.\n if (externalLayoutName) {\n const externalLayoutData = this._runtimeGame.getExternalLayoutData(\n externalLayoutName\n );\n if (externalLayoutData) {\n newScene.createObjectsFrom(\n externalLayoutData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n }\n }\n this._stack.push(newScene);\n return newScene;\n }\n\n /**\n * Start the specified scene, replacing the one currently being played.\n * If `clear` is set to true, all running scenes are also removed from the stack of scenes.\n */\n replace(newSceneName: string, clear?: boolean): gdjs.RuntimeScene | null {\n if (!!clear) {\n // Unload all the scenes\n while (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n } else {\n // Unload the current scene\n if (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n }\n return this.push(newSceneName);\n }\n\n /**\n * Return the current gdjs.RuntimeScene being played, or null if none is run.\n */\n getCurrentScene(): gdjs.RuntimeScene | null {\n if (this._stack.length === 0) {\n return null;\n }\n return this._stack[this._stack.length - 1];\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._wasFirstSceneLoaded;\n }\n\n getAllSceneNames(): Array<string> {\n return this._stack.map((scene) => scene.getName());\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): SceneStackNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n const isHost = syncOptions.isHost;\n if (syncedPlayerNumber !== undefined && !isHost) {\n // If we are getting sync data of a specific player,\n // and they are not the host, we don't sync the scene stack.\n return null;\n }\n\n // If we are the host, we can take charge of\n // generating a networkId for each scene if they don't have one.\n // They will be reconciled on the other players' games.\n const sceneStackSyncData: SceneStackSceneNetworkSyncData[] = [];\n for (let i = 0; i < this._stack.length; ++i) {\n const scene = this._stack[i];\n sceneStackSyncData.push({\n name: scene.getName(),\n networkId: scene.getOrCreateNetworkId(),\n });\n }\n return sceneStackSyncData;\n }\n\n updateFromNetworkSyncData(\n sceneStackSyncData: SceneStackNetworkSyncData\n ): void {\n // Don't directly apply changes to the scene stack. Store them and they will be applied\n // in `step` (i.e: at the end of a frame). Otherwise, we would risk doing operations on the scene\n // stack, like creating a new scene or unloading a scene, while being inside the `renderAndStep` method\n // of the current scene.\n this._sceneStackSyncDataToApply = sceneStackSyncData;\n }\n\n applyUpdateFromNetworkSyncDataIfAny(): boolean {\n const sceneStackSyncData = this._sceneStackSyncDataToApply;\n let hasMadeChangeToStack = false;\n if (!sceneStackSyncData) return hasMadeChangeToStack;\n\n this._sceneStackSyncDataToApply = null;\n\n // If this method is called, we are a client.\n // We trust the host to be the source of truth for the scene stack.\n // So we loop through the scenes in the stack given by the host and either:\n // - Set the networkId of the scene if it's already in the stack at the right place\n // - Add the scene to the stack if it's not there, and set its networkId\n // - Remove any scenes that are in the stack but not in the data given by the host\n for (let i = 0; i < sceneStackSyncData.length; ++i) {\n const sceneSyncData = sceneStackSyncData[i];\n const sceneAtThisPositionInOurStack = this._stack[i];\n if (!sceneAtThisPositionInOurStack) {\n debugLogger.info(\n `Scene at position ${i} with name ${sceneSyncData.name} is missing from the stack, adding it.`\n );\n // We have fewer scenes in the stack than the host, let's add the scene.\n const newScene = this.push(sceneSyncData.name);\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (sceneAtThisPositionInOurStack.getName() !== sceneSyncData.name) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} is not the same as the expected ${\n sceneSyncData.name\n }, replacing.`\n );\n // The scene does not correspond to the scene at this position in our stack\n // Let's unload everything after this position to recreate the stack.\n const newScene = this.replace(\n sceneSyncData.name,\n true // Clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n !sceneAtThisPositionInOurStack.networkId &&\n sceneSyncData.networkId &&\n sceneSyncData.name === sceneAtThisPositionInOurStack.getName()\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${\n sceneSyncData.networkId\n }.`\n );\n // The scene is in the stack but has no networkId,\n // this can happen at the start of the game on a player that is not the host,\n // or if a player switch to another scene before the host has sent the scene stack.\n // Let's set the networkId of the scene.\n sceneAtThisPositionInOurStack.networkId = sceneSyncData.networkId;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n sceneAtThisPositionInOurStack.networkId !== sceneSyncData.networkId\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has a different networkId ${\n sceneAtThisPositionInOurStack.networkId\n } than the expected ${sceneSyncData.networkId}, replacing.`\n );\n // The scene is in the stack but has a different networkId\n // This can happen if the host has restarted the scene\n // We can't just update the networkId of the scene in the stack\n // We need to replace it with a new scene\n const newScene = this.replace(\n sceneSyncData.name,\n false // Don't clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n // The scene is in the stack and has the right networkId.\n // Nothing to do, just continue to the next scene in the stack received from the host.\n }\n\n // Pop any scene not on the host.\n // In the future, we could avoid to pop scenes if they are not set to be synchronized.\n if (this._stack.length > sceneStackSyncData.length) {\n const popCount = this._stack.length - sceneStackSyncData.length;\n this.pop(popCount);\n hasMadeChangeToStack = true;\n }\n\n return hasMadeChangeToStack;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eACzB,EAAc,GAAI,GAAK,OAAO,uBAK7B,OAAiB,CAUtB,YAAY,EAA+B,CAR3C,YAA8B,GAC9B,0BAAgC,GAChC,0BAAgC,GAChC,gCAA+D,KAM7D,GAAI,CAAC,EACH,KAAM,0DAER,KAAK,aAAe,EAQtB,yBAAgC,CAC9B,OAAS,GAAI,EAAG,EAAI,KAAK,OAAO,OAAQ,EAAE,EACxC,KAAK,OAAO,GAAG,0BAInB,KAAK,EAA6B,CAChC,GAAI,KAAK,sBAAwB,KAAK,OAAO,SAAW,EACtD,MAAO,GAIT,GAD6B,KAAK,sCAEhC,SAAY,KACV,uEAKK,GAGT,KAAM,GAAe,KAAK,OAAO,KAAK,OAAO,OAAS,GACtD,GAAI,EAAa,cAAc,GAAc,CAC3C,KAAM,GAAU,EAAa,qBAG7B,GAAI,IAAY,EAAK,mBAAmB,UACtC,YAAK,aAAa,cAAc,WACzB,GACF,AAAI,IAAY,EAAK,mBAAmB,UAC7C,KAAK,MACA,AAAI,IAAY,EAAK,mBAAmB,WAC7C,KAAK,KAAK,EAAa,qBAClB,AAAI,IAAY,EAAK,mBAAmB,cAC7C,KAAK,QAAQ,EAAa,qBACrB,AAAI,IAAY,EAAK,mBAAmB,aAC7C,KAAK,QAAQ,EAAa,oBAAqB,IAE/C,EAAO,MAAM,uCAAyC,GAI1D,MAAO,GAGT,mBAA6B,CAC3B,MAAI,MAAK,OAAO,SAAW,EAClB,GAGT,CADqB,KAAK,OAAO,K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AAc,KACd,IAEF,AAAI,GACF,GAAS,UAAY,EAAc,WAErC,EAAuB,GAEvB,UASJ,GAAI,KAAK,OAAO,OAAS,EAAmB,OAAQ,CAClD,KAAM,GAAW,KAAK,OAAO,OAAS,EAAmB,OACzD,KAAK,IAAI,GACT,EAAuB,GAGzB,MAAO,IA3VJ,EAAM,eAPL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(n){class s extends n.RuntimeObject{constructor(t,e){super(t,e);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._animationFrameDirty=!0;this._updateIfNotVisible=!!e.updateIfNotVisible,this._renderer=new n.SpriteRuntimeObjectRenderer(this,t),this._animator=new n.SpriteAnimator(e.animations,n.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(t.getGame().getImageManager())),this._updateAnimationFrame(),this.onCreated()}reinitialize(t){super.reinitialize(t);const e=this.getInstanceContainer();this._animator.reinitialize(t.animations),this._scaleX=1,this._scaleY=1,this._blendMode=0,this._flippedX=!1,this._flippedY=!1,this.opacity=255,this._updateIfNotVisible=!!t.updateIfNotVisible,this._renderer.reinitialize(this,e),this._updateAnimationFrame(),this.onCreated()}updateFromObjectData(t,e){return this._animator.updateFromObjectData(t.animations,e.animations),this._updateIfNotVisible=!!e.updateIfNotVisible,this.invalidateHitboxes(),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),anim:this._animator.getNetworkSyncData(),ifx:this.isFlippedX(),ify:this.isFlippedY(),sx:this._scaleX,sy:this._scaleY,op:this.opacity,color:this.getColor()}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),t.ifx!==void 0&&this.flipX(t.ifx),t.ify!==void 0&&this.flipY(t.ify),t.sx!==void 0&&this.setScaleX(Math.abs(t.sx)),t.sy!==void 0&&this.setScaleY(Math.abs(t.sy)),t.op!==void 0&&this.setOpacity(t.op),t.anim&&(this._animator.updateFromNetworkSyncData(t.anim),this._updateAnimationFrame()),(t.ifx!==void 0||t.ify!==void 0||t.sx!==void 0||t.sy!==void 0||t.anim!==void 0)&&this.invalidateHitboxes(),t.color!==void 0&&this.setColor(t.color)}extraInitializationFromInitialInstance(t){if(t.numberProperties)for(let e=0,i=t.numberProperties.length;e<i;++e){const a=t.numberProperties[e];a.name==="animation"&&this.setAnimationIndex(a.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height))}update(t){if(!this._updateIfNotVisible&&!this._renderer.getRendererObject().visible)return;this._animator.step(this.getElapsedTime()/1e3)&&(this._updateAnimationFrame(),this.invalidateHitboxes()),this._renderer.ensureUpToDate()}updatePreRender(t){this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.ensureUpToDate()}_updateAnimationFrame(){this._animationFrameDirty=!1;const t=this._animator.getCurrentFrame();t&&this._renderer.updateFrame(t)}getRendererObject(){return this._renderer.getRendererObject()}updateHitBoxes(){const t=this._animator.getCurrentFrame();if(!!t){if(!t.hasCustomHitBoxes)return super.updateHitBoxes();for(let e=0;e<t.customHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new n.Polygon);for(let i=0;i<t.customHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),this._transformToGlobal(t.customHitBoxes[e].vertices[i][0],t.customHitBoxes[e].vertices[i][1],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=t.customHitBoxes[e].vertices.length}this.hitBoxes.length=t.customHitBoxes.length}}setAnimation(t){this.setAnimationIndex(t)}setAnimationIndex(t){this._animator.setAnimationIndex(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}setAnimationName(t){this._animator.setAnimationName(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimation(){return this.getAnimationIndex()}getAnimationIndex(){return this._animator.getAnimationIndex()}getAnimationName(){return this._animator.getAnimationName()}isCurrentAnimationName(t){return this.getAnimationName()===t}setDirectionOrAngle(t){const e=this._animator.setDirectionOrAngle(this.angle,t);e!==null&&(this.angle=e,this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes(),this._renderer.updateAngle())}getDirectionOrAngle(){return this._animator.getDirectionOrAngle(this.angle)}setAnimationFrame(t){this._animator.setAnimationFrameIndex(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationFrame(){return this._animator.getAnimationFrameIndex()}getAnimationElapsedTime(){return this._animator.getAnimationElapsedTime()}setAnimationElapsedTime(t){this._animator.getAnimationElapsedTime()&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationDuration(){return this._animator.getAnimationDuration()}getAnimationFrameCount(){return this._animator.getAnimationFrameCount()}hasAnimationEndedLegacy(){return this._animator.hasAnimationEndedLegacy()}hasAnimationEnded2(){return this._animator.hasAnimationEnded()}hasAnimationEnded(){return this._animator.hasAnimationEnded()}animationPaused(){return this._animator.isAnimationPaused()}isAnimationPaused(){return this._animator.isAnimationPaused()}pauseAnimation(){this._animator.pauseAnimation()}playAnimation(){this._animator.resumeAnimation()}resumeAnimation(){this._animator.resumeAnimation()}getAnimationSpeedScale(){return this._animator.getAnimationSpeedScale()}setAnimationSpeedScale(t){this._animator.setAnimationSpeedScale(t)}getPointX(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getX();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),a[0]}getPointY(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getY();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointY);return this._transformToGlobal(i.x,i.y,a),a[1]}getPointPosition(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return[this.getX(),this.getY()];const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),[a[0],a[1]]}_transformToGlobal(t,e,i){const a=this._animator.getCurrentFrame();let r=a.center.x,o=a.center.y;this._flippedX&&(t=t+(r-t)*2),this._flippedY&&(e=e+(o-e)*2);const h=Math.abs(this._scaleX),l=Math.abs(this._scaleY);t*=h,e*=l,r*=h,o*=l;const d=this.angle/180*Math.PI,m=Math.cos(d),u=Math.sin(d),p=t-r,g=e-o;t=r+m*p-u*g,e=o+u*p+m*g,i.length=2,i[0]=t+(this.x-a.origin.x*h),i[1]=e+(this.y-a.origin.y*l)}getDrawableX(){const t=this._animator.getCurrentFrame();if(t===null)return this.x;const e=Math.abs(this._scaleX);return this._flippedX?this.x+(-t.origin.x-this._renderer.getUnscaledWidth()+2*t.center.x)*e:this.x-t.origin.x*e}getDrawableY(){const t=this._animator.getCurrentFrame();if(t===null)return this.y;const e=Math.abs(this._scaleY);return this._flippedY?this.y+(-t.origin.y-this._renderer.getUnscaledHeight()+2*t.center.y)*e:this.y-t.origin.y*e}getCenterX(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedX?(this._renderer.getUnscaledWidth()-t.center.x)*Math.abs(this._scaleX):t.center.x*Math.abs(this._scaleX)}getCenterY(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedY?(this._renderer.getUnscaledHeight()-t.center.y)*Math.abs(this._scaleY):t.center.y*Math.abs(this._scaleY)}setX(t){if(t===this.x)return;this.x=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateX())}setY(t){if(t===this.y)return;this.y=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateY())}setAngle(t){const e=this._animator.setAngle(this.angle,t);e!==null&&(this.angle=e,this.invalidateHitboxes(),this._renderer.updateAngle())}getAngle(){return this._animator.getAngle(this.angle)}setBlendMode(t){this._blendMode!==t&&(this._blendMode=t,this._renderer.update())}getBlendMode(){return this._blendMode}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this._renderer.updateVisibility()}setColor(t){this._renderer.setColor(t)}getColor(){return this._renderer.getColor()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this._renderer.update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this._renderer.update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getWidth(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getWidth()}getHeight(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getHeight()}setWidth(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledWidth();e!==0&&this.setScaleX(t/e)}setHeight(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledHeight();e!==0&&this.setScaleY(t/e)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}turnTowardObject(t,e){t!==null&&this.rotateTowardPosition(t.getDrawableX()+t.getCenterX(),t.getDrawableY()+t.getCenterY(),0,e)}}n.SpriteRuntimeObject=s,n.registerObject("Sprite",n.SpriteRuntimeObject),s.supportsReinitialization=!0})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(n){class s extends n.RuntimeObject{constructor(t,e){super(t,e);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._preScale=1;this._animationFrameDirty=!0;this._updateIfNotVisible=!!e.updateIfNotVisible,this._preScale=e.preScale||1,this._renderer=new n.SpriteRuntimeObjectRenderer(this,t),this._animator=new n.SpriteAnimator(e.animations,n.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(t.getGame().getImageManager())),this._updateAnimationFrame(),this.onCreated()}reinitialize(t){super.reinitialize(t);const e=this.getInstanceContainer();this._animator.reinitialize(t.animations),this._scaleX=1,this._scaleY=1,this._blendMode=0,this._flippedX=!1,this._flippedY=!1,this.opacity=255,this._updateIfNotVisible=!!t.updateIfNotVisible,this._preScale=t.preScale||1,this._renderer.reinitialize(this,e),this._updateAnimationFrame(),this.onCreated()}updateFromObjectData(t,e){return this._preScale=e.preScale||1,this._animator.updateFromObjectData(t.animations,e.animations),this._updateIfNotVisible=!!e.updateIfNotVisible,this._updateAnimationFrame(),this.invalidateHitboxes(),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),anim:this._animator.getNetworkSyncData(),ifx:this.isFlippedX(),ify:this.isFlippedY(),sx:this._scaleX,sy:this._scaleY,op:this.opacity,color:this.getColor()}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),t.ifx!==void 0&&this.flipX(t.ifx),t.ify!==void 0&&this.flipY(t.ify),t.sx!==void 0&&this.setScaleX(Math.abs(t.sx)),t.sy!==void 0&&this.setScaleY(Math.abs(t.sy)),t.op!==void 0&&this.setOpacity(t.op),t.anim&&(this._animator.updateFromNetworkSyncData(t.anim),this._updateAnimationFrame()),(t.ifx!==void 0||t.ify!==void 0||t.sx!==void 0||t.sy!==void 0||t.anim!==void 0)&&this.invalidateHitboxes(),t.color!==void 0&&this.setColor(t.color)}extraInitializationFromInitialInstance(t){if(t.numberProperties)for(let e=0,i=t.numberProperties.length;e<i;++e){const a=t.numberProperties[e];a.name==="animation"&&this.setAnimationIndex(a.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height)),t.opacity!==void 0&&this.setOpacity(t.opacity),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY)}update(t){if(!this._updateIfNotVisible&&!this._renderer.getRendererObject().visible)return;this._animator.step(this.getElapsedTime()/1e3)&&(this._updateAnimationFrame(),this.invalidateHitboxes()),this._renderer.ensureUpToDate()}updatePreRender(t){this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.ensureUpToDate()}_updateAnimationFrame(){this._animationFrameDirty=!1;const t=this._animator.getCurrentFrame();t&&this._renderer.updateFrame(t)}getRendererObject(){return this._renderer.getRendererObject()}updateHitBoxes(){const t=this._animator.getCurrentFrame();if(!!t){if(!t.hasCustomHitBoxes)return super.updateHitBoxes();for(let e=0;e<t.customHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new n.Polygon);for(let i=0;i<t.customHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),this._transformToGlobal(t.customHitBoxes[e].vertices[i][0],t.customHitBoxes[e].vertices[i][1],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=t.customHitBoxes[e].vertices.length}this.hitBoxes.length=t.customHitBoxes.length}}setAnimation(t){this.setAnimationIndex(t)}setAnimationIndex(t){this._animator.setAnimationIndex(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}setAnimationName(t){this._animator.setAnimationName(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimation(){return this.getAnimationIndex()}getAnimationIndex(){return this._animator.getAnimationIndex()}getAnimationName(){return this._animator.getAnimationName()}isCurrentAnimationName(t){return this.getAnimationName()===t}setDirectionOrAngle(t){const e=this._animator.setDirectionOrAngle(this.angle,t);e!==null&&(this.angle=e,this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes(),this._renderer.updateAngle())}getDirectionOrAngle(){return this._animator.getDirectionOrAngle(this.angle)}setAnimationFrame(t){this._animator.setAnimationFrameIndex(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationFrame(){return this._animator.getAnimationFrameIndex()}getAnimationElapsedTime(){return this._animator.getAnimationElapsedTime()}setAnimationElapsedTime(t){this._animator.setAnimationElapsedTime(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationDuration(){return this._animator.getAnimationDuration()}getAnimationFrameCount(){return this._animator.getAnimationFrameCount()}hasAnimationEndedLegacy(){return this._animator.hasAnimationEndedLegacy()}hasAnimationEnded2(){return this._animator.hasAnimationEnded()}hasAnimationEnded(){return this._animator.hasAnimationEnded()}animationPaused(){return this._animator.isAnimationPaused()}isAnimationPaused(){return this._animator.isAnimationPaused()}pauseAnimation(){this._animator.pauseAnimation()}playAnimation(){this._animator.resumeAnimation()}resumeAnimation(){this._animator.resumeAnimation()}getAnimationSpeedScale(){return this._animator.getAnimationSpeedScale()}setAnimationSpeedScale(t){this._animator.setAnimationSpeedScale(t)}getPointX(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getX();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),a[0]}getPointY(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getY();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointY);return this._transformToGlobal(i.x,i.y,a),a[1]}getPointPosition(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return[this.getX(),this.getY()];const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),[a[0],a[1]]}_transformToGlobal(t,e,i){const a=this._animator.getCurrentFrame();let r=a.center.x,o=a.center.y;this._flippedX&&(t=t+(r-t)*2),this._flippedY&&(e=e+(o-e)*2);const h=Math.abs(this._scaleX*this._preScale),l=Math.abs(this._scaleY*this._preScale);t*=h,e*=l,r*=h,o*=l;const d=this.angle/180*Math.PI,m=Math.cos(d),p=Math.sin(d),u=t-r,f=e-o;t=r+m*u-p*f,e=o+p*u+m*f,i.length=2,i[0]=t+(this.x-a.origin.x*h),i[1]=e+(this.y-a.origin.y*l)}getDrawableX(){const t=this._animator.getCurrentFrame();if(t===null)return this.x;const e=Math.abs(this._scaleX*this._preScale);return this._flippedX?this.x+(-t.origin.x-this._renderer.getUnscaledWidth()+2*t.center.x)*e:this.x-t.origin.x*e}getDrawableY(){const t=this._animator.getCurrentFrame();if(t===null)return this.y;const e=Math.abs(this._scaleY*this._preScale);return this._flippedY?this.y+(-t.origin.y-this._renderer.getUnscaledHeight()+2*t.center.y)*e:this.y-t.origin.y*e}getCenterX(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedX?(this._renderer.getUnscaledWidth()-t.center.x)*Math.abs(this._scaleX*this._preScale):t.center.x*Math.abs(this._scaleX*this._preScale)}getCenterY(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedY?(this._renderer.getUnscaledHeight()-t.center.y)*Math.abs(this._scaleY*this._preScale):t.center.y*Math.abs(this._scaleY*this._preScale)}setX(t){if(t===this.x)return;this.x=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateX())}setY(t){if(t===this.y)return;this.y=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateY())}setAngle(t){const e=this._animator.setAngle(this.angle,t);e!==null&&(this.angle=e,this.invalidateHitboxes(),this._renderer.updateAngle())}getAngle(){return this._animator.getAngle(this.angle)}setBlendMode(t){this._blendMode!==t&&(this._blendMode=t,this._renderer.update())}getBlendMode(){return this._blendMode}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this._renderer.updateVisibility()}setColor(t){this._renderer.setColor(t)}getColor(){return this._renderer.getColor()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this._renderer.update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this._renderer.update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getWidth(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getWidth()}getHeight(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getHeight()}setWidth(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledWidth();e!==0&&this.setScaleX(t/e)}setHeight(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledHeight();e!==0&&this.setScaleY(t/e)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}turnTowardObject(t,e){t!==null&&this.rotateTowardPosition(t.getDrawableX()+t.getCenterX(),t.getDrawableY()+t.getCenterY(),0,e)}}n.SpriteRuntimeObject=s,n.registerObject("Sprite",n.SpriteRuntimeObject),s.supportsReinitialization=!0})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=spriteruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/spriteruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(newNetworkSyncData: SpriteNetworkSyncData) {\n super.updateFromNetworkSyncData(newNetworkSyncData);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged = this._animator.setAnimationIndex(\n newAnimation\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged = this._animator.setAnimationName(\n newAnimationName\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.getAnimationElapsedTime();\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame = this._animator.getCurrentFrame() as SpriteAnimationFrame<\n any\n >;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return animationFrame.center.x * Math.abs(this._scaleX);\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return animationFrame.center.y * Math.abs(this._scaleY);\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbColor The color, in RGB format (\"128;200;255\").\n */\n setColor(rgbColor: string): void {\n this._renderer.setColor(rgbColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / unscaledWidth);\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / unscaledHeight);\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @param scene The scene containing the object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null, scene: gdjs.RuntimeScene) {\n if (obj === null) {\n return;\n }\n this.rotateTowardPosition(\n obj.getDrawableX() + obj.getCenterX(),\n obj.getDrawableY() + obj.getCenterY(),\n 0,\n scene\n );\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The scale applied to object to evaluate the default dimensions */\n preScale?: float;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n _preScale: float = 1;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._preScale = newObjectData.preScale || 1;\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this._updateAnimationFrame();\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(newNetworkSyncData: SpriteNetworkSyncData) {\n super.updateFromNetworkSyncData(newNetworkSyncData);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged = this._animator.setAnimationIndex(\n newAnimation\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged = this._animator.setAnimationName(\n newAnimationName\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.setAnimationElapsedTime(time);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame = this._animator.getCurrentFrame() as SpriteAnimationFrame<\n any\n >;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.x * Math.abs(this._scaleX * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX * this._preScale)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.y * Math.abs(this._scaleY * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY * this._preScale)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbOrHexColor The color as a string, in RGB format (\"128;200;255\") or Hex format.\n */\n setColor(rgbOrHexColor: string): void {\n this._renderer.setColor(rgbOrHexColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / unscaledWidth);\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / unscaledHeight);\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @param scene The scene containing the object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null, scene: gdjs.RuntimeScene) {\n if (obj === null) {\n return;\n }\n this.rotateTowardPosition(\n obj.getDrawableX() + obj.getCenterX(),\n obj.getDrawableY() + obj.getCenterY(),\n 0,\n scene\n );\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CA6BS,eACG,GAAK,aAMS,CAkBtB,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApB3B,aAAiB,EACjB,aAAiB,EACjB,gBAAsB,EACtB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IAEjB,eAAmB,EAGnB,0BAAuB,GAWrB,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,UAAY,GAAI,GAA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