Beispiel #1
0
        private bool AppropriateNow(SongDef song)
        {
            if (!song.playOnMap)
            {
                return(false);
            }
            if (DangerMusicMode)
            {
                if (!song.tense)
                {
                    return(false);
                }
            }
            else if (song.tense)
            {
                return(false);
            }
            Map map = Find.AnyPlayerHomeMap ?? Find.CurrentMap;

            if (!song.allowedSeasons.NullOrEmpty())
            {
                if (map == null)
                {
                    return(false);
                }
                if (!song.allowedSeasons.Contains(GenLocalDate.Season(map)))
                {
                    return(false);
                }
            }
            if (song.minRoyalTitle != null && !PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists.Any((Pawn p) => p.royalty.AllTitlesForReading.Any() && p.royalty.MostSeniorTitle.def.seniority >= song.minRoyalTitle.seniority && !p.IsQuestLodger()))
            {
                return(false);
            }
            if (recentSongs.Contains(song))
            {
                return(false);
            }
            if (song.allowedTimeOfDay != TimeOfDay.Any)
            {
                if (map == null)
                {
                    return(true);
                }
                if (song.allowedTimeOfDay == TimeOfDay.Night)
                {
                    if (!(GenLocalDate.DayPercent(map) < 0.2f))
                    {
                        return(GenLocalDate.DayPercent(map) > 0.7f);
                    }
                    return(true);
                }
                if (GenLocalDate.DayPercent(map) > 0.2f)
                {
                    return(GenLocalDate.DayPercent(map) < 0.7f);
                }
                return(false);
            }
            return(true);
        }
Beispiel #2
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());
        }
Beispiel #3
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
            });
        }
Beispiel #4
0
        private bool AppropriateNow(SongDef song)
        {
            bool result;

            if (!song.playOnMap)
            {
                result = false;
            }
            else
            {
                if (this.DangerMusicMode)
                {
                    if (!song.tense)
                    {
                        return(false);
                    }
                }
                else if (song.tense)
                {
                    return(false);
                }
                Map map = Find.AnyPlayerHomeMap ?? Find.CurrentMap;
                if (!song.allowedSeasons.NullOrEmpty <Season>())
                {
                    if (map == null)
                    {
                        return(false);
                    }
                    if (!song.allowedSeasons.Contains(GenLocalDate.Season(map)))
                    {
                        return(false);
                    }
                }
                if (this.recentSongs.Contains(song))
                {
                    result = false;
                }
                else if (song.allowedTimeOfDay != TimeOfDay.Any)
                {
                    if (map == null)
                    {
                        result = true;
                    }
                    else if (song.allowedTimeOfDay == TimeOfDay.Night)
                    {
                        result = (GenLocalDate.DayPercent(map) < 0.2f || GenLocalDate.DayPercent(map) > 0.7f);
                    }
                    else
                    {
                        result = (GenLocalDate.DayPercent(map) > 0.2f && GenLocalDate.DayPercent(map) < 0.7f);
                    }
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
Beispiel #5
0
        public static LightInfo GetLightSourceInfo(Map map, LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

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

            case LightType.LightingSun:
                flag      = true;
                intensity = Mathf.Clamp01((CurCelestialSunGlow(map) - 0.6f + 0.2f) / 0.15f);
                break;

            case LightType.LightingMoon:
                flag      = false;
                intensity = Mathf.Clamp01((0f - (CurCelestialSunGlow(map) - 0.6f - 0.2f)) / 0.15f);
                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    = ((!(num > 0.5f)) ? (0.5f + Mathf.InverseLerp(0f, 0.5f, num) * 0.5f) : (Mathf.InverseLerp(0.5f, 1f, num) * 0.5f));
                num2 = -0.9f;
                num3 = 15f;
            }
            float     num4   = Mathf.LerpUnclamped(0f - num3, num3, t);
            float     y      = num2 - 2.5f * (num4 * num4 / 100f);
            LightInfo result = default(LightInfo);

            result.vector    = new Vector2(num4, y);
            result.intensity = intensity;
            return(result);
        }
Beispiel #6
0
        public void RecalculateAllowed()
        {
            float num = GenLocalDate.DayPercent(parent);

            if (Props.startTime <= Props.endTime)
            {
                Allowed = num > Props.startTime && num < Props.endTime;
            }
            else
            {
                Allowed = num <Props.endTime || num> Props.startTime;
            }
        }
Beispiel #7
0
        public void RecalculateAllowed()
        {
            float num = GenLocalDate.DayPercent(base.parent);

            if (this.Props.startTime <= this.Props.endTime)
            {
                this.Allowed = (num > this.Props.startTime && num < this.Props.endTime);
            }
            else
            {
                this.Allowed = (num <this.Props.endTime || num> this.Props.startTime);
            }
        }
Beispiel #8
0
        private bool AppropriateNow(SongDef song)
        {
            if (!song.playOnMap)
            {
                return(false);
            }
            if (this.DangerMusicMode)
            {
                if (!song.tense)
                {
                    return(false);
                }
            }
            else if (song.tense)
            {
                return(false);
            }
            Map map = Find.AnyPlayerHomeMap ?? Find.VisibleMap;

            if (!song.allowedSeasons.NullOrEmpty())
            {
                if (map == null)
                {
                    return(false);
                }
                if (!song.allowedSeasons.Contains(GenLocalDate.Season(map)))
                {
                    return(false);
                }
            }
            if (this.recentSongs.Contains(song))
            {
                return(false);
            }
            if (song.allowedTimeOfDay != TimeOfDay.Any)
            {
                if (map == null)
                {
                    return(true);
                }
                if (song.allowedTimeOfDay == TimeOfDay.Night)
                {
                    return(GenLocalDate.DayPercent(map) < 0.20000000298023224 || GenLocalDate.DayPercent(map) > 0.699999988079071);
                }
                return(GenLocalDate.DayPercent(map) > 0.20000000298023224 && GenLocalDate.DayPercent(map) < 0.699999988079071);
            }
            return(true);
        }
Beispiel #9
0
 public static float DayPercent(Map map)
 {
     return(GenLocalDate.DayPercent(map.Tile));
 }