using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class Thermometer : MonoBehaviour
{
    public static float temperature = 0.5f;

    public static Dictionary<GameObject, float> contributions = new Dictionary<GameObject, float>();
    
    public GameObject indicator;
    public Transform indicatorMaxHeight;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void reset()
    {
        temperature = 0.5f;
    }

    // Update is called once per frame
    void Update()
    {
        temperature = Mathf.Clamp01(temperature);
        
        indicator.transform.localPosition = new Vector3(
            indicator.transform.localPosition.x, 
            indicatorMaxHeight.localPosition.y * temperature,
            indicator.transform.localPosition.z);

        float rateOfChange = contributions.Values.Sum();

        temperature += rateOfChange * Time.deltaTime;

        float deviation = Mathf.Abs(temperature - 0.5f);
        
        SleepDepth.subtract(deviation * deviation * Time.deltaTime);
    }
}
