示例#1
0
        private void UpdateOverlays(SkyTarget curSky)
        {
            tempOverlays.Clear();
            List <SkyOverlay> overlays = map.weatherManager.curWeather.Worker.overlays;

            for (int i = 0; i < overlays.Count; i++)
            {
                AddTempOverlay(new Pair <SkyOverlay, float>(overlays[i], map.weatherManager.TransitionLerpFactor));
            }
            List <SkyOverlay> overlays2 = map.weatherManager.lastWeather.Worker.overlays;

            for (int j = 0; j < overlays2.Count; j++)
            {
                AddTempOverlay(new Pair <SkyOverlay, float>(overlays2[j], 1f - map.weatherManager.TransitionLerpFactor));
            }
            for (int k = 0; k < map.gameConditionManager.ActiveConditions.Count; k++)
            {
                GameCondition     gameCondition = map.gameConditionManager.ActiveConditions[k];
                List <SkyOverlay> list          = gameCondition.SkyOverlays(map);
                if (list != null)
                {
                    for (int l = 0; l < list.Count; l++)
                    {
                        AddTempOverlay(new Pair <SkyOverlay, float>(list[l], gameCondition.SkyTargetLerpFactor(map)));
                    }
                }
            }
            for (int m = 0; m < tempOverlays.Count; m++)
            {
                Color overlay = curSky.colors.overlay;
                overlay.a = tempOverlays[m].Second;
                tempOverlays[m].First.OverlayColor = overlay;
            }
        }
示例#2
0
        public void SkyManagerUpdate()
        {
            SkyTarget curSky = this.CurrentSkyTarget();

            this.curSkyGlowInt = curSky.glow;
            if (this.map == Find.VisibleMap)
            {
                MatBases.LightOverlay.color = curSky.colors.sky;
                Find.CameraColor.saturation = curSky.colors.saturation;
                Color color = curSky.colors.sky;
                color.a = 1f;
                color  *= SkyManager.FogOfWarBaseColor;
                MatBases.FogOfWar.color = color;
                Color   color2 = curSky.colors.shadow;
                Vector3?overridenShadowVector = this.GetOverridenShadowVector();
                if (overridenShadowVector.HasValue)
                {
                    this.SetSunShadowVector(overridenShadowVector.Value);
                }
                else
                {
                    GenCelestial.LightInfo lightSourceInfo = GenCelestial.GetLightSourceInfo(this.map, GenCelestial.LightType.Shadow);
                    this.SetSunShadowVector(lightSourceInfo.vector);
                    color2 = Color.Lerp(Color.white, color2, GenCelestial.CurShadowStrength(this.map));
                }
                GenCelestial.LightInfo lightSourceInfo2 = GenCelestial.GetLightSourceInfo(this.map, GenCelestial.LightType.LightingSun);
                GenCelestial.LightInfo lightSourceInfo3 = GenCelestial.GetLightSourceInfo(this.map, GenCelestial.LightType.LightingMoon);
                Shader.SetGlobalVector(ShaderPropertyIDs.WaterCastVectSun, new Vector4(lightSourceInfo2.vector.x, 0f, lightSourceInfo2.vector.y, lightSourceInfo2.intensity));
                Shader.SetGlobalVector(ShaderPropertyIDs.WaterCastVectMoon, new Vector4(lightSourceInfo3.vector.x, 0f, lightSourceInfo3.vector.y, lightSourceInfo3.intensity));
                Shader.SetGlobalFloat("_LightsourceShineSizeReduction", (float)(20.0 * (1.0 / curSky.lightsourceShineSize)));
                Shader.SetGlobalFloat("_LightsourceShineIntensity", curSky.lightsourceShineIntensity);
                MatBases.SunShadow.color = color2;
                this.UpdateOverlays(curSky);
            }
        }
