} // end TimeStoringTakes public List <Thing> getContentsHeader(out string header, out string tooltip) { listOfStoredItems.Clear(); headerStringB.Length = 0; tooltip = null; // TODO: add more information via tooltip for DSUs with minNumStacks above 2 var flagUseStackInsteadOfItem = false; // "3/4 Items" vs "3/4 Stacks" var numCells = 0; float itemsTotalMass = 0; // or Bulk for CE ;p var cellsBelowMin = 0; var cellsAtAboveMin = 0; foreach (var storageCell in (parent as Building_Storage).AllSlotCells()) { var countInThisCell = 0; numCells++; foreach (var t in parent.Map.thingGrid.ThingsListAt(storageCell)) { if (t.Spawned && t.def.EverStorable(false)) { listOfStoredItems.Add(t); itemsTotalMass += t.GetStatValue(stat) * t.stackCount; if (t.def.stackLimit > 1) { flagUseStackInsteadOfItem = true; } countInThisCell++; } } if (countInThisCell >= minNumberStacks) { cellsAtAboveMin++; } else { cellsBelowMin++; } } // We want to give user inforation about mass limits and how close we are, if they exist // TODO: Maybe use prop's kg() to translate everywhere, for better readability if using // bulk. Or maybe just leave it as is; CE will live. if (limitingTotalFactorForCell > 0f) { // If minNumberStacks > 2, this really really complicates things. // For example, if one cell has 1 SUPER HEAVY item in it, and the other cell has 7 light items... // What do we say? It's over the total mass limit....but each cell can get more things! if (minNumberStacks > 2) { // Easy case: if each cell has at least minimum number of stacks: // TODO: if min is 5 and there are 4 with below mass limit, also go here: if (cellsAtAboveMin == numCells) { //////////////// NO cells below minimum // Simple header that includes mass: 12/20 stacks with total mass of 2.3/5 - as below headerStringB.Append("LWM.ContentsHeaderMaxMass".Translate(listOfStoredItems.Count, // 3 stacks or 3 items: (flagUseStackInsteadOfItem ? "LWM.XStacks" : "LWM.XItems").Translate(maxNumberStacks * numCells), stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"), (limitingTotalFactorForCell * numCells).ToString("0.##"))); } else if (cellsBelowMin == numCells) { ///////////// ALL cells below minimum // 3/10 items, max 20, with total mass 0.45 headerStringB.Append("LWM.ContentsHeaderMinMax".Translate(listOfStoredItems.Count, (flagUseStackInsteadOfItem ? "LWM.XStacks" : "LWM.XItems").Translate(minNumberStacks * numCells), maxNumberStacks * numCells, stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"))); } else { ////////////////////////////////////////// SOME cells are below the minimum if (flagUseStackInsteadOfItem) // 11 stacks, max 20, limited with total mass 8.2 { headerStringB.Append("LWM.ContentsHeaderStacksMax".Translate(listOfStoredItems.Count, maxNumberStacks * numCells, stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"))); } else { headerStringB.Append("LWM.ContentsHeaderItemsMax".Translate(listOfStoredItems.Count, maxNumberStacks * numCells, stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"))); } } } else { // Simple header that includes mass: 4/8 stacks with total mass of 12/20 headerStringB.Append("LWM.ContentsHeaderMaxMass".Translate(listOfStoredItems.Count, (flagUseStackInsteadOfItem ? "LWM.XStacks" : "LWM.XItems").Translate(maxNumberStacks * numCells), stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"), (limitingTotalFactorForCell * numCells).ToString("0.##"))); } } else { // No limiting mass factor per cell // 4/8 stacks with total mass of 12kg headerStringB.Append("LWM.ContentsHeaderMax".Translate(listOfStoredItems.Count, // 3 stacks or 3 items: (flagUseStackInsteadOfItem ? "LWM.XStacks" : "LWM.XItems").Translate(maxNumberStacks * numCells), stat.ToString().ToLower(), itemsTotalMass.ToString("0.##"))); } ///////////////////////////// Max mass per item? if (limitingFactorForItem > 0f) // (Cannot store items above mass of X kg) { headerStringB.Append('\n').Append("LWM.ContentsHeaderMaxSize".Translate( stat.ToString().ToLower(), limitingFactorForItem.ToString("0.##"))); } AddPawnReservationsHeader((Building_Storage)parent); // seriously, don't add this comp to anything else. header = headerStringB.ToString(); return(listOfStoredItems); }