seeComponent method
PolygonShape?
seeComponent(
- GameComponent component, {
- required dynamic observed(),
- VoidCallback? notObserved,
- double radiusVision = 32,
- double? visionAngle,
- double angle = 3.14159,
This method we notify when detect the component when enter in radiusVision
configuration
Method that bo used in update method.
visionAngle
in radians
angle
in radians.
Implementation
PolygonShape? seeComponent(
GameComponent component, {
required Function(GameComponent) observed,
VoidCallback? notObserved,
double radiusVision = 32,
double? visionAngle,
double angle = 3.14159,
}) {
if (component.isRemoving) {
notObserved?.call();
return _currentShape = null;
}
PolygonShape shape = _getShapeVision(radiusVision, visionAngle, angle);
if (_canSee(shape, component, radiusVision)) {
observed(component);
} else {
notObserved?.call();
}
return _currentShape = shape;
}