using Engine.Asset.Font;
using Engine.Graphics.Pipeline;
using OpenTK.Mathematics;

namespace Engine.Scene.Component.BuiltIn.Renderer;

public class TextRenderer : Component
{
  public Font Font { get; set; } = null!;
  public string? Text { get; set; }
  public ref Vector4 Color => ref _color;

  public RenderLayer RenderLayer { get; set; } = RenderLayer.DEFAULT;

  private Vector4 _color = Vector4.One;

  public override void Render()
  {
    if (Text == null)
      return;

    Engine.Instance.Renderer[RenderLayer].TextRenderer
      .Commit(Font, Text, Color, GameObject.Transform.FullTransformMatrix);
  }
}