* This is used to reload the Tilemap
()
| 1732 | * This is used to reload the Tilemap |
| 1733 | */ |
| 1734 | updateTileMap() { |
| 1735 | const tilemapAtlasImage = this._tilemapAtlasImage; |
| 1736 | const tilemapJsonFile = this._tilemapJsonFile; |
| 1737 | const tilesetJsonFile = this._tilesetJsonFile; |
| 1738 | const layerIndex = this._layerIndex; |
| 1739 | const levelIndex = this._levelIndex; |
| 1740 | const displayMode = this._displayMode; |
| 1741 | |
| 1742 | const tilemapResource = this._project |
| 1743 | .getResourcesManager() |
| 1744 | .getResource(tilemapJsonFile); |
| 1745 | |
| 1746 | let metadata = {}; |
| 1747 | try { |
| 1748 | const tilemapMetadataAsString = tilemapResource.getMetadata(); |
| 1749 | if (tilemapMetadataAsString) |
| 1750 | metadata = JSON.parse(tilemapMetadataAsString); |
| 1751 | } catch (error) { |
| 1752 | console.warn('Malformed metadata in a tilemap object:', error); |
| 1753 | } |
| 1754 | const mapping = metadata.embeddedResourcesMapping || {}; |
| 1755 | |
| 1756 | const atlasTexture = this._pixiResourcesLoader.getPIXITexture( |
| 1757 | this._project, |
| 1758 | tilemapAtlasImage |
| 1759 | ); |
| 1760 | |
| 1761 | const loadTileMap = () => { |
| 1762 | /** @type {TileMapHelper.TileMapManager} */ |
| 1763 | const manager = TilemapHelper.TileMapManager.getManager( |
| 1764 | this._project |
| 1765 | ); |
| 1766 | manager.getOrLoadTileMap( |
| 1767 | this._loadTileMapWithCallback.bind(this), |
| 1768 | tilemapJsonFile, |
| 1769 | tilesetJsonFile, |
| 1770 | levelIndex, |
| 1771 | pako, |
| 1772 | (tileMap) => { |
| 1773 | if (this._wasDestroyed) return; |
| 1774 | if (!tileMap) { |
| 1775 | this._onLoadingError(); |
| 1776 | // _loadTileMapWithCallback already log errors |
| 1777 | return; |
| 1778 | } |
| 1779 | |
| 1780 | this._editableTileMap = tileMap; |
| 1781 | |
| 1782 | /** @type {TileMapHelper.TileTextureCache} */ |
| 1783 | manager.getOrLoadTextureCache( |
| 1784 | this._loadTileMapWithCallback.bind(this), |
| 1785 | (textureName) => |
| 1786 | this._pixiResourcesLoader.getPIXITexture( |
| 1787 | this._project, |
| 1788 | mapping[textureName] || textureName |
| 1789 | ), |
| 1790 | tilemapAtlasImage, |
| 1791 | tilemapJsonFile, |
no test coverage detected