canSee method
Returns true if this camera is able to see the component
.
Will always return false if
- world is null or
- world is not mounted or
component
is not mounted orcomponentWorld
is non-null and does not match with world
If componentWorld
is null, this method does not take into consideration
the world to which the given component
belongs (if any). This means, in
such cases, any component overlapping the visibleWorldRect will be
reported as visible, even if it is not part of the world this camera is
currently looking at. This can be changed by passing the component's
world as componentWorld
.
Implementation
bool canSee(PositionComponent component, {World? componentWorld}) {
if (!(world?.isMounted ?? false) ||
!component.isMounted ||
(componentWorld != null && componentWorld != world)) {
return false;
}
return visibleWorldRect.overlaps(component.toAbsoluteRect());
}