示例#1
0
        public override string GetReport()
        {
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
            {
                return("WatchingEclipse".Translate());
            }
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
            {
                return("WatchingAurora".Translate());
            }
            float num = GenCelestial.CurCelestialSunGlow(base.Map);

            if (num < 0.1f)
            {
                return("Stargazing".Translate());
            }
            if (num >= 0.65f)
            {
                return("CloudWatching".Translate());
            }
            if (GenLocalDate.DayPercent(this.pawn) < 0.5f)
            {
                return("WatchingSunrise".Translate());
            }
            return("WatchingSunset".Translate());
        }
示例#2
0
		public static float GetFallColorFactor(float latitude, int dayOfYear)
		{
			float a = GenCelestial.AverageGlow(latitude, dayOfYear);
			float b = GenCelestial.AverageGlow(latitude, dayOfYear + 1);
			float x = Mathf.LerpUnclamped(a, b, PlantFallColors.FallSlopeComponent);
			return GenMath.LerpDoubleClamped(PlantFallColors.FallColorBegin, PlantFallColors.FallColorEnd, 0f, 1f, x);
		}
示例#3
0
 public static void LogSunGlowForYear()
 {
     for (int i = -90; i <= 90; i += 10)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("Sun visibility percents for latitude " + i + ", for each hour of each day of the year");
         stringBuilder.AppendLine("---------------------------------------");
         stringBuilder.Append("Day/hr".PadRight(6));
         for (int j = 0; j < 24; j += 2)
         {
             stringBuilder.Append((j.ToString() + "h").PadRight(6));
         }
         stringBuilder.AppendLine();
         for (int k = 0; k < 60; k += 5)
         {
             stringBuilder.Append(k.ToString().PadRight(6));
             for (int l = 0; l < 24; l += 2)
             {
                 stringBuilder.Append(GenCelestial.CelestialSunGlowPercent((float)i, k, (float)((float)l / 24.0)).ToString("F3").PadRight(6));
             }
             stringBuilder.AppendLine();
         }
         Log.Message(stringBuilder.ToString());
     }
 }
示例#4
0
 public static void LogSunAngleForYear()
 {
     for (int i = -90; i <= 90; i += 10)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("Sun angles for latitude " + i + ", for each hour of each day of the year");
         stringBuilder.AppendLine("---------------------------------------");
         stringBuilder.Append("Day/hr".PadRight(6));
         for (int j = 0; j < 24; j += 2)
         {
             stringBuilder.Append((j.ToString() + "h").PadRight(6));
         }
         stringBuilder.AppendLine();
         for (int k = 0; k < 60; k += 5)
         {
             stringBuilder.Append(k.ToString().PadRight(6));
             for (int l = 0; l < 24; l += 2)
             {
                 float num = Vector3.Angle(GenCelestial.SurfaceNormal((float)i), GenCelestial.SunPositionUnmodified((float)k, (float)l / 24f, new Vector3(1f, 0f, 0f), 0f));
                 stringBuilder.Append((90f - num).ToString("F0").PadRight(6));
             }
             stringBuilder.AppendLine();
         }
         Log.Message(stringBuilder.ToString(), false);
     }
 }
示例#5
0
        public static GenCelestial.LightInfo GetLightSourceInfo(Map map, GenCelestial.LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

            if (type == GenCelestial.LightType.Shadow)
            {
                flag      = GenCelestial.IsDaytime(GenCelestial.CurCelestialSunGlow(map));
                intensity = GenCelestial.CurShadowStrength(map);
            }
            else if (type == GenCelestial.LightType.LightingSun)
            {
                flag      = true;
                intensity = Mathf.Clamp01((GenCelestial.CurCelestialSunGlow(map) - 0.6f + 0.2f) / 0.15f);
            }
            else if (type == GenCelestial.LightType.LightingMoon)
            {
                flag      = false;
                intensity = Mathf.Clamp01(-(GenCelestial.CurCelestialSunGlow(map) - 0.6f - 0.2f) / 0.15f);
            }
            else
            {
                Log.ErrorOnce("Invalid light type requested", 64275614, false);
                flag      = true;
                intensity = 0f;
            }
            float t;
            float num2;
            float num3;

            if (flag)
            {
                t    = num;
                num2 = -1.5f;
                num3 = 15f;
            }
            else
            {
                if (num > 0.5f)
                {
                    t = Mathf.InverseLerp(0.5f, 1f, num) * 0.5f;
                }
                else
                {
                    t = 0.5f + Mathf.InverseLerp(0f, 0.5f, num) * 0.5f;
                }
                num2 = -0.9f;
                num3 = 15f;
            }
            float num4 = Mathf.LerpUnclamped(-num3, num3, t);
            float y    = num2 - 2.5f * (num4 * num4 / 100f);

            return(new GenCelestial.LightInfo
            {
                vector = new Vector2(num4, y),
                intensity = intensity
            });
        }
