silphius/public/assets/tomato-seeds/projection-check.js

27 lines
606 B
JavaScript
Raw Normal View History

2024-06-28 12:12:38 -05:00
const filtered = []
for (let i = 0; i < projected.length; ++i) {
2024-07-02 14:41:54 -05:00
const x0 = projected[i].x * layer.tileSize.x;
const y0 = projected[i].y * layer.tileSize.y;
const entities = Array.from(ecs.system('VisibleAabbs').within({
x0,
x1: x0 + layer.tileSize.x - 1,
y0,
y1: y0 + layer.tileSize.y - 1,
}));
2024-06-28 14:36:49 -05:00
let hasPlant = false;
for (let j = 0; j < entities.length; ++j) {
if (entities[j].Plant) {
hasPlant = true
}
}
if (!hasPlant) {
const tile = layer.tile(projected[i])
if ([7].includes(tile)) {
filtered.push(projected[i])
}
2024-06-28 12:12:38 -05:00
}
}
return filtered