Esempio n. 1
0
        internal static void HandleHotkeys()
        {
            if ((InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L) && !InputManager.GetSprintDown(InputManager.m_CurrentContext) && AmbientLights.debugVer) || (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L) && InputManager.GetSprintDown(InputManager.m_CurrentContext) && Settings.options.enableDebugKey && !AmbientLights.debugVer))
            {
                if (AmbientLights.lightOverride)
                {
                    AmbientLights.lightOverride = false;
                    AmbientLights.MaybeUpdateLightsToPeriod(true);

                    Log("Ambient Lights: On", true, false, true);

                    /*HUDMessage.AddMessage("Ambient Lights: On");
                     * if (AmbientLights.debugVer)
                     *  Debug.Log("Ambient Lights: On");*/
                }
                else
                {
                    AmbientLights.lightOverride = true;
                    AmbientLights.SetLightsIntensity(0f);

                    Log("Ambient Lights: Off", true, false, true);

                    /*HUDMessage.AddMessage("Ambient Lights: Off");
                     * if (AmbientLights.debugVer)
                     *  Debug.Log("Ambient Lights: Off");*/
                }
            }

            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L) && InputManager.GetSprintDown(InputManager.m_CurrentContext) && AmbientLights.debugVer)
            {
                AmbientLights.Unload(true);
                AmbientLights.Reset(false);
                AmbientLights.LoadConfigs();
                //HUDMessage.AddMessage("Reloading Config");
                Log("Reloading Scene Config", true, false, true);
            }

            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Z) && !InputManager.GetSprintDown(InputManager.m_CurrentContext) && AmbientLights.debugVer)
            {
                GetPoint();
            }

            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Z) && InputManager.GetSprintDown(InputManager.m_CurrentContext) && AmbientLights.debugVer)
            {
                ShowGameLights();
            }

            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.F6) && AmbientLights.debugVer)
            {
                TimeWeather.GetCurrentPeriodAndWeather();

                //HUDMessage.AddMessage(AmbientLights.currentScene + " " + TimeWeather.GetCurrentTimeString() + " - " + TimeWeather.currentWeather + " (" + (Math.Round(TimeWeather.currentWeatherPct, 2) * 100) + " %)" + TimeWeather.currentPeriod + "(" + (Math.Round(TimeWeather.currentPeriodPct, 2) * 100) + "%)");

                Log("Environment data: " + AmbientLights.currentScene + " " + TimeWeather.GetCurrentTimeString() + " - " + TimeWeather.currentWeather + " (" + (Math.Round(TimeWeather.currentWeatherPct, 2) * 100) + " %)" + TimeWeather.currentPeriod + "(" + (Math.Round(TimeWeather.currentPeriodPct, 2) * 100) + "%)", true);

                ALUtils.debugNext = true;
            }
        }
Esempio n. 2
0
        public static void Reset(bool firstPass = true)
        {
            debugVer = Settings.options.verbose;
            verbose  = Settings.options.verbose;

            ALUtils.Log("Scene reset.", false);

            lightList.Clear();

            config = null;

            lightsInit = false;

            lightOverride    = false;
            showGameLights   = false;
            enableGameLights = true;

            if (firstPass)
            {
                TimeWeather.Reset();
                timeInit    = false;
                weatherInit = false;
            }
        }
