seeComponent method

PolygonShape? seeComponent(
  1. GameComponent component, {
  2. required dynamic observed(
    1. GameComponent
    ),
  3. VoidCallback? notObserved,
  4. double radiusVision = 32,
  5. double? visionAngle,
  6. 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;
}