using Godot;

namespace ReactorMaintenance.Godot.Screens;

public partial class SplashScreen : ScreenBase
{
    public event Action? Started;

    public override void _Ready()
    {
        var body = CreatePage("Reactor Maintenance");
        body.Alignment = BoxContainer.AlignmentMode.Center;
        body.AddChild(CreateBodyText("Systems booting..."));
        GetTree().CreateTimer(1.2).Timeout += Start;
    }

    public override void _UnhandledInput(InputEvent @event)
    {
        if (@event.IsPressed())
            Start();
    }

    private void Start()
    {
        if (m_Transitioned)
            return;

        m_Transitioned = true;
        Started?.Invoke();
    }

    private bool m_Transitioned;
}