private bool TryDistributeHorizontalSlotsBetweenGroups(int maxPerGlobalRow) { int num = this.CalculateGroupsCount(); this.horizontalSlotsPerGroup.Clear(); for (int k = 0; k < num; k++) { this.horizontalSlotsPerGroup.Add(0); } GenMath.DHondtDistribution(this.horizontalSlotsPerGroup, (int i) => (float)this.entriesInGroup[i], maxPerGlobalRow); for (int j = 0; j < this.horizontalSlotsPerGroup.Count; j++) { if (this.horizontalSlotsPerGroup[j] == 0) { int num2 = this.horizontalSlotsPerGroup.Max(); if (num2 <= 1) { return(false); } int num3 = this.horizontalSlotsPerGroup.IndexOf(num2); List <int> list; int index; (list = this.horizontalSlotsPerGroup)[index = num3] = list[index] - 1; int index2; (list = this.horizontalSlotsPerGroup)[index2 = j] = list[index2] + 1; } } return(true); }
// Modified private method ColonistBarDrawLocsFinder.TryDistributeHorizontalSlotsBetweenGroups() /// <summary> /// Trys to distribute horizontal slots between groups based on a per /// row maximum. /// </summary> /// <param name="maxPerGlobalRow">The maximum amount of slots per row.</param> /// <param name="entriesInGroup">The amount of entries per group.</param> /// <param name="horizontalSlotsPerGroup">The result of the distribution.</param> /// <returns>Returns true if successful, otherwise false.</returns> public static bool TryDistributeHorizontalSlotsBetweenGroups(int maxPerGlobalRow, List <int> entriesInGroup, out List <int> horizontalSlotsPerGroup) { horizontalSlotsPerGroup = new List <int>(); int groupsCount = ColonistBarUtility.GetVisibleGroupsCount(); for (int i = 0; i < groupsCount; i++) { horizontalSlotsPerGroup.Add(0); } GenMath.DHondtDistribution(horizontalSlotsPerGroup, (int i) => (float)entriesInGroup[i], maxPerGlobalRow); for (int i = 0; i < horizontalSlotsPerGroup.Count; i++) { if (horizontalSlotsPerGroup[i] == 0) { int num2 = horizontalSlotsPerGroup.Max(); if (num2 <= 1) { return(false); } int num3 = horizontalSlotsPerGroup.IndexOf(num2); List <int> list; // Not my fault int index; (list = horizontalSlotsPerGroup)[index = num3] = list[index] - 1; int index2; (list = horizontalSlotsPerGroup)[index2 = i] = list[index2] + 1; } } return(true); }
private bool TryDistributeHorizontalSlotsBetweenGroups(int maxPerGlobalRow) { int num = CalculateGroupsCount(); horizontalSlotsPerGroup.Clear(); for (int j = 0; j < num; j++) { horizontalSlotsPerGroup.Add(0); } GenMath.DHondtDistribution(horizontalSlotsPerGroup, (int i) => entriesInGroup[i], maxPerGlobalRow); for (int k = 0; k < horizontalSlotsPerGroup.Count; k++) { if (horizontalSlotsPerGroup[k] == 0) { int num2 = horizontalSlotsPerGroup.Max(); if (num2 <= 1) { return(false); } int index = horizontalSlotsPerGroup.IndexOf(num2); horizontalSlotsPerGroup[index]--; horizontalSlotsPerGroup[k]++; } } return(true); }
// RimWorld.ColonistBarDrawLocsFinder private static bool TryDistributeHorizontalSlotsBetweenGroups(int maxPerGlobalRow) { int num = CalculateGroupsCount(); horizontalSlotsPerGroup.Clear(); for (int k = 0; k < num; k++) { horizontalSlotsPerGroup.Add(0); } GenMath.DHondtDistribution(horizontalSlotsPerGroup, (int i) => (float)entriesInGroup[i], maxPerGlobalRow); for (int j = 0; j < horizontalSlotsPerGroup.Count; j++) { if (horizontalSlotsPerGroup[j] == 0) { int num2 = horizontalSlotsPerGroup.Max(); if (num2 <= 1) { return(false); } int num3 = horizontalSlotsPerGroup.IndexOf(num2); List <int> list; List <int> expr_89 = list = horizontalSlotsPerGroup; int num4; int expr_8E = num4 = num3; num4 = list[num4]; expr_89[expr_8E] = num4 - 1; List <int> list2; List <int> expr_AB = list2 = horizontalSlotsPerGroup; int expr_AF = num4 = j; num4 = list2[num4]; expr_AB[expr_AF] = num4 + 1; } } return(true); }
private bool TryDistributeHorizontalSlotsBetweenGroups(int maxPerGlobalRow) { int groupsCount = this.CalculateGroupsCount(); this._horizontalSlotsPerGroup.Clear(); for (int k = 0; k < groupsCount; k++) { this._horizontalSlotsPerGroup.Add(0); } GenMath.DHondtDistribution(this._horizontalSlotsPerGroup, i => (float)this._entriesInGroup[i], maxPerGlobalRow); for (int j = 0; j < this._horizontalSlotsPerGroup.Count; j++) { if (this._horizontalSlotsPerGroup[j] == 0) { int maxSlots = this._horizontalSlotsPerGroup.Max(); if (maxSlots <= 1) { return(false); } int num3 = this._horizontalSlotsPerGroup.IndexOf(maxSlots); List <int> list; List <int> listInt = list = this._horizontalSlotsPerGroup; int num4; int index = num4 = num3; num4 = list[num4]; listInt[index] = num4 - 1; List <int> list2; List <int> slots = list2 = this._horizontalSlotsPerGroup; int integerK = num4 = j; num4 = list2[num4]; slots[integerK] = num4 + 1; } } return(true); }