/** Tile table; Image fields filled after preload. */ var Tiles = { Nothing: { ID: 0, Color: { R: 255, G: 255, B: 255 }, Solid: false, ImageName: null }, Stone: { ID: 1, Color: { R: 155, G: 155, B: 155 }, Solid: true, ImageName: "stone" }, Finish: { ID: 2, Color: { R: 255, G: 255, B: 0 }, Solid: false, ImageName: null }, Wood: { ID: 3, Color: { R: 168, G: 102, B: 50 }, Solid: true, ImageName: "wood" }, findByID: function (id) { for (var key in Tiles) { if (!Object.prototype.hasOwnProperty.call(Tiles, key)) { continue; } var value = Tiles[key]; if (value && value.ID === id) { return value; } } return null; }, bindImages: function (images) { for (var key in Tiles) { if (!Object.prototype.hasOwnProperty.call(Tiles, key)) { continue; } var tile = Tiles[key]; if (tile && tile.ImageName && images[tile.ImageName]) { tile.Image = images[tile.ImageName]; } } } };