
using Godot;
using System.Collections.Generic;

namespace Rokojori
{  
  [Tool]
  [GlobalClass]
  public partial class SetCompositorEffectsStates:Action
  {
    [Export]
    public CompositorEffectReference[] compositorEffectReferences = [];

    public enum ChangeMode
    {
      Set_Enabled,
      Set_Disabled,
      Toggle
    }

    [Export]
    public ChangeMode mode = ChangeMode.Set_Disabled;

    protected override void _OnTrigger()
    {
      if ( compositorEffectReferences == null )
      {
        return;
      }

      compositorEffectReferences.ForEach(
        ( cr )=>
        {
          if ( cr == null )
          {
            return;
          }

          var c = cr.GetCompositorEffect( this );
          
          var settingMode = mode == ChangeMode.Toggle ? ! c.Enabled : ( ChangeMode.Set_Enabled == mode );
          c.Enabled = settingMode;
        }
      );
    }
  }
}