collisions method

  1. @override
Iterable<ShapeHitbox> collisions({
  1. bool onlyVisible = false,
})
override

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;
}