using Cirno.Scripts.Interactables;
using Cirno.Scripts.Resources.Events;
using Godot;
using Godot.Collections;

namespace Cirno.Scripts.Activables;

public partial class NPC : Area2D, IInteractable
{
    
    [Export] public Array<EventResource> Events;

    private ScriptableBase _scriptable;
    
    public override void _Ready()
    {
        _scriptable = new ScriptableBase();
        _scriptable.Events = Events;
        
        // Add as sibling so relative paths still work
        GetParent().CallDeferred("add_child", _scriptable);
    }

    public bool Activate(ActivationType activationType = ActivationType.Toggle)
    {
        _scriptable?.Activate(activationType);

        return true;
    }

    public bool CanActivate()
    {
        return true;
    }
}