From c1d9b2c9ed20ce0ff94a5f18d9b03a5955330020 Mon Sep 17 00:00:00 2001 From: jonny Date: Sat, 19 Jun 2021 15:41:58 +0200 Subject: [PATCH] coverted property map to object --- front/src/Phaser/Game/GameMap.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index 6148830e..4fd5b832 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -12,10 +12,7 @@ export class GameMap { private lastProperties = new Map(); private callbacks = new Map>(); - /** - * tileset.firstgid => (Map>) - */ - private tileSetPropertyMap = new Map>>() + private tileSetPropertyMap: { [tilset_firstgid: number]: { [tile_id: number]: Array } } = {} public readonly layersIterator: LayersIterator; public exitUrls: Array = [] @@ -24,12 +21,12 @@ export class GameMap { this.layersIterator = new LayersIterator(map); for (const tileset of map.tilesets) { - if (!this.tileSetPropertyMap.has(tileset.firstgid)) { - this.tileSetPropertyMap.set(tileset.firstgid, new Map()) + if (!this.tileSetPropertyMap[tileset.firstgid]) { + this.tileSetPropertyMap[tileset.firstgid] = {} } tileset?.tiles?.forEach(tile => { if (tile.properties) { - this.tileSetPropertyMap.get(tileset.firstgid)?.set(tile.id, tile.properties) + this.tileSetPropertyMap[tileset.firstgid][tile.id] = tile.properties tile.properties.forEach(prop => { if (prop.name == "exitUrl" && typeof prop.value == "string") { this.exitUrls.push(prop.value); @@ -106,7 +103,7 @@ export class GameMap { if (tileIndex) { const tileset = this.map.tilesets.find(tileset => tileset.firstgid + tileset.tilecount > (tileIndex as number)) if (tileset) { - const tileProperties = this.tileSetPropertyMap.get(tileset?.firstgid)?.get(tileIndex - tileset.firstgid) + const tileProperties = this.tileSetPropertyMap[tileset?.firstgid][tileIndex - tileset.firstgid] if (tileProperties) { for (const property of tileProperties) { if (property.value) {