Exemplo n.º 1
0
 public static void MapInterfaceOnGUI_AfterMainTabs_PostFix()
 {
     if (Find.CurrentMap == null)
     {
         return;
     }
     if (!WorldRendererUtility.WorldRenderedNow && !Find.UIRoot.screenshotMode.FiltersCurrentEvent)
     {
         TraitRarityOverlayDrawer.TraitRarityStatsOnGUI();
     }
 }
        public static void TraitRarityStatsOnGUI()
        {
            if (Event.current.type != EventType.Repaint || !TraitRarityOverlayDrawer.ShouldShowWindowNow())
            {
                return;
            }
            CellRect currentViewRect = Find.CameraDriver.CurrentViewRect;

            foreach (Pawn pawn in Find.CurrentMap.mapPawns.AllPawnsSpawned)
            {
                if (pawn.RaceProps.Humanlike && currentViewRect.Contains(pawn.Position) && !pawn.Position.Fogged(Find.CurrentMap))
                {
                    TraitRarityOverlayDrawer.DrawInfowWindow(pawn);
                }
            }
        }
        public static void DrawInfowWindow(Pawn pawn)
        {
            string text           = pawn.LabelCap + ": " + string.Join(", ", pawn.story.traits.allTraits.Select(t => t.CurrentData.label.CapitalizeFirst()));
            float  cellSizePixels = Find.CameraDriver.CellSizePixels;

            Text.Font = GameFont.Small;
            Vector2 vector     = new Vector2(cellSizePixels, cellSizePixels);
            Vector2 vectorText = Text.CalcSize(text);
            Rect    rect       = new Rect(0f, 0f, vectorText.x + 36f, Text.CalcHeight(text, vectorText.x) + 18f);
            Vector2 vector2    = pawn.DrawPos.MapToUIPosition();

            rect.x = vector2.x - vector.x / 2f;
            rect.y = vector2.y + vector.x / 2f;

            Find.WindowStack.ImmediateWindow(1751884355 + pawn.thingIDNumber, rect, WindowLayer.GameUI, delegate
            {
                TraitRarityOverlayDrawer.FillWindow(rect, text);
            }, true, false, 1f);
        }