private void UpdateRelativeFieldsFromTicks(int ticksToUse) { var diff = GenDate.TickGameToAbs(ticksToUse) - Find.TickManager.TicksAbs; int years = 0, quadrums = 0, days = 0; var hours = 8f; if (diff > 0) { GenDate.TicksToPeriod(diff, out years, out quadrums, out days, out hours); } hoursFromNowValue = Mathf.CeilToInt(hours); daysFromNowValue = days + quadrums * GenDate.DaysPerQuadrum + years * GenDate.DaysPerYear; var remainder = hoursFromNowValue == 24; if (remainder) { hoursFromNowValue = 0; daysFromNowValue += 1; } hoursFromNowBuffer = hoursFromNowValue.ToString(); daysFromNowBuffer = daysFromNowValue.ToString(); Log.Debug($"Set to {hoursFromNowValue} ({hoursFromNowBuffer}) on day {daysFromNowValue} ({daysFromNowBuffer})"); }
private void UpdateAbsoluteFieldsFromTicks(int ticksToUse) { var tileCoords = RemindersGameComponent.VectorForTime; if (!tileCoords.HasValue) { return; } var absTicks = GenDate.TickGameToAbs(ticksToUse); var coords = tileCoords.Value; yearValue = GenDate.Year(absTicks, coords.x); yearBuffer = yearValue.ToString(); quadrumValue = GenDate.Quadrum(absTicks, coords.x); dayValue = GenDate.DayOfQuadrum(absTicks, coords.x) + 1; dayBuffer = dayValue.ToString(); hourValue = GenDate.HourOfDay(absTicks, coords.x); hourBuffer = hourValue.ToString(); Log.Debug($"Set defaults to {dayBuffer} {quadrumValue}, {yearBuffer} at {hourBuffer}."); Log.Debug($"Should have set to {GenDate.DateFullStringWithHourAt(absTicks, coords)}."); }
private static string DateString(int ticks) { if (!VectorForTime.HasValue) { return("1st of January, 1970, 0h"); } // Kappa return(GenDate.DateFullStringWithHourAt(GenDate.TickGameToAbs(ticks), VectorForTime.GetValueOrDefault())); }
public static void PlanFuneral(Building_Grave __instance, Pawn worker) { Pawn planner; (from c in worker.Map.mapPawns.FreeColonistsSpawned where c.relations.OpinionOf(__instance.Corpse.InnerPawn) >= 20 select c).TryRandomElementByWeight((c) => Mathf.Max(0f, c.relations.OpinionOf(__instance.Corpse.InnerPawn) - (PsycheHelper.PsychologyEnabled(c) ? 100f * (1f - PsycheHelper.Comp(c).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Nostalgic)) : 0f)), out planner); if (planner != null && PsycheHelper.PsychologyEnabled(__instance.Corpse.InnerPawn) && !PsycheHelper.Comp(__instance.Corpse.InnerPawn).AlreadyBuried) { Func <int, float> timeAssignmentFactor = delegate(int h) { if (planner.timetable.GetAssignment(h) == TimeAssignmentDefOf.Joy) { return(1.25f); } if (planner.timetable.GetAssignment(h) == TimeAssignmentDefOf.Anything) { return(0.9f); } return(0f); }; int hour = -1; if (Enumerable.Range(0, GenDate.HoursPerDay).TryRandomElementByWeight(h => timeAssignmentFactor(h), out hour)) { int date = Find.TickManager.TicksGame + Mathf.RoundToInt(GenDate.TicksPerDay * (2f + (PsycheHelper.PsychologyEnabled(planner) ? 3f - (5f * PsycheHelper.Comp(planner).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous)) : 0f))); int currentDay = GenDate.DayOfYear(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x); if (currentDay <= GenLocalDate.DayOfYear(planner.Map) && GenDate.HourOfDay(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x) > hour) { date += GenDate.TicksPerDay * (currentDay - GenLocalDate.DayOfYear(planner.Map)); } Hediff_Funeral planFuneral = HediffMaker.MakeHediff(HediffDefOfPsychology.PlannedFuneral, planner) as Hediff_Funeral; planFuneral.date = date; planFuneral.hour = hour; planFuneral.day = GenDate.DayOfYear(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(planner.Map.Tile).x); planFuneral.grave = __instance; planFuneral.spot = __instance.Position; planner.health.AddHediff(planFuneral); PsycheHelper.Comp(__instance.Corpse.InnerPawn).AlreadyBuried = true; } } }
private void DoArchivableRow(Rect rect, IArchivable archivable, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Widgets.DrawHighlightIfMouseover(rect); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Rect rect2 = rect; Rect rect3 = rect2; rect3.width = 30f; rect2.xMin += 40f; float num = Find.Archive.IsPinned(archivable) ? 1f : ((!Mouse.IsOver(rect3)) ? 0f : 0.25f); if (num > 0f) { GUI.color = new Color(1f, 1f, 1f, num); GUI.DrawTexture(new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded(), PinTex); GUI.color = Color.white; } Rect rect4 = rect2; Rect outerRect = rect2; outerRect.width = 30f; rect2.xMin += 40f; Texture archivedIcon = archivable.ArchivedIcon; if (archivedIcon != null) { GUI.color = archivable.ArchivedIconColor; Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f); GUI.color = Color.white; } Rect rect5 = rect2; rect5.width = 200f; rect2.xMin += 210f; Vector2 location = (Find.CurrentMap == null) ? default(Vector2) : Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile); GUI.color = new Color(0.75f, 0.75f, 0.75f); int num2 = GenDate.TickGameToAbs(archivable.CreatedTicksGame); string str = GenDate.DateFullStringAt(num2, location) + ", " + GenDate.HourInteger(num2, location.x) + "LetterHour".Translate(); Widgets.Label(rect5, str.Truncate(rect5.width)); GUI.color = Color.white; Rect rect6 = rect2; Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width)); GenUI.ResetLabelAlign(); Text.WordWrap = true; TooltipHandler.TipRegion(rect3, "PinArchivableTip".Translate(200)); if (Mouse.IsOver(rect4)) { TooltipHandler.TipRegion(rect4, archivable.ArchivedTooltip); } if (Widgets.ButtonInvisible(rect3)) { if (Find.Archive.IsPinned(archivable)) { Find.Archive.Unpin(archivable); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } else { Find.Archive.Pin(archivable); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } } if (Widgets.ButtonInvisible(rect4)) { if (Event.current.button == 1) { LookTargets lookTargets = archivable.LookTargets; if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget())) { CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget()); Find.MainTabsRoot.EscapeCurrentTab(); } } else { archivable.OpenArchived(); } } }
public override void Tick() { Pawn dead = null; base.Tick(); if (dead == null) { Corpse corpse = (grave as Building_Grave).Corpse; if (corpse != null && corpse.InnerPawn != null) { dead = corpse.InnerPawn; } else { Log.Warning("[Psychology] A funeral was planned for someone, but they're gone now."); pawn.health.RemoveHediff(this); } } if (!announced && ageTicks > GenDate.TicksPerHour) { Find.LetterStack.ReceiveLetter("LetterLabelFuneralPlanned".Translate(dead), "LetterFuneralPlanned".Translate(pawn, dead, GenDate.QuadrumDateStringAt(GenDate.TickGameToAbs(date), Find.WorldGrid.LongLatOf(pawn.Map.Tile).x), hour), LetterDefOf.PositiveEvent, pawn); announced = true; } if (GenLocalDate.DayOfYear(pawn.Map) >= day && GenLocalDate.HourOfDay(pawn.Map) == hour) { Find.LetterStack.ReceiveLetter("LetterLabelFuneralStarted".Translate(dead), "LetterFuneralStarted".Translate(dead), LetterDefOf.PositiveEvent, grave); LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Funeral(spot, grave as Building_Grave), pawn.Map, null); pawn.health.RemoveHediff(this); } }
public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { PsychologyPawn realRecipient = recipient as PsychologyPawn; PsychologyPawn realInitiator = initiator as PsychologyPawn; //Choose a time that works with their schedule, based on their personality Dictionary <int, float> possibleHours = new Dictionary <int, float>(); for (int i = 0; i < GenDate.HoursPerDay; i++) { possibleHours.Add(i, 0f); } foreach (PersonalityNodeDef d in DefDatabase <PersonalityNodeDef> .AllDefsListForReading) { if (d.preferredDateHours != null) { foreach (int h in d.preferredDateHours) { possibleHours[h] += (Mathf.Pow(Mathf.Abs(0.5f - realInitiator.psyche.GetPersonalityRating(d)), 2) / (1.3f - realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) + Mathf.Pow(Mathf.Abs(0.5f - realRecipient.psyche.GetPersonalityRating(d)), 2) / (1.3f - realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) / 2f); } } } int hour = possibleHours.Keys.RandomElementByWeight(h => possibleHours[h] * RendezvousUtility.TimeAssignmentFactor(initiator, h) * RendezvousUtility.TimeAssignmentFactor(recipient, h)); //More Spontaneous couples will plan their dates sooner; possibly even immediately! int day = Find.TickManager.TicksGame + Mathf.RoundToInt(GenDate.TicksPerDay * 5 * (((1f - realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous)) + (1f - realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Spontaneous))) / 2f)); Hediff_PlannedDate plannedDate = HediffMaker.MakeHediff(HediffDefOfPsychology.PlannedDate, initiator) as Hediff_PlannedDate; plannedDate.partner = recipient; plannedDate.day = day; plannedDate.hour = hour; initiator.health.AddHediff(plannedDate); realInitiator.psyche.lastDateTick = day; realRecipient.psyche.lastDateTick = day; if (Prefs.DevMode && Prefs.LogVerbose) { Log.Message(initiator.LabelShort + " planned date with " + recipient.LabelShort + " for hour " + hour + " on date " + GenDate.DateFullStringAt(GenDate.TickGameToAbs(day), Find.WorldGrid.LongLatOf(initiator.Map.Tile))); } }
private string GetDateTimeString(DataPoint point, Vector2 latLong) { return(GenDate.DateFullStringWithHourAt(GenDate.TickGameToAbs(point.TimeStampGameTicks), latLong)); }