Cache tile properties at map load time instead of parsing them every time we shoot a vision ray

This commit is contained in:
2014-07-12 10:49:00 -07:00
parent e530233cde
commit 152414550c
2 changed files with 8 additions and 1 deletions

View File

@@ -61,6 +61,14 @@ GameState.prototype.create = function()
} }
} }
this.map_collision_layers.forEach(function(layer) {
layer.layer.data.forEach(function(row) {
row.forEach(function(column) {
setTileProperties(column);
}, this);
}, this);
}, this);
pathfinder_grid = new PF.Grid(this.map.width, pathfinder_grid = new PF.Grid(this.map.width,
this.map.height, this.map.height,
pfgrid); pfgrid);

View File

@@ -347,7 +347,6 @@ function tilesFromCollisionLayers(x, y)
var res = []; var res = [];
layers.forEach(function(layer) { layers.forEach(function(layer) {
var tile = layer.getTiles(x, y, 1, 1)[0]; var tile = layer.getTiles(x, y, 1, 1)[0];
setTileProperties(tile);
res.push(tile); res.push(tile);
}, this); }, this);
return res; return res;