import 'package:ecosim/src/ecosim/models/boid.dart';
import 'package:flutter/rendering.dart';

import 'models/pointer_indicator.dart';

class SeekingSimulationPainter extends CustomPainter {
  final double x;
  final double y;
  final PointerIndicator pointerIndicator;
  final List<Boid> boids;

  SeekingSimulationPainter(
    this.pointerIndicator,
    this.x,
    this.y,
    this.boids,
  );

  @override
  void paint(Canvas canvas, Size size) {
    for (var boid in boids) {
      boid.render(canvas);
    }
    pointerIndicator.input(x, y);
    pointerIndicator.render(canvas);

    final white = Paint()..color = const Color.fromARGB(255, 255, 255, 255);
    white.style = PaintingStyle.stroke;

    canvas.drawRect(
      Rect.fromCenter(
        center: Offset(size.width / 2, size.height / 2),
        width: size.width + 200,
        height: size.height + 200,
      ),
      white,
    );
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
