using System;
using Godot;
using static ld48.Extensions;

public class SilentMessage : Node2D {
    private float intensity = 0f;

    private ColorRect color;
    private Label label;

    public String message;

    private float initialDelay;

    public override void _Ready() {
        base._Ready();

        var canvas = GetNode("Canvas");
        color = canvas.GetNode<ColorRect>("ColorRect");
    }

    public override void _Process(float delta) {
        base._Process(delta);

        color.Color = C(0f).Alpha(Mathf.Max(0f, intensity));
        intensity += delta;
        
        if (intensity >= 50f) {
            GetTree().Quit();
        }
        
        Update();
    }

    public override void _Draw() {
        base._Draw();

        var size = Game.bigFont.GetStringSize(message);
        DrawString(Game.bigFont, GetViewportRect().Size/2f+GetViewportRect().Position - size/2f + V2(0f, Game.bigFont.GetAscent()), message, C(1f).Alpha(intensity));
    }
}

