From 152414550c006b32f7e8f9855ed9185b5cac246e Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 12 Jul 2014 10:49:00 -0700 Subject: [PATCH] Cache tile properties at map load time instead of parsing them every time we shoot a vision ray --- moonlight/src/GameStates.js | 8 ++++++++ moonlight/src/Util.js | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/moonlight/src/GameStates.js b/moonlight/src/GameStates.js index e1b4078..9bf9adf 100644 --- a/moonlight/src/GameStates.js +++ b/moonlight/src/GameStates.js @@ -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, this.map.height, pfgrid); diff --git a/moonlight/src/Util.js b/moonlight/src/Util.js index 6846339..4bbe9ed 100644 --- a/moonlight/src/Util.js +++ b/moonlight/src/Util.js @@ -347,7 +347,6 @@ function tilesFromCollisionLayers(x, y) var res = []; layers.forEach(function(layer) { var tile = layer.getTiles(x, y, 1, 1)[0]; - setTileProperties(tile); res.push(tile); }, this); return res;