/// <summary>
        /// Flattens the horizontal slots to the lowest between itself and
        /// relevant counts of entries for a group.
        /// </summary>
        /// <param name="entriesInGroup">The amount of entries per group.</param>
        /// <param name="horizontalSlotsPerGroup">The amount of horizontal slots per group.</param>
        public static void FlattenHorizontalSlots(List <int> entriesInGroup, List <int> horizontalSlotsPerGroup)
        {
            var visibleGroups = ColonistBarUtility.GetVisibleGroups(Find.ColonistBar);

            foreach (var visibleGroup in visibleGroups)
            {
                int index = ColonistBarUtility.GetGroupRelativeToVisible(visibleGroup);
                horizontalSlotsPerGroup[index] = Mathf.Min(horizontalSlotsPerGroup[index], entriesInGroup[visibleGroup]);
            }
        }
        // Modified private method ColonistBarDrawLocsFinder.GetDrawLoc()
        /// <summary>
        /// Gets the drawing location for a given entry.
        /// </summary>
        /// <param name="groupStartX">The group's starting x position.</param>
        /// <param name="groupStartY">The group's starting y position.</param>
        /// <param name="group">The group of the entry.</param>
        /// <param name="positionInGroup">The position of the entry in the group.</param>
        /// <param name="scale">The scale of the colonist bar.</param>
        /// <param name="entriesInGroup">The amount of entries for a given group.</param>
        /// <param name="horizontalSlotsPerGroup">The amount of horizontal slots for a given group.</param>
        /// <returns>The drawing location for a given entry.</returns>
        public static Vector2 GetDrawLoc(float groupStartX, float groupStartY, int group, int positionInGroup, float scale, List <int> entriesInGroup, List <int> horizontalSlotsPerGroup)
        {
            int horizontalSlot = horizontalSlotsPerGroup[ColonistBarUtility.GetGroupRelativeToVisible(group)];

            if (horizontalSlot == 0)
            {
                throw new ArgumentException("Horizontal slot cannot be equal to zero.");
            }
            int entryCountInGroup = entriesInGroup[group];

            float x = groupStartX + (float)(positionInGroup % horizontalSlot) * scale * (ColonistBar.BaseSize.x + 24f);
            float y = groupStartY + (float)(positionInGroup / horizontalSlot) * scale * (ColonistBar.BaseSize.y + 32f);

            if (positionInGroup >= entryCountInGroup - (entryCountInGroup % horizontalSlot))
            {
                int num2 = horizontalSlot - entryCountInGroup % horizontalSlot;
                x += (float)num2 * scale * (ColonistBar.BaseSize.x + 24f) * 0.5f;
            }
            return(new Vector2(x, y));
        }
        // Modified private method ColonistBarDrawLocsFinder.FindBestScale().
        /// <summary>
        /// Returns the best scale for the colonist bar.
        /// </summary>
        /// <param name="entriesInGroup">The amount of entries for a given group.</param>
        /// <param name="onlyOneRow">Whether the colonist bar should use only one row.</param>
        /// <param name="maxPerGlobalRow">The maximum amounts of entries per row.</param>
        /// <param name="horizontalSlotsPerGroup">The amount of horizontal slots to use for a given group.</param>
        /// <returns>The best scale based on the amount of entries per group.</returns>
        public static float GetBestScale(List <int> entriesInGroup, out bool onlyOneRow, out int maxPerGlobalRow, out List <int> horizontalSlotsPerGroup)
        {
            float bestScale   = 1f;
            var   entries     = ColonistBarUtility.GetVisibleEntries();
            int   groupsCount = ColonistBarUtility.GetVisibleGroupsCount();

            while (true)
            {
                float colonistBarWidth = (ColonistBar.BaseSize.x + 24f) * bestScale;
                float num4             = MaxColonistBarWidth - (float)(groupsCount - 1) * 25f * bestScale;
                maxPerGlobalRow = Mathf.FloorToInt(num4 / colonistBarWidth);
                onlyOneRow      = true;
                bool result = TryDistributeHorizontalSlotsBetweenGroups(
                    maxPerGlobalRow, entriesInGroup, out horizontalSlotsPerGroup);
                if (result)
                {
                    int  allowedRowsCountForScale = GetAllowedRowsCountForScale(bestScale);
                    bool flag         = true;
                    int  currentGroup = -1;

                    foreach (var entry in entries)
                    {
                        if (currentGroup != entry.group)
                        {
                            currentGroup = entry.group;

                            int rowCount = Mathf.CeilToInt(
                                (float)entriesInGroup[entry.group] / (float)horizontalSlotsPerGroup[ColonistBarUtility.GetGroupRelativeToVisible(entry.group)]
                                );

                            if (rowCount > 1)
                            {
                                onlyOneRow = false;
                            }
                            if (rowCount > allowedRowsCountForScale)
                            {
                                flag = false;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                bestScale *= 0.95f;
            }
            return(bestScale);
        }