Example #1
0
        public void DateNotifierTick()
        {
            Map    map       = this.FindPlayerHomeWithMinTimezone();
            float  latitude  = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).y;
            float  longitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).x;
            Season season    = GenDate.Season((long)Find.TickManager.TicksAbs, latitude, longitude);

            if (season != this.lastSeason && (this.lastSeason == Season.Undefined || season != this.lastSeason.GetPreviousSeason()))
            {
                if (this.lastSeason != Season.Undefined && this.AnyPlayerHomeSeasonsAreMeaningful())
                {
                    if (GenDate.YearsPassed == 0 && season == Season.Summer && this.AnyPlayerHomeAvgTempIsLowInWinter())
                    {
                        Find.LetterStack.ReceiveLetter("LetterLabelFirstSummerWarning".Translate(), "FirstSummerWarning".Translate(), LetterDefOf.NeutralEvent, null);
                    }
                    else if (GenDate.DaysPassed > 5)
                    {
                        Messages.Message("MessageSeasonBegun".Translate(new object[]
                        {
                            season.Label()
                        }).CapitalizeFirst(), MessageTypeDefOf.NeutralEvent);
                    }
                }
                this.lastSeason = season;
            }
        }
Example #2
0
        public static string SeasonDateStringAt(long absTicks, Vector2 longLat)
        {
            int    num  = GenDate.DayOfSeason(absTicks, longLat.x) + 1;
            string text = Find.ActiveLanguageWorker.OrdinalNumber(num);

            return("SeasonFullDate".Translate(text, GenDate.Season(absTicks, longLat).Label(), num));
        }
        public void DateNotifierTick()
        {
            Map    map = this.FindPlayerHomeWithMinTimezone();
            double num;

            if (map != null)
            {
                Vector2 vector = Find.WorldGrid.LongLatOf(map.Tile);
                num = vector.y;
            }
            else
            {
                num = 0.0;
            }
            float  latitude = (float)num;
            double num2;

            if (map != null)
            {
                Vector2 vector2 = Find.WorldGrid.LongLatOf(map.Tile);
                num2 = vector2.x;
            }
            else
            {
                num2 = 0.0;
            }
            float  longitude = (float)num2;
            Season season    = GenDate.Season(Find.TickManager.TicksAbs, latitude, longitude);

            if (season != this.lastSeason)
            {
                if (this.lastSeason != 0 && season == this.lastSeason.GetPreviousSeason())
                {
                    return;
                }
                if (this.lastSeason != 0 && this.AnyPlayerHomeSeasonsAreMeaningful())
                {
                    if (GenDate.YearsPassed == 0 && season == Season.Summer && this.AnyPlayerHomeAvgTempIsLowInWinter())
                    {
                        Find.LetterStack.ReceiveLetter("LetterLabelFirstSummerWarning".Translate(), "FirstSummerWarning".Translate(), LetterDefOf.NeutralEvent, (string)null);
                    }
                    else if (GenDate.DaysPassed > 5)
                    {
                        Messages.Message("MessageSeasonBegun".Translate(season.Label()).CapitalizeFirst(), MessageTypeDefOf.NeutralEvent);
                    }
                }
                this.lastSeason = season;
            }
        }
