using System.Threading.Tasks;
using Godot;

namespace Cirno.Scripts.Resources.Events;

[GlobalClass]
public partial class WaitEvent : EventResource
{
    [Export(PropertyHint.None, "suffix:s")]
    public float WaitTime { get; set; }
    protected bool _isComplete = false;
    
    public override void Init(Node2D parent)
    {
        
    }

    public override void Start(Node2D parent)
    {
        _ = Wait();
    }

    private async Task Wait()
    {
        await Task.Delay((int)(WaitTime)*1000);
        _isComplete = true;
    }

    public override void UpdateEvent(double delta)
    {
        
    }

    public override bool IsComplete()
    {
        return _isComplete;
    }
}