gdcore-tools 2.0.0-gd-v5.5.223-autobuild → 2.0.0-gd-v5.5.225-autobuild

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject2D.js.map +2 -2
  4. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/Base3DBehavior.js.map +2 -2
  6. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
  9. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
  12. package/dist/Runtime/Extensions/3D/JsExtension.js +219 -108
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  16. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  17. package/dist/Runtime/Extensions/AdMob/JsExtension.js +63 -1
  18. package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
  19. package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
  20. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  21. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  22. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  23. package/dist/Runtime/Extensions/BBText/JsExtension.js +10 -9
  24. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  25. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +4 -6
  26. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject-pixi-renderer.js.map +2 -2
  27. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  28. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  29. package/dist/Runtime/Extensions/DraggableBehavior/draggableruntimebehavior.js.map +2 -2
  30. package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js.map +2 -2
  31. package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js.map +2 -2
  32. package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js.map +2 -2
  33. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js.map +2 -2
  35. package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js.map +2 -2
  37. package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js.map +2 -2
  39. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js.map +2 -2
  41. package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js.map +2 -2
  43. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js.map +2 -2
  45. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  46. package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js.map +2 -2
  47. package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js.map +2 -2
  48. package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js.map +2 -2
  49. package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js.map +2 -2
  50. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  51. package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js.map +2 -2
  52. package/dist/Runtime/Extensions/Effects/pixi-filters/types/drop-shadow/types.d.ts +10 -4
  53. package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js.map +2 -2
  54. package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js.map +2 -2
  55. package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js.map +2 -2
  56. package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js.map +2 -2
  57. package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js.map +2 -2
  58. package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js.map +2 -2
  59. package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js.map +2 -2
  60. package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js.map +2 -2
  61. package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js.map +2 -2
  62. package/dist/Runtime/Extensions/FacebookInstantGames/facebookinstantgamestools.js.map +2 -2
  63. package/dist/Runtime/Extensions/Firebase/A_firebasejs/firebase.d.ts +5 -4
  64. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_cloudfirestoretools.js.map +2 -2
  65. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_remoteconfigtools.js.map +2 -2
  66. package/dist/Runtime/Extensions/Firebase/JsExtension.js +21 -21
  67. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +1 -0
  68. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  69. package/dist/Runtime/Extensions/Lighting/JsExtension.js +2 -2
  70. package/dist/Runtime/Extensions/Lighting/lightobstacleruntimebehavior.js.map +2 -2
  71. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  72. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js.map +2 -2
  74. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +122 -0
  75. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  76. package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
  78. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
  79. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  80. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
  81. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  82. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js +1 -1
  83. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js.map +2 -2
  84. package/dist/Runtime/Extensions/Multiplayer/peerjs.d.ts +8 -10
  85. package/dist/Runtime/Extensions/P2P/peerjs.d.ts +8 -10
  86. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  87. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  88. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  89. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  90. package/dist/Runtime/Extensions/ParticleSystem/pixi-particles-pixi-renderer.d.ts +2 -1
  91. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingobstacleruntimebehavior.js.map +2 -2
  92. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  93. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +106 -106
  94. package/dist/Runtime/Extensions/Physics2Behavior/box2d.d.ts +13 -7
  95. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  96. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  97. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  98. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  99. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  100. package/dist/Runtime/Extensions/PhysicsBehavior/physicsruntimebehavior.js.map +2 -2
  101. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  102. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  103. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js.map +1 -1
  104. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  105. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  106. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js.map +2 -2
  107. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  108. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js +1 -1
  109. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js.map +2 -2
  110. package/dist/Runtime/Extensions/Spine/JsExtension.js +5 -4
  111. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  112. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  113. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  114. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  115. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
  116. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  117. package/dist/Runtime/Extensions/Steamworks/JsExtension.js +12 -12
  118. package/dist/Runtime/Extensions/Steamworks/Z_steamworksinputtools.js.map +2 -2
  119. package/dist/Runtime/Extensions/Steamworks/steamworkstools.js.map +2 -2
  120. package/dist/Runtime/Extensions/TextEntryObject/textentryruntimeobject-pixi-renderer.js.map +2 -2
  121. package/dist/Runtime/Extensions/TextInput/JsExtension.js +2 -2
  122. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  123. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  125. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  126. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  127. package/dist/Runtime/Extensions/TileMap/JsExtension.js +20 -18
  128. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  129. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  130. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +1 -3
  131. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  132. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  133. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +1 -1
  134. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  135. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject-pixi-renderer.js.map +2 -2
  136. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  137. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  138. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +1 -1
  139. package/dist/Runtime/Extensions/Video/JsExtension.js +2 -1
  140. package/dist/Runtime/Extensions/Video/videoruntimeobject-pixi-renderer.js.map +2 -2
  141. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  142. package/dist/Runtime/InAppTutorialMessage.js +6 -0
  143. package/dist/Runtime/InAppTutorialMessage.js.map +7 -0
  144. package/dist/Runtime/Model3DManager.js.map +2 -2
  145. package/dist/Runtime/ResourceLoader.js.map +2 -2
  146. package/dist/Runtime/RuntimeCustomObjectLayer.js +1 -1
  147. package/dist/Runtime/RuntimeCustomObjectLayer.js.map +2 -2
  148. package/dist/Runtime/RuntimeInstanceContainer.js.map +1 -1
  149. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  150. package/dist/Runtime/SpriteAnimator.js.map +2 -2
  151. package/dist/Runtime/affinetransformation.js.map +1 -1
  152. package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
  153. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  154. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  155. package/dist/Runtime/debugger-client/websocket-debugger-client.js +1 -1
  156. package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
  157. package/dist/Runtime/events-tools/networktools.js +1 -1
  158. package/dist/Runtime/events-tools/networktools.js.map +2 -2
  159. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  160. package/dist/Runtime/gd.js.map +2 -2
  161. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  162. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  163. package/dist/Runtime/inputmanager.js.map +2 -2
  164. package/dist/Runtime/jsonmanager.js.map +2 -2
  165. package/dist/Runtime/layer.js.map +2 -2
  166. package/dist/Runtime/libs/nanomarkdown.js +5 -0
  167. package/dist/Runtime/libs/nanomarkdown.js.map +7 -0
  168. package/dist/Runtime/object-capabilities/AnimatableBehavior.js.map +2 -2
  169. package/dist/Runtime/object-capabilities/EffectBehavior.js.map +2 -2
  170. package/dist/Runtime/object-capabilities/FlippableBehavior.js.map +2 -2
  171. package/dist/Runtime/object-capabilities/OpacityBehavior.js.map +2 -2
  172. package/dist/Runtime/object-capabilities/ResizableBehavior.js.map +2 -2
  173. package/dist/Runtime/object-capabilities/ScalableBehavior.js.map +2 -2
  174. package/dist/Runtime/object-capabilities/TextContainerBehavior.js.map +2 -2
  175. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  176. package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js.map +2 -2
  177. package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js.map +2 -2
  178. package/dist/Runtime/pixi-renderers/loadingscreen-pixi-renderer.js.map +2 -2
  179. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  180. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  181. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  182. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  183. package/dist/Runtime/pixi-renderers/pixi.js +123 -177
  184. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  185. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  186. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  187. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  188. package/dist/Runtime/profiler.js.map +2 -2
  189. package/dist/Runtime/runtimegame.js +1 -1
  190. package/dist/Runtime/runtimegame.js.map +2 -2
  191. package/dist/Runtime/runtimeobject.js +1 -1
  192. package/dist/Runtime/runtimeobject.js.map +2 -2
  193. package/dist/Runtime/runtimescene.js.map +2 -2
  194. package/dist/Runtime/runtimewatermark.js.map +2 -2
  195. package/dist/Runtime/scenestack.js.map +2 -2
  196. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  197. package/dist/Runtime/variable.js.map +2 -2
  198. package/dist/Runtime/variablescontainer.js.map +2 -2
  199. package/dist/lib/libGD.cjs +1 -1
  200. package/dist/lib/libGD.wasm +0 -0
  201. package/gd.d.ts +6 -0
  202. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../GDevelop/Extensions/TileMap/collision/TransformedTileMap.ts"],
