moveToPositionWithPathFinding method

Future<List<Vector2>> moveToPositionWithPathFinding(
  1. Vector2 position, {
  2. List<GameComponent>? ignoreCollisions,
  3. VoidCallback? onFinish,
})

Implementation

Future<List<Vector2>> moveToPositionWithPathFinding(
  Vector2 position, {
  List<GameComponent>? ignoreCollisions,
  VoidCallback? onFinish,
}) async {
  if (!hasGameRef) {
    return Future.value([]);
  }

  _onFinish = onFinish;
  _currentIndex = 0;
  _removeLinePathComponent();

  _currentPath = await Future.microtask(
    () => getPathToPosition(
      position,
      ignoreCollisions: ignoreCollisions,
    ),
  );
  _addLinePathComponent();

  return _currentPath;
}