coverted property map to object
This commit is contained in:
parent
27ccdf165c
commit
c1d9b2c9ed
@ -12,10 +12,7 @@ export class GameMap {
|
||||
private lastProperties = new Map<string, string | boolean | number>();
|
||||
private callbacks = new Map<string, Array<PropertyChangeCallback>>();
|
||||
|
||||
/**
|
||||
* tileset.firstgid => (Map<tileid,Array<ITiledMapLayerProperty>>)
|
||||
*/
|
||||
private tileSetPropertyMap = new Map<number, Map<number, Array<ITiledMapLayerProperty>>>()
|
||||
private tileSetPropertyMap: { [tilset_firstgid: number]: { [tile_id: number]: Array<ITiledMapLayerProperty> } } = {}
|
||||
public readonly layersIterator: LayersIterator;
|
||||
|
||||
public exitUrls: Array<string> = []
|
||||
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user