TsarBot/util_etc.js

17 lines
389 B
JavaScript

function calculateSourceSpace(source){
var count = 0;
for(let y = -1; y <= 1; y++){
for(let x = -1; x <= 1; x++){
if(x == 0 && y == 0) continue;
for(var object of source.room.lookAt(source.pos.x + x, source.pos.y + y)){
if(object.type != 'terrain') continue;
if(object.terrain != 'wall') count++;
}
}
}
return count;
}
module.exports = { calculateSourceSpace };