
using Godot;
using System.Collections.Generic;
using System.Linq;

namespace Rokojori
{  
  public enum RG_BlendModeType
  {
    Alpha,
    Screen
  }

  public class RG_BlendModesTool
  {
    public static List<RG_BlendModeBase> CreateAll( RDGraph graph )
    {
      List<RG_BlendModeBase> blendModes = [
        new RG_BlendMode_Alpha( graph ),
        new RG_BlendMode_Screen( graph ) 
      ];


      return blendModes;
    }

    public static RG_BlendModeBase ByType( RDGraph graph, RG_BlendModeType type )
    {
      if ( RG_BlendModeType.Alpha == type )
      {
        return new RG_BlendMode_Alpha( graph );
      }
      else if ( RG_BlendModeType.Screen == type )
      {
        return new RG_BlendMode_Screen( graph );
      }

      return null;
    }

    public static RG_BlendModeBase[] Create( RDGraph graph, params RG_BlendModeType[] types )
    {
      return types.Map( t => ByType( graph, t ) );
    }

    public static RG_BlendModeBase GetCurrentBlendMode( IEnumerable<RG_BlendModeBase> blendModes, RG_BlendModeType type )
    {
      foreach ( var bm in blendModes )
      {
        if ( bm.GetBlendModeType() == type )
        {
          return bm;
        }
      }

      return null;
    } 

  }
}