4
- "sourcesContent": ["/// <reference path=\"../helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export namespace TileMap {\n /**\n * A tile map transformed with an affine transformation.\n *\n * @see {@link getHitboxesAround} It gives a fast access to hitboxes for collision handling.\n */\n export class TransformedCollisionTileMap {\n /**\n * The model that describes the tile map.\n */\n private _source: TileMapHelper.EditableTileMap;\n tag: string;\n private _layerIndex: integer | null;\n private _layers: Map<integer, TransformedCollisionTileMapLayer>;\n // TODO Tiled allows to offset the layers\n /**\n * The transformation from the time map coordinate (in pixels)\n * to the scene coordinate (in pixels).\n */\n private _transformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n /**\n * The transformation from the scene coordinate (in pixels)\n * to the time map coordinate (in pixels).\n */\n private _inverseTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n /**\n * This allows tiles to know if their hitboxes must be updated.\n * @see {@link TransformedCollisionTile.affineTransformationUpToDateCount}\n */\n _transformationUpToDateCount: integer = 1;\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n /**\n * @param source The model that describes the tile map.\n */\n constructor(\n source: TileMapHelper.EditableTileMap,\n tag: string,\n layerIndex: number | null = null\n ) {\n this._source = source;\n this.tag = tag;\n this._layerIndex = layerIndex;\n this._layers = new Map<integer, TransformedCollisionTileMapLayer>();\n this._buildLayersFromTileMap(source, this._layers);\n }\n\n updateFromTileMap(tileMap: TileMapHelper.EditableTileMap) {\n this._source = tileMap;\n this._layers = new Map<integer, TransformedCollisionTileMapLayer>();\n\n this._buildLayersFromTileMap(tileMap, this._layers);\n }\n\n _buildLayersFromTileMap(\n tileMap: TileMapHelper.EditableTileMap,\n layers: Map<integer, TransformedCollisionTileMapLayer>\n ) {\n if (this._layerIndex) {\n const tileLayer = tileMap.getTileLayer(this._layerIndex);\n if (!tileLayer) {\n return;\n }\n layers.set(\n tileLayer.id,\n new TransformedCollisionTileMapLayer(this, tileLayer)\n );\n } else {\n for (const sourceLayer of tileMap.getLayers()) {\n // TODO A visitor could be used to avoid a cast.\n if (!(sourceLayer instanceof TileMapHelper.EditableTileMapLayer)) {\n // TODO Collision mask for object layers is not handled.\n continue;\n }\n const tileLayer = sourceLayer as TileMapHelper.EditableTileMapLayer;\n layers.set(\n tileLayer.id,\n new TransformedCollisionTileMapLayer(this, tileLayer)\n );\n }\n }\n }\n\n /**\n * @returns The transformation from the time map coordinate (in pixels)\n * to the scene coordinate (in pixels).\n */\n getTransformation(): gdjs.AffineTransformation {\n return this._transformation;\n }\n\n /**\n * @param transformation the transformation from the tile map coordinate\n * (in pixels) to the scene coordinate (in pixels).\n */\n setTransformation(transformation: gdjs.AffineTransformation) {\n this._transformation = transformation;\n\n const inverseTransformation = this._inverseTransformation;\n inverseTransformation.copyFrom(transformation);\n inverseTransformation.invert();\n\n this._invalidate();\n }\n\n private _invalidate() {\n this._transformationUpToDateCount =\n (this._transformationUpToDateCount + 1) % Number.MAX_SAFE_INTEGER;\n }\n\n invalidateTile(layerIndex: integer, x: integer, y: integer) {\n const layer = this.getLayer(layerIndex);\n if (layer) {\n const tile = layer.get(x, y);\n if (tile) {\n tile.invalidate();\n }\n }\n }\n\n /**\n * @returns The tile map width in pixels.\n */\n getWidth() {\n return this._source.getWidth();\n }\n\n /**\n * @returns The tile map height in pixels.\n */\n getHeight() {\n return this._source.getHeight();\n }\n\n /**\n * @returns The tile width in pixels.\n */\n getTileHeight() {\n return this._source.getTileHeight();\n }\n\n /**\n * @returns The tile height in pixels.\n */\n getTileWidth() {\n return this._source.getTileWidth();\n }\n\n /**\n * @returns The number of tile columns in the map.\n */\n getDimensionX() {\n return this._source.getDimensionX();\n }\n\n /**\n * @returns The number of tile rows in the map.\n */\n getDimensionY() {\n return this._source.getDimensionY();\n }\n\n /**\n * @param tileId The tile identifier\n * @returns The tile definition form the tile set.\n */\n getTileDefinition(tileId: integer) {\n return this._source.getTileDefinition(tileId);\n }\n\n /**\n * @param layerId The layer identifier.\n * @returns the layer\n */\n getLayer(layerId: integer): TransformedCollisionTileMapLayer | undefined {\n return this._layers.get(layerId);\n }\n\n /**\n * @returns All the layers of the tile map.\n */\n getLayers(): Iterable<TransformedCollisionTileMapLayer> {\n return this._layers.values();\n }\n\n /**\n * Check if a point is inside a tile with a given tag.\n *\n * It doesn't use the tile hitboxes.\n * It only check the point is inside the tile square.\n *\n * @param x The X coordinate of the point to check.\n * @param y The Y coordinate of the point to check.\n * @param tag The tile tag\n * @returns true when the point is inside a tile with a given tag.\n */\n pointIsInsideTile(x: float, y: float, tag: string): boolean {\n const workingPoint: FloatPoint =\n TransformedCollisionTileMap.workingPoint;\n workingPoint[0] = x;\n workingPoint[1] = y;\n this._inverseTransformation.transform(workingPoint, workingPoint);\n return this._source.pointIsInsideTile(\n workingPoint[0],\n workingPoint[1],\n tag\n );\n }\n\n /**\n * @param tag The tile tag.\n * @param left The left border of the area in the scene.\n * @param top The top border of the area in the scene.\n * @param right The right border of the area in the scene.\n * @param bottom The left border of the area in the scene.\n * @returns At least all the hitboxes from the given area\n * where tiles have the right tag.\n *\n * @see {@link gdjs.RuntimeObject.getHitboxesAround}\n */\n getHitboxesAround(\n tag: string,\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // Return the hitboxes from the tiles that overlap\n // the AABB of the area in the tile map basis.\n // Some of these tiles are not event in the given area\n // but this is a good trade of between the number of\n // useless returned hitboxes and the time to find them.\n\n // Transform the vertices of the area\n // from the scene basis to the tile map basis.\n const inverseTransformation = this._inverseTransformation;\n const workingPoint: FloatPoint =\n TransformedCollisionTileMap.workingPoint;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n inverseTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n inverseTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n inverseTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n inverseTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n // Calculate the AABB of the area in the tile map basis.\n const xMin = Math.max(\n 0,\n Math.floor(\n Math.min(topLeftX, topRightX, bottomRightX, bottomLeftX) /\n this._source.getTileWidth()\n )\n );\n const xMax = Math.min(\n this.getDimensionX() - 1,\n Math.floor(\n Math.max(topLeftX, topRightX, bottomRightX, bottomLeftX) /\n this._source.getTileWidth()\n )\n );\n const yMin = Math.max(\n 0,\n Math.floor(\n Math.min(topLeftY, topRightY, bottomRightY, bottomLeftY) /\n this._source.getTileHeight()\n )\n );\n const yMax = Math.min(\n this.getDimensionY() - 1,\n Math.floor(\n Math.max(topLeftY, topRightY, bottomRightY, bottomLeftY) /\n this._source.getTileHeight()\n )\n );\n\n return this.getHitboxes(tag, xMin, yMin, xMax, yMax);\n }\n\n /**\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n * @returns All the hitboxes from the tiles overlapping\n * the given area where tiles have the right tag.\n */\n getHitboxes(\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ): Iterable<gdjs.Polygon> {\n return new MapCollisionMaskIterable(this, tag, xMin, yMin, xMax, yMax);\n }\n\n /**\n * @param tag The tile tag.\n * @returns All the hitboxes from the tiles having the right tag.\n */\n getAllHitboxes(tag: string): Iterable<gdjs.Polygon> {\n return this.getHitboxes(\n tag,\n 0,\n 0,\n this._source.getDimensionX() - 1,\n this._source.getDimensionY() - 1\n );\n }\n }\n\n /**\n * Iterable over the tile hitboxes of a given area and tag.\n */\n class MapCollisionMaskIterable implements Iterable<gdjs.Polygon> {\n map: TransformedCollisionTileMap;\n tag: string;\n xMin: integer;\n yMin: integer;\n xMax: integer;\n yMax: integer;\n\n /**\n * Avoid to allocate an empty iterator each time\n * the iterable is initialized.\n */\n static emptyItr: Iterator<gdjs.Polygon> = {\n next: () => ({ value: undefined, done: true }),\n };\n\n /**\n * @param map The tile map.\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n */\n constructor(\n map: TransformedCollisionTileMap,\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ) {\n this.map = map;\n this.tag = tag;\n this.xMin = xMin;\n this.yMin = yMin;\n this.xMax = xMax;\n this.yMax = yMax;\n }\n\n [Symbol.iterator]() {\n // Flatten the iterable of each layers into one.\n let layerItr = this.map.getLayers()[Symbol.iterator]();\n let listItr: Iterator<gdjs.Polygon> = MapCollisionMaskIterable.emptyItr;\n\n return {\n next: () => {\n let listNext = listItr.next();\n while (listNext.done) {\n const layerNext = layerItr.next();\n if (layerNext.done) {\n return listNext;\n }\n listItr = layerNext.value\n .getHitboxes(\n this.tag,\n this.xMin,\n this.yMin,\n this.xMax,\n this.yMax\n )\n [Symbol.iterator]();\n listNext = listItr.next();\n }\n return listNext;\n },\n };\n }\n }\n\n /**\n * A tile map layer transformed with an affine transformation.\n */\n export class TransformedCollisionTileMapLayer {\n /**\n * The time map that contains this layer.\n */\n readonly tileMap: TransformedCollisionTileMap;\n /**\n * The model that describes the tile map.\n */\n readonly _source: TileMapHelper.EditableTileMapLayer;\n private readonly _tiles: TransformedCollisionTile[][];\n\n /**\n * @param tileMap The time map that contains this layer.\n * @param source The model that describes the tile map.\n */\n constructor(\n tileMap: TransformedCollisionTileMap,\n source: TileMapHelper.EditableTileMapLayer\n ) {\n this.tileMap = tileMap;\n this._source = source;\n this._tiles = [];\n const dimX = this._source.getDimensionX();\n const dimY = this._source.getDimensionY();\n this._tiles.length = dimY;\n for (let y = 0; y < dimY; y++) {\n this._tiles[y] = [];\n this._tiles[y].length = dimX;\n for (let x = 0; x < dimX; x++) {\n this._tiles[y][x] = new TransformedCollisionTile(this, x, y);\n }\n }\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @return The tile from the tile set.\n */\n get(x: integer, y: integer): TransformedCollisionTile | undefined {\n const row = this._tiles[y];\n return row ? row[x] : undefined;\n }\n\n /**\n * The number of tile columns in the layer.\n */\n getDimensionX() {\n return this._tiles.length === 0 ? 0 : this._tiles[0].length;\n }\n\n /**\n * The number of tile rows in the layer.\n */\n getDimensionY() {\n return this._tiles.length;\n }\n\n /**\n * @returns The layer width in pixels.\n */\n getWidth() {\n return this._source.getWidth();\n }\n\n /**\n * @returns The layer height in pixels.\n */\n getHeight() {\n return this._source.getHeight();\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped diagonally.\n */\n isFlippedDiagonally(x: integer, y: integer) {\n return this._source.isFlippedDiagonally(x, y);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped vertically.\n */\n isFlippedVertically(x: integer, y: integer) {\n return this._source.isFlippedVertically(x, y);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped horizontally.\n */\n isFlippedHorizontally(x: integer, y: integer) {\n return this._source.isFlippedHorizontally(x, y);\n }\n /**\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n * @returns All the hitboxes from the tiles overlapping\n * the given area where tiles have the right tag.\n */\n getHitboxes(\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ): Iterable<gdjs.Polygon> {\n return new LayerCollisionMaskIterable(\n this,\n tag,\n xMin,\n yMin,\n xMax,\n yMax\n );\n }\n\n /**\n * @param tag The tile tag.\n * @returns All the hitboxes from the tiles having the right tag.\n */\n getAllHitboxes(tag: string): Iterable<gdjs.Polygon> {\n return this.getHitboxes(\n tag,\n 0,\n 0,\n this.getDimensionX() - 1,\n this.getDimensionY() - 1\n );\n }\n }\n\n /**\n * Iterable over the tile hitboxes of a given area and tag.\n */\n class LayerCollisionMaskIterable implements Iterable<gdjs.Polygon> {\n layer: TransformedCollisionTileMapLayer;\n tag: string;\n xMin: integer;\n yMin: integer;\n xMax: integer;\n yMax: integer;\n\n /**\n * Avoid to allocate an empty iterator each time\n * the iterable is initialized.\n */\n static emptyItr: Iterator<gdjs.Polygon> = {\n next: () => ({ value: undefined, done: true }),\n };\n\n /**\n * @param map The tile map.\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n */\n constructor(\n layer: TransformedCollisionTileMapLayer,\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ) {\n this.layer = layer;\n this.tag = tag;\n this.xMin = xMin;\n this.yMin = yMin;\n this.xMax = xMax;\n this.yMax = yMax;\n }\n\n [Symbol.iterator]() {\n // Flatten the iterable of each tile into one.\n\n // xMin and yMin next increment\n let x = this.xMax;\n let y = this.yMin - 1;\n let polygonItr: Iterator<gdjs.Polygon> =\n LayerCollisionMaskIterable.emptyItr;\n\n return {\n next: () => {\n let listNext = polygonItr.next();\n while (listNext.done) {\n x++;\n if (x > this.xMax) {\n y++;\n x = this.xMin;\n }\n if (y > this.yMax) {\n // done\n return listNext;\n }\n const tile = this.layer.get(x, y);\n if (!tile) {\n continue;\n }\n const definition = tile.getDefinition();\n if (!definition) {\n continue;\n }\n if (definition.hasTaggedHitBox(this.tag)) {\n polygonItr = tile.getHitboxes()[Symbol.iterator]();\n listNext = polygonItr.next();\n }\n }\n return listNext;\n },\n };\n }\n }\n\n /**\n * A tile transformed with an affine transformation.\n */\n class TransformedCollisionTile {\n /**\n * The layer that contains this tile.\n */\n readonly layer: TransformedCollisionTileMapLayer;\n /**\n * The column index in the layer.\n */\n readonly x: integer;\n /**\n * The row index in the layer.\n */\n readonly y: integer;\n private readonly hitBoxes: gdjs.Polygon[];\n private affineTransformationUpToDateCount: integer = 0;\n\n /**\n * An reusable AffineTransformation to avoid allocations.\n */\n private static readonly workingTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n\n /**\n *\n * @param layer The layer that contains this tile.\n * @param x The column index in the layer.\n * @param y The row index in the layer.\n */\n constructor(\n layer: TransformedCollisionTileMapLayer,\n x: integer,\n y: integer\n ) {\n this.layer = layer;\n this.x = x;\n this.y = y;\n const definition = this.getDefinition();\n this.hitBoxes = [];\n if (definition) {\n const tag = this.layer.tileMap.tag;\n const definitionHitboxes = definition.getHitBoxes(tag);\n if (definitionHitboxes) {\n this.hitBoxes.length = definitionHitboxes.length;\n for (\n let polygonIndex = 0;\n polygonIndex < this.hitBoxes.length;\n polygonIndex++\n ) {\n const polygon = new gdjs.Polygon();\n this.hitBoxes[polygonIndex] = polygon;\n polygon.vertices.length = definitionHitboxes[polygonIndex].length;\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n polygon.vertices[vertexIndex] = [0, 0];\n }\n }\n }\n }\n }\n\n /**\n * @returns The tile definition from the tile set.\n */\n getDefinition(): TileMapHelper.TileDefinition {\n return this.layer.tileMap.getTileDefinition(\n this.layer._source.getTileId(this.x, this.y)!\n )!;\n }\n\n private _isHitboxesUpToDate() {\n return (\n this.affineTransformationUpToDateCount ===\n this.layer.tileMap._transformationUpToDateCount\n );\n }\n\n private _setHitboxesUpToDate() {\n this.affineTransformationUpToDateCount = this.layer.tileMap._transformationUpToDateCount;\n }\n\n invalidate() {\n this.affineTransformationUpToDateCount = -1;\n // Also invalidate neighbors because their hit boxes may need to be\n // extended differently.\n let neighbor = this.layer.get(this.x - 1, this.y);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x + 1, this.y);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x, this.y - 1);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x, this.y + 1);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n }\n\n /**\n * @returns The hitboxes of this tile in the scene basis.\n */\n getHitboxes(): Polygon[] {\n if (this._isHitboxesUpToDate()) {\n return this.hitBoxes;\n }\n\n const definition = this.getDefinition();\n if (!definition) {\n this._setHitboxesUpToDate();\n this.hitBoxes.length = 0;\n return this.hitBoxes;\n }\n const tag = this.layer.tileMap.tag;\n const definitionHitboxes = definition.getHitBoxes(tag);\n if (!definitionHitboxes) {\n this._setHitboxesUpToDate();\n this.hitBoxes.length = 0;\n return this.hitBoxes;\n }\n\n const tileMap = this.layer.tileMap;\n const width = tileMap.getTileWidth();\n const height = tileMap.getTileHeight();\n\n // Extend the hit boxes.\n // It avoids small objects to be pushed side way into a wall when they\n // should be pop out of the wall.\n\n const hasFullHitBox =\n definitionHitboxes.length === 1 && definition.hasFullHitBox(tag);\n if (hasFullHitBox) {\n const isLeftFull = this._hasNeighborFullHitBox(-1, 0);\n const isRightFull = this._hasNeighborFullHitBox(1, 0);\n const isTopFull = this._hasNeighborFullHitBox(0, -1);\n const isBottomFull = this._hasNeighborFullHitBox(0, 1);\n\n let hitBoxesCount = 0;\n if (isLeftFull || isRightFull) {\n let minX = isLeftFull ? -width : 0;\n let maxX = isRightFull ? 2 * width : width;\n if (hitBoxesCount >= this.hitBoxes.length) {\n this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[hitBoxesCount],\n minX,\n 0,\n maxX,\n height\n );\n hitBoxesCount++;\n }\n if (isTopFull || isBottomFull) {\n let minY = isTopFull ? -height : 0;\n let maxY = isBottomFull ? 2 * height : height;\n if (hitBoxesCount >= this.hitBoxes.length) {\n this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[hitBoxesCount],\n 0,\n minY,\n width,\n maxY\n );\n hitBoxesCount++;\n }\n if (hitBoxesCount === 0) {\n if (this.hitBoxes.length === 0) {\n this.hitBoxes[0] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[0],\n 0,\n 0,\n width,\n height\n );\n hitBoxesCount++;\n }\n this.hitBoxes.length = hitBoxesCount;\n } else {\n for (\n let polygonIndex = 0;\n polygonIndex < definitionHitboxes.length;\n polygonIndex++\n ) {\n const defPolygon = definitionHitboxes[polygonIndex];\n if (polygonIndex >= this.hitBoxes.length) {\n // This can't happen in practice as only the simple tile map can be\n // modify and it only contains full hit boxes.\n this.hitBoxes[polygonIndex] = gdjs.Polygon.createRectangle(0, 0);\n }\n const polygon = this.hitBoxes[polygonIndex];\n\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n const defVertex = defPolygon[vertexIndex];\n const vertex = polygon.vertices[vertexIndex];\n\n vertex[0] = defVertex[0];\n vertex[1] = defVertex[1];\n }\n }\n }\n\n // Transform the hit boxes.\n // First compute the affine transformation relative to the tile.\n // Then the transformation is applied to each polygon in the hitboxes.\n // TODO: If the tile contains hitboxes that are both extended and not full,\n // this code should be adapted so that the transformation considers the\n // actual width and height of the hitbox (and not the tile).\n // At the moment, extended hitboxes can only be full and since flipping\n // transformations don't change a full hitbox, those transformations\n // are not applied.\n\n const tileTransformation =\n TransformedCollisionTile.workingTransformation;\n tileTransformation.setToTranslation(width * this.x, height * this.y);\n if (!hasFullHitBox) {\n if (this.layer.isFlippedHorizontally(this.x, this.y)) {\n tileTransformation.flipX(width / 2);\n }\n if (this.layer.isFlippedVertically(this.x, this.y)) {\n tileTransformation.flipY(height / 2);\n }\n if (this.layer.isFlippedDiagonally(this.x, this.y)) {\n tileTransformation.flipX(width / 2);\n tileTransformation.rotateAround(Math.PI / 2, width / 2, height / 2);\n }\n }\n tileTransformation.preConcatenate(tileMap.getTransformation());\n for (\n let polygonIndex = 0;\n polygonIndex < this.hitBoxes.length;\n polygonIndex++\n ) {\n const polygon = this.hitBoxes[polygonIndex];\n\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n const vertex = polygon.vertices[vertexIndex];\n\n tileTransformation.transform(vertex, vertex);\n }\n }\n this._setHitboxesUpToDate();\n return this.hitBoxes;\n }\n\n private _hasNeighborFullHitBox(deltaX: integer, deltaY: integer) {\n const sourceLayer = this.layer._source;\n const tileId = sourceLayer.getTileId(this.x + deltaX, this.y + deltaY);\n const tileDefinition =\n tileId && this.layer.tileMap.getTileDefinition(tileId);\n return (\n tileDefinition && tileDefinition.hasFullHitBox(this.layer.tileMap.tag)\n );\n }\n\n private static setRectangle(\n polygon: gdjs.Polygon,\n minX: float,\n minY: float,\n maxX: float,\n maxY: float\n ) {\n const vertices = polygon.vertices;\n vertices[0][0] = minX;\n vertices[0][1] = minY;\n vertices[1][0] = maxX;\n vertices[1][1] = minY;\n vertices[2][0] = maxX;\n vertices[2][1] = maxY;\n vertices[3][0] = minX;\n vertices[3][1] = maxY;\n }\n }\n }\n}\n"],
5
- "mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CAME,aAAkC,CAgCvC,YACE,EACA,EACA,EAA4B,KAC5B,CAvBM,qBAA6C,GAAI,GAAK,qBAKtD,4BAAo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B,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,IA/RrB,QAmB0B,AAnB1B,EAmB0B,sBAAmD,GAAI,GAAK,uBA9oBvE,+BADT",
4
+ "sourcesContent": ["/// <reference path=\"../helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export namespace TileMap {\n /**\n * A tile map transformed with an affine transformation.\n *\n * @see {@link getHitboxesAround} It gives a fast access to hitboxes for collision handling.\n */\n export class TransformedCollisionTileMap {\n /**\n * The model that describes the tile map.\n */\n private _source: TileMapHelper.EditableTileMap;\n tag: string;\n private _layerIndex: integer | null;\n private _layers: Map<integer, TransformedCollisionTileMapLayer>;\n // TODO Tiled allows to offset the layers\n /**\n * The transformation from the time map coordinate (in pixels)\n * to the scene coordinate (in pixels).\n */\n private _transformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n /**\n * The transformation from the scene coordinate (in pixels)\n * to the time map coordinate (in pixels).\n */\n private _inverseTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n /**\n * This allows tiles to know if their hitboxes must be updated.\n * @see {@link TransformedCollisionTile.affineTransformationUpToDateCount}\n */\n _transformationUpToDateCount: integer = 1;\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n /**\n * @param source The model that describes the tile map.\n */\n constructor(\n source: TileMapHelper.EditableTileMap,\n tag: string,\n layerIndex: number | null = null\n ) {\n this._source = source;\n this.tag = tag;\n this._layerIndex = layerIndex;\n this._layers = new Map<integer, TransformedCollisionTileMapLayer>();\n this._buildLayersFromTileMap(source, this._layers);\n }\n\n updateFromTileMap(tileMap: TileMapHelper.EditableTileMap) {\n this._source = tileMap;\n this._layers = new Map<integer, TransformedCollisionTileMapLayer>();\n\n this._buildLayersFromTileMap(tileMap, this._layers);\n }\n\n _buildLayersFromTileMap(\n tileMap: TileMapHelper.EditableTileMap,\n layers: Map<integer, TransformedCollisionTileMapLayer>\n ) {\n if (this._layerIndex) {\n const tileLayer = tileMap.getTileLayer(this._layerIndex);\n if (!tileLayer) {\n return;\n }\n layers.set(\n tileLayer.id,\n new TransformedCollisionTileMapLayer(this, tileLayer)\n );\n } else {\n for (const sourceLayer of tileMap.getLayers()) {\n // TODO A visitor could be used to avoid a cast.\n if (!(sourceLayer instanceof TileMapHelper.EditableTileMapLayer)) {\n // TODO Collision mask for object layers is not handled.\n continue;\n }\n const tileLayer = sourceLayer as TileMapHelper.EditableTileMapLayer;\n layers.set(\n tileLayer.id,\n new TransformedCollisionTileMapLayer(this, tileLayer)\n );\n }\n }\n }\n\n /**\n * @returns The transformation from the time map coordinate (in pixels)\n * to the scene coordinate (in pixels).\n */\n getTransformation(): gdjs.AffineTransformation {\n return this._transformation;\n }\n\n /**\n * @param transformation the transformation from the tile map coordinate\n * (in pixels) to the scene coordinate (in pixels).\n */\n setTransformation(transformation: gdjs.AffineTransformation) {\n this._transformation = transformation;\n\n const inverseTransformation = this._inverseTransformation;\n inverseTransformation.copyFrom(transformation);\n inverseTransformation.invert();\n\n this._invalidate();\n }\n\n private _invalidate() {\n this._transformationUpToDateCount =\n (this._transformationUpToDateCount + 1) % Number.MAX_SAFE_INTEGER;\n }\n\n invalidateTile(layerIndex: integer, x: integer, y: integer) {\n const layer = this.getLayer(layerIndex);\n if (layer) {\n const tile = layer.get(x, y);\n if (tile) {\n tile.invalidate();\n }\n }\n }\n\n /**\n * @returns The tile map width in pixels.\n */\n getWidth() {\n return this._source.getWidth();\n }\n\n /**\n * @returns The tile map height in pixels.\n */\n getHeight() {\n return this._source.getHeight();\n }\n\n /**\n * @returns The tile width in pixels.\n */\n getTileHeight() {\n return this._source.getTileHeight();\n }\n\n /**\n * @returns The tile height in pixels.\n */\n getTileWidth() {\n return this._source.getTileWidth();\n }\n\n /**\n * @returns The number of tile columns in the map.\n */\n getDimensionX() {\n return this._source.getDimensionX();\n }\n\n /**\n * @returns The number of tile rows in the map.\n */\n getDimensionY() {\n return this._source.getDimensionY();\n }\n\n /**\n * @param tileId The tile identifier\n * @returns The tile definition form the tile set.\n */\n getTileDefinition(tileId: integer) {\n return this._source.getTileDefinition(tileId);\n }\n\n /**\n * @param layerId The layer identifier.\n * @returns the layer\n */\n getLayer(layerId: integer): TransformedCollisionTileMapLayer | undefined {\n return this._layers.get(layerId);\n }\n\n /**\n * @returns All the layers of the tile map.\n */\n getLayers(): Iterable<TransformedCollisionTileMapLayer> {\n return this._layers.values();\n }\n\n /**\n * Check if a point is inside a tile with a given tag.\n *\n * It doesn't use the tile hitboxes.\n * It only check the point is inside the tile square.\n *\n * @param x The X coordinate of the point to check.\n * @param y The Y coordinate of the point to check.\n * @param tag The tile tag\n * @returns true when the point is inside a tile with a given tag.\n */\n pointIsInsideTile(x: float, y: float, tag: string): boolean {\n const workingPoint: FloatPoint =\n TransformedCollisionTileMap.workingPoint;\n workingPoint[0] = x;\n workingPoint[1] = y;\n this._inverseTransformation.transform(workingPoint, workingPoint);\n return this._source.pointIsInsideTile(\n workingPoint[0],\n workingPoint[1],\n tag\n );\n }\n\n /**\n * @param tag The tile tag.\n * @param left The left border of the area in the scene.\n * @param top The top border of the area in the scene.\n * @param right The right border of the area in the scene.\n * @param bottom The left border of the area in the scene.\n * @returns At least all the hitboxes from the given area\n * where tiles have the right tag.\n *\n * @see {@link gdjs.RuntimeObject.getHitboxesAround}\n */\n getHitboxesAround(\n tag: string,\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // Return the hitboxes from the tiles that overlap\n // the AABB of the area in the tile map basis.\n // Some of these tiles are not event in the given area\n // but this is a good trade of between the number of\n // useless returned hitboxes and the time to find them.\n\n // Transform the vertices of the area\n // from the scene basis to the tile map basis.\n const inverseTransformation = this._inverseTransformation;\n const workingPoint: FloatPoint =\n TransformedCollisionTileMap.workingPoint;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n inverseTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n inverseTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n inverseTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n inverseTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n // Calculate the AABB of the area in the tile map basis.\n const xMin = Math.max(\n 0,\n Math.floor(\n Math.min(topLeftX, topRightX, bottomRightX, bottomLeftX) /\n this._source.getTileWidth()\n )\n );\n const xMax = Math.min(\n this.getDimensionX() - 1,\n Math.floor(\n Math.max(topLeftX, topRightX, bottomRightX, bottomLeftX) /\n this._source.getTileWidth()\n )\n );\n const yMin = Math.max(\n 0,\n Math.floor(\n Math.min(topLeftY, topRightY, bottomRightY, bottomLeftY) /\n this._source.getTileHeight()\n )\n );\n const yMax = Math.min(\n this.getDimensionY() - 1,\n Math.floor(\n Math.max(topLeftY, topRightY, bottomRightY, bottomLeftY) /\n this._source.getTileHeight()\n )\n );\n\n return this.getHitboxes(tag, xMin, yMin, xMax, yMax);\n }\n\n /**\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n * @returns All the hitboxes from the tiles overlapping\n * the given area where tiles have the right tag.\n */\n getHitboxes(\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ): Iterable<gdjs.Polygon> {\n return new MapCollisionMaskIterable(this, tag, xMin, yMin, xMax, yMax);\n }\n\n /**\n * @param tag The tile tag.\n * @returns All the hitboxes from the tiles having the right tag.\n */\n getAllHitboxes(tag: string): Iterable<gdjs.Polygon> {\n return this.getHitboxes(\n tag,\n 0,\n 0,\n this._source.getDimensionX() - 1,\n this._source.getDimensionY() - 1\n );\n }\n }\n\n /**\n * Iterable over the tile hitboxes of a given area and tag.\n */\n class MapCollisionMaskIterable implements Iterable<gdjs.Polygon> {\n map: TransformedCollisionTileMap;\n tag: string;\n xMin: integer;\n yMin: integer;\n xMax: integer;\n yMax: integer;\n\n /**\n * Avoid to allocate an empty iterator each time\n * the iterable is initialized.\n */\n static emptyItr: Iterator<gdjs.Polygon> = {\n next: () => ({ value: undefined, done: true }),\n };\n\n /**\n * @param map The tile map.\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n */\n constructor(\n map: TransformedCollisionTileMap,\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ) {\n this.map = map;\n this.tag = tag;\n this.xMin = xMin;\n this.yMin = yMin;\n this.xMax = xMax;\n this.yMax = yMax;\n }\n\n [Symbol.iterator]() {\n // Flatten the iterable of each layers into one.\n let layerItr = this.map.getLayers()[Symbol.iterator]();\n let listItr: Iterator<gdjs.Polygon> = MapCollisionMaskIterable.emptyItr;\n\n return {\n next: () => {\n let listNext = listItr.next();\n while (listNext.done) {\n const layerNext = layerItr.next();\n if (layerNext.done) {\n return listNext;\n }\n listItr = layerNext.value\n .getHitboxes(\n this.tag,\n this.xMin,\n this.yMin,\n this.xMax,\n this.yMax\n )\n [Symbol.iterator]();\n listNext = listItr.next();\n }\n return listNext;\n },\n };\n }\n }\n\n /**\n * A tile map layer transformed with an affine transformation.\n */\n export class TransformedCollisionTileMapLayer {\n /**\n * The time map that contains this layer.\n */\n readonly tileMap: TransformedCollisionTileMap;\n /**\n * The model that describes the tile map.\n */\n readonly _source: TileMapHelper.EditableTileMapLayer;\n private readonly _tiles: TransformedCollisionTile[][];\n\n /**\n * @param tileMap The time map that contains this layer.\n * @param source The model that describes the tile map.\n */\n constructor(\n tileMap: TransformedCollisionTileMap,\n source: TileMapHelper.EditableTileMapLayer\n ) {\n this.tileMap = tileMap;\n this._source = source;\n this._tiles = [];\n const dimX = this._source.getDimensionX();\n const dimY = this._source.getDimensionY();\n this._tiles.length = dimY;\n for (let y = 0; y < dimY; y++) {\n this._tiles[y] = [];\n this._tiles[y].length = dimX;\n for (let x = 0; x < dimX; x++) {\n this._tiles[y][x] = new TransformedCollisionTile(this, x, y);\n }\n }\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @return The tile from the tile set.\n */\n get(x: integer, y: integer): TransformedCollisionTile | undefined {\n const row = this._tiles[y];\n return row ? row[x] : undefined;\n }\n\n /**\n * The number of tile columns in the layer.\n */\n getDimensionX() {\n return this._tiles.length === 0 ? 0 : this._tiles[0].length;\n }\n\n /**\n * The number of tile rows in the layer.\n */\n getDimensionY() {\n return this._tiles.length;\n }\n\n /**\n * @returns The layer width in pixels.\n */\n getWidth() {\n return this._source.getWidth();\n }\n\n /**\n * @returns The layer height in pixels.\n */\n getHeight() {\n return this._source.getHeight();\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped diagonally.\n */\n isFlippedDiagonally(x: integer, y: integer) {\n return this._source.isFlippedDiagonally(x, y);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped vertically.\n */\n isFlippedVertically(x: integer, y: integer) {\n return this._source.isFlippedVertically(x, y);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @returns true if the tile is flipped horizontally.\n */\n isFlippedHorizontally(x: integer, y: integer) {\n return this._source.isFlippedHorizontally(x, y);\n }\n /**\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n * @returns All the hitboxes from the tiles overlapping\n * the given area where tiles have the right tag.\n */\n getHitboxes(\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ): Iterable<gdjs.Polygon> {\n return new LayerCollisionMaskIterable(\n this,\n tag,\n xMin,\n yMin,\n xMax,\n yMax\n );\n }\n\n /**\n * @param tag The tile tag.\n * @returns All the hitboxes from the tiles having the right tag.\n */\n getAllHitboxes(tag: string): Iterable<gdjs.Polygon> {\n return this.getHitboxes(\n tag,\n 0,\n 0,\n this.getDimensionX() - 1,\n this.getDimensionY() - 1\n );\n }\n }\n\n /**\n * Iterable over the tile hitboxes of a given area and tag.\n */\n class LayerCollisionMaskIterable implements Iterable<gdjs.Polygon> {\n layer: TransformedCollisionTileMapLayer;\n tag: string;\n xMin: integer;\n yMin: integer;\n xMax: integer;\n yMax: integer;\n\n /**\n * Avoid to allocate an empty iterator each time\n * the iterable is initialized.\n */\n static emptyItr: Iterator<gdjs.Polygon> = {\n next: () => ({ value: undefined, done: true }),\n };\n\n /**\n * @param map The tile map.\n * @param tag The tile tag.\n * @param xMin The fist column to include.\n * @param yMin The fist row to include.\n * @param xMax The last column to include.\n * @param yMax The last row to include.\n */\n constructor(\n layer: TransformedCollisionTileMapLayer,\n tag: string,\n xMin: integer,\n yMin: integer,\n xMax: integer,\n yMax: integer\n ) {\n this.layer = layer;\n this.tag = tag;\n this.xMin = xMin;\n this.yMin = yMin;\n this.xMax = xMax;\n this.yMax = yMax;\n }\n\n [Symbol.iterator]() {\n // Flatten the iterable of each tile into one.\n\n // xMin and yMin next increment\n let x = this.xMax;\n let y = this.yMin - 1;\n let polygonItr: Iterator<gdjs.Polygon> =\n LayerCollisionMaskIterable.emptyItr;\n\n return {\n next: () => {\n let listNext = polygonItr.next();\n while (listNext.done) {\n x++;\n if (x > this.xMax) {\n y++;\n x = this.xMin;\n }\n if (y > this.yMax) {\n // done\n return listNext;\n }\n const tile = this.layer.get(x, y);\n if (!tile) {\n continue;\n }\n const definition = tile.getDefinition();\n if (!definition) {\n continue;\n }\n if (definition.hasTaggedHitBox(this.tag)) {\n polygonItr = tile.getHitboxes()[Symbol.iterator]();\n listNext = polygonItr.next();\n }\n }\n return listNext;\n },\n };\n }\n }\n\n /**\n * A tile transformed with an affine transformation.\n */\n class TransformedCollisionTile {\n /**\n * The layer that contains this tile.\n */\n readonly layer: TransformedCollisionTileMapLayer;\n /**\n * The column index in the layer.\n */\n readonly x: integer;\n /**\n * The row index in the layer.\n */\n readonly y: integer;\n private readonly hitBoxes: gdjs.Polygon[];\n private affineTransformationUpToDateCount: integer = 0;\n\n /**\n * An reusable AffineTransformation to avoid allocations.\n */\n private static readonly workingTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n\n /**\n *\n * @param layer The layer that contains this tile.\n * @param x The column index in the layer.\n * @param y The row index in the layer.\n */\n constructor(\n layer: TransformedCollisionTileMapLayer,\n x: integer,\n y: integer\n ) {\n this.layer = layer;\n this.x = x;\n this.y = y;\n const definition = this.getDefinition();\n this.hitBoxes = [];\n if (definition) {\n const tag = this.layer.tileMap.tag;\n const definitionHitboxes = definition.getHitBoxes(tag);\n if (definitionHitboxes) {\n this.hitBoxes.length = definitionHitboxes.length;\n for (\n let polygonIndex = 0;\n polygonIndex < this.hitBoxes.length;\n polygonIndex++\n ) {\n const polygon = new gdjs.Polygon();\n this.hitBoxes[polygonIndex] = polygon;\n polygon.vertices.length = definitionHitboxes[polygonIndex].length;\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n polygon.vertices[vertexIndex] = [0, 0];\n }\n }\n }\n }\n }\n\n /**\n * @returns The tile definition from the tile set.\n */\n getDefinition(): TileMapHelper.TileDefinition {\n return this.layer.tileMap.getTileDefinition(\n this.layer._source.getTileId(this.x, this.y)!\n )!;\n }\n\n private _isHitboxesUpToDate() {\n return (\n this.affineTransformationUpToDateCount ===\n this.layer.tileMap._transformationUpToDateCount\n );\n }\n\n private _setHitboxesUpToDate() {\n this.affineTransformationUpToDateCount =\n this.layer.tileMap._transformationUpToDateCount;\n }\n\n invalidate() {\n this.affineTransformationUpToDateCount = -1;\n // Also invalidate neighbors because their hit boxes may need to be\n // extended differently.\n let neighbor = this.layer.get(this.x - 1, this.y);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x + 1, this.y);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x, this.y - 1);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n neighbor = this.layer.get(this.x, this.y + 1);\n if (neighbor) {\n neighbor.affineTransformationUpToDateCount = -1;\n }\n }\n\n /**\n * @returns The hitboxes of this tile in the scene basis.\n */\n getHitboxes(): Polygon[] {\n if (this._isHitboxesUpToDate()) {\n return this.hitBoxes;\n }\n\n const definition = this.getDefinition();\n if (!definition) {\n this._setHitboxesUpToDate();\n this.hitBoxes.length = 0;\n return this.hitBoxes;\n }\n const tag = this.layer.tileMap.tag;\n const definitionHitboxes = definition.getHitBoxes(tag);\n if (!definitionHitboxes) {\n this._setHitboxesUpToDate();\n this.hitBoxes.length = 0;\n return this.hitBoxes;\n }\n\n const tileMap = this.layer.tileMap;\n const width = tileMap.getTileWidth();\n const height = tileMap.getTileHeight();\n\n // Extend the hit boxes.\n // It avoids small objects to be pushed side way into a wall when they\n // should be pop out of the wall.\n\n const hasFullHitBox =\n definitionHitboxes.length === 1 && definition.hasFullHitBox(tag);\n if (hasFullHitBox) {\n const isLeftFull = this._hasNeighborFullHitBox(-1, 0);\n const isRightFull = this._hasNeighborFullHitBox(1, 0);\n const isTopFull = this._hasNeighborFullHitBox(0, -1);\n const isBottomFull = this._hasNeighborFullHitBox(0, 1);\n\n let hitBoxesCount = 0;\n if (isLeftFull || isRightFull) {\n let minX = isLeftFull ? -width : 0;\n let maxX = isRightFull ? 2 * width : width;\n if (hitBoxesCount >= this.hitBoxes.length) {\n this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[hitBoxesCount],\n minX,\n 0,\n maxX,\n height\n );\n hitBoxesCount++;\n }\n if (isTopFull || isBottomFull) {\n let minY = isTopFull ? -height : 0;\n let maxY = isBottomFull ? 2 * height : height;\n if (hitBoxesCount >= this.hitBoxes.length) {\n this.hitBoxes[hitBoxesCount] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[hitBoxesCount],\n 0,\n minY,\n width,\n maxY\n );\n hitBoxesCount++;\n }\n if (hitBoxesCount === 0) {\n if (this.hitBoxes.length === 0) {\n this.hitBoxes[0] = gdjs.Polygon.createRectangle(0, 0);\n }\n TransformedCollisionTile.setRectangle(\n this.hitBoxes[0],\n 0,\n 0,\n width,\n height\n );\n hitBoxesCount++;\n }\n this.hitBoxes.length = hitBoxesCount;\n } else {\n for (\n let polygonIndex = 0;\n polygonIndex < definitionHitboxes.length;\n polygonIndex++\n ) {\n const defPolygon = definitionHitboxes[polygonIndex];\n if (polygonIndex >= this.hitBoxes.length) {\n // This can't happen in practice as only the simple tile map can be\n // modify and it only contains full hit boxes.\n this.hitBoxes[polygonIndex] = gdjs.Polygon.createRectangle(0, 0);\n }\n const polygon = this.hitBoxes[polygonIndex];\n\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n const defVertex = defPolygon[vertexIndex];\n const vertex = polygon.vertices[vertexIndex];\n\n vertex[0] = defVertex[0];\n vertex[1] = defVertex[1];\n }\n }\n }\n\n // Transform the hit boxes.\n // First compute the affine transformation relative to the tile.\n // Then the transformation is applied to each polygon in the hitboxes.\n // TODO: If the tile contains hitboxes that are both extended and not full,\n // this code should be adapted so that the transformation considers the\n // actual width and height of the hitbox (and not the tile).\n // At the moment, extended hitboxes can only be full and since flipping\n // transformations don't change a full hitbox, those transformations\n // are not applied.\n\n const tileTransformation =\n TransformedCollisionTile.workingTransformation;\n tileTransformation.setToTranslation(width * this.x, height * this.y);\n if (!hasFullHitBox) {\n if (this.layer.isFlippedHorizontally(this.x, this.y)) {\n tileTransformation.flipX(width / 2);\n }\n if (this.layer.isFlippedVertically(this.x, this.y)) {\n tileTransformation.flipY(height / 2);\n }\n if (this.layer.isFlippedDiagonally(this.x, this.y)) {\n tileTransformation.flipX(width / 2);\n tileTransformation.rotateAround(Math.PI / 2, width / 2, height / 2);\n }\n }\n tileTransformation.preConcatenate(tileMap.getTransformation());\n for (\n let polygonIndex = 0;\n polygonIndex < this.hitBoxes.length;\n polygonIndex++\n ) {\n const polygon = this.hitBoxes[polygonIndex];\n\n for (\n let vertexIndex = 0;\n vertexIndex < polygon.vertices.length;\n vertexIndex++\n ) {\n const vertex = polygon.vertices[vertexIndex];\n\n tileTransformation.transform(vertex, vertex);\n }\n }\n this._setHitboxesUpToDate();\n return this.hitBoxes;\n }\n\n private _hasNeighborFullHitBox(deltaX: integer, deltaY: integer) {\n const sourceLayer = this.layer._source;\n const tileId = sourceLayer.getTileId(this.x + deltaX, this.y + deltaY);\n const tileDefinition =\n tileId && this.layer.tileMap.getTileDefinition(tileId);\n return (\n tileDefinition && tileDefinition.hasFullHitBox(this.layer.tileMap.tag)\n );\n }\n\n private static setRectangle(\n polygon: gdjs.Polygon,\n minX: float,\n minY: float,\n maxX: float,\n maxY: float\n ) {\n const vertices = polygon.vertices;\n vertices[0][0] = minX;\n vertices[0][1] = minY;\n vertices[1][0] = maxX;\n vertices[1][1] = minY;\n vertices[2][0] = maxX;\n vertices[2][1] = maxY;\n vertices[3][0] = minX;\n vertices[3][1] = maxY;\n }\n }\n }\n}\n"],
5
+ "mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CAME,aAAkC,CAkCvC,YACE,EACA,EACA,EAA4B,KAC5B,CAzBM,qBACN,GAAI,GAAK,qBAKH,4BACN,GAAI,GAAK,qBAKX,kCAAwC,EActC,KAAK,QAAU,EACf,KAAK,IAAM,EACX,KAAK,YAAc,EACnB,KAAK,QAAU,GAAI,KACnB,KAAK,wBAAwB,EAAQ,KAAK,SAG5C,kBAAkB,EAAwC,CACxD,KAAK,QAAU,EACf,KAAK,QAAU,GAAI,KAEnB,KAAK,wBAAwB,EAAS,KAAK,SAG7C,wBACE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BAAiB,EAAQ,KAAK,EAAG,EAAS,KAAK,GAC7D,GACC,MAAK,MAAM,sBAAsB,KAAK,EAAG,KAAK,IAChD,EAAmB,MAAM,EAAQ,GAE/B,KAAK,MAAM,oBAAoB,KAAK,EAAG,KAAK,IAC9C,EAAmB,MAAM,EAAS,GAEhC,KAAK,MAAM,oBAAoB,KAAK,EAAG,KAAK,IAC9C,GAAmB,MAAM,EAAQ,GACjC,EAAmB,aAAa,KAAK,GAAK,EAAG,EAAQ,EAAG,EAAS,KAGrE,EAAmB,eAAe,EAAQ,qBAC1C,OACM,GAAe,EACnB,EAAe,KAAK,SAAS,OAC7B,IACA,CACA,KAAM,GAAU,KAAK,SAAS,GAE9B,OACM,GAAc,EAClB,EAAc,EAAQ,SAAS,OAC/B,IACA,CACA,KAAM,GAAS,EAAQ,SAAS,GAEhC,EAAmB,UAAU,EAAQ,IAGzC,YAAK,uBACE,KAAK,SAGN,uBAAuB,EAAiB,EAAiB,CAE/D,KAAM,GAAS,AADK,KAAK,MAAM,QACJ,UAAU,KAAK,EAAI,EAAQ,KAAK,EAAI,GACzD,EACJ,GAAU,KAAK,MAAM,QAAQ,kBAAkB,GACjD,MACE,IAAkB,EAAe,cAAc,KAAK,MAAM,QAAQ,WAIvD,cACb,EACA,EACA,EACA,EACA,EACA,CACA,KAAM,GAAW,EAAQ,SACzB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,EACjB,EAAS,GAAG,GAAK,IAjSrB,QAmB0B,AAnB1B,EAmB0B,sBACtB,GAAI,GAAK,uBAjpBE,+BADT",
6
6
  "names": []
