seeComponent method
void
seeComponent(
- GameComponent component, {
- required dynamic observed(),
- VoidCallback? notObserved,
- double radiusVision = 32,
This method we notify when detect the component when enter in radiusVision
configuration
Method that bo used in update method.
Implementation
void seeComponent(
GameComponent component, {
required Function(GameComponent) observed,
VoidCallback? notObserved,
double radiusVision = 32,
}) {
if (component.shouldRemove) {
notObserved?.call();
return;
}
Rect fieldOfVision = Rect.fromCircle(
center: this.center.toOffset(),
radius: radiusVision,
);
if (fieldOfVision.overlaps(getRectAndCollision(component))) {
observed(component);
} else {
notObserved?.call();
}
}