コード例 #1
0
 /// <summary>
 /// Show label names on hostile animals. Credits: mehni. 4misc mods
 /// </summary>
 /// <param name="___pawn"></param>
 public static void DrawPawnGUIOverlay_Postfix(Pawn ___pawn)
 {
     // First two checks are just to prevent duplicates
     if (Settings.Get().BetterHostileReadouts&& !___pawn.RaceProps.Humanlike && ___pawn.Faction != Faction.OfPlayer && ___pawn.HostileTo(Faction.OfPlayer))
     {
         GenMapUI.DrawPawnLabel(___pawn, GenMapUI.LabelDrawPosFor(___pawn, -0.6f), font: GameFont.Tiny);
     }
 }
コード例 #2
0
ファイル: Zombie.cs プロジェクト: DoctorVanGogh/zombieland
 public override void DrawGUIOverlay()
 {
     if (wasColonist)
     {
         var pos = GenMapUI.LabelDrawPosFor(this, -0.6f);
         GenMapUI.DrawPawnLabel(this, pos, 1f, 9999f, null, GameFont.Tiny, true, true);
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        private void DoRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            var rect2 = rect.AtZero();

            //CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            //CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, p, ref this.specificHealthTabForPawn);
            rect2.width -= 24f;
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            var rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            var bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            if (!compactMode)
            {
                var num = bgRect.xMax;
                if (p.RaceProps.IsFlesh)
                {
                    var rect4 = new Rect(num, 0f, 100f, 50f);
                    DoPain(rect4, p);
                }
                var list = CapacitiesToDisplay;
                for (var i = 0; i < list.Count; i++)
                {
                    num += 100f;
                    var rect5 = new Rect(num, 0f, 100f, 50f);
                    if (!p.RaceProps.Humanlike || list[i].showOnHumanlikes)
                    {
                        if (!p.RaceProps.Animal || list[i].showOnAnimals)
                        {
                            if (!p.RaceProps.IsMechanoid || list[i].showOnMechanoids)
                            {
                                if (PawnCapacityUtility.BodyCanEverDoCapacity(p.RaceProps.body, list[i]))
                                {
                                    DoCapacity(rect5, p, list[i]);
                                }
                            }
                        }
                    }
                }
            }
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #5
0
ファイル: PawnUIOverlay.cs プロジェクト: yangbum7/WhatTheHack
        static void Postfix(PawnUIOverlay __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn.IsHacked() && pawn.Faction == Faction.OfPlayer && pawn.Name != null)
            {
                Vector2 pos = GenMapUI.LabelDrawPosFor(pawn, -0.6f);
                GenMapUI.DrawPawnLabel(pawn, pos, 1f, 9999f, null, GameFont.Tiny, true, true);
            }
        }
コード例 #6
0
        private void DoPawnRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanThingsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            bool flag = this.draggedItem != null && rect2.Contains(Event.current.mousePosition) && this.CurrentWearerOf(this.draggedItem) != p;

            if ((Mouse.IsOver(rect2) && this.draggedItem == null) || flag)
            {
                Widgets.DrawHighlight(rect2);
            }
            if (flag && this.droppedDraggedItem)
            {
                this.TryEquipDraggedItem(p);
                SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            float xMax = bgRect.xMax;

            if (p.equipment != null)
            {
                List <ThingWithComps> allEquipmentListForReading = p.equipment.AllEquipmentListForReading;
                for (int i = 0; i < allEquipmentListForReading.Count; i++)
                {
                    this.DoEquippedGear(allEquipmentListForReading[i], p, ref xMax);
                }
            }
            if (p.apparel != null)
            {
                WITab_Caravan_Gear.tmpApparel.Clear();
                WITab_Caravan_Gear.tmpApparel.AddRange(p.apparel.WornApparel);
                WITab_Caravan_Gear.tmpApparel.SortBy((Apparel x) => x.def.apparel.LastLayer.drawOrder, (Apparel x) => - x.def.apparel.HumanBodyCoverage);
                for (int j = 0; j < WITab_Caravan_Gear.tmpApparel.Count; j++)
                {
                    this.DoEquippedGear(WITab_Caravan_Gear.tmpApparel[j], p, ref xMax);
                }
            }
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #7
0
        public void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering)
        {
            float num = this.ColonistBar.GetEntryRectAlpha(rect);

            this.ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref num);
            if (reordering)
            {
                num *= 0.5f;
            }
            Color color = new Color(1f, 1f, 1f, num);

            GUI.color = color;
            GUI.DrawTexture(rect, ColonistBar.BGTex);
            if (colonist.needs != null && colonist.needs.mood != null)
            {
                Rect  position = rect.ContractedBy(2f);
                float num2     = position.height * colonist.needs.mood.CurLevelPercentage;
                position.yMin   = position.yMax - num2;
                position.height = num2;
                GUI.DrawTexture(position, ColonistBarColonistDrawer.MoodBGTex);
            }
            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 * this.ColonistBar.Scale);
            bool flag  = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse);

            if (flag && !WorldRendererUtility.WorldRenderedNow)
            {
                this.DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                this.DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            GUI.DrawTexture(this.GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f));
            GUI.color = new Color(1f, 1f, 1f, num * 0.8f);
            this.DrawIcons(rect, colonist);
            GUI.color = color;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, ColonistBarColonistDrawer.DeadColonistTex);
            }
            float   num3 = 4f * this.ColonistBar.Scale;
            Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num3);

            GenMapUI.DrawPawnLabel(colonist, pos, num, rect.width + this.ColonistBar.SpaceBetweenColonistsHorizontal - 2f, this.pawnLabelsCache, GameFont.Tiny, true, true);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
        }
