using UnityEngine;

public class TimeChanger : MonoBehaviour
{
    [SerializeField] private Material skybox;
    private float dayLength;
    private GameManager gm;

    private static readonly int Rotation = Shader.PropertyToID("_Rotation");
    private static readonly int Exposure = Shader.PropertyToID("_Exposure");

    void Start()
    {
        gm = GameManager.Instance;
        dayLength = gm.timeRemaining;
    }

    void Update()
    {
        float timer = Mathf.Clamp01(1f - (gm.timeRemaining / dayLength));

        float roationAmount = timer * 360f;
        skybox.SetFloat(Rotation, roationAmount);

        float exposureValue = Mathf.Lerp(1f, 0.15f, timer);
        skybox.SetFloat(Exposure, exposureValue);
    }
}
