27 lines
603 B
JavaScript
27 lines
603 B
JavaScript
const filtered = []
|
|
|
|
for (let i = 0; i < projected.length; ++i) {
|
|
const x0 = projected[i].x * layer.tileSize.x;
|
|
const y0 = projected[i].y * layer.tileSize.y;
|
|
const entities = Array.from(ecs.system('Colliders').within({
|
|
x0,
|
|
x1: x0 + layer.tileSize.x - 1,
|
|
y0,
|
|
y1: y0 + layer.tileSize.y - 1,
|
|
}));
|
|
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])
|
|
}
|
|
}
|
|
}
|
|
|
|
return filtered
|