Code/UI/GraphStyle.cs
namespace Nodebox.UI;

public class GraphStyle {
    [JsonInclude]
    public TypePalette TypePalette { get; set; }

    public void ConfigureLineRenderer(LineRenderer lineRenderer) {
        // TODO: Add settings and shit insstead

        lineRenderer.Color = Color.White;
        lineRenderer.Width = 0.55f;

        // lineRenderer.StartCap = SceneLineObject.CapStyle.Rounded;
        // lineRenderer.EndCap = SceneLineObject.CapStyle.Rounded;
        lineRenderer.EndCap = SceneLineObject.CapStyle.Arrow;
        lineRenderer.SplineTension = 1f;
        lineRenderer.SplineInterpolation = 10;

        lineRenderer.Face = SceneLineObject.FaceMode.Camera;
        lineRenderer.CastShadows = false;
        lineRenderer.UseVectorPoints = true;
        // lineRenderer.RenderOptions.Bloom = true;
    }

    public static GraphStyle DefaultForExecutionContext() => new() {
        TypePalette = TypePalette.DefaultForExecutionContext(),
    };
}


public interface IGraphStyle {
    public Panel Parent => null;
    public GraphStyle GraphStyle {
        get {
            var panel = Parent;
            while (panel.IsValid()) {
                foreach (var panelComponent in panel.GameObject.Components.GetAll<PanelComponent>().Where(x => x.Panel == panel)) {
                    if (panelComponent is IGraphStyle componentProvider && componentProvider != null && componentProvider.GraphStyle != null) {
                        return componentProvider.GraphStyle;
                    }
                }

                if (panel is IGraphStyle provider && provider != null && provider.GraphStyle != null) {
                    return provider.GraphStyle;
                }

                panel = panel.Parent;
            }

            return null;
        }
    }
}

public static class GraphStyleExtensions {
    extension(IGraphStyle provider) {
        public GraphStyle GraphStyle => provider.GraphStyle;
    }
}