7
7
  }
@@ -177,9 +177,7 @@ export declare class EditableTileMap {
177
177
  isTileFlippedOnX(x: integer, y: integer, layerId: integer): boolean;
178
178
  isTileFlippedOnY(x: integer, y: integer, layerId: integer): boolean;
179
179
  removeTile(x: integer, y: integer, layerId: integer): void;
180
- trimEmptyColumnsAndRowToFitLayer(
181
- layerId: integer
182
- ):
180
+ trimEmptyColumnsAndRowToFitLayer(layerId: integer):
183
181
  | {
184
182
  poppedRows: number;
185
183
  poppedColumns: number;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/TileMap/simpletilemapruntimeobject.ts"],
4
- "sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n wid: number;\n hei: number;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float = 255;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTileMapAsJsObject = {\n tileWidth: this._tileSize,\n tileHeight: this._tileSize,\n dimX: 1,\n dimY: 1,\n layers: [{ id: 0, alpha: this._opacity / 255, tiles: [] }],\n };\n this._initialTilesWithHitBox = (objectData.content\n .tilesWithHitBox as string)\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n this._renderer.updatePosition();\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n\n this.updateTransformation();\n });\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (\n networkSyncData.wid !== undefined &&\n networkSyncData.wid !== this.getWidth()\n ) {\n this.setWidth(networkSyncData.wid);\n }\n if (\n networkSyncData.hei !== undefined &&\n networkSyncData.hei !== this.getHeight()\n ) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\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 // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return (this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(textureName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\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 tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\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 /**\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 updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\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 if (!this._collisionTileMap) return;\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 getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\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 if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation = this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [\n columnIndex,\n rowIndex,\n ] = this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
5
- "mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CA6BS,qBACG,GAAK,aACiD,CA0B9D,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAxB3B,cAAkB,IAOlB,kBAAe,MACf,iBAAc,EAGd,qBAA2B,GAC3B,mCAA2D,GAAI,GAAK,qBACpE,mCAA2D,GAAI,GAAK,qBACpE,uBAAqE,KACrE,gBAAqB,YACb,+BAAqC,GAS3C,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,0BAA4B,CAC/B,UAAW,KAAK,UAChB,WAAY,KAAK,UACjB,KAAM,EACN,KAAM,EACN,OAAQ,CAAC,CAAE,GAAI,EAAG,MAAO,KAAK,SAAW,IAAK,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AU,kBAGxB,oBAA8B,CAC5B,MAAO,MAAK,UAAU,qBAGxB,uBAAiC,CAC/B,MAAO,MAAK,aAGd,oBAA8B,CAC5B,MAAO,MAAK,YAlyBT,QAMmB,AANnB,EAMmB,aAA2B,CAAC,EAAG,GANlD,EAAM,6BAqyBb,EAAK,eACH,yBACA,EAAK,8BAp0BC",
4
+ "sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n wid: number;\n hei: number;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler\n {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float = 255;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTileMapAsJsObject = {\n tileWidth: this._tileSize,\n tileHeight: this._tileSize,\n dimX: 1,\n dimY: 1,\n layers: [{ id: 0, alpha: this._opacity / 255, tiles: [] }],\n };\n this._initialTilesWithHitBox = (\n objectData.content.tilesWithHitBox as string\n )\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n this._renderer.updatePosition();\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n\n this.updateTransformation();\n });\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (\n networkSyncData.wid !== undefined &&\n networkSyncData.wid !== this.getWidth()\n ) {\n this.setWidth(networkSyncData.wid);\n }\n if (\n networkSyncData.hei !== undefined &&\n networkSyncData.hei !== this.getHeight()\n ) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\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 // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\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 tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\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 this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\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 /**\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 updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\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 if (!this._collisionTileMap) return;\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 getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\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 if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation =\n this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
5
+ "mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CA6BS,qBACG,GAAK,aAEf,CA4BE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GA1B3B,cAAkB,IAOlB,kBAAe,MACf,iBAAc,EAGd,qBAA2B,GAC3B,mCACE,GAAI,GAAK,qBACX,mCACE,GAAI,GAAK,qBACX,uBAAqE,KACrE,gBAAqB,YACb,+BAAqC,GAS3C,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,0BAA4B,CAC/B,UAAW,KAAK,UAChB,WAAY,KAAK,UACjB,KAAM,EACN,KAAM,EACN,OAAQ,CAAC,CAAE,GAAI,EAAG,MAAO,KAAK,SAAW,IAAK,MAAO,MAEvD,KAAK,wBACH,EAAW,QAAQ,gBAElB,MAAM,KACN,OAAO,AAAC,GAAO,CAAC,CAAC,GACjB,IAAI,AAAC,GAAe,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B,MAAO,MAAK,YAxxBT,QAOmB,AAPnB,EAOmB,aAA2B,CAAC,EAAG,GAPlD,EAAM,6BA2xBb,EAAK,eACH,yBACA,EAAK,8BA1zBC",
6
6
  "names": []
7
7
  }
@@ -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 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 = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\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,CAsCS,eACG,GAAK,a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K,QAAU,EACf,KAAK,QAAU,EAAS,KAAK,kBAAkB,YAC/C,KAAK,0BAA4B,GACjC,KAAK,sBAGP,UAAkB,CAChB,MAAO,MAAK,OAGd,WAAmB,CACjB,MAAO,MAAK,QAGd,WAAmB,CACjB,MAAO,MAAK,QAGd,WAAmB,CACjB,MAAO,MAAK,SA5mBT,EAAM,oCA+mBb,EAAK,eACH,yBACA,EAAK,mCAEP,EAAkC,yBAA2B,KAzpBrD",
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,GAA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,GAAS,GAEP,KAAK,UAAY,GAGrB,MAAK,QAAU,EACf,KAAK,QAAU,EAAS,KAAK,kBAAkB,YAC/C,KAAK,0BAA4B,GACjC,KAAK,sBAGP,UAAkB,CAChB,MAAO,MAAK,OAGd,WAAmB,CACjB,MAAO,MAAK,QAGd,WAAmB,CACjB,MAAO,MAAK,QAGd,WAAmB,CACjB,MAAO,MAAK,SA5mBT,EAAM,oCA+mBb,EAAK,eACH,yBACA,EAAK,mCAEP,EAAkC,yBAA2B,KAzpBrD",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.ts"],
4
- "sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\n/// <reference path=\"pixi-tilemap/dist/pixi-tilemap.d.ts\" />\nnamespace gdjs {\n /**\n * The PIXI.js renderer for the Tile map runtime object.\n *\n * @class TileMapRuntimeObjectPixiRenderer\n */\n export class TileMapRuntimeObjectPixiRenderer {\n private _object:\n | gdjs.TileMapRuntimeObject\n | gdjs.SimpleTileMapRuntimeObject;\n // TODO Move this attribute in the object as it's a model.\n _tileMap: TileMapHelper.EditableTileMap | null = null;\n\n private _pixiObject: PIXI.tilemap.CompositeTilemap;\n\n /**\n * @param runtimeObject The object to render\n * @param instanceContainer The gdjs.RuntimeScene in which the object is\n */\n constructor(\n runtimeObject:\n | gdjs.TileMapRuntimeObject\n | gdjs.SimpleTileMapRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n\n // This setting allows tile maps with more than 16K tiles.\n PIXI.tilemap.settings.use32bitIndex = true;\n\n // Load (or reset)\n this._pixiObject = new PIXI.tilemap.CompositeTilemap();\n this._pixiObject.tileAnim = [0, 0];\n\n instanceContainer\n .getLayer('')\n .getRenderer()\n .addRendererObject(this._pixiObject, runtimeObject.getZOrder());\n this.updateAngle();\n this.updateOpacity();\n this.updatePosition();\n }\n\n getRendererObject() {\n return this._pixiObject;\n }\n\n incrementAnimationFrameX(instanceContainer: gdjs.RuntimeInstanceContainer) {\n this._pixiObject.tileAnim[0] += 1;\n }\n\n updatePixiTileMap(\n tileMap: TileMapHelper.EditableTileMap,\n textureCache: TileMapHelper.TileTextureCache\n ) {\n this._tileMap = tileMap;\n TileMapHelper.PixiTileMapHelper.updatePixiTileMap(\n this._pixiObject,\n tileMap,\n textureCache,\n // @ts-ignore\n this._object._displayMode,\n this._object._layerIndex\n );\n }\n\n refreshPixiTileMap(textureCache: TileMapHelper.TileTextureCache) {\n if (!this._tileMap) return;\n TileMapHelper.PixiTileMapHelper.updatePixiTileMap(\n this._pixiObject,\n this._tileMap,\n textureCache,\n // @ts-ignore\n this._object._displayMode,\n this._object._layerIndex\n );\n }\n\n getTileMap(): TileMapHelper.EditableTileMap | null {\n return this._tileMap;\n }\n\n updatePosition(): void {\n this._pixiObject.pivot.x = this.getTileMapWidth() / 2;\n this._pixiObject.pivot.y = this.getTileMapHeight() / 2;\n this._pixiObject.position.x = this._object.x + this.getWidth() / 2;\n this._pixiObject.position.y = this._object.y + this.getHeight() / 2;\n }\n\n updateAngle(): void {\n this._pixiObject.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n // TODO: Currently, the renderer does not use the object alpha to set\n // opacity. Setting alpha on each layer tile might not be useful as\n // each layer would be separately transparent instead of the whole tilemap.\n this._pixiObject.alpha = this._object._opacity / 255;\n const tileMap = this._tileMap;\n if (!tileMap) return;\n for (const layer of tileMap.getLayers()) {\n if (\n (this._object._displayMode === 'index' &&\n this._object._layerIndex !== layer.id) ||\n (this._object._displayMode === 'visible' && !layer.isVisible())\n ) {\n continue;\n }\n if (layer instanceof TileMapHelper.EditableTileMapLayer) {\n layer.setAlpha(this._pixiObject.alpha);\n }\n }\n }\n\n getTileMapWidth() {\n const tileMap = this._tileMap;\n return tileMap ? tileMap.getWidth() : 20;\n }\n\n getTileMapHeight() {\n const tileMap = this._tileMap;\n return tileMap ? tileMap.getHeight() : 20;\n }\n\n setWidth(width: float): void {\n this._pixiObject.scale.x = width / this.getTileMapWidth();\n this._pixiObject.position.x = this._object.x + width / 2;\n }\n\n setHeight(height: float): void {\n this._pixiObject.scale.y = height / this.getTileMapHeight();\n this._pixiObject.position.y = this._object.y + height / 2;\n }\n\n setScaleX(scaleX: float): void {\n this._pixiObject.scale.x = scaleX;\n const width = scaleX * this.getTileMapWidth();\n this._pixiObject.position.x = this._object.x + width / 2;\n }\n\n setScaleY(scaleY: float): void {\n this._pixiObject.scale.y = scaleY;\n const height = scaleY * this.getTileMapHeight();\n this._pixiObject.position.y = this._object.y + height / 2;\n }\n\n getWidth(): float {\n return this.getTileMapWidth() * this._pixiObject.scale.x;\n }\n\n getHeight(): float {\n return this.getTileMapHeight() * this._pixiObject.scale.y;\n }\n\n getScaleX(): float {\n return this._pixiObject.scale.x;\n }\n\n getScaleY(): float {\n return this._pixiObject.scale.y;\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @returns The tile's id.\n */\n getTileId(x: integer, y: integer, layerIndex: integer): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return -1;\n return tileMap.getTileId(x, y, layerIndex);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @param flip true if the tile should be flipped.\n */\n flipTileOnY(x: integer, y: integer, layerIndex: integer, flip: boolean) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n tileMap.flipTileOnY(x, y, layerIndex, flip);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @param flip true if the tile should be flipped.\n */\n flipTileOnX(x: integer, y: integer, layerIndex: integer, flip: boolean) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n tileMap.flipTileOnX(x, y, layerIndex, flip);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n */\n isTileFlippedOnX(x: integer, y: integer, layerIndex: integer): boolean {\n const tileMap = this._tileMap;\n if (!tileMap) return false;\n return tileMap.isTileFlippedOnX(x, y, layerIndex);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n */\n isTileFlippedOnY(x: integer, y: integer, layerIndex: integer): boolean {\n const tileMap = this._tileMap;\n if (!tileMap) return false;\n return tileMap.isTileFlippedOnY(x, y, layerIndex);\n }\n\n /**\n * @param targetRowCount The number of rows to have.\n */\n setGridRowCount(targetRowCount: integer) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n return tileMap.setDimensionY(targetRowCount);\n }\n /**\n * @param targetColumnCount The number of rows to have.\n */\n setGridColumnCount(targetColumnCount: integer) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n return tileMap.setDimensionX(targetColumnCount);\n }\n\n getGridRowCount(): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return 0;\n return tileMap.getDimensionY();\n }\n\n getGridColumnCount(): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return 0;\n return tileMap.getDimensionX();\n }\n\n destroy(): void {\n // Keep textures because they are shared by all tile maps.\n this._pixiObject.destroy(false);\n }\n }\n export const TileMapRuntimeObjectRenderer =\n gdjs.TileMapRuntimeObjectPixiRenderer;\n export type TileMapRuntimeObjectRenderer = gdjs.TileMapRuntimeObjectPixiRenderer;\n}\n"],
4
+ "sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\n/// <reference path=\"pixi-tilemap/dist/pixi-tilemap.d.ts\" />\nnamespace gdjs {\n /**\n * The PIXI.js renderer for the Tile map runtime object.\n *\n * @class TileMapRuntimeObjectPixiRenderer\n */\n export class TileMapRuntimeObjectPixiRenderer {\n private _object:\n | gdjs.TileMapRuntimeObject\n | gdjs.SimpleTileMapRuntimeObject;\n // TODO Move this attribute in the object as it's a model.\n _tileMap: TileMapHelper.EditableTileMap | null = null;\n\n private _pixiObject: PIXI.tilemap.CompositeTilemap;\n\n /**\n * @param runtimeObject The object to render\n * @param instanceContainer The gdjs.RuntimeScene in which the object is\n */\n constructor(\n runtimeObject:\n | gdjs.TileMapRuntimeObject\n | gdjs.SimpleTileMapRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n\n // This setting allows tile maps with more than 16K tiles.\n PIXI.tilemap.settings.use32bitIndex = true;\n\n // Load (or reset)\n this._pixiObject = new PIXI.tilemap.CompositeTilemap();\n this._pixiObject.tileAnim = [0, 0];\n\n instanceContainer\n .getLayer('')\n .getRenderer()\n .addRendererObject(this._pixiObject, runtimeObject.getZOrder());\n this.updateAngle();\n this.updateOpacity();\n this.updatePosition();\n }\n\n getRendererObject() {\n return this._pixiObject;\n }\n\n incrementAnimationFrameX(instanceContainer: gdjs.RuntimeInstanceContainer) {\n this._pixiObject.tileAnim[0] += 1;\n }\n\n updatePixiTileMap(\n tileMap: TileMapHelper.EditableTileMap,\n textureCache: TileMapHelper.TileTextureCache\n ) {\n this._tileMap = tileMap;\n TileMapHelper.PixiTileMapHelper.updatePixiTileMap(\n this._pixiObject,\n tileMap,\n textureCache,\n // @ts-ignore\n this._object._displayMode,\n this._object._layerIndex\n );\n }\n\n refreshPixiTileMap(textureCache: TileMapHelper.TileTextureCache) {\n if (!this._tileMap) return;\n TileMapHelper.PixiTileMapHelper.updatePixiTileMap(\n this._pixiObject,\n this._tileMap,\n textureCache,\n // @ts-ignore\n this._object._displayMode,\n this._object._layerIndex\n );\n }\n\n getTileMap(): TileMapHelper.EditableTileMap | null {\n return this._tileMap;\n }\n\n updatePosition(): void {\n this._pixiObject.pivot.x = this.getTileMapWidth() / 2;\n this._pixiObject.pivot.y = this.getTileMapHeight() / 2;\n this._pixiObject.position.x = this._object.x + this.getWidth() / 2;\n this._pixiObject.position.y = this._object.y + this.getHeight() / 2;\n }\n\n updateAngle(): void {\n this._pixiObject.rotation = gdjs.toRad(this._object.angle);\n }\n\n updateOpacity(): void {\n // TODO: Currently, the renderer does not use the object alpha to set\n // opacity. Setting alpha on each layer tile might not be useful as\n // each layer would be separately transparent instead of the whole tilemap.\n this._pixiObject.alpha = this._object._opacity / 255;\n const tileMap = this._tileMap;\n if (!tileMap) return;\n for (const layer of tileMap.getLayers()) {\n if (\n (this._object._displayMode === 'index' &&\n this._object._layerIndex !== layer.id) ||\n (this._object._displayMode === 'visible' && !layer.isVisible())\n ) {\n continue;\n }\n if (layer instanceof TileMapHelper.EditableTileMapLayer) {\n layer.setAlpha(this._pixiObject.alpha);\n }\n }\n }\n\n getTileMapWidth() {\n const tileMap = this._tileMap;\n return tileMap ? tileMap.getWidth() : 20;\n }\n\n getTileMapHeight() {\n const tileMap = this._tileMap;\n return tileMap ? tileMap.getHeight() : 20;\n }\n\n setWidth(width: float): void {\n this._pixiObject.scale.x = width / this.getTileMapWidth();\n this._pixiObject.position.x = this._object.x + width / 2;\n }\n\n setHeight(height: float): void {\n this._pixiObject.scale.y = height / this.getTileMapHeight();\n this._pixiObject.position.y = this._object.y + height / 2;\n }\n\n setScaleX(scaleX: float): void {\n this._pixiObject.scale.x = scaleX;\n const width = scaleX * this.getTileMapWidth();\n this._pixiObject.position.x = this._object.x + width / 2;\n }\n\n setScaleY(scaleY: float): void {\n this._pixiObject.scale.y = scaleY;\n const height = scaleY * this.getTileMapHeight();\n this._pixiObject.position.y = this._object.y + height / 2;\n }\n\n getWidth(): float {\n return this.getTileMapWidth() * this._pixiObject.scale.x;\n }\n\n getHeight(): float {\n return this.getTileMapHeight() * this._pixiObject.scale.y;\n }\n\n getScaleX(): float {\n return this._pixiObject.scale.x;\n }\n\n getScaleY(): float {\n return this._pixiObject.scale.y;\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @returns The tile's id.\n */\n getTileId(x: integer, y: integer, layerIndex: integer): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return -1;\n return tileMap.getTileId(x, y, layerIndex);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @param flip true if the tile should be flipped.\n */\n flipTileOnY(x: integer, y: integer, layerIndex: integer, flip: boolean) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n tileMap.flipTileOnY(x, y, layerIndex, flip);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n * @param flip true if the tile should be flipped.\n */\n flipTileOnX(x: integer, y: integer, layerIndex: integer, flip: boolean) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n tileMap.flipTileOnX(x, y, layerIndex, flip);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n */\n isTileFlippedOnX(x: integer, y: integer, layerIndex: integer): boolean {\n const tileMap = this._tileMap;\n if (!tileMap) return false;\n return tileMap.isTileFlippedOnX(x, y, layerIndex);\n }\n\n /**\n * @param x The layer column.\n * @param y The layer row.\n * @param layerIndex The layer index.\n */\n isTileFlippedOnY(x: integer, y: integer, layerIndex: integer): boolean {\n const tileMap = this._tileMap;\n if (!tileMap) return false;\n return tileMap.isTileFlippedOnY(x, y, layerIndex);\n }\n\n /**\n * @param targetRowCount The number of rows to have.\n */\n setGridRowCount(targetRowCount: integer) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n return tileMap.setDimensionY(targetRowCount);\n }\n /**\n * @param targetColumnCount The number of rows to have.\n */\n setGridColumnCount(targetColumnCount: integer) {\n const tileMap = this._tileMap;\n if (!tileMap) return;\n return tileMap.setDimensionX(targetColumnCount);\n }\n\n getGridRowCount(): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return 0;\n return tileMap.getDimensionY();\n }\n\n getGridColumnCount(): integer {\n const tileMap = this._tileMap;\n if (!tileMap) return 0;\n return tileMap.getDimensionX();\n }\n\n destroy(): void {\n // Keep textures because they are shared by all tile maps.\n this._pixiObject.destroy(false);\n }\n }\n export const TileMapRuntimeObjectRenderer =\n gdjs.TileMapRuntimeObjectPixiRenderer;\n export type TileMapRuntimeObjectRenderer =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