示例#3
0
        public void SkyManagerUpdate()
        {
            SkyTarget curSky = CurrentSkyTarget();

            curSkyGlowInt = curSky.glow;
            if (map == Find.CurrentMap)
            {
                MatBases.LightOverlay.color = curSky.colors.sky;
                //Find.CameraColor.saturation = curSky.colors.saturation;
                Color sky = curSky.colors.sky;
                sky.a = 1f;
                sky  *= FogOfWarBaseColor;
                MatBases.FogOfWar.color = sky;
                Color   color = curSky.colors.shadow;
                Vector3?overridenShadowVector = GetOverridenShadowVector();
                if (overridenShadowVector.HasValue)
                {
                    SetSunShadowVector(overridenShadowVector.Value);
                }
                else
                {
                    SetSunShadowVector(GenCelestial.GetLightSourceInfo(map, GenCelestial.LightType.Shadow).vector);
                    color = Color.Lerp(Color.white, color, GenCelestial.CurShadowStrength(map));
                }
                GenCelestial.LightInfo lightSourceInfo  = GenCelestial.GetLightSourceInfo(map, GenCelestial.LightType.LightingSun);
                GenCelestial.LightInfo lightSourceInfo2 = GenCelestial.GetLightSourceInfo(map, GenCelestial.LightType.LightingMoon);
                Shader.SetGlobalVector(ShaderPropertyIDs.WaterCastVectSun, new Vector4(lightSourceInfo.vector.x, 0f, lightSourceInfo.vector.y, lightSourceInfo.intensity));
                Shader.SetGlobalVector(ShaderPropertyIDs.WaterCastVectMoon, new Vector4(lightSourceInfo2.vector.x, 0f, lightSourceInfo2.vector.y, lightSourceInfo2.intensity));
                Shader.SetGlobalFloat("_LightsourceShineSizeReduction", 20f * (1f / curSky.lightsourceShineSize));
                Shader.SetGlobalFloat("_LightsourceShineIntensity", curSky.lightsourceShineIntensity);
                MatBases.SunShadow.color = color;
                UpdateOverlays(curSky);
            }
        }
示例#4
0
        private SkyTarget CurrentSkyTarget()
        {
            SkyTarget b         = this.map.weatherManager.curWeather.Worker.CurSkyTarget(this.map);
            SkyTarget a         = this.map.weatherManager.lastWeather.Worker.CurSkyTarget(this.map);
            SkyTarget skyTarget = SkyTarget.Lerp(a, b, this.map.weatherManager.TransitionLerpFactor);
            float     num       = this.map.gameConditionManager.AggregateSkyTargetLerpFactor();

            if (num > 9.9999997473787516E-05)
            {
                SkyTarget value = this.map.gameConditionManager.AggregateSkyTarget().Value;
                skyTarget = SkyTarget.LerpDarken(skyTarget, value, num);
            }
            List <WeatherEvent> liveEventsListForReading = this.map.weatherManager.eventHandler.LiveEventsListForReading;

            for (int i = 0; i < liveEventsListForReading.Count; i++)
            {
                if (liveEventsListForReading[i].CurrentlyAffectsSky)
                {
                    skyTarget = SkyTarget.Lerp(skyTarget, liveEventsListForReading[i].SkyTarget, liveEventsListForReading[i].SkyTargetLerpFactor);
                }
            }
            List <Thing> list = this.map.listerThings.ThingsInGroup(ThingRequestGroup.AffectsSky);

            for (int j = 0; j < list.Count; j++)
            {
                CompAffectsSky compAffectsSky = list[j].TryGetComp <CompAffectsSky>();
                if (compAffectsSky.LerpFactor > 0.0)
                {
                    skyTarget = ((!compAffectsSky.Props.lerpDarken) ? SkyTarget.Lerp(skyTarget, compAffectsSky.SkyTarget, compAffectsSky.LerpFactor) : SkyTarget.LerpDarken(skyTarget, compAffectsSky.SkyTarget, compAffectsSky.LerpFactor));
                }
            }
            return(skyTarget);
        }
示例#5
0
        public SkyTarget CurSkyTarget(Map map)
        {
            float num  = GenCelestial.CurCelestialSunGlow(map);
            int   num2 = 0;
            int   num3 = 0;

            for (int i = 0; i < skyTargets.Length; i++)
            {
                num3 = i;
                if (num + 0.001f < skyTargets[i].celGlowThreshold)
                {
                    break;
                }
                num2 = i;
            }
            SkyThreshold skyThreshold  = skyTargets[num2];
            SkyThreshold skyThreshold2 = skyTargets[num3];
            float        num4          = skyThreshold2.celGlowThreshold - skyThreshold.celGlowThreshold;
            float        t             = (num4 != 0f) ? ((num - skyThreshold.celGlowThreshold) / num4) : 1f;
            SkyTarget    result        = default(SkyTarget);

            result.glow   = num;
            result.colors = SkyColorSet.Lerp(skyThreshold.colors, skyThreshold2.colors, t);
            if (GenCelestial.IsDaytime(num))
            {
                result.lightsourceShineIntensity = 1f;
                result.lightsourceShineSize      = 1f;
            }
            else
            {
                result.lightsourceShineIntensity = 0.7f;
                result.lightsourceShineSize      = 0.5f;
            }
            return(result);
        }
示例#6
0
        public static SkyTarget LerpDarken(SkyTarget A, SkyTarget B, float t)
        {
            SkyTarget result = default(SkyTarget);

            result.colors = SkyColorSet.Lerp(A.colors, B.colors, t);
            result.glow   = Mathf.Lerp(A.glow, Mathf.Min(A.glow, B.glow), t);
            result.lightsourceShineSize      = Mathf.Lerp(A.lightsourceShineSize, Mathf.Min(A.lightsourceShineSize, B.lightsourceShineSize), t);
            result.lightsourceShineIntensity = Mathf.Lerp(A.lightsourceShineIntensity, Mathf.Min(A.lightsourceShineIntensity, B.lightsourceShineIntensity), t);
            return(result);
        }
