gdcore-tools 2.0.0-gd-v5.5.236-autobuild → 2.0.0-gd-v5.5.238-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 +6 -5
- package/dist/Runtime/Extensions/BBText/JsExtension.js +7 -5
- package/dist/Runtime/Extensions/BitmapText/JsExtension.js +7 -5
- package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +7 -2
- 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/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.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/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/types/project-data.d.ts +4 -0
- package/dist/lib/libGD.wasm +0 -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,+BAA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,MAAO,MAAK,SApmBT,EAAM,oCAumBb,EAAK,eACH,yBACA,EAAK,mCAEP,EAAkC,yBAA2B,KA/oBrD",
|
|
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,iBA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UAAU,SAAS,GACxB,KAAK,sBAGP,UAAU,EAAqB,CAC7B,AAAI,KAAK,cAAgB,GAEzB,MAAK,UAAU,UAAU,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,MAA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EAAS,GAMzD,WAAmB,CACjB,MAAO,MAAK,OAAS,KAAK,UAAU,kBAMtC,WAAmB,CACjB,MAAO,MAAK,QAAU,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(r){class c extends r.RuntimeBehavior{constructor(e,t,f){super(e,t,f);this._angle=0;this._xVelocity=0;this._yVelocity=0;this._angularSpeed=0;this._leftKey=!1;this._rightKey=!1;this._upKey=!1;this._downKey=!1;this._leftKeyPressedDuration=0;this._rightKeyPressedDuration=0;this._upKeyPressedDuration=0;this._downKeyPressedDuration=0;this._wasStickUsed=!1;this._stickAngle=0;this._stickForce=0;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._temporaryPointForTransformations=[0,0];this._topDownMovementHooks=[];this._allowDiagonals=t.allowDiagonals,this._acceleration=t.acceleration,this._deceleration=t.deceleration,this._maxSpeed=t.maxSpeed,this._angularMaxSpeed=t.angularMaxSpeed,this._rotateObject=t.rotateObject,this._angleOffset=t.angleOffset,this._ignoreDefaultControls=t.ignoreDefaultControls,this.setViewpoint(t.viewpoint,t.customIsometryAngle),this._movementAngleOffset=t.movementAngleOffset||0,this._useLegacyTurnBack=t.useLegacyTurnBack===void 0?!0:t.useLegacyTurnBack}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{a:this._angle,xv:this._xVelocity,yv:this._yVelocity,as:this._angularSpeed,lk:this._wasLeftKeyPressed,rk:this._wasRightKeyPressed,uk:this._wasUpKeyPressed,dk:this._wasDownKeyPressed,wsu:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.a!==void 0&&(this._angle=t.a),t.xv!==void 0&&(this._xVelocity=t.xv),t.yv!==void 0&&(this._yVelocity=t.yv),t.as!==void 0&&(this._angularSpeed=t.as),t.lk!==void 0&&(this._leftKey=t.lk),t.rk!==void 0&&(this._rightKey=t.rk),t.uk!==void 0&&(this._upKey=t.uk),t.dk!==void 0&&(this._downKey=t.dk),t.wsu!==void 0&&(this._wasStickUsed=t.wsu),t.sa!==void 0&&(this._stickAngle=t.sa),t.sf!==void 0&&(this._stickForce=t.sf),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(e,t){return e.allowDiagonals!==t.allowDiagonals&&(this._allowDiagonals=t.allowDiagonals),e.acceleration!==t.acceleration&&(this._acceleration=t.acceleration),e.deceleration!==t.deceleration&&(this._deceleration=t.deceleration),e.maxSpeed!==t.maxSpeed&&(this._maxSpeed=t.maxSpeed),e.angularMaxSpeed!==t.angularMaxSpeed&&(this._angularMaxSpeed=t.angularMaxSpeed),e.rotateObject!==t.rotateObject&&(this._rotateObject=t.rotateObject),e.angleOffset!==t.angleOffset&&(this._angleOffset=t.angleOffset),e.ignoreDefaultControls!==t.ignoreDefaultControls&&(this._ignoreDefaultControls=t.ignoreDefaultControls),(e.platformType!==t.platformType||e.customIsometryAngle!==t.customIsometryAngle)&&this.setViewpoint(t.platformType,t.customIsometryAngle),e.movementAngleOffset!==t.movementAngleOffset&&(this._movementAngleOffset=t.movementAngleOffset),!0}setViewpoint(e,t){e==="PixelIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.atan(.5)):e==="TrueIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.PI/6):e==="CustomIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(t*Math.PI/180):this._basisTransformation=null}setAcceleration(e){this._acceleration=e}getAcceleration(){return this._acceleration}setDeceleration(e){this._deceleration=e}getDeceleration(){return this._deceleration}setMaxSpeed(e){this._maxSpeed=e}getMaxSpeed(){return this._maxSpeed}setAngularMaxSpeed(e){this._angularMaxSpeed=e}getAngularMaxSpeed(){return this._angularMaxSpeed}setAngleOffset(e){this._angleOffset=e}getAngleOffset(){return this._angleOffset}allowDiagonals(e){this._allowDiagonals=e}diagonalsAllowed(){return this._allowDiagonals}setRotateObject(e){this._rotateObject=e}isObjectRotated(){return this._rotateObject}isMoving(){return this._xVelocity!==0||this._yVelocity!==0}getSpeed(){return Math.hypot(this._xVelocity,this._yVelocity)}getXVelocity(){return this._xVelocity}setXVelocity(e){this._xVelocity=e}getYVelocity(){return this._yVelocity}setYVelocity(e){this._yVelocity=e}getAngle(){return this._angle}isMovementAngleAround(e,t){return Math.abs(r.evtTools.common.angleDifference(this._angle,e))<=t}setMovementAngleOffset(e){this._movementAngleOffset=e}getMovementAngleOffset(){return this._movementAngleOffset}doStepPreEvents(e){const t=37,f=38,h=39,i=40;this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(t)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(h)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(i)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(f));const o=this.owner.getElapsedTime();this._leftKey?this._leftKeyPressedDuration+=o:this._leftKeyPressedDuration=0,this._rightKey?this._rightKeyPressedDuration+=o:this._rightKeyPressedDuration=0,this._downKey?this._downKeyPressedDuration+=o:this._downKeyPressedDuration=0,this._upKey?this._upKeyPressedDuration+=o:this._upKeyPressedDuration=0;let s=-1;this._allowDiagonals?this._upKey&&!this._downKey?this._leftKey&&!this._rightKey?s=5:!this._leftKey&&this._rightKey?s=7:s=6:!this._upKey&&this._downKey?this._leftKey&&!this._rightKey?s=3:!this._leftKey&&this._rightKey?s=1:s=2:this._leftKey&&!this._rightKey?s=4:!this._leftKey&&this._rightKey&&(s=0):(this._upKey&&!this._downKey?s=6:!this._upKey&&this._downKey&&(s=2),this._leftKey&&!this._rightKey&&(this._upKey===this._downKey||this._upKey&&this._leftKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._leftKeyPressedDuration<this._downKeyPressedDuration)?s=4:this._rightKey&&!this._leftKey&&(this._upKey===this._downKey||this._upKey&&this._rightKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._rightKeyPressedDuration<this._downKeyPressedDuration)&&(s=0));const a=r.TopDownMovementRuntimeBehavior._topDownMovementHookContext;for(const n of this._topDownMovementHooks)a._setDirection(s),s=n.overrideDirection(a);a._setDirection(s);for(const n of this._topDownMovementHooks)n.beforeSpeedUpdate(a);const l=this.owner,p=this.owner.getElapsedTime()/1e3,x=this._xVelocity,P=this._yVelocity;this._wasStickUsed=!1;let _=0,y=0,g=!1,m=0;if(s!==-1?(g=!0,_=(s+this._movementAngleOffset/45)*Math.PI/4,y=s*45+this._movementAngleOffset,m=this._maxSpeed):this._stickForce!==0?(g=!0,this._allowDiagonals||(this._stickAngle=90*Math.floor((this._stickAngle+45)/90)),y=this._stickAngle+this._movementAngleOffset,_=y*Math.PI/180,m=this._maxSpeed*this._stickForce,this._wasStickUsed=!0):(this._yVelocity!==0||this._xVelocity!==0)&&(g=!0,_=Math.atan2(this._yVelocity,this._xVelocity),y=_*180/Math.PI),g){let n=Math.cos(_),u=Math.sin(_);(n===-1||n===1)&&(u=0),(u===-1||u===1)&&(n=0);const D=this._useLegacyTurnBack?c.getLegacyAcceleratedSpeed:c.getAcceleratedSpeed;let M=Math.hypot(this._xVelocity,this._yVelocity);const v=this._xVelocity*n+this._yVelocity*u;v<0&&(M=v);const k=D(M,m,this._maxSpeed,this._acceleration,this._deceleration,p);this._xVelocity=k*n,this._yVelocity=k*u}const d=this._xVelocity*this._xVelocity+this._yVelocity*this._yVelocity;if(d>this._maxSpeed*this._maxSpeed){const n=this._maxSpeed/Math.sqrt(d);this._xVelocity*=n,this._yVelocity*=n}this._angularSpeed=this._angularMaxSpeed;for(const n of this._topDownMovementHooks)n.beforePositionUpdate(a);const K=(x+this._xVelocity)/2*p,w=(P+this._yVelocity)/2*p;if(this._basisTransformation===null)l.setX(l.getX()+K),l.setY(l.getY()+w);else{const n=this._temporaryPointForTransformations;n[0]=K,n[1]=w,this._basisTransformation.toScreen(n,n),l.setX(l.getX()+n[0]),l.setY(l.getY()+n[1])}(this._xVelocity!==0||this._yVelocity!==0)&&(this._angle=y,this._rotateObject&&l.rotateTowardAngle(y+this._angleOffset,this._angularSpeed)),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._upKey=!1,this._downKey=!1,this._stickForce=0)}static getAcceleratedSpeed(e,t,f,h,i,o){let s=e;const a=Math.max(h,i);return t<0?e<=t?s=Math.min(t,e+a*o):e<=0?s-=Math.max(-f,h*o):s=Math.max(t,e-a*o):t>0?e>=t?s=Math.max(t,e-a*o):e>=0?s=Math.min(f,e+h*o):s=Math.min(t,e+a*o):(e<0&&(s=Math.min(e+i*o,0)),e>0&&(s=Math.max(e-i*o,0))),s}static getLegacyAcceleratedSpeed(e,t,f,h,i,o){let s=e;return t<0?e<=t?s=Math.min(t,e+i*o):e<=0?s-=Math.max(-f,h*o):s=Math.max(t,e-i*o):t>0?e>=t?s=Math.max(t,e-i*o):e>=0?s=Math.min(f,e+h*o):s=Math.min(t,e+i*o):(e<0&&(s=Math.min(e+i*o,0)),e>0&&(s=Math.max(e-i*o,0))),s}simulateControl(e){e==="Left"?this._leftKey=!0:e==="Right"?this._rightKey=!0:e==="Up"?this._upKey=!0:e==="Down"&&(this._downKey=!0)}ignoreDefaultControls(e){this._ignoreDefaultControls=e}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateStick(e,t){this._stickAngle=e%360,this._stickForce=Math.max(0,Math.min(1,t))}isUsingControl(e){return e==="Left"?this._leftKeyPressedDuration>0:e==="Right"?this._rightKeyPressedDuration>0:e==="Up"?this._upKeyPressedDuration>0:e==="Down"?this._downKeyPressedDuration>0:e==="Stick"?this._wasStickUsed:!1}getLastStickInputAngle(){return this._stickAngle}registerHook(e){this._topDownMovementHooks.push(e)}}r.TopDownMovementRuntimeBehavior=c,function(f){class T{constructor(){this.direction=-1}getDirection(){return this.direction}_setDirection(i){this.direction=i}}f.TopDownMovementHookContext=T,f._topDownMovementHookContext=new r.TopDownMovementRuntimeBehavior.TopDownMovementHookContext;class t{constructor(i){if(i<=0||i>=Math.PI/4)throw new RangeError("An isometry angle must be in ]0; pi/4] but was: "+i);const o=Math.asin(Math.tan(i)),s=Math.sin(o),a=Math.cos(Math.PI/4),l=a;this._screen=[[a,-l],[s*l,s*a]]}toScreen(i,o){const s=this._screen[0][0]*i[0]+this._screen[0][1]*i[1],a=this._screen[1][0]*i[0]+this._screen[1][1]*i[1];o[0]=s,o[1]=a}}f.IsometryTransformation=t}(c=r.TopDownMovementRuntimeBehavior||(r.TopDownMovementRuntimeBehavior={})),r.registerBehavior("TopDownMovementBehavior::TopDownMovementBehavior",r.TopDownMovementRuntimeBehavior)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(l){class u extends l.RuntimeBehavior{constructor(e,t,f){super(e,t,f);this._angle=0;this._xVelocity=0;this._yVelocity=0;this._angularSpeed=0;this._leftKey=!1;this._rightKey=!1;this._upKey=!1;this._downKey=!1;this._leftKeyPressedDuration=0;this._rightKeyPressedDuration=0;this._upKeyPressedDuration=0;this._downKeyPressedDuration=0;this._wasStickUsed=!1;this._stickAngle=0;this._stickForce=0;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._temporaryPointForTransformations=[0,0];this._topDownMovementHooks=[];this._allowDiagonals=t.allowDiagonals,this._acceleration=t.acceleration,this._deceleration=t.deceleration,this._maxSpeed=t.maxSpeed,this._angularMaxSpeed=t.angularMaxSpeed,this._rotateObject=t.rotateObject,this._angleOffset=t.angleOffset,this._ignoreDefaultControls=t.ignoreDefaultControls,this.setViewpoint(t.viewpoint,t.customIsometryAngle),this._movementAngleOffset=t.movementAngleOffset||0,this._useLegacyTurnBack=t.useLegacyTurnBack===void 0?!0:t.useLegacyTurnBack}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{a:this._angle,xv:this._xVelocity,yv:this._yVelocity,as:this._angularSpeed,lk:this._wasLeftKeyPressed,rk:this._wasRightKeyPressed,uk:this._wasUpKeyPressed,dk:this._wasDownKeyPressed,wsu:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.a!==void 0&&(this._angle=t.a),t.xv!==void 0&&(this._xVelocity=t.xv),t.yv!==void 0&&(this._yVelocity=t.yv),t.as!==void 0&&(this._angularSpeed=t.as),t.lk!==void 0&&(this._leftKey=t.lk),t.rk!==void 0&&(this._rightKey=t.rk),t.uk!==void 0&&(this._upKey=t.uk),t.dk!==void 0&&(this._downKey=t.dk),t.wsu!==void 0&&(this._wasStickUsed=t.wsu),t.sa!==void 0&&(this._stickAngle=t.sa),t.sf!==void 0&&(this._stickForce=t.sf),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(e,t){return e.allowDiagonals!==t.allowDiagonals&&(this._allowDiagonals=t.allowDiagonals),e.acceleration!==t.acceleration&&(this._acceleration=t.acceleration),e.deceleration!==t.deceleration&&(this._deceleration=t.deceleration),e.maxSpeed!==t.maxSpeed&&(this._maxSpeed=t.maxSpeed),e.angularMaxSpeed!==t.angularMaxSpeed&&(this._angularMaxSpeed=t.angularMaxSpeed),e.rotateObject!==t.rotateObject&&(this._rotateObject=t.rotateObject),e.angleOffset!==t.angleOffset&&(this._angleOffset=t.angleOffset),e.ignoreDefaultControls!==t.ignoreDefaultControls&&(this._ignoreDefaultControls=t.ignoreDefaultControls),(e.platformType!==t.platformType||e.customIsometryAngle!==t.customIsometryAngle)&&this.setViewpoint(t.platformType,t.customIsometryAngle),e.movementAngleOffset!==t.movementAngleOffset&&(this._movementAngleOffset=t.movementAngleOffset),!0}setViewpoint(e,t){e==="PixelIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.atan(.5)):e==="TrueIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.PI/6):e==="CustomIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(t*Math.PI/180):this._basisTransformation=null}setAcceleration(e){this._acceleration=e}getAcceleration(){return this._acceleration}setDeceleration(e){this._deceleration=e}getDeceleration(){return this._deceleration}setMaxSpeed(e){this._maxSpeed=e}getMaxSpeed(){return this._maxSpeed}setAngularMaxSpeed(e){this._angularMaxSpeed=e}getAngularMaxSpeed(){return this._angularMaxSpeed}setAngleOffset(e){this._angleOffset=e}getAngleOffset(){return this._angleOffset}allowDiagonals(e){this._allowDiagonals=e}diagonalsAllowed(){return this._allowDiagonals}setRotateObject(e){this._rotateObject=e}isObjectRotated(){return this._rotateObject}isMoving(){return this._xVelocity!==0||this._yVelocity!==0}getSpeed(){return Math.hypot(this._xVelocity,this._yVelocity)}getXVelocity(){return this._xVelocity}setXVelocity(e){this._xVelocity=e}getYVelocity(){return this._yVelocity}setYVelocity(e){this._yVelocity=e}getAngle(){return this._angle}isMovementAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this._angle,e))<=t}setMovementAngleOffset(e){this._movementAngleOffset=e}getMovementAngleOffset(){return this._movementAngleOffset}doStepPreEvents(e){const t=37,f=38,h=39,a=40;this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(t)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(h)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(a)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(f));const n=this.owner.getElapsedTime();this._leftKey?this._leftKeyPressedDuration+=n:this._leftKeyPressedDuration=0,this._rightKey?this._rightKeyPressedDuration+=n:this._rightKeyPressedDuration=0,this._downKey?this._downKeyPressedDuration+=n:this._downKeyPressedDuration=0,this._upKey?this._upKeyPressedDuration+=n:this._upKeyPressedDuration=0;let s=-1;this._allowDiagonals?this._upKey&&!this._downKey?this._leftKey&&!this._rightKey?s=5:!this._leftKey&&this._rightKey?s=7:s=6:!this._upKey&&this._downKey?this._leftKey&&!this._rightKey?s=3:!this._leftKey&&this._rightKey?s=1:s=2:this._leftKey&&!this._rightKey?s=4:!this._leftKey&&this._rightKey&&(s=0):(this._upKey&&!this._downKey?s=6:!this._upKey&&this._downKey&&(s=2),this._leftKey&&!this._rightKey&&(this._upKey===this._downKey||this._upKey&&this._leftKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._leftKeyPressedDuration<this._downKeyPressedDuration)?s=4:this._rightKey&&!this._leftKey&&(this._upKey===this._downKey||this._upKey&&this._rightKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._rightKeyPressedDuration<this._downKeyPressedDuration)&&(s=0));const o=l.TopDownMovementRuntimeBehavior._topDownMovementHookContext;for(const i of this._topDownMovementHooks)o._setDirection(s),s=i.overrideDirection(o);o._setDirection(s);for(const i of this._topDownMovementHooks)i.beforeSpeedUpdate(o);const r=this.owner,g=this.owner.getElapsedTime()/1e3,x=this._xVelocity,D=this._yVelocity;this._wasStickUsed=!1;let _=0,y=0,d=!1,p=0;if(s!==-1?(d=!0,_=(s+this._movementAngleOffset/45)*Math.PI/4,y=s*45+this._movementAngleOffset,p=this._maxSpeed):this._stickForce!==0?(d=!0,this._allowDiagonals||(this._stickAngle=90*Math.floor((this._stickAngle+45)/90)),y=this._stickAngle+this._movementAngleOffset,_=y*Math.PI/180,p=this._maxSpeed*this._stickForce,this._wasStickUsed=!0):(this._yVelocity!==0||this._xVelocity!==0)&&(d=!0,_=Math.atan2(this._yVelocity,this._xVelocity),y=_*180/Math.PI),d){let i=Math.cos(_),c=Math.sin(_);(i===-1||i===1)&&(c=0),(c===-1||c===1)&&(i=0);let v=Math.hypot(this._xVelocity,this._yVelocity);const M=this._xVelocity*i+this._yVelocity*c;M<0&&(v=M);const k=u.getAcceleratedSpeed(v,p,this._maxSpeed,this._acceleration,this._deceleration,g,this._useLegacyTurnBack);this._xVelocity=k*i,this._yVelocity=k*c}const m=this._xVelocity*this._xVelocity+this._yVelocity*this._yVelocity;if(m>this._maxSpeed*this._maxSpeed){const i=this._maxSpeed/Math.sqrt(m);this._xVelocity*=i,this._yVelocity*=i}this._angularSpeed=this._angularMaxSpeed;for(const i of this._topDownMovementHooks)i.beforePositionUpdate(o);const K=(x+this._xVelocity)/2*g,w=(D+this._yVelocity)/2*g;if(this._basisTransformation===null)r.setX(r.getX()+K),r.setY(r.getY()+w);else{const i=this._temporaryPointForTransformations;i[0]=K,i[1]=w,this._basisTransformation.toScreen(i,i),r.setX(r.getX()+i[0]),r.setY(r.getY()+i[1])}(this._xVelocity!==0||this._yVelocity!==0)&&(this._angle=y,this._rotateObject&&r.rotateTowardAngle(y+this._angleOffset,this._angularSpeed)),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._upKey=!1,this._downKey=!1,this._stickForce=0)}static getAcceleratedSpeed(e,t,f,h,a,n,s=!1){let o=e;const r=s?h:Math.max(h,a);return t<0?e<=t?o=Math.min(t,e+r*n):e<=0?o-=Math.max(-f,h*n):o=Math.max(t,e-r*n):t>0?e>=t?o=Math.max(t,e-r*n):e>=0?o=Math.min(f,e+h*n):o=Math.min(t,e+r*n):(e<0&&(o=Math.min(e+a*n,0)),e>0&&(o=Math.max(e-a*n,0))),o}simulateControl(e){e==="Left"?this._leftKey=!0:e==="Right"?this._rightKey=!0:e==="Up"?this._upKey=!0:e==="Down"&&(this._downKey=!0)}ignoreDefaultControls(e){this._ignoreDefaultControls=e}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateStick(e,t){this._stickAngle=e%360,this._stickForce=Math.max(0,Math.min(1,t))}isUsingControl(e){return e==="Left"?this._leftKeyPressedDuration>0:e==="Right"?this._rightKeyPressedDuration>0:e==="Up"?this._upKeyPressedDuration>0:e==="Down"?this._downKeyPressedDuration>0:e==="Stick"?this._wasStickUsed:!1}getLastStickInputAngle(){return this._stickAngle}registerHook(e){this._topDownMovementHooks.push(e)}}l.TopDownMovementRuntimeBehavior=u,function(f){class P{constructor(){this.direction=-1}getDirection(){return this.direction}_setDirection(a){this.direction=a}}f.TopDownMovementHookContext=P,f._topDownMovementHookContext=new l.TopDownMovementRuntimeBehavior.TopDownMovementHookContext;class t{constructor(a){if(a<=0||a>=Math.PI/4)throw new RangeError("An isometry angle must be in ]0; pi/4] but was: "+a);const n=Math.asin(Math.tan(a)),s=Math.sin(n),o=Math.cos(Math.PI/4),r=o;this._screen=[[o,-r],[s*r,s*o]]}toScreen(a,n){const s=this._screen[0][0]*a[0]+this._screen[0][1]*a[1],o=this._screen[1][0]*a[0]+this._screen[1][1]*a[1];n[0]=s,n[1]=o}}f.IsometryTransformation=t}(u=l.TopDownMovementRuntimeBehavior||(l.TopDownMovementRuntimeBehavior={})),l.registerBehavior("TopDownMovementBehavior::TopDownMovementBehavior",l.TopDownMovementRuntimeBehavior)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=topdownmovementruntimebehavior.js.map
|
package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nGDevelop - Top-down movement Behavior Extension\nCopyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n interface TopDownMovementNetworkSyncDataType {\n a: float;\n xv: float;\n yv: float;\n as: float;\n lk: boolean;\n rk: boolean;\n uk: boolean;\n dk: boolean;\n wsu: boolean;\n sa: float;\n sf: float;\n }\n\n export interface TopDownMovementNetworkSyncData\n extends BehaviorNetworkSyncData {\n props: TopDownMovementNetworkSyncDataType;\n }\n /**\n * Allows an object to move in 4 or 8 directions, with customizable speed, accelerations\n * and rotation.\n */\n export class TopDownMovementRuntimeBehavior extends gdjs.RuntimeBehavior {\n //Behavior configuration:\n private _allowDiagonals: boolean;\n private _acceleration: float;\n private _deceleration: float;\n private _maxSpeed: float;\n private _angularMaxSpeed: float;\n private _rotateObject: boolean;\n private _angleOffset: float;\n private _ignoreDefaultControls: boolean;\n private _movementAngleOffset: float;\n private _useLegacyTurnBack: boolean;\n\n /** The latest angle of movement, in degrees. */\n private _angle: float = 0;\n\n //Attributes used when moving\n private _xVelocity: float = 0;\n private _yVelocity: float = 0;\n private _angularSpeed: float = 0;\n\n // Inputs\n private _leftKey: boolean = false;\n private _rightKey: boolean = false;\n private _upKey: boolean = false;\n private _downKey: boolean = false;\n private _leftKeyPressedDuration: float = 0;\n private _rightKeyPressedDuration: float = 0;\n private _upKeyPressedDuration: float = 0;\n private _downKeyPressedDuration: float = 0;\n private _wasStickUsed: boolean = false;\n private _stickAngle: float = 0;\n private _stickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n _dontClearInputsBetweenFrames: boolean = false;\n // This is useful when the object is synchronized over the network,\n // object is controlled by the network and we want to ensure the current player\n // cannot control it.\n _ignoreDefaultControlsAsSyncedByNetwork: boolean = false;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasUpKeyPressed: boolean = false;\n private _wasDownKeyPressed: boolean = false;\n\n // @ts-ignore The setter \"setViewpoint\" is not detected as an affectation.\n private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;\n private _temporaryPointForTransformations: FloatPoint = [0, 0];\n\n private _topDownMovementHooks: Array<gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook> =\n [];\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._allowDiagonals = behaviorData.allowDiagonals;\n this._acceleration = behaviorData.acceleration;\n this._deceleration = behaviorData.deceleration;\n this._maxSpeed = behaviorData.maxSpeed;\n this._angularMaxSpeed = behaviorData.angularMaxSpeed;\n this._rotateObject = behaviorData.rotateObject;\n this._angleOffset = behaviorData.angleOffset;\n this._ignoreDefaultControls = behaviorData.ignoreDefaultControls;\n this.setViewpoint(\n behaviorData.viewpoint,\n behaviorData.customIsometryAngle\n );\n this._movementAngleOffset = behaviorData.movementAngleOffset || 0;\n this._useLegacyTurnBack =\n behaviorData.useLegacyTurnBack === undefined\n ? true\n : behaviorData.useLegacyTurnBack;\n }\n\n getNetworkSyncData(): TopDownMovementNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._dontClearInputsBetweenFrames = false;\n this._ignoreDefaultControlsAsSyncedByNetwork = false;\n\n return {\n ...super.getNetworkSyncData(),\n props: {\n a: this._angle,\n xv: this._xVelocity,\n yv: this._yVelocity,\n as: this._angularSpeed,\n lk: this._wasLeftKeyPressed,\n rk: this._wasRightKeyPressed,\n uk: this._wasUpKeyPressed,\n dk: this._wasDownKeyPressed,\n wsu: this._wasStickUsed,\n sa: this._stickAngle,\n sf: this._stickForce,\n },\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TopDownMovementNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (behaviorSpecificProps.a !== undefined) {\n this._angle = behaviorSpecificProps.a;\n }\n if (behaviorSpecificProps.xv !== undefined) {\n this._xVelocity = behaviorSpecificProps.xv;\n }\n if (behaviorSpecificProps.yv !== undefined) {\n this._yVelocity = behaviorSpecificProps.yv;\n }\n if (behaviorSpecificProps.as !== undefined) {\n this._angularSpeed = behaviorSpecificProps.as;\n }\n if (behaviorSpecificProps.lk !== undefined) {\n this._leftKey = behaviorSpecificProps.lk;\n }\n if (behaviorSpecificProps.rk !== undefined) {\n this._rightKey = behaviorSpecificProps.rk;\n }\n if (behaviorSpecificProps.uk !== undefined) {\n this._upKey = behaviorSpecificProps.uk;\n }\n if (behaviorSpecificProps.dk !== undefined) {\n this._downKey = behaviorSpecificProps.dk;\n }\n if (behaviorSpecificProps.wsu !== undefined) {\n this._wasStickUsed = behaviorSpecificProps.wsu;\n }\n if (behaviorSpecificProps.sa !== undefined) {\n this._stickAngle = behaviorSpecificProps.sa;\n }\n if (behaviorSpecificProps.sf !== undefined) {\n this._stickForce = behaviorSpecificProps.sf;\n }\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n // And we are not using the default controls.\n this._ignoreDefaultControlsAsSyncedByNetwork = true;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.allowDiagonals !== newBehaviorData.allowDiagonals) {\n this._allowDiagonals = newBehaviorData.allowDiagonals;\n }\n if (oldBehaviorData.acceleration !== newBehaviorData.acceleration) {\n this._acceleration = newBehaviorData.acceleration;\n }\n if (oldBehaviorData.deceleration !== newBehaviorData.deceleration) {\n this._deceleration = newBehaviorData.deceleration;\n }\n if (oldBehaviorData.maxSpeed !== newBehaviorData.maxSpeed) {\n this._maxSpeed = newBehaviorData.maxSpeed;\n }\n if (oldBehaviorData.angularMaxSpeed !== newBehaviorData.angularMaxSpeed) {\n this._angularMaxSpeed = newBehaviorData.angularMaxSpeed;\n }\n if (oldBehaviorData.rotateObject !== newBehaviorData.rotateObject) {\n this._rotateObject = newBehaviorData.rotateObject;\n }\n if (oldBehaviorData.angleOffset !== newBehaviorData.angleOffset) {\n this._angleOffset = newBehaviorData.angleOffset;\n }\n if (\n oldBehaviorData.ignoreDefaultControls !==\n newBehaviorData.ignoreDefaultControls\n ) {\n this._ignoreDefaultControls = newBehaviorData.ignoreDefaultControls;\n }\n if (\n oldBehaviorData.platformType !== newBehaviorData.platformType ||\n oldBehaviorData.customIsometryAngle !==\n newBehaviorData.customIsometryAngle\n ) {\n this.setViewpoint(\n newBehaviorData.platformType,\n newBehaviorData.customIsometryAngle\n );\n }\n if (\n oldBehaviorData.movementAngleOffset !==\n newBehaviorData.movementAngleOffset\n ) {\n this._movementAngleOffset = newBehaviorData.movementAngleOffset;\n }\n return true;\n }\n\n setViewpoint(viewpoint: string, customIsometryAngle: float): void {\n if (viewpoint === 'PixelIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.atan(0.5)\n );\n } else if (viewpoint === 'TrueIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.PI / 6\n );\n } else if (viewpoint === 'CustomIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n (customIsometryAngle * Math.PI) / 180\n );\n } else {\n this._basisTransformation = null;\n }\n }\n\n setAcceleration(acceleration: float): void {\n this._acceleration = acceleration;\n }\n\n getAcceleration() {\n return this._acceleration;\n }\n\n setDeceleration(deceleration: float): void {\n this._deceleration = deceleration;\n }\n\n getDeceleration() {\n return this._deceleration;\n }\n\n setMaxSpeed(maxSpeed: float): void {\n this._maxSpeed = maxSpeed;\n }\n\n getMaxSpeed() {\n return this._maxSpeed;\n }\n\n setAngularMaxSpeed(angularMaxSpeed: float): void {\n this._angularMaxSpeed = angularMaxSpeed;\n }\n\n getAngularMaxSpeed() {\n return this._angularMaxSpeed;\n }\n\n setAngleOffset(angleOffset: float): void {\n this._angleOffset = angleOffset;\n }\n\n getAngleOffset() {\n return this._angleOffset;\n }\n\n allowDiagonals(allow: boolean) {\n this._allowDiagonals = allow;\n }\n\n diagonalsAllowed() {\n return this._allowDiagonals;\n }\n\n setRotateObject(allow: boolean): void {\n this._rotateObject = allow;\n }\n\n isObjectRotated(): boolean {\n return this._rotateObject;\n }\n\n isMoving(): boolean {\n return this._xVelocity !== 0 || this._yVelocity !== 0;\n }\n\n getSpeed(): float {\n return Math.hypot(this._xVelocity, this._yVelocity);\n }\n\n getXVelocity(): float {\n return this._xVelocity;\n }\n\n setXVelocity(velocityX: float): void {\n this._xVelocity = velocityX;\n }\n\n getYVelocity(): float {\n return this._yVelocity;\n }\n\n setYVelocity(velocityY: float): void {\n this._yVelocity = velocityY;\n }\n\n getAngle(): float {\n return this._angle;\n }\n\n isMovementAngleAround(degreeAngle: float, tolerance: float) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(this._angle, degreeAngle)\n ) <= tolerance\n );\n }\n\n setMovementAngleOffset(movementAngleOffset: float): void {\n this._movementAngleOffset = movementAngleOffset;\n }\n\n getMovementAngleOffset() {\n return this._movementAngleOffset;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const LEFTKEY = 37;\n const UPKEY = 38;\n const RIGHTKEY = 39;\n const DOWNKEY = 40;\n\n //Get the player input:\n this._leftKey ||\n (this._leftKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(LEFTKEY));\n this._rightKey ||\n (this._rightKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(RIGHTKEY));\n this._downKey ||\n (this._downKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(DOWNKEY));\n this._upKey ||\n (this._upKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(UPKEY));\n\n const elapsedTime = this.owner.getElapsedTime();\n\n if (!this._leftKey) {\n this._leftKeyPressedDuration = 0;\n } else {\n this._leftKeyPressedDuration += elapsedTime;\n }\n if (!this._rightKey) {\n this._rightKeyPressedDuration = 0;\n } else {\n this._rightKeyPressedDuration += elapsedTime;\n }\n if (!this._downKey) {\n this._downKeyPressedDuration = 0;\n } else {\n this._downKeyPressedDuration += elapsedTime;\n }\n if (!this._upKey) {\n this._upKeyPressedDuration = 0;\n } else {\n this._upKeyPressedDuration += elapsedTime;\n }\n\n let direction = -1;\n if (!this._allowDiagonals) {\n if (this._upKey && !this._downKey) {\n direction = 6;\n } else if (!this._upKey && this._downKey) {\n direction = 2;\n }\n // when 2 keys are pressed for diagonals the most recently pressed win\n if (\n this._leftKey &&\n !this._rightKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._leftKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._leftKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 4;\n } else if (\n this._rightKey &&\n !this._leftKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._rightKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._rightKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 0;\n }\n } else {\n if (this._upKey && !this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 5;\n } else if (!this._leftKey && this._rightKey) {\n direction = 7;\n } else {\n direction = 6;\n }\n } else if (!this._upKey && this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 3;\n } else if (!this._leftKey && this._rightKey) {\n direction = 1;\n } else {\n direction = 2;\n }\n } else {\n if (this._leftKey && !this._rightKey) {\n direction = 4;\n } else if (!this._leftKey && this._rightKey) {\n direction = 0;\n }\n }\n }\n\n const hookContext =\n gdjs.TopDownMovementRuntimeBehavior._topDownMovementHookContext;\n for (const topDownMovementHook of this._topDownMovementHooks) {\n hookContext._setDirection(direction);\n direction = topDownMovementHook.overrideDirection(hookContext);\n }\n hookContext._setDirection(direction);\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforeSpeedUpdate(hookContext);\n }\n\n const object = this.owner;\n const timeDelta = this.owner.getElapsedTime() / 1000;\n const previousVelocityX = this._xVelocity;\n const previousVelocityY = this._yVelocity;\n this._wasStickUsed = false;\n\n // These 4 values are not actually used.\n // JavaScript doesn't allow to declare\n // variables without assigning them a value.\n let directionInRad = 0;\n let directionInDeg = 0;\n\n let isMoving = false;\n let targetedSpeed = 0;\n // Update the speed of the object:\n if (direction !== -1) {\n isMoving = true;\n directionInRad =\n ((direction + this._movementAngleOffset / 45) * Math.PI) / 4.0;\n directionInDeg = direction * 45 + this._movementAngleOffset;\n targetedSpeed = this._maxSpeed;\n } else if (this._stickForce !== 0) {\n isMoving = true;\n if (!this._allowDiagonals) {\n this._stickAngle = 90 * Math.floor((this._stickAngle + 45) / 90);\n }\n directionInDeg = this._stickAngle + this._movementAngleOffset;\n directionInRad = (directionInDeg * Math.PI) / 180;\n targetedSpeed = this._maxSpeed * this._stickForce;\n\n this._wasStickUsed = true;\n } else if (this._yVelocity !== 0 || this._xVelocity !== 0) {\n isMoving = true;\n directionInRad = Math.atan2(this._yVelocity, this._xVelocity);\n directionInDeg = (directionInRad * 180.0) / Math.PI;\n }\n if (isMoving) {\n // This makes the trigo resilient to rounding errors on directionInRad.\n let cos = Math.cos(directionInRad);\n let sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n\n const getAcceleratedSpeed = this._useLegacyTurnBack\n ? TopDownMovementRuntimeBehavior.getLegacyAcceleratedSpeed\n : TopDownMovementRuntimeBehavior.getAcceleratedSpeed;\n\n let currentSpeed = Math.hypot(this._xVelocity, this._yVelocity);\n const dotProduct = this._xVelocity * cos + this._yVelocity * sin;\n if (dotProduct < 0) {\n // The object is turning back.\n // Keep the negative velocity projected on the new direction.\n currentSpeed = dotProduct;\n }\n const speed = getAcceleratedSpeed(\n currentSpeed,\n targetedSpeed,\n this._maxSpeed,\n this._acceleration,\n this._deceleration,\n timeDelta\n );\n this._xVelocity = speed * cos;\n this._yVelocity = speed * sin;\n }\n\n const squaredSpeed =\n this._xVelocity * this._xVelocity + this._yVelocity * this._yVelocity;\n if (squaredSpeed > this._maxSpeed * this._maxSpeed) {\n const ratio = this._maxSpeed / Math.sqrt(squaredSpeed);\n this._xVelocity *= ratio;\n this._yVelocity *= ratio;\n }\n\n // No acceleration for angular speed for now.\n this._angularSpeed = this._angularMaxSpeed;\n\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforePositionUpdate(hookContext);\n }\n\n // Position object.\n // This is a Verlet integration considering the acceleration as constant.\n // If you expand deltaX or deltaY, it gives, thanks to the usage of both\n // the old and the new velocity:\n // \"velocity * timeDelta + acceleration * timeDelta^2 / 2\".\n //\n // The acceleration is not actually always constant, particularly with a gamepad,\n // but the error is multiplied by timDelta^3. So, it shouldn't matter much.\n const deltaX = ((previousVelocityX + this._xVelocity) / 2) * timeDelta;\n const deltaY = ((previousVelocityY + this._yVelocity) / 2) * timeDelta;\n if (this._basisTransformation === null) {\n // Top-down viewpoint\n object.setX(object.getX() + deltaX);\n object.setY(object.getY() + deltaY);\n } else {\n // Isometry viewpoint\n const point = this._temporaryPointForTransformations;\n point[0] = deltaX;\n point[1] = deltaY;\n this._basisTransformation.toScreen(point, point);\n object.setX(object.getX() + point[0]);\n object.setY(object.getY() + point[1]);\n }\n\n // Also update angle if needed.\n if (this._xVelocity !== 0 || this._yVelocity !== 0) {\n this._angle = directionInDeg;\n if (this._rotateObject) {\n object.rotateTowardAngle(\n directionInDeg + this._angleOffset,\n this._angularSpeed\n );\n }\n }\n\n this._wasLeftKeyPressed = this._leftKey;\n this._wasRightKeyPressed = this._rightKey;\n this._wasUpKeyPressed = this._upKey;\n this._wasDownKeyPressed = this._downKey;\n if (!this._dontClearInputsBetweenFrames) {\n this._leftKey = false;\n this._rightKey = false;\n this._upKey = false;\n this._downKey = false;\n this._stickForce = 0;\n }\n }\n\n private static getAcceleratedSpeed(\n currentSpeed: float,\n targetedSpeed: float,\n speedMax: float,\n acceleration: float,\n deceleration: float,\n timeDelta: float\n ): float {\n let newSpeed = currentSpeed;\n const turningBackAcceleration = Math.max(acceleration, deceleration);\n if (targetedSpeed < 0) {\n if (currentSpeed <= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed <= 0) {\n // Accelerate\n newSpeed -= Math.max(-speedMax, acceleration * timeDelta);\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n }\n } else if (targetedSpeed > 0) {\n if (currentSpeed >= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed >= 0) {\n // Accelerate\n newSpeed = Math.min(\n speedMax,\n currentSpeed + acceleration * timeDelta\n );\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n }\n } else {\n // Decelerate and stop.\n if (currentSpeed < 0) {\n newSpeed = Math.min(currentSpeed + deceleration * timeDelta, 0);\n }\n if (currentSpeed > 0) {\n newSpeed = Math.max(currentSpeed - deceleration * timeDelta, 0);\n }\n }\n return newSpeed;\n }\n\n private static getLegacyAcceleratedSpeed(\n currentSpeed: float,\n targetedSpeed: float,\n speedMax: float,\n acceleration: float,\n deceleration: float,\n timeDelta: float\n ): float {\n let newSpeed = currentSpeed;\n if (targetedSpeed < 0) {\n if (currentSpeed <= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + deceleration * timeDelta\n );\n } else if (currentSpeed <= 0) {\n // Accelerate\n newSpeed -= Math.max(-speedMax, acceleration * timeDelta);\n } else {\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - deceleration * timeDelta\n );\n }\n } else if (targetedSpeed > 0) {\n if (currentSpeed >= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - deceleration * timeDelta\n );\n } else if (currentSpeed >= 0) {\n // Accelerate\n newSpeed = Math.min(\n speedMax,\n currentSpeed + acceleration * timeDelta\n );\n } else {\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + deceleration * timeDelta\n );\n }\n } else {\n // Decelerate and stop.\n if (currentSpeed < 0) {\n newSpeed = Math.min(currentSpeed + deceleration * timeDelta, 0);\n }\n if (currentSpeed > 0) {\n newSpeed = Math.max(currentSpeed - deceleration * timeDelta, 0);\n }\n }\n return newSpeed;\n }\n\n simulateControl(input: string) {\n if (input === 'Left') {\n this._leftKey = true;\n } else if (input === 'Right') {\n this._rightKey = true;\n } else if (input === 'Up') {\n this._upKey = true;\n } else if (input === 'Down') {\n this._downKey = true;\n }\n }\n\n ignoreDefaultControls(ignore: boolean) {\n this._ignoreDefaultControls = ignore;\n }\n\n shouldIgnoreDefaultControls() {\n return (\n this._ignoreDefaultControls ||\n this._ignoreDefaultControlsAsSyncedByNetwork\n );\n }\n\n simulateLeftKey() {\n this._leftKey = true;\n }\n\n simulateRightKey() {\n this._rightKey = true;\n }\n\n simulateUpKey() {\n this._upKey = true;\n }\n\n simulateDownKey() {\n this._downKey = true;\n }\n\n simulateStick(stickAngle: float, stickForce: float) {\n this._stickAngle = stickAngle % 360;\n this._stickForce = Math.max(0, Math.min(1, stickForce));\n }\n\n /**.\n * @param input The control to be tested [Left,Right,Up,Down,Stick].\n * @returns true if the key was used since the last `doStepPreEvents` call.\n */\n isUsingControl(input: string): boolean {\n if (input === 'Left') {\n return this._leftKeyPressedDuration > 0;\n }\n if (input === 'Right') {\n return this._rightKeyPressedDuration > 0;\n }\n if (input === 'Up') {\n return this._upKeyPressedDuration > 0;\n }\n if (input === 'Down') {\n return this._downKeyPressedDuration > 0;\n }\n if (input === 'Stick') {\n return this._wasStickUsed;\n }\n return false;\n }\n\n getLastStickInputAngle() {\n return this._stickAngle;\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(\n hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook\n ) {\n this._topDownMovementHooks.push(hook);\n }\n }\n\n export namespace TopDownMovementRuntimeBehavior {\n export class TopDownMovementHookContext {\n private direction: integer = -1;\n\n /**\n * @returns The movement direction from 0 for left to 7 for up-left and\n * -1 for no direction.\n */\n getDirection(): integer {\n return this.direction;\n }\n\n /**\n * This method won't change the direction used by the top-down movement\n * behavior.\n */\n _setDirection(direction: integer): void {\n this.direction = direction;\n }\n }\n\n // This should be a static attribute but it's not possible because of\n // declaration order.\n export const _topDownMovementHookContext =\n new gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHookContext();\n\n /**\n * Allow extensions relying on the top-down movement to customize its\n * behavior a bit.\n */\n export interface TopDownMovementHook {\n /**\n * Return the direction to use instead of the direction given in\n * parameter.\n */\n overrideDirection(hookContext: TopDownMovementHookContext): integer;\n /**\n * Called before the acceleration and new direction is applied to the\n * velocity.\n */\n beforeSpeedUpdate(hookContext: TopDownMovementHookContext): void;\n /**\n * Called before the velocity is applied to the object position and\n * angle.\n */\n beforePositionUpdate(hookContext: TopDownMovementHookContext): void;\n }\n\n export interface BasisTransformation {\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;\n }\n\n export class IsometryTransformation\n implements gdjs.TopDownMovementRuntimeBehavior.BasisTransformation\n {\n private _screen: float[][];\n\n /**\n * @param angle between the x axis and the projected isometric x axis.\n * @throws if the angle is not in ]0; pi/4[. Note that 0 is a front viewpoint and pi/4 a top-down viewpoint.\n */\n constructor(angle: float) {\n if (angle <= 0 || angle >= Math.PI / 4)\n throw new RangeError(\n 'An isometry angle must be in ]0; pi/4] but was: ' + angle\n );\n\n const alpha = Math.asin(Math.tan(angle));\n const sinA = Math.sin(alpha);\n const cosB = Math.cos(Math.PI / 4);\n const sinB = cosB;\n // https://en.wikipedia.org/wiki/Isometric_projection\n //\n // / 1 0 0 \\ / cosB 0 -sinB \\ / 1 0 0 \\\n // | 0 cosA sinA | | 0 1 0 | | 0 0 -1 |\n // \\ 0 -sinA cosA / \\ sinB 0 cosB / \\ 0 1 0 /\n this._screen = [\n [cosB, -sinB],\n [sinA * sinB, sinA * cosB],\n ];\n }\n\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void {\n const x =\n this._screen[0][0] * worldPoint[0] +\n this._screen[0][1] * worldPoint[1];\n const y =\n this._screen[1][0] * worldPoint[0] +\n this._screen[1][1] * worldPoint[1];\n screenPoint[0] = x;\n screenPoint[1] = y;\n }\n }\n }\n\n gdjs.registerBehavior(\n 'TopDownMovementBehavior::TopDownMovementBehavior',\n gdjs.TopDownMovementRuntimeBehavior\n );\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAuBS,eAA6C,GAAK,eAAgB,CA0DvE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAjDjC,YAAgB,EAGhB,gBAAoB,EACpB,gBAAoB,EACpB,mBAAuB,EAGvB,cAAoB,GACpB,eAAqB,GACrB,YAAkB,GAClB,cAAoB,GACpB,6BAAiC,EACjC,8BAAkC,EAClC,2BAA+B,EAC/B,6BAAiC,EACjC,mBAAyB,GACzB,iBAAqB,EACrB,iBAAqB,EAK7B,mCAAyC,GAIzC,6CAAmD,GAK3C,wBAA8B,GAC9B,yBAA+B,GAC/B,sBAA4B,GAC5B,wBAA8B,GAI9B,uCAAgD,CAAC,EAAG,GAEpD,2BACN,GAQA,KAAK,gBAAkB,EAAa,eACpC,KAAK,cAAgB,EAAa,aAClC,KAAK,cAAgB,EAAa,aAClC,KAAK,UAAY,EAAa,SAC9B,KAAK,iBAAmB,EAAa,gBACrC,KAAK,cAAgB,EAAa,aAClC,KAAK,aAAe,EAAa,YACjC,KAAK,uBAAyB,EAAa,sBAC3C,KAAK,aACH,EAAa,UACb,EAAa,qBAEf,KAAK,qBAAuB,EAAa,qBAAuB,EAChE,KAAK,mBACH,EAAa,oBAAsB,OAC/B,GACA,EAAa,kBAGrB,oBAAqD,CAGnD,YAAK,8BAAgC,GACrC,KAAK,wCAA0C,GAExC,IACF,MAAM,qBACT,MAAO,CACL,EAAG,KAAK,OACR,GAAI,KAAK,WACT,GAAI,KAAK,WACT,GAAI,KAAK,cACT,GAAI,KAAK,mBACT,GAAI,KAAK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C,EAAU,CAEZ,GAAI,GAAM,KAAK,IAAI,GACf,EAAM,KAAK,IAAI,GACnB,AAAI,KAAQ,IAAM,IAAQ,IACxB,GAAM,GAEJ,KAAQ,IAAM,IAAQ,IACxB,GAAM,GAGR,
|
|
4
|
+
"sourcesContent": ["/*\nGDevelop - Top-down movement Behavior Extension\nCopyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n interface TopDownMovementNetworkSyncDataType {\n a: float;\n xv: float;\n yv: float;\n as: float;\n lk: boolean;\n rk: boolean;\n uk: boolean;\n dk: boolean;\n wsu: boolean;\n sa: float;\n sf: float;\n }\n\n export interface TopDownMovementNetworkSyncData\n extends BehaviorNetworkSyncData {\n props: TopDownMovementNetworkSyncDataType;\n }\n /**\n * Allows an object to move in 4 or 8 directions, with customizable speed, accelerations\n * and rotation.\n */\n export class TopDownMovementRuntimeBehavior extends gdjs.RuntimeBehavior {\n //Behavior configuration:\n private _allowDiagonals: boolean;\n private _acceleration: float;\n private _deceleration: float;\n private _maxSpeed: float;\n private _angularMaxSpeed: float;\n private _rotateObject: boolean;\n private _angleOffset: float;\n private _ignoreDefaultControls: boolean;\n private _movementAngleOffset: float;\n private _useLegacyTurnBack: boolean;\n\n /** The latest angle of movement, in degrees. */\n private _angle: float = 0;\n\n //Attributes used when moving\n private _xVelocity: float = 0;\n private _yVelocity: float = 0;\n private _angularSpeed: float = 0;\n\n // Inputs\n private _leftKey: boolean = false;\n private _rightKey: boolean = false;\n private _upKey: boolean = false;\n private _downKey: boolean = false;\n private _leftKeyPressedDuration: float = 0;\n private _rightKeyPressedDuration: float = 0;\n private _upKeyPressedDuration: float = 0;\n private _downKeyPressedDuration: float = 0;\n private _wasStickUsed: boolean = false;\n private _stickAngle: float = 0;\n private _stickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n _dontClearInputsBetweenFrames: boolean = false;\n // This is useful when the object is synchronized over the network,\n // object is controlled by the network and we want to ensure the current player\n // cannot control it.\n _ignoreDefaultControlsAsSyncedByNetwork: boolean = false;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasUpKeyPressed: boolean = false;\n private _wasDownKeyPressed: boolean = false;\n\n // @ts-ignore The setter \"setViewpoint\" is not detected as an affectation.\n private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;\n private _temporaryPointForTransformations: FloatPoint = [0, 0];\n\n private _topDownMovementHooks: Array<gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook> =\n [];\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._allowDiagonals = behaviorData.allowDiagonals;\n this._acceleration = behaviorData.acceleration;\n this._deceleration = behaviorData.deceleration;\n this._maxSpeed = behaviorData.maxSpeed;\n this._angularMaxSpeed = behaviorData.angularMaxSpeed;\n this._rotateObject = behaviorData.rotateObject;\n this._angleOffset = behaviorData.angleOffset;\n this._ignoreDefaultControls = behaviorData.ignoreDefaultControls;\n this.setViewpoint(\n behaviorData.viewpoint,\n behaviorData.customIsometryAngle\n );\n this._movementAngleOffset = behaviorData.movementAngleOffset || 0;\n this._useLegacyTurnBack =\n behaviorData.useLegacyTurnBack === undefined\n ? true\n : behaviorData.useLegacyTurnBack;\n }\n\n getNetworkSyncData(): TopDownMovementNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._dontClearInputsBetweenFrames = false;\n this._ignoreDefaultControlsAsSyncedByNetwork = false;\n\n return {\n ...super.getNetworkSyncData(),\n props: {\n a: this._angle,\n xv: this._xVelocity,\n yv: this._yVelocity,\n as: this._angularSpeed,\n lk: this._wasLeftKeyPressed,\n rk: this._wasRightKeyPressed,\n uk: this._wasUpKeyPressed,\n dk: this._wasDownKeyPressed,\n wsu: this._wasStickUsed,\n sa: this._stickAngle,\n sf: this._stickForce,\n },\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TopDownMovementNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (behaviorSpecificProps.a !== undefined) {\n this._angle = behaviorSpecificProps.a;\n }\n if (behaviorSpecificProps.xv !== undefined) {\n this._xVelocity = behaviorSpecificProps.xv;\n }\n if (behaviorSpecificProps.yv !== undefined) {\n this._yVelocity = behaviorSpecificProps.yv;\n }\n if (behaviorSpecificProps.as !== undefined) {\n this._angularSpeed = behaviorSpecificProps.as;\n }\n if (behaviorSpecificProps.lk !== undefined) {\n this._leftKey = behaviorSpecificProps.lk;\n }\n if (behaviorSpecificProps.rk !== undefined) {\n this._rightKey = behaviorSpecificProps.rk;\n }\n if (behaviorSpecificProps.uk !== undefined) {\n this._upKey = behaviorSpecificProps.uk;\n }\n if (behaviorSpecificProps.dk !== undefined) {\n this._downKey = behaviorSpecificProps.dk;\n }\n if (behaviorSpecificProps.wsu !== undefined) {\n this._wasStickUsed = behaviorSpecificProps.wsu;\n }\n if (behaviorSpecificProps.sa !== undefined) {\n this._stickAngle = behaviorSpecificProps.sa;\n }\n if (behaviorSpecificProps.sf !== undefined) {\n this._stickForce = behaviorSpecificProps.sf;\n }\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n // And we are not using the default controls.\n this._ignoreDefaultControlsAsSyncedByNetwork = true;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.allowDiagonals !== newBehaviorData.allowDiagonals) {\n this._allowDiagonals = newBehaviorData.allowDiagonals;\n }\n if (oldBehaviorData.acceleration !== newBehaviorData.acceleration) {\n this._acceleration = newBehaviorData.acceleration;\n }\n if (oldBehaviorData.deceleration !== newBehaviorData.deceleration) {\n this._deceleration = newBehaviorData.deceleration;\n }\n if (oldBehaviorData.maxSpeed !== newBehaviorData.maxSpeed) {\n this._maxSpeed = newBehaviorData.maxSpeed;\n }\n if (oldBehaviorData.angularMaxSpeed !== newBehaviorData.angularMaxSpeed) {\n this._angularMaxSpeed = newBehaviorData.angularMaxSpeed;\n }\n if (oldBehaviorData.rotateObject !== newBehaviorData.rotateObject) {\n this._rotateObject = newBehaviorData.rotateObject;\n }\n if (oldBehaviorData.angleOffset !== newBehaviorData.angleOffset) {\n this._angleOffset = newBehaviorData.angleOffset;\n }\n if (\n oldBehaviorData.ignoreDefaultControls !==\n newBehaviorData.ignoreDefaultControls\n ) {\n this._ignoreDefaultControls = newBehaviorData.ignoreDefaultControls;\n }\n if (\n oldBehaviorData.platformType !== newBehaviorData.platformType ||\n oldBehaviorData.customIsometryAngle !==\n newBehaviorData.customIsometryAngle\n ) {\n this.setViewpoint(\n newBehaviorData.platformType,\n newBehaviorData.customIsometryAngle\n );\n }\n if (\n oldBehaviorData.movementAngleOffset !==\n newBehaviorData.movementAngleOffset\n ) {\n this._movementAngleOffset = newBehaviorData.movementAngleOffset;\n }\n return true;\n }\n\n setViewpoint(viewpoint: string, customIsometryAngle: float): void {\n if (viewpoint === 'PixelIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.atan(0.5)\n );\n } else if (viewpoint === 'TrueIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.PI / 6\n );\n } else if (viewpoint === 'CustomIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n (customIsometryAngle * Math.PI) / 180\n );\n } else {\n this._basisTransformation = null;\n }\n }\n\n setAcceleration(acceleration: float): void {\n this._acceleration = acceleration;\n }\n\n getAcceleration() {\n return this._acceleration;\n }\n\n setDeceleration(deceleration: float): void {\n this._deceleration = deceleration;\n }\n\n getDeceleration() {\n return this._deceleration;\n }\n\n setMaxSpeed(maxSpeed: float): void {\n this._maxSpeed = maxSpeed;\n }\n\n getMaxSpeed() {\n return this._maxSpeed;\n }\n\n setAngularMaxSpeed(angularMaxSpeed: float): void {\n this._angularMaxSpeed = angularMaxSpeed;\n }\n\n getAngularMaxSpeed() {\n return this._angularMaxSpeed;\n }\n\n setAngleOffset(angleOffset: float): void {\n this._angleOffset = angleOffset;\n }\n\n getAngleOffset() {\n return this._angleOffset;\n }\n\n allowDiagonals(allow: boolean) {\n this._allowDiagonals = allow;\n }\n\n diagonalsAllowed() {\n return this._allowDiagonals;\n }\n\n setRotateObject(allow: boolean): void {\n this._rotateObject = allow;\n }\n\n isObjectRotated(): boolean {\n return this._rotateObject;\n }\n\n isMoving(): boolean {\n return this._xVelocity !== 0 || this._yVelocity !== 0;\n }\n\n getSpeed(): float {\n return Math.hypot(this._xVelocity, this._yVelocity);\n }\n\n getXVelocity(): float {\n return this._xVelocity;\n }\n\n setXVelocity(velocityX: float): void {\n this._xVelocity = velocityX;\n }\n\n getYVelocity(): float {\n return this._yVelocity;\n }\n\n setYVelocity(velocityY: float): void {\n this._yVelocity = velocityY;\n }\n\n getAngle(): float {\n return this._angle;\n }\n\n isMovementAngleAround(degreeAngle: float, tolerance: float) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(this._angle, degreeAngle)\n ) <= tolerance\n );\n }\n\n setMovementAngleOffset(movementAngleOffset: float): void {\n this._movementAngleOffset = movementAngleOffset;\n }\n\n getMovementAngleOffset() {\n return this._movementAngleOffset;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const LEFTKEY = 37;\n const UPKEY = 38;\n const RIGHTKEY = 39;\n const DOWNKEY = 40;\n\n //Get the player input:\n this._leftKey ||\n (this._leftKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(LEFTKEY));\n this._rightKey ||\n (this._rightKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(RIGHTKEY));\n this._downKey ||\n (this._downKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(DOWNKEY));\n this._upKey ||\n (this._upKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(UPKEY));\n\n const elapsedTime = this.owner.getElapsedTime();\n\n if (!this._leftKey) {\n this._leftKeyPressedDuration = 0;\n } else {\n this._leftKeyPressedDuration += elapsedTime;\n }\n if (!this._rightKey) {\n this._rightKeyPressedDuration = 0;\n } else {\n this._rightKeyPressedDuration += elapsedTime;\n }\n if (!this._downKey) {\n this._downKeyPressedDuration = 0;\n } else {\n this._downKeyPressedDuration += elapsedTime;\n }\n if (!this._upKey) {\n this._upKeyPressedDuration = 0;\n } else {\n this._upKeyPressedDuration += elapsedTime;\n }\n\n let direction = -1;\n if (!this._allowDiagonals) {\n if (this._upKey && !this._downKey) {\n direction = 6;\n } else if (!this._upKey && this._downKey) {\n direction = 2;\n }\n // when 2 keys are pressed for diagonals the most recently pressed win\n if (\n this._leftKey &&\n !this._rightKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._leftKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._leftKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 4;\n } else if (\n this._rightKey &&\n !this._leftKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._rightKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._rightKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 0;\n }\n } else {\n if (this._upKey && !this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 5;\n } else if (!this._leftKey && this._rightKey) {\n direction = 7;\n } else {\n direction = 6;\n }\n } else if (!this._upKey && this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 3;\n } else if (!this._leftKey && this._rightKey) {\n direction = 1;\n } else {\n direction = 2;\n }\n } else {\n if (this._leftKey && !this._rightKey) {\n direction = 4;\n } else if (!this._leftKey && this._rightKey) {\n direction = 0;\n }\n }\n }\n\n const hookContext =\n gdjs.TopDownMovementRuntimeBehavior._topDownMovementHookContext;\n for (const topDownMovementHook of this._topDownMovementHooks) {\n hookContext._setDirection(direction);\n direction = topDownMovementHook.overrideDirection(hookContext);\n }\n hookContext._setDirection(direction);\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforeSpeedUpdate(hookContext);\n }\n\n const object = this.owner;\n const timeDelta = this.owner.getElapsedTime() / 1000;\n const previousVelocityX = this._xVelocity;\n const previousVelocityY = this._yVelocity;\n this._wasStickUsed = false;\n\n // These 4 values are not actually used.\n // JavaScript doesn't allow to declare\n // variables without assigning them a value.\n let directionInRad = 0;\n let directionInDeg = 0;\n\n let isMoving = false;\n let targetedSpeed = 0;\n // Update the speed of the object:\n if (direction !== -1) {\n isMoving = true;\n directionInRad =\n ((direction + this._movementAngleOffset / 45) * Math.PI) / 4.0;\n directionInDeg = direction * 45 + this._movementAngleOffset;\n targetedSpeed = this._maxSpeed;\n } else if (this._stickForce !== 0) {\n isMoving = true;\n if (!this._allowDiagonals) {\n this._stickAngle = 90 * Math.floor((this._stickAngle + 45) / 90);\n }\n directionInDeg = this._stickAngle + this._movementAngleOffset;\n directionInRad = (directionInDeg * Math.PI) / 180;\n targetedSpeed = this._maxSpeed * this._stickForce;\n\n this._wasStickUsed = true;\n } else if (this._yVelocity !== 0 || this._xVelocity !== 0) {\n isMoving = true;\n directionInRad = Math.atan2(this._yVelocity, this._xVelocity);\n directionInDeg = (directionInRad * 180.0) / Math.PI;\n }\n if (isMoving) {\n // This makes the trigo resilient to rounding errors on directionInRad.\n let cos = Math.cos(directionInRad);\n let sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n\n let currentSpeed = Math.hypot(this._xVelocity, this._yVelocity);\n const dotProduct = this._xVelocity * cos + this._yVelocity * sin;\n if (dotProduct < 0) {\n // The object is turning back.\n // Keep the negative velocity projected on the new direction.\n currentSpeed = dotProduct;\n }\n const speed = TopDownMovementRuntimeBehavior.getAcceleratedSpeed(\n currentSpeed,\n targetedSpeed,\n this._maxSpeed,\n this._acceleration,\n this._deceleration,\n timeDelta,\n this._useLegacyTurnBack\n );\n this._xVelocity = speed * cos;\n this._yVelocity = speed * sin;\n }\n\n const squaredSpeed =\n this._xVelocity * this._xVelocity + this._yVelocity * this._yVelocity;\n if (squaredSpeed > this._maxSpeed * this._maxSpeed) {\n const ratio = this._maxSpeed / Math.sqrt(squaredSpeed);\n this._xVelocity *= ratio;\n this._yVelocity *= ratio;\n }\n\n // No acceleration for angular speed for now.\n this._angularSpeed = this._angularMaxSpeed;\n\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforePositionUpdate(hookContext);\n }\n\n // Position object.\n // This is a Verlet integration considering the acceleration as constant.\n // If you expand deltaX or deltaY, it gives, thanks to the usage of both\n // the old and the new velocity:\n // \"velocity * timeDelta + acceleration * timeDelta^2 / 2\".\n //\n // The acceleration is not actually always constant, particularly with a gamepad,\n // but the error is multiplied by timDelta^3. So, it shouldn't matter much.\n const deltaX = ((previousVelocityX + this._xVelocity) / 2) * timeDelta;\n const deltaY = ((previousVelocityY + this._yVelocity) / 2) * timeDelta;\n if (this._basisTransformation === null) {\n // Top-down viewpoint\n object.setX(object.getX() + deltaX);\n object.setY(object.getY() + deltaY);\n } else {\n // Isometry viewpoint\n const point = this._temporaryPointForTransformations;\n point[0] = deltaX;\n point[1] = deltaY;\n this._basisTransformation.toScreen(point, point);\n object.setX(object.getX() + point[0]);\n object.setY(object.getY() + point[1]);\n }\n\n // Also update angle if needed.\n if (this._xVelocity !== 0 || this._yVelocity !== 0) {\n this._angle = directionInDeg;\n if (this._rotateObject) {\n object.rotateTowardAngle(\n directionInDeg + this._angleOffset,\n this._angularSpeed\n );\n }\n }\n\n this._wasLeftKeyPressed = this._leftKey;\n this._wasRightKeyPressed = this._rightKey;\n this._wasUpKeyPressed = this._upKey;\n this._wasDownKeyPressed = this._downKey;\n if (!this._dontClearInputsBetweenFrames) {\n this._leftKey = false;\n this._rightKey = false;\n this._upKey = false;\n this._downKey = false;\n this._stickForce = 0;\n }\n }\n\n private static getAcceleratedSpeed(\n currentSpeed: float,\n targetedSpeed: float,\n speedMax: float,\n acceleration: float,\n deceleration: float,\n timeDelta: float,\n useLegacyTurnBack: boolean = false\n ): float {\n let newSpeed = currentSpeed;\n const turningBackAcceleration = useLegacyTurnBack\n ? acceleration\n : Math.max(acceleration, deceleration);\n if (targetedSpeed < 0) {\n if (currentSpeed <= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed <= 0) {\n // Accelerate\n newSpeed -= Math.max(-speedMax, acceleration * timeDelta);\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n }\n } else if (targetedSpeed > 0) {\n if (currentSpeed >= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed >= 0) {\n // Accelerate\n newSpeed = Math.min(\n speedMax,\n currentSpeed + acceleration * timeDelta\n );\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n }\n } else {\n // Decelerate and stop.\n if (currentSpeed < 0) {\n newSpeed = Math.min(currentSpeed + deceleration * timeDelta, 0);\n }\n if (currentSpeed > 0) {\n newSpeed = Math.max(currentSpeed - deceleration * timeDelta, 0);\n }\n }\n return newSpeed;\n }\n\n simulateControl(input: string) {\n if (input === 'Left') {\n this._leftKey = true;\n } else if (input === 'Right') {\n this._rightKey = true;\n } else if (input === 'Up') {\n this._upKey = true;\n } else if (input === 'Down') {\n this._downKey = true;\n }\n }\n\n ignoreDefaultControls(ignore: boolean) {\n this._ignoreDefaultControls = ignore;\n }\n\n shouldIgnoreDefaultControls() {\n return (\n this._ignoreDefaultControls ||\n this._ignoreDefaultControlsAsSyncedByNetwork\n );\n }\n\n simulateLeftKey() {\n this._leftKey = true;\n }\n\n simulateRightKey() {\n this._rightKey = true;\n }\n\n simulateUpKey() {\n this._upKey = true;\n }\n\n simulateDownKey() {\n this._downKey = true;\n }\n\n simulateStick(stickAngle: float, stickForce: float) {\n this._stickAngle = stickAngle % 360;\n this._stickForce = Math.max(0, Math.min(1, stickForce));\n }\n\n /**.\n * @param input The control to be tested [Left,Right,Up,Down,Stick].\n * @returns true if the key was used since the last `doStepPreEvents` call.\n */\n isUsingControl(input: string): boolean {\n if (input === 'Left') {\n return this._leftKeyPressedDuration > 0;\n }\n if (input === 'Right') {\n return this._rightKeyPressedDuration > 0;\n }\n if (input === 'Up') {\n return this._upKeyPressedDuration > 0;\n }\n if (input === 'Down') {\n return this._downKeyPressedDuration > 0;\n }\n if (input === 'Stick') {\n return this._wasStickUsed;\n }\n return false;\n }\n\n getLastStickInputAngle() {\n return this._stickAngle;\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(\n hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook\n ) {\n this._topDownMovementHooks.push(hook);\n }\n }\n\n export namespace TopDownMovementRuntimeBehavior {\n export class TopDownMovementHookContext {\n private direction: integer = -1;\n\n /**\n * @returns The movement direction from 0 for left to 7 for up-left and\n * -1 for no direction.\n */\n getDirection(): integer {\n return this.direction;\n }\n\n /**\n * This method won't change the direction used by the top-down movement\n * behavior.\n */\n _setDirection(direction: integer): void {\n this.direction = direction;\n }\n }\n\n // This should be a static attribute but it's not possible because of\n // declaration order.\n export const _topDownMovementHookContext =\n new gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHookContext();\n\n /**\n * Allow extensions relying on the top-down movement to customize its\n * behavior a bit.\n */\n export interface TopDownMovementHook {\n /**\n * Return the direction to use instead of the direction given in\n * parameter.\n */\n overrideDirection(hookContext: TopDownMovementHookContext): integer;\n /**\n * Called before the acceleration and new direction is applied to the\n * velocity.\n */\n beforeSpeedUpdate(hookContext: TopDownMovementHookContext): void;\n /**\n * Called before the velocity is applied to the object position and\n * angle.\n */\n beforePositionUpdate(hookContext: TopDownMovementHookContext): void;\n }\n\n export interface BasisTransformation {\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;\n }\n\n export class IsometryTransformation\n implements gdjs.TopDownMovementRuntimeBehavior.BasisTransformation\n {\n private _screen: float[][];\n\n /**\n * @param angle between the x axis and the projected isometric x axis.\n * @throws if the angle is not in ]0; pi/4[. Note that 0 is a front viewpoint and pi/4 a top-down viewpoint.\n */\n constructor(angle: float) {\n if (angle <= 0 || angle >= Math.PI / 4)\n throw new RangeError(\n 'An isometry angle must be in ]0; pi/4] but was: ' + angle\n );\n\n const alpha = Math.asin(Math.tan(angle));\n const sinA = Math.sin(alpha);\n const cosB = Math.cos(Math.PI / 4);\n const sinB = cosB;\n // https://en.wikipedia.org/wiki/Isometric_projection\n //\n // / 1 0 0 \\ / cosB 0 -sinB \\ / 1 0 0 \\\n // | 0 cosA sinA | | 0 1 0 | | 0 0 -1 |\n // \\ 0 -sinA cosA / \\ sinB 0 cosB / \\ 0 1 0 /\n this._screen = [\n [cosB, -sinB],\n [sinA * sinB, sinA * cosB],\n ];\n }\n\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void {\n const x =\n this._screen[0][0] * worldPoint[0] +\n this._screen[0][1] * worldPoint[1];\n const y =\n this._screen[1][0] * worldPoint[0] +\n this._screen[1][1] * worldPoint[1];\n screenPoint[0] = x;\n screenPoint[1] = y;\n }\n }\n }\n\n gdjs.registerBehavior(\n 'TopDownMovementBehavior::TopDownMovementBehavior',\n gdjs.TopDownMovementRuntimeBehavior\n );\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAuBS,eAA6C,GAAK,eAAgB,CA0DvE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAjDjC,YAAgB,EAGhB,gBAAoB,EACpB,gBAAoB,EACpB,mBAAuB,EAGvB,cAAoB,GACpB,eAAqB,GACrB,YAAkB,GAClB,cAAoB,GACpB,6BAAiC,EACjC,8BAAkC,EAClC,2BAA+B,EAC/B,6BAAiC,EACjC,mBAAyB,GACzB,iBAAqB,EACrB,iBAAqB,EAK7B,mCAAyC,GAIzC,6CAAmD,GAK3C,wBAA8B,GAC9B,yBAA+B,GAC/B,sBAA4B,GAC5B,wBAA8B,GAI9B,uCAAgD,CAAC,EAAG,GAEpD,2BACN,GAQA,KAAK,gBAAkB,EAAa,eACpC,KAAK,cAAgB,EAAa,aAClC,KAAK,cAAgB,EAAa,aAClC,KAAK,UAAY,EAAa,SAC9B,KAAK,iBAAmB,EAAa,gBACrC,KAAK,cAAgB,EAAa,aAClC,KAAK,aAAe,EAAa,YACjC,KAAK,uBAAyB,EAAa,sBAC3C,KAAK,aACH,EAAa,UACb,EAAa,qBAEf,KAAK,qBAAuB,EAAa,qBAAuB,EAChE,KAAK,mBACH,EAAa,oBAAsB,OAC/B,GACA,EAAa,kBAGrB,oBAAqD,CAGnD,YAAK,8BAAgC,GACrC,KAAK,wCAA0C,GAExC,IACF,MAAM,qBACT,MAAO,CACL,EAAG,KAAK,OACR,GAAI,KAAK,WACT,GAAI,KAAK,WACT,GAAI,KAAK,cACT,GAAI,KAAK,mBACT,GAAI,KAAK,oBACT,GAAI,KAAK,iBACT,GAAI,KAAK,mBACT,IAAK,KAAK,cACV,GAAI,KAAK,YACT,GAAI,KAAK,cAKf,0BACE,EACM,CACN,MAAM,0BAA0B,GAEhC,KAAM,GAAwB,EAAg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