30 lines
587 B
JavaScript
30 lines
587 B
JavaScript
const layer = ecs.get(1).TileLayers.layer(1)
|
|
const {tileSize} = layer;
|
|
|
|
const filtered = []
|
|
|
|
for (const position of projected) {
|
|
const x0 = position.x * tileSize.x;
|
|
const y0 = position.y * tileSize.y;
|
|
const entities = ecs.system('MaintainColliderHash').within({
|
|
x0,
|
|
x1: x0 + tileSize.x - 1,
|
|
y0,
|
|
y1: y0 + tileSize.y - 1,
|
|
});
|
|
let hasPlant = false;
|
|
for (const {Plant} of entities) {
|
|
if (Plant) {
|
|
hasPlant = true
|
|
break;
|
|
}
|
|
}
|
|
if (!hasPlant) {
|
|
if ([7].includes(layer.tile(position))) {
|
|
filtered.push(position)
|
|
}
|
|
}
|
|
}
|
|
|
|
filtered
|