示例#7
0
 public static SkyTarget LerpDarken(SkyTarget A, SkyTarget B, float t)
 {
     return(new SkyTarget
     {
         colors = SkyColorSet.Lerp(A.colors, B.colors, t),
         glow = Mathf.Lerp(A.glow, Mathf.Min(A.glow, B.glow), t),
         lightsourceShineSize = Mathf.Lerp(A.lightsourceShineSize, Mathf.Min(A.lightsourceShineSize, B.lightsourceShineSize), t),
         lightsourceShineIntensity = Mathf.Lerp(A.lightsourceShineIntensity, Mathf.Min(A.lightsourceShineIntensity, B.lightsourceShineIntensity), t)
     });
 }
示例#8
0
        private SkyTarget CurrentSkyTarget()
        {
            SkyTarget b         = this.map.weatherManager.curWeather.Worker.CurSkyTarget(this.map);
            SkyTarget a         = this.map.weatherManager.lastWeather.Worker.CurSkyTarget(this.map);
            SkyTarget skyTarget = SkyTarget.Lerp(a, b, this.map.weatherManager.TransitionLerpFactor);

            this.map.gameConditionManager.GetAllGameConditionsAffectingMap(this.map, this.tempAllGameConditionsAffectingMap);
            for (int i = 0; i < this.tempAllGameConditionsAffectingMap.Count; i++)
            {
                SkyTarget?skyTarget2 = this.tempAllGameConditionsAffectingMap[i].SkyTarget(this.map);
                if (skyTarget2.HasValue)
                {
                    skyTarget = SkyTarget.LerpDarken(skyTarget, skyTarget2.Value, this.tempAllGameConditionsAffectingMap[i].SkyTargetLerpFactor(this.map));
                }
            }
            this.tempAllGameConditionsAffectingMap.Clear();
            List <WeatherEvent> liveEventsListForReading = this.map.weatherManager.eventHandler.LiveEventsListForReading;

            for (int j = 0; j < liveEventsListForReading.Count; j++)
            {
                if (liveEventsListForReading[j].CurrentlyAffectsSky)
                {
                    skyTarget = SkyTarget.Lerp(skyTarget, liveEventsListForReading[j].SkyTarget, liveEventsListForReading[j].SkyTargetLerpFactor);
                }
            }
            List <Thing> list = this.map.listerThings.ThingsInGroup(ThingRequestGroup.AffectsSky);

            for (int k = 0; k < list.Count; k++)
            {
                CompAffectsSky compAffectsSky = list[k].TryGetComp <CompAffectsSky>();
                if (compAffectsSky.LerpFactor > 0f)
                {
                    if (compAffectsSky.Props.lerpDarken)
                    {
                        skyTarget = SkyTarget.LerpDarken(skyTarget, compAffectsSky.SkyTarget, compAffectsSky.LerpFactor);
                    }
                    else
                    {
                        skyTarget = SkyTarget.Lerp(skyTarget, compAffectsSky.SkyTarget, compAffectsSky.LerpFactor);
                    }
                }
            }
            return(skyTarget);
        }
        public SkyTarget CurSkyTarget(Map map)
        {
            float num  = GenCelestial.CurCelestialSunGlow(map);
            int   num2 = 0;
            int   num3 = 0;
            int   num4 = 0;

            while (num4 < this.skyTargets.Length)
            {
                num3 = num4;
                if (!(num + 0.0010000000474974513 < this.skyTargets[num4].celGlowThreshold))
                {
                    num2 = num4;
                    num4++;
                    continue;
                }
                break;
            }
            SkyThreshold skyThreshold  = this.skyTargets[num2];
            SkyThreshold skyThreshold2 = this.skyTargets[num3];
            float        num5          = skyThreshold2.celGlowThreshold - skyThreshold.celGlowThreshold;
            float        t             = (float)((num5 != 0.0) ? ((num - skyThreshold.celGlowThreshold) / num5) : 1.0);
            SkyTarget    result        = default(SkyTarget);

            result.glow   = num;
            result.colors = SkyColorSet.Lerp(skyThreshold.colors, skyThreshold2.colors, t);
            if (GenCelestial.IsDaytime(num))
            {
                result.lightsourceShineIntensity = 1f;
                result.lightsourceShineSize      = 1f;
            }
            else
            {
                result.lightsourceShineIntensity = 0.7f;
                result.lightsourceShineSize      = 0.5f;
            }
            return(result);
        }