Example #4
0
        public void DateNotifierTick()
        {
            Map    map       = FindPlayerHomeWithMinTimezone();
            float  latitude  = (map != null) ? Find.WorldGrid.LongLatOf(map.Tile).y : 0f;
            float  longitude = (map != null) ? Find.WorldGrid.LongLatOf(map.Tile).x : 0f;
            Season season    = GenDate.Season(Find.TickManager.TicksAbs, latitude, longitude);

            if (season == lastSeason || (lastSeason != 0 && season == lastSeason.GetPreviousSeason()))
            {
                return;
            }
            if (lastSeason != 0 && AnyPlayerHomeSeasonsAreMeaningful())
            {
                if (GenDate.YearsPassed == 0 && season == Season.Summer && AnyPlayerHomeAvgTempIsLowInWinter())
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelFirstSummerWarning".Translate(), "FirstSummerWarning".Translate(), LetterDefOf.NeutralEvent);
                }
                else if (GenDate.DaysPassed > 5)
                {
                    Messages.Message("MessageSeasonBegun".Translate(season.Label()).CapitalizeFirst(), MessageTypeDefOf.NeutralEvent);
                }
            }
            lastSeason = season;
        }
        public static void DateOnGUI(Rect dateRect)
        {
            Vector2 location;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.VisibleMap == null)
                {
                    return;
                }
                location = Find.WorldGrid.LongLatOf(Find.VisibleMap.Tile);
            }
            int     index   = GenDate.HourInteger(Find.TickManager.TicksAbs, location.x);
            int     num     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, location.x);
            Season  season  = GenDate.Season(Find.TickManager.TicksAbs, location);
            Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, location.x);
            int     num2    = GenDate.Year(Find.TickManager.TicksAbs, location.x);
            string  text    = (!DateReadout.SeasonLabelVisible) ? string.Empty : season.LabelCap();

            if (num != DateReadout.dateStringDay || season != DateReadout.dateStringSeason || quadrum != DateReadout.dateStringQuadrum || num2 != DateReadout.dateStringYear)
            {
                DateReadout.dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, location);
                DateReadout.dateStringDay     = num;
                DateReadout.dateStringSeason  = season;
                DateReadout.dateStringQuadrum = quadrum;
                DateReadout.dateStringYear    = num2;
            }
            Text.Font = GameFont.Small;
            Vector2 vector  = Text.CalcSize(DateReadout.fastHourStrings[index]);
            float   x       = vector.x;
            Vector2 vector2 = Text.CalcSize(DateReadout.dateString);
            float   a       = Mathf.Max(x, (float)(vector2.x + 7.0));
            Vector2 vector3 = Text.CalcSize(text);
            float   num3    = Mathf.Max(a, vector3.x);

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, DateReadout.fastHourStrings[index]);
            rect.yMin += 26f;
            Widgets.Label(rect, DateReadout.dateString);
            rect.yMin += 26f;
            if (!text.NullOrEmpty())
            {
                Widgets.Label(rect, text);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            TooltipHandler.TipRegion(dateRect, new TipSignal(delegate
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    Quadrum quadrum2 = (Quadrum)i;
                    stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(location.y).LabelCap());
                }
                return("DateReadoutTip".Translate(GenDate.DaysPassed, 15, season.LabelCap(), 15, GenDate.Quadrum(GenTicks.TicksAbs, location.x).Label(), stringBuilder.ToString()));
            }, 86423));
        }
Example #6
0
 public static Season Season(long absTicks, Vector2 longLat)
 {
     return(GenDate.Season(absTicks, longLat.y, longLat.x));
 }
Example #7
0
 public static Season Season(int tile)
 {
     return(GenDate.Season(GenLocalDate.TicksAbs, Find.WorldGrid.LongLatOf(tile)));
 }
Example #8
0
 public static Season Season(Thing thing)
 {
     return(GenDate.Season(GenLocalDate.TicksAbs, GenLocalDate.LocationForDate(thing)));
 }
Example #9
0
        public static void DateOnGUI(Rect dateRect)
        {
            Vector2 vector;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                vector = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                vector = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.CurrentMap == null)
                {
                    return;
                }
                vector = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
            }
            int     index   = GenDate.HourInteger(Find.TickManager.TicksAbs, vector.x);
            int     num     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, vector.x);
            Season  season  = GenDate.Season(Find.TickManager.TicksAbs, vector);
            Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, vector.x);
            int     num2    = GenDate.Year(Find.TickManager.TicksAbs, vector.x);
            string  text    = (SeasonLabelVisible ? seasonsCached[(int)season] : "");

            if (num != dateStringDay || season != dateStringSeason || quadrum != dateStringQuadrum || num2 != dateStringYear)
            {
                dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector);
                dateStringDay     = num;
                dateStringSeason  = season;
                dateStringQuadrum = quadrum;
                dateStringYear    = num2;
            }
            Text.Font = GameFont.Small;
            float num3 = Mathf.Max(Mathf.Max(Text.CalcSize(fastHourStrings[index]).x, Text.CalcSize(dateString).x), Text.CalcSize(text).x) + 7f;

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, fastHourStrings[index]);
            rect.yMin += 26f;
            Widgets.Label(rect, dateString);
            rect.yMin += 26f;
            if (!text.NullOrEmpty())
            {
                Widgets.Label(rect, text);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            if (Mouse.IsOver(dateRect))
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    Quadrum quadrum2 = (Quadrum)i;
                    stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(vector.y).LabelCap());
                }
                TaggedString taggedString = "DateReadoutTip".Translate(GenDate.DaysPassed, 15, season.LabelCap(), 15, GenDate.Quadrum(GenTicks.TicksAbs, vector.x).Label(), stringBuilder.ToString());
                TooltipHandler.TipRegion(dateRect, new TipSignal(taggedString, 86423));
            }
        }