Beispiel #1
0
        private void CheckRecacheEntries()
        {
            if (!entriesDirty)
            {
                return;
            }
            entriesDirty = false;
            cachedEntries.Clear();
            if (Find.PlaySettings.showColonistBar)
            {
                tmpMaps.Clear();
                tmpMaps.AddRange(Find.Maps);
                tmpMaps.SortBy((Map x) => !x.IsPlayerHome, (Map x) => x.uniqueID);
                int num = 0;
                for (int i = 0; i < tmpMaps.Count; i++)
                {
                    tmpPawns.Clear();
                    tmpPawns.AddRange(tmpMaps[i].mapPawns.FreeColonistsAndPrisoners.Where(x => x.Faction == Faction.OfPlayer));
                    List <Thing> list = tmpMaps[i].listerThings.ThingsInGroup(ThingRequestGroup.Corpse);
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (!list[j].IsDessicated())
                        {
                            Pawn innerPawn = ((Corpse)list[j]).InnerPawn;
                            if (innerPawn != null && innerPawn.IsColonist)
                            {
                                tmpPawns.Add(innerPawn);
                            }
                        }
                    }
                    List <Pawn> allPawnsSpawned = tmpMaps[i].mapPawns.AllPawnsSpawned;
                    for (int k = 0; k < allPawnsSpawned.Count; k++)
                    {
                        Corpse corpse = allPawnsSpawned[k].carryTracker.CarriedThing as Corpse;
                        if (corpse != null && !corpse.IsDessicated() && corpse.InnerPawn.IsColonist)
                        {
                            tmpPawns.Add(corpse.InnerPawn);
                        }
                    }
                    tmpPawns = GetNonHiddenPawns(tmpPawns);
                    PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
                    for (int l = 0; l < tmpPawns.Count; l++)
                    {
                        if (TacticUtils.TacticalGroups.colonyGroups.TryGetValue(tmpMaps[i], out ColonyGroup colonyGroup))
                        {
                            cachedEntries.Add(new Entry(tmpPawns[l], tmpMaps[i], num, null, colonyGroup));
                        }
                        else
                        {
                            cachedEntries.Add(new Entry(tmpPawns[l], tmpMaps[i], num, null, null));
                        }
                    }
                    if (!tmpPawns.Any())
                    {
                        try
                        {
                            var colonyGroup = TacticUtils.AllColonyGroups.Where(x => x.Map == tmpMaps[i]).FirstOrDefault();
                            cachedEntries.Add(new Entry(null, tmpMaps[i], num, null, colonyGroup));
                        }
                        catch { };
                    }
                    num++;
                }

                tmpCaravans.Clear();
                tmpCaravans.AddRange(Find.WorldObjects.Caravans);
                tmpCaravans.SortBy((Caravan x) => x.ID);
                for (int m = 0; m < tmpCaravans.Count; m++)
                {
                    if (!tmpCaravans[m].IsPlayerControlled)
                    {
                        continue;
                    }
                    tmpPawns.Clear();
                    tmpPawns.AddRange(tmpCaravans[m].PawnsListForReading);
                    tmpPawns = GetNonHiddenPawns(tmpPawns);
                    PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
                    for (int n = 0; n < tmpPawns.Count; n++)
                    {
                        if (tmpPawns[n].IsColonist)
                        {
                            if (TacticUtils.TacticalGroups.caravanGroups.TryGetValue(tmpCaravans[m], out CaravanGroup value))
                            {
                                cachedEntries.Add(new Entry(tmpPawns[n], null, num, value, null));
                            }
                            else
                            {
                                var caravanGroup = TacticUtils.TacticalGroups.AddCaravanGroup(tmpCaravans[m]);
                                cachedEntries.Add(new Entry(tmpPawns[n], null, num, caravanGroup, null));
                            }
                        }
                    }

                    if (!tmpPawns.Any())
                    {
                        var caravanGroup = TacticUtils.TacticalGroups.caravanGroups.Where(x => x.Key == tmpCaravans[m]).FirstOrDefault();
                        if (caravanGroup.Value != null)
                        {
                            cachedEntries.Add(new Entry(null, null, num, caravanGroup.Value, null));
                        }
                    }
                    num++;
                }
            }

            drawer.Notify_RecachedEntries();
            tmpPawns.Clear();
            tmpMaps.Clear();
            tmpCaravans.Clear();
            GenMapUIOptimized.ForceUpdateLabels();
            TacticUtils.ForceUpdateGroups();
            drawLocsFinder.CalculateDrawLocs(cachedDrawLocs, out cachedScale);
        }
        public void DrawColonist(Rect rect, Pawn colonist, Map pawnMap, bool highlight, bool reordering)
        {
            if (ModCompatibility.AlteredCarbonIsActive)
            {
                bool prefixValue = (bool)ModCompatibility.alteredCarbonDrawColonist_PatchMethod.Invoke(this, new object[]
                {
                    rect, colonist, pawnMap, highlight, reordering, pawnLabelsCache, PawnTextureSize, MoodBGTex, bracketLocs
                });
                if (!prefixValue)
                {
                    return;
                }
            }
            float alpha = TacticUtils.TacticalColonistBar.GetEntryRectAlpha(rect);

            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, GetMoodBarTexture(colonist));
                    if (!TacticalGroupsSettings.DisplayBreakRiskOverlay)
                    {
                        GUI.DrawTexture(position, Textures.ColorMoodBarOverlay);
                    }
                }
                else
                {
                    GUI.DrawTexture(position, MoodBGTex);
                }

                if (TacticalGroupsSettings.DisplayBreakRiskOverlay)
                {
                    if (colonist.needs.mood.CurLevel < colonist.mindState.mentalBreaker.BreakThresholdMajor)
                    {
                        GUI.DrawTexture(rect.ContractedBy(2f), Textures.ColorMoodBarOverlayRedMajor);
                    }
                    else if (colonist.needs.mood.CurLevel < colonist.mindState.mentalBreaker.BreakThresholdMinor)
                    {
                        GUI.DrawTexture(rect.ContractedBy(2f), Textures.ColorMoodBarOverlayRedMinor);
                    }
                    else if (TacticalGroupsSettings.DisplayColorBars)
                    {
                        GUI.DrawTexture(position, Textures.ColorMoodBarOverlay);
                    }
                }
            }

            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)
            {
                DrawSelectionOverlayOnGUI(colonist, rect2);
            }
            else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan()))
            {
                DrawCaravanSelectionOverlayOnGUI(colonist.GetCaravan(), rect2);
            }
            var pawnIconRect = GetPawnTextureRect(rect.position);

            GUI.DrawTexture(pawnIconRect, PortraitsCache.Get(colonist, PawnTextureSize * TacticalGroupsSettings.PawnScale, PawnTextureCameraOffset, PawnTextureCameraZoom * TacticalGroupsSettings.PawnScale));
            if (colonist.Drafted)
            {
                GUI.DrawTexture(rect, Textures.PawnDrafted);
            }
            GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f);
            DrawIcons(rect, colonist);
            GUI.color = color2;
            if (colonist.Dead)
            {
                GUI.DrawTexture(rect, DeadColonistTex);
            }
            else if (colonist.IsPrisoner)
            {
                GUI.DrawTexture(rect, Textures.PawnPrisoner);
            }

            var pawnStates = PawnStateUtility.GetAllPawnStatesCache(colonist);

            if (pawnStates.Contains(PawnState.IsBleeding))
            {
                GUI.DrawTexture(rect, Textures.PawnBleeding);
            }

            float   num2 = 4f * TacticUtils.TacticalColonistBar.Scale;
            Vector2 pos  = new Vector2(rect.center.x, rect.yMax - num2);

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

            DrawHealthBar(colonist, rect);
            DrawRestAndFoodBars(colonist, rect, TacticalGroupsSettings.PawnNeedsWidth);
            ShowDrafteesWeapon(rect, colonist, TacticalGroupsSettings.WeaponPlacementOffset);

            if (ModCompatibility.PawnBadgesIsActive)
            {
                ModCompatibility.pawnBadgesDrawMethod.Invoke(this, new object[]
                {
                    rect, colonist, pawnMap, highlight, reordering
                });
            }
            if (ModCompatibility.JobInBarIsActive)
            {
                ModCompatibility.jobInBarDrawMethod.Invoke(this, new object[]
                {
                    null, pawnLabelsCache, rect, colonist, pawnMap, highlight, reordering
                });
            }
        }