コード例 #8
0
        static bool Prefix(PawnUIOverlay __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn.GetExtendedPawnData() is ExtendedPawnData data && data.mount != null)
            {
                Vector2 pos = GenMapUI.LabelDrawPosFor(pawn, -(data.drawOffset + 0.6f));
                GenMapUI.DrawPawnLabel(pawn, pos, 1f, 9999f, null, GameFont.Tiny, true, true);
                return(false);
            }
            return(true);
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        public static bool Prefix(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering,
                                  Dictionary <string, string> ___pawnLabelsCache, Vector2 ___PawnTextureSize,
                                  Texture2D ___MoodBGTex, Vector2[] ___bracketLocs)
        {
            if (colonist.Dead && colonist.HasStack())
            {
                float alpha = Find.ColonistBar.GetEntryRectAlpha(rect);
                ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref alpha);
                if (reordering)
                {
                    alpha *= 0.5f;
                }
                Color color2 = GUI.color = new Color(1f, 1f, 1f, alpha);
                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;
                    GUI.DrawTexture(position, ___MoodBGTex);
                }
                if (highlight)
                {
                    int thickness = (rect.width <= 22f) ? 2 : 3;
                    GUI.color = Color.white;
                    Widgets.DrawBox(rect, thickness);
                    GUI.color = color2;
                }
                Rect rect2 = rect.ContractedBy(-2f * Find.ColonistBar.Scale);
                if ((colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist)) && !WorldRendererUtility.WorldRenderedNow)
                {
                    DrawSelectionOverlayOnGUI(colonist, rect2, ___bracketLocs);
                }

                GUI.DrawTexture(GetPawnTextureRect(rect.position, ___PawnTextureSize), PortraitsCache.Get(colonist, ___PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f));
                GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);

                float   num3 = 20f * Find.ColonistBar.Scale;
                Vector2 pos2 = new Vector2(rect.x + 1f, rect.yMax - num3 - 1f);
                DrawIcon(Icon_StackDead, ref pos2, "ActivityIconMedicalRest".Translate());
                GUI.color = color2;

                float   num2 = 4f * Find.ColonistBar.Scale;
                Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num2);
                GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + Find.ColonistBar.SpaceBetweenColonistsHorizontal - 2f, ___pawnLabelsCache);
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
                return(false);
            }
            return(true);
        }
