package ecs.systems;

import ecs.components.Death;
import ecs.components.Health;
import ecs.core.Entity;
import ecs.core.System;

class HealthSystem extends System {
	public function new() {
		super(Health);
	}

	override function updateEntity(entity:Entity, dt:Float) {
		final health = entity.get(Health);
		if (health.current <= 0) {
			if (health.die && !entity.has(Death)) {
				entity.remove(health);
				entity.add(new Death());
			}
		}
	}
}
