gdcore-tools 2.0.0-gd-v5.5.235-autobuild → 2.0.0-gd-v5.5.237-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Cube3DRuntimeObjectPixiRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.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/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +10 -8
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +67 -0
- 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.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +48 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.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 +26 -0
- 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/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.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/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/events-tools/inputtools.js +1 -1
- package/dist/Runtime/events-tools/inputtools.js.map +2 -2
- package/dist/Runtime/runtimeobject.js +1 -1
- package/dist/Runtime/runtimeobject.js.map +2 -2
- package/dist/Runtime/runtimescene.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +4 -0
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TileMap/tilemapcollisionmaskruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapCollisionMaskObjectDataType = {\n content: {\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n collisionMaskTag: string;\n debugMode: boolean;\n fillColor: string;\n outlineColor: string;\n };\n fillOpacity: float;\n outlineOpacity: float;\n outlineSize: float;\n };\n\n export type TilemapCollisionMaskObjectData = ObjectData &\n TilemapCollisionMaskObjectDataType;\n\n export type TilemapCollisionMaskNetworkSyncDataType = {\n tmjf: string;\n tsjf: string;\n dm: boolean;\n oc: integer;\n fc: integer;\n os: float;\n fo: float;\n oo: float;\n wid: float;\n hei: float;\n };\n\n export type TilemapCollisionMaskNetworkSyncData = ObjectNetworkSyncData &\n TilemapCollisionMaskNetworkSyncDataType;\n\n /**\n * An object that handle hitboxes for a tile map.\n * @extends gdjs.RuntimeObject\n */\n export class TileMapCollisionMaskRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable\n {\n private _tilemapJsonFile: string;\n private _tilesetJsonFile: string;\n private _renderer: gdjs.TileMap.TileMapCollisionMaskRenderer;\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap;\n /**\n * The tiles are filtered according to this tag.\n *\n * This allows have multiple objects with different usage\n * for the same tile map.\n * For instance, platforms, jumpthru, ladder, spike, water...\n */\n private _collisionMaskTag: string;\n private _layerIndex: integer | null;\n private _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n\n /**\n * When set to true, the hitboxes will be shown.\n */\n _debugMode: boolean;\n _fillColor: integer;\n _outlineColor: integer;\n _fillOpacity: float;\n _outlineOpacity: float;\n _outlineSize: float;\n\n _width: float;\n _height: float;\n _scaleX: float;\n _scaleY: float;\n\n /**\n * If the owner moves, the hitboxes vertices\n * will have to be transformed again.\n */\n private _transformationIsUpToDate: boolean = false;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._collisionMaskTag = objectData.content.collisionMaskTag;\n this._layerIndex =\n objectData.content.useAllLayers ||\n objectData.content.useAllLayers === undefined\n ? null\n : Number.isFinite(objectData.content.layerIndex)\n ? objectData.content.layerIndex\n : 1;\n this._debugMode = objectData.content.debugMode;\n this._fillColor = gdjs.rgbOrHexStringToNumber(\n objectData.content.fillColor\n );\n this._outlineColor = gdjs.rgbOrHexStringToNumber(\n objectData.content.outlineColor\n );\n this._fillOpacity = objectData.content.fillOpacity;\n this._outlineOpacity = objectData.content.outlineOpacity;\n this._outlineSize = objectData.content.outlineSize;\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n\n // The actual size is set when the tile map file is loaded.\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n const editableTileMap = new TileMapHelper.EditableTileMap(\n 1,\n 1,\n 0,\n 0,\n new Map()\n );\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n editableTileMap,\n this._collisionMaskTag,\n this._layerIndex\n );\n\n this._renderer = new gdjs.TileMap.TileMapCollisionMaskRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer) {\n super.updatePreRender(instanceContainer);\n\n if (this._debugMode && this.hitBoxesDirty) {\n this.updateHitBoxes();\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n getVisibilityAABB() {\n return null;\n }\n\n updateFromObjectData(\n oldObjectData: TilemapCollisionMaskObjectData,\n newObjectData: TilemapCollisionMaskObjectData\n ): boolean {\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (oldObjectData.content.debugMode !== newObjectData.content.debugMode) {\n this.setDebugMode(newObjectData.content.debugMode);\n }\n if (oldObjectData.content.fillColor !== newObjectData.content.fillColor) {\n this.setFillColor(\n gdjs.rgbOrHexStringToNumber(newObjectData.content.fillColor)\n );\n }\n if (\n oldObjectData.content.outlineColor !==\n newObjectData.content.outlineColor\n ) {\n this.setOutlineColor(\n gdjs.rgbOrHexStringToNumber(newObjectData.content.outlineColor)\n );\n }\n if (oldObjectData.fillOpacity !== newObjectData.fillOpacity) {\n this.setFillOpacity(newObjectData.fillOpacity);\n }\n if (oldObjectData.outlineOpacity !== newObjectData.outlineOpacity) {\n this.setOutlineOpacity(newObjectData.outlineOpacity);\n }\n if (oldObjectData.outlineSize !== newObjectData.outlineSize) {\n this.setOutlineSize(newObjectData.outlineSize);\n }\n // TODO Handle changes to collisionMaskTag, useAllLayers and layerIndex.\n return true;\n }\n\n getNetworkSyncData(): TilemapCollisionMaskNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n tmjf: this.getTilemapJsonFile(),\n tsjf: this.getTilesetJsonFile(),\n dm: this.getDebugMode(),\n oc: this.getOutlineColor(),\n fc: this.getFillColor(),\n os: this.getOutlineSize(),\n fo: this.getFillOpacity(),\n oo: this.getOutlineOpacity(),\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TilemapCollisionMaskNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.dm !== undefined) {\n this.setDebugMode(networkSyncData.dm);\n }\n if (networkSyncData.oc !== undefined) {\n this.setOutlineColor(networkSyncData.oc);\n }\n if (networkSyncData.fc !== undefined) {\n this.setFillColor(networkSyncData.fc);\n }\n if (networkSyncData.os !== undefined) {\n this.setOutlineSize(networkSyncData.os);\n }\n if (networkSyncData.fo !== undefined) {\n this.setFillOpacity(networkSyncData.fo);\n }\n if (networkSyncData.oo !== undefined) {\n this.setOutlineOpacity(networkSyncData.oo);\n }\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n 0, // levelIndex\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already log errors.\n return;\n }\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._collisionMaskTag,\n this._layerIndex\n );\n // The tile map polygons always keep the same references.\n // It works because the tilemap is never modified.\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._collisionMaskTag)\n );\n this._renderer.redrawCollisionMask();\n\n this._width = this._collisionTileMap.getWidth() * this._scaleX;\n this._height = this._collisionTileMap.getHeight() * this._scaleY;\n }\n );\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n // Update the RuntimeObject hitboxes attribute.\n for (const _ of this._collisionTileMap.getAllHitboxes(\n this._collisionMaskTag\n )) {\n // RuntimeObject.hitBoxes contains the same polygons instances as the\n // hitboxes from the tiles.\n //\n // When hitboxes for a tile is asked to the model, they are updated\n // according to the new object location if needed.\n // Iterating over all the tiles forces them to update their hitboxes.\n //\n // The hitboxes array is built by _updateTileMap().\n }\n this.hitBoxesDirty = false;\n this._renderer.redrawCollisionMask();\n this.updateAABB();\n }\n\n /**\n * Update the affine transformation according to the object position, size\n * and angle.\n */\n updateTransformation(): void {\n if (this._transformationIsUpToDate) {\n return;\n }\n const transformation = this._collisionTileMap.getTransformation();\n\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n\n transformation.setToIdentity();\n\n // Translation\n transformation.translate(this.x, this.y);\n\n // Rotation\n const angleInRadians = (this.angle * Math.PI) / 180;\n transformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n transformation.scale(absScaleX, absScaleY);\n\n this._collisionTileMap.setTransformation(transformation);\n\n this._transformationIsUpToDate = true;\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n getHitBoxesAround(left: float, top: float, right: float, bottom: float) {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n return this._collisionTileMap.getHitboxesAround(\n this._collisionMaskTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n /**\n * insideObject usually use the AABB of the object.\n * But, in case of a tile map, it makes more sense to look each tile individually.\n * It returns true when there is an hitbox in the tile.\n */\n insideObject(x: float, y: float): boolean {\n this.updateTransformation();\n // This is more precise than the default implementation.\n return this._collisionTileMap.pointIsInsideTile(\n x,\n y,\n this._collisionMaskTag\n );\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n /**\n * Set the Tilemap json file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string) {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n /**\n * @returns true if the hitboxes are shown.\n */\n getDebugMode(): boolean {\n return this._debugMode;\n }\n\n /**\n * @returns true if the hitboxes are shown.\n */\n setDebugMode(debugMode: boolean): void {\n this._debugMode = debugMode;\n this._renderer.redrawCollisionMask();\n }\n\n getFillColor(): integer {\n return this._fillColor;\n }\n\n getOutlineColor(): integer {\n return this._outlineColor;\n }\n\n setFillColor(fillColor: integer): void {\n this._fillColor = fillColor;\n }\n\n setOutlineColor(outlineColor: integer): void {\n this._outlineColor = outlineColor;\n }\n\n setOutlineSize(size: float): void {\n this._outlineSize = size;\n }\n\n getOutlineSize(): float {\n return this._outlineSize;\n }\n\n /**\n *\n * @param opacity from 0 to 255\n */\n setFillOpacity(opacity: float): void {\n this._fillOpacity = opacity;\n }\n\n /**\n *\n * @returns an opacity value from 0 to 255.\n */\n getFillOpacity(): float {\n return this._fillOpacity;\n }\n\n /**\n *\n * @param opacity from 0 to 255\n */\n setOutlineOpacity(opacity: float): void {\n this._outlineOpacity = opacity;\n }\n\n /**\n *\n * @returns an opacity value from 0 to 255.\n */\n getOutlineOpacity(): float {\n return this._outlineOpacity;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._transformationIsUpToDate = false;\n }\n\n setWidth(width: float): void {\n if (this._width === width) {\n return;\n }\n this._scaleX = width / this._collisionTileMap.getWidth();\n this._width = width;\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this._height === height) {\n return;\n }\n this._scaleY = height / this._collisionTileMap.getHeight();\n this._height = height;\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\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 = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this._scaleX === scaleX) {\n return;\n }\n this._scaleX = scaleX;\n this._width = scaleX * this._collisionTileMap.getWidth();\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this._scaleY === scaleY) {\n return;\n }\n this._scaleY = scaleY;\n this._height = scaleY * this._collisionTileMap.getHeight();\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n getWidth(): float {\n return this._width;\n }\n\n getHeight(): float {\n return this._height;\n }\n\n getScaleX(): float {\n return this._scaleX;\n }\n\n getScaleY(): float {\n return this._scaleY;\n }\n }\n gdjs.registerObject(\n 'TileMap::CollisionMask',\n gdjs.TileMapCollisionMaskRuntimeObject\n );\n TileMapCollisionMaskRuntimeObject.supportsReinitialization = false;\n}\n"],
|
|
5
|
-
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapCollisionMaskObjectDataType = {\n content: {\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n collisionMaskTag: string;\n debugMode: boolean;\n fillColor: string;\n outlineColor: string;\n };\n fillOpacity: float;\n outlineOpacity: float;\n outlineSize: float;\n };\n\n export type TilemapCollisionMaskObjectData = ObjectData &\n TilemapCollisionMaskObjectDataType;\n\n export type TilemapCollisionMaskNetworkSyncDataType = {\n tmjf: string;\n tsjf: string;\n dm: boolean;\n oc: integer;\n fc: integer;\n os: float;\n fo: float;\n oo: float;\n };\n\n export type TilemapCollisionMaskNetworkSyncData = ObjectNetworkSyncData &\n TilemapCollisionMaskNetworkSyncDataType;\n\n /**\n * An object that handle hitboxes for a tile map.\n * @extends gdjs.RuntimeObject\n */\n export class TileMapCollisionMaskRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable\n {\n private _tilemapJsonFile: string;\n private _tilesetJsonFile: string;\n private _renderer: gdjs.TileMap.TileMapCollisionMaskRenderer;\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap;\n /**\n * The tiles are filtered according to this tag.\n *\n * This allows have multiple objects with different usage\n * for the same tile map.\n * For instance, platforms, jumpthru, ladder, spike, water...\n */\n private _collisionMaskTag: string;\n private _layerIndex: integer | null;\n private _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n\n /**\n * When set to true, the hitboxes will be shown.\n */\n _debugMode: boolean;\n _fillColor: integer;\n _outlineColor: integer;\n _fillOpacity: float;\n _outlineOpacity: float;\n _outlineSize: float;\n\n _width: float;\n _height: float;\n _scaleX: float;\n _scaleY: float;\n\n /**\n * If the owner moves, the hitboxes vertices\n * will have to be transformed again.\n */\n private _transformationIsUpToDate: boolean = false;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._collisionMaskTag = objectData.content.collisionMaskTag;\n this._layerIndex =\n objectData.content.useAllLayers ||\n objectData.content.useAllLayers === undefined\n ? null\n : Number.isFinite(objectData.content.layerIndex)\n ? objectData.content.layerIndex\n : 1;\n this._debugMode = objectData.content.debugMode;\n this._fillColor = gdjs.rgbOrHexStringToNumber(\n objectData.content.fillColor\n );\n this._outlineColor = gdjs.rgbOrHexStringToNumber(\n objectData.content.outlineColor\n );\n this._fillOpacity = objectData.content.fillOpacity;\n this._outlineOpacity = objectData.content.outlineOpacity;\n this._outlineSize = objectData.content.outlineSize;\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n\n // The actual size is set when the tile map file is loaded.\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n const editableTileMap = new TileMapHelper.EditableTileMap(\n 1,\n 1,\n 0,\n 0,\n new Map()\n );\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n editableTileMap,\n this._collisionMaskTag,\n this._layerIndex\n );\n\n this._renderer = new gdjs.TileMap.TileMapCollisionMaskRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer) {\n super.updatePreRender(instanceContainer);\n\n if (this._debugMode && this.hitBoxesDirty) {\n this.updateHitBoxes();\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n getVisibilityAABB() {\n return null;\n }\n\n updateFromObjectData(\n oldObjectData: TilemapCollisionMaskObjectData,\n newObjectData: TilemapCollisionMaskObjectData\n ): boolean {\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (oldObjectData.content.debugMode !== newObjectData.content.debugMode) {\n this.setDebugMode(newObjectData.content.debugMode);\n }\n if (oldObjectData.content.fillColor !== newObjectData.content.fillColor) {\n this.setFillColor(\n gdjs.rgbOrHexStringToNumber(newObjectData.content.fillColor)\n );\n }\n if (\n oldObjectData.content.outlineColor !==\n newObjectData.content.outlineColor\n ) {\n this.setOutlineColor(\n gdjs.rgbOrHexStringToNumber(newObjectData.content.outlineColor)\n );\n }\n if (oldObjectData.fillOpacity !== newObjectData.fillOpacity) {\n this.setFillOpacity(newObjectData.fillOpacity);\n }\n if (oldObjectData.outlineOpacity !== newObjectData.outlineOpacity) {\n this.setOutlineOpacity(newObjectData.outlineOpacity);\n }\n if (oldObjectData.outlineSize !== newObjectData.outlineSize) {\n this.setOutlineSize(newObjectData.outlineSize);\n }\n // TODO Handle changes to collisionMaskTag, useAllLayers and layerIndex.\n return true;\n }\n\n getNetworkSyncData(): TilemapCollisionMaskNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n tmjf: this.getTilemapJsonFile(),\n tsjf: this.getTilesetJsonFile(),\n dm: this.getDebugMode(),\n oc: this.getOutlineColor(),\n fc: this.getFillColor(),\n os: this.getOutlineSize(),\n fo: this.getFillOpacity(),\n oo: this.getOutlineOpacity(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TilemapCollisionMaskNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.dm !== undefined) {\n this.setDebugMode(networkSyncData.dm);\n }\n if (networkSyncData.oc !== undefined) {\n this.setOutlineColor(networkSyncData.oc);\n }\n if (networkSyncData.fc !== undefined) {\n this.setFillColor(networkSyncData.fc);\n }\n if (networkSyncData.os !== undefined) {\n this.setOutlineSize(networkSyncData.os);\n }\n if (networkSyncData.fo !== undefined) {\n this.setFillOpacity(networkSyncData.fo);\n }\n if (networkSyncData.oo !== undefined) {\n this.setOutlineOpacity(networkSyncData.oo);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n 0, // levelIndex\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already log errors.\n return;\n }\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._collisionMaskTag,\n this._layerIndex\n );\n // The tile map polygons always keep the same references.\n // It works because the tilemap is never modified.\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._collisionMaskTag)\n );\n this._renderer.redrawCollisionMask();\n\n this._width = this._collisionTileMap.getWidth() * this._scaleX;\n this._height = this._collisionTileMap.getHeight() * this._scaleY;\n }\n );\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n // Update the RuntimeObject hitboxes attribute.\n for (const _ of this._collisionTileMap.getAllHitboxes(\n this._collisionMaskTag\n )) {\n // RuntimeObject.hitBoxes contains the same polygons instances as the\n // hitboxes from the tiles.\n //\n // When hitboxes for a tile is asked to the model, they are updated\n // according to the new object location if needed.\n // Iterating over all the tiles forces them to update their hitboxes.\n //\n // The hitboxes array is built by _updateTileMap().\n }\n this.hitBoxesDirty = false;\n this._renderer.redrawCollisionMask();\n this.updateAABB();\n }\n\n /**\n * Update the affine transformation according to the object position, size\n * and angle.\n */\n updateTransformation(): void {\n if (this._transformationIsUpToDate) {\n return;\n }\n const transformation = this._collisionTileMap.getTransformation();\n\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n\n transformation.setToIdentity();\n\n // Translation\n transformation.translate(this.x, this.y);\n\n // Rotation\n const angleInRadians = (this.angle * Math.PI) / 180;\n transformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n transformation.scale(absScaleX, absScaleY);\n\n this._collisionTileMap.setTransformation(transformation);\n\n this._transformationIsUpToDate = true;\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n getHitBoxesAround(left: float, top: float, right: float, bottom: float) {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n return this._collisionTileMap.getHitboxesAround(\n this._collisionMaskTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n /**\n * insideObject usually use the AABB of the object.\n * But, in case of a tile map, it makes more sense to look each tile individually.\n * It returns true when there is an hitbox in the tile.\n */\n insideObject(x: float, y: float): boolean {\n this.updateTransformation();\n // This is more precise than the default implementation.\n return this._collisionTileMap.pointIsInsideTile(\n x,\n y,\n this._collisionMaskTag\n );\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n /**\n * Set the Tilemap json file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string) {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n /**\n * @returns true if the hitboxes are shown.\n */\n getDebugMode(): boolean {\n return this._debugMode;\n }\n\n /**\n * @returns true if the hitboxes are shown.\n */\n setDebugMode(debugMode: boolean): void {\n this._debugMode = debugMode;\n this._renderer.redrawCollisionMask();\n }\n\n getFillColor(): integer {\n return this._fillColor;\n }\n\n getOutlineColor(): integer {\n return this._outlineColor;\n }\n\n setFillColor(fillColor: integer): void {\n this._fillColor = fillColor;\n }\n\n setOutlineColor(outlineColor: integer): void {\n this._outlineColor = outlineColor;\n }\n\n setOutlineSize(size: float): void {\n this._outlineSize = size;\n }\n\n getOutlineSize(): float {\n return this._outlineSize;\n }\n\n /**\n *\n * @param opacity from 0 to 255\n */\n setFillOpacity(opacity: float): void {\n this._fillOpacity = opacity;\n }\n\n /**\n *\n * @returns an opacity value from 0 to 255.\n */\n getFillOpacity(): float {\n return this._fillOpacity;\n }\n\n /**\n *\n * @param opacity from 0 to 255\n */\n setOutlineOpacity(opacity: float): void {\n this._outlineOpacity = opacity;\n }\n\n /**\n *\n * @returns an opacity value from 0 to 255.\n */\n getOutlineOpacity(): float {\n return this._outlineOpacity;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._transformationIsUpToDate = false;\n }\n\n setWidth(width: float): void {\n if (this._width === width) {\n return;\n }\n this._scaleX = width / this._collisionTileMap.getWidth();\n this._width = width;\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this._height === height) {\n return;\n }\n this._scaleY = height / this._collisionTileMap.getHeight();\n this._height = height;\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\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 = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this._scaleX === scaleX) {\n return;\n }\n this._scaleX = scaleX;\n this._width = scaleX * this._collisionTileMap.getWidth();\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this._scaleY === scaleY) {\n return;\n }\n this._scaleY = scaleY;\n this._height = scaleY * this._collisionTileMap.getHeight();\n this._transformationIsUpToDate = false;\n this.invalidateHitboxes();\n }\n\n getWidth(): float {\n return this._width;\n }\n\n getHeight(): float {\n return this._height;\n }\n\n getScaleX(): float {\n return this._scaleX;\n }\n\n getScaleY(): float {\n return this._scaleY;\n }\n }\n gdjs.registerObject(\n 'TileMap::CollisionMask',\n gdjs.TileMapCollisionMaskRuntimeObject\n );\n TileMapCollisionMaskRuntimeObject.supportsReinitialization = false;\n}\n"],
|
|
5
|
+
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CAoCS,eACG,GAAK,aAEf,CAqCE,YAAY,EAAkD,EAAY,CACxE,MAAM,EAAmB,GAHnB,+BAAqC,GAI3C,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,kB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|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(i){class l extends i.RuntimeObject{constructor(e,t){super(e,t);this._frameElapsedTime=0;this._opacity=t.content.opacity,this._tilemapJsonFile=t.content.tilemapJsonFile,this._tilesetJsonFile=t.content.tilesetJsonFile,this._tilemapAtlasImage=t.content.tilemapAtlasImage,this._displayMode=t.content.displayMode,this._layerIndex=t.content.layerIndex,this._levelIndex=t.content.levelIndex,this._animationSpeedScale=t.content.animationSpeedScale,this._animationFps=t.content.animationFps,this._tileMapManager=i.TileMap.TileMapRuntimeManager.getManager(e),this._renderer=new i.TileMapRuntimeObjectRenderer(this,e),this._updateTileMap(),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}update(e){if(this._animationSpeedScale<=0||this._animationFps===0)return;const t=this.getElapsedTime()/1e3;for(this._frameElapsedTime+=t*this._animationSpeedScale;this._frameElapsedTime>1/this._animationFps;)this._renderer.incrementAnimationFrameX(e),this._frameElapsedTime-=1/this._animationFps}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.tilemapJsonFile!==t.content.tilemapJsonFile&&this.setTilemapJsonFile(t.content.tilemapJsonFile),e.content.tilesetJsonFile!==t.content.tilesetJsonFile&&this.setTilesetJsonFile(t.content.tilesetJsonFile),e.content.displayMode!==t.content.displayMode&&this.setDisplayMode(t.content.displayMode),e.content.layerIndex!==t.content.layerIndex&&this.setLayerIndex(t.content.layerIndex),e.content.levelIndex!==t.content.levelIndex&&this.setLevelIndex(t.content.levelIndex),e.content.animationSpeedScale!==t.content.animationSpeedScale&&this.setAnimationSpeedScale(t.content.animationSpeedScale),e.content.animationFps!==t.content.animationFps&&this.setAnimationFps(t.content.animationFps),e.content.tilemapAtlasImage===t.content.tilemapAtlasImage}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,tmjf:this._tilemapJsonFile,tsjf:this._tilesetJsonFile,tmai:this._tilemapAtlasImage,dm:this._displayMode,lai:this._layerIndex,lei:this._levelIndex,asps:this._animationSpeedScale}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.op!==void 0&&this.setOpacity(e.op),e.tmjf!==void 0&&this.setTilemapJsonFile(e.tmjf),e.tsjf!==void 0&&this.setTilesetJsonFile(e.tsjf),e.tmai!==void 0&&(this._tilemapAtlasImage=e.tmai),e.dm!==void 0&&this.setDisplayMode(e.dm),e.lai!==void 0&&this.setLayerIndex(e.lai),e.lei!==void 0&&this.setLevelIndex(e.lei),e.asps!==void 0&&this.setAnimationSpeedScale(e.asps)}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity)}_updateTileMap(){this._tileMapManager.getOrLoadTileMap(this._tilemapJsonFile,this._tilesetJsonFile,this._levelIndex,e=>{!e||this._tileMapManager.getOrLoadTextureCache(t=>{const s=this.getInstanceContainer().getGame(),n=s.resolveEmbeddedResource(this._tilemapJsonFile,t);return s.getImageManager().getPIXITexture(n)},this._tilemapAtlasImage,this._tilemapJsonFile,this._tilesetJsonFile,this._levelIndex,t=>{!t||this._renderer.updatePixiTileMap(e,t)})})}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setTilemapJsonFile(e){this._tilemapJsonFile=e,this._updateTileMap()}getTilemapJsonFile(){return this._tilemapJsonFile}isTilemapJsonFile(e){return this._tilemapJsonFile===e}setTilesetJsonFile(e){this._tilesetJsonFile=e,this._updateTileMap()}getTilesetJsonFile(){return this._tilesetJsonFile}setAnimationFps(e){this._animationFps=e}getAnimationFps(){return this._animationFps}isTilesetJsonFile(e){return this._tilesetJsonFile===e}isDisplayMode(e){return this._displayMode===e}setDisplayMode(e){this._displayMode=e,this._updateTileMap()}getDisplayMode(){return this._displayMode}setLayerIndex(e){this._layerIndex=e,this._updateTileMap()}getLayerIndex(){return this._layerIndex}setLevelIndex(e){this._levelIndex=e,this._updateTileMap()}getLevelIndex(){return this._levelIndex}setAnimationSpeedScale(e){this._animationSpeedScale=e}getAnimationSpeedScale(){return this._animationSpeedScale}setWidth(e){this.getWidth()!==e&&(this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this.getHeight()!==e&&(this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t)}getScale(){const e=this.getScaleX(),t=this.getScaleY();return e===t?e:Math.sqrt(e*t)}setScale(e){this.setScaleX(e),this.setScaleY(e)}setScaleX(e){e<0&&(e=0),this.getScaleX()!==e&&(this._renderer.setScaleX(e),this.invalidateHitboxes())}setScaleY(e){e<0&&(e=0),this.getScaleY()!==e&&(this._renderer.setScaleY(e),this.invalidateHitboxes())}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=e,this._renderer.updateOpacity()}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleX(){return this._renderer.getScaleX()}getScaleY(){return this._renderer.getScaleY()}}i.TileMapRuntimeObject=l,i.registerObject("TileMap::TileMap",i.TileMapRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=tilemapruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TileMap/tilemapruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapObjectDataType = {\n content: {\n opacity: number;\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n tilemapAtlasImage: string;\n displayMode: string;\n layerIndex: integer;\n levelIndex: integer;\n animationSpeedScale: number;\n animationFps: number;\n };\n };\n\n export type TilemapObjectData = ObjectData & TilemapObjectDataType;\n\n export type TilemapNetworkSyncDataType = {\n op: number;\n tmjf: string;\n tsjf: string;\n tmai: string;\n dm: string;\n lai: number;\n lei: number;\n asps: number;\n wid: number;\n hei: number;\n };\n\n export type TilemapNetworkSyncData = ObjectNetworkSyncData &\n TilemapNetworkSyncDataType;\n\n /**\n * Displays a Tilemap object (LDtk and Tiled).\n */\n export class TileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler\n {\n _frameElapsedTime: float = 0;\n _opacity: float;\n _tilemapJsonFile: string;\n _tilesetJsonFile: string;\n _tilemapAtlasImage: string;\n _displayMode: string;\n _layerIndex: integer;\n _levelIndex: integer;\n _animationSpeedScale: number;\n _animationFps: number;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._tilemapAtlasImage = objectData.content.tilemapAtlasImage;\n this._displayMode = objectData.content.displayMode;\n this._layerIndex = objectData.content.layerIndex;\n this._levelIndex = objectData.content.levelIndex;\n this._animationSpeedScale = objectData.content.animationSpeedScale;\n this._animationFps = objectData.content.animationFps;\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationSpeedScale <= 0 || this._animationFps === 0) {\n return;\n }\n const elapsedTime = this.getElapsedTime() / 1000;\n this._frameElapsedTime += elapsedTime * this._animationSpeedScale;\n while (this._frameElapsedTime > 1 / this._animationFps) {\n this._renderer.incrementAnimationFrameX(instanceContainer);\n this._frameElapsedTime -= 1 / this._animationFps;\n }\n }\n\n updateFromObjectData(\n oldObjectData: TilemapObjectData,\n newObjectData: TilemapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (\n oldObjectData.content.displayMode !== newObjectData.content.displayMode\n ) {\n this.setDisplayMode(newObjectData.content.displayMode);\n }\n if (\n oldObjectData.content.layerIndex !== newObjectData.content.layerIndex\n ) {\n this.setLayerIndex(newObjectData.content.layerIndex);\n }\n if (\n oldObjectData.content.levelIndex !== newObjectData.content.levelIndex\n ) {\n this.setLevelIndex(newObjectData.content.levelIndex);\n }\n if (\n oldObjectData.content.animationSpeedScale !==\n newObjectData.content.animationSpeedScale\n ) {\n this.setAnimationSpeedScale(newObjectData.content.animationSpeedScale);\n }\n if (\n oldObjectData.content.animationFps !==\n newObjectData.content.animationFps\n ) {\n this.setAnimationFps(newObjectData.content.animationFps);\n }\n if (\n oldObjectData.content.tilemapAtlasImage !==\n newObjectData.content.tilemapAtlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): TilemapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n tmjf: this._tilemapJsonFile,\n tsjf: this._tilesetJsonFile,\n tmai: this._tilemapAtlasImage,\n dm: this._displayMode,\n lai: this._layerIndex,\n lei: this._levelIndex,\n asps: this._animationSpeedScale,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: TilemapNetworkSyncData): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.tmai !== undefined) {\n this._tilemapAtlasImage = networkSyncData.tmai;\n }\n if (networkSyncData.dm !== undefined) {\n this.setDisplayMode(networkSyncData.dm);\n }\n if (networkSyncData.lai !== undefined) {\n this.setLayerIndex(networkSyncData.lai);\n }\n if (networkSyncData.lei !== undefined) {\n this.setLevelIndex(networkSyncData.lei);\n }\n if (networkSyncData.asps !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.asps);\n }\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\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 }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already warn.\n return;\n }\n this._tileMapManager.getOrLoadTextureCache(\n (textureName) => {\n const game = this.getInstanceContainer().getGame();\n const mappedName = game.resolveEmbeddedResource(\n this._tilemapJsonFile,\n textureName\n );\n return game\n .getImageManager()\n .getPIXITexture(\n mappedName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._tilemapAtlasImage,\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the Tilemap file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string): void {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n setAnimationFps(animationFps: float) {\n this._animationFps = animationFps;\n }\n\n getAnimationFps(): float {\n return this._animationFps;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n isDisplayMode(selectedDisplayMode: string): boolean {\n return this._displayMode === selectedDisplayMode;\n }\n\n setDisplayMode(displayMode: string): void {\n this._displayMode = displayMode;\n this._updateTileMap();\n }\n\n getDisplayMode(): string {\n return this._displayMode;\n }\n\n setLayerIndex(layerIndex): void {\n this._layerIndex = layerIndex;\n this._updateTileMap();\n }\n\n getLayerIndex(): integer {\n return this._layerIndex;\n }\n\n setLevelIndex(levelIndex): void {\n this._levelIndex = levelIndex;\n this._updateTileMap();\n }\n\n getLevelIndex() {\n return this._levelIndex;\n }\n\n setAnimationSpeedScale(animationSpeedScale): void {\n this._animationSpeedScale = animationSpeedScale;\n }\n\n getAnimationSpeedScale(): float {\n return this._animationSpeedScale;\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\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 = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n }\n gdjs.registerObject('TileMap::TileMap', gdjs.TileMapRuntimeObject);\n}\n"],
|
|
5
|
-
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapObjectDataType = {\n content: {\n opacity: number;\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n tilemapAtlasImage: string;\n displayMode: string;\n layerIndex: integer;\n levelIndex: integer;\n animationSpeedScale: number;\n animationFps: number;\n };\n };\n\n export type TilemapObjectData = ObjectData & TilemapObjectDataType;\n\n export type TilemapNetworkSyncDataType = {\n op: number;\n tmjf: string;\n tsjf: string;\n tmai: string;\n dm: string;\n lai: number;\n lei: number;\n asps: number;\n };\n\n export type TilemapNetworkSyncData = ObjectNetworkSyncData &\n TilemapNetworkSyncDataType;\n\n /**\n * Displays a Tilemap object (LDtk and Tiled).\n */\n export class TileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler\n {\n _frameElapsedTime: float = 0;\n _opacity: float;\n _tilemapJsonFile: string;\n _tilesetJsonFile: string;\n _tilemapAtlasImage: string;\n _displayMode: string;\n _layerIndex: integer;\n _levelIndex: integer;\n _animationSpeedScale: number;\n _animationFps: number;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._tilemapAtlasImage = objectData.content.tilemapAtlasImage;\n this._displayMode = objectData.content.displayMode;\n this._layerIndex = objectData.content.layerIndex;\n this._levelIndex = objectData.content.levelIndex;\n this._animationSpeedScale = objectData.content.animationSpeedScale;\n this._animationFps = objectData.content.animationFps;\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationSpeedScale <= 0 || this._animationFps === 0) {\n return;\n }\n const elapsedTime = this.getElapsedTime() / 1000;\n this._frameElapsedTime += elapsedTime * this._animationSpeedScale;\n while (this._frameElapsedTime > 1 / this._animationFps) {\n this._renderer.incrementAnimationFrameX(instanceContainer);\n this._frameElapsedTime -= 1 / this._animationFps;\n }\n }\n\n updateFromObjectData(\n oldObjectData: TilemapObjectData,\n newObjectData: TilemapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (\n oldObjectData.content.displayMode !== newObjectData.content.displayMode\n ) {\n this.setDisplayMode(newObjectData.content.displayMode);\n }\n if (\n oldObjectData.content.layerIndex !== newObjectData.content.layerIndex\n ) {\n this.setLayerIndex(newObjectData.content.layerIndex);\n }\n if (\n oldObjectData.content.levelIndex !== newObjectData.content.levelIndex\n ) {\n this.setLevelIndex(newObjectData.content.levelIndex);\n }\n if (\n oldObjectData.content.animationSpeedScale !==\n newObjectData.content.animationSpeedScale\n ) {\n this.setAnimationSpeedScale(newObjectData.content.animationSpeedScale);\n }\n if (\n oldObjectData.content.animationFps !==\n newObjectData.content.animationFps\n ) {\n this.setAnimationFps(newObjectData.content.animationFps);\n }\n if (\n oldObjectData.content.tilemapAtlasImage !==\n newObjectData.content.tilemapAtlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): TilemapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n tmjf: this._tilemapJsonFile,\n tsjf: this._tilesetJsonFile,\n tmai: this._tilemapAtlasImage,\n dm: this._displayMode,\n lai: this._layerIndex,\n lei: this._levelIndex,\n asps: this._animationSpeedScale,\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: TilemapNetworkSyncData): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.tmai !== undefined) {\n this._tilemapAtlasImage = networkSyncData.tmai;\n }\n if (networkSyncData.dm !== undefined) {\n this.setDisplayMode(networkSyncData.dm);\n }\n if (networkSyncData.lai !== undefined) {\n this.setLayerIndex(networkSyncData.lai);\n }\n if (networkSyncData.lei !== undefined) {\n this.setLevelIndex(networkSyncData.lei);\n }\n if (networkSyncData.asps !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.asps);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\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 }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already warn.\n return;\n }\n this._tileMapManager.getOrLoadTextureCache(\n (textureName) => {\n const game = this.getInstanceContainer().getGame();\n const mappedName = game.resolveEmbeddedResource(\n this._tilemapJsonFile,\n textureName\n );\n return game\n .getImageManager()\n .getPIXITexture(\n mappedName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._tilemapAtlasImage,\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the Tilemap file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string): void {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n setAnimationFps(animationFps: float) {\n this._animationFps = animationFps;\n }\n\n getAnimationFps(): float {\n return this._animationFps;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n isDisplayMode(selectedDisplayMode: string): boolean {\n return this._displayMode === selectedDisplayMode;\n }\n\n setDisplayMode(displayMode: string): void {\n this._displayMode = displayMode;\n this._updateTileMap();\n }\n\n getDisplayMode(): string {\n return this._displayMode;\n }\n\n setLayerIndex(layerIndex): void {\n this._layerIndex = layerIndex;\n this._updateTileMap();\n }\n\n getLayerIndex(): integer {\n return this._layerIndex;\n }\n\n setLevelIndex(levelIndex): void {\n this._levelIndex = levelIndex;\n this._updateTileMap();\n }\n\n getLevelIndex() {\n return this._levelIndex;\n }\n\n setAnimationSpeedScale(animationSpeedScale): void {\n this._animationSpeedScale = animationSpeedScale;\n }\n\n getAnimationSpeedScale(): float {\n return this._animationSpeedScale;\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\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 = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n }\n gdjs.registerObject('TileMap::TileMap', gdjs.TileMapRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CAkCS,eACG,GAAK,aAEf,CAcE,YAAY,EAAkD,EAAY,CACxE,MAAM,EAAmB,GAd3B,uBAA2B,EAezB,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,mBAAqB,EAAW,QAAQ,kBAC7C,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,qBAAuB,EAAW,QAAQ,oBAC/C,KAAK,cAAgB,EAAW,QAAQ,aACxC,KAAK,gBACH,EAAK,QAAQ,sBAAsB,WAAW,GAChD,KAAK,UAAY,GAAI,GAAK,6BACxB,KACA,GAEF,KAAK,iBAGL,KAAK,YAGP,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,OAAO,EAAwD,CAC7D,GAAI,KAAK,sBAAwB,GAAK,KAAK,gBAAkB,EAC3D,OAEF,KAAM,GAAc,KAAK,iBAAmB,IAE5C,IADA,KAAK,mBAAqB,EAAc,KAAK,qBACtC,KAAK,kBAAoB,EAAI,KAAK,eACvC,KAAK,UAAU,yBAAyB,GACxC,KAAK,mBAAqB,EAAI,KAAK,cAIvC,qBACE,EACA,EACS,CA2CT,MA1CI,GAAc,QAAQ,UAAY,EAAc,QAAQ,SAC1D,KAAK,WAAW,EAAc,QAAQ,SAGtC,EAAc,QAAQ,kBACtB,EAAc,QAAQ,iBAEtB,KAAK,mBAAmB,EAAc,QAAQ,iBAG9C,EAAc,QAAQ,kBACtB,EAAc,QAAQ,iBAEtB,KAAK,mB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AAU,GACzB,KAAK,sBAGP,QAAQ,EAAiB,EAAwB,CAC/C,KAAK,SAAS,GACd,KAAK,UAAU,GAQjB,UAAkB,CAChB,KAAM,GAAS,KAAK,YACd,EAAS,KAAK,YACpB,MAAO,KAAW,EAAS,EAAS,KAAK,KAAK,EAAS,GAQzD,SAAS,EAAoB,CAC3B,KAAK,UAAU,GACf,KAAK,UAAU,GAQjB,UAAU,EAAqB,CAI7B,AAHI,EAAS,GACX,GAAS,GAEP,KAAK,cAAgB,GAEzB,MAAK,UAAU,UAAU,GACzB,KAAK,sBAQP,UAAU,EAAqB,CAI7B,AAHI,EAAS,GACX,GAAS,GAEP,KAAK,cAAgB,GAEzB,MAAK,UAAU,UAAU,GACzB,KAAK,sBAGP,KAAK,EAAgB,CACnB,MAAM,KAAK,GACX,KAAK,UAAU,iBAGjB,KAAK,EAAgB,CACnB,MAAM,KAAK,GACX,KAAK,UAAU,iBAGjB,SAAS,EAAoB,CAC3B,MAAM,SAAS,GACf,KAAK,UAAU,cAGjB,WAAW,EAAsB,CAC/B,KAAK,SAAW,EAChB,KAAK,UAAU,gBAGjB,YAAoB,CAClB,MAAO,MAAK,SAGd,UAAkB,CAChB,MAAO,MAAK,UAAU,WAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,YAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,YAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,aAxYnB,EAAM,uBA2Yb,EAAK,eAAe,mBAAoB,EAAK,wBA7arC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(e,t){super(e,t);this._xOffset=0;this._yOffset=0;this.opacity=255;this._renderer=new i.TiledSpriteRuntimeObjectRenderer(this,e,t.texture),this._width=0,this._height=0,this.setWidth(t.width),this.setHeight(t.height),this.onCreated()}updateFromObjectData(e,t){return e.texture!==t.texture&&this.setTexture(t.texture,this.getRuntimeScene()),e.width!==t.width&&this.setWidth(t.width),e.height!==t.height&&this.setHeight(t.height),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),
|
|
1
|
+
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(e,t){super(e,t);this._xOffset=0;this._yOffset=0;this.opacity=255;this._renderer=new i.TiledSpriteRuntimeObjectRenderer(this,e,t.texture),this._width=0,this._height=0,this.setWidth(t.width),this.setHeight(t.height),this.onCreated()}updateFromObjectData(e,t){return e.texture!==t.texture&&this.setTexture(t.texture,this.getRuntimeScene()),e.width!==t.width&&this.setWidth(t.width),e.height!==t.height&&this.setHeight(t.height),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),xo:this.getXOffset(),yo:this.getYOffset(),op:this.getOpacity(),color:this.getColor()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.xo!==void 0&&this.setXOffset(e.xo),e.yo!==void 0&&this.setYOffset(e.yo),e.op!==void 0&&this.setOpacity(e.op),e.color!==void 0&&this.setColor(e.color)}getRendererObject(){return this._renderer.getRendererObject()}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity)}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setTexture(e,t){this._renderer.setTexture(e,t)}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}getWidth(){return this._width}getHeight(){return this._height}setWidth(e){this._width!==e&&(this._width=e,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._height!==e&&(this._height=e,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t)}setXOffset(e){this._xOffset=e,this._renderer.updateXOffset()}setYOffset(e){this._yOffset=e,this._renderer.updateYOffset()}getXOffset(){return this._xOffset}getYOffset(){return this._yOffset}setOpacity(e){e<0&&(e=0),e>255&&(e=255),this.opacity=e,this._renderer.updateOpacity()}getOpacity(){return this.opacity}setColor(e){this._renderer.setColor(e)}getColor(){return this._renderer.getColor()}getScale(){const e=Math.abs(this.getScaleX()),t=Math.abs(this.getScaleY());return e===t?e:Math.sqrt(e*t)}getScaleX(){return this._width/this._renderer.getTextureWidth()}getScaleY(){return this._height/this._renderer.getTextureHeight()}setScale(e){this.setWidth(this._renderer.getTextureWidth()*e),this.setHeight(this._renderer.getTextureHeight()*e)}setScaleX(e){this.setWidth(this._renderer.getTextureWidth()*e)}setScaleY(e){this.setHeight(this._renderer.getTextureHeight()*e)}}i.TiledSpriteRuntimeObject=r,i.registerObject("TiledSpriteObject::TiledSprite",i.TiledSpriteRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=tiledspriteruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TiledSpriteObject/tiledspriteruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * 2013 Florian Rival (Florian.Rival@gmail.com)\n */\nnamespace gdjs {\n /** Initial properties for a Tiled Sprite object */\n export type TiledSpriteObjectDataType = {\n /** Default width of the object, if the instance has no custom width. */\n width: number;\n /** Default height of the object, if the instance has no custom height. */\n height: number;\n texture: string;\n };\n\n export type TiledSpriteObjectData = ObjectData & TiledSpriteObjectDataType;\n\n export type TiledSpriteNetworkSyncDataType = {\n wid: number;\n hei: number;\n xo: number;\n yo: number;\n op: number;\n color: string;\n };\n\n export type TiledSpriteNetworkSyncData = ObjectNetworkSyncData &\n TiledSpriteNetworkSyncDataType;\n\n /**\n * The TiledSpriteRuntimeObject displays a tiled texture.\n */\n export class TiledSpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.OpacityHandler\n {\n _xOffset: float = 0;\n _yOffset: float = 0;\n opacity: float = 255;\n\n // Width and height can be stored because they do not depend on the\n // size of the texture being used (contrary to most objects).\n _width: float;\n _height: float;\n\n _renderer: gdjs.TiledSpriteRuntimeObjectRenderer;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param tiledSpriteObjectData The initial properties of the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n tiledSpriteObjectData: TiledSpriteObjectData\n ) {\n super(instanceContainer, tiledSpriteObjectData);\n this._renderer = new gdjs.TiledSpriteRuntimeObjectRenderer(\n this,\n instanceContainer,\n tiledSpriteObjectData.texture\n );\n this._width = 0;\n this._height = 0;\n this.setWidth(tiledSpriteObjectData.width);\n this.setHeight(tiledSpriteObjectData.height);\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updateFromObjectData(oldObjectData, newObjectData): boolean {\n if (oldObjectData.texture !== newObjectData.texture) {\n this.setTexture(newObjectData.texture, this.getRuntimeScene());\n }\n if (oldObjectData.width !== newObjectData.width) {\n this.setWidth(newObjectData.width);\n }\n if (oldObjectData.height !== newObjectData.height) {\n this.setHeight(newObjectData.height);\n }\n return true;\n }\n\n getNetworkSyncData(): TiledSpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n wid: this.getWidth(),\n hei: this.getHeight(),\n xo: this.getXOffset(),\n yo: this.getYOffset(),\n op: this.getOpacity(),\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TiledSpriteNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n // Texture is not synchronized, see if this is asked or not.\n\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.xo !== undefined) {\n this.setXOffset(networkSyncData.xo);\n }\n if (networkSyncData.yo !== undefined) {\n this.setYOffset(networkSyncData.yo);\n }\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.color !== undefined) {\n this.setColor(networkSyncData.color);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\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 }\n\n /**\n * Set the X position of the Tiled Sprite object.\n * @param x The new X position.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the Y position of the Tiled Sprite object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Assign a new texture to the Tiled Sprite object.\n * @param textureName The name of the image texture resource.\n * @param instanceContainer The container in which the texture is used.\n */\n setTexture(\n textureName: string,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): void {\n this._renderer.setTexture(textureName, instanceContainer);\n }\n\n /**\n * Set the angle of the Tiled Sprite object.\n * @param angle The new angle.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Get the width of the Tiled Sprite object.\n * @returns The width of the Tiled Sprite object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Get the height of the Tiled Sprite object.\n * @returns The height of the Tiled Sprite object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Set the width of the Tiled Sprite object.\n * @param width The new width.\n */\n setWidth(width: float): void {\n if (this._width === width) return;\n\n this._width = width;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the Tiled Sprite object.\n * @param height The new height.\n */\n setHeight(height: float): void {\n if (this._height === height) return;\n\n this._height = height;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the size of the Tiled Sprite object.\n * @param width The new width.\n * @param height The new height.\n */\n setSize(width: float, height: float): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n /**\n * Set the offset on the X-axis when displaying the image of the Tiled Sprite object.\n * @param xOffset The new offset on the X-axis.\n */\n setXOffset(xOffset: number): void {\n this._xOffset = xOffset;\n this._renderer.updateXOffset();\n }\n\n /**\n * Set the offset on the Y-axis when displaying the image of the Tiled Sprite object.\n * @param yOffset The new offset on the Y-axis.\n */\n setYOffset(yOffset: number): void {\n this._yOffset = yOffset;\n this._renderer.updateYOffset();\n }\n\n /**\n * Get the offset on the X-axis of the Tiled Sprite object.\n * @returns The offset on the X-axis\n */\n getXOffset(): number {\n return this._xOffset;\n }\n\n /**\n * Get the offset on the Y-axis of the Tiled Sprite object.\n * @returns The offset on the Y-axis\n */\n getYOffset(): number {\n return this._yOffset;\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(): number {\n return this.opacity;\n }\n\n /**\n * Change the tint of the tiled 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 tiled 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 // Implement support for get/set scale:\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.getScaleX());\n const scaleY = Math.abs(this.getScaleY());\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get x-scale of the tiled sprite object.\n */\n getScaleX(): float {\n return this._width / this._renderer.getTextureWidth();\n }\n\n /**\n * Get y-scale of the tiled sprite object.\n */\n getScaleY(): float {\n return this._height / this._renderer.getTextureHeight();\n }\n\n /**\n * Set the tiled sprite object scale.\n * @param newScale The new scale for the tiled sprite object.\n */\n setScale(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n\n /**\n * Set the tiled sprite object x-scale.\n * @param newScale The new x-scale for the tiled sprite object.\n */\n setScaleX(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n }\n\n /**\n * Set the tiled sprite object y-scale.\n * @param newScale The new y-scale for the tiled sprite object.\n */\n setScaleY(newScale: float): void {\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n }\n gdjs.registerObject(\n 'TiledSpriteObject::TiledSprite',\n gdjs.TiledSpriteRuntimeObject\n );\n}\n"],
|
|
5
|
-
"mappings": "AAIA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * 2013 Florian Rival (Florian.Rival@gmail.com)\n */\nnamespace gdjs {\n /** Initial properties for a Tiled Sprite object */\n export type TiledSpriteObjectDataType = {\n /** Default width of the object, if the instance has no custom width. */\n width: number;\n /** Default height of the object, if the instance has no custom height. */\n height: number;\n texture: string;\n };\n\n export type TiledSpriteObjectData = ObjectData & TiledSpriteObjectDataType;\n\n export type TiledSpriteNetworkSyncDataType = {\n xo: number;\n yo: number;\n op: number;\n color: string;\n };\n\n export type TiledSpriteNetworkSyncData = ObjectNetworkSyncData &\n TiledSpriteNetworkSyncDataType;\n\n /**\n * The TiledSpriteRuntimeObject displays a tiled texture.\n */\n export class TiledSpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.OpacityHandler\n {\n _xOffset: float = 0;\n _yOffset: float = 0;\n opacity: float = 255;\n\n // Width and height can be stored because they do not depend on the\n // size of the texture being used (contrary to most objects).\n _width: float;\n _height: float;\n\n _renderer: gdjs.TiledSpriteRuntimeObjectRenderer;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param tiledSpriteObjectData The initial properties of the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n tiledSpriteObjectData: TiledSpriteObjectData\n ) {\n super(instanceContainer, tiledSpriteObjectData);\n this._renderer = new gdjs.TiledSpriteRuntimeObjectRenderer(\n this,\n instanceContainer,\n tiledSpriteObjectData.texture\n );\n this._width = 0;\n this._height = 0;\n this.setWidth(tiledSpriteObjectData.width);\n this.setHeight(tiledSpriteObjectData.height);\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updateFromObjectData(oldObjectData, newObjectData): boolean {\n if (oldObjectData.texture !== newObjectData.texture) {\n this.setTexture(newObjectData.texture, this.getRuntimeScene());\n }\n if (oldObjectData.width !== newObjectData.width) {\n this.setWidth(newObjectData.width);\n }\n if (oldObjectData.height !== newObjectData.height) {\n this.setHeight(newObjectData.height);\n }\n return true;\n }\n\n getNetworkSyncData(): TiledSpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n xo: this.getXOffset(),\n yo: this.getYOffset(),\n op: this.getOpacity(),\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TiledSpriteNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n // Texture is not synchronized, see if this is asked or not.\n\n if (networkSyncData.xo !== undefined) {\n this.setXOffset(networkSyncData.xo);\n }\n if (networkSyncData.yo !== undefined) {\n this.setYOffset(networkSyncData.yo);\n }\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.color !== undefined) {\n this.setColor(networkSyncData.color);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\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 }\n\n /**\n * Set the X position of the Tiled Sprite object.\n * @param x The new X position.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the Y position of the Tiled Sprite object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Assign a new texture to the Tiled Sprite object.\n * @param textureName The name of the image texture resource.\n * @param instanceContainer The container in which the texture is used.\n */\n setTexture(\n textureName: string,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): void {\n this._renderer.setTexture(textureName, instanceContainer);\n }\n\n /**\n * Set the angle of the Tiled Sprite object.\n * @param angle The new angle.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Get the width of the Tiled Sprite object.\n * @returns The width of the Tiled Sprite object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Get the height of the Tiled Sprite object.\n * @returns The height of the Tiled Sprite object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Set the width of the Tiled Sprite object.\n * @param width The new width.\n */\n setWidth(width: float): void {\n if (this._width === width) return;\n\n this._width = width;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the Tiled Sprite object.\n * @param height The new height.\n */\n setHeight(height: float): void {\n if (this._height === height) return;\n\n this._height = height;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the size of the Tiled Sprite object.\n * @param width The new width.\n * @param height The new height.\n */\n setSize(width: float, height: float): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n /**\n * Set the offset on the X-axis when displaying the image of the Tiled Sprite object.\n * @param xOffset The new offset on the X-axis.\n */\n setXOffset(xOffset: number): void {\n this._xOffset = xOffset;\n this._renderer.updateXOffset();\n }\n\n /**\n * Set the offset on the Y-axis when displaying the image of the Tiled Sprite object.\n * @param yOffset The new offset on the Y-axis.\n */\n setYOffset(yOffset: number): void {\n this._yOffset = yOffset;\n this._renderer.updateYOffset();\n }\n\n /**\n * Get the offset on the X-axis of the Tiled Sprite object.\n * @returns The offset on the X-axis\n */\n getXOffset(): number {\n return this._xOffset;\n }\n\n /**\n * Get the offset on the Y-axis of the Tiled Sprite object.\n * @returns The offset on the Y-axis\n */\n getYOffset(): number {\n return this._yOffset;\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(): number {\n return this.opacity;\n }\n\n /**\n * Change the tint of the tiled 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 tiled 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 // Implement support for get/set scale:\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.getScaleX());\n const scaleY = Math.abs(this.getScaleY());\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get x-scale of the tiled sprite object.\n */\n getScaleX(): float {\n return this._width / this._renderer.getTextureWidth();\n }\n\n /**\n * Get y-scale of the tiled sprite object.\n */\n getScaleY(): float {\n return this._height / this._renderer.getTextureHeight();\n }\n\n /**\n * Set the tiled sprite object scale.\n * @param newScale The new scale for the tiled sprite object.\n */\n setScale(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n\n /**\n * Set the tiled sprite object x-scale.\n * @param newScale The new x-scale for the tiled sprite object.\n */\n setScaleX(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n }\n\n /**\n * Set the tiled sprite object y-scale.\n * @param newScale The new y-scale for the tiled sprite object.\n */\n setScaleY(newScale: float): void {\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n }\n gdjs.registerObject(\n 'TiledSpriteObject::TiledSprite',\n gdjs.TiledSpriteRuntimeObject\n );\n}\n"],
|
|
5
|
+
"mappings": "AAIA,GAAU,MAAV,UAAU,EAAV,CAyBS,eACG,GAAK,aAEf,CAgBE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAnB3B,cAAkB,EAClB,cAAkB,EAClB,aAAiB,IAkBf,KAAK,UAAY,GAAI,GAAK,iCACxB,KACA,EACA,EAAsB,SAExB,KAAK,OAAS,EACd,KAAK,QAAU,EACf,KAAK,SAAS,EAAsB,OACpC,KAAK,UAAU,EAAsB,QAGrC,KAAK,YAGP,qBAAqB,EAAe,EAAwB,CAC1D,MAAI,GAAc,UAAY,EAAc,SAC1C,KAAK,WAAW,EAAc,QAAS,KAAK,mBAE1C,EAAc,QAAU,EAAc,OACxC,KAAK,SAAS,EAAc,OAE1B,EAAc,SAAW,EAAc,QACzC,KAAK,UAAU,EAAc,QAExB,GAGT,oBAAiD,CAC/C,MAAO,IACF,MAAM,qBACT,GAAI,KAAK,aACT,GAAI,KAAK,aACT,GAAI,KAAK,aACT,MAAO,KAAK,YAIhB,0BACE,EACM,CACN,MAAM,0BAA0B,GAI5B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,QAAU,QAC5B,KAAK,SAAS,EAAgB,OAIlC,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,aAAoB,CAClB,MAAM,cACN,KAAK,UAAU,UAMjB,uCAAuC,EAAmC,CACxE,AAAI,EAAoB,YACtB,MAAK,SAAS,EAAoB,OAClC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AAU,KAAK,UAAU,mBAOvC,SAAS,EAAuB,CAC9B,KAAK,SAAS,KAAK,UAAU,kBAAoB,GACjD,KAAK,UAAU,KAAK,UAAU,mBAAqB,GAOrD,UAAU,EAAuB,CAC/B,KAAK,SAAS,KAAK,UAAU,kBAAoB,GAOnD,UAAU,EAAuB,CAC/B,KAAK,UAAU,KAAK,UAAU,mBAAqB,IArThD,EAAM,2BAwTb,EAAK,eACH,iCACA,EAAK,4BAnVC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(o){class n extends o.RuntimeObject{constructor(e,t){super(e,t);this._pausedAsScenePaused=!1;this._opacity=t.content.opacity,this._loop=t.content.loop,this._volume=t.content.volume,this._videoResource=t.content.videoResource,this._renderer=new o.VideoRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.loop!==t.content.loop&&this.setLoop(t.content.loop),e.content.volume!==t.content.volume&&this.setVolume(t.content.volume),e.content.videoResource===t.content.videoResource}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,pla:this.isPlayed(),loop:this.isLooped(),ct:this.getCurrentTime(),ps:this.getPlaybackSpeed()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),this._opacity!==void 0&&this._opacity&&e.op&&this.setOpacity(e.op),e.pla!==void 0&&this.isPlayed()!==e.pla&&(e.pla?this.play():this.pause()),e.loop!==void 0&&this.isLooped()!==e.loop&&this.setLoop(e.loop),e.ct!==void 0&&Math.abs(this.getCurrentTime()-e.ct)>3&&this.setCurrentTime(e.ct),e.ps!==void 0&&this.getPlaybackSpeed()!==e.ps&&this.setPlaybackSpeed(e.ps)}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity)}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}update(e){this._renderer.ensureUpToDate()}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=e,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWidth(e){this._renderer.getWidth()!==e&&(this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._renderer.getHeight()!==e&&(this._renderer.setHeight(e),this.invalidateHitboxes())}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}play(){this._renderer.play()}pause(){this._renderer.pause()}setLoop(e){this._renderer.setLoop(e)}mute(e){this._renderer.setMute(e)}isMuted(){return this._renderer.isMuted()}setVolume(e){this._volume=o.evtTools.common.clamp(o.evtTools.common.normalize(e,0,100),0,1)*100,this._renderer.updateVolume()}getVolume(){return o.evtTools.common.normalize(this._renderer.getVolume(),0,1)*100}isPlayed(){return this._renderer.isPlayed()}isPaused(){return!this._renderer.isPlayed()}isLooped(){return this._renderer.isLooped()}getDuration(){return this._renderer.getDuration()}isEnded(){return this._renderer.isEnded()}setCurrentTime(e){this._renderer.setCurrentTime(e)}getCurrentTime(){return this._renderer.getCurrentTime()}setPlaybackSpeed(e){this._playbackSpeed=o.evtTools.common.clamp(e,.5,2),this._renderer.setPlaybackSpeed(this._playbackSpeed)}getPlaybackSpeed(){return this._renderer.getPlaybackSpeed()}}o.VideoRuntimeObject=n,o.registerObject("Video::VideoObject",o.VideoRuntimeObject),o.registerRuntimeSceneUnloadedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const i=e[t];i instanceof o.VideoRuntimeObject&&i.isPlayed()&&i.pause()}}),o.registerRuntimeScenePausedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const i=e[t];i instanceof o.VideoRuntimeObject&&i.isPlayed()&&(i.pause(),i._pausedAsScenePaused=!0)}}),o.registerRuntimeSceneResumedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const i=e[t];i instanceof o.VideoRuntimeObject&&i._pausedAsScenePaused&&i.play()}})})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=videoruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/Video/videoruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n /** The initial properties for {@link gdjs.VideoRuntimeObject} */\n export type VideoObjectDataType = {\n /** The base parameters of the video */\n content: {\n /** The opacity of the video */\n opacity: number;\n /** Does the video loops itself? */\n loop: boolean;\n /** The volume of the video */\n volume: number;\n /** Name of the resource corresponding to the video */\n videoResource: string;\n };\n };\n\n export type VideoObjectData = ObjectData & VideoObjectDataType;\n\n export type VideoNetworkSyncDataType = {\n op: float;\n wid: float;\n hei: float;\n // We don't sync volume, as it's probably a user setting?\n pla: boolean;\n loop: boolean;\n ct: float;\n ps: number;\n };\n\n export type VideoNetworkSyncData = ObjectNetworkSyncData &\n VideoNetworkSyncDataType;\n\n /**\n * An object displaying a video on screen.\n *\n * For the same video resource, only one video is being created in memory (\n * as a HTMLVideoElement). This means that two objects displaying the same\n * video will have the same state for this video (paused/playing, current time,\n * volume, etc...).\n */\n export class VideoRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler\n {\n _opacity: float;\n _loop: boolean;\n _volume: float;\n _videoResource: string;\n\n // Use a boolean to track if the video was paused because we\n // navigated to another scene, and so should resume if we're back.\n _pausedAsScenePaused: boolean = false;\n _renderer: gdjs.VideoRuntimeObjectRenderer;\n _playbackSpeed: any;\n\n /**\n * @param instanceContainer The scene the object belongs to.\n * @param videoObjectData The data defining the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n videoObjectData: VideoObjectData\n ) {\n super(instanceContainer, videoObjectData);\n this._opacity = videoObjectData.content.opacity;\n this._loop = videoObjectData.content.loop;\n this._volume = videoObjectData.content.volume;\n this._videoResource = videoObjectData.content.videoResource;\n this._renderer = new gdjs.VideoRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updateFromObjectData(\n oldObjectData: VideoObjectData,\n newObjectData: VideoObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.loop !== newObjectData.content.loop) {\n this.setLoop(newObjectData.content.loop);\n }\n if (oldObjectData.content.volume !== newObjectData.content.volume) {\n this.setVolume(newObjectData.content.volume);\n }\n if (\n oldObjectData.content.videoResource !==\n newObjectData.content.videoResource\n ) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): VideoNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n wid: this.getWidth(),\n hei: this.getHeight(),\n pla: this.isPlayed(),\n loop: this.isLooped(),\n ct: this.getCurrentTime(),\n ps: this.getPlaybackSpeed(),\n };\n }\n\n updateFromNetworkSyncData(syncData: VideoNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (this._opacity !== undefined && this._opacity && syncData.op) {\n this.setOpacity(syncData.op);\n }\n if (this.getWidth() !== undefined && this.getWidth() !== syncData.wid) {\n this.setWidth(syncData.wid);\n }\n if (this.getHeight() !== undefined && this.getHeight() !== syncData.hei) {\n this.setHeight(syncData.hei);\n }\n if (syncData.pla !== undefined && this.isPlayed() !== syncData.pla) {\n syncData.pla ? this.play() : this.pause();\n }\n if (syncData.loop !== undefined && this.isLooped() !== syncData.loop) {\n this.setLoop(syncData.loop);\n }\n // We don't update the current time too regularly, only if it's off by a lot.\n if (\n syncData.ct !== undefined &&\n Math.abs(this.getCurrentTime() - syncData.ct) > 3 // More than 3 seconds off\n ) {\n this.setCurrentTime(syncData.ct);\n }\n if (\n syncData.ps !== undefined &&\n this.getPlaybackSpeed() !== syncData.ps\n ) {\n this.setPlaybackSpeed(syncData.ps);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The initial instance data\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\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 }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Set object position on X axis.\n * @param x The new position X of the object.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set object position on Y axis.\n * @param y The new position Y of the object.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle of the object.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Set object opacity.\n * @param opacity The new opacity of the object (0-255).\n */\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n * @returns The current opacity\n */\n getOpacity(): number {\n return this._opacity;\n }\n\n /**\n * Set the width of the video.\n * @param width The new width in pixels.\n */\n setWidth(width: float): void {\n if (this._renderer.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the video.\n * @param height The new height in pixels.\n */\n setHeight(height: float): void {\n if (this._renderer.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Get the width of the video object.\n * @returns The current width of the object\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the video object.\n * @returns The current height of the object\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n /**\n * Play the video.\n */\n play(): void {\n this._renderer.play();\n }\n\n /**\n * Pause the video.\n */\n pause(): void {\n this._renderer.pause();\n }\n\n /**\n * Set the state looped of the video.\n * @param enable true to loop the video\n */\n setLoop(enable: boolean): void {\n this._renderer.setLoop(enable);\n }\n\n /**\n * Set the state muted of the video.\n * @param enable The new state.\n */\n mute(enable: boolean) {\n this._renderer.setMute(enable);\n }\n\n /**\n * Return the state muted of video object.\n * @returns Is the video muted?\n */\n isMuted(): boolean {\n return this._renderer.isMuted();\n }\n\n /**\n * Set the volume of the video object.\n * @param volume The new volume, between 0 and 100.\n */\n setVolume(volume: number): void {\n this._volume =\n gdjs.evtTools.common.clamp(\n gdjs.evtTools.common.normalize(volume, 0, 100),\n 0,\n 1\n ) * 100;\n this._renderer.updateVolume();\n }\n\n /**\n * Get the volume of the video object.\n * @returns The current video's volume, between 0 and 100.\n */\n getVolume(): number {\n return (\n gdjs.evtTools.common.normalize(this._renderer.getVolume(), 0, 1) * 100\n );\n }\n\n /**\n * Check if the video is being played.\n * @returns Is the video being played?\n */\n isPlayed(): boolean {\n return this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is paused.\n * @returns Is the video being paused?\n */\n isPaused(): boolean {\n return !this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is looping.\n * @returns Is the video looping?\n */\n isLooped(): boolean {\n return this._renderer.isLooped();\n }\n\n /**\n * Return the total time of the video.\n * @returns The duration of the video\n */\n getDuration(): number {\n return this._renderer.getDuration();\n }\n\n /**\n * Check if the video has ended.\n * @returns Has the video ended?\n */\n isEnded(): boolean {\n return this._renderer.isEnded();\n }\n\n /**\n * Set the new time of the video object.\n * @param time The new time.\n */\n setCurrentTime(time: float): void {\n this._renderer.setCurrentTime(time);\n }\n\n /**\n * Get the current time of the video object.\n * @returns The current time of the video\n */\n getCurrentTime(): float {\n return this._renderer.getCurrentTime();\n }\n\n /**\n * Set the new playback speed of the video object.\n * @param playbackSpeed The new playback speed.\n */\n setPlaybackSpeed(playbackSpeed: number): void {\n this._playbackSpeed = gdjs.evtTools.common.clamp(playbackSpeed, 0.5, 2);\n this._renderer.setPlaybackSpeed(this._playbackSpeed);\n }\n\n /**\n * Get the playback speed of the video object.\n * @returns The current playback speed of the video.\n */\n getPlaybackSpeed(): number {\n return this._renderer.getPlaybackSpeed();\n }\n }\n gdjs.registerObject('Video::VideoObject', gdjs.VideoRuntimeObject);\n\n /**\n * When a scene is unloaded, pause any video being run.\n * TODO: Investigate how to dispose the video source?\n */\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n }\n }\n }\n });\n\n /**\n * When a scene is paused, pause any video being run.\n */\n gdjs.registerRuntimeScenePausedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n obj._pausedAsScenePaused = true;\n }\n }\n }\n });\n\n // Flag it to be started again when scene is resumed.\n\n /**\n * When a scene is resumed, resume any video previously paused.\n */\n gdjs.registerRuntimeSceneResumedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and play them if they have been previously paused.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj._pausedAsScenePaused) {\n obj.play();\n }\n }\n }\n });\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n /** The initial properties for {@link gdjs.VideoRuntimeObject} */\n export type VideoObjectDataType = {\n /** The base parameters of the video */\n content: {\n /** The opacity of the video */\n opacity: number;\n /** Does the video loops itself? */\n loop: boolean;\n /** The volume of the video */\n volume: number;\n /** Name of the resource corresponding to the video */\n videoResource: string;\n };\n };\n\n export type VideoObjectData = ObjectData & VideoObjectDataType;\n\n export type VideoNetworkSyncDataType = {\n op: float;\n // We don't sync volume, as it's probably a user setting?\n pla: boolean;\n loop: boolean;\n ct: float;\n ps: number;\n };\n\n export type VideoNetworkSyncData = ObjectNetworkSyncData &\n VideoNetworkSyncDataType;\n\n /**\n * An object displaying a video on screen.\n *\n * For the same video resource, only one video is being created in memory (\n * as a HTMLVideoElement). This means that two objects displaying the same\n * video will have the same state for this video (paused/playing, current time,\n * volume, etc...).\n */\n export class VideoRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler\n {\n _opacity: float;\n _loop: boolean;\n _volume: float;\n _videoResource: string;\n\n // Use a boolean to track if the video was paused because we\n // navigated to another scene, and so should resume if we're back.\n _pausedAsScenePaused: boolean = false;\n _renderer: gdjs.VideoRuntimeObjectRenderer;\n _playbackSpeed: any;\n\n /**\n * @param instanceContainer The scene the object belongs to.\n * @param videoObjectData The data defining the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n videoObjectData: VideoObjectData\n ) {\n super(instanceContainer, videoObjectData);\n this._opacity = videoObjectData.content.opacity;\n this._loop = videoObjectData.content.loop;\n this._volume = videoObjectData.content.volume;\n this._videoResource = videoObjectData.content.videoResource;\n this._renderer = new gdjs.VideoRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updateFromObjectData(\n oldObjectData: VideoObjectData,\n newObjectData: VideoObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.loop !== newObjectData.content.loop) {\n this.setLoop(newObjectData.content.loop);\n }\n if (oldObjectData.content.volume !== newObjectData.content.volume) {\n this.setVolume(newObjectData.content.volume);\n }\n if (\n oldObjectData.content.videoResource !==\n newObjectData.content.videoResource\n ) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): VideoNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n pla: this.isPlayed(),\n loop: this.isLooped(),\n ct: this.getCurrentTime(),\n ps: this.getPlaybackSpeed(),\n };\n }\n\n updateFromNetworkSyncData(syncData: VideoNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (this._opacity !== undefined && this._opacity && syncData.op) {\n this.setOpacity(syncData.op);\n }\n if (syncData.pla !== undefined && this.isPlayed() !== syncData.pla) {\n syncData.pla ? this.play() : this.pause();\n }\n if (syncData.loop !== undefined && this.isLooped() !== syncData.loop) {\n this.setLoop(syncData.loop);\n }\n // We don't update the current time too regularly, only if it's off by a lot.\n if (\n syncData.ct !== undefined &&\n Math.abs(this.getCurrentTime() - syncData.ct) > 3 // More than 3 seconds off\n ) {\n this.setCurrentTime(syncData.ct);\n }\n if (\n syncData.ps !== undefined &&\n this.getPlaybackSpeed() !== syncData.ps\n ) {\n this.setPlaybackSpeed(syncData.ps);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The initial instance data\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\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 }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Set object position on X axis.\n * @param x The new position X of the object.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set object position on Y axis.\n * @param y The new position Y of the object.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle of the object.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Set object opacity.\n * @param opacity The new opacity of the object (0-255).\n */\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n * @returns The current opacity\n */\n getOpacity(): number {\n return this._opacity;\n }\n\n /**\n * Set the width of the video.\n * @param width The new width in pixels.\n */\n setWidth(width: float): void {\n if (this._renderer.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the video.\n * @param height The new height in pixels.\n */\n setHeight(height: float): void {\n if (this._renderer.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Get the width of the video object.\n * @returns The current width of the object\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the video object.\n * @returns The current height of the object\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n /**\n * Play the video.\n */\n play(): void {\n this._renderer.play();\n }\n\n /**\n * Pause the video.\n */\n pause(): void {\n this._renderer.pause();\n }\n\n /**\n * Set the state looped of the video.\n * @param enable true to loop the video\n */\n setLoop(enable: boolean): void {\n this._renderer.setLoop(enable);\n }\n\n /**\n * Set the state muted of the video.\n * @param enable The new state.\n */\n mute(enable: boolean) {\n this._renderer.setMute(enable);\n }\n\n /**\n * Return the state muted of video object.\n * @returns Is the video muted?\n */\n isMuted(): boolean {\n return this._renderer.isMuted();\n }\n\n /**\n * Set the volume of the video object.\n * @param volume The new volume, between 0 and 100.\n */\n setVolume(volume: number): void {\n this._volume =\n gdjs.evtTools.common.clamp(\n gdjs.evtTools.common.normalize(volume, 0, 100),\n 0,\n 1\n ) * 100;\n this._renderer.updateVolume();\n }\n\n /**\n * Get the volume of the video object.\n * @returns The current video's volume, between 0 and 100.\n */\n getVolume(): number {\n return (\n gdjs.evtTools.common.normalize(this._renderer.getVolume(), 0, 1) * 100\n );\n }\n\n /**\n * Check if the video is being played.\n * @returns Is the video being played?\n */\n isPlayed(): boolean {\n return this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is paused.\n * @returns Is the video being paused?\n */\n isPaused(): boolean {\n return !this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is looping.\n * @returns Is the video looping?\n */\n isLooped(): boolean {\n return this._renderer.isLooped();\n }\n\n /**\n * Return the total time of the video.\n * @returns The duration of the video\n */\n getDuration(): number {\n return this._renderer.getDuration();\n }\n\n /**\n * Check if the video has ended.\n * @returns Has the video ended?\n */\n isEnded(): boolean {\n return this._renderer.isEnded();\n }\n\n /**\n * Set the new time of the video object.\n * @param time The new time.\n */\n setCurrentTime(time: float): void {\n this._renderer.setCurrentTime(time);\n }\n\n /**\n * Get the current time of the video object.\n * @returns The current time of the video\n */\n getCurrentTime(): float {\n return this._renderer.getCurrentTime();\n }\n\n /**\n * Set the new playback speed of the video object.\n * @param playbackSpeed The new playback speed.\n */\n setPlaybackSpeed(playbackSpeed: number): void {\n this._playbackSpeed = gdjs.evtTools.common.clamp(playbackSpeed, 0.5, 2);\n this._renderer.setPlaybackSpeed(this._playbackSpeed);\n }\n\n /**\n * Get the playback speed of the video object.\n * @returns The current playback speed of the video.\n */\n getPlaybackSpeed(): number {\n return this._renderer.getPlaybackSpeed();\n }\n }\n gdjs.registerObject('Video::VideoObject', gdjs.VideoRuntimeObject);\n\n /**\n * When a scene is unloaded, pause any video being run.\n * TODO: Investigate how to dispose the video source?\n */\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n }\n }\n }\n });\n\n /**\n * When a scene is paused, pause any video being run.\n */\n gdjs.registerRuntimeScenePausedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n obj._pausedAsScenePaused = true;\n }\n }\n }\n });\n\n // Flag it to be started again when scene is resumed.\n\n /**\n * When a scene is resumed, resume any video previously paused.\n */\n gdjs.registerRuntimeSceneResumedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and play them if they have been previously paused.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj._pausedAsScenePaused) {\n obj.play();\n }\n }\n }\n });\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAsCS,eACG,GAAK,aAEf,CAgBE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAZ3B,0BAAgC,GAa9B,KAAK,SAAW,EAAgB,QAAQ,QACxC,KAAK,MAAQ,EAAgB,QAAQ,KACrC,KAAK,QAAU,EAAgB,QAAQ,OACvC,KAAK,eAAiB,EAAgB,QAAQ,cAC9C,KAAK,UAAY,GAAI,GAAK,2BACxB,KACA,GAIF,KAAK,YAGP,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,qBACE,EACA,EACS,CAUT,MATI,GAAc,QAAQ,UAAY,EAAc,QAAQ,SAC1D,KAAK,WAAW,EAAc,QAAQ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U,OAAQ,EAAE,EAAG,CACzC,KAAM,GAAM,EAAU,GACtB,AAAI,YAAe,GAAK,oBAClB,EAAI,YACN,EAAI,WASZ,EAAK,mCAAmC,SAAU,EAAc,CAG9D,KAAM,GAAY,EAAa,6BAC/B,OAAS,GAAI,EAAG,EAAI,EAAU,OAAQ,EAAE,EAAG,CACzC,KAAM,GAAM,EAAU,GACtB,AAAI,YAAe,GAAK,oBAClB,EAAI,YACN,GAAI,QACJ,EAAI,qBAAuB,OAWnC,EAAK,oCAAoC,SAAU,EAAc,CAG/D,KAAM,GAAY,EAAa,6BAC/B,OAAS,GAAI,EAAG,EAAI,EAAU,OAAQ,EAAE,EAAG,CACzC,KAAM,GAAM,EAAU,GACtB,AAAI,YAAe,GAAK,oBAClB,EAAI,sBACN,EAAI,YA9aJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var gdjs;(function(d){const y=new d.Logger("Hot reloader");class u{constructor(r){this._reloadedScriptElement={};this._logs=[];this._alreadyLoadedScriptFiles={};this._runtimeGame=r}static indexByPersistentUuid(r){return r.reduce(function(t,o){return o.persistentUuid&&t.set(o.persistentUuid,o),t},new Map)}static indexByName(r){return r.reduce(function(t,o){return o.name&&t.set(o.name,o),t},new Map)}_canReloadScriptFile(r){function t(o,e){const a=o.indexOf(e);return a!==-1&&a===o.length-e.length}return!(t(r,".h")||this._alreadyLoadedScriptFiles[r]&&(t(r,"box2d.js")||t(r,"sha256.js")||t(r,"shopify-buy.umd.polyfilled.min.js")||t(r,"pixi-multistyle-text.umd.js")||t(r,"pixi-tilemap.umd.js")||t(r,"bondage.min.js")||t(r,"pixi-particles-pixi-renderer.min.js")||t(r,"pixi-tilemap.umd.js")||t(r,"pixi-tilemap-helper.js")||t(r,"pako/dist/pako.min")))}_reloadScript(r){function t(e,a){const i=e.indexOf(a);return i!==-1&&i===e.length-a.length}if(!this._canReloadScriptFile(r))return this._logs.push({kind:"info",message:"Not reloading "+r+" as it is blocked for hot-reloading."}),Promise.resolve();const o=document.getElementsByTagName("head")[0];return o?new Promise((e,a)=>{const i=this._reloadedScriptElement[r];if(i)o.removeChild(i);else{const n=o.getElementsByTagName("script");for(let l=0;l<n.length;++l){const h=n[l];t(h.src,r)&&o.removeChild(h)}}const s=document.createElement("script");s.src=r+"?timestamp="+Date.now(),s.onload=()=>{e()},s.onerror=n=>{a(n)},o.appendChild(s),this._reloadedScriptElement[r]=s}):Promise.reject(new Error("No head element found, are you in a navigator?"))}hotReload(){y.info("Hot reload started"),this._runtimeGame.pause(!0),this._logs=[];const r=d.projectData,t=d.runtimeGameOptions.scriptFiles;t.forEach(e=>{this._alreadyLoadedScriptFiles[e.path]=!0});const o={};for(let e in d.behaviorsTypes.items)o[e]=d.behaviorsTypes.items[e];return this._reloadScript("data.js").then(()=>{const e=d.projectData,a=d.runtimeGameOptions;d.inAppTutorialMessage&&d.inAppTutorialMessage.displayInAppTutorialMessage(this._runtimeGame,a.inAppTutorialMessageInPreview,a.inAppTutorialMessagePositionInPreview||"");const i=a.scriptFiles,s=!!a.projectDataOnlyExport;return this.reloadScriptFiles(e,t,i,s).then(()=>{const n=this._computeChangedRuntimeBehaviors(o,d.behaviorsTypes.items);return this._hotReloadRuntimeGame(r,e,n,this._runtimeGame)}).catch(n=>{const l=n.target;l instanceof HTMLScriptElement?this._logs.push({kind:"fatal",message:"Unable to reload script: "+l.src}):this._logs.push({kind:"fatal",message:"Unexpected error happened while hot-reloading: "+n.message+`
|
|
2
2
|
`+n.stack})}).then(()=>(y.info("Hot reload finished with logs:",this._logs.map(n=>`
|
|
3
|
-
`+n.kind+": "+n.message)),this._runtimeGame.pause(!1),this._logs))})}_computeChangedRuntimeBehaviors(r,t){const o=[];for(let e in r){const a=r[e],i=t[e];i?a!==i&&(this._logs.push({kind:"info",message:"Behavior with type "+e+" was changed, and will be re-instantiated in gdjs.RuntimeObjects using it."}),o.push({oldBehaviorConstructor:a,newBehaviorConstructor:i,behaviorTypeName:e})):this._logs.push({kind:"warning",message:"Behavior with type "+e+" was removed from the registered behaviors in gdjs."})}return o}reloadScriptFiles(r,t,o,e){const a=[];e||r.layouts.forEach((i,s)=>{a.push(this._reloadScript("code"+s+".js"))});for(let i=0;i<o.length;++i){const s=o[i],n=t.filter(l=>l.path===s.path)[0];n?s.hash!==n.hash&&(this._logs.push({kind:"info",message:"Reloading "+s.path+" because it was changed."}),a.push(this._reloadScript(s.path))):(this._logs.push({kind:"info",message:"Loading "+s.path+" as it was added to the list of scripts."}),a.push(this._reloadScript(s.path)))}for(let i=0;i<t.length;++i){const s=t[i];!o.filter(l=>l.path===s.path)[0]&&!e&&this._logs.push({kind:"warning",message:"Script file "+s.path+" was removed."})}return Promise.all(a)}async _hotReloadRuntimeGame(r,t,o,e){const a=e.getSceneStack(),i=a.getCurrentScene();if(!i){this._logs.push({kind:"error",message:"Can't hot-reload as no scene are opened."});return}e.setProjectData(t),await e.loadFirstAssetsAndStartBackgroundLoading(i.getName(),()=>{}),this._hotReloadVariablesContainer(r.variables,t.variables,e.getVariables());for(const l of t.eventsFunctionsExtensions){const h=r.eventsFunctionsExtensions.find(g=>g.name===l.name),f=h?h.globalVariables:[],p=l.globalVariables;if(f.length>0||p.length>0){const g=e.getVariablesForExtension(l.name);g?this._hotReloadVariablesContainer(f,p,g):e._variablesByExtensionName.set(l.name,new d.VariablesContainer(p))}}const s=u.indexByName(r.layouts),n=u.indexByName(t.layouts);a._stack.forEach(l=>{const h=s.get(l.getName()),f=n.get(l.getName());if(h&&f){this._hotReloadRuntimeScene(r,t,h,f,o,l);for(const p of t.eventsFunctionsExtensions){const g=r.eventsFunctionsExtensions.find(m=>m.name===p.name),v=g?g.sceneVariables:[],c=p.sceneVariables;if(v.length>0||c.length>0){const m=l.getVariablesForExtension(p.name);m?this._hotReloadVariablesContainer(v,c,m):l._variablesByExtensionName.set(p.name,new d.VariablesContainer(c))}}}else this._logs.push({kind:"error",message:"Scene "+(h&&h.name)+" was removed. A fresh preview should be launched."})}),t.externalLayouts.forEach(l=>{const h=r.externalLayouts.filter(f=>f.name===l.name)[0];if(h&&!u.deepEqual(h,l)){const f=s.get(h.associatedLayout),p=n.get(l.associatedLayout),g=u.resolveCustomObjectConfigurations(r,f?f.objects:[]),v=u.resolveCustomObjectConfigurations(t,p?p.objects:[]);a._stack.forEach(c=>{this._hotReloadRuntimeSceneInstances(r,t,o,g,v,h.instances,l.instances,c)})}})}_hotReloadVariablesContainer(r,t,o){t.forEach(e=>{const a=e.name,i=r.find(n=>n.name===a),s=o.get(e.name);i?d.Variable.isPrimitive(e.type||"number")&&(i.value!==e.value||!d.Variable.isPrimitive(i.type||"number"))?(o.remove(a),o.add(a,new d.Variable(e))):d.Variable.isPrimitive(e.type||"number")||(e.type==="structure"?this._hotReloadStructureVariable(i.children,e.children,s):(o.remove(a),o.add(a,new d.Variable(e)))):o.add(a,new d.Variable(e))}),r.forEach(e=>{t.find(i=>i.name===e.name)||o.remove(e.name)}),o.rebuildIndexFrom(t)}_hotReloadStructureVariable(r,t,o){r?(r.forEach(e=>{const a=t.find(i=>i.name===e.name);a?d.Variable.isPrimitive(a.type||"number")&&(e.value!==a.value||!d.Variable.isPrimitive(e.type||"number"))?o.addChild(a.name,new d.Variable(a)):d.Variable.isPrimitive(a.type||"number")||(a.type==="structure"?this._hotReloadStructureVariable(e.children,a.children,o.getChild(a.name)):o.addChild(a.name,new d.Variable(a))):o.removeChild(e.name)}),t.forEach(e=>{r.find(i=>i.name===e.name)||o.addChild(e.name,new d.Variable(e))})):t.forEach(e=>{o.addChild(e.name,new d.Variable(e))})}_hotReloadRuntimeScene(r,t,o,e,a,i){i.setBackgroundColor(e.r,e.v,e.b),o.title!==e.title&&i.getGame().getRenderer().setWindowTitle(e.title),this._hotReloadVariablesContainer(o.variables,e.variables,i.getVariables()),this._hotReloadRuntimeSceneBehaviorsSharedData(o.behaviorsSharedData,e.behaviorsSharedData,i),this._hotReloadRuntimeInstanceContainer(r,t,o,e,a,i),i.setEventsGeneratedCodeFunction(e)}static resolveCustomObjectConfigurations(r,t){return t.map(o=>{const[e,a]=o.type.split("::"),i=r.eventsFunctionsExtensions.find(f=>f.name===e);if(!i)return o;const s=i&&i.eventsBasedObjects.find(f=>f.name===a);if(!s)return o;const n=o,l=n.childrenContent?s.objects.map(f=>({...f,...n.childrenContent[f.name]})):s.objects;return{...s,...o,objects:l,childrenContent:l}})}_hotReloadRuntimeInstanceContainer(r,t,o,e,a,i){const s=u.resolveCustomObjectConfigurations(r,o.objects),n=u.resolveCustomObjectConfigurations(t,e.objects);this._reinstantiateRuntimeSceneRuntimeBehaviors(a,n,i),this._hotReloadRuntimeSceneObjects(s,n,i),this._hotReloadRuntimeSceneInstances(r,t,a,s,n,o.instances,e.instances,i),this._hotReloadRuntimeSceneLayers(o.layers,e.layers,i)}_hotReloadRuntimeSceneBehaviorsSharedData(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];i?u.deepEqual(e,i)||o.setInitialSharedDataForBehavior(i.name,i):o.setInitialSharedDataForBehavior(e.name,null)}),t.forEach(e=>{const a=e.name;r.filter(s=>s.name===a)[0]||o.setInitialSharedDataForBehavior(e.name,e)})}_reinstantiateRuntimeSceneRuntimeBehaviors(r,t,o){t.forEach(e=>{const a=e.name,i=e.behaviors,s=o.getObjects(a);r.forEach(n=>{const l=n.behaviorTypeName;i.filter(h=>h.type===l).forEach(h=>{const f=h.name;this._logs.push({kind:"info",message:'Re-instantiating behavior named "'+f+'" for instances of object "'+a+'".'}),s.forEach(p=>{this._reinstantiateRuntimeObjectRuntimeBehavior(h,p)})})})})}_reinstantiateRuntimeObjectRuntimeBehavior(r,t){const o=r.name,e=t.getBehavior(o);if(!e)return;t.removeBehavior(o),t.addNewBehavior(r);const a=t.getBehavior(o);if(!a){this._logs.push({kind:"error",message:"Could not create behavior "+o+" (type: "+r.type+") for object "+t.getName()});return}for(let i in e)if(!!e.hasOwnProperty(i))if(i==="_behaviorData"){a[i]=a[i]||{};for(let s in e[i])a[i][s]=e[i][s]}else a[i]=e[i]}_hotReloadRuntimeSceneObjects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];!i||e.type!==i.type?o.unregisterObject(a):o.isObjectRegistered(a)&&this._hotReloadRuntimeSceneObject(e,i,o)}),t.forEach(e=>{const a=e.name,i=r.filter(s=>s.name===a)[0];(!i||i.type!==e.type)&&!o.isObjectRegistered(a)&&o.registerObject(e)})}_hotReloadRuntimeSceneObject(r,t,o){let e=!0;if(!u.deepEqual(r,t)){this._logs.push({kind:"info",message:'Object "'+t.name+'" was modified and is hot-reloaded.'}),o.updateObject(t);const a=o.getObjects(t.name);a.forEach(i=>{e=i.updateFromObjectData(r,t)&&e}),this._hotReloadRuntimeObjectsBehaviors(r.behaviors,t.behaviors,a),this._hotReloadRuntimeObjectsEffects(r.effects,t.effects,a)}e||this._logs.push({kind:"error",message:'Object "'+t.name+'" could not be hot-reloaded. A fresh preview should be run.'})}_hotReloadRuntimeObjectsBehaviors(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.forEach(s=>{s.hasBehavior(a)&&(s.removeBehavior(a)||this._logs.push({kind:"error",message:"Behavior "+a+" could not be removed from object"+s.getName()}))});else if(!u.deepEqual(e,i)){let s=!0;o.forEach(n=>{const l=n.getBehavior(i.name);l&&(s=this._hotReloadRuntimeBehavior(e,i,l)&&s)}),s||this._logs.push({kind:"error",message:i.name+" behavior could not be hot-reloaded."})}}),t.forEach(e=>{const a=e.name;if(!r.filter(s=>s.name===a)[0]){let s=!0;o.forEach(n=>{s=n.addNewBehavior(e)&&s}),s||this._logs.push({kind:"error",message:e.name+" behavior could not be added during hot-reload."})}})}_hotReloadRuntimeObjectsEffects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.forEach(s=>{s.hasEffect(a)&&(s.removeEffect(a)||this._logs.push({kind:"error",message:"Effect "+a+" could not be removed from object"+s.getName()}))});else if(!u.deepEqual(e,i)){let s=!0;o.forEach(n=>{e.effectType===i.effectType?s=n.updateAllEffectParameters(i)&&s:(n.removeEffect(e.name),n.addEffect(i))}),s||this._logs.push({kind:"error",message:i.name+" effect could not be hot-reloaded."})}}),t.forEach(e=>{const a=e.name;if(!r.filter(s=>s.name===a)[0]){let s=!0;o.forEach(n=>{s=n.addEffect(e)&&s}),s||this._logs.push({kind:"error",message:e.name+" effect could not be added during hot-reload."})}})}_hotReloadRuntimeBehavior(r,t,o){return o.updateFromBehaviorData(r,t)}_hotReloadRuntimeSceneLayers(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.removeLayer(a);else if(o.hasLayer(a)){const s=o.getLayer(a);this._hotReloadRuntimeLayer(e,i,s)}}),t.forEach(e=>{const a=e.name;!r.filter(s=>s.name===a)[0]&&!o.hasLayer(a)&&o.addLayer(e)}),t.forEach((e,a)=>{o.setLayerIndex(e.name,a)})}_hotReloadRuntimeLayer(r,t,o){r.visibility!==t.visibility&&o.show(t.visibility),t.isLightingLayer&&((r.ambientLightColorR!==t.ambientLightColorR||r.ambientLightColorG!==t.ambientLightColorG||r.ambientLightColorB!==t.ambientLightColorB)&&o.setClearColor(t.ambientLightColorR,t.ambientLightColorG,t.ambientLightColorB),r.followBaseLayerCamera!==t.followBaseLayerCamera&&o.setFollowBaseLayerCamera(t.followBaseLayerCamera)),r.renderingType!==t.renderingType&&this._logs.push({kind:"error",message:`Could not change the rendering type (2D, 3D...) layer at runtime (for layer "${t.name}").`}),t.isLightingLayer!==r.isLightingLayer&&this._logs.push({kind:"error",message:`Could not add/remove a lighting layer at runtime (for layer "${t.name}").`}),this._hotReloadRuntimeLayerEffects(r.effects,t.effects,o)}_hotReloadRuntimeLayerEffects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];i?o.hasEffect(a)&&(e.effectType!==i.effectType?(o.removeEffect(a),o.addEffect(i)):this._hotReloadRuntimeLayerEffect(e,i,o,a)):o.removeEffect(a)}),t.forEach(e=>{const a=e.name;!r.filter(s=>s.name===a)[0]&&!o.hasEffect(a)&&o.addEffect(e)})}_hotReloadRuntimeLayerEffect(r,t,o,e){for(let a in t.booleanParameters){const i=t.booleanParameters[a];i!==r.booleanParameters[a]&&o.setEffectBooleanParameter(e,a,i)}for(let a in t.doubleParameters){const i=t.doubleParameters[a];i!==r.doubleParameters[a]&&o.setEffectDoubleParameter(e,a,i)}for(let a in t.stringParameters){const i=t.stringParameters[a];i!==r.stringParameters[a]&&o.setEffectStringParameter(e,a,i)}}_hotReloadRuntimeSceneInstances(r,t,o,e,a,i,s,n){const l=n.getAdhocListOfAllInstances(),h=u.indexByPersistentUuid(i),f=u.indexByPersistentUuid(s),p=u.indexByPersistentUuid(l),g=u.indexByName(e),v=u.indexByName(a);for(const c of h.keys()){const m=h.get(c),b=f.get(c),R=p.get(c);m&&(!b||m.name!==b.name)&&R&&R.deleteFromScene()}for(const c of l){const m=g.get(c.getName()),b=v.get(c.getName());if(!c||!m||!b)continue;const R=h.get(c.persistentUuid),E=f.get(c.persistentUuid);if(R&&E)this._hotReloadRuntimeInstance(r,t,o,m,b,R,E,c);else if(this._hotReloadVariablesContainer(m.variables,b.variables,c.getVariables()),c instanceof d.CustomRuntimeObject){const C=c.getChildrenContainer(),_=m,j=b;this._hotReloadRuntimeInstanceContainer(r,t,_,j,o,C)}}for(const c of f.keys()){const m=h.get(c),b=f.get(c),R=p.get(c);b&&(!m||m.name!==b.name)&&!R&&n.createObjectsFrom([b],0,0,0,!0)}}_hotReloadRuntimeInstance(r,t,o,e,a,i,s,n){let l=!1;i.x!==s.x&&(n.setX(s.x),l=!0),i.y!==s.y&&(n.setY(s.y),l=!0),i.angle!==s.angle&&(n.setAngle(s.angle),l=!0),i.zOrder!==s.zOrder&&(n.setZOrder(s.zOrder),l=!0),i.layer!==s.layer&&(n.setLayer(s.layer),l=!0),d.Base3DHandler&&d.Base3DHandler.is3D(n)&&(i.z!==s.z&&s.z!==void 0&&(n.setZ(s.z),l=!0),i.rotationX!==s.rotationX&&s.rotationX!==void 0&&(n.setRotationX(s.rotationX),l=!0),i.rotationY!==s.rotationY&&s.rotationY!==void 0&&(n.setRotationY(s.rotationY),l=!0));let h=!1;if(s.customSize?i.customSize?(i.width!==s.width&&(n.setWidth(s.width),l=!0,h=!0),i.height!==s.height&&(n.setHeight(s.height),l=!0,h=!0)):(n.setWidth(s.width),n.setHeight(s.height),l=!0,h=!0):!s.customSize&&i.customSize&&(h=!0),d.Base3DHandler&&d.Base3DHandler.is3D(n)&&(i.depth!==s.depth&&s.depth!==void 0?(n.setDepth(s.depth),l=!0,h=!0):s.depth===void 0&&i.depth!==void 0&&(h=!0)),n instanceof d.CustomRuntimeObject){const g=n.getChildrenContainer(),v=e,c=a;this._hotReloadRuntimeInstanceContainer(r,t,v,c,o,g)}this._hotReloadVariablesContainer(this._mergeObjectVariablesData(e.variables,i.initialVariables),this._mergeObjectVariablesData(a.variables,s.initialVariables),n.getVariables());const f=s.numberProperties.some(g=>{const v=g.name,c=g.value,m=i.numberProperties.filter(b=>b.name===v)[0];return!m||m.value!==c}),p=s.stringProperties.some(g=>{const v=g.name,c=g.value,m=i.stringProperties.filter(b=>b.name===v)[0];return!m||m.value!==c});(f||p||h)&&(n.extraInitializationFromInitialInstance(s),l=!0),l&&n.notifyBehaviorsObjectHotReloaded()}_mergeObjectVariablesData(r,t){if(t.length===0)return r;const o=[...r];for(const e of t){const a=o.indexOf(i=>i.name===e.name);a>=0&&(o[a]=e)}return o}static deepEqual(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;let o,e,a;if(Array.isArray(r)){if(o=r.length,o!=t.length)return!1;for(e=o;e--!=0;)if(!u.deepEqual(r[e],t[e]))return!1;return!0}if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(a=Object.keys(r),o=a.length,o!==Object.keys(t).length)return!1;for(e=o;e--!=0;)if(!Object.prototype.hasOwnProperty.call(t,a[e]))return!1;for(e=o;e--!=0;){const i=a[e];if(!u.deepEqual(r[i],t[i]))return!1}return!0}return r!==r&&t!==t}}d.HotReloader=u})(gdjs||(gdjs={}));
|
|
3
|
+
`+n.kind+": "+n.message)),this._runtimeGame.pause(!1),this._logs))})}_computeChangedRuntimeBehaviors(r,t){const o=[];for(let e in r){const a=r[e],i=t[e];i?a!==i&&(this._logs.push({kind:"info",message:"Behavior with type "+e+" was changed, and will be re-instantiated in gdjs.RuntimeObjects using it."}),o.push({oldBehaviorConstructor:a,newBehaviorConstructor:i,behaviorTypeName:e})):this._logs.push({kind:"warning",message:"Behavior with type "+e+" was removed from the registered behaviors in gdjs."})}return o}reloadScriptFiles(r,t,o,e){const a=[];e||r.layouts.forEach((i,s)=>{a.push(this._reloadScript("code"+s+".js"))});for(let i=0;i<o.length;++i){const s=o[i],n=t.filter(l=>l.path===s.path)[0];n?s.hash!==n.hash&&(this._logs.push({kind:"info",message:"Reloading "+s.path+" because it was changed."}),a.push(this._reloadScript(s.path))):(this._logs.push({kind:"info",message:"Loading "+s.path+" as it was added to the list of scripts."}),a.push(this._reloadScript(s.path)))}for(let i=0;i<t.length;++i){const s=t[i];!o.filter(l=>l.path===s.path)[0]&&!e&&this._logs.push({kind:"warning",message:"Script file "+s.path+" was removed."})}return Promise.all(a)}async _hotReloadRuntimeGame(r,t,o,e){const a=e.getSceneStack(),i=a.getCurrentScene();if(!i){this._logs.push({kind:"error",message:"Can't hot-reload as no scene are opened."});return}e.setProjectData(t),await e.loadFirstAssetsAndStartBackgroundLoading(i.getName(),()=>{}),this._hotReloadVariablesContainer(r.variables,t.variables,e.getVariables());for(const l of t.eventsFunctionsExtensions){const h=r.eventsFunctionsExtensions.find(g=>g.name===l.name),f=h?h.globalVariables:[],p=l.globalVariables;if(f.length>0||p.length>0){const g=e.getVariablesForExtension(l.name);g?this._hotReloadVariablesContainer(f,p,g):e._variablesByExtensionName.set(l.name,new d.VariablesContainer(p))}}const s=u.indexByName(r.layouts),n=u.indexByName(t.layouts);a._stack.forEach(l=>{const h=s.get(l.getName()),f=n.get(l.getName());if(h&&f){this._hotReloadRuntimeScene(r,t,h,f,o,l);for(const p of t.eventsFunctionsExtensions){const g=r.eventsFunctionsExtensions.find(m=>m.name===p.name),v=g?g.sceneVariables:[],c=p.sceneVariables;if(v.length>0||c.length>0){const m=l.getVariablesForExtension(p.name);m?this._hotReloadVariablesContainer(v,c,m):l._variablesByExtensionName.set(p.name,new d.VariablesContainer(c))}}}else this._logs.push({kind:"error",message:"Scene "+(h&&h.name)+" was removed. A fresh preview should be launched."})}),t.externalLayouts.forEach(l=>{const h=r.externalLayouts.filter(f=>f.name===l.name)[0];if(h&&!u.deepEqual(h,l)){const f=s.get(h.associatedLayout),p=n.get(l.associatedLayout),g=u.resolveCustomObjectConfigurations(r,f?f.objects:[]),v=u.resolveCustomObjectConfigurations(t,p?p.objects:[]);a._stack.forEach(c=>{this._hotReloadRuntimeSceneInstances(r,t,o,g,v,h.instances,l.instances,c)})}})}_hotReloadVariablesContainer(r,t,o){t.forEach(e=>{const a=e.name,i=r.find(n=>n.name===a),s=o.get(e.name);i?d.Variable.isPrimitive(e.type||"number")&&(i.value!==e.value||!d.Variable.isPrimitive(i.type||"number"))?(o.remove(a),o.add(a,new d.Variable(e))):d.Variable.isPrimitive(e.type||"number")||(e.type==="structure"?this._hotReloadStructureVariable(i.children,e.children,s):(o.remove(a),o.add(a,new d.Variable(e)))):o.add(a,new d.Variable(e))}),r.forEach(e=>{t.find(i=>i.name===e.name)||o.remove(e.name)}),o.rebuildIndexFrom(t)}_hotReloadStructureVariable(r,t,o){r?(r.forEach(e=>{const a=t.find(i=>i.name===e.name);a?d.Variable.isPrimitive(a.type||"number")&&(e.value!==a.value||!d.Variable.isPrimitive(e.type||"number"))?o.addChild(a.name,new d.Variable(a)):d.Variable.isPrimitive(a.type||"number")||(a.type==="structure"?this._hotReloadStructureVariable(e.children,a.children,o.getChild(a.name)):o.addChild(a.name,new d.Variable(a))):o.removeChild(e.name)}),t.forEach(e=>{r.find(i=>i.name===e.name)||o.addChild(e.name,new d.Variable(e))})):t.forEach(e=>{o.addChild(e.name,new d.Variable(e))})}_hotReloadRuntimeScene(r,t,o,e,a,i){i.setBackgroundColor(e.r,e.v,e.b),o.title!==e.title&&i.getGame().getRenderer().setWindowTitle(e.title),this._hotReloadVariablesContainer(o.variables,e.variables,i.getVariables()),this._hotReloadRuntimeSceneBehaviorsSharedData(o.behaviorsSharedData,e.behaviorsSharedData,i),this._hotReloadRuntimeInstanceContainer(r,t,o,e,a,i),i.setEventsGeneratedCodeFunction(e)}static resolveCustomObjectConfigurations(r,t){return t.map(o=>{const[e,a]=o.type.split("::"),i=r.eventsFunctionsExtensions.find(f=>f.name===e);if(!i)return o;const s=i&&i.eventsBasedObjects.find(f=>f.name===a);if(!s)return o;const n=o,l=n.childrenContent?s.objects.map(f=>({...f,...n.childrenContent[f.name]})):s.objects;return{...s,...o,objects:l}})}_hotReloadRuntimeInstanceContainer(r,t,o,e,a,i){const s=u.resolveCustomObjectConfigurations(r,o.objects),n=u.resolveCustomObjectConfigurations(t,e.objects);this._reinstantiateRuntimeSceneRuntimeBehaviors(a,n,i),this._hotReloadRuntimeSceneObjects(s,n,i),this._hotReloadRuntimeSceneInstances(r,t,a,s,n,o.instances,e.instances,i),this._hotReloadRuntimeSceneLayers(o.layers,e.layers,i)}_hotReloadRuntimeSceneBehaviorsSharedData(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];i?u.deepEqual(e,i)||o.setInitialSharedDataForBehavior(i.name,i):o.setInitialSharedDataForBehavior(e.name,null)}),t.forEach(e=>{const a=e.name;r.filter(s=>s.name===a)[0]||o.setInitialSharedDataForBehavior(e.name,e)})}_reinstantiateRuntimeSceneRuntimeBehaviors(r,t,o){t.forEach(e=>{const a=e.name,i=e.behaviors,s=o.getObjects(a);r.forEach(n=>{const l=n.behaviorTypeName;i.filter(h=>h.type===l).forEach(h=>{const f=h.name;this._logs.push({kind:"info",message:'Re-instantiating behavior named "'+f+'" for instances of object "'+a+'".'}),s.forEach(p=>{this._reinstantiateRuntimeObjectRuntimeBehavior(h,p)})})})})}_reinstantiateRuntimeObjectRuntimeBehavior(r,t){const o=r.name,e=t.getBehavior(o);if(!e)return;t.removeBehavior(o),t.addNewBehavior(r);const a=t.getBehavior(o);if(!a){this._logs.push({kind:"error",message:"Could not create behavior "+o+" (type: "+r.type+") for object "+t.getName()});return}for(let i in e)if(!!e.hasOwnProperty(i))if(i==="_behaviorData"){a[i]=a[i]||{};for(let s in e[i])a[i][s]=e[i][s]}else a[i]=e[i]}_hotReloadRuntimeSceneObjects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];!i||e.type!==i.type?o.unregisterObject(a):o.isObjectRegistered(a)&&this._hotReloadRuntimeSceneObject(e,i,o)}),t.forEach(e=>{const a=e.name,i=r.filter(s=>s.name===a)[0];(!i||i.type!==e.type)&&!o.isObjectRegistered(a)&&o.registerObject(e)})}_hotReloadRuntimeSceneObject(r,t,o){let e=!0;if(!u.deepEqual(r,t)){this._logs.push({kind:"info",message:'Object "'+t.name+'" was modified and is hot-reloaded.'}),o.updateObject(t);const a=o.getObjects(t.name);a.forEach(i=>{e=i.updateFromObjectData(r,t)&&e}),this._hotReloadRuntimeObjectsBehaviors(r.behaviors,t.behaviors,a),this._hotReloadRuntimeObjectsEffects(r.effects,t.effects,a)}e||this._logs.push({kind:"error",message:'Object "'+t.name+'" could not be hot-reloaded. A fresh preview should be run.'})}_hotReloadRuntimeObjectsBehaviors(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.forEach(s=>{s.hasBehavior(a)&&(s.removeBehavior(a)||this._logs.push({kind:"error",message:"Behavior "+a+" could not be removed from object"+s.getName()}))});else if(!u.deepEqual(e,i)){let s=!0;o.forEach(n=>{const l=n.getBehavior(i.name);l&&(s=this._hotReloadRuntimeBehavior(e,i,l)&&s)}),s||this._logs.push({kind:"error",message:i.name+" behavior could not be hot-reloaded."})}}),t.forEach(e=>{const a=e.name;if(!r.filter(s=>s.name===a)[0]){let s=!0;o.forEach(n=>{s=n.addNewBehavior(e)&&s}),s||this._logs.push({kind:"error",message:e.name+" behavior could not be added during hot-reload."})}})}_hotReloadRuntimeObjectsEffects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.forEach(s=>{s.hasEffect(a)&&(s.removeEffect(a)||this._logs.push({kind:"error",message:"Effect "+a+" could not be removed from object"+s.getName()}))});else if(!u.deepEqual(e,i)){let s=!0;o.forEach(n=>{e.effectType===i.effectType?s=n.updateAllEffectParameters(i)&&s:(n.removeEffect(e.name),n.addEffect(i))}),s||this._logs.push({kind:"error",message:i.name+" effect could not be hot-reloaded."})}}),t.forEach(e=>{const a=e.name;if(!r.filter(s=>s.name===a)[0]){let s=!0;o.forEach(n=>{s=n.addEffect(e)&&s}),s||this._logs.push({kind:"error",message:e.name+" effect could not be added during hot-reload."})}})}_hotReloadRuntimeBehavior(r,t,o){return o.updateFromBehaviorData(r,t)}_hotReloadRuntimeSceneLayers(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];if(!i)o.removeLayer(a);else if(o.hasLayer(a)){const s=o.getLayer(a);this._hotReloadRuntimeLayer(e,i,s)}}),t.forEach(e=>{const a=e.name;!r.filter(s=>s.name===a)[0]&&!o.hasLayer(a)&&o.addLayer(e)}),t.forEach((e,a)=>{o.setLayerIndex(e.name,a)})}_hotReloadRuntimeLayer(r,t,o){r.visibility!==t.visibility&&o.show(t.visibility),t.isLightingLayer&&((r.ambientLightColorR!==t.ambientLightColorR||r.ambientLightColorG!==t.ambientLightColorG||r.ambientLightColorB!==t.ambientLightColorB)&&o.setClearColor(t.ambientLightColorR,t.ambientLightColorG,t.ambientLightColorB),r.followBaseLayerCamera!==t.followBaseLayerCamera&&o.setFollowBaseLayerCamera(t.followBaseLayerCamera)),r.renderingType!==t.renderingType&&this._logs.push({kind:"error",message:`Could not change the rendering type (2D, 3D...) layer at runtime (for layer "${t.name}").`}),t.isLightingLayer!==r.isLightingLayer&&this._logs.push({kind:"error",message:`Could not add/remove a lighting layer at runtime (for layer "${t.name}").`}),this._hotReloadRuntimeLayerEffects(r.effects,t.effects,o)}_hotReloadRuntimeLayerEffects(r,t,o){r.forEach(e=>{const a=e.name,i=t.filter(s=>s.name===a)[0];i?o.hasEffect(a)&&(e.effectType!==i.effectType?(o.removeEffect(a),o.addEffect(i)):this._hotReloadRuntimeLayerEffect(e,i,o,a)):o.removeEffect(a)}),t.forEach(e=>{const a=e.name;!r.filter(s=>s.name===a)[0]&&!o.hasEffect(a)&&o.addEffect(e)})}_hotReloadRuntimeLayerEffect(r,t,o,e){for(let a in t.booleanParameters){const i=t.booleanParameters[a];i!==r.booleanParameters[a]&&o.setEffectBooleanParameter(e,a,i)}for(let a in t.doubleParameters){const i=t.doubleParameters[a];i!==r.doubleParameters[a]&&o.setEffectDoubleParameter(e,a,i)}for(let a in t.stringParameters){const i=t.stringParameters[a];i!==r.stringParameters[a]&&o.setEffectStringParameter(e,a,i)}}_hotReloadRuntimeSceneInstances(r,t,o,e,a,i,s,n){const l=n.getAdhocListOfAllInstances(),h=u.indexByPersistentUuid(i),f=u.indexByPersistentUuid(s),p=u.indexByPersistentUuid(l),g=u.indexByName(e),v=u.indexByName(a);for(const c of h.keys()){const m=h.get(c),b=f.get(c),R=p.get(c);m&&(!b||m.name!==b.name)&&R&&R.deleteFromScene()}for(const c of l){const m=g.get(c.getName()),b=v.get(c.getName());if(!c||!m||!b)continue;const R=h.get(c.persistentUuid),E=f.get(c.persistentUuid);if(R&&E)this._hotReloadRuntimeInstance(r,t,o,m,b,R,E,c);else if(this._hotReloadVariablesContainer(m.variables,b.variables,c.getVariables()),c instanceof d.CustomRuntimeObject){const C=c.getChildrenContainer(),_=m,j=b;this._hotReloadRuntimeInstanceContainer(r,t,_,j,o,C)}}for(const c of f.keys()){const m=h.get(c),b=f.get(c),R=p.get(c);b&&(!m||m.name!==b.name)&&!R&&n.createObjectsFrom([b],0,0,0,!0)}}_hotReloadRuntimeInstance(r,t,o,e,a,i,s,n){let l=!1;i.x!==s.x&&(n.setX(s.x),l=!0),i.y!==s.y&&(n.setY(s.y),l=!0),i.angle!==s.angle&&(n.setAngle(s.angle),l=!0),i.zOrder!==s.zOrder&&(n.setZOrder(s.zOrder),l=!0),i.layer!==s.layer&&(n.setLayer(s.layer),l=!0),d.Base3DHandler&&d.Base3DHandler.is3D(n)&&(i.z!==s.z&&s.z!==void 0&&(n.setZ(s.z),l=!0),i.rotationX!==s.rotationX&&s.rotationX!==void 0&&(n.setRotationX(s.rotationX),l=!0),i.rotationY!==s.rotationY&&s.rotationY!==void 0&&(n.setRotationY(s.rotationY),l=!0));let h=!1;if(s.customSize?i.customSize?(i.width!==s.width&&(n.setWidth(s.width),l=!0,h=!0),i.height!==s.height&&(n.setHeight(s.height),l=!0,h=!0)):(n.setWidth(s.width),n.setHeight(s.height),l=!0,h=!0):!s.customSize&&i.customSize&&(h=!0),d.Base3DHandler&&d.Base3DHandler.is3D(n)&&(i.depth!==s.depth&&s.depth!==void 0?(n.setDepth(s.depth),l=!0,h=!0):s.depth===void 0&&i.depth!==void 0&&(h=!0)),n instanceof d.CustomRuntimeObject){const g=n.getChildrenContainer(),v=e,c=a;this._hotReloadRuntimeInstanceContainer(r,t,v,c,o,g)}this._hotReloadVariablesContainer(this._mergeObjectVariablesData(e.variables,i.initialVariables),this._mergeObjectVariablesData(a.variables,s.initialVariables),n.getVariables());const f=s.numberProperties.some(g=>{const v=g.name,c=g.value,m=i.numberProperties.filter(b=>b.name===v)[0];return!m||m.value!==c}),p=s.stringProperties.some(g=>{const v=g.name,c=g.value,m=i.stringProperties.filter(b=>b.name===v)[0];return!m||m.value!==c});(f||p||h)&&(n.extraInitializationFromInitialInstance(s),l=!0),l&&n.notifyBehaviorsObjectHotReloaded()}_mergeObjectVariablesData(r,t){if(t.length===0)return r;const o=[...r];for(const e of t){const a=o.indexOf(i=>i.name===e.name);a>=0&&(o[a]=e)}return o}static deepEqual(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;let o,e,a;if(Array.isArray(r)){if(o=r.length,o!=t.length)return!1;for(e=o;e--!=0;)if(!u.deepEqual(r[e],t[e]))return!1;return!0}if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(a=Object.keys(r),o=a.length,o!==Object.keys(t).length)return!1;for(e=o;e--!=0;)if(!Object.prototype.hasOwnProperty.call(t,a[e]))return!1;for(e=o;e--!=0;){const i=a[e];if(!u.deepEqual(r[i],t[i]))return!1}return!0}return r!==r&&t!==t}}d.HotReloader=u})(gdjs||(gdjs={}));
|
|
4
4
|
//# sourceMappingURL=hot-reloader.js.map
|