コード例 #11
0
        public void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering)
        {
            float alpha = ColonistBar.GetEntryRectAlpha(rect);

            ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref alpha);
            if (reordering)
            {
                alpha *= 0.5f;
            }
            Color color2 = (GUI.color = new Color(1f, 1f, 1f, alpha));

            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;
                GUI.DrawTexture(position, MoodBGTex);
            }
            if (highlight)
            {
                int thickness = ((rect.width <= 22f) ? 2 : 3);
                GUI.color = Color.white;
                Widgets.DrawBox(rect, thickness);
                GUI.color = color2;
            }
            Rect rect2 = rect.ContractedBy(-2f * ColonistBar.Scale);

            if ((colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist)) && !WorldRendererUtility.WorldRenderedNow)
            {
                DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            GUI.DrawTexture(GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, PawnTextureSize, PawnTextureCameraOffset, 1.28205f));
            GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);
            DrawIcons(rect, colonist);
            GUI.color = color2;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, DeadColonistTex);
            }
            float   num2 = 4f * ColonistBar.Scale;
            Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num2);

            GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + ColonistBar.SpaceBetweenColonistsHorizontal - 2f, pawnLabelsCache);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
        }
コード例 #12
0
        public void DrawPawnGUIOverlay()
        {
            if (!actor.Spawned || actor.Map.fogGrid.IsFogged(actor.Position))
            {
                return;
            }

            var pawn = Converter.ActorToPawn(actor);

            GenMapUI.DrawPawnLabel(pawn, GenMapUI.LabelDrawPosFor(pawn, -0.6f), 1f, 9999f, null, GameFont.Tiny, true, true);

            actor.Map.overlayDrawer.DrawOverlay(actor, OverlayTypes.QuestionMark);
        }
コード例 #13
0
        public void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)
        {
            float entryRectAlpha = this.ColonistBar.GetEntryRectAlpha(rect);

            this.ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref entryRectAlpha);
            bool  flag   = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse);
            Color color2 = GUI.color = new Color(1f, 1f, 1f, entryRectAlpha);

            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;
                GUI.DrawTexture(position, ColonistBarColonistDrawer.MoodBGTex);
            }
            Rect rect2 = rect.ContractedBy((float)(-2.0 * this.ColonistBar.Scale));

            if (flag && !WorldRendererUtility.WorldRenderedNow)
            {
                this.DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                this.DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            GUI.DrawTexture(this.GetPawnTextureRect(rect.x, rect.y), PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f));
            GUI.color = new Color(1f, 1f, 1f, (float)(entryRectAlpha * 0.800000011920929));
            this.DrawIcons(rect, colonist);
            GUI.color = color2;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, ColonistBarColonistDrawer.DeadColonistTex);
            }
            float   num2   = (float)(4.0 * this.ColonistBar.Scale);
            Vector2 center = rect.center;
            Vector2 pos    = new Vector2(center.x, rect.yMax - num2);

            GenMapUI.DrawPawnLabel(colonist, pos, entryRectAlpha, (float)(rect.width + this.ColonistBar.SpaceBetweenColonistsHorizontal - 2.0), this.pawnLabelsCache, GameFont.Tiny, true, true);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
        }
