protected override ThoughtState CurrentStateInternal(Pawn p) { Need_LeaderLevel need = (Need_LeaderLevel)p.needs.TryGetNeed(DefDatabase <NeedDef> .GetNamed("LeaderLevel")); if (need == null) { return(ThoughtState.Inactive); } else { if (need.opinion <= -50) { return(ThoughtState.ActiveAtStage(1)); } else if (need.opinion <= -10) { return(ThoughtState.ActiveAtStage(0)); } } return(ThoughtState.Inactive); }
private float DrawLeaderRow(Pawn leader, float rowY, Rect fillRect) { Rect rect = new Rect(40f, rowY, 300f, 80f); Need_LeaderLevel need = (Need_LeaderLevel)leader.needs.AllNeeds.Find((Need x) => x.def == DefDatabase <NeedDef> .GetNamed("LeaderLevel")); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(""); string text = stringBuilder.ToString(); float width = fillRect.width - rect.xMax; float num = Text.CalcHeight(text, width); float num2 = Mathf.Max(80f, num); Rect position = new Rect(8f, rowY + 12f, 30f, 30f); Rect rect2 = new Rect(0f, rowY, fillRect.width, num2); if (Mouse.IsOver(rect2)) { StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.AppendLine("AverageOpinionAbout".Translate() + need.opinion); if (need.opinion < -60 && !Utility.isDictatorship) { stringBuilder2.AppendLine("UnpopularLeader".Translate()); } else if (need.opinion < -20) { stringBuilder2.AppendLine("UnlikedLeader".Translate()); } TooltipHandler.TipRegion(rect2, stringBuilder2.ToString()); GUI.DrawTexture(rect2, TexUI.HighlightTex); if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { CameraJumper.TryJumpAndSelect(leader); } } } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; Widgets.ThingIcon(position, leader, 1f); //Widgets.DrawRectFast(position, Color.white, null); string label = string.Concat(new string[] { leader.Name.ToStringFull, "\n", " ", leaderType(leader), "\n" }); if (need.opinion < -20) { GUI.color = Color.yellow; } if (need.opinion < -60) { GUI.color = Color.red; } Widgets.Label(rect, label); GUI.color = Color.white; return(num2); }