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

namespace Rokojori
{  
  [Tool]
  [GlobalClass]
  public partial class RokojoriCompositorEffectIDReference:CompositorEffectReference
  {
    [Export]
    public NodePath worldEnvironmentPath;
    
    [Export]
    public RokojoriCompositorEffectID compositorEffectID;

    public override CompositorEffect GetCompositorEffect( Node context )
    {
      var we = context.GetNode<WorldEnvironment>( worldEnvironmentPath );

      if ( we == null || we.Compositor == null )
      {
        return null;
      }

      var fxs = we.Compositor.CompositorEffects;
      return fxs.Find( c => c is RokojoriCompositorEffect rce && rce.compositorEffectID == compositorEffectID );
    }   
  }
}