コード例 #14
0
        internal static void _DrawPawnGUIOverlay(this PawnUIOverlay _this)
        {
            if (!_this.GetPawn().Spawned || _this.GetPawn().Map.fogGrid.IsFogged(_this.GetPawn().Position) || _this.GetPawn().health.hediffSet.HasHediff(HediffDefOfPsychology.Thief))
            {
                return;
            }
            if (!_this.GetPawn().RaceProps.Humanlike)
            {
                switch (Prefs.AnimalNameMode)
                {
                case AnimalNameDisplayMode.None:
                    return;

                case AnimalNameDisplayMode.TameNamed:
                    if (_this.GetPawn().Name == null || _this.GetPawn().Name.Numerical)
                    {
                        return;
                    }
                    break;

                case AnimalNameDisplayMode.TameAll:
                    if (_this.GetPawn().Name == null)
                    {
                        return;
                    }
                    break;
                }
            }
            Vector2 pos = GenMapUI.LabelDrawPosFor(_this.GetPawn(), -0.6f);

            GenMapUI.DrawPawnLabel(_this.GetPawn(), pos, 1f, 9999f, null, GameFont.Tiny, true, true);
            if (_this.GetPawn().CanTradeNow)
            {
                _this.GetPawn().Map.overlayDrawer.DrawOverlay(_this.GetPawn(), OverlayTypes.QuestionMark);
            }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering)
        {
            float alpha = TacticUtils.TacticalColonistBar.GetEntryRectAlpha(rect);

            TacticUtils.TacticalColonistBar.drawer.ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref alpha);
            if (reordering)
            {
                alpha *= 0.5f;
            }
            Color color2 = GUI.color = new Color(1f, 1f, 1f, alpha);

            GUI.DrawTexture(rect, TacticalColonistBar.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;
                if (TacticalGroupsSettings.DisplayColorBars)
                {
                    GUI.DrawTexture(position, ColonistBarColonistDrawer.GetMoodBarTexture(colonist));
                }
                else
                {
                    GUI.DrawTexture(position, ColonistBarColonistDrawer.MoodBGTex);
                }
            }

            if (highlight)
            {
                int thickness = (rect.width <= 22f) ? 2 : 3;
                GUI.color = Color.white;
                Widgets.DrawBox(rect, thickness);
                GUI.color = color2;
            }
            Rect rect2 = rect.ContractedBy(-2f * TacticUtils.TacticalColonistBar.Scale);

            if ((colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist)) && !WorldRendererUtility.WorldRenderedNow)
            {
                TacticUtils.TacticalColonistBar.drawer.DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                TacticUtils.TacticalColonistBar.drawer.DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            GUI.DrawTexture(GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, ColonistBarColonistDrawer.DefaultPawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f));
            if (colonist.Drafted)
            {
                GUI.DrawTexture(rect, Textures.PawnDrafted);
            }
            GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);
            TacticUtils.TacticalColonistBar.drawer.DrawIcons(rect, colonist);
            GUI.color = color2;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, ColonistBarColonistDrawer.DeadColonistTex);
            }
            float   num2 = 4f * TacticUtils.TacticalColonistBar.Scale;
            Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num2);

            GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + TacticUtils.TacticalColonistBar.SpaceBetweenColonistsHorizontal - 2f, TacticUtils.TacticalColonistBar.drawer.pawnLabelsCache);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;

            ColonistBarColonistDrawer.DrawHealthBar(colonist, rect);
            ColonistBarColonistDrawer.DrawRestAndFoodBars(colonist, rect, Textures.RestFood.width);
            //ColonistBarColonistDrawer.ShowDrafteesWeapon(rect, colonist, 10);
        }
コード例 #17
0
        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();
        }
