seePlayer method

Shape? seePlayer({
  1. required dynamic observed(
    1. Player
    ),
  2. VoidCallback? notObserved,
  3. double radiusVision = 32,
  4. double? visionAngle,
  5. double? angle,
})

This method we notify when detect the player when enter in radiusVision configuration Method that bo used in update method. visionAngle in radians angle in radians. is automatically picked up using the component's direction.

Implementation

Shape? seePlayer({
  required Function(Player) observed,
  VoidCallback? notObserved,
  double radiusVision = 32,
  double? visionAngle,
  double? angle,
}) {
  Player? player = gameRef.player;
  if (player == null || player.isDead) {
    notObserved?.call();
    return null;
  }
  return seeComponent(
    player,
    observed: (c) => observed(c as Player),
    notObserved: notObserved,
    radiusVision: radiusVision,
    visionAngle: visionAngle,
    angle: angle ?? lastDirection.toRadians(),
  );
}