private static void DrawThoughtListing(Rect listingRect, Pawn pawn, ref Vector2 thoughtScrollPosition) { if (Event.current.type == EventType.Layout) { return; } Text.Font = GameFont.Small; PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(pawn.needs.mood, NeedsCardUtility.thoughtGroupsPresent); float height = (float)NeedsCardUtility.thoughtGroupsPresent.Count * 24f; Widgets.BeginScrollView(listingRect, ref thoughtScrollPosition, new Rect(0f, 0f, listingRect.width - 16f, height), true); Text.Anchor = TextAnchor.MiddleLeft; float num = 0f; for (int i = 0; i < NeedsCardUtility.thoughtGroupsPresent.Count; i++) { Rect rect = new Rect(0f, num, listingRect.width - 16f, 20f); if (NeedsCardUtility.DrawThoughtGroup(rect, NeedsCardUtility.thoughtGroupsPresent[i], pawn)) { num += 24f; } } Widgets.EndScrollView(); Text.Anchor = TextAnchor.UpperLeft; }
private static void UpdateDisplayNeeds(Pawn pawn) { NeedsCardUtility.displayNeeds.Clear(); List <Need> allNeeds = pawn.needs.AllNeeds; for (int i = 0; i < allNeeds.Count; i++) { if (allNeeds[i].ShowOnNeedList) { NeedsCardUtility.displayNeeds.Add(allNeeds[i]); } } PawnNeedsUIUtility.SortInDisplayOrder(NeedsCardUtility.displayNeeds); }
private static bool DrawThoughtGroup(Rect rect, Thought group, Pawn pawn) { try { pawn.needs.mood.thoughts.GetMoodThoughts(group, NeedsCardUtility.thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(NeedsCardUtility.thoughtGroup); if (!leadingThoughtInGroup.VisibleInNeedsTab) { NeedsCardUtility.thoughtGroup.Clear(); return(false); } if (leadingThoughtInGroup != NeedsCardUtility.thoughtGroup[0]) { NeedsCardUtility.thoughtGroup.Remove(leadingThoughtInGroup); NeedsCardUtility.thoughtGroup.Insert(0, leadingThoughtInGroup); } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(leadingThoughtInGroup.Description); if (group.def.DurationTicks > 5) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); Thought_Memory thought_Memory = leadingThoughtInGroup as Thought_Memory; if (thought_Memory != null) { if (NeedsCardUtility.thoughtGroup.Count == 1) { stringBuilder.Append("ThoughtExpiresIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod())); } else { Thought_Memory thought_Memory2 = (Thought_Memory)NeedsCardUtility.thoughtGroup[NeedsCardUtility.thoughtGroup.Count - 1]; stringBuilder.Append("ThoughtStartsExpiringIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod())); stringBuilder.AppendLine(); stringBuilder.Append("ThoughtFinishesExpiringIn".Translate((group.def.DurationTicks - thought_Memory2.age).ToStringTicksToPeriod())); } } } if (NeedsCardUtility.thoughtGroup.Count > 1) { bool flag = false; for (int i = 1; i < NeedsCardUtility.thoughtGroup.Count; i++) { bool flag2 = false; for (int j = 0; j < i; j++) { if (NeedsCardUtility.thoughtGroup[i].LabelCap == NeedsCardUtility.thoughtGroup[j].LabelCap) { flag2 = true; break; } } if (!flag2) { if (!flag) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); flag = true; } stringBuilder.AppendLine("+ " + NeedsCardUtility.thoughtGroup[i].LabelCap); } } } TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), 7291)); Text.WordWrap = false; Text.Anchor = TextAnchor.MiddleLeft; Rect rect2 = new Rect(rect.x + 10f, rect.y, 225f, rect.height); rect2.yMin -= 3f; rect2.yMax += 3f; string text = leadingThoughtInGroup.LabelCap; if (NeedsCardUtility.thoughtGroup.Count > 1) { text = text + " x" + NeedsCardUtility.thoughtGroup.Count; } Widgets.Label(rect2, text); Text.Anchor = TextAnchor.MiddleCenter; float num = pawn.needs.mood.thoughts.MoodOffsetOfGroup(group); if (num == 0f) { GUI.color = NeedsCardUtility.NoEffectColor; } else if (num > 0f) { GUI.color = NeedsCardUtility.MoodColor; } else { GUI.color = NeedsCardUtility.MoodColorNegative; } Rect rect3 = new Rect(rect.x + 235f, rect.y, 32f, rect.height); Widgets.Label(rect3, num.ToString("##0")); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; Text.WordWrap = true; } catch (Exception ex) { Log.ErrorOnce(string.Concat(new object[] { "Exception in DrawThoughtGroup for ", group.def, " on ", pawn, ": ", ex.ToString() }), 3452698, false); } return(true); }
private static bool DrawThoughtGroup(Rect rect, Thought group, Pawn pawn) { try { pawn.needs.mood.thoughts.GetMoodThoughts(group, thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup); if (!leadingThoughtInGroup.VisibleInNeedsTab) { thoughtGroup.Clear(); return(false); } if (leadingThoughtInGroup != thoughtGroup[0]) { thoughtGroup.Remove(leadingThoughtInGroup); thoughtGroup.Insert(0, leadingThoughtInGroup); } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } if (Mouse.IsOver(rect)) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(leadingThoughtInGroup.Description); if (group.def.DurationTicks > 5) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); Thought_Memory thought_Memory = leadingThoughtInGroup as Thought_Memory; if (thought_Memory != null) { if (thoughtGroup.Count == 1) { stringBuilder.Append("ThoughtExpiresIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod())); } else { int num = int.MaxValue; int num2 = int.MinValue; foreach (Thought_Memory item in thoughtGroup) { num = Mathf.Min(num, item.age); num2 = Mathf.Max(num2, item.age); } stringBuilder.Append("ThoughtStartsExpiringIn".Translate((group.def.DurationTicks - num2).ToStringTicksToPeriod())); stringBuilder.AppendLine(); stringBuilder.Append("ThoughtFinishesExpiringIn".Translate((group.def.DurationTicks - num).ToStringTicksToPeriod())); } } } if (thoughtGroup.Count > 1) { bool flag = false; for (int i = 1; i < thoughtGroup.Count; i++) { bool flag2 = false; for (int j = 0; j < i; j++) { if (thoughtGroup[i].LabelCap == thoughtGroup[j].LabelCap) { flag2 = true; break; } } if (!flag2) { if (!flag) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); flag = true; } stringBuilder.AppendLine("+ " + thoughtGroup[i].LabelCap); } } } TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), 7291)); } Text.WordWrap = false; Text.Anchor = TextAnchor.MiddleLeft; Rect rect2 = new Rect(rect.x + 10f, rect.y, 225f, rect.height); rect2.yMin -= 3f; rect2.yMax += 3f; string text = leadingThoughtInGroup.LabelCap; if (thoughtGroup.Count > 1) { text = text + " x" + thoughtGroup.Count; } Widgets.Label(rect2, text); Text.Anchor = TextAnchor.MiddleCenter; float num3 = pawn.needs.mood.thoughts.MoodOffsetOfGroup(group); if (num3 == 0f) { GUI.color = NoEffectColor; } else if (num3 > 0f) { GUI.color = MoodColor; } else { GUI.color = MoodColorNegative; } Widgets.Label(new Rect(rect.x + 235f, rect.y, 32f, rect.height), num3.ToString("##0")); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; Text.WordWrap = true; } catch (Exception ex) { Log.ErrorOnce("Exception in DrawThoughtGroup for " + group.def + " on " + pawn + ": " + ex.ToString(), 3452698); } return(true); }