コード例 #18
0
        private void DoRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanThingsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            float num = bgRect.xMax;

            for (int i = 0; i < 3; i++)
            {
                Rect rect5 = new Rect(num, 0f, 100f, 50f);
                if (Mouse.IsOver(rect5))
                {
                    Widgets.DrawHighlight(rect5);
                }
                Text.Anchor = TextAnchor.MiddleCenter;
                string s = "";
                switch (i)
                {
                case 0:
                    s = PawnBuildingUtility.ShowConstructionValue(p);
                    break;

                case 1:
                    s = PawnBuildingUtility.ShowSkill(p);
                    break;

                case 2:
                    s = PawnBuildingUtility.ShowBestRoad(p);
                    break;

                default:
                    s = "-";
                    break;
                }
                Widgets.Label(rect5, s);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
                TooltipHandler.TipRegion(rect5, s);
                num += 125f;
            }

            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering, bool showSlaveSuppresion = false)
        {
            float alpha = TacticUtils.TacticalColonistBar.GetEntryRectAlpha(rect);

            TacticUtils.TacticalColonistBar.drawer.ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref alpha);
            if (reordering)
            {
                alpha *= 0.5f;
            }
            Color color2 = GUI.color = new Color(1f, 1f, 1f, alpha);

            GUI.DrawTexture(rect, TacticalColonistBar.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;
                if (TacticalGroupsSettings.DisplayColorBars)
                {
                    GUI.DrawTexture(position, ColonistBarColonistDrawer.GetMoodBarTexture(colonist));
                }
                else
                {
                    GUI.DrawTexture(position, ColonistBarColonistDrawer.MoodBGTex);
                }
            }
            if (highlight)
            {
                int thickness = (rect.width <= 22f) ? 2 : 3;
                GUI.color = Color.white;
                Widgets.DrawBox(rect, thickness);
                GUI.color = color2;
            }
            Rect rect2 = rect.ContractedBy(-2f * TacticUtils.TacticalColonistBar.Scale);

            if ((colonist.Dead ? Find.Selector.SelectedObjects.Contains(colonist.Corpse) : Find.Selector.SelectedObjects.Contains(colonist)) && !WorldRendererUtility.WorldRenderedNow)
            {
                TacticUtils.TacticalColonistBar.drawer.DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                TacticUtils.TacticalColonistBar.drawer.DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            GUI.DrawTexture(GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, PawnTextureSize, Rot4.South, PawnTextureCameraOffset, PawnTextureCameraZoom));
            if (colonist.Drafted)
            {
                GUI.DrawTexture(rect, Textures.PawnDrafted);
            }
            GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);
            TacticUtils.TacticalColonistBar.drawer.DrawIcons(rect, colonist);
            GUI.color = color2;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, ColonistBarColonistDrawer.DeadColonistTex);
            }
            float   num2 = 4f * TacticUtils.TacticalColonistBar.Scale;
            Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num2);

            GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + TacticUtils.TacticalColonistBar.SpaceBetweenColonistsHorizontal - 2f, TacticUtils.TacticalColonistBar.drawer.pawnLabelsCache);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;

            if (showSlaveSuppresion && colonist.needs.TryGetNeed <Need_Suppression>() is Need_Suppression need_Suppression)
            {
                Rect  suppressionBar = new Rect(rect.x + rect.width, rect.y, Textures.RestFood.width, rect.height);
                float num            = Mathf.Clamp(need_Suppression.CurLevelPercentage, 0f, 1f);
                Rect  rect3          = GenUI.ContractedBy(suppressionBar, 1f);
                float num5           = rect3.height * num;
                rect3.yMin   = rect3.yMax - num5;
                rect3.height = num5;
                GUI.DrawTexture(rect3, Textures.SlaveSuppressionBar, ScaleMode.ScaleAndCrop);
                GUI.DrawTexture(suppressionBar, Textures.RestFood, ScaleMode.StretchToFill);
            }
            else
            {
                ColonistBarColonistDrawer.DrawHealthBar(rect, colonist, Textures.HealthBar.width);
                ColonistBarColonistDrawer.DrawRestAndFoodBars(rect, colonist, Textures.RestFood.width);
            }
        }
        public static bool Prefix(ColonistBarColonistDrawer __instance,
                                  ref Rect rect, ref Pawn colonist, ref Map pawnMap,
                                  ref bool highlight, ref bool reordering)
        {
            var colonistBar    = Find.ColonistBar;
            var entryRectAlpha = colonistBar.GetEntryRectAlpha(rect);

            entryRectAlpha = ApplyEntryInAnotherMapAlphaFactor(pawnMap, entryRectAlpha);

            if (reordering)
            {
                entryRectAlpha *= 0.5f;
            }

            var mood          = !colonist.Dead ? colonist.needs.mood : null;
            var mentalBreaker = !colonist.Dead ? colonist.mindState.mentalBreaker : null;

            var color = new Color(1f, 1f, 1f, entryRectAlpha);

            GUI.color = color;

            if (mood != null && mentalBreaker != null)
            {
                var moodBorderRect = rect.ContractedBy(-1f);
                if (mood.CurLevelPercentage <= mentalBreaker.BreakThresholdExtreme)
                {
                    GUI.DrawTexture(moodBorderRect, Main.MoodExtremeCrossedTex);
                }
                else if (mood.CurLevelPercentage <= mentalBreaker.BreakThresholdMajor)
                {
                    GUI.DrawTexture(moodBorderRect, Main.MoodMajorCrossedTex);
                }
                else if (mood.CurLevelPercentage <= mentalBreaker.BreakThresholdMinor)
                {
                    GUI.DrawTexture(moodBorderRect, Main.MoodMinorCrossedTex);
                }

                GUI.DrawTexture(rect, ColonistBar.BGTex);
                var moodRect = rect.ContractedBy(2f);
                var position = moodRect;
                var num      = position.height * colonist.needs.mood.CurLevelPercentage;
                position.yMin   = position.yMax - num;
                position.height = num;

                var currentMoodLevel = colonist.needs.mood.CurLevel;

                // Extreme break threshold
                if (currentMoodLevel <= mentalBreaker.BreakThresholdExtreme)
                {
                    GUI.DrawTexture(moodRect, Main.MoodExtremeCrossedBGTex);
                    GUI.DrawTexture(position, Main.MoodExtremeCrossedTex);
                }
                // Major break threshold
                else if (currentMoodLevel <= mentalBreaker.BreakThresholdMajor)
                {
                    GUI.DrawTexture(position, Main.MoodMajorCrossedTex);
                }
                // Minor break threshold
                else if (currentMoodLevel <= mentalBreaker.BreakThresholdMinor)
                {
                    GUI.DrawTexture(position, Main.MoodMinorCrossedTex);
                }
                // Neutral
                else if (currentMoodLevel <= 0.65f)
                {
                    GUI.DrawTexture(position, Main.NeutralMoodTex);
                }
                // Content
                else if (currentMoodLevel <= 0.9f)
                {
                    GUI.DrawTexture(position, Main.ContentMoodTex);
                }
                // Happy
                else
                {
                    GUI.DrawTexture(position, Main.HappyMoodTex);
                }

                foreach (var threshold in new List <float>
                {
                    mentalBreaker.BreakThresholdExtreme, mentalBreaker.BreakThresholdMajor,
                    mentalBreaker.BreakThresholdMinor
                })
                {
                    var lineColor = Main.MoodBreakTex;
                    if (currentMoodLevel <= threshold)
                    {
                        lineColor = Main.MoodBreakInvertedTex;
                    }

                    GUI.DrawTexture(new Rect(moodRect.x,
                                             moodRect.yMax - (moodRect.height * threshold),
                                             moodRect.width, 1),
                                    lineColor);
                }

                GUI.DrawTexture(
                    new Rect(moodRect.x, moodRect.yMax - (moodRect.height * mood.CurInstantLevelPercentage),
                             moodRect.width, 1), Main.MoodTargetTex);
                GUI.DrawTexture(
                    new Rect(moodRect.xMax + 1, moodRect.yMax - (moodRect.height * mood.CurInstantLevelPercentage) - 1,
                             2, 3), Main.MoodTargetTex);
            }
            else
            {
                GUI.DrawTexture(rect, ColonistBar.BGTex);
            }

            if (highlight)
            {
                var thickness = rect.width > 22f ? 3 : 2;
                GUI.color = Color.white;
                Widgets.DrawBox(rect, thickness);
                GUI.color = color;
            }

            var rect2 = rect.ContractedBy(-2f * colonistBar.Scale);

            var 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 });
            }

            var pawnTexturePosition = __instance.GetPawnTextureRect(new Vector2(rect.x, rect.y));

            GUI.DrawTexture(pawnTexturePosition, PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize,
                                                                    Rot4.South,
                                                                    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));
            }

            var num2 = 4f * colonistBar.Scale;
            var 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));
            Text.Font = GameFont.Small;
            GUI.color = Color.white;

            return(false);
        }