Esempio n. 3
0
        internal LightSet GetCurrentLightSet()
        {
            if (data == null)
            {
                return(null);
            }

            TimeWeather.GetCurrentPeriodAndWeather();

            LightSet ls = new LightSet();

            UniStormWeatherSystem uniStorm = GameManager.GetUniStorm();
            TODStateConfig        state    = uniStorm.GetActiveTODState();

            AmbPeriod prd = GetPeriodSet();

            //Base Colors
            Color baseSun = state.m_SunLight;
            Color origSun = state.m_SunLight;
            Color baseFog = state.m_FogColor;
            Color origFog = state.m_FogColor;

            baseSun.a = 1;
            baseFog.a = 1;

            float auroraFade = GameManager.GetAuroraManager().GetNormalizedAlphaSquare();

            if (Mathf.Abs(auroraFade) > 0.0001f)
            {
                Color    auroraColour   = GameManager.GetAuroraManager().GetAuroraColour();
                ColorHSV auroraModColor = auroraColour;

                if (!GameManager.GetAuroraManager().IsUsingCinematicColours())
                {
                    auroraModColor.s *= Settings.options.auroraSaturation;
                    auroraModColor.v *= Settings.options.auroraIntensity;
                }

                float auroraLevel = Mathf.Clamp01(GameManager.GetAuroraManager().m_NormalizedActive / GameManager.GetAuroraManager().m_FullyActiveValue);

                baseSun = Color.Lerp(origSun, auroraModColor, auroraLevel);
                baseFog = Color.Lerp(origFog, auroraModColor, auroraLevel);
            }

            float baseInt = 1f;
            float baseRng = 10f;

            //Setup Global values

            ls.intMod = ApplyWeatherIntensityMod() + (GetFlickeringMod() * 1f);
            ls.rngMod = ApplyWeatherRangeMod();

            ls.shadowStr     = GetShadowStrength();
            ls.lightshaftStr = GetLightshaftStrength();
            ls.sunStr        = (GetLightshaftStrength() + (GetFlickeringMod() * 0.4f)) * GetSunStrength();

            //Lightshaft
            ColorHSV sColor = baseSun;

            sColor.v           = 0.8f;
            ls.lightshaftColor = ApplyWeatherMod(sColor);

            //Ambience
            Color bColor = ApplyWeatherMod(baseSun);

            ColorHSV dColor = bColor;

            dColor.s *= 0.5f;
            //Flicker doesn't affect ambience
            //dColor.v = 0.4f + (GetFlickeringMod() * 0.1f);
            dColor.v = 0.4f;

            ColorHSV nColor = dColor;

            nColor.v = 0.01f;

            ls.ambientDayColor   = dColor;
            ls.ambientNightColor = nColor;

            //Windows
            ColorHSV wColor = bColor;

            wColor.s *= Mathf.Min(ApplyWeatherSaturationMod() - 0.2f, 0.4f);
            wColor.v *= (ls.intMod + 0.5f) + GetFlickeringMod();

            ls.windowColor = wColor;

            ls.windowStrMod = ls.intMod;

            //Setup Orientations
            foreach (string dir in cardinal)
            {
                Color lColor = baseFog;

                if (prd != null)
                {
                    float sunMix = Mathf.Lerp(prd.orientations[dir].sun[0], prd.orientations[dir].sun[1], TimeWeather.currentPeriodPct);
                    lColor = Color.Lerp(baseFog, baseSun, sunMix);

                    //Apply hue mod
                    if (prd.orientations[dir].hue != null)
                    {
                        float    hueMix    = Mathf.Lerp(prd.orientations[dir].hue[0], prd.orientations[dir].hue[1], TimeWeather.currentPeriodPct);
                        ColorHSV lColorHSV = new ColorHSV(lColor);

                        lColorHSV.h += hueMix;

                        lColor = lColorHSV;
                    }

                    //Apply weather mods
                    lColor = ApplyWeatherMod(lColor);

                    //Apply Intensity & Range
                    baseInt = Mathf.Lerp(prd.intensity[0], prd.intensity[1], TimeWeather.currentPeriodPct);
                    baseRng = Mathf.Lerp(prd.range[0], prd.range[1], TimeWeather.currentPeriodPct);
                }

                LightOrientation lo = new LightOrientation
                {
                    color     = (Color)lColor,
                    intensity = baseInt,
                    range     = baseRng
                };

                ls.orientations.Add(dir, lo);
            }

            LightOrientation defaultOrientation = new LightOrientation
            {
                color     = baseFog,
                intensity = baseInt,
                range     = baseRng
            };

            ls.orientations.Add("default", defaultOrientation);

            return(ls);
        }
Esempio n. 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;
                }
            }
        }