Exemple #1
0
        public static AmbientConfigWeather GetWeatherSet(AmbientConfigPeriod prd, string weather_name)
        {
            AmbientConfigWeather select_weather = null;

            select_weather = TryToFetchWeather(prd, weather_name);

            if (select_weather == null && AmbientLightControl.config.periods.ContainsKey("default"))
            {
                //Debug.Log("[ambient-lights] No WeatherSet found, trying default period for current weather.");
                select_weather = TryToFetchWeather(AmbientLightControl.config.periods["default"], weather_name);

                if (select_weather == null && prd.weathers.ContainsKey("default"))
                {
                    //Debug.Log("[ambient-lights] Default Weather selected.");
                    select_weather = prd.weathers["default"];

                    if (select_weather == null)
                    {
                        //Debug.Log("[ambient-lights] No WeatherSet found at default, trying default period for default weather.");
                        select_weather = TryToFetchWeather(AmbientLightControl.config.periods["default"], "default");

                        if (select_weather == null)
                        {
                            Debug.Log("[ambient-lights] ERROR: No default weather found.");
                        }
                    }
                }
            }

            return(select_weather);
        }
Exemple #2
0
        public static AmbientConfigPeriod GetPeriodSet(string periodName)
        {
            AmbientConfigPeriod period = null;

            period = AmbientLightControl.config.periods[periodName];

            return(period);
        }
Exemple #3
0
        public static AmbientConfigWeather TryToFetchWeather(AmbientConfigPeriod prd, string weather_name)
        {
            AmbientConfigWeather select_weather = null;

            if (prd.weathers != null)
            {
                foreach (KeyValuePair <string, AmbientConfigWeather> weather in prd.weathers)
                {
                    if (weather.Key == weather_name)
                    {
                        select_weather = weather.Value;
                    }
                }
            }

            return(select_weather);
        }
Exemple #4
0
        public static void MaybeUpdateLightsToPeriod(bool force_update = false)
        {
            if (light_setup_done && scene_time_init && scene_weather_init)
            {
                int now_time = AmbientLightUtils.GetCurrentTimeFormatted();

                string period_name  = TimeWeather.GetCurrentPeriod();
                string weather_name = TimeWeather.GetCurrentWeather();

                AuroraLightsControl.UpdateAuroraLightsRanges();

                if (period_name != current_period || weather_name != current_weather || force_update)
                {
                    AmbientConfigPeriod  period     = TimeWeather.GetPeriodSet(period_name);
                    AmbientConfigWeather weatherSet = TimeWeather.GetWeatherSet(period, weather_name);

                    period_transition.start = now_time;


                    if (period_name == current_period && weather_name != current_weather)
                    {
                        period_transition.duration = 15;
                        period_transition.end      = now_time + 15;
                    }
                    else
                    {
                        period_transition.duration = TimeWeather.GetPeriodChangeDuration(period_name);
                        period_transition.end      = now_time + TimeWeather.GetPeriodChangeDuration(period_name);
                    }

                    period_transition.complete = force_update;

                    current_weather = weather_name;
                    current_period  = period_name;

                    if (AmbientLightsOptions.verbose)
                    {
                        Debug.Log("[ambient-lights] * Light period change:");
                        Debug.Log("[ambient-lights] Period: " + current_period);
                        Debug.Log("[ambient-lights] Weather: " + current_weather);
                    }

                    foreach (var light in light_list)
                    {
                        AmbientConfigPeriodSet set = TimeWeather.GetLightSet(weatherSet, light.light_set);

                        if (set != null)
                        {
                            light.SetLightParams(set, force_update);
                        }
                    }
                }
                else if (now_time > period_transition.start && now_time <= period_transition.end && !period_transition.complete)
                {
                    float time_passed    = now_time - period_transition.start;
                    float transition_pos = time_passed / period_transition.duration;

                    //Debug.Log("[ambient-lights] Transition position: " + transition_pos.ToString());

                    foreach (var light in light_list)
                    {
                        light.UpdateLightTransition(transition_pos);
                    }
                }
                else if (now_time > period_transition.end && !period_transition.complete)
                {
                    //Debug.Log("[ambient-lights] End of transition.");
                    period_transition.complete = true;
                }
            }
        }