コード例 #22
0
        public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)
        {
            float entryRectAlpha = GetEntryRectAlpha(rect);

            ApplyEntryInAnotherMapAlphaFactor(pawnMap, ref entryRectAlpha);

            bool colonistAlive = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse);

            Color color = new Color(1f, 1f, 1f, entryRectAlpha);

            GUI.color = color;

            Color BGColor = new Color();



            Rect moodBorderRect = new Rect(rect);

            if (ColBarSettings.UseExternalMoodBar)
            {
                // draw mood border
                switch (ColBarSettings.MoodBarPos)
                {
                case Position.Alignment.Right:
                    moodBorderRect.x      = rect.xMax;
                    moodBorderRect.width /= 4;
                    break;

                case Position.Alignment.Left:
                    moodBorderRect.x      = rect.xMin - rect.width / 4;
                    moodBorderRect.width /= 4;
                    break;

                case Position.Alignment.Top:
                    moodBorderRect.x       = rect.xMin;
                    moodBorderRect.y       = rect.yMin - rect.height / 4;
                    moodBorderRect.height /= 4;
                    break;

                case Position.Alignment.Bottom:
                    moodBorderRect.x       = rect.xMin;
                    moodBorderRect.y       = moodBorderRect.yMax + SpacingLabel;
                    moodBorderRect.height /= 4;
                    break;
                }
            }

            PawnStats pawnStats = null;

            if (ColBarSettings.UseNewMood || ColBarSettings.UseExternalMoodBar)
            {
                if (PSI.PSI._statsDict.TryGetValue(colonist, out pawnStats))
                {
                    if (pawnStats.mood != null && pawnStats.mb != null)
                    {
                        if (pawnStats.mood.CurLevelPercentage <= pawnStats.mb.BreakThresholdExtreme)
                        {
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodExtremeCrossedTex);
                        }
                        else if (pawnStats.mood.CurLevelPercentage <= pawnStats.mb.BreakThresholdMajor)
                        {
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMajorCrossedTex);
                        }
                        else if (pawnStats.mood.CurLevelPercentage <= pawnStats.mb.BreakThresholdMinor)
                        {
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMinorCrossedTex);
                        }
                        else
                        {
                            GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
                        }
                    }
                }
            }



            if (ColBarSettings.UseGender)
            {
                if (colonist.gender == Gender.Male)
                {
                    BGColor = ColBarSettings.MaleColor;
                }
                if (colonist.gender == Gender.Female)
                {
                    BGColor = ColBarSettings.FemaleColor;
                }

                if (colonist.Dead)
                {
                    BGColor = BGColor * Color.gray;
                }

                BGColor.a = entryRectAlpha;

                GUI.color = BGColor;
            }


            GUI.DrawTexture(rect, ColBarSettings.UseGender ? ColonistBarTextures.BGTexGrey : ColonistBarTextures.BGTexVanilla);

            GUI.color = color;

            if (colonist.needs != null && colonist.needs.mood != null)
            {
                if (ColBarSettings.UseExternalMoodBar || ColBarSettings.UseNewMood)
                {
                    if (pawnStats != null)
                    {
                        Rect moodRect = moodBorderRect.ContractedBy(2f);
                        DrawNewMoodRect(moodRect, pawnStats.mood, pawnStats.mb);
                    }
                }
                else
                {
                    Rect  position = rect.ContractedBy(2f);
                    float num      = position.height * colonist.needs.mood.CurLevelPercentage;
                    position.yMin   = position.yMax - num;
                    position.height = num;
                    GUI.DrawTexture(position, ColonistBarTextures.MoodBGTex);
                }
            }



            Rect rect2 = rect.ContractedBy(-2f * Scale);

            if (colonistAlive && !WorldRendererUtility.WorldRenderedNow)
            {
                DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }

            GUI.DrawTexture(GetPawnTextureRect(rect.x, rect.y), PortraitsCache.Get(colonist, PawnTextureSize, PawnTextureCameraOffset, ColBarSettings.PawnTextureCameraZoom));

            if (ColBarSettings.UseWeaponIcons)
            {
                DrawWeaponIcon(rect, colonist);
            }

            GUI.color = new Color(1f, 1f, 1f, entryRectAlpha * 0.8f);
            DrawIcons(rect, colonist);
            GUI.color = color;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, ColonistBarTextures.DeadColonistTex);
            }
            //       float num = 4f * Scale;
            Vector2 pos = new Vector2(rect.center.x, rect.yMax + 1f * Scale);

            GenMapUI.DrawPawnLabel(colonist, pos, entryRectAlpha, rect.width + ColonistBarDrawLocsFinderKF.SpacingHorizontal - 2f, ColonistBarColonistDrawerKF.pawnLabelsCache);
            GUI.color = Color.white;
        }
