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

public class WeatherData : MonoBehaviour
{
    public Color m_lightColor = GFColor.UintToColor(0xFFE8E1D0);
    public float m_lightIntensity = 0.7f;

    public Color m_ambientSkyColor = GFColor.UintToColor(0xFF96ADCC);
    public Color m_ambientEquatorColor = GFColor.UintToColor(0xFFCC993F);
    public Color m_ambientGroundColor = GFColor.UintToColor(0xFF6F0100);

    public Color m_skyHorizontColor = GFColor.UintToColor(0xFFFFFF);
    public float m_skyFogFactor = 0.1f;

    public float m_fogDenisty = 0.03f;
    public Color m_fogColor = GFColor.UintToColor(0xFF7D7E8B);

    public float m_rainIntensity = 0; // 0 - 1
    public float m_rainLight = 1.1f; // 1.1f at day, 2.2 at night

    public float m_cameraPitchFactor = 1; // 0=look down, 1=look far

    public void Lerp(WeatherData a, WeatherData b, float t)
    {
        m_lightColor = GFColor.Lerp(a.m_lightColor, b.m_lightColor, t);
        m_lightIntensity = Mathf.Lerp(a.m_lightIntensity, b.m_lightIntensity, t);

        m_ambientSkyColor = GFColor.Lerp(a.m_ambientSkyColor, b.m_ambientSkyColor, t);
        m_ambientEquatorColor = GFColor.Lerp(a.m_ambientEquatorColor, b.m_ambientEquatorColor, t);
        m_ambientGroundColor = GFColor.Lerp(a.m_ambientGroundColor, b.m_ambientGroundColor, t);

        m_skyFogFactor = Mathf.Lerp(a.m_skyFogFactor, b.m_skyFogFactor, t);
        m_skyHorizontColor = GFColor.Lerp(a.m_skyHorizontColor, b.m_skyHorizontColor, t);

        m_fogDenisty = Mathf.Lerp(a.m_fogDenisty, b.m_fogDenisty, t);
        m_fogColor = GFColor.Lerp(a.m_fogColor, b.m_fogColor, t);

        m_rainIntensity = Mathf.Lerp(a.m_rainIntensity, b.m_rainIntensity, t);
        m_rainLight = Mathf.Lerp(a.m_rainLight, b.m_rainLight, t);

        m_cameraPitchFactor = Mathf.Lerp(a.m_cameraPitchFactor, b.m_cameraPitchFactor, t);
    }

    public void CopyFrom(WeatherData a)
    {
        m_lightColor = a.m_lightColor;
        m_lightIntensity = a.m_lightIntensity;

        m_ambientSkyColor = a.m_ambientSkyColor;
        m_ambientEquatorColor = a.m_ambientEquatorColor;
        m_ambientGroundColor = a.m_ambientGroundColor;

        m_skyFogFactor = a.m_skyFogFactor;
        m_skyHorizontColor = a.m_skyHorizontColor;

        m_fogDenisty = a.m_fogDenisty;
        m_fogColor = a.m_fogColor;

        m_rainIntensity = a.m_rainIntensity;
        m_rainLight = a.m_rainLight;

        m_cameraPitchFactor = a.m_cameraPitchFactor;
    }
}
