import 'dart:ui';

import 'package:ecosim/src/ecosim/models/world_object.dart';

// Food WorldObject
class Food extends WorldObject {
  double nutrition;
  final double startNutrition;
  final double foodDecayRate;

  Food({
    required this.nutrition,
    required this.startNutrition,
    required this.foodDecayRate,
    required super.position,
  });

  void update() {
    nutrition -= foodDecayRate;
  }

  bool get dead => nutrition < 0;

  render(Canvas canvas) {
    canvas.save();
    canvas.translate(position.x, position.y);
    // print(nutrition / startNutrition * 100);
    final colorHealth = (255) * (nutrition / startNutrition);
    final white = Paint()
      ..color = Color.fromARGB(
        colorHealth.toInt(),
        0,
        255,
        0,
      );
    canvas.drawCircle(const Offset(0, 0), 1, white);
    canvas.restore();
  }
}
