using UnityEngine;

[CreateAssetMenu]
public class TextureData : UpdatableData
{
    const int maxLayers = 4;

    public Color[] baseColors = new Color[maxLayers];
    [Range(0, 1)]
    public float[] baseStartHeights = new float[maxLayers];

    float savedMinHeight;
    float savedMaxHeight;
    public void ApplyToMaterial(Material material)
    {
        for (int i = 0; i < maxLayers; i++)
        {
            material.SetColor($"_baseColor{i}", baseColors[i]);
            material.SetFloat($"_baseStartHeight{i}", baseStartHeights[i]);
        }

        UpdateMeshHeights(material, savedMinHeight, savedMaxHeight);
    }

    public void UpdateMeshHeights(Material material, float minHeight, float maxHeight)
    {
        savedMinHeight = minHeight;
        savedMaxHeight = maxHeight;

        material.SetFloat("_minHeight", minHeight);
        material.SetFloat("_maxHeight", maxHeight);
    }
}
