using UnityEngine;

[CreateAssetMenu()]
public class TextureData : UpdatableData
{
    const int MAX_LAYERS = 8;

    public Color[] baseColours = new Color[MAX_LAYERS];
    [Range(0,1)]
    public float[] baseStartHeights = new float[MAX_LAYERS];

    float savedMinHeight;
    float savedMaxHeight;
    public void ApplyToMaterial(Material material)
    {
        for (int i = 0; i < MAX_LAYERS; i++)
        {
            material.SetColor($"_baseColor{i}", baseColours[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);
    }
}
