コード例 #1
0
        public static void MaybeUpdateLightsToPeriod(bool forceUpdate = false)
        {
            if (lightsInit && timeInit && weatherInit && config.ready)
            {
                //Generate lightsets for emitters based on time, weather and transition progress
                LightSet lightSet = config.GetCurrentLightSet();

                if (lightSet != null)
                {
                    currentLightSet = lightSet;
                    foreach (var light in lightList)
                    {
                        LightOrientation set = lightSet.orientations[light.orientation];

                        if (set != null)
                        {
                            light.SetLightParams(set, forceUpdate);
                        }
                        else
                        {
                            //MelonLoader.MelonLogger.Log("[AL] No set matches orientation.");
                            ALUtils.Log("ERROR: No set matches orientation.", false, true);
                        }
                    }
                }
                else
                {
                    //MelonLoader.MelonLogger.Log("[AL] No lightset defined");
                    ALUtils.Log("ERROR: No lightset defined.", false, true);
                }
            }
        }
コード例 #2
0
        public static void LoadConfigs()
        {
            currentScene = GameManager.m_ActiveScene;

            //Debug.Log("[ambient-lights] Loaded Scene: " + currentScene);
            ALUtils.Log("Loading Scene: " + currentScene, false, true);

            if (currentScene != "MainMenu")
            {
                config = new LightConfig();
                config.Load();

                if (config.ready)
                {
                    currentLightSet = config.GetCurrentLightSet();
                }

                SetupLights();
            }
        }
コード例 #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);
        }