コード例 #1
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);
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public void ColonistBarOnGUI()
        {
            if (!Visible)
            {
                return;
            }
            if (Event.current.type != EventType.Layout)
            {
                List <Entry> entries          = Entries;
                int          num              = -1;
                bool         showGroupFrames  = ShowGroupFrames;
                int          reorderableGroup = -1;
                GUI.color = Color.white;
                Text.Font = GameFont.Tiny;

                var createGroupRect = ColonistBarDrawLocsFinder.createGroupRect;
                if (Mouse.IsOver(createGroupRect))
                {
                    GUI.DrawTexture(createGroupRect, Textures.CreateGroupIconHover);
                    TooltipHandler.TipRegion(createGroupRect, Strings.CreateGroupTooltip);
                }
                else if (!TacticalGroupsSettings.HideCreateGroup)
                {
                    GUI.DrawTexture(createGroupRect, Textures.CreateGroupIcon);
                }

                HandleGroupingClicks(createGroupRect);
                Rect optionsGearRect = new Rect(createGroupRect.x + (createGroupRect.width / 3f), createGroupRect.y + createGroupRect.height + 5, Textures.OptionsGear.width, Textures.OptionsGear.height);
                if (Mouse.IsOver(optionsGearRect))
                {
                    GUI.DrawTexture(optionsGearRect, Textures.OptionsGearHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                    {
                        TieredFloatMenu floatMenu = new OptionsMenu(null, null, optionsGearRect, Textures.OptionsMenu);
                        Find.WindowStack.Add(floatMenu);
                    }
                    TooltipHandler.TipRegion(optionsGearRect, Strings.OptionsGearTooltip);
                }
                else if (!TacticalGroupsSettings.HideCreateGroup)
                {
                    GUI.DrawTexture(optionsGearRect, Textures.OptionsGear);
                }
                for (var i = 0; i < ColonistBarDrawLocsFinder.pawnGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.pawnGroupDrawLoc[i].colonistGroup.Draw(ColonistBarDrawLocsFinder.pawnGroupDrawLoc[i].rect);
                }
                for (var i = 0; i < ColonistBarDrawLocsFinder.colonyGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.colonyGroupDrawLoc[i].colonistGroup.Draw(ColonistBarDrawLocsFinder.colonyGroupDrawLoc[i].rect);
                }
                for (var i = 0; i < ColonistBarDrawLocsFinder.caravanGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.caravanGroupDrawLoc[i].colonistGroup.Draw(ColonistBarDrawLocsFinder.caravanGroupDrawLoc[i].rect);
                }

                for (var i = 0; i < ColonistBarDrawLocsFinder.pawnGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.pawnGroupDrawLoc[i].colonistGroup.DrawOverlays(ColonistBarDrawLocsFinder.pawnGroupDrawLoc[i].rect);
                }

                for (var i = 0; i < ColonistBarDrawLocsFinder.colonyGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.colonyGroupDrawLoc[i].colonistGroup.DrawOverlays(ColonistBarDrawLocsFinder.colonyGroupDrawLoc[i].rect);
                }

                for (var i = 0; i < ColonistBarDrawLocsFinder.caravanGroupDrawLoc.Count; i++)
                {
                    ColonistBarDrawLocsFinder.caravanGroupDrawLoc[i].colonistGroup.DrawOverlays(ColonistBarDrawLocsFinder.caravanGroupDrawLoc[i].rect);
                }

                for (int i = 0; i < cachedDrawLocs.Count; i++)
                {
                    Entry entry = entries[i];
                    bool  flag  = num != entry.group;
                    num = entry.group;
                    if (flag)
                    {
                        reorderableGroup = ReorderableWidget.NewGroup(entry.reorderAction, ReorderableDirection.Horizontal, SpaceBetweenColonistsHorizontal, entry.extraDraggedItemOnGUI);
                    }
                    bool reordering;
                    if (entry.pawn != null)
                    {
                        drawer.HandleClicks(cachedDrawLocs[i], entry.pawn, reorderableGroup, out reordering);
                    }
                    else
                    {
                        reordering = false;
                    }
                    if (Event.current.type != EventType.Repaint)
                    {
                        continue;
                    }
                    if (flag && showGroupFrames)
                    {
                        drawer.DrawGroupFrame(entry.group);
                    }
                    if (entry.pawn != null)
                    {
                        drawer.DrawColonist(cachedDrawLocs[i], entry.pawn, entry.map, colonistsToHighlight.Contains(entry.pawn), reordering);
                        ColonistBarColonistDrawer.DrawHealthBar(cachedDrawLocs[i], entry.pawn, TacticalGroupsSettings.HealthBarWidth);
                        ColonistBarColonistDrawer.DrawRestAndFoodBars(cachedDrawLocs[i], entry.pawn, TacticalGroupsSettings.PawnNeedsWidth);
                        ColonistBarColonistDrawer.ShowDrafteesWeapon(cachedDrawLocs[i], entry.pawn, TacticalGroupsSettings.WeaponPlacementOffset);
                    }
                }
                num = -1;
                if (showGroupFrames)
                {
                    for (int j = 0; j < cachedDrawLocs.Count; j++)
                    {
                        Entry entry2 = entries[j];
                        bool  num3   = num != entry2.group;
                        num = entry2.group;
                        if (num3)
                        {
                            drawer.HandleGroupFrameClicks(entry2.group);
                        }
                    }
                }
            }

            if (Event.current.type == EventType.Repaint)
            {
                colonistsToHighlight.Clear();
            }

            if (Find.TickManager.TicksGame % 1000 == 0)
            {
                foreach (var group in TacticUtils.AllGroups)
                {
                    group.Sort();
                }
            }
        }