コード例 #23
0
        private void DoRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanThingsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            CaravanThingsTabUtility.DoOpenSpecificTabButton(rect2, p, ref specificHealthTabForPawn);
            rect2.width -= 24f;
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, alwaysDrawBg: false, alignCenter: false);
            float num = bgRect.xMax;

            if (!compactMode)
            {
                if (p.RaceProps.IsFlesh)
                {
                    Rect rect4 = new Rect(num, 0f, 100f, 50f);
                    DoPain(rect4, p);
                }
                num += 100f;
                List <PawnCapacityDef> list = CapacitiesToDisplay;
                for (int i = 0; i < list.Count; i++)
                {
                    Rect rect5 = new Rect(num, 0f, 100f, 50f);
                    if ((p.RaceProps.Humanlike && !list[i].showOnHumanlikes) || (p.RaceProps.Animal && !list[i].showOnAnimals) || (p.RaceProps.IsMechanoid && !list[i].showOnMechanoids) || !PawnCapacityUtility.BodyCanEverDoCapacity(p.RaceProps.body, list[i]))
                    {
                        num += 100f;
                    }
                    else
                    {
                        DoCapacity(rect5, p, list[i]);
                        num += 100f;
                    }
                }
            }
            if (!compactMode)
            {
                Vector2 vector = new Vector2(num + 8f, 13f);
                Widgets.Checkbox(vector, ref p.health.beCarriedByCaravanIfSick, 24f, disabled: false, paintable: true);
                TooltipHandler.TipRegion(new Rect(vector, new Vector2(24f, 24f)), "BeCarriedIfSickTip".Translate());
                num += 40f;
            }
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #24
0
        public static bool DrawQueue_Prefix(object __instance, Rect canvas)
        {
            if (AltRPal)
            {
                canvas.xMax += 130f + 2 * Margin; //keep an eye on his MainTabWindow_ResearchTree.DrawTopBar method for changes to this number
                canvas       = canvas.ExpandedBy(Margin);
            }
            float   padding   = 12f;
            float   spacing   = Find.ColonistBar.SpaceBetweenColonistsHorizontal;
            float   height    = canvas.height;
            float   startPos  = canvas.xMax - height - padding;
            Vector2 size      = new Vector2(height + spacing, height - padding);
            Vector2 innerSize = new Vector2(height - padding, height - padding);
            IEnumerable <object> expertiseDisplay = new object[] { };
            bool displayActive = false;

            using (IEnumerator <Pawn> enumerator = Find.ColonistBar.GetColonistsInOrder().Where(x => x.TechBound()).AsEnumerable().Reverse().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Vector2 position = new Vector2(startPos, canvas.y);
                    Rect    box      = new Rect(position, size);
                    Rect    innerBox = new Rect(position.x + spacing, position.y, size.x - spacing - 2 * padding, size.y);
                    Pawn    pawn     = enumerator.Current;
                    GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, Rot4.South, cameraZoom: 1.4f));
                    CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                    if (Mouse.IsOver(innerBox))
                    {
                        DeInterest();
                        ReflectKnowledge(__instance, techComp, out expertiseDisplay);
                        displayActive = true;
                    }
                    if (!techComp.homework.NullOrEmpty())
                    {
                        StringBuilder homeworkSummary = new StringBuilder();
                        homeworkSummary.AppendLine("AssignedTo".Translate(pawn));
                        foreach (var tech in techComp.homework)
                        {
                            homeworkSummary.AppendLine("- " + TechStrings.GetTask(pawn, tech) + " " + tech.label);
                        }
                        TooltipHandler.TipRegionByKey(box, homeworkSummary.ToString());
                    }
                    Vector2 pos = new Vector2(box.center.x, box.yMax);
                    GenMapUI.DrawPawnLabel(pawn, pos, 1f, box.width, null, GameFont.Tiny, false, true);
                    startPos -= height;
                }
            }
            if (AltRPal)
            {
                if (displayActive)
                {
                    UpdateMatches(expertiseDisplay);
                    expertiseDisplayed = true;
                }
                else if (expertiseDisplayed)
                {
                    ToggleSearch(false);
                    expertiseDisplayed = false;
                }
            }
            return(false);
        }