collisions method
Used to get all "ShapeHitbox".
Implementation
@override
Iterable<ShapeHitbox> collisions({bool onlyVisible = false}) {
if (onlyVisible) {
List<ShapeHitbox> tilesCollision = [];
map
.getRenderedTiles()
.where((element) => element.containsShapeHitbox)
.forEach(
(e) => tilesCollision.addAll(e.children.query<ShapeHitbox>()),
);
return [
..._visibleCollisions,
...tilesCollision,
];
}
return collisionDetection.items;
}