示例#6
0
        public override SkyTarget?SkyTarget(Map map)
        {
            Color       currentColor = this.CurrentColor;
            SkyColorSet colorSet     = new SkyColorSet(Color.Lerp(Color.white, currentColor, 0.075f) * this.Brightness(map), new Color(0.92f, 0.92f, 0.92f), Color.Lerp(Color.white, currentColor, 0.025f) * this.Brightness(map), 1f);
            float       glow         = Mathf.Max(GenCelestial.CurCelestialSunGlow(map), 0.25f);

            return(new SkyTarget?(new SkyTarget(glow, colorSet, 1f, 1f)));
        }
示例#7
0
        private static float CelestialSunGlowPercent(float latitude, int dayOfYear, float dayPercent)
        {
            Vector3 vector = GenCelestial.SurfaceNormal(latitude);
            Vector3 rhs    = GenCelestial.SunPosition(latitude, dayOfYear, dayPercent);
            float   value  = Vector3.Dot(vector.normalized, rhs);
            float   value2 = Mathf.InverseLerp(0f, 0.7f, value);

            return(Mathf.Clamp01(value2));
        }
示例#8
0
        public static float AverageGlow(float latitude, int dayOfYear)
        {
            float num = 0f;

            for (int i = 0; i < 24; i++)
            {
                num += GenCelestial.CelestialSunGlowPercent(latitude, dayOfYear, (float)i / 24f);
            }
            return(num / 24f);
        }
示例#9
0
        public override SkyTarget?SkyTarget()
        {
            Color currentColor = this.CurrentColor;

            this.AuroraSkyColors.sky     = Color.Lerp(Color.white, currentColor, 0.075f) * this.Brightness;
            this.AuroraSkyColors.overlay = Color.Lerp(Color.white, currentColor, 0.025f) * this.Brightness;
            float glow = Mathf.Max(GenCelestial.CurCelestialSunGlow(base.Map), 0.25f);

            return(new SkyTarget?(new SkyTarget(glow, this.AuroraSkyColors, 1f, 1f)));
        }
        protected override bool CanFireNowSub(IIncidentTarget target)
        {
            if (!base.CanFireNowSub(target))
            {
                return(false);
            }
            Map map = (Map)target;

            return(GenCelestial.CurCelestialSunGlow(map) <= 0.5f && GenCelestial.CelestialSunGlow(map, Find.TickManager.TicksAbs + 5000) <= 0.5f);
        }
示例#11
0
        public static LightInfo GetLightSourceInfo(Map map, LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

            switch (type)
            {
            case LightType.Shadow:
                flag      = GenCelestial.IsDaytime(GenCelestial.CurCelestialSunGlow(map));
                intensity = GenCelestial.CurShadowStrength(map);
                break;

            case LightType.LightingSun:
                flag      = true;
                intensity = Mathf.Clamp01((float)((GenCelestial.CurCelestialSunGlow(map) - 0.60000002384185791 + 0.20000000298023224) / 0.15000000596046448));
                break;

            case LightType.LightingMoon:
                flag      = false;
                intensity = Mathf.Clamp01((float)((0.0 - (GenCelestial.CurCelestialSunGlow(map) - 0.60000002384185791 - 0.20000000298023224)) / 0.15000000596046448));
                break;

            default:
                Log.ErrorOnce("Invalid light type requested", 64275614);
                flag      = true;
                intensity = 0f;
                break;
            }
            float t;
            float num2;
            float num3;

            if (flag)
            {
                t    = num;
                num2 = -1.5f;
                num3 = 15f;
            }
            else
            {
                t    = (float)((!(num > 0.5)) ? (0.5 + Mathf.InverseLerp(0f, 0.5f, num) * 0.5) : (Mathf.InverseLerp(0.5f, 1f, num) * 0.5));
                num2 = -0.9f;
                num3 = 15f;
            }
            float     num4   = Mathf.LerpUnclamped((float)(0.0 - num3), num3, t);
            float     y      = (float)(num2 - 2.5 * (num4 * num4 / 100.0));
            LightInfo result = default(LightInfo);

            result.vector    = new Vector2(num4, y);
            result.intensity = intensity;
            return(result);
        }
示例#12
0
 private bool AuroraWillEndSoon(Map map)
 {
     if (GenCelestial.CurCelestialSunGlow(map) > 0.5f)
     {
         return(true);
     }
     if (GenCelestial.CelestialSunGlow(map, Find.TickManager.TicksAbs + 5000) > 0.5f)
     {
         return(true);
     }
     return(false);
 }
