private static string CustomMoodNeedTooltip(Need_Mood mood) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(mood.GetTipString()); PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(mood, thoughtGroupsPresent); bool flag = false; for (int i = 0; i < thoughtGroupsPresent.Count; i++) { Thought group = thoughtGroupsPresent[i]; mood.thoughts.GetMoodThoughts(group, thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup); if (leadingThoughtInGroup.VisibleInNeedsTab) { if (!flag) { flag = true; stringBuilder.AppendLine(); } stringBuilder.Append(leadingThoughtInGroup.LabelCap); if (thoughtGroup.Count > 1) { stringBuilder.Append(" x"); stringBuilder.Append(thoughtGroup.Count); } stringBuilder.Append(": "); stringBuilder.AppendLine(mood.thoughts.MoodOffsetOfGroup(group).ToString("##0")); } } return(stringBuilder.ToString()); }
protected void DrawMood(Rect rect, Pawn pawn, Need_Mood mood) { this.threshPercentsForMood.Clear(); this.threshPercentsForMood.Add(pawn.mindState.breaker.HardBreakThreshold); this.threshPercentsForMood.Add(pawn.mindState.breaker.SoftBreakThreshold); this.DrawNeed(rect, mood, this.threshPercentsForMood); }
public static void RemoveMySpouseMarriageRelatedThoughts(Pawn_RelationsTracker __instance) { #if RW12 Pawn spouse = __instance.pawn.GetSpouse(); if (spouse == null || spouse.Dead || spouse.needs.mood == null) { return; } MemoryThoughtHandler memories = spouse.needs.mood.thoughts.memories; memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried); memories.RemoveMemoriesOfDef(ThoughtDefOf.HoneymoonPhase); #endif #if RW13 foreach (Pawn spouse in __instance.pawn.GetSpouses(includeDead: false)) { if (spouse == null || spouse.Dead) { continue; } Need_Mood mood = spouse.needs.mood; if (mood == null) { continue; } if (mood != null) { MemoryThoughtHandler memories = mood.thoughts.memories; memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried); memories.RemoveMemoriesOfDef(ThoughtDefOf.HoneymoonPhase); } } #endif }
private static void DoRow(Rect rect, Pawn pawn, ref Pawn specificNeedsTabForPawn) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, pawn); rect2.width -= 24f; if (!pawn.Dead) { OpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn); rect2.width -= 24f; } Widgets.DrawHighlightIfMouseover(rect2); Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect3, pawn, 1f); Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false); tmpNeeds.Clear(); List <Need> allNeeds = pawn.needs.AllNeeds; foreach (Need n in allNeeds) { if (n.def.showForCaravanMembers) // Change for all needs? { tmpNeeds.Add(n); } } PawnNeedsUIUtility.SortInDisplayOrder(tmpNeeds); float xMax = bgRect.xMax; foreach (Need need in tmpNeeds) { int maxThresholdMarkers = 0; bool doTooltip = true; Rect rect4 = new Rect(xMax, 0f, 100f, 50f); Need_Mood mood = need as Need_Mood; if (mood != null) { maxThresholdMarkers = 1; doTooltip = false; //TooltipHandler.TipRegion(rect4, new TipSignal(() => CaravanNeedsTabUtility.CustomMoodNeed)) //Add better way to make stringbuilder } need.DrawOnGUI(rect4, maxThresholdMarkers, 10f, false, doTooltip); xMax = rect4.xMax; } if (pawn.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } GUI.EndGroup(); }
private static void DoRow(Rect rect, Pawn pawn, Caravan caravan, ref Pawn specificNeedsTabForPawn, bool doNeeds) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); CaravanThingsTabUtility.DoAbandonButton(rect2, pawn, caravan); rect2.width -= 24f; Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, pawn); rect2.width -= 24f; if (!pawn.Dead) { CaravanThingsTabUtility.DoOpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn); rect2.width -= 24f; } Widgets.DrawHighlightIfMouseover(rect2); Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect3, pawn); Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, alwaysDrawBg: false, alignCenter: false); if (doNeeds) { GetNeedsToDisplay(pawn, tmpNeeds); float xMax = bgRect.xMax; for (int i = 0; i < tmpNeeds.Count; i++) { Need need = tmpNeeds[i]; int maxThresholdMarkers = 0; bool doTooltip = true; Rect rect4 = new Rect(xMax, 0f, 100f, 50f); Need_Mood mood = need as Need_Mood; if (mood != null) { maxThresholdMarkers = 1; doTooltip = false; if (Mouse.IsOver(rect4)) { TooltipHandler.TipRegion(rect4, new TipSignal(() => CustomMoodNeedTooltip(mood), rect4.GetHashCode())); } } need.DrawOnGUI(rect4, maxThresholdMarkers, 10f, drawArrows: false, doTooltip); xMax = rect4.xMax; } } if (pawn.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } GUI.EndGroup(); }
static void Postfix(Need_Mood __instance) { if (!Settings.mood_regen) { return; } Pawn pawn = (Pawn)LPawn.GetValue(__instance); if ((bool)LIsFrozen.GetValue(__instance) && !pawn.Suspended && pawn.health.capacities.CanBeAwake) { float curInstantLevel = __instance.CurInstantLevel; if (curInstantLevel > __instance.CurLevel && __instance.CurLevel < 0.5f) { __instance.CurLevel = Mathf.Min(__instance.CurLevel + __instance.def.seekerRisePerHour * 0.01f, curInstantLevel); } else if (curInstantLevel < __instance.CurLevel && __instance.CurLevel > 0.5f) { __instance.CurLevel = Mathf.Max(__instance.CurLevel - __instance.def.seekerFallPerHour * 0.01f, curInstantLevel); } } }
private static void DoRow(Rect rect, Thing thing, CompVehicle vehicle, ref Pawn specificNeedsTabForPawn, bool doNeeds) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); Pawn pawn = thing as Pawn; //if (listingUsesAbandonSpecificCountButtons) //{ // if (thing.stackCount != 1) // { // CaravanPeopleAndItemsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan); // } // rect2.width -= 24f; //} //CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, thing, caravan); rect2.width -= 24f; Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, thing); rect2.width -= 24f; if (pawn != null && !pawn.Dead) { CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn); rect2.width -= 24f; } if (pawn == null) { Rect rect3 = rect2; rect3.xMin = rect3.xMax - 60f; CaravanPeopleAndItemsTabUtility.TryDrawMass(thing, rect3); rect2.width -= 60f; } if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Rect rect4 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect4, thing, 1f); if (pawn != null) { Rect bgRect = new Rect(rect4.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false); if (doNeeds) { GetNeedsToDisplay(pawn, tmpNeeds); float xMax = bgRect.xMax; for (int i = 0; i < tmpNeeds.Count; i++) { Need need = tmpNeeds[i]; int maxThresholdMarkers = 0; bool doTooltip = true; Rect rect5 = new Rect(xMax, 0f, 100f, 50f); #pragma warning disable IDE0019 // Use pattern matching Need_Mood mood = need as Need_Mood; #pragma warning restore IDE0019 // Use pattern matching if (mood != null) { maxThresholdMarkers = 1; doTooltip = false; //TooltipHandler.TipRegion(rect5, new TipSignal(() => CaravanPeopleAndItemsTabUtility.CustomMoodNeedTooltip(mood), rect5.GetHashCode())); } need.DrawOnGUI(rect5, maxThresholdMarkers, 10f, false, doTooltip); xMax = rect5.xMax; } } if (pawn.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } } else { Rect rect6 = new Rect(rect4.xMax + 4f, 0f, 300f, 30f); Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Widgets.Label(rect6, thing.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; } GUI.EndGroup(); }
private static void DrawNewMoodRect(Rect moodRect, Need_Mood mood, MentalBreaker mb) { if (mood != null && mb != null) { if (mood.CurLevelPercentage > mb.BreakThresholdMinor) { if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right) { GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodTex); } else { GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodTex); } } else if (mood.CurLevelPercentage > mb.BreakThresholdMajor) { if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right) { GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMinorCrossedTex); } else { GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMinorCrossedTex); } } else if (mood.CurLevelPercentage > mb.BreakThresholdExtreme) { if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right) { GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMajorCrossedTex); } else { GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodMajorCrossedTex); } } else { GUI.DrawTexture(moodRect, ColonistBarTextures.MoodExtremeCrossedBGTex); if (ColBarSettings.MoodBarPos == Position.Alignment.Left || ColBarSettings.MoodBarPos == Position.Alignment.Right) { GUI.DrawTexture(moodRect.BottomPart(mood.CurLevelPercentage), ColonistBarTextures.MoodExtremeCrossedTex); } else { GUI.DrawTexture(moodRect.LeftPart(mood.CurLevelPercentage), ColonistBarTextures.MoodExtremeCrossedTex); } } DrawMentalThreshold(moodRect, mb.BreakThresholdExtreme, mood.CurLevelPercentage); DrawMentalThreshold(moodRect, mb.BreakThresholdMajor, mood.CurLevelPercentage); DrawMentalThreshold(moodRect, mb.BreakThresholdMinor, mood.CurLevelPercentage); switch (ColBarSettings.MoodBarPos) { case Position.Alignment.Left: case Position.Alignment.Right: GUI.DrawTexture( new Rect(moodRect.x, moodRect.yMax - moodRect.height * mood.CurInstantLevelPercentage, moodRect.width, 1), ColonistBarTextures.MoodTargetTex); GUI.DrawTexture( new Rect(moodRect.xMax + 1, moodRect.yMax - moodRect.height * mood.CurInstantLevelPercentage - 1, 2, 3), ColonistBarTextures.MoodTargetTex); break; case Position.Alignment.Top: GUI.DrawTexture( new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage, moodRect.y, 1, moodRect.height), ColonistBarTextures.MoodTargetTex); GUI.DrawTexture( new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage - 1, moodRect.yMin - 1, 3, 2), ColonistBarTextures.MoodTargetTex); break; case Position.Alignment.Bottom: GUI.DrawTexture( new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage, moodRect.y, 1, moodRect.height), ColonistBarTextures.MoodTargetTex); GUI.DrawTexture( new Rect(moodRect.x + moodRect.width * mood.CurInstantLevelPercentage - 1, moodRect.yMax + 1, 3, 2), ColonistBarTextures.MoodTargetTex); break; } } }