import 'dart:ui';

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

// Poison WorldObject
class Poison extends WorldObject {
  double damage;
  final double poisonDecayRate;
  final double startDamage;

  Poison({
    required this.damage,
    required this.poisonDecayRate,
    required this.startDamage,
    required super.position,
  });

  void update() {
    damage -= poisonDecayRate;
  }

  bool dead() => damage < 0;

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