using UnityEngine;
using UnityEngine.UI;

public class HealthBar : MonoBehaviour
{
    public Image healthBarFill;
    public Health playerHealth;
    
    
    private void OnEnable()
    {
        playerHealth.OnHealthChanged += UpdateHealthBar;
    }

    private void OnDisable()
    {
        playerHealth.OnHealthChanged -= UpdateHealthBar;
    }
    
    public void UpdateHealthBar(int currentHealth)
    {
        healthBarFill.fillAmount = currentHealth / 100f;
    }
}
