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) {
if (notObserved != null) notObserved();
return;
}
double vision = radiusVision * 2;
Rect fieldOfVision = Rect.fromLTWH(
this.position.center.dx - radiusVision,
this.position.center.dy - radiusVision,
vision,
vision,
);
if (fieldOfVision.overlaps(getRectAndCollision(component).rect)) {
observed(component);
} else {
notObserved?.call();
}
}