public static bool Prefix(ColonistBarColonistDrawer __instance, ref Rect rect, ref Pawn colonist, ref Map pawnMap, ref bool highlight, ref bool reordering) { ColonistBar colonistBar = Find.ColonistBar; float entryRectAlpha = colonistBar.GetEntryRectAlpha(rect); entryRectAlpha = ApplyEntryInAnotherMapAlphaFactor(pawnMap, entryRectAlpha); if (reordering) { entryRectAlpha *= 0.5f; } Color color = new Color(1f, 1f, 1f, entryRectAlpha); GUI.color = color; GUI.DrawTexture(rect, ColonistBar.BGTex); if (colonist.needs != null && colonist.needs.mood != null) { Rect position = rect.ContractedBy(2f); float num = position.height * colonist.needs.mood.CurLevelPercentage; position.yMin = position.yMax - num; position.height = num; Texture2D moodTexture = getMoodTexture(ref colonist); GUI.DrawTexture(position, moodTexture); } if (highlight) { int thickness = (rect.width > 22f) ? 3 : 2; GUI.color = Color.white; Widgets.DrawBox(rect, thickness); GUI.color = color; } Rect rect2 = rect.ContractedBy(-2f * colonistBar.Scale); bool isColonistSelected = colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist); if (isColonistSelected && !WorldRendererUtility.WorldRenderedNow) { Main.drawSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist, rect2 }); } else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan())) { Main.drawCaravanSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist.GetCaravan(), rect2 }); } Rect pawnTexturePosition = __instance.GetPawnTextureRect(new Vector2(rect.x, rect.y)); GUI.DrawTexture(pawnTexturePosition, PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f)); GUI.color = new Color(1f, 1f, 1f, entryRectAlpha * 0.8f); Main.drawIconsMethod.Invoke(__instance, new object[] { rect, colonist }); GUI.color = color; if (colonist.Dead) { GUI.DrawTexture(rect, (Texture)Main.deadColonistTexField.GetValue(null)); } float num2 = 4f * colonistBar.Scale; Vector2 pos = new Vector2(rect.center.x, rect.yMax - num2); GenMapUI.DrawPawnLabel(colonist, pos, entryRectAlpha, rect.width + colonistBar.SpaceBetweenColonistsHorizontal - 2f, (Dictionary <string, string>)Main.pawnLabelsCacheField.GetValue(__instance), GameFont.Tiny, true, true); Text.Font = GameFont.Small; GUI.color = Color.white; return(false); }
public static bool Prefix(ColonistBarColonistDrawer __instance, ref Rect rect, ref Pawn colonist, ref Map pawnMap, ref bool highlight, ref bool reordering) { ColonistBar colonistBar = Find.ColonistBar; float alpha = ApplyEntryInAnotherMapAlphaFactor(pawnMap, colonistBar.GetEntryRectAlpha(rect)); Rect pawnBackgroundSize = rect.ExpandedBy(2.5f); if (reordering) { alpha *= 0.5f; } Color color = new Color(1f, 1f, 1f, alpha); GUI.color = color; GUI.DrawTexture(rect, ColonistBar.BGTex); if (colonist.needs != null && colonist.needs.mood != null) { Rect position = pawnBackgroundSize.ContractedBy(2f); float value = position.height * colonist.needs.mood.CurLevelPercentage; position.yMin = position.yMax - value; position.height = value; float statValue = colonist.GetStatValue(StatDefOf.MentalBreakThreshold, true); float currentMoodLevel = colonist.needs.mood.CurLevel; // Extreme break threshold if (currentMoodLevel <= statValue) { GUI.DrawTexture(position, Main.extremeBreakTex); } // Major break threshold else if (currentMoodLevel <= statValue + 0.15f) { GUI.DrawTexture(position, Main.majorBreakTex); } // Minor break threshold else if (currentMoodLevel <= statValue + 0.3f) { GUI.DrawTexture(position, Main.minorBreakTex); } // Neutral else if (currentMoodLevel <= 0.65f) { GUI.DrawTexture(position, Main.neutralTex); } // Content else if (currentMoodLevel <= 0.9f) { GUI.DrawTexture(position, Main.contentTex); } // Happy else { GUI.DrawTexture(position, Main.happyTex); } } if (highlight) { int thickness = (rect.width > 22f) ? 3 : 2; GUI.color = Color.white; Widgets.DrawBox(rect, thickness); GUI.color = color; } Rect rect2 = rect.ContractedBy(-2f * colonistBar.Scale); bool notdeadandselected = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse); if (notdeadandselected && !WorldRendererUtility.WorldRenderedNow) { Main.drawSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist, rect2 }); } else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan())) { Main.drawCaravanSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist.GetCaravan(), rect2 }); } GUI.DrawTexture(__instance.GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f)); GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f); Main.drawIconsMethod.Invoke(__instance, new object[] { rect, colonist }); GUI.color = color; if (colonist.Dead) { GUI.DrawTexture(rect, (Texture)Main.deadColonistTexField.GetValue(__instance)); } float num3 = 4f * colonistBar.Scale; Vector2 pos = new Vector2(rect.center.x, rect.yMax - num3); GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + colonistBar.SpaceBetweenColonistsHorizontal - 2f, (Dictionary <string, string>)Main.pawnLabelsCacheField.GetValue(__instance), GameFont.Tiny, true, true); Text.Font = GameFont.Small; GUI.color = Color.white; return(false); }