private static int <ThingsLabel> m__0(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
        {
            int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);

            if (num != 0)
            {
                return(num);
            }
            return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
        }
示例#2
0
        public static string ThingsLabel(List <ThingCount> things, string prefix = "  - ")
        {
            GenLabel.tmpThingsLabelElements.Clear();
            foreach (ThingCount thing in things)
            {
                GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements
                                                      where thing.Thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.Thing.def && elem.thingTemplate.Stuff == thing.Thing.Stuff
                                                      select elem).FirstOrDefault <GenLabel.LabelElement>();
                if (labelElement != null)
                {
                    labelElement.count += thing.Count;
                }
                else
                {
                    GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement
                    {
                        thingTemplate = thing.Thing,
                        count         = thing.Count
                    });
                }
            }
            GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
            {
                int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);
                if (num != 0)
                {
                    return(num);
                }
                return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
            });
            StringBuilder stringBuilder = new StringBuilder();

            foreach (GenLabel.LabelElement current in GenLabel.tmpThingsLabelElements)
            {
                string str = string.Empty;
                if (current.thingTemplate.ParentHolder is Pawn_ApparelTracker)
                {
                    str = " (" + "WornBy".Translate(((Pawn)current.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)current.thingTemplate.ParentHolder.ParentHolder) + ")";
                }
                else if (current.thingTemplate.ParentHolder is Pawn_EquipmentTracker)
                {
                    str = " (" + "EquippedBy".Translate(((Pawn)current.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)current.thingTemplate.ParentHolder.ParentHolder) + ")";
                }
                if (current.count == 1)
                {
                    stringBuilder.AppendLine(prefix + current.thingTemplate.LabelCap + str);
                }
                else
                {
                    stringBuilder.AppendLine(prefix + GenLabel.ThingLabel(current.thingTemplate.def, current.thingTemplate.Stuff, current.count).CapitalizeFirst() + str);
                }
            }
            GenLabel.tmpThingsLabelElements.Clear();
            return(stringBuilder.ToString().TrimEndNewlines());
        }
 internal bool <> m__0(GenLabel.LabelElement elem)
 {
     return(this.thing.Thing.def.stackLimit > 1 && elem.thingTemplate.def == this.thing.Thing.def && elem.thingTemplate.Stuff == this.thing.Thing.Stuff);
 }
示例#4
0
        public static string ThingsLabel(List <Thing> things)
        {
            GenLabel.tmpThingsLabelElements.Clear();
            using (List <Thing> .Enumerator enumerator = things.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Thing thing = enumerator.Current;
                    GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements
                                                          where thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.def && elem.thingTemplate.Stuff == thing.Stuff
                                                          select elem).FirstOrDefault <GenLabel.LabelElement>();
                    if (labelElement != null)
                    {
                        labelElement.count += thing.stackCount;
                    }
                    else
                    {
                        GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement
                        {
                            thingTemplate = thing,
                            count         = thing.stackCount
                        });
                    }
                }
            }
            GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
            {
                int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);
                int result;
                if (num != 0)
                {
                    result = num;
                }
                else
                {
                    result = lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue);
                }
                return(result);
            });
            StringBuilder stringBuilder = new StringBuilder();

            foreach (GenLabel.LabelElement labelElement2 in GenLabel.tmpThingsLabelElements)
            {
                string str = "";
                if (labelElement2.thingTemplate.ParentHolder is Pawn_ApparelTracker)
                {
                    str = " (" + "WornBy".Translate(new object[]
                    {
                        (labelElement2.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort
                    }) + ")";
                }
                else if (labelElement2.thingTemplate.ParentHolder is Pawn_EquipmentTracker)
                {
                    str = " (" + "EquippedBy".Translate(new object[]
                    {
                        (labelElement2.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort
                    }) + ")";
                }
                if (labelElement2.count == 1)
                {
                    stringBuilder.AppendLine("  " + labelElement2.thingTemplate.LabelCap + str);
                }
                else
                {
                    stringBuilder.AppendLine("  " + GenLabel.ThingLabel(labelElement2.thingTemplate.def, labelElement2.thingTemplate.Stuff, labelElement2.count).CapitalizeFirst() + str);
                }
            }
            GenLabel.tmpThingsLabelElements.Clear();
            return(stringBuilder.ToString());
        }