示例#13
0
 public override void GameConditionTick()
 {
     this.curColorTransition += 1f / (float)this.TransitionDurationTicks;
     if (this.curColorTransition >= 1f)
     {
         this.prevColorIndex     = this.curColorIndex;
         this.curColorIndex      = this.GetNewColorIndex();
         this.curColorTransition = 0f;
     }
     if (!base.Permanent && base.TicksLeft > 200 && GenCelestial.CurCelestialSunGlow(base.Map) > 0.5f)
     {
         base.TicksLeft = 200;
     }
 }
示例#14
0
        private static Vector3 SunPosition(float latitude, int dayOfYear, float dayPercent)
        {
            Vector3 target  = GenCelestial.SurfaceNormal(latitude);
            Vector3 current = GenCelestial.SunPositionUnmodified((float)dayOfYear, dayPercent, new Vector3(1f, 0f, 0f));

            current = Vector3.RotateTowards(current, target, 0.331612557f, 9999999f);
            float num = Mathf.InverseLerp(60f, 0f, Mathf.Abs(latitude));

            if (num > 0.0)
            {
                current = Vector3.RotateTowards(current, target, (float)(6.2831854820251465 * (17.0 * num / 360.0)), 9999999f);
            }
            return(current.normalized);
        }
示例#15
0
        private static Vector3 SunPosition(float latitude, int dayOfYear, float dayPercent)
        {
            Vector3 target  = GenCelestial.SurfaceNormal(latitude);
            Vector3 current = GenCelestial.SunPositionUnmodified((float)dayOfYear, dayPercent, new Vector3(1f, 0f, 0f), latitude);
            float   num     = GenCelestial.SunPeekAroundDegreesFactorCurve.Evaluate(latitude);

            current = Vector3.RotateTowards(current, target, 0.331612557f * num, 9999999f);
            float num2 = Mathf.InverseLerp(60f, 0f, Mathf.Abs(latitude));

            if (num2 > 0f)
            {
                current = Vector3.RotateTowards(current, target, 6.28318548f * (17f * num2 / 360f), 9999999f);
            }
            return(current.normalized);
        }
示例#16
0
 public static float CurShadowStrength(Map map)
 {
     return(Mathf.Clamp01((float)(Mathf.Abs((float)(GenCelestial.CurCelestialSunGlow(map) - 0.60000002384185791)) / 0.15000000596046448)));
 }
示例#17
0
        public static float CelestialSunGlow(Map map, int ticksAbs)
        {
            Vector2 vector = Find.WorldGrid.LongLatOf(map.Tile);

            return(GenCelestial.CelestialSunGlowPercent(vector.y, GenDate.DayOfYear(ticksAbs, vector.x), GenDate.DayPercent(ticksAbs, vector.x)));
        }
示例#18
0
 public static float CurCelestialSunGlow(Map map)
 {
     return(GenCelestial.CelestialSunGlow(map, Find.TickManager.TicksAbs));
 }
示例#19
0
        public static Vector3 CurSunPositionInWorldSpace()
        {
            int ticksAbsForSunPosInWorldSpace = GenCelestial.TicksAbsForSunPosInWorldSpace;

            return(GenCelestial.SunPositionUnmodified((float)GenDate.DayOfYear(ticksAbsForSunPosInWorldSpace, 0f), GenDate.DayPercent(ticksAbsForSunPosInWorldSpace, 0f), new Vector3(0f, 0f, -1f)));
        }
示例#20
0
 public static float CurShadowStrength(Map map)
 {
     return(Mathf.Clamp01(Mathf.Abs(GenCelestial.CurCelestialSunGlow(map) - 0.6f) / 0.15f));
 }
        public override SkyTarget?SkyTarget(Map map)
        {
            Color currentColor = CurrentColor;

            return(new SkyTarget(colorSet: new SkyColorSet(Color.Lerp(Color.white, currentColor, 0.075f) * Brightness(map), new Color(0.92f, 0.92f, 0.92f), Color.Lerp(Color.white, currentColor, 0.025f) * Brightness(map), 1f), glow: Mathf.Max(GenCelestial.CurCelestialSunGlow(map), 0.25f), lightsourceShineSize: 1f, lightsourceShineIntensity: 1f));
        }
 private float Brightness(Map map)
 {
     return(Mathf.Max(0.73f, GenCelestial.CurCelestialSunGlow(map)));
 }
 private bool AuroraWillEndSoon(Map map)
 {
     return(GenCelestial.CurCelestialSunGlow(map) > 0.5f || GenCelestial.CelestialSunGlow(map, Find.TickManager.TicksAbs + 5000) > 0.5f);
 }