using Godot;
using System.Reflection;
using System.Collections.Generic;

namespace Rokojori
{ 
  [Tool]
  [GlobalClass]
  public partial class ColorProperty : ShaderProperty
  { 
    [Export]
    public ColorPropertyName propertyName;

    [Export]
    public Color color;

    public override void Apply( Material material )
    {
      propertyName.Set( material, color );
    }

    public void ReadFrom( Material material )
    {
      color = propertyName.Get( material );
    }

    public void ApplyLerped( Material material, Color from, float lerpState )
    {
      var lerpedColor = from.Lerp( color, lerpState );
      propertyName.Set( material, lerpedColor );
    }

    public static ColorProperty Create( string name, Color color )
    {
      var cp = new ColorProperty();
      cp.propertyName = ColorPropertyName.Create( name );
      cp.color = color;
      return cp;
    }
  }
}