using Godot;
using Godot.Collections;

namespace Cirno.Scripts.Activables;

public partial class ChainActivable : Activable
{
    [Export] private Array<Node2D> _targets;

    protected void ActivateTargets()
    {
        foreach (var activationTarget in _targets)
        {
            ActivateTarget(activationTarget);
        }
    }
    
    private bool ActivateTarget(Node2D activationTarget)
    {
        if (activationTarget is not IActivable target)
        {
            GD.PrintErr($"Target {activationTarget.Name} is not activable");
            return false;
        }
        
        target?.Activate();
        
        GD.Print($"{activationTarget.Name} activated");

        return true;
    }
}