using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using UnityEngine.Rendering.PostProcessing;

namespace X2Engine
{
    public class GameCopyWeatherSetting : MonoBehaviour
    {
        //public BoxTriggerZone.PostProcessData _postProcessData = new BoxTriggerZone.PostProcessData() { enabled = false };
        //public BoxTriggerZone.EnvironmentData _envData = new BoxTriggerZone.EnvironmentData() { enabled = false };

        //public PostProcessVolume m_postProcessVolume;
        void OnEnable()
        {
            //m_postProcessVolume = FindObjectOfType<PostProcessVolume>();
            //if (null == m_postProcessVolume)
            //    m_postProcessVolume = gameObject.AddComponent<PostProcessVolume>();
            //if (m_postProcessVolume)
            //{
            //    m_postProcessVolume.enabled = _postProcessData.enabled;
            //    m_postProcessVolume.weight = 1f;
            //    m_postProcessVolume.sharedProfile = _postProcessData.GetProfile(0);
            //    m_postProcessVolume.profile = _postProcessData.GetProfile(0);
            //}
        }

        public void Transition(float blendWeight, int weather)
        {
            // Enviroment
            //if (_envData.enabled && EnvironmentSystem.instance)
            {
                EnvironmentProfile newProfile = null;// _envData.GetProfile(weather);
#if UNITY_EDITOR
                if (blendWeight == 1)
                {
                    EnvironmentSystem.instance.sharedProfile = newProfile;
                    EnvironmentSystem.instance.profile.ambient.SetLightProbeFromData();
                    EnvironmentSystem.instance.profile.ambientCharacter.SetLightProbeFromData();
                }
                else
                {
                    if (newProfile != null)
                    {
                        EnvironmentSystem.instance.profile.Lerp(newProfile, blendWeight);

                    }
                }
#else
                EnvironmentSystem.instance.profile.Lerp(newProfile, blendWeight);
#endif
            }

            //// PostProcess
            //if (m_postProcessVolume)
            //{
            //    m_postProcessVolume.enabled = false;// _envData.enabled;
            //    PostProcessProfile newProfile = null;// _postProcessData.GetProfile(weather);
            //    m_postProcessVolume.sharedProfile = newProfile;
            //    m_postProcessVolume.profile = newProfile;
            //}
        }
    }
}
