Beispiel #1
0
        /// <summary>
        /// Handles clicks and repaints to the colonist bar.
        /// </summary>
        /// <param name="colonistsToHighlight">The colonists to highlight on the colonist bar.</param>
        private static void HandleOnGUI(List <Pawn> colonistsToHighlight)
        {
            var colonistBar = Find.ColonistBar;
            var entries     = ColonistBarUtility.GetVisibleEntries();

            int currentGroup     = -1;
            int reorderableGroup = -1;

            for (int i = 0; i < colonistBar.DrawLocs.Count; i++)
            {
                var rect  = ColonistBarUtility.GetRect(i);
                var entry = entries[i];

                bool isDifferentGroup = currentGroup != entry.group;
                currentGroup = entry.group;
                if (isDifferentGroup)
                {
                    reorderableGroup = GetReorderableGroup(entry, entries);
                }
                bool reordering;
                if (entry.pawn != null)
                {
                    colonistBar.drawer.HandleClicks(
                        rect, entry.pawn, reorderableGroup, out reordering);
                }
                else
                {
                    reordering = false;
                }
                HandleRepaint(entry, rect, isDifferentGroup, reordering, colonistsToHighlight);
            }
        }
        // Modified public method ColonistBar.ColonistsOrCorpsesInScreenRect()
        private static List <Thing> ColonistsOrCorpsesInScreenRect(Rect rect,
                                                                   List <Pair <Thing, Map> > tmpColonistsWithMap, List <Thing> tmpColonists)
        {
            List <Vector2> drawLocs = Find.ColonistBar.DrawLocs;
            var            entries  = ColonistBarUtility.GetVisibleEntries();
            Vector2        size     = Find.ColonistBar.Size;

            tmpColonistsWithMap.Clear();
            for (int i = 0; i < drawLocs.Count; i++)
            {
                if (rect.Overlaps(new Rect(drawLocs[i].x, drawLocs[i].y, size.x, size.y)))
                {
                    Pawn pawn = entries[i].pawn;
                    if (pawn != null)
                    {
                        Thing first;
                        if (pawn.Dead && pawn.Corpse != null && pawn.Corpse.SpawnedOrAnyParentSpawned)
                        {
                            first = pawn.Corpse;
                        }
                        else
                        {
                            first = pawn;
                        }
                        tmpColonistsWithMap.Add(new Pair <Thing, Map>(first, entries[i].map));
                    }
                }
            }
            if (WorldRendererUtility.WorldRenderedNow)
            {
                if (tmpColonistsWithMap.Any((Pair <Thing, Map> x) => x.Second == null))
                {
                    tmpColonistsWithMap.RemoveAll((Pair <Thing, Map> x) => x.Second != null);
                    goto IL_1A1;
                }
            }
            if (tmpColonistsWithMap.Any((Pair <Thing, Map> x) => x.Second == Find.CurrentMap))
            {
                tmpColonistsWithMap.RemoveAll((Pair <Thing, Map> x) => x.Second != Find.CurrentMap);
            }
IL_1A1:
            tmpColonists.Clear();
            for (int j = 0; j < tmpColonistsWithMap.Count; j++)
            {
                tmpColonists.Add(tmpColonistsWithMap[j].First);
            }
            tmpColonistsWithMap.Clear();
            return(tmpColonists);
        }
        // Modified private method ColonistBarColonistDrawer.GroupFrameRect()
        private static Rect GroupFrameRect(int group)
        {
            float          num      = 99999f;
            float          num2     = 0f;
            float          num3     = 0f;
            var            entries  = ColonistBarUtility.GetVisibleEntries();
            List <Vector2> drawLocs = Find.ColonistBar.DrawLocs;

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].group == group)
                {
                    num  = Mathf.Min(num, drawLocs[i].x);
                    num2 = Mathf.Max(num2, drawLocs[i].x + Find.ColonistBar.Size.x);
                    num3 = Mathf.Max(num3, drawLocs[i].y + Find.ColonistBar.Size.y);
                }
            }
            return(new Rect(num, 0f, num2 - num, num3).ContractedBy(-12f * Find.ColonistBar.Scale));
        }
        private static bool Prefix(ref List <int> ___entriesInGroup)
        {
            var entries          = ColonistBarUtility.GetVisibleEntries(Find.ColonistBar);
            var totalGroupsCount = ColonistBarUtility.GetTotalGroupsCount();

            var list = new List <int>(totalGroupsCount);

            for (int i = 0; i < totalGroupsCount; i++)
            {
                list.Add(0);
            }
            foreach (var entry in entries)
            {
                int group = entry.group;
                list[group]++;
            }
            ___entriesInGroup = list;
            return(false);
        }