/* InventoryCountDefs * If the ThingDef is minifiable, search the container for how many minified objects are contained. * fallback to TotalStackCountOfDef for non-minifiable things. */ private int InventoryCountDefs(ThingContainer container, ThingDef def) { int count = 0; if (def.Minifiable) { count = container.Count(t => t.GetInnerIfMinified().def == def); } else { count = container.TotalStackCountOfDef(def); } return(count); }