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

namespace Rokojori
{ 
  [Tool]
  [GlobalClass]
  public partial class CSShaderReplacementChange:CSShaderVariantChange
  {  
    [Export]
    public string searchPattern;

    [Export]
    public bool searchIsRegex = false;
    
    [Export]
    public string replacement;

    public override string ChangeShaderCode( string shaderCode )
    {
      if ( searchIsRegex )
      {
        return shaderCode.Replace( searchPattern, replacement );
      }
      else
      {
        return shaderCode.Replace( new Regex( searchPattern ), replacement );
      }
    }
  }
}