using Godot;
using Godot.Collections;

namespace Newlon.Components.Plants.Behaviours;

public partial class HpBasedBehaviour : BaseBehaviour
{
    private RuntimePlantData _data;
    [Export] private Array<string> parameters;

    public override void _Ready()
    {
        base._Ready();
        _data = GetParent<RuntimePlantData>();
    }

    public void OnHPChanged(float amount, Node origin)
    {
        var calc = _data.HP / _data.MaxHP;
        foreach (var par in parameters)
        {
            _tree.Set(par